ReceiptController.php 566 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287
  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. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. private function _itineraryDateMin(){
  58. Doo::loadModel ( "itinerary" );
  59. $itinerary = new itinerary ();
  60. $itineraryDetail=$itinerary->getOne(array (
  61. 'where'=>'sid ='.$this->staff [0] ['sid'],
  62. 'desc'=>'itineraryDate',
  63. 'asArray' => true
  64. ));
  65. return date("Y-m-d",strtotime("+1 day",strtotime($itineraryDetail['itineraryDate'])));
  66. }
  67. public function beforeRun($resource, $action) {
  68. Doo::loadClass ( 'XDeode' );
  69. $XDeode = new XDeode ( 5 );
  70. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  71. // 单独判断公司汇总的访问权限
  72. if ($action == 'companyCategoryCollect') {
  73. Doo::loadModel ( "receiptAuthorityManage" );
  74. $invoiceCompanyManage = new receiptAuthorityManage ();
  75. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  76. if (empty ( $icm ))
  77. die ( 'illegal request-statistics' );
  78. }
  79. Doo::loadModel ( 'staff' );
  80. $staff = new staff ();
  81. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  82. $accessModular = 'RECEIPTS';
  83. if (empty ( $detail ['cldAccessArray'] ))
  84. die ( 'illegal request' );
  85. else {
  86. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  87. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  88. $flag = true;
  89. } else {
  90. $flag = false;
  91. }
  92. } else {
  93. die ( 'illegal request' );
  94. }
  95. }
  96. if (! $flag)
  97. die ( 'illegal request' );
  98. }
  99. function __construct() {
  100. if (isset ( $_COOKIE ["staff"] )) {
  101. if (! empty ( $_COOKIE ["staff"] )) {
  102. Doo::loadModel ( 'staff' );
  103. Doo::loadModel ( 'verify' );
  104. $verify = new verify ();
  105. $staff = new staff ();
  106. Doo::loadModel ( "execute" );
  107. $execute = new execute ();
  108. $verifyList = $verify->find ( array (
  109. 'select' => 'staff',
  110. 'asArray' => true
  111. ) );
  112. $list = array ();
  113. // 判断角色的审批权限
  114. foreach ( $verifyList as $key => $value ) {
  115. $ver = json_decode ( $value ['staff'] );
  116. foreach ( $ver as $k => $v ) {
  117. if ($v [1] == 'ROLE') {
  118. $roleList = json_decode ( $v [3] );
  119. foreach ( $roleList as $t => $g ) {
  120. $gList = explode ( "_", $g );
  121. array_push ( $list, $gList [0] );
  122. // print_r($list);
  123. }
  124. } else
  125. array_push ( $list, $v [0] );
  126. }
  127. }
  128. // 判断执行人的审批权限
  129. $executeList = $execute->find ( array (
  130. 'where'=>'mold !="日常收支"',
  131. 'select' => 'staff',
  132. 'asArray' => true
  133. ) );
  134. $list2 = array ();
  135. foreach ( $executeList as $key => $value ) {
  136. $ver = json_decode ( $value ['staff'] );
  137. foreach ( $ver as $k => $v ) {
  138. array_push ( $list2, $v [0] );
  139. }
  140. }
  141. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  142. $eidList = array_filter ( explode ( ",", $eidList ) );
  143. $this->executeId = array_merge ( $list2, $eidList );
  144. //print_r($this->executeId);
  145. $this->verifyId = $list;
  146. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  147. // 检测用户信息完成
  148. $this->data ['isStaffCompleteMsg'] = false;
  149. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  150. if (! empty ( $detail ))
  151. $this->data ['isStaffCompleteMsg'] = true;
  152. return "/";
  153. }
  154. }
  155. Doo::loadCore ( 'uri/DooUriRouter' );
  156. $router = new DooUriRouter ();
  157. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  158. if ($routeRs ['1'] != "login") {
  159. header ( 'Content-Type:text/html;charset=utf-8' );
  160. @header ( "Location: /login" );
  161. }
  162. }
  163. /**
  164. * 费用首页
  165. */
  166. function saeaBorad() {
  167. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  168. Doo::loadModel ( 'receipt' );
  169. $receipt = new receipt ();
  170. Doo::loadModel ( 'verify' );
  171. $verify = new verify ();
  172. Doo::loadModel ( 'L_category' );
  173. $lCategory = new L_category ();
  174. Doo::loadModel ( "role" );
  175. $role = new role ();
  176. Doo::loadModel ( "receiptLog" );
  177. $receiptLog = new receiptLog ();
  178. Doo::loadModel ( 'accountItem' );
  179. $accountItem = new accountItem ();
  180. Doo::loadClass ( 'XDeode' );
  181. $XDeode = new XDeode ( 7 );
  182. $XDeode9 = new XDeode ( 9 );
  183. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  184. $receiptDetail = $receipt->find ( array (
  185. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  186. 'desc' => 'rid',
  187. 'asArray' => true
  188. ) );
  189. foreach ( $receiptDetail as $key => $value ) {
  190. $receiptDetail [$key] ['receiptId'] = $XDeode9->encode ( $value ['rid'] );
  191. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  192. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  193. $veList = $verify->getOne ( array (
  194. 'where' => 'vid=' . $value ['verify'],
  195. 'asArray' => true
  196. ) );
  197. $v = json_decode ( $veList ['staff'] );
  198. array_push ( $v [0], $veList ['description'] );
  199. foreach ( $v as $n => $m ) {
  200. if ($m ['1'] == 'ROLE') {
  201. $roleInfo = $role->getOne ( array (
  202. 'where' => 'rid=' . $m [0],
  203. 'asArray' => true
  204. ) );
  205. $v [$n] [1] = $roleInfo ['name'];
  206. }
  207. }
  208. $receiptDetail [$key] ['staff'] = $v;
  209. $category = $lCategory->getOne ( array (
  210. 'where' => 'cid=' . $value ['cid'],
  211. 'asArray' => true
  212. ) );
  213. $receiptDetail [$key] ['category'] = $category ['title'];
  214. }
  215. // print_r($receiptLogList);
  216. Doo::loadModel ( 'RAssist' );
  217. $RAssist = new RAssist ();
  218. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  219. //费用项目
  220. $acItem = $accountItem->find ( array ('asArray' => true) );
  221. if ($travel=='success'){
  222. $data ['travel'] =true;
  223. }else{
  224. $data ['travel'] =false;
  225. }
  226. $data ['acItem'] = $acItem;
  227. $data ['receiptExtendList'] = $receiptExtendList;
  228. $data ['receiptLogList'] = $receiptLogList;
  229. $data ['receiptDetail'] = $receiptDetail;
  230. $data ['memu'] = "receipt";
  231. $data ['staff'] = $this->staff;
  232. $data ['receiptMemu'] = 'saeaBorad';
  233. $data ['verifyId'] = $this->verifyId;
  234. $data ['executeId'] = $this->executeId;
  235. $this->render ( "/receipt/receiptFee", $data );
  236. }
  237. /**
  238. * 费用报销单-导流入哪个细分类
  239. */
  240. function receiptFeeDiversion(){
  241. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  242. if($feeType==2){
  243. return '/receipt/feeTravel';
  244. }elseif($feeType==3){
  245. return '/receipt/feeInternalTrain';
  246. }else{
  247. return '/receipt/feeAgency';
  248. }
  249. }
  250. private function _feeData(){
  251. Doo::loadModel ( 'L_category' );
  252. $lCategory = new L_category ();
  253. Doo::loadModel ( 'verify' );
  254. $verify = new verify ();
  255. Doo::loadModel ( 'accountItem' );
  256. $accountItem = new accountItem ();
  257. Doo::loadModel ( "role" );
  258. $role = new role ();
  259. $acItem = $accountItem->find ( array (
  260. 'asArray' => true
  261. ) );
  262. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  263. $data ['category'] = $lCategory->find ( array (
  264. 'asArray' => true
  265. ) );
  266. $data ['itineraryDate'] = $this->_itineraryDateMin();
  267. $data ['veList'] = $veList;
  268. $data ['acItem'] = $acItem;
  269. $data ['memu'] = "receipt";
  270. $data ['staff'] = $this->staff;
  271. $data ['receiptMemu'] = 'saeaBorad';
  272. $data ['verifyId'] = $this->verifyId;
  273. $data ['executeId'] = $this->executeId;
  274. return $data;
  275. }
  276. /**
  277. * 办事处相关费用
  278. */
  279. function feeAgency(){
  280. $data=$this->_feeData();
  281. $this->render ( "/receipt/feeAgency", $data );
  282. }
  283. /**
  284. * 办事处
  285. */
  286. function feeTravel(){
  287. $data=$this->_feeData();
  288. $this->render ( "/receipt/feeTravel", $data );
  289. }
  290. function feeInternalTrain(){
  291. $data=$this->_feeData();
  292. $this->render ( "/receipt/feeInternalTrain", $data );
  293. }
  294. /**
  295. * 添加费用报销单页面
  296. */
  297. function saeaCreate() {
  298. Doo::loadModel ( 'accountItem' );
  299. Doo::loadModel ( 'verify' );
  300. Doo::loadModel ( 'receipt' );
  301. Doo::loadModel ( 'L_category' );
  302. $lCategory = new L_category ();
  303. $receipt = new receipt ();
  304. $verify = new verify ();
  305. $accountItem = new accountItem ();
  306. Doo::loadModel ( "role" );
  307. $role = new role ();
  308. $acItem = $accountItem->find ( array (
  309. 'asArray' => true
  310. ) );
  311. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  312. $data ['category'] = $lCategory->find ( array (
  313. 'asArray' => true
  314. ) );
  315. $data ['veList'] = $veList;
  316. $data ['acItem'] = $acItem;
  317. $data ['memu'] = "receipt";
  318. $data ['staff'] = $this->staff;
  319. $data ['receiptMemu'] = 'saeaBorad';
  320. $data ['verifyId'] = $this->verifyId;
  321. $data ['executeId'] = $this->executeId;
  322. $this->render ( "/admin/saea_create", $data );
  323. }
  324. private function _storageItinerary($itinerary,$rid,$version=2){
  325. $itineraryJson=json_decode($itinerary,true);
  326. Doo::loadModel ( 'itinerary' );
  327. $itinerary = new itinerary ();
  328. $itinerary->delete(array('where' => 'rid=' . $rid ));
  329. if($version==2){
  330. foreach ($itineraryJson as $k=>$v){
  331. foreach ($v as $kk=>$vv){
  332. foreach ($vv as $key=>$value){
  333. if($key==0){
  334. $feeTraveItem=json_encode($value['feeTraveItem']);
  335. $itinerary = new itinerary ();
  336. $itinerary->rid=$rid;
  337. $itinerary->sid=$this->staff [0] ['sid'];
  338. $itinerary->itineraryDate=$value['departuredate'];
  339. $itinerary->itineraryCity=$value['departurecity'];
  340. $itinerary->feeTraveItem='';
  341. $itinerary->itineraryIndex=0;
  342. $itinerary->insert ();
  343. $itinerary = new itinerary ();
  344. $itinerary->rid=$rid;
  345. $itinerary->sid=$this->staff [0] ['sid'];
  346. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  347. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  348. $itinerary->feeTraveItem=$feeTraveItem;
  349. $itinerary->itineraryIndex=1;
  350. $itinerary->insert ();
  351. }else{
  352. $feeTraveItem=json_encode($value['feeTraveItem']);
  353. $itinerary = new itinerary ();
  354. $itinerary->rid=$rid;
  355. $itinerary->sid=$this->staff [0] ['sid'];
  356. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  357. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  358. $itinerary->feeTraveItem=$feeTraveItem;
  359. $itinerary->itineraryIndex=$key+1;
  360. $itinerary->insert ();
  361. }
  362. }
  363. }
  364. }
  365. }elseif($version==1){
  366. foreach ($itineraryJson as $key=>$value){
  367. if($key==0){
  368. $feeTraveItem=json_encode($value['feeTraveItem']);
  369. $itinerary = new itinerary ();
  370. $itinerary->rid=$rid;
  371. $itinerary->sid=$this->staff [0] ['sid'];
  372. $itinerary->itineraryDate=$value['departuredate'];
  373. $itinerary->itineraryCity=$value['departurecity'];
  374. $itinerary->feeTraveItem='';
  375. $itinerary->itineraryIndex=0;
  376. $itinerary->insert ();
  377. $itinerary = new itinerary ();
  378. $itinerary->rid=$rid;
  379. $itinerary->sid=$this->staff [0] ['sid'];
  380. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  381. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  382. $itinerary->feeTraveItem=$feeTraveItem;
  383. $itinerary->itineraryIndex=1;
  384. $itinerary->insert ();
  385. }else{
  386. $feeTraveItem=json_encode($value['feeTraveItem']);
  387. $itinerary = new itinerary ();
  388. $itinerary->rid=$rid;
  389. $itinerary->sid=$this->staff [0] ['sid'];
  390. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  391. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  392. $itinerary->feeTraveItem=$feeTraveItem;
  393. $itinerary->itineraryIndex=$key+1;
  394. $itinerary->insert ();
  395. }
  396. }
  397. }else{
  398. die ( '行程单版本不正确' );
  399. }
  400. }
  401. private function _verificationItinerary($itinerary){
  402. Doo::loadModel ( 'itinerary' );
  403. $itineraryObj = new itinerary ();
  404. if(empty($itinerary)){
  405. header ( 'Content-Type:text/html;charset=utf-8' );
  406. die ( '请填写行程单' );
  407. }
  408. $itineraryJson=json_decode($itinerary,true);
  409. foreach ($itineraryJson as $k=>$v){
  410. foreach ($v as $kk=>$vv){
  411. foreach ($vv as $key=>$value){
  412. if(empty($value['departuredate'])||empty($value['arrivalsdate'])){
  413. header ( 'Content-Type:text/html;charset=utf-8' );
  414. die ( '有行程的日期未设置' );
  415. }
  416. }
  417. }
  418. }
  419. $itineraryDate=array();$sql=array();
  420. foreach ($itineraryJson as $k=>$v){
  421. foreach ($v as $kk=>$vv){
  422. foreach ($vv as $key=>$value){
  423. if($key==0){
  424. array_push($itineraryDate, $value['departuredate']);
  425. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  426. array_push($sql,'?');array_push($sql,'?');
  427. }else{
  428. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  429. array_push($sql,'?');
  430. }
  431. }
  432. }
  433. }
  434. array_push($itineraryDate, $this->staff [0] ['sid']);
  435. $sql=implode(',',$sql);
  436. // $itineraryDate=array();$sql=array();
  437. // foreach ($itineraryJson as $key=>$value){
  438. // if($key==0){
  439. // array_push($itineraryDate, $value['departuredate']);
  440. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  441. // array_push($sql,'?');array_push($sql,'?');
  442. // }else{
  443. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  444. // array_push($sql,'?');
  445. // }
  446. // }
  447. // array_push($itineraryDate, $this->staff [0] ['sid']);
  448. // $sql=implode(',',$sql);
  449. if(empty($sql)){
  450. header ( 'Content-Type:text/html;charset=utf-8' );
  451. die ( '请填写行程单-2' );
  452. }
  453. $qualification=array(
  454. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  455. 'param' => $itineraryDate,
  456. 'asArray' => TRUE);
  457. $itDateList=$itineraryObj->find($qualification);
  458. if(empty($itDateList)){
  459. return false;
  460. }else{
  461. return true;
  462. }
  463. }
  464. private function _buildFeeData($receiptClass=1,$itinerary=''){
  465. $agency = $this->get_args ( 'agency' );
  466. $travel = $this->get_args ( 'travel' );
  467. $train = $this->get_args ( 'train' );
  468. $other = $this->get_args ( 'other' );
  469. $inttrain = $this->get_args ( 'inttrain' );
  470. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  471. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  472. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  473. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  474. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  475. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  476. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  477. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  478. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  479. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  480. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  481. header ( 'Content-Type:text/html;charset=utf-8' );
  482. die ( '请填写联行号' );
  483. }
  484. if($receiptClass==2){
  485. //TODO 日期检测
  486. if($this->_verificationItinerary($itinerary)){
  487. header ( 'Content-Type:text/html;charset=utf-8' );
  488. die ( '已申请过类此日期的行程' );
  489. }
  490. }
  491. $itinerary=str_replace('\n','<br/>',$itinerary);
  492. Doo::loadModel ( 'receipt' );
  493. Doo::loadModel ( 'receiptDetail' );
  494. Doo::loadModel ( 'accountItem' );
  495. $accountItem = new accountItem ();
  496. $receipt = new receipt ();
  497. Doo::loadModel ( 'enclosur' );
  498. Doo::loadModel ( 'execute' );
  499. $execute = new execute ();
  500. $executeDetail = $execute->getOne ( array (
  501. 'where' => 'mold="报销单执行人"',
  502. 'asArray' => true
  503. ) );
  504. $aItem = $accountItem->find ( array (
  505. 'asArray' => true
  506. ) );
  507. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  508. $ag = $tr = $ta = $ot= $it = 0;
  509. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  510. foreach ( $aItem as $key => $value ) {
  511. if ($value ['category'] == $this->AGENCY) {
  512. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  513. array_push ( $accountJson [$this->AGENCY], array (
  514. 'aid' => $value ['aid'],
  515. 'name' => $value ['name'],
  516. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  517. ) );
  518. $sum += $agency [$ag];
  519. $agencySum += $agency [$ag];
  520. }
  521. $ag ++;
  522. }
  523. if ($value ['category'] == $this->TRAVEL) {
  524. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  525. array_push ( $accountJson [$this->TRAVEL], array (
  526. 'aid' => $value ['aid'],
  527. 'name' => $value ['name'],
  528. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  529. ) );
  530. $sum += $travel [$tr];
  531. $travelSum += $travel [$tr];
  532. }
  533. $tr ++;
  534. }
  535. if ($value ['category'] == $this->TRAIN) {
  536. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  537. array_push ( $accountJson [$this->TRAIN], array (
  538. 'aid' => $value ['aid'],
  539. 'name' => $value ['name'],
  540. 'price' => number_format ( $train [$ta], 2, '.', '' )
  541. ) );
  542. $sum += $train [$ta];
  543. $trainSum += $train [$ta];
  544. }
  545. $ta ++;
  546. }
  547. if ($value ['category'] == $this->INTTRAIN) {
  548. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  549. array_push ( $accountJson [$this->INTTRAIN], array (
  550. 'aid' => $value ['aid'],
  551. 'name' => $value ['name'],
  552. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  553. ) );
  554. $sum += $inttrain [$it];
  555. $inttrainSum += $inttrain [$it];
  556. }
  557. $it ++;
  558. }
  559. if ($value ['category'] == $this->OTHER) {
  560. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  561. array_push ( $accountJson [$this->OTHER], array (
  562. 'aid' => $value ['aid'],
  563. 'name' => $value ['name'],
  564. 'price' => number_format ( $other [$ot], 2, '.', '' )
  565. ) );
  566. $sum += $other [$ot];
  567. $otherSum += $other [$ot];
  568. }
  569. $ot ++;
  570. }
  571. }
  572. $accountJson ['cSum'] = array (
  573. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  574. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  575. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  576. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  577. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  578. );
  579. // 报销单
  580. $receipt->accountItem = json_encode ( $accountJson );
  581. $receipt->staff = $this->staff [0] ['sid'];
  582. $receipt->sum = number_format ( $sum, 2, '.', '' );
  583. $receipt->date = date ( "Y-m-d" );
  584. $receipt->cid = $cid;
  585. $receipt->status = 5;
  586. // 修改审批流程加入角色
  587. $receipt->verify = $verify;
  588. $receipt->executeCopy = $executeDetail ['staff'];
  589. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  590. $order = array (
  591. "\r\n",
  592. "\n",
  593. "\r"
  594. );
  595. $replace = '<br/>';
  596. $explanation = str_replace ( $order, $replace, $explanation );
  597. $receipt->explanation = $explanation;
  598. $receipt->receiptClass = $receiptClass;
  599. $receipt->itinerary2=$itinerary;
  600. $receipt->remittanceName = $remittanceName;
  601. $receipt->bankName = $bankName;
  602. $receipt->bankNumber = $bankNumber;
  603. $receipt->remittanceBankType = $remittanceBankType;
  604. if ($remittanceBankType == 1) {
  605. $receipt->coupletNumber = $coupletNumber;
  606. }
  607. $rid = $receipt->insert ();
  608. //记录行程单
  609. $this->_storageItinerary($itinerary,$rid);
  610. // 附件
  611. if (! empty ( $enclosurName )) {
  612. $enclosurArray = explode ( '-', $enclosurName );
  613. foreach ( $enclosurArray as $value ) {
  614. $enclosur = new enclosur ();
  615. $enclosur->name = $value;
  616. $enclosur->rid = $rid;
  617. $enclosur->insert ();
  618. }
  619. }
  620. // 报销详情
  621. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  622. $receiptDetail = new receiptDetail ();
  623. $receiptDetail->staff = $this->staff [0] ['sid'];
  624. $receiptDetail->item = $value ['name'];
  625. $receiptDetail->itemCategory = $this->AGENCY;
  626. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  627. $receiptDetail->date = date ( "Y-m-d" );
  628. $receiptDetail->cid = $cid;
  629. $receiptDetail->rid = $rid;
  630. $receiptDetail->status = 4;
  631. $receiptDetail->insert ();
  632. }
  633. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  634. $receiptDetail = new receiptDetail ();
  635. $receiptDetail->staff = $this->staff [0] ['sid'];
  636. $receiptDetail->item = $value ['name'];
  637. $receiptDetail->itemCategory = $this->TRAVEL;
  638. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  639. $receiptDetail->date = date ( "Y-m-d" );
  640. $receiptDetail->cid = $cid;
  641. $receiptDetail->rid = $rid;
  642. $receiptDetail->status = 4;
  643. $receiptDetail->insert ();
  644. }
  645. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  646. $receiptDetail = new receiptDetail ();
  647. $receiptDetail->staff = $this->staff [0] ['sid'];
  648. $receiptDetail->item = $value ['name'];
  649. $receiptDetail->itemCategory = $this->TRAIN;
  650. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  651. $receiptDetail->date = date ( "Y-m-d" );
  652. $receiptDetail->cid = $cid;
  653. $receiptDetail->rid = $rid;
  654. $receiptDetail->status = 4;
  655. $receiptDetail->insert ();
  656. }
  657. // 内训
  658. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  659. $receiptDetail = new receiptDetail ();
  660. $receiptDetail->staff = $this->staff [0] ['sid'];
  661. $receiptDetail->item = $value ['name'];
  662. $receiptDetail->itemCategory = $this->INTTRAIN;
  663. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  664. $receiptDetail->date = date ( "Y-m-d" );
  665. $receiptDetail->cid = $cid;
  666. $receiptDetail->rid = $rid;
  667. $receiptDetail->status = 4;
  668. $receiptDetail->insert ();
  669. }
  670. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  671. $receiptDetail = new receiptDetail ();
  672. $receiptDetail->staff = $this->staff [0] ['sid'];
  673. $receiptDetail->item = $value ['name'];
  674. $receiptDetail->itemCategory = $this->OTHER;
  675. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  676. $receiptDetail->date = date ( "Y-m-d" );
  677. $receiptDetail->cid = $cid;
  678. $receiptDetail->rid = $rid;
  679. $receiptDetail->status = 4;
  680. $receiptDetail->insert ();
  681. }
  682. return true;
  683. } else
  684. return false;
  685. }
  686. function addReceipt() {
  687. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  688. if ($this->_buildFeeData(1)) {
  689. return "/saeaBorad";
  690. } else{
  691. die ( 'illegal request' );
  692. }
  693. }
  694. function addFeeTravel(){
  695. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  696. $itineraryList=json_decode($itinerary,true);
  697. // foreach ($itineraryList as $key=>$value){
  698. // if(empty($value['departuredate'])||empty($value['departurecity'])){
  699. // header ( 'Content-Type:text/html;charset=utf-8' );
  700. // die ( '请设置出发地和出发日期' );
  701. // }
  702. // }
  703. if ($this->_buildFeeData(2,$itinerary)) {
  704. return "/saeaBorad?travel=success";
  705. } else{
  706. die ( 'illegal request' );
  707. }
  708. }
  709. function addFeeInternalTrain(){
  710. if ($this->_buildFeeData(3)) {
  711. return "/saeaBorad";
  712. } else{
  713. die ( 'illegal request' );
  714. }
  715. }
  716. function referReceipt() {
  717. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  718. Doo::loadModel ( 'receipt' );
  719. Doo::loadModel ( 'verify' );
  720. $verify = new verify ();
  721. $receipt = new receipt ();
  722. Doo::loadModel ( 'L_category' );
  723. $lCategory = new L_category ();
  724. Doo::loadModel ( "role" );
  725. $role = new role ();
  726. $receiptDetail = $receipt->find ( array (
  727. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  728. 'asArray' => true
  729. ) );
  730. if (empty ( $receiptDetail ))
  731. return "/addReceipt";
  732. foreach ( $receiptDetail as $key => $value ) {
  733. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  734. $veList = $verify->getOne ( array (
  735. 'where' => 'vid=' . $value ['verify'],
  736. 'asArray' => true
  737. ) );
  738. $v = json_decode ( $veList ['staff'] );
  739. array_push ( $v [0], $veList ['description'] );
  740. foreach ( $v as $n => $m ) {
  741. if ($m ['1'] == 'ROLE') {
  742. $roleInfo = $role->getOne ( array (
  743. 'where' => 'rid=' . $m [0],
  744. 'asArray' => true
  745. ) );
  746. $v [$n] [1] = $roleInfo ['name'];
  747. }
  748. }
  749. $receiptDetail [$key] ['staff'] = $v;
  750. $category = $lCategory->getOne ( array (
  751. 'where' => 'cid=' . $value ['cid'],
  752. 'asArray' => true
  753. ) );
  754. $receiptDetail [$key] ['category'] = $category ['title'];
  755. }
  756. // print_r($receiptDetail);
  757. $data ['receiptDetail'] = $receiptDetail;
  758. $data ['memu'] = "receipt";
  759. $data ['staff'] = $this->staff;
  760. $data ['receiptMemu'] = 'saeaCreate';
  761. $data ['verifyId'] = $this->verifyId;
  762. $data ['executeId'] = $this->executeId;
  763. $this->render ( "/admin/saea_confirm", $data );
  764. }
  765. function editReceipt() {
  766. // edit status 4
  767. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  768. Doo::loadClass ( 'XDeode' );
  769. $XDeode = new XDeode ( 7 );
  770. $rid = $XDeode->decode ( $ridKey );
  771. if (empty ( $rid )) {
  772. die ( 'illegal request-id' );
  773. }
  774. // echo $rid.'sd';
  775. Doo::loadModel ( 'accountItem' );
  776. Doo::loadModel ( 'verify' );
  777. Doo::loadModel ( 'receipt' );
  778. $receipt = new receipt ();
  779. $verify = new verify ();
  780. $accountItem = new accountItem ();
  781. Doo::loadModel ( 'L_category' );
  782. $lCategory = new L_category ();
  783. Doo::loadModel ( "role" );
  784. $role = new role ();
  785. Doo::loadModel ( 'enclosur' );
  786. $enclosur = new enclosur ();
  787. $receiptDetail = $receipt->getOne ( array (
  788. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  789. 'asArray' => true
  790. ) );
  791. if (empty ( $receiptDetail )) {
  792. die ( 'illegal request-emptyData' );
  793. }
  794. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  795. $acItem = $accountItem->find ( array (
  796. 'asArray' => true
  797. ) );
  798. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  799. // 配置编辑信息
  800. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  801. foreach ( $acItem as $key => $value ) {
  802. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  803. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  804. $acItem [$key] ['price'] = $v ['price'];
  805. }
  806. }
  807. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  808. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  809. $acItem [$key] ['price'] = $v ['price'];
  810. }
  811. }
  812. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  813. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  814. $acItem [$key] ['price'] = $v ['price'];
  815. }
  816. }
  817. // 内训
  818. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  819. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  820. $acItem [$key] ['price'] = $v ['price'];
  821. }
  822. }
  823. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  824. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  825. $acItem [$key] ['price'] = $v ['price'];
  826. }
  827. }
  828. }
  829. //$receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  830. //nl2br($receiptDetail['explanation']);
  831. Doo::loadModel ( 'itinerary' );
  832. $itinerary = new itinerary ();
  833. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  834. $receiptDetail['explanation']= str_replace('<br/>',"\n",$receiptDetail['explanation']);
  835. $receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  836. $data ['category'] = $lCategory->find ( array (
  837. 'asArray' => true
  838. ) );
  839. $data ['cSum'] = $accountItemList ['cSum'];
  840. $data ['sum'] = $receiptDetail ['sum'];
  841. $data ['enclosurList'] = $enclosurList;
  842. $data ['receiptDetail'] = $receiptDetail;
  843. $data ['veList'] = $veList;
  844. $data ['acItem'] = $acItem;
  845. $data ['memu'] = "receipt";
  846. $data ['staff'] = $this->staff;
  847. $data ['receiptMemu'] = 'saeaBorad';
  848. $data ['verify'] = $receiptDetail ['verify'];
  849. $data ['verifyId'] = $this->verifyId;
  850. $data ['executeId'] = $this->executeId;
  851. $data ['rid'] = $ridKey;
  852. if($receiptDetail['receiptClass']==1){
  853. $this->render ( "/receipt/feeAgencyEdi", $data );
  854. }elseif($receiptDetail['receiptClass']==2){
  855. if(!empty($receiptDetail['itinerary2'])){
  856. //TODO 报销说明
  857. $this->render ( "/receipt/feeTravelEdi2", $data );
  858. }else{
  859. $this->render ( "/receipt/feeTravelEdi", $data );
  860. }
  861. }elseif($receiptDetail['receiptClass']==3){
  862. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  863. }else{
  864. $this->render ( "/admin/saea_edit", $data );
  865. //die ( 'illegal request-renderHtml' );
  866. }
  867. }
  868. function updateReceipt() {
  869. $agency = $this->get_args ( 'agency' );
  870. $travel = $this->get_args ( 'travel' );
  871. $train = $this->get_args ( 'train' );
  872. $other = $this->get_args ( 'other' );
  873. $inttrain = $this->get_args ( 'inttrain' );
  874. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  875. $traveVer = $this->get_args ( 'traveVer' ) ? $this->get_args ( 'traveVer' ) : "trave2";
  876. $itinerary = $_POST['itinerary'];
  877. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  878. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  879. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  880. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  881. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  882. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  883. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  884. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  885. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  886. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  887. Doo::loadClass ( 'XDeode' );
  888. $XDeode = new XDeode ( 7 );
  889. $rid = $XDeode->decode ( $ridKey );
  890. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  891. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  892. header ( 'Content-Type:text/html;charset=utf-8' );
  893. die ( '请填写联行号' );
  894. }
  895. if($traveVer!='trave1'){
  896. if($receiptClass=='trave'){
  897. //TODO 日期检测
  898. if($this->_verificationItinerary($itinerary)){
  899. header ( 'Content-Type:text/html;charset=utf-8' );
  900. die ( '已申请过类此日期的行程' );
  901. }
  902. }
  903. }
  904. Doo::loadModel ( 'receipt' );
  905. Doo::loadModel ( 'receiptDetail' );
  906. Doo::loadModel ( 'accountItem' );
  907. $accountItem = new accountItem ();
  908. $receipt = new receipt ();
  909. Doo::loadModel ( 'enclosur' );
  910. Doo::loadModel ( 'execute' );
  911. $execute = new execute ();
  912. $receiptDetail = $receipt->getOne ( array (
  913. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  914. 'asArray' => true
  915. ) );
  916. if (empty ( $receiptDetail )) {
  917. return "/saeaBorad";
  918. }
  919. //TODO 存储行程单-兼容旧版本的行程单
  920. $itinerary=str_replace('\n','<br/>',$itinerary);
  921. if(!empty($receiptDetail['itinerary2'])){
  922. $this->_storageItinerary($itinerary,$rid);
  923. }else{
  924. $this->_storageItinerary($itinerary,$rid,1);
  925. }
  926. if ($receiptDetail ['Rtype'] == 1) {
  927. $executeDetail = $execute->getOne ( array (
  928. 'where' => 'mold="借款费用执行人"',
  929. 'asArray' => true
  930. ) );
  931. } else {
  932. $executeDetail = $execute->getOne ( array (
  933. 'where' => 'mold="报销单执行人"',
  934. 'asArray' => true
  935. ) );
  936. }
  937. $aItem = $accountItem->find ( array (
  938. 'asArray' => true
  939. ) );
  940. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  941. $ag = $tr = $ta = $ot = $it = 0;
  942. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  943. foreach ( $aItem as $key => $value ) {
  944. if ($value ['category'] == $this->AGENCY) {
  945. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  946. array_push ( $accountJson [$this->AGENCY], array (
  947. 'aid' => $value ['aid'],
  948. 'name' => $value ['name'],
  949. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  950. ) );
  951. $sum += $agency [$ag];
  952. $agencySum += $agency [$ag];
  953. }
  954. $ag ++;
  955. }
  956. if ($value ['category'] == $this->TRAVEL) {
  957. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  958. array_push ( $accountJson [$this->TRAVEL], array (
  959. 'aid' => $value ['aid'],
  960. 'name' => $value ['name'],
  961. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  962. ) );
  963. $sum += $travel [$tr];
  964. $travelSum += $travel [$tr];
  965. }
  966. $tr ++;
  967. }
  968. if ($value ['category'] == $this->TRAIN) {
  969. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  970. array_push ( $accountJson [$this->TRAIN], array (
  971. 'aid' => $value ['aid'],
  972. 'name' => $value ['name'],
  973. 'price' => number_format ( $train [$ta], 2, '.', '' )
  974. ) );
  975. $sum += $train [$ta];
  976. $trainSum += $train [$ta];
  977. }
  978. $ta ++;
  979. }
  980. if ($value ['category'] == $this->INTTRAIN) {
  981. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  982. array_push ( $accountJson [$this->INTTRAIN], array (
  983. 'aid' => $value ['aid'],
  984. 'name' => $value ['name'],
  985. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  986. ) );
  987. $sum += $inttrain [$it];
  988. $inttrainSum += $inttrain [$it];
  989. }
  990. $it ++;
  991. }
  992. if ($value ['category'] == $this->OTHER) {
  993. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  994. array_push ( $accountJson [$this->OTHER], array (
  995. 'aid' => $value ['aid'],
  996. 'name' => $value ['name'],
  997. 'price' => number_format ( $other [$ot], 2, '.', '' )
  998. ) );
  999. $sum += $other [$ot];
  1000. $otherSum += $other [$ot];
  1001. }
  1002. $ot ++;
  1003. }
  1004. }
  1005. $accountJson ['cSum'] = array (
  1006. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1007. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1008. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1009. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  1010. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1011. );
  1012. // 报销单
  1013. $rid = $receipt->rid = $receiptDetail ['rid'];
  1014. $receipt->accountItem = json_encode ( $accountJson );
  1015. $receipt->staff = $this->staff [0] ['sid'];
  1016. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1017. $receipt->date = date ( "Y-m-d" );
  1018. $receipt->cid = $cid;
  1019. if (($receiptDetail ['status'] != 4)) {
  1020. if ($receiptDetail ['Rtype'] == 1) {
  1021. $receipt->status = 7;
  1022. } else {
  1023. $receipt->status = 5;
  1024. }
  1025. }
  1026. if ($receiptDetail != 4 && ! empty ( $verify ))
  1027. $receipt->verify = $verify;
  1028. $receipt->executeCopy = $executeDetail ['staff'];
  1029. $order = array (
  1030. "\r\n",
  1031. "\n",
  1032. "\r"
  1033. );
  1034. $replace = '<br/>';
  1035. $explanation = str_replace ( $order, $replace, $explanation );
  1036. $receipt->explanation = $explanation;
  1037. if($receiptClass=='trave'){
  1038. if(!empty($receiptDetail['itinerary2'])){//行程单版本
  1039. $receipt->itinerary2=$itinerary;
  1040. }else{
  1041. $receipt->itinerary=$itinerary;
  1042. }
  1043. }
  1044. $receipt->remittanceName = $remittanceName;
  1045. $receipt->bankName = $bankName;
  1046. $receipt->bankNumber = $bankNumber;
  1047. $receipt->remittanceBankType = $remittanceBankType;
  1048. if ($remittanceBankType == 1)
  1049. $receipt->coupletNumber = $coupletNumber;
  1050. $receipt->update ();
  1051. $receiptDetail = new receiptDetail ();
  1052. $receiptDetail->delete ( array (
  1053. 'where' => 'rid=' . $rid
  1054. ) );
  1055. // 报销详情
  1056. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1057. $receiptDetail = new receiptDetail ();
  1058. $receiptDetail->staff = $this->staff [0] ['sid'];
  1059. $receiptDetail->item = $value ['name'];
  1060. $receiptDetail->itemCategory = $this->AGENCY;
  1061. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1062. $receiptDetail->date = date ( "Y-m-d" );
  1063. $receiptDetail->cid = $cid;
  1064. $receiptDetail->rid = $rid;
  1065. $receiptDetail->status = 4;
  1066. $receiptDetail->insert ();
  1067. }
  1068. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1069. $receiptDetail = new receiptDetail ();
  1070. $receiptDetail->staff = $this->staff [0] ['sid'];
  1071. $receiptDetail->item = $value ['name'];
  1072. $receiptDetail->itemCategory = $this->TRAVEL;
  1073. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1074. $receiptDetail->date = date ( "Y-m-d" );
  1075. $receiptDetail->cid = $cid;
  1076. $receiptDetail->rid = $rid;
  1077. $receiptDetail->status = 4;
  1078. $receiptDetail->insert ();
  1079. }
  1080. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1081. $receiptDetail = new receiptDetail ();
  1082. $receiptDetail->staff = $this->staff [0] ['sid'];
  1083. $receiptDetail->item = $value ['name'];
  1084. $receiptDetail->itemCategory = $this->TRAIN;
  1085. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1086. $receiptDetail->date = date ( "Y-m-d" );
  1087. $receiptDetail->cid = $cid;
  1088. $receiptDetail->rid = $rid;
  1089. $receiptDetail->status = 4;
  1090. $receiptDetail->insert ();
  1091. }
  1092. // 内训
  1093. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1094. $receiptDetail = new receiptDetail ();
  1095. $receiptDetail->staff = $this->staff [0] ['sid'];
  1096. $receiptDetail->item = $value ['name'];
  1097. $receiptDetail->itemCategory = $this->INTTRAIN;
  1098. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1099. $receiptDetail->date = date ( "Y-m-d" );
  1100. $receiptDetail->cid = $cid;
  1101. $receiptDetail->rid = $rid;
  1102. $receiptDetail->status = 4;
  1103. $receiptDetail->insert ();
  1104. }
  1105. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1106. $receiptDetail = new receiptDetail ();
  1107. $receiptDetail->staff = $this->staff [0] ['sid'];
  1108. $receiptDetail->item = $value ['name'];
  1109. $receiptDetail->itemCategory = $this->OTHER;
  1110. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1111. $receiptDetail->date = date ( "Y-m-d" );
  1112. $receiptDetail->cid = $cid;
  1113. $receiptDetail->rid = $rid;
  1114. $receiptDetail->status = 4;
  1115. $receiptDetail->insert ();
  1116. }
  1117. // 附件
  1118. if (! empty ( $enclosurName )) {
  1119. $enclosurArray = explode ( '-', $enclosurName );
  1120. foreach ( $enclosurArray as $value ) {
  1121. $enclosur = new enclosur ();
  1122. $enclosur->name = $value;
  1123. $enclosur->rid = $rid;
  1124. $enclosur->insert ();
  1125. }
  1126. }
  1127. // return "/referReceipt/".$rid;
  1128. }
  1129. return "/saeaBorad";
  1130. }
  1131. function remitAdd() {
  1132. Doo::loadModel ( 'accountItem' );
  1133. Doo::loadModel ( 'verify' );
  1134. Doo::loadModel ( 'receipt' );
  1135. Doo::loadModel ( 'L_category' );
  1136. $lCategory = new L_category ();
  1137. $receipt = new receipt ();
  1138. $verify = new verify ();
  1139. $accountItem = new accountItem ();
  1140. Doo::loadModel ( "role" );
  1141. $role = new role ();
  1142. $acItem = $accountItem->find ( array (
  1143. 'asArray' => true
  1144. ) );
  1145. $veList = $verify->getVerifyBySubordinate('REMIT');
  1146. $data ['category'] = $lCategory->find ( array (
  1147. 'asArray' => true
  1148. ) );
  1149. $data ['veList'] = $veList;
  1150. $data ['acItem'] = $acItem;
  1151. $data ['memu'] = "receipt";
  1152. $data ['staff'] = $this->staff;
  1153. $data ['receiptMemu'] = 'saeaBorad';
  1154. $data ['verifyId'] = $this->verifyId;
  1155. $data ['executeId'] = $this->executeId;
  1156. $this->render ( "/admin/remitAdd", $data );
  1157. }
  1158. function remitAddDo() {
  1159. $agency = $this->get_args ( 'agency' );
  1160. $travel = $this->get_args ( 'travel' );
  1161. $train = $this->get_args ( 'train' );
  1162. $other = $this->get_args ( 'other' );
  1163. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1164. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1165. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1166. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1167. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1168. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1169. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1170. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1171. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1172. // print_r($agency);die;
  1173. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1174. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1175. header ( 'Content-Type:text/html;charset=utf-8' );
  1176. die ( '请填写联行号' );
  1177. }
  1178. Doo::loadModel ( 'receipt' );
  1179. Doo::loadModel ( 'receiptDetail' );
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $receipt = new receipt ();
  1183. Doo::loadModel ( 'enclosur' );
  1184. Doo::loadModel ( 'execute' );
  1185. $execute = new execute ();
  1186. $executeDetail = $execute->getOne ( array (
  1187. 'where' => 'mold="对公汇款执行人"',
  1188. 'asArray' => true
  1189. ) );
  1190. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1191. $aItem = $accountItem->find ( array (
  1192. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1193. 'asArray' => true
  1194. ) );
  1195. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1196. $ag = $tr = $ta = $ot = 0;
  1197. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1198. print_r($aItem);
  1199. foreach ( $aItem as $key => $value ) {
  1200. if ($value ['category'] == $this->AGENCY) {
  1201. if (isset ( $agency [$ag] )) {
  1202. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1203. array_push ( $accountJson [$this->AGENCY], array (
  1204. 'aid' => $value ['aid'],
  1205. 'name' => $value ['name'],
  1206. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1207. ) );
  1208. $sum += $agency [$ag];
  1209. $agencySum += $agency [$ag];
  1210. }
  1211. }
  1212. $ag ++;
  1213. }
  1214. }
  1215. $accountJson ['cSum'] = array (
  1216. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1217. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1218. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1219. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1220. );
  1221. //die;
  1222. // 报销单
  1223. $receipt->accountItem = json_encode ( $accountJson );
  1224. $receipt->staff = $this->staff [0] ['sid'];
  1225. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1226. $receipt->date = date ( "Y-m-d" );
  1227. $receipt->cid = $cid;
  1228. $receipt->status = 5;
  1229. $receipt->Rtype = 2;
  1230. // 修改审批流程加入角色
  1231. $receipt->verify = $verify;
  1232. $receipt->executeCopy = $executeDetail ['staff'];
  1233. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1234. $order = array (
  1235. "\r\n",
  1236. "\n",
  1237. "\r"
  1238. );
  1239. $replace = '<br/>';
  1240. $explanation = str_replace ( $order, $replace, $explanation );
  1241. $receipt->explanation = $explanation;
  1242. $receipt->remittanceName = $remittanceName;
  1243. $receipt->bankName = $bankName;
  1244. $receipt->bankNumber = $bankNumber;
  1245. $receipt->remittanceBankType = $remittanceBankType;
  1246. if ($remittanceBankType == 1)
  1247. $receipt->coupletNumber = $coupletNumber;
  1248. $rid = $receipt->insert ();
  1249. // 附件
  1250. if (! empty ( $enclosurName )) {
  1251. $enclosurArray = explode ( '-', $enclosurName );
  1252. foreach ( $enclosurArray as $value ) {
  1253. $enclosur = new enclosur ();
  1254. $enclosur->name = $value;
  1255. $enclosur->rid = $rid;
  1256. $enclosur->insert ();
  1257. }
  1258. // print_r($enclosurArray);die;
  1259. }
  1260. // 报销详情
  1261. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1262. $receiptDetail = new receiptDetail ();
  1263. $receiptDetail->staff = $this->staff [0] ['sid'];
  1264. $receiptDetail->item = $value ['name'];
  1265. $receiptDetail->itemCategory = $this->AGENCY;
  1266. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1267. $receiptDetail->date = date ( "Y-m-d" );
  1268. $receiptDetail->cid = $cid;
  1269. $receiptDetail->rid = $rid;
  1270. $receiptDetail->status = 4;
  1271. $receiptDetail->insert ();
  1272. }
  1273. return "/saeaBorad";
  1274. } else
  1275. die ( 'illegal request' );
  1276. }
  1277. function remitEdit() {
  1278. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1279. Doo::loadClass ( 'XDeode' );
  1280. $XDeode = new XDeode ( 7 );
  1281. $rid = $XDeode->decode ( $ridKey );
  1282. if (! is_numeric ( $rid ))
  1283. die ( 'illegal request' );
  1284. Doo::loadModel ( 'accountItem' );
  1285. Doo::loadModel ( 'verify' );
  1286. Doo::loadModel ( 'receipt' );
  1287. $receipt = new receipt ();
  1288. $verify = new verify ();
  1289. $accountItem = new accountItem ();
  1290. Doo::loadModel ( 'L_category' );
  1291. $lCategory = new L_category ();
  1292. Doo::loadModel ( "role" );
  1293. $role = new role ();
  1294. Doo::loadModel ( 'enclosur' );
  1295. $enclosur = new enclosur ();
  1296. $receiptDetail = $receipt->getOne ( array (
  1297. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1298. 'asArray' => true
  1299. ) );
  1300. if (empty ( $receiptDetail ))
  1301. return "/saeaCreate";
  1302. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1303. $acItem = $accountItem->find ( array (
  1304. 'asArray' => true
  1305. ) );
  1306. $veList = $verify->getVerifyBySubordinate('REMIT');
  1307. // 配置编辑信息
  1308. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1309. foreach ( $acItem as $key => $value ) {
  1310. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1311. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1312. $acItem [$key] ['price'] = $v ['price'];
  1313. }
  1314. }
  1315. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1316. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1317. $acItem [$key] ['price'] = $v ['price'];
  1318. }
  1319. }
  1320. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1321. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1322. $acItem [$key] ['price'] = $v ['price'];
  1323. }
  1324. }
  1325. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1326. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1327. $acItem [$key] ['price'] = $v ['price'];
  1328. }
  1329. }
  1330. }
  1331. $data ['category'] = $lCategory->find ( array (
  1332. 'asArray' => true
  1333. ) );
  1334. $data ['enclosurList'] = $enclosurList;
  1335. $data ['cSum'] = $accountItemList ['cSum'];
  1336. $data ['sum'] = $receiptDetail ['sum'];
  1337. $data ['receiptDetail'] = $receiptDetail;
  1338. $data ['veList'] = $veList;
  1339. $data ['acItem'] = $acItem;
  1340. $data ['memu'] = "receipt";
  1341. $data ['staff'] = $this->staff;
  1342. $data ['receiptMemu'] = 'saeaBorad';
  1343. $data ['verify'] = $receiptDetail ['verify'];
  1344. $data ['verifyId'] = $this->verifyId;
  1345. $data ['executeId'] = $this->executeId;
  1346. $data ['rid'] = $rid;
  1347. $data ['ridKey'] = $ridKey;
  1348. $this->render ( "/admin/remitEdit", $data );
  1349. }
  1350. function remitEdiDo() {
  1351. $agency = $this->get_args ( 'agency' );
  1352. $travel = $this->get_args ( 'travel' );
  1353. $train = $this->get_args ( 'train' );
  1354. $other = $this->get_args ( 'other' );
  1355. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1356. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1357. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1358. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1359. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1360. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1361. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1362. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1363. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1364. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1365. Doo::loadClass ( 'XDeode' );
  1366. $XDeode = new XDeode ( 7 );
  1367. $rid = $XDeode->decode ( $ridKey );
  1368. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1369. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1370. header ( 'Content-Type:text/html;charset=utf-8' );
  1371. die ( '请填写联行号' );
  1372. }
  1373. Doo::loadModel ( 'receipt' );
  1374. Doo::loadModel ( 'receiptDetail' );
  1375. Doo::loadModel ( 'accountItem' );
  1376. $accountItem = new accountItem ();
  1377. $receipt = new receipt ();
  1378. Doo::loadModel ( 'enclosur' );
  1379. $enclosur = new enclosur ();
  1380. Doo::loadModel ( 'execute' );
  1381. $execute = new execute ();
  1382. $executeDetail = $execute->getOne ( array (
  1383. 'where' => 'mold="对公汇款执行人"',
  1384. 'asArray' => true
  1385. ) );
  1386. $receiptDetail = $receipt->getOne ( array (
  1387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1388. 'asArray' => true
  1389. ) );
  1390. if (empty ( $receiptDetail ))
  1391. return "/saeaBorad";
  1392. $aItem = $accountItem->find ( array (
  1393. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1394. 'asArray' => true
  1395. ) );
  1396. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1397. $ag = $tr = $ta = $ot = 0;
  1398. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1399. foreach ( $aItem as $key => $value ) {
  1400. if ($value ['category'] == $this->AGENCY) {
  1401. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1402. array_push ( $accountJson [$this->AGENCY], array (
  1403. 'aid' => $value ['aid'],
  1404. 'name' => $value ['name'],
  1405. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1406. ) );
  1407. $sum += $agency [$ag];
  1408. $agencySum += $agency [$ag];
  1409. }
  1410. $ag ++;
  1411. }
  1412. }
  1413. $accountJson ['cSum'] = array (
  1414. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1415. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1416. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1417. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1418. );
  1419. // 报销单
  1420. $rid = $receipt->rid = $receiptDetail ['rid'];
  1421. $receipt->accountItem = json_encode ( $accountJson );
  1422. $receipt->staff = $this->staff [0] ['sid'];
  1423. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1424. $receipt->date = date ( "Y-m-d" );
  1425. $receipt->cid = $cid;
  1426. if ($receiptDetail ['Rtype'] == 1)
  1427. $receipt->status = 7;
  1428. else
  1429. $receipt->status = 5;
  1430. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1431. $receipt->verify = $verify;
  1432. $receipt->executeCopy = $executeDetail ['staff'];
  1433. $order = array (
  1434. "\r\n",
  1435. "\n",
  1436. "\r"
  1437. );
  1438. $replace = '<br/>';
  1439. $explanation = str_replace ( $order, $replace, $explanation );
  1440. $receipt->explanation = $explanation;
  1441. $receipt->remittanceName = $remittanceName;
  1442. $receipt->bankName = $bankName;
  1443. $receipt->bankNumber = $bankNumber;
  1444. $receipt->remittanceBankType = $remittanceBankType;
  1445. if ($remittanceBankType == 1)
  1446. $receipt->coupletNumber = $coupletNumber;
  1447. $receipt->update ();
  1448. $receiptDetail = new receiptDetail ();
  1449. $receiptDetail->delete ( array (
  1450. 'where' => 'rid=' . $rid
  1451. ) );
  1452. // 报销详情
  1453. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1454. $receiptDetail = new receiptDetail ();
  1455. $receiptDetail->staff = $this->staff [0] ['sid'];
  1456. $receiptDetail->item = $value ['name'];
  1457. $receiptDetail->itemCategory = $this->AGENCY;
  1458. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1459. $receiptDetail->date = date ( "Y-m-d" );
  1460. $receiptDetail->cid = $cid;
  1461. $receiptDetail->rid = $rid;
  1462. $receiptDetail->status = 4;
  1463. $receiptDetail->insert ();
  1464. }
  1465. // 附件
  1466. if (! empty ( $enclosurName )) {
  1467. $enclosurArray = explode ( '-', $enclosurName );
  1468. foreach ( $enclosurArray as $value ) {
  1469. $enclosur = new enclosur ();
  1470. $enclosur->name = $value;
  1471. $enclosur->rid = $rid;
  1472. $enclosur->insert ();
  1473. }
  1474. }
  1475. }
  1476. return "/saeaBorad";
  1477. }
  1478. function remitApproval() {
  1479. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1480. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1482. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1483. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1484. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1485. if (empty ( $status ))
  1486. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1487. $vidList = array ();
  1488. $button = 0;
  1489. Doo::loadModel ( 'verify' );
  1490. Doo::loadModel ( 'receipt' );
  1491. Doo::loadModel ( 'staff' );
  1492. $staff = new staff ();
  1493. $receipt = new receipt ();
  1494. $verify = new verify ();
  1495. Doo::loadModel ( 'L_category' );
  1496. $Lcategory = new L_category ();
  1497. Doo::loadModel ( 'enclosur' );
  1498. $enclosur = new enclosur ();
  1499. // user verify ID
  1500. $verifyDetail = $verify->find ( array (
  1501. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1502. 'asArray' => true
  1503. ) );
  1504. foreach ( $verifyDetail as $key => $value ) {
  1505. array_push ( $vidList, $value ['vid'] );
  1506. }
  1507. $vid = implode ( ",", $vidList );
  1508. if (empty ( $verifyDetail ))
  1509. $vid = 0;
  1510. $categoryList = $Lcategory->find ( array (
  1511. 'asArray' => true
  1512. ) );
  1513. $staffList = $staff->find ( array (
  1514. 'where' => 'cid=' . $cid,
  1515. 'asArray' => true
  1516. ) );
  1517. $ap = "";
  1518. if ($status == 4) {
  1519. $ap = 4;
  1520. $status = 2;
  1521. }
  1522. // get Receipt By verifyID status 2
  1523. $receiptList = $receipt->find ( array (
  1524. 'where' => 'rid =' . $rid . ' and status=2',
  1525. 'desc' => 'rid',
  1526. 'asArray' => true
  1527. ) );
  1528. if (empty ( $receiptList )) {
  1529. die ( 'illegal request' );
  1530. }
  1531. $Locate = 0;
  1532. $roleId = 0;
  1533. if ($ap == 4)
  1534. $status = 4;
  1535. foreach ( $receiptList as $key => $value ) {
  1536. $receiptList [$key] ['Locate'] = $Locate;
  1537. $Locate ++;
  1538. $receiptList [$key] ['reviseDetail'] = array ();
  1539. if (! empty ( $value ['reviseDetail'] ))
  1540. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1541. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1542. $categoryDetil = $Lcategory->getOne ( array (
  1543. 'where' => 'cid=' . $value ['cid'],
  1544. 'asArray' => true
  1545. ) );
  1546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1547. // 检测编辑状态
  1548. $verifyList = $verify->getOne ( array (
  1549. 'where' => 'vid=' . $value ['verify'],
  1550. 'asArray' => true
  1551. ) );
  1552. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1553. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1554. Doo::loadModel ( 'role' );
  1555. $role = new role ();
  1556. // print_r($verifyList);
  1557. $flag = true;
  1558. $roleKey = 0;
  1559. $endStaffArray = array ();
  1560. $roleArrayCopy = array ();
  1561. foreach ( $verifyList as $k => $v ) {
  1562. // init verifyStaff
  1563. if ($v [1] == 'ROLE') {
  1564. if (! empty ( $verifyStaff )) {
  1565. $endStaffArray = end ( $verifyStaff );
  1566. if ($v [0] == $endStaffArray ['nextStaff']) {
  1567. $roleId = $v [0];
  1568. }
  1569. }
  1570. $roleVerify = json_decode ( $v [3], true );
  1571. $roleKey = $k;
  1572. $roleArray = array ();
  1573. $rolename = $role->getOne ( array (
  1574. 'where' => 'rid=' . $v [0],
  1575. 'asArray' => true
  1576. ) );
  1577. foreach ( $roleVerify as $o => $p ) {
  1578. $staffID = explode ( '_', $p );
  1579. $staffInfo = $staff->getOne ( array (
  1580. 'where' => 'sid=' . $staffID [0],
  1581. 'asArray' => true
  1582. ) );
  1583. // print_r($staffID);
  1584. $exp = array (
  1585. 0 => $staffInfo ['sid'],
  1586. 1 => $staffID [1],
  1587. 2 => $staffInfo ['avatar'],
  1588. 'date' => '',
  1589. 'date' => '',
  1590. 'opinion' => '',
  1591. 'status' => '',
  1592. 'rolename' => $rolename ['name']
  1593. );
  1594. array_push ( $roleArray, $exp );
  1595. }
  1596. $roleArrayCopy [$v [0]] = $roleArray;
  1597. // $verifyList[$k]['roleArray']=$roleArray;
  1598. }
  1599. // print_r($roleArray);
  1600. $verifyList [$k] ['date'] = "";
  1601. $verifyList [$k] ['opinion'] = "";
  1602. $verifyList [$k] ['status'] = "";
  1603. if (empty ( $verifyStaff )) {
  1604. $verifyList [$k] ['date'] = "";
  1605. $verifyList [$k] ['opinion'] = "";
  1606. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1607. $verifyList [$k] ['status'] = 4;
  1608. $button = 4;
  1609. $flag = false;
  1610. }
  1611. } else {
  1612. foreach ( $verifyStaff as $m => $u ) {
  1613. if ($v [0] == $m) {
  1614. $verifyList [$k] ['date'] = $u ['date'];
  1615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1616. $verifyList [$k] ['status'] = $u ['status'];
  1617. $flag = false;
  1618. break;
  1619. }
  1620. }
  1621. $endStaffArray = end ( $verifyStaff );
  1622. if (isset ( $endStaffArray ['ROLE'] )) {
  1623. } else {
  1624. $endKey = key ( $verifyStaff );
  1625. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1626. $button = 4;
  1627. $verifyList [$k] ['status'] = 4;
  1628. }
  1629. }
  1630. }
  1631. }
  1632. $rolename ['name'] = '';
  1633. if (! empty ( $roleId )) {
  1634. Doo::loadModel ( 'role' );
  1635. $role = new role ();
  1636. $rolename = $role->getOne ( array (
  1637. 'where' => 'rid=' . $roleId,
  1638. 'asArray' => true
  1639. ) );
  1640. }
  1641. if (! empty ( $verifyStaff ))
  1642. $endStaffArray = end ( $verifyStaff );
  1643. $KOP = false;
  1644. foreach ( $roleArrayCopy as $P => $A ) {
  1645. foreach ( $A as $MKI => $AVL ) {
  1646. if (! empty ( $verifyStaff )) {
  1647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1649. $button = 4;
  1650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1651. }
  1652. foreach ( $verifyStaff as $m => $u ) {
  1653. $AVLFK = $AVL [0] . '_R';
  1654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1659. break;
  1660. }
  1661. }
  1662. } else {
  1663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1664. $button = 4;
  1665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1666. }
  1667. }
  1668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1669. $KOP = true;
  1670. }
  1671. }
  1672. foreach ( $roleArrayCopy as $k => $v ) {
  1673. foreach ( $verifyList as $m => $n ) {
  1674. if ($n [0] == $k) {
  1675. array_splice ( $verifyList, $m, 1, $v );
  1676. }
  1677. }
  1678. }
  1679. $receiptList [$key] ['verifyList'] = $verifyList;
  1680. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1681. 'where' => 'sid=' . $value ['staff'],
  1682. 'asArray' => true
  1683. ) );
  1684. $receiptList [$key] ['button'] = $button;
  1685. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1686. }
  1687. $mothHtml = "";
  1688. for($i = 1; $i <= 12; $i ++) {
  1689. if ($month == $i)
  1690. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1691. else
  1692. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1693. }
  1694. // 获取审批日志
  1695. Doo::loadModel ( 'receiptLog' );
  1696. $receiptLog = new receiptLog ();
  1697. $rlList = array ();
  1698. $rlInfo = $receiptLog->getOne ( array (
  1699. 'where' => 'rid=' . $rid . ' and status=4',
  1700. 'asArray' => true
  1701. ) );
  1702. $tijdate = $receiptLog->getOne ( array (
  1703. 'where' => 'rid=' . $rid . ' and status=2',
  1704. 'asc' => 'rlid',
  1705. 'asArray' => true
  1706. ) );
  1707. if (! empty ( $rlInfo )) {
  1708. $rlList = $receiptLog->find ( array (
  1709. 'where' => 'rid=' . $rid,
  1710. 'asc' => 'rlid',
  1711. 'asArray' => true
  1712. ) );
  1713. }
  1714. $receiptList [0] ['rlList'] = $rlList;
  1715. $enclosurList = $enclosur->find ( array (
  1716. 'where' => 'rid=' . $rid,
  1717. 'asArray' => true
  1718. ) );
  1719. $enclosurHtml = '';
  1720. foreach ( $enclosurList as $value ) {
  1721. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1722. }
  1723. // print_r($receiptList);
  1724. $data ['enclosurHtml'] = $enclosurHtml;
  1725. $data ['rolename'] = $rolename ['name'];
  1726. $data ['datetij'] = $tijdate ['date'];
  1727. $data ['mothHtml'] = $mothHtml;
  1728. $data ['rid'] = $rid;
  1729. $data ['receiptList'] = $receiptList;
  1730. $data ['receiptApprovalCount'] = count ( $receiptList );
  1731. $data ['status'] = $status;
  1732. $data ['year'] = $year;
  1733. $data ['categoryList'] = $categoryList;
  1734. $data ['staffList'] = $staffList;
  1735. $data ['cid'] = $cid;
  1736. $data ['sid'] = $sid;
  1737. $data ['ap'] = $ap;
  1738. $data ['memu'] = "receipt";
  1739. $data ['staff'] = $this->staff;
  1740. $data ['receiptMemu'] = 'approvalExpenses';
  1741. $data ['verifyId'] = $this->verifyId;
  1742. $data ['executeId'] = $this->executeId;
  1743. $this->render ( "/admin/remitApproval", $data );
  1744. }
  1745. function saeaLoanAdd() {
  1746. Doo::loadModel ( 'verify' );
  1747. $verify = new verify ();
  1748. Doo::loadModel ( "role" );
  1749. $role = new role ();
  1750. Doo::loadModel ( 'L_category' );
  1751. $lCategory = new L_category ();
  1752. $veList = $verify->getVerifyBySubordinate('LOAN');
  1753. $data ['category'] = $lCategory->find ( array (
  1754. 'asArray' => true
  1755. ) );
  1756. $data ['veList'] = $veList;
  1757. $data ['memu'] = "receipt";
  1758. $data ['staff'] = $this->staff;
  1759. $data ['receiptMemu'] = 'saeaBorad';
  1760. $data ['verifyId'] = $this->verifyId;
  1761. $data ['executeId'] = $this->executeId;
  1762. $this->render ( "/admin/saeaLoanAdd", $data );
  1763. }
  1764. function saeaLoanAddDo() {
  1765. $agency = $this->get_args ( 'agency' );
  1766. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1767. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1768. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1769. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1770. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1771. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1772. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1773. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1774. // die;
  1775. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1776. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1777. header ( 'Content-Type:text/html;charset=utf-8' );
  1778. die ( '请填写联行号' );
  1779. }
  1780. Doo::loadModel ( 'receipt' );
  1781. Doo::loadModel ( 'receiptDetail' );
  1782. Doo::loadModel ( 'accountItem' );
  1783. $accountItem = new accountItem ();
  1784. $receipt = new receipt ();
  1785. Doo::loadModel ( 'loanReceipt' );
  1786. $loanReceipt = new loanReceipt ();
  1787. Doo::loadModel ( 'execute' );
  1788. $execute = new execute ();
  1789. Doo::loadModel ( 'enclosur' );
  1790. $executeDetail = $execute->getOne ( array (
  1791. 'where' => 'mold="借款执行人"',
  1792. 'asArray' => true
  1793. ) );
  1794. $aItem = $accountItem->find ( array (
  1795. 'asArray' => true
  1796. ) );
  1797. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1798. $ag = $tr = $ta = $ot = 0;
  1799. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1800. array_push ( $accountJson ['借款费用'], array (
  1801. 'aid' => 0,
  1802. 'name' => '申请金额',
  1803. 'price' => number_format ( $agency, 2, '.', '' )
  1804. ) );
  1805. $sum += $agency;
  1806. $agencySum += $agency;
  1807. $accountJson ['cSum'] = array (
  1808. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1809. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1810. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1811. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1812. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1813. );
  1814. // 借款数据备份
  1815. $loanReceipt->loanItem = json_encode ( $accountJson );
  1816. $loanReceipt->staff = $this->staff [0] ['sid'];
  1817. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1818. $loanReceipt->date = date ( "Y-m-d" );
  1819. $loanReceipt->cid = $cid;
  1820. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1821. $loanReceipt->status = 5;
  1822. $loanReceipt->Rtype = 1;
  1823. $loanReceipt->verify = $verify;
  1824. $receipt->receiptOrder = $receipt->receiptOrder;
  1825. // 添加HTML换行符
  1826. // var_dump($explanation);
  1827. $order = array (
  1828. "\r\n",
  1829. "\n",
  1830. "\r"
  1831. );
  1832. $replace = '<br/>';
  1833. $explanation = str_replace ( $order, $replace, $explanation );
  1834. // $explanation=str_replace('\r',"<br/>",$explanation);
  1835. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1836. $loanReceipt->explanation = $explanation;
  1837. $loanRid = $loanReceipt->insert ();
  1838. // 报销单
  1839. $receipt->loanItem = json_encode ( $accountJson );
  1840. $receipt->staff = $this->staff [0] ['sid'];
  1841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1842. $receipt->date = date ( "Y-m-d" );
  1843. $receipt->cid = $cid;
  1844. // 特殊状态
  1845. $receipt->status = 5;
  1846. $receipt->Rtype = 1;
  1847. $receipt->loanRid = $loanRid;
  1848. // 修改审批流程加入角色
  1849. $receipt->verify = $verify;
  1850. $receipt->executeCopy = $executeDetail ['staff'];
  1851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1852. $receipt->explanation = $explanation;
  1853. $receipt->remittanceName = $remittanceName;
  1854. $receipt->bankName = $bankName;
  1855. $receipt->bankNumber = $bankNumber;
  1856. $receipt->remittanceBankType = $remittanceBankType;
  1857. if ($remittanceBankType == 1)
  1858. $receipt->coupletNumber = $coupletNumber;
  1859. $rid = $receipt->insert ();
  1860. return "/saeaBorad";
  1861. } else
  1862. die ( 'illegal request' );
  1863. }
  1864. function saeaLoanEdi() {
  1865. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1866. Doo::loadClass ( 'XDeode' );
  1867. $XDeode = new XDeode ( 7 );
  1868. $rid = $XDeode->decode ( $ridKey );
  1869. if (! is_numeric ( $rid ))
  1870. die ( 'illegal request' );
  1871. Doo::loadModel ( 'verify' );
  1872. $verify = new verify ();
  1873. Doo::loadModel ( "role" );
  1874. $role = new role ();
  1875. Doo::loadModel ( 'L_category' );
  1876. $lCategory = new L_category ();
  1877. Doo::loadModel ( 'receipt' );
  1878. $receipt = new receipt ();
  1879. $receiptInfo = $receipt->getOne ( array (
  1880. 'where' => 'rid=' . $rid,
  1881. 'asArray' => true
  1882. ) );
  1883. $veList = $verify->find ( array (
  1884. 'where'=>'subordinate like "%LOAN%"',
  1885. 'asArray' => true
  1886. ) );
  1887. foreach ( $veList as $key => $value ) {
  1888. $v = json_decode ( $value ['staff'] );
  1889. $list = array ();
  1890. foreach ( $v as $n => $m ) {
  1891. if ($m ['1'] == 'ROLE') {
  1892. $roleInfo = $role->getOne ( array (
  1893. 'where' => 'rid=' . $m [0],
  1894. 'asArray' => true
  1895. ) );
  1896. $v [$n] [1] = $roleInfo ['name'];
  1897. array_push ( $list, $roleInfo ['name'] );
  1898. } else {
  1899. array_push ( $list, $v [$n] [1] );
  1900. }
  1901. }
  1902. $veList [$key] ['staff'] = implode ( '>', $list );
  1903. }
  1904. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1905. // print_r($receiptInfo);
  1906. $data ['receiptInfo'] = $receiptInfo;
  1907. $data ['category'] = $lCategory->find ( array (
  1908. 'asArray' => true
  1909. ) );
  1910. $data ['veList'] = $veList;
  1911. $data ['ridKey'] = $ridKey;
  1912. $data ['memu'] = "receipt";
  1913. $data ['staff'] = $this->staff;
  1914. $data ['receiptMemu'] = 'saeaBorad';
  1915. $data ['verifyId'] = $this->verifyId;
  1916. $data ['executeId'] = $this->executeId;
  1917. $this->render ( "/admin/saeaLoanEdi", $data );
  1918. }
  1919. function saeaLoanEdiDo() {
  1920. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1921. $agency = $this->get_args ( 'agency' );
  1922. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1923. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1924. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1925. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1926. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1927. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1928. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1929. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1930. // die;
  1931. Doo::loadClass ( 'XDeode' );
  1932. $XDeode = new XDeode ( 7 );
  1933. $rid = $XDeode->decode ( $ridKey );
  1934. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1935. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1936. header ( 'Content-Type:text/html;charset=utf-8' );
  1937. die ( '请填写联行号' );
  1938. }
  1939. Doo::loadModel ( 'receipt' );
  1940. Doo::loadModel ( 'receiptDetail' );
  1941. Doo::loadModel ( 'accountItem' );
  1942. $accountItem = new accountItem ();
  1943. $receipt = new receipt ();
  1944. Doo::loadModel ( 'loanReceipt' );
  1945. $loanReceipt = new loanReceipt ();
  1946. Doo::loadModel ( 'enclosur' );
  1947. Doo::loadModel ( 'execute' );
  1948. $execute = new execute ();
  1949. $executeDetail = $execute->getOne ( array (
  1950. 'where' => 'mold="借款执行人"',
  1951. 'asArray' => true
  1952. ) );
  1953. $receiptDetail = $receipt->getOne ( array (
  1954. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1955. 'asArray' => true
  1956. ) );
  1957. if (empty ( $receiptDetail ))
  1958. die ( '参数错误' );
  1959. $aItem = $accountItem->find ( array (
  1960. 'asArray' => true
  1961. ) );
  1962. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1963. $ag = $tr = $ta = $ot = 0;
  1964. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1965. array_push ( $accountJson ['借款费用'], array (
  1966. 'aid' => 0,
  1967. 'name' => '申请金额',
  1968. 'price' => number_format ( $agency, 2, '.', '' )
  1969. ) );
  1970. $sum += $agency;
  1971. $agencySum += $agency;
  1972. $accountJson ['cSum'] = array (
  1973. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1974. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1975. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1976. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1977. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1978. );
  1979. // 报销单
  1980. $receipt->loanItem = json_encode ( $accountJson );
  1981. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1982. $receipt->cid = $cid;
  1983. // 特殊状态
  1984. // 修改审批流程加入角色
  1985. if ($receiptDetail ['status'] != 4)
  1986. $receipt->verify = $verify;
  1987. $order = array (
  1988. "\r\n",
  1989. "\n",
  1990. "\r"
  1991. );
  1992. $replace = '<br/>';
  1993. $explanation = str_replace ( $order, $replace, $explanation );
  1994. $receipt->explanation = $explanation;
  1995. $receipt->remittanceName = $remittanceName;
  1996. $receipt->bankName = $bankName;
  1997. $receipt->bankNumber = $bankNumber;
  1998. $receipt->remittanceBankType = $remittanceBankType;
  1999. if ($remittanceBankType == 1)
  2000. $receipt->coupletNumber = $coupletNumber;
  2001. $receipt->update ( array (
  2002. 'where' => 'rid=' . $rid
  2003. ) );
  2004. // 借款数据更新
  2005. $loanReceipt->loanItem = json_encode ( $accountJson );
  2006. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  2007. $loanReceipt->cid = $cid;
  2008. if ($receiptDetail ['status'] != 4)
  2009. $loanReceipt->verify = $verify;
  2010. $loanReceipt->explanation = $explanation;
  2011. $receipt->executeCopy = $executeDetail ['staff'];
  2012. $loanReceipt->update ( array (
  2013. 'where' => 'rid=' . $receiptDetail ['loanRid']
  2014. ) );
  2015. }
  2016. return "/saeaBorad";
  2017. }
  2018. function saeaLoanReceiptAdd() {
  2019. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2020. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2021. Doo::loadModel ( 'receipt' );
  2022. $receipt = new receipt ();
  2023. Doo::loadModel ( 'loanReceipt' );
  2024. $loanReceipt = new loanReceipt ();
  2025. Doo::loadModel ( 'L_category' );
  2026. $Lcategory = new L_category ();
  2027. Doo::loadModel ( 'verify' );
  2028. Doo::loadModel ( 'statistics' );
  2029. $statistics = new statistics ();
  2030. $verify = new verify ();
  2031. Doo::loadModel ( 'staff' );
  2032. $staff = new staff ();
  2033. $receiptDetail = $receipt->getOne ( array (
  2034. 'where' => 'rid=' . $rid,
  2035. 'desc' => 'rid',
  2036. 'asArray' => true
  2037. ) );
  2038. $receiptList = $loanReceipt->find ( array (
  2039. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2040. 'desc' => 'rid',
  2041. 'asArray' => true
  2042. ) );
  2043. $Locate = 0;
  2044. $roleId = 0;
  2045. $button = 0;
  2046. foreach ( $receiptList as $key => $value ) {
  2047. $receiptList [$key] ['Locate'] = $Locate;
  2048. $Locate ++;
  2049. $receiptList [$key] ['reviseDetail'] = array ();
  2050. if (! empty ( $value ['reviseDetail'] ))
  2051. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2052. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2053. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2054. $categoryDetil = $Lcategory->getOne ( array (
  2055. 'where' => 'cid=' . $value ['cid'],
  2056. 'asArray' => true
  2057. ) );
  2058. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2059. // 检测编辑状态
  2060. $verifyList = $verify->getOne ( array (
  2061. 'where' => 'vid=' . $value ['verify'],
  2062. 'asArray' => true
  2063. ) );
  2064. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2065. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2066. Doo::loadModel ( 'role' );
  2067. $role = new role ();
  2068. $flag = true;
  2069. $roleKey = 0;
  2070. $endStaffArray = array ();
  2071. $roleArrayCopy = array ();
  2072. foreach ( $verifyList as $k => $v ) {
  2073. // init verifyStaff
  2074. if ($v [1] == 'ROLE') {
  2075. if (! empty ( $verifyStaff )) {
  2076. $endStaffArray = end ( $verifyStaff );
  2077. // if ($v[0]==$endStaffArray['nextStaff']){
  2078. // $roleId=$v[0];
  2079. // }
  2080. }
  2081. $roleVerify = json_decode ( $v [3], true );
  2082. $roleKey = $k;
  2083. $roleArray = array ();
  2084. $rolename = $role->getOne ( array (
  2085. 'where' => 'rid=' . $v [0],
  2086. 'asArray' => true
  2087. ) );
  2088. foreach ( $roleVerify as $o => $p ) {
  2089. $staffID = explode ( '_', $p );
  2090. $staffInfo = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $staffID [0],
  2092. 'asArray' => true
  2093. ) );
  2094. // print_r($staffID);
  2095. $exp = array (
  2096. 0 => $staffInfo ['sid'],
  2097. 1 => $staffID [1],
  2098. 2 => $staffInfo ['avatar'],
  2099. 'date' => '',
  2100. 'date' => '',
  2101. 'opinion' => '',
  2102. 'status' => '',
  2103. 'rolename' => $rolename ['name']
  2104. );
  2105. array_push ( $roleArray, $exp );
  2106. }
  2107. $roleArrayCopy [$v [0]] = $roleArray;
  2108. // $verifyList[$k]['roleArray']=$roleArray;
  2109. }
  2110. $verifyList [$k] ['date'] = "";
  2111. $verifyList [$k] ['opinion'] = "";
  2112. $verifyList [$k] ['status'] = "";
  2113. if (empty ( $verifyStaff )) {
  2114. $verifyList [$k] ['date'] = "";
  2115. $verifyList [$k] ['opinion'] = "";
  2116. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2117. $verifyList [$k] ['status'] = 4;
  2118. $flag = false;
  2119. }
  2120. } else {
  2121. foreach ( $verifyStaff as $m => $u ) {
  2122. if ($v [0] == $m) {
  2123. $verifyList [$k] ['date'] = $u ['date'];
  2124. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2125. $verifyList [$k] ['status'] = $u ['status'];
  2126. $flag = false;
  2127. break;
  2128. }
  2129. }
  2130. $endStaffArray = end ( $verifyStaff );
  2131. if (isset ( $endStaffArray ['ROLE'] )) {
  2132. } else {
  2133. // $endKey=key($verifyStaff);
  2134. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2135. // $button=4;
  2136. // $verifyList[$k]['status']=4;
  2137. // }
  2138. }
  2139. }
  2140. }
  2141. $rolename ['name'] = '';
  2142. if (! empty ( $roleId )) {
  2143. Doo::loadModel ( 'role' );
  2144. $role = new role ();
  2145. $rolename = $role->getOne ( array (
  2146. 'where' => 'rid=' . $roleId,
  2147. 'asArray' => true
  2148. ) );
  2149. }
  2150. if (! empty ( $verifyStaff ))
  2151. $endStaffArray = end ( $verifyStaff );
  2152. $KOP = false;
  2153. foreach ( $roleArrayCopy as $P => $A ) {
  2154. foreach ( $A as $MKI => $AVL ) {
  2155. if (! empty ( $verifyStaff )) {
  2156. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2157. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2158. $button = 4;
  2159. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2160. }
  2161. foreach ( $verifyStaff as $m => $u ) {
  2162. $AVLFK = $AVL [0] . '_R';
  2163. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2164. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2165. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2166. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2167. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2168. break;
  2169. }
  2170. }
  2171. } else {
  2172. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2173. $button = 4;
  2174. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2175. }
  2176. }
  2177. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2178. $KOP = true;
  2179. }
  2180. }
  2181. foreach ( $roleArrayCopy as $k => $v ) {
  2182. foreach ( $verifyList as $m => $n ) {
  2183. if ($n [0] == $k) {
  2184. array_splice ( $verifyList, $m, 1, $v );
  2185. }
  2186. }
  2187. }
  2188. $receiptList [$key] ['verifyList'] = $verifyList;
  2189. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2190. 'where' => 'sid=' . $value ['staff'],
  2191. 'asArray' => true
  2192. ) );
  2193. $receiptList [$key] ['button'] = $button;
  2194. //
  2195. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2196. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2197. }
  2198. $data ['receiptList'] = $receiptList;
  2199. $data ['receiptDetail'] = $receiptDetail;
  2200. Doo::loadModel ( 'L_category' );
  2201. $lCategory = new L_category ();
  2202. Doo::loadModel ( 'accountItem' );
  2203. $accountItem = new accountItem ();
  2204. $acItem = $accountItem->find ( array (
  2205. 'asArray' => true
  2206. ) );
  2207. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2208. $data ['rid'] = $rid;
  2209. $data ['category'] = $lCategory->find ( array (
  2210. 'asArray' => true
  2211. ) );
  2212. $data ['veList'] = $veList;
  2213. $data ['acItem'] = $acItem;
  2214. $data['itineraryDate']=$this->_itineraryDateMin();
  2215. $data ['memu'] = "receipt";
  2216. $data ['staff'] = $this->staff;
  2217. $data ['receiptMemu'] = 'saeaBorad';
  2218. $data ['verifyId'] = $this->verifyId;
  2219. $data ['executeId'] = $this->executeId;
  2220. $data['receiptClass']=$receiptClass;
  2221. if($receiptClass=='trave'){
  2222. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2223. }else{
  2224. $this->render ( "/receipt/feeLoanReceipt", $data );
  2225. }
  2226. }
  2227. function saeaLoanReceiptAddDo() {
  2228. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2229. $agency = $this->get_args ( 'agency' );
  2230. $travel = $this->get_args ( 'travel' );
  2231. $train = $this->get_args ( 'train' );
  2232. $other = $this->get_args ( 'other' );
  2233. $inttrain = $this->get_args ( 'inttrain' );
  2234. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2235. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2236. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2237. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2238. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2239. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2240. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2241. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2242. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2243. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2244. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2245. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2246. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2247. header ( 'Content-Type:text/html;charset=utf-8' );
  2248. die ( '请填写联行号' );
  2249. }
  2250. if($receiptClass=='agency'){
  2251. $receiptClass=1;
  2252. }elseif($receiptClass=='trave'){
  2253. $receiptClass=2;
  2254. if($this->_verificationItinerary($itinerary)){
  2255. header ( 'Content-Type:text/html;charset=utf-8' );
  2256. die ( '已申请过类此日期的行程' );
  2257. }
  2258. }elseif($receiptClass=='internalTrain'){
  2259. $receiptClass=3;
  2260. }else{
  2261. header ( 'Content-Type:text/html;charset=utf-8' );
  2262. die ( '借款报销单分类不正确' );
  2263. }
  2264. Doo::loadModel ( 'receipt' );
  2265. Doo::loadModel ( 'receiptDetail' );
  2266. Doo::loadModel ( 'accountItem' );
  2267. $accountItem = new accountItem ();
  2268. $receipt = new receipt ();
  2269. Doo::loadModel ( 'enclosur' );
  2270. Doo::loadModel ( 'execute' );
  2271. $execute = new execute ();
  2272. $executeDetail = $execute->getOne ( array (
  2273. 'where' => 'mold="借款费用执行人"',
  2274. 'asArray' => true
  2275. ) );
  2276. $receiptDet = $receipt->getOne ( array (
  2277. 'where' => 'rid=' . $rid,
  2278. 'asArray' => true
  2279. ) );
  2280. // if(!empty($receiptDetail))
  2281. // return "/referReceipt/".$receiptDetail['rid'];
  2282. $aItem = $accountItem->find ( array (
  2283. 'asArray' => true
  2284. ) );
  2285. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2286. $ag = $tr = $ta = $ot =$it = 0;
  2287. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2288. foreach ( $aItem as $key => $value ) {
  2289. if ($value ['category'] == $this->AGENCY) {
  2290. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2291. array_push ( $accountJson [$this->AGENCY], array (
  2292. 'aid' => $value ['aid'],
  2293. 'name' => $value ['name'],
  2294. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2295. ) );
  2296. $sum += $agency [$ag];
  2297. $agencySum += $agency [$ag];
  2298. }
  2299. $ag ++;
  2300. }
  2301. if ($value ['category'] == $this->TRAVEL) {
  2302. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2303. array_push ( $accountJson [$this->TRAVEL], array (
  2304. 'aid' => $value ['aid'],
  2305. 'name' => $value ['name'],
  2306. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2307. ) );
  2308. $sum += $travel [$tr];
  2309. $travelSum += $travel [$tr];
  2310. }
  2311. $tr ++;
  2312. }
  2313. if ($value ['category'] == $this->INTTRAIN) {
  2314. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2315. array_push ( $accountJson [$this->INTTRAIN], array (
  2316. 'aid' => $value ['aid'],
  2317. 'name' => $value ['name'],
  2318. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2319. ) );
  2320. $sum += $inttrain [$it];
  2321. $inttrainSum += $inttrain [$it];
  2322. }
  2323. $it ++;
  2324. }
  2325. if ($value ['category'] == $this->TRAIN) {
  2326. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2327. array_push ( $accountJson [$this->TRAIN], array (
  2328. 'aid' => $value ['aid'],
  2329. 'name' => $value ['name'],
  2330. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2331. ) );
  2332. $sum += $train [$ta];
  2333. $trainSum += $train [$ta];
  2334. }
  2335. $ta ++;
  2336. }
  2337. if ($value ['category'] == $this->OTHER) {
  2338. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2339. array_push ( $accountJson [$this->OTHER], array (
  2340. 'aid' => $value ['aid'],
  2341. 'name' => $value ['name'],
  2342. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2343. ) );
  2344. $sum += $other [$ot];
  2345. $otherSum += $other [$ot];
  2346. }
  2347. $ot ++;
  2348. }
  2349. }
  2350. $accountJson ['cSum'] = array (
  2351. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2352. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2353. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2354. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2355. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2356. );
  2357. // 报销单
  2358. $receipt->accountItem = json_encode ( $accountJson );
  2359. $receipt->staff = $this->staff [0] ['sid'];
  2360. $receipt->loanSum = $receiptDet ['sum'];
  2361. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2362. $receipt->date = date ( "Y-m-d" );
  2363. $receipt->pastDate = '0000-00-00';
  2364. $receipt->cid = $cid;
  2365. $receipt->status = 7;
  2366. $receipt->receiptClass=$receiptClass;
  2367. if($receiptClass==2){
  2368. $receipt->itinerary2=$itinerary;
  2369. $this->_storageItinerary($itinerary, $rid);
  2370. }
  2371. // 修改审批流程加入角色
  2372. $receipt->verify = $verify;
  2373. $receipt->verifyStaff = '';
  2374. $receipt->executeStaff = '';
  2375. $receipt->executeCopy = $executeDetail ['staff'];
  2376. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2377. $receipt->explanation = $explanation;
  2378. $receipt->remittanceName = $remittanceName;
  2379. $receipt->bankName = $bankName;
  2380. $receipt->bankNumber = $bankNumber;
  2381. $receipt->remittanceBankType = $remittanceBankType;
  2382. if ($remittanceBankType == 1)
  2383. $receipt->coupletNumber = $coupletNumber;
  2384. $receipt->update ( array (
  2385. 'where' => 'rid=' . $rid
  2386. ) );
  2387. // 附件
  2388. if (! empty ( $enclosurName )) {
  2389. $enclosurArray = explode ( '-', $enclosurName );
  2390. foreach ( $enclosurArray as $value ) {
  2391. $enclosur = new enclosur ();
  2392. $enclosur->name = $value;
  2393. $enclosur->rid = $rid;
  2394. $enclosur->insert ();
  2395. }
  2396. // print_r($enclosurArray);die;
  2397. }
  2398. // 报销详情
  2399. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2400. $receiptDetail = new receiptDetail ();
  2401. $receiptDetail->staff = $this->staff [0] ['sid'];
  2402. $receiptDetail->item = $value ['name'];
  2403. $receiptDetail->itemCategory = $this->AGENCY;
  2404. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2405. $receiptDetail->date = date ( "Y-m-d" );
  2406. $receiptDetail->cid = $cid;
  2407. $receiptDetail->rid = $rid;
  2408. $receiptDetail->status = 4;
  2409. $receiptDetail->insert ();
  2410. }
  2411. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2412. $receiptDetail = new receiptDetail ();
  2413. $receiptDetail->staff = $this->staff [0] ['sid'];
  2414. $receiptDetail->item = $value ['name'];
  2415. $receiptDetail->itemCategory = $this->TRAVEL;
  2416. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2417. $receiptDetail->date = date ( "Y-m-d" );
  2418. $receiptDetail->cid = $cid;
  2419. $receiptDetail->rid = $rid;
  2420. $receiptDetail->status = 4;
  2421. $receiptDetail->insert ();
  2422. }
  2423. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2424. $receiptDetail = new receiptDetail ();
  2425. $receiptDetail->staff = $this->staff [0] ['sid'];
  2426. $receiptDetail->item = $value ['name'];
  2427. $receiptDetail->itemCategory = $this->TRAIN;
  2428. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2429. $receiptDetail->date = date ( "Y-m-d" );
  2430. $receiptDetail->cid = $cid;
  2431. $receiptDetail->rid = $rid;
  2432. $receiptDetail->status = 4;
  2433. $receiptDetail->insert ();
  2434. }
  2435. //内训
  2436. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2437. $receiptDetail = new receiptDetail ();
  2438. $receiptDetail->staff = $this->staff [0] ['sid'];
  2439. $receiptDetail->item = $value ['name'];
  2440. $receiptDetail->itemCategory = $this->INTTRAIN;
  2441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2442. $receiptDetail->date = date ( "Y-m-d" );
  2443. $receiptDetail->cid = $cid;
  2444. $receiptDetail->rid = $rid;
  2445. $receiptDetail->status = 4;
  2446. $receiptDetail->insert ();
  2447. }
  2448. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2449. $receiptDetail = new receiptDetail ();
  2450. $receiptDetail->staff = $this->staff [0] ['sid'];
  2451. $receiptDetail->item = $value ['name'];
  2452. $receiptDetail->itemCategory = $this->OTHER;
  2453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2454. $receiptDetail->date = date ( "Y-m-d" );
  2455. $receiptDetail->cid = $cid;
  2456. $receiptDetail->rid = $rid;
  2457. $receiptDetail->status = 4;
  2458. $receiptDetail->insert ();
  2459. }
  2460. return "/saeaBorad";
  2461. }
  2462. return "/saeaLoanReceiptAdd/" . $rid;
  2463. }
  2464. function saeaLoanReceiptEdi() {
  2465. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2466. Doo::loadClass ( 'XDeode' );
  2467. $XDeode = new XDeode ( 7 );
  2468. $rid = $XDeode->decode ( $ridKey );
  2469. if (! is_numeric ( $rid ))
  2470. die ( 'illegal request' );
  2471. Doo::loadModel ( 'accountItem' );
  2472. Doo::loadModel ( 'verify' );
  2473. Doo::loadModel ( 'receipt' );
  2474. $receipt = new receipt ();
  2475. $verify = new verify ();
  2476. $accountItem = new accountItem ();
  2477. Doo::loadModel ( 'L_category' );
  2478. $Lcategory = new L_category ();
  2479. Doo::loadModel ( "role" );
  2480. $role = new role ();
  2481. Doo::loadModel ( 'loanReceipt' );
  2482. $loanReceipt = new loanReceipt ();
  2483. Doo::loadModel ( 'staff' );
  2484. $staff = new staff ();
  2485. $receiptDetail = $receipt->getOne ( array (
  2486. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2487. 'asArray' => true
  2488. ) );
  2489. if (empty ( $receiptDetail ))
  2490. return "/saeaBorad";
  2491. $receiptList = $loanReceipt->find ( array (
  2492. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2493. 'desc' => 'rid',
  2494. 'asArray' => true
  2495. ) );
  2496. $Locate = 0;
  2497. $roleId = 0;
  2498. $button = 0;
  2499. foreach ( $receiptList as $key => $value ) {
  2500. $receiptList [$key] ['Locate'] = $Locate;
  2501. $Locate ++;
  2502. $receiptList [$key] ['reviseDetail'] = array ();
  2503. if (! empty ( $value ['reviseDetail'] ))
  2504. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2505. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2506. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2507. $categoryDetil = $Lcategory->getOne ( array (
  2508. 'where' => 'cid=' . $value ['cid'],
  2509. 'asArray' => true
  2510. ) );
  2511. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2512. // 检测编辑状态
  2513. $verifyList = $verify->getOne ( array (
  2514. 'where' => 'vid=' . $value ['verify'],
  2515. 'asArray' => true
  2516. ) );
  2517. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2518. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2519. Doo::loadModel ( 'role' );
  2520. $role = new role ();
  2521. $flag = true;
  2522. $roleKey = 0;
  2523. $endStaffArray = array ();
  2524. $roleArrayCopy = array ();
  2525. foreach ( $verifyList as $k => $v ) {
  2526. // init verifyStaff
  2527. if ($v [1] == 'ROLE') {
  2528. if (! empty ( $verifyStaff )) {
  2529. $endStaffArray = end ( $verifyStaff );
  2530. // if ($v[0]==$endStaffArray['nextStaff']){
  2531. // $roleId=$v[0];
  2532. // }
  2533. }
  2534. $roleVerify = json_decode ( $v [3], true );
  2535. $roleKey = $k;
  2536. $roleArray = array ();
  2537. $rolename = $role->getOne ( array (
  2538. 'where' => 'rid=' . $v [0],
  2539. 'asArray' => true
  2540. ) );
  2541. foreach ( $roleVerify as $o => $p ) {
  2542. $staffID = explode ( '_', $p );
  2543. $staffInfo = $staff->getOne ( array (
  2544. 'where' => 'sid=' . $staffID [0],
  2545. 'asArray' => true
  2546. ) );
  2547. // print_r($staffID);
  2548. $exp = array (
  2549. 0 => $staffInfo ['sid'],
  2550. 1 => $staffID [1],
  2551. 2 => $staffInfo ['avatar'],
  2552. 'date' => '',
  2553. 'date' => '',
  2554. 'opinion' => '',
  2555. 'status' => '',
  2556. 'rolename' => $rolename ['name']
  2557. );
  2558. array_push ( $roleArray, $exp );
  2559. }
  2560. $roleArrayCopy [$v [0]] = $roleArray;
  2561. // $verifyList[$k]['roleArray']=$roleArray;
  2562. }
  2563. $verifyList [$k] ['date'] = "";
  2564. $verifyList [$k] ['opinion'] = "";
  2565. $verifyList [$k] ['status'] = "";
  2566. if (empty ( $verifyStaff )) {
  2567. $verifyList [$k] ['date'] = "";
  2568. $verifyList [$k] ['opinion'] = "";
  2569. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2570. $verifyList [$k] ['status'] = 4;
  2571. $flag = false;
  2572. }
  2573. } else {
  2574. foreach ( $verifyStaff as $m => $u ) {
  2575. if ($v [0] == $m) {
  2576. $verifyList [$k] ['date'] = $u ['date'];
  2577. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2578. $verifyList [$k] ['status'] = $u ['status'];
  2579. $flag = false;
  2580. break;
  2581. }
  2582. }
  2583. $endStaffArray = end ( $verifyStaff );
  2584. if (isset ( $endStaffArray ['ROLE'] )) {
  2585. } else {
  2586. // $endKey=key($verifyStaff);
  2587. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2588. // $button=4;
  2589. // $verifyList[$k]['status']=4;
  2590. // }
  2591. }
  2592. }
  2593. }
  2594. $rolename ['name'] = '';
  2595. if (! empty ( $roleId )) {
  2596. Doo::loadModel ( 'role' );
  2597. $role = new role ();
  2598. $rolename = $role->getOne ( array (
  2599. 'where' => 'rid=' . $roleId,
  2600. 'asArray' => true
  2601. ) );
  2602. }
  2603. if (! empty ( $verifyStaff ))
  2604. $endStaffArray = end ( $verifyStaff );
  2605. $KOP = false;
  2606. foreach ( $roleArrayCopy as $P => $A ) {
  2607. foreach ( $A as $MKI => $AVL ) {
  2608. if (! empty ( $verifyStaff )) {
  2609. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2610. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2611. $button = 4;
  2612. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2613. }
  2614. foreach ( $verifyStaff as $m => $u ) {
  2615. $AVLFK = $AVL [0] . '_R';
  2616. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2617. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2618. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2619. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2620. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2621. break;
  2622. }
  2623. }
  2624. } else {
  2625. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2626. $button = 4;
  2627. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2628. }
  2629. }
  2630. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2631. $KOP = true;
  2632. }
  2633. }
  2634. foreach ( $roleArrayCopy as $k => $v ) {
  2635. foreach ( $verifyList as $m => $n ) {
  2636. if ($n [0] == $k) {
  2637. array_splice ( $verifyList, $m, 1, $v );
  2638. }
  2639. }
  2640. }
  2641. $receiptList [$key] ['verifyList'] = $verifyList;
  2642. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2643. 'where' => 'sid=' . $value ['staff'],
  2644. 'asArray' => true
  2645. ) );
  2646. $receiptList [$key] ['button'] = $button;
  2647. //
  2648. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2649. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2650. }
  2651. $data ['receiptList'] = $receiptList;
  2652. $acItem = $accountItem->find ( array (
  2653. 'asArray' => true
  2654. ) );
  2655. $veList = $verify->find ( array (
  2656. 'asArray' => true
  2657. ) );
  2658. foreach ( $veList as $key => $value ) {
  2659. $v = json_decode ( $value ['staff'] );
  2660. $list = array ();
  2661. foreach ( $v as $n => $m ) {
  2662. if ($m ['1'] == 'ROLE') {
  2663. $roleInfo = $role->getOne ( array (
  2664. 'where' => 'rid=' . $m [0],
  2665. 'asArray' => true
  2666. ) );
  2667. $v [$n] [1] = $roleInfo ['name'];
  2668. array_push ( $list, $roleInfo ['name'] );
  2669. } else {
  2670. array_push ( $list, $v [$n] [1] );
  2671. }
  2672. }
  2673. $veList [$key] ['staff'] = implode ( '>', $list );
  2674. }
  2675. // 配置编辑信息
  2676. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2677. foreach ( $acItem as $key => $value ) {
  2678. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2679. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2680. $acItem [$key] ['price'] = $v ['price'];
  2681. }
  2682. }
  2683. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2684. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2685. $acItem [$key] ['price'] = $v ['price'];
  2686. }
  2687. }
  2688. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2689. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2690. $acItem [$key] ['price'] = $v ['price'];
  2691. }
  2692. }
  2693. //内训
  2694. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2695. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2696. $acItem [$key] ['price'] = $v ['price'];
  2697. }
  2698. }
  2699. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2700. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2701. $acItem [$key] ['price'] = $v ['price'];
  2702. }
  2703. }
  2704. }
  2705. $data ['category'] = $Lcategory->find ( array (
  2706. 'asArray' => true
  2707. ) );
  2708. $data ['ridKey'] = $ridKey;
  2709. $data ['cSum'] = $accountItemList ['cSum'];
  2710. $data ['sum'] = $receiptDetail ['sum'];
  2711. $data ['receiptDetail'] = $receiptDetail;
  2712. $data ['veList'] = $veList;
  2713. $data ['acItem'] = $acItem;
  2714. $data ['memu'] = "receipt";
  2715. $data ['staff'] = $this->staff;
  2716. $data ['receiptMemu'] = 'saeaBorad';
  2717. $data ['verify'] = $receiptDetail ['verify'];
  2718. $data ['verifyId'] = $this->verifyId;
  2719. $data ['executeId'] = $this->executeId;
  2720. $data ['rid'] = $rid;
  2721. if($receiptDetail['receiptClass']==1){
  2722. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2723. }elseif($receiptDetail['receiptClass']==2){
  2724. Doo::loadModel ( 'itinerary' );
  2725. $itinerary = new itinerary ();
  2726. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  2727. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2728. }elseif($receiptDetail['receiptClass']==3){
  2729. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2730. }else{
  2731. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2732. }
  2733. }
  2734. /**
  2735. * 培训班结算
  2736. */
  2737. function receiptTrainAdd() {
  2738. Doo::loadModel ( 'accountItem' );
  2739. $accountItem = new accountItem ();
  2740. $acItem = $accountItem->find ( array (
  2741. 'asArray' => true
  2742. ) );
  2743. // 审批组
  2744. Doo::loadModel ( 'verify' );
  2745. $verify = new verify ();
  2746. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2747. // 办事处
  2748. Doo::loadModel ( 'L_category' );
  2749. $lCategory = new L_category ();
  2750. $data ['category'] = $lCategory->getCategory ();
  2751. $data ['veList'] = $veList;
  2752. $data ['memu'] = "receipt";
  2753. $data ['staff'] = $this->staff;
  2754. $data ['acItem'] = $acItem;
  2755. $data ['receiptMemu'] = 'saeaBorad';
  2756. $data ['verifyId'] = $this->verifyId;
  2757. $data ['executeId'] = $this->executeId;
  2758. $this->render ( "/receipt/receiptTrainAdd", $data );
  2759. }
  2760. /**
  2761. * 添加培训班结算
  2762. */
  2763. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2764. // 培训班信息
  2765. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2766. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2767. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2768. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2769. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2770. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2771. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2772. // 发票信息
  2773. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2774. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2775. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2776. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2777. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2778. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2779. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2780. //&&! empty ( $participants )
  2781. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2782. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2783. header ( 'Content-Type:text/html;charset=utf-8' );
  2784. die ( '请填写联行号' );
  2785. }
  2786. Doo::loadModel ( 'execute' );
  2787. $execute = new execute ();
  2788. $executeDetail = $execute->getOne ( array (
  2789. 'where' => 'mold="培训班结算"',
  2790. 'asArray' => true
  2791. ) );
  2792. if (empty ( $executeDetail )) {
  2793. header ( 'Content-Type:text/html;charset=utf-8' );
  2794. die ( '未设置执行人' );
  2795. }
  2796. Doo::loadClass ( 'XDeode' );
  2797. $XDeode = new XDeode ( 5 );
  2798. $cid = $XDeode->decode ( $cid );
  2799. Doo::loadModel ( 'receipt' );
  2800. $receipt = new receipt ();
  2801. Doo::loadModel ( 'receiptTraining' );
  2802. $receiptTraining = new receiptTraining ();
  2803. // 创建费用培训班
  2804. $item = array (
  2805. 'cid' => $this->staff [0] ['cid'],
  2806. 'categoryName' => $this->staff [0] ['category'],
  2807. 'trainName' => $trainName,
  2808. 'trainStartDate' => $trainStartDate,
  2809. 'trainEndDate' => $trainEndDate,
  2810. 'participants' => $participants,
  2811. 'freeParticipants'=>$freeParticipants,
  2812. 'trainAddress' => $trainAddress,
  2813. 'trainRemarks' => $trainRemarks,
  2814. 'creator' => $this->staff [0] ['sid'],
  2815. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2816. );
  2817. $irid = $receiptTraining->addReceiptTraining ( $item );
  2818. // 报销单
  2819. $receipt->status = 5;
  2820. $receipt->trainId = $irid;
  2821. $receipt->Rtype = 3;
  2822. $receipt->staff = $this->staff [0] ['sid'];
  2823. $receipt->cid = $cid;
  2824. $receipt->verify = $verify;
  2825. $receipt->date = date ( "Y-m-d" );
  2826. $receipt->executeCopy = $executeDetail ['staff'];
  2827. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2828. $receipt->remittanceName = $remittanceName;
  2829. $receipt->bankName = $bankName;
  2830. $receipt->bankNumber = $bankNumber;
  2831. $receipt->remittanceBankType = $remittanceBankType;
  2832. if ($remittanceBankType == 1)
  2833. $receipt->coupletNumber = $coupletNumber;
  2834. $rid = $receipt->insert ();
  2835. $XDeode = new XDeode ( 7 );
  2836. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2837. } else
  2838. die ( 'illegal request' );
  2839. }
  2840. /**
  2841. * 培训班编辑
  2842. */
  2843. function receiptTrainEdi() {
  2844. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2845. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2846. Doo::loadClass ( 'XDeode' );
  2847. $XDeode = new XDeode ( 7 );
  2848. $rid = $XDeode->decode ( $ridKey );
  2849. if (! is_numeric ( $rid ))
  2850. die ( 'illegal request' );
  2851. Doo::loadModel ( 'receipt' );
  2852. $receipt = new receipt ();
  2853. Doo::loadModel ( 'receiptTraining' );
  2854. $receiptTraining = new receiptTraining ();
  2855. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2856. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2857. die ('illegal request--status');
  2858. }
  2859. //如有已入账已收款的发票,自动取消办事处已收款
  2860. // Doo::loadModel ( 'RIExtend' );
  2861. // $RIExtend = new RIExtend ();
  2862. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2863. // if (!empty($RIExtendList)){
  2864. // foreach ($RIExtendList as $key=>$value){
  2865. // $RIExtend = new RIExtend ();
  2866. // $RIExtend->delete(array (
  2867. // 'where' => 'iid=' . $value['iid'],
  2868. // 'limit' => 1
  2869. // ));
  2870. // }
  2871. // }
  2872. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2873. // 汇总表合计
  2874. // 收入合计--加入开票合计
  2875. Doo::loadModel ( 'invoiceTraining' );
  2876. $invoiceTraining = new invoiceTraining ();
  2877. $invoiceTrainingDetail = array (
  2878. 'invoiceArriveAmount' => 0,
  2879. 'RIAmount' => 0,
  2880. 'invoiceTotalAmount' => 0,
  2881. 'invoiceCompanyAmount'=>0
  2882. );
  2883. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2884. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2885. }
  2886. // print_r($invoiceTrainingDetail);
  2887. $invoiceArriveAmount = $RIAmount = 0;
  2888. if (! empty ( $invoiceTrainingDetail )) {
  2889. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2890. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2891. }
  2892. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2893. //print_r($invoiceTrainingDetail);
  2894. // 支出项目
  2895. Doo::loadModel ( 'accountItem' );
  2896. $accountItem = new accountItem ();
  2897. // 项目金额合计
  2898. Doo::loadModel ( 'RItem' );
  2899. $RItem = new RItem ();
  2900. // 讲师获得
  2901. Doo::loadModel ( 'RILecturer' );
  2902. $RILecturer = new RILecturer ();
  2903. $RItemList = $RItem->getRItemByRid ( $rid );
  2904. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2905. // 支出项金额详情
  2906. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2907. // print_r($aiData);
  2908. // 利润
  2909. $profit=$invoiceArriveAmount - $aiData ['total'];
  2910. $companyProfit=$profit * 0.6;
  2911. $categoryProfit=$profit * 0.4;
  2912. $data ['profit'] = sprintf("%.2f",$profit);
  2913. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2914. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2915. //发票利润
  2916. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2917. //发票公司利润
  2918. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2919. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2920. //办事处利润
  2921. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2922. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2923. // print_r($aiData['dataList']);
  2924. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2925. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2926. // 备用金
  2927. $sum = 0;
  2928. $data ['receiptLoanDetail'] = array (
  2929. 'sum' => '0.00'
  2930. );
  2931. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2932. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2933. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2934. $sum=0;
  2935. foreach ($receiptLoanList as $key=>$value){
  2936. $sum+=$value['sum'];
  2937. }
  2938. $data ['receiptLoanDetail'] = array (
  2939. 'sum' => $sum
  2940. );
  2941. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2942. }
  2943. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2944. $data ['payment'] = sprintf("%.2f",$payment);
  2945. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2946. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2947. $data ['aiList'] = $aiData ['dataList'];
  2948. // 占比计算
  2949. if ($invoiceArriveAmount != 0) {
  2950. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2951. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2952. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2953. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2954. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2955. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2956. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2957. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2958. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2959. } else {
  2960. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2961. }
  2962. //发票金额占比计算
  2963. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2964. //支出
  2965. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2966. //利润
  2967. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2968. //公司利润
  2969. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2970. //办事处利润
  2971. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2972. //公司收款
  2973. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2974. //备用金
  2975. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2976. //办事处收款
  2977. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2978. //办事处实际支出
  2979. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2980. //付总部款
  2981. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2982. }else{
  2983. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2984. }
  2985. //讲师人数
  2986. Doo::loadModel ( 'RILecturer' );
  2987. $RILecturer = new RILecturer ();
  2988. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2989. $data['lectureCount']=count($RILecturerList);
  2990. // 审批组
  2991. Doo::loadModel ( 'verify' );
  2992. $verify = new verify ();
  2993. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2994. // 办事处
  2995. Doo::loadModel ( 'L_category' );
  2996. $lCategory = new L_category ();
  2997. $data ['category'] = $lCategory->getCategory ();
  2998. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2999. $data ['receiptDetail'] = $receiptDetail;
  3000. $data ['veList'] = $veList;
  3001. $data ['trainEdiType'] = $trainEdiType;
  3002. $data ['ridKey'] = $ridKey;
  3003. $data ['memu'] = "receipt";
  3004. $data ['staff'] = $this->staff;
  3005. $data ['receiptMemu'] = 'saeaBorad';
  3006. $data ['verifyId'] = $this->verifyId;
  3007. $data ['executeId'] = $this->executeId;
  3008. $this->render ( "/receipt/receiptTrainEdi", $data );
  3009. }
  3010. /**
  3011. * 培训班借款编辑
  3012. */
  3013. function receiptTrainLoanEdi() {
  3014. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3015. Doo::loadClass ( 'XDeode' );
  3016. $XDeode = new XDeode ( 7 );
  3017. $rid = $XDeode->decode ( $ridKey );
  3018. if (! is_numeric ( $rid ))
  3019. die ( 'illegal request' );
  3020. Doo::loadModel ( 'receipt' );
  3021. $receipt = new receipt ();
  3022. Doo::loadModel ( 'receiptTraining' );
  3023. $receiptTraining = new receiptTraining ();
  3024. Doo::loadModel ( 'verify' );
  3025. $verify = new verify ();
  3026. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3027. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3028. die ();
  3029. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3030. // 借款详情HTML
  3031. // 获得借款信息
  3032. $receiptLoanHtml = '';
  3033. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3034. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3035. foreach ($receiptLoanList as $key=>$value){
  3036. // 获得某费用单审批信息
  3037. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3038. Doo::loadClass ( 'receipt.func' );
  3039. $extendHtml = '<p><a class="button"
  3040. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3041. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3042. }
  3043. }
  3044. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3045. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3046. $data ['receiptDetail'] = $receiptDetail;
  3047. $data ['trainEdiType'] = "LOAN";
  3048. $data ['ridKey'] = $ridKey;
  3049. $data ['memu'] = "receipt";
  3050. $data ['staff'] = $this->staff;
  3051. $data ['receiptMemu'] = 'saeaBorad';
  3052. $data ['verifyId'] = $this->verifyId;
  3053. $data ['executeId'] = $this->executeId;
  3054. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3055. }
  3056. /**
  3057. * 更新培训班结算基本信息
  3058. */
  3059. function receiptTrainInfoEdiDo() {
  3060. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3061. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3062. // 培训班信息
  3063. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3064. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3065. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3066. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3067. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3068. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3069. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3070. // 发票信息
  3071. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3072. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3073. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3074. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3075. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3076. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3077. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3078. //&& ! empty ( $participants )
  3079. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3080. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3081. header ( 'Content-Type:text/html;charset=utf-8' );
  3082. die ( '请填写联行号' );
  3083. }
  3084. Doo::loadClass ( 'XDeode' );
  3085. $XDeode = new XDeode ( 5 );
  3086. $cid = $XDeode->decode ( $cid );
  3087. $rtid = $XDeode->decode ( $rtid );
  3088. $rid = $XDeode->decode ( $rid );
  3089. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3090. die ( 'illegal request-IdError' );
  3091. }
  3092. Doo::loadModel ( 'receipt' );
  3093. $receipt = new receipt ();
  3094. Doo::loadModel ( 'receiptTraining' );
  3095. $receiptTraining = new receiptTraining ();
  3096. // 更新费用培训班
  3097. $item = array (
  3098. 'rtid' => $rtid,
  3099. 'trainName' => $trainName,
  3100. 'trainStartDate' => $trainStartDate,
  3101. 'trainEndDate' => $trainEndDate,
  3102. 'participants' => $participants,
  3103. 'freeParticipants'=>$freeParticipants,
  3104. 'trainAddress' => $trainAddress,
  3105. 'trainRemarks' => $trainRemarks
  3106. );
  3107. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3108. // 报销单
  3109. $receipt->rid = $rid;
  3110. $receipt->cid = $cid;
  3111. $receipt->verify = $verify;
  3112. $receipt->remittanceName = $remittanceName;
  3113. $receipt->bankName = $bankName;
  3114. $receipt->bankNumber = $bankNumber;
  3115. $receipt->remittanceBankType = $remittanceBankType;
  3116. if ($remittanceBankType == 1)
  3117. $receipt->coupletNumber = $coupletNumber;
  3118. $receipt->update ();
  3119. $XDeode = new XDeode ( 7 );
  3120. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3121. } else
  3122. die ( 'illegal request' );
  3123. }
  3124. /**
  3125. * 编辑培训班结算---更新借款
  3126. */
  3127. function receiptTrainLoanEdiDo() {
  3128. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3129. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3130. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3131. Doo::loadModel ( 'receipt' );
  3132. $receipt = new receipt ();
  3133. Doo::loadClass ( 'XDeode' );
  3134. $XDeode = new XDeode ( 5 );
  3135. $rid = $XDeode->decode ( $ridKey );
  3136. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3137. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3138. die ( 'illegal request-ridError' );
  3139. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3140. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3141. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3142. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3143. die ( 'illegal request-receiptError' );
  3144. }
  3145. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3146. die ( 'illegal request-receipLoantError' );
  3147. }
  3148. // 培训班结算挂钩借款
  3149. $receipt = new receipt ();
  3150. $trainLoanRid=$ridLoan;
  3151. if (!empty($receiptDetail['trainLoanRid'])){
  3152. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3153. }
  3154. $item = array (
  3155. 'rid' => $rid,
  3156. 'trainLoanRid' => $trainLoanRid
  3157. );
  3158. $receipt->setReceiptByCondition ( $item );
  3159. // 更新借款状态变成已挂钩
  3160. $receipt = new receipt ();
  3161. $item = array (
  3162. 'rid' => $ridLoan,
  3163. 'status' => 10,
  3164. 'statusTrain' => 1
  3165. );
  3166. $receipt->setReceiptByCondition ( $item );
  3167. $XDeode = new XDeode ( 7 );
  3168. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3169. } else
  3170. die ( 'illegal request' );
  3171. }
  3172. /**
  3173. * 编辑培训班结算--移除借款
  3174. */
  3175. function receiptTrainLoanRemoveDo() {
  3176. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3177. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3178. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3179. Doo::loadModel ( 'receipt' );
  3180. $receipt = new receipt ();
  3181. Doo::loadClass ( 'XDeode' );
  3182. $XDeode = new XDeode ( 5 );
  3183. $rid = $XDeode->decode ( $ridKey );
  3184. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3185. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3186. die ( 'illegal request-ridError' );
  3187. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3188. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3189. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3190. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3191. die ( 'illegal request-receiptError' );
  3192. }
  3193. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3194. die ( 'illegal request-receipLoantError' );
  3195. }
  3196. // 培训班结算挂钩借款
  3197. $receipt = new receipt ();
  3198. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3199. foreach ($trainLoanRidArray as $key=>$value){
  3200. if($value==$ridLoan){
  3201. unset($trainLoanRidArray[$key]);
  3202. }
  3203. }
  3204. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3205. $item = array (
  3206. 'rid' => $rid,
  3207. 'trainLoanRid' => $trainLoanRidString
  3208. );
  3209. $receipt->setReceiptByCondition ( $item );
  3210. // 更新借款状态变成已挂钩
  3211. $receipt = new receipt ();
  3212. $item = array (
  3213. 'rid' => $ridLoan,
  3214. 'status' => 8,
  3215. 'statusTrain' => 0
  3216. );
  3217. $receipt->setReceiptByCondition ( $item );
  3218. $XDeode = new XDeode ( 7 );
  3219. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3220. } else
  3221. die ( 'illegal request' );
  3222. }
  3223. /**
  3224. * 编辑培训班结算 ---开票
  3225. */
  3226. function receiptTrainInvoiceEdi() {
  3227. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3228. Doo::loadClass ( 'XDeode' );
  3229. $XDeode = new XDeode ( 7 );
  3230. $rid = $XDeode->decode ( $ridKey );
  3231. if (! is_numeric ( $rid ))
  3232. die ( 'illegal request' );
  3233. Doo::loadModel ( 'receipt' );
  3234. $receipt = new receipt ();
  3235. Doo::loadModel ( 'receiptTraining' );
  3236. $receiptTraining = new receiptTraining ();
  3237. Doo::loadModel ( 'invoice' );
  3238. $invoice = new invoice ();
  3239. Doo::loadModel ( 'invoiceTraining' );
  3240. $invoiceTraining = new invoiceTraining ();
  3241. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3242. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3243. die ();
  3244. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3245. $invoiceList = $invoiceTrainingDetail = array ();
  3246. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3247. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3248. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3249. }
  3250. //print_r($invoiceList);
  3251. $data ['invoiceList'] = $invoiceList;
  3252. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3253. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3254. $data ['receiptDetail'] = $receiptDetail;
  3255. $data ['trainEdiType'] = "INVOICE";
  3256. $data ['ridKey'] = $ridKey;
  3257. $data ['memu'] = "receipt";
  3258. $data ['staff'] = $this->staff;
  3259. $data ['receiptMemu'] = 'saeaBorad';
  3260. $data ['verifyId'] = $this->verifyId;
  3261. $data ['executeId'] = $this->executeId;
  3262. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3263. }
  3264. /**
  3265. * 编辑培训班结算---更新开票
  3266. */
  3267. function receiptTrainInvoiceEdiDo() {
  3268. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3269. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3270. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3271. Doo::loadModel ( 'receipt' );
  3272. $receipt = new receipt ();
  3273. Doo::loadModel ( 'invoiceTraining' );
  3274. $invoiceTraining = new invoiceTraining ();
  3275. Doo::loadClass ( 'XDeode' );
  3276. $XDeode = new XDeode ( 5 );
  3277. $rid = $XDeode->decode ( $ridKey );
  3278. $itid = $XDeode->decode ( $itidKey );
  3279. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3280. die ( 'illegal request-idError' );
  3281. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3282. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3283. // 不合法的数据
  3284. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3285. die ( 'illegal request-receiptError' );
  3286. }
  3287. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3288. die ( 'illegal request-receipLoantError' );
  3289. }
  3290. // 培训班结算挂钩借款
  3291. $receipt = new receipt ();
  3292. $item = array (
  3293. 'rid' => $rid,
  3294. 'invoiceTrainId' => $itid
  3295. );
  3296. $receipt->setReceiptByCondition ( $item );
  3297. $invoiceTraining = new invoiceTraining ();
  3298. $item = array (
  3299. 'bindReceipt' => 1,
  3300. 'itid' => $itid
  3301. );
  3302. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3303. $XDeode = new XDeode ( 7 );
  3304. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3305. } else
  3306. die ( 'illegal request' );
  3307. }
  3308. /**
  3309. * 更新培训班结算 收款和取消收款
  3310. */
  3311. function receiptTrainReceivables() {
  3312. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3313. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3314. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3315. Doo::loadClass ( 'XDeode' );
  3316. $XDeode = new XDeode ( 5 );
  3317. $rid = $XDeode->decode ( $ridKey );
  3318. $iid = $XDeode->decode ( $iidKey );
  3319. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3320. die ( 'illegal request-iid' );
  3321. Doo::loadModel ( 'RIExtend' );
  3322. $RIExtend = new RIExtend ();
  3323. if ($doType == 'CONFIRM') {
  3324. $RIExtend->rid = $rid;
  3325. $RIExtend->iid = $iid;
  3326. $RIExtend->RIstatus = 1;
  3327. $RIExtend->insert ();
  3328. echo json_encode ( array (
  3329. 'status' => 1,
  3330. ) );
  3331. die ( );
  3332. } elseif ($doType == 'CANCEL') {
  3333. $RIExtend->delete ( array (
  3334. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3335. 'limit' => 1
  3336. ) );
  3337. echo json_encode ( array (
  3338. 'status' => 1,
  3339. ) );
  3340. die ( );
  3341. } else {
  3342. echo json_encode ( array (
  3343. 'status' => 2,
  3344. ) );
  3345. die ( );
  3346. }
  3347. }
  3348. /**
  3349. * 移除挂钩的培训班发票
  3350. */
  3351. function receiptTrainReceivablesDelDo() {
  3352. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3353. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3354. Doo::loadModel ( 'receipt' );
  3355. $receipt = new receipt ();
  3356. Doo::loadModel ( 'RIExtend' );
  3357. $RIExtend = new RIExtend ();
  3358. Doo::loadClass ( 'XDeode' );
  3359. $XDeode = new XDeode ( 5 );
  3360. $rid = $XDeode->decode ( $ridKey );
  3361. $itid = $XDeode->decode ( $itidKey );
  3362. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3363. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3364. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3365. die ( 'illegal request-status' );
  3366. }
  3367. $receipt = new receipt ();
  3368. $receipt->rid = $rid;
  3369. $receipt->invoiceTrainId = 0;
  3370. $receipt->update ();
  3371. Doo::loadModel ( 'invoiceTraining' );
  3372. $invoiceTraining = new invoiceTraining ();
  3373. $item = array (
  3374. 'bindReceipt' => 0,
  3375. 'itid' => $itid
  3376. );
  3377. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3378. $RIExtend->delete ( array (
  3379. 'where' => 'rid=' . $rid
  3380. ) );
  3381. $XDeode = new XDeode ( 7 );
  3382. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3383. } else
  3384. die ( 'illegal request-iid' );
  3385. }
  3386. /**
  3387. * 编辑培训班结算
  3388. */
  3389. function receiptTrainItemEdi() {
  3390. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3391. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3392. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3393. Doo::loadClass ( 'XDeode' );
  3394. $XDeode = new XDeode ( 7 );
  3395. $rid = $XDeode->decode ( $ridKey );
  3396. if (! is_numeric ( $rid ))
  3397. die ( 'illegal request' );
  3398. Doo::loadModel ( 'receipt' );
  3399. $receipt = new receipt ();
  3400. Doo::loadModel ( 'receiptTraining' );
  3401. $receiptTraining = new receiptTraining ();
  3402. Doo::loadModel ( 'RItem' );
  3403. $RItem = new RItem ();
  3404. Doo::loadModel ( 'accountItem' );
  3405. $accountItem = new accountItem ();
  3406. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3407. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3408. die ();
  3409. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3410. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3411. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3412. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3413. // if($value['name']=='税款'){
  3414. // unset($aiList[$key]);break;
  3415. // }
  3416. // }
  3417. //print_r($RItemList);
  3418. $data ['name'] = $name;
  3419. $data ['RItemList'] = $RItemList;
  3420. $data ['aiList'] = $aiList;
  3421. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3422. $data ['receiptDetail'] = $receiptDetail;
  3423. $data ['trainEdiType'] = "ITEM";
  3424. $data ['ridKey'] = $ridKey;
  3425. $data ['memu'] = "receipt";
  3426. $data ['staff'] = $this->staff;
  3427. $data ['receiptMemu'] = 'saeaBorad';
  3428. $data ['verifyId'] = $this->verifyId;
  3429. $data ['executeId'] = $this->executeId;
  3430. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3431. }
  3432. /**
  3433. * 添加支出项 需要修改 费用金额合计
  3434. */
  3435. function receiptTrainItemAddDo() {
  3436. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3437. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3438. // 支出项信息
  3439. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3440. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3441. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3442. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3443. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3444. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3445. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3446. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3447. Doo::loadClass ( 'XDeode' );
  3448. $XDeode = new XDeode ( 5 );
  3449. Doo::loadModel ( 'RItem' );
  3450. $RItem = new RItem ();
  3451. $rid = $XDeode->decode ( $ridKey );
  3452. $rtid= $XDeode->decode ( $rtidKey );
  3453. if (! is_numeric ( $rid )){
  3454. die ( 'illegal request' );
  3455. }
  3456. Doo::loadModel ( 'receiptDetail' );
  3457. $receiptDetail = new receiptDetail ();
  3458. Doo::loadModel ( 'receipt' );
  3459. $receipt = new receipt ();
  3460. Doo::loadModel ( 'receiptTraining' );
  3461. $receiptTraining = new receiptTraining ();
  3462. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3463. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3464. $order = array (
  3465. "\r\n",
  3466. "\n",
  3467. "\r"
  3468. );
  3469. $replace = '<br/>';
  3470. $describe = str_replace ( $order, $replace, $describe );
  3471. $itemData = array (
  3472. 'rid' => $rid,
  3473. 'item' => $item,
  3474. 'price' => $price,
  3475. 'date' => $date,
  3476. 'inputer' => $inputer,
  3477. 'describe' => $describe,
  3478. 'creater' => $this->staff['0']['username'],
  3479. 'createrId' => $this->staff['0']['sid'],
  3480. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3481. 'identifying'=>$identifyingTotal
  3482. );
  3483. if($payType=='company'){
  3484. $itemData += array (
  3485. 'payType' => 1
  3486. );
  3487. }
  3488. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3489. //更新支出项标识总数
  3490. $itemData = array (
  3491. 'rtid'=>$rtid,
  3492. 'identifyingTotal'=>$identifyingTotal
  3493. );
  3494. $receiptTraining->setReceiptTrainByCondition($itemData);
  3495. $XDeode = new XDeode ( 7 );
  3496. if($payType=='company'){
  3497. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3498. }else{
  3499. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3500. }
  3501. } else
  3502. die ( 'illegal request-dataError' );
  3503. }
  3504. /**
  3505. * 培训班结算-讲师
  3506. */
  3507. function receiptTrainLecturerEdi() {
  3508. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3509. Doo::loadClass ( 'XDeode' );
  3510. $XDeode = new XDeode ( 7 );
  3511. $rid = $XDeode->decode ( $ridKey );
  3512. if (! is_numeric ( $rid ))
  3513. die ( 'illegal request' );
  3514. Doo::loadModel ( 'receipt' );
  3515. $receipt = new receipt ();
  3516. Doo::loadModel ( 'receiptTraining' );
  3517. $receiptTraining = new receiptTraining ();
  3518. Doo::loadModel ( 'RILecturer' );
  3519. $RILecturer = new RILecturer ();
  3520. Doo::loadModel ( 'lecturer' );
  3521. $lecturer = new lecturer ();
  3522. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3523. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3524. die ();
  3525. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3526. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3527. $lecturerList = $lecturer->getLecturerAll ();
  3528. $INSIDEhtml = $OUTSIDEhtml = '';
  3529. foreach ( $lecturerList as $key => $value ) {
  3530. if ($value ['ltype'] == 'INSIDE') {
  3531. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3532. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3533. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3534. }
  3535. }
  3536. $data ['INSIDEhtml'] = $INSIDEhtml;
  3537. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3538. // print_r($RItemList);
  3539. $data ['RILecturerList'] = $RILecturerList;
  3540. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3541. $data ['receiptDetail'] = $receiptDetail;
  3542. $data ['trainEdiType'] = "LECTURER";
  3543. $data ['ridKey'] = $ridKey;
  3544. $data ['memu'] = "receipt";
  3545. $data ['staff'] = $this->staff;
  3546. $data ['receiptMemu'] = 'saeaBorad';
  3547. $data ['verifyId'] = $this->verifyId;
  3548. $data ['executeId'] = $this->executeId;
  3549. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3550. }
  3551. /**
  3552. * 添加讲师
  3553. */
  3554. function receiptTrainLecturerAddDo() {
  3555. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3556. // 支出项信息
  3557. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3558. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3559. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3560. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3561. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3562. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3563. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3564. Doo::loadClass ( 'XDeode' );
  3565. $XDeode = new XDeode ( 5 );
  3566. Doo::loadModel ( 'RILecturer' );
  3567. $RILecturer = new RILecturer ();
  3568. $rid = $XDeode->decode ( $ridKey );
  3569. if (! is_numeric ( $rid ))
  3570. die ( 'illegal request' );
  3571. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3572. die ( 'illegal request-taxationError' );
  3573. $RILecturer->rid = $rid;
  3574. $RILecturer->ltype = $ltype;
  3575. if ($ltype == 'OUTSIDE') {
  3576. if ($taxation == 'TAXATION') {
  3577. $RILecturer->taxation = 1;
  3578. } elseif ($taxation == 'NOTAXATION') {
  3579. $RILecturer->taxation = 0;
  3580. }
  3581. }
  3582. $RILecturer->lecturerName = $lecturerName;
  3583. $RILecturer->schoolDay = $schoolDay;
  3584. $RILecturer->price = $price;
  3585. $RILecturer->fees=$fees;
  3586. $RILecturer->insert ();
  3587. // 添加公司汇总
  3588. // 报销详情
  3589. Doo::loadModel ( 'receiptDetail' );
  3590. $receiptDetail = new receiptDetail ();
  3591. Doo::loadModel ( 'receipt' );
  3592. $receipt = new receipt ();
  3593. // 金额总计
  3594. $price = $price * $schoolDay;
  3595. $rInfo = $receipt->getReceiptByRid ( $rid );
  3596. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3597. if (empty ( $rdInfo )) {
  3598. $receiptDetail = new receiptDetail ();
  3599. $receiptDetail->staff = $rInfo ['staff'];
  3600. $receiptDetail->item = '讲课费';
  3601. $receiptDetail->itemCategory = '培训班费用';
  3602. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3603. $receiptDetail->date = date ( "Y-m-d" );
  3604. $receiptDetail->cid = $rInfo ['cid'];
  3605. $receiptDetail->rid = $rid;
  3606. $receiptDetail->status = 4;
  3607. $receiptDetail->insert ();
  3608. } else {
  3609. $receiptDetail = new receiptDetail ();
  3610. $rdInfo ['price'] += $fees;
  3611. $receiptDetail->price = $rdInfo ['price'];
  3612. $receiptDetail->update ( array (
  3613. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3614. ) );
  3615. }
  3616. $receipt = new receipt ();
  3617. $receipt->sum=$rInfo['sum']+$fees;
  3618. $receipt->update ( array (
  3619. 'where' => 'rid=' . $rid
  3620. ) );
  3621. $XDeode = new XDeode ( 7 );
  3622. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3623. } else
  3624. die ( 'illegal request' );
  3625. }
  3626. /**
  3627. * 移除讲师
  3628. */
  3629. function receiptTrainLecturerDelDo() {
  3630. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3631. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3632. Doo::loadModel ( 'receipt' );
  3633. $receipt = new receipt ();
  3634. Doo::loadModel ( 'RILecturer' );
  3635. $RILecturer = new RILecturer ();
  3636. Doo::loadClass ( 'XDeode' );
  3637. $XDeode = new XDeode ( 5 );
  3638. $rid = $XDeode->decode ( $ridKey );
  3639. $rlid = $XDeode->decode ( $rlidKey );
  3640. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3641. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3642. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3643. die ( 'illegal request-status' );
  3644. }
  3645. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3646. if (empty($detail)){
  3647. die ( 'illegal request-data' );
  3648. }
  3649. $RILecturer->delete ( array (
  3650. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3651. ) );
  3652. //更新费用合计金额
  3653. $rInfo = $receipt->getReceiptByRid ( $rid );
  3654. $receipt = new receipt ();
  3655. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3656. $receipt->update ( array (
  3657. 'where' => 'rid=' . $rid
  3658. ) );
  3659. Doo::loadModel ( 'receiptDetail' );
  3660. $receiptDetail = new receiptDetail ();
  3661. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3662. $receiptDetail = new receiptDetail ();
  3663. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3664. $receiptDetail->price = $rdInfo ['price'];
  3665. $receiptDetail->update ( array (
  3666. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3667. ) );
  3668. $XDeode = new XDeode ( 7 );
  3669. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3670. } else
  3671. die ( 'illegal request-iid' );
  3672. }
  3673. /**
  3674. * 培训班提交审批
  3675. */
  3676. function receiptTrainDo() {
  3677. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3678. Doo::loadClass ( 'XDeode' );
  3679. $XDeode = new XDeode ( 7 );
  3680. $rid = $XDeode->decode ( $ridKey );
  3681. Doo::loadModel ( 'receipt' );
  3682. $receipt = new receipt ();
  3683. Doo::loadModel ( 'receiptDetail' );
  3684. $receiptDetail = new receiptDetail ();
  3685. Doo::loadModel ( 'statistics' );
  3686. $statistics = new statistics ();
  3687. Doo::loadModel ( "verify" );
  3688. $verify = new verify ();
  3689. // 审批状态的判定
  3690. $receiptDetailList = $receipt->getOne ( array (
  3691. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3692. 'asArray' => true
  3693. ) );
  3694. if (empty ( $receiptDetailList ))
  3695. return "/saeaBorad";
  3696. $verifyDetail = $verify->getOne ( array (
  3697. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3698. 'asArray' => true
  3699. ) );
  3700. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3701. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3702. $nowStaff = "";
  3703. $nowStaffList = array ();
  3704. if ($verifyDetail [0] [1] == 'ROLE') {
  3705. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3706. foreach ( $vStaffString as $key => $value ) {
  3707. $staffK = explode ( "_", $value );
  3708. array_push ( $nowStaffList, $staffK [0] );
  3709. }
  3710. $nowStaff = implode ( ',', $nowStaffList );
  3711. } else {
  3712. $nowStaff = $verifyDetail [0] [0];
  3713. }
  3714. $receipt->nowStaff = $nowStaff;
  3715. }
  3716. // echo $nowStaff;
  3717. // print_r($verifyDetail);die;
  3718. $receipt->rid = $receiptDetailList ['rid'];
  3719. $receipt->date = date ( "Y-m-d" );
  3720. $receipt->status = 2;
  3721. $receipt->update ();
  3722. $receiptDetail->status = 2;
  3723. $receiptDetail->update ( array (
  3724. 'where' => 'rid=' . $receiptDetailList ['rid']
  3725. ) );
  3726. Doo::loadModel ( "receiptLog" );
  3727. $receiptLog = new receiptLog ();
  3728. Doo::loadModel ( "verify" );
  3729. $verify = new verify ();
  3730. $vr = $verify->getOne ( array (
  3731. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3732. 'asArray' => true
  3733. ) );
  3734. $jd = json_decode ( $vr ['staff'] );
  3735. $roleId = 0;
  3736. foreach ( $jd as $key => $value ) {
  3737. if ($value [1] == 'ROLE') {
  3738. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3739. if ($pos !== false) {
  3740. $roleId = $value [0];
  3741. }
  3742. }
  3743. }
  3744. // 审批日志
  3745. // echo $roleId;die;
  3746. if (! empty ( $roleId )) {
  3747. Doo::loadModel ( "role" );
  3748. $role = new role ();
  3749. $roleInfo = $role->getOne ( array (
  3750. 'where' => 'rid=' . $roleId,
  3751. 'asArray' => true
  3752. ) );
  3753. // $receiptLog->rolename = $roleInfo ['name'];
  3754. }
  3755. $receiptLog->username = $this->staff [0] ['username'];
  3756. $receiptLog->uid = $this->staff [0] ['sid'];
  3757. $receiptLog->date = date ( "Y-m-d" );
  3758. $receiptLog->opinion = '提交审批';
  3759. $receiptLog->img = $this->staff [0] ['avatar'];
  3760. $receiptLog->status = 2;
  3761. $receiptLog->rid = $rid;
  3762. $receiptLog->insert ();
  3763. // 写入列表项
  3764. Doo::loadModel ( 'accountItem' );
  3765. $accountItem = new accountItem ();
  3766. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3767. // 项目金额合计
  3768. Doo::loadModel ( 'RItem' );
  3769. $RItem = new RItem ();
  3770. // 讲师获得
  3771. Doo::loadModel ( 'RILecturer' );
  3772. $RILecturer = new RILecturer ();
  3773. $RItemList = $RItem->getRItemByRid ( $rid );
  3774. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3775. // 支出项金额详情
  3776. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3777. // print_r($aItem);
  3778. // print_r($aiData);
  3779. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3780. $ag = $tr = $ta = $ot = 0;
  3781. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3782. foreach ( $aItem as $key => $value ) {
  3783. if ($value ['category'] == $this->TRAIN) {
  3784. foreach ( $aiData ['dataList'] as $k => $v ) {
  3785. if ($value ['name'] == $v ['name']) {
  3786. array_push ( $accountJson [$this->TRAIN], array (
  3787. 'aid' => $value ['aid'],
  3788. 'name' => $value ['name'],
  3789. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3790. ) );
  3791. $sum += $v ['price'];
  3792. $trainSum += $v ['price'];
  3793. unset ( $aiData ['dataList'] [$k] );
  3794. break;
  3795. }
  3796. }
  3797. }
  3798. }
  3799. $accountJson ['cSum'] = array (
  3800. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3801. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3802. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3803. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3804. );
  3805. // 报销单
  3806. $receipt = new receipt ();
  3807. $receipt->accountItem = json_encode ( $accountJson );
  3808. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3809. $receipt->update ( array (
  3810. 'where' => 'rid=' . $rid
  3811. ) );
  3812. // print_r($accountJson);
  3813. // statistics item 统计写入
  3814. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3815. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3816. $accountItem = $accountJson;
  3817. $stat = $statistics->getOne ( array (
  3818. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3819. 'asArray' => true
  3820. ) );
  3821. if (empty ( $stat )) {
  3822. $statistics->date = date ( "Y-m-d" );
  3823. $statistics->cid = $this->staff [0] ['cid'];
  3824. $statistics->staff = $this->staff [0] ['sid'];
  3825. $statistics->agPrice = 0;
  3826. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3827. $statistics->insert ();
  3828. } else {
  3829. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3830. $statistics->update ( array (
  3831. 'where' => 'sid=' . $stat ['sid']
  3832. ) );
  3833. }
  3834. return "/saeaBorad";
  3835. }
  3836. function confirmation() {
  3837. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3838. Doo::loadModel ( 'receipt' );
  3839. Doo::loadModel ( 'receiptDetail' );
  3840. $receipt = new receipt ();
  3841. $receiptDetail = new receiptDetail ();
  3842. Doo::loadModel ( 'statistics' );
  3843. Doo::loadModel ( 'itemStatistics' );
  3844. $statistics = new statistics ();
  3845. $itemStatistics = new itemStatistics ();
  3846. Doo::loadModel ( "verify" );
  3847. $verify = new verify ();
  3848. $receiptDetailList = $receipt->getOne ( array (
  3849. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3850. 'asArray' => true
  3851. ) );
  3852. if (empty ( $receiptDetailList ))
  3853. return "/saeaBorad";
  3854. $verifyDetail = $verify->getOne ( array (
  3855. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3856. 'asArray' => true
  3857. ) );
  3858. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3859. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3860. $nowStaff = "";
  3861. $nowStaffList = array ();
  3862. if ($verifyDetail [0] [1] == 'ROLE') {
  3863. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3864. foreach ( $vStaffString as $key => $value ) {
  3865. $staffK = explode ( "_", $value );
  3866. array_push ( $nowStaffList, $staffK [0] );
  3867. }
  3868. $nowStaff = implode ( ',', $nowStaffList );
  3869. } else {
  3870. $nowStaff = $verifyDetail [0] [0];
  3871. }
  3872. $receipt->nowStaff = $nowStaff;
  3873. }
  3874. // echo $nowStaff;
  3875. // print_r($verifyDetail);die;
  3876. $receipt->rid = $receiptDetailList ['rid'];
  3877. $receipt->status = 2;
  3878. $receipt->update ();
  3879. // 操作日志
  3880. Doo::loadModel ( "receiptLog" );
  3881. $receiptLog = new receiptLog ();
  3882. $verify = new verify ();
  3883. $receiptInfo = $receipt->getOne ( array (
  3884. 'where' => 'rid=' . $rid,
  3885. 'asArray' => true
  3886. ) );
  3887. $vr = $verify->getOne ( array (
  3888. 'where' => 'vid=' . $receiptInfo ['verify'],
  3889. 'asArray' => true
  3890. ) );
  3891. $jd = json_decode ( $vr ['staff'] );
  3892. $roleId = 0;
  3893. foreach ( $jd as $key => $value ) {
  3894. if ($value [1] == 'ROLE') {
  3895. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3896. if ($pos !== false) {
  3897. $roleId = $value [0];
  3898. }
  3899. }
  3900. }
  3901. // 审批日志
  3902. // echo $roleId;die;
  3903. if (! empty ( $roleId )) {
  3904. Doo::loadModel ( "role" );
  3905. $role = new role ();
  3906. $roleInfo = $role->getOne ( array (
  3907. 'where' => 'rid=' . $roleId,
  3908. 'asArray' => true
  3909. ) );
  3910. // $receiptLog->rolename = $roleInfo ['name'];
  3911. }
  3912. $receiptLog->username = $this->staff [0] ['username'];
  3913. $receiptLog->uid = $this->staff [0] ['sid'];
  3914. $receiptLog->date = date ( "Y-m-d" );
  3915. $receiptLog->opinion = '提交审批';
  3916. $receiptLog->img = $this->staff [0] ['avatar'];
  3917. $receiptLog->status = 2;
  3918. $receiptLog->rid = $rid;
  3919. $receiptLog->insert ();
  3920. return "/expenses";
  3921. }
  3922. function expenses() {
  3923. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3924. if (empty ( $item ))
  3925. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3926. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3927. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3928. Doo::loadClass ( 'XDeode' );
  3929. $XDeode = new XDeode ( 7 );
  3930. Doo::loadModel ( 'receipt' );
  3931. $receipt = new receipt ();
  3932. Doo::loadModel ( 'L_category' );
  3933. $Lcategory = new L_category ();
  3934. Doo::loadModel ( 'verify' );
  3935. Doo::loadModel ( 'statistics' );
  3936. $statistics = new statistics ();
  3937. $verify = new verify ();
  3938. Doo::loadModel ( 'staff' );
  3939. $staff = new staff ();
  3940. $condition = "";
  3941. if ($item == "expenses")
  3942. $condition = " and Rtype=1 ";
  3943. elseif ($item == "receipts")
  3944. $condition = " and Rtype=0 ";
  3945. elseif ($item == "remits")
  3946. $condition = " and Rtype=2 ";
  3947. elseif ($item == "train")
  3948. $condition = " and Rtype=3 ";
  3949. $dateCondition = " and Year(date) =" . $year;
  3950. if (! empty ( $moth )) {
  3951. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3952. $stList = $statistics->getOne ( array (
  3953. 'select' => 'rePrice ,agPrice',
  3954. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3955. 'asArray' => true
  3956. ) );
  3957. } else
  3958. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3959. if (empty ( $stList ))
  3960. $stList = array (
  3961. 'rePrice' => 0,
  3962. 'agPrice' => 0
  3963. );
  3964. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3965. if (! isset ( $noPassSum ['sum'] ))
  3966. $noPassSum ['sum'] = 0;
  3967. $data ['stList'] = array (
  3968. 'rePrice' => $stList ['rePrice'],
  3969. 'agPrice' => $stList ['agPrice'],
  3970. 'skPrice' => ($noPassSum ['sum'])
  3971. );
  3972. $receiptList = $receipt->find ( array (
  3973. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3974. 'desc' => 'rid',
  3975. 'asArray' => true
  3976. ) );
  3977. $Locate = 0;
  3978. $roleId = 0;
  3979. $button = 0;
  3980. foreach ( $receiptList as $key => $value ) {
  3981. $receiptList[$key]['balance']='';
  3982. if($value['Rtype']==1){
  3983. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3984. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3985. }elseif($value['Rtype']==3){
  3986. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3987. $receiptList[$key]['payment']=$payment;
  3988. $receiptList[$key]['paymentABS']=abs($payment);
  3989. }
  3990. $receiptList [$key] ['Locate'] = $Locate;
  3991. $Locate ++;
  3992. $receiptList [$key] ['reviseDetail'] = array ();
  3993. if (! empty ( $value ['reviseDetail'] ))
  3994. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3995. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3996. $categoryDetil = $Lcategory->getOne ( array (
  3997. 'where' => 'cid=' . $value ['cid'],
  3998. 'asArray' => true
  3999. ) );
  4000. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4001. // 检测编辑状态
  4002. $verifyList = $verify->getOne ( array (
  4003. 'where' => 'vid=' . $value ['verify'],
  4004. 'asArray' => true
  4005. ) );
  4006. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4007. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4008. Doo::loadModel ( 'role' );
  4009. $role = new role ();
  4010. $flag = true;
  4011. $roleKey = 0;
  4012. $endStaffArray = array ();
  4013. $roleArrayCopy = array ();
  4014. foreach ( $verifyList as $k => $v ) {
  4015. // init verifyStaff
  4016. if ($v [1] == 'ROLE') {
  4017. if (! empty ( $verifyStaff )) {
  4018. $endStaffArray = end ( $verifyStaff );
  4019. // if ($v[0]==$endStaffArray['nextStaff']){
  4020. // $roleId=$v[0];
  4021. // }
  4022. }
  4023. $roleVerify = json_decode ( $v [3], true );
  4024. $roleKey = $k;
  4025. $roleArray = array ();
  4026. $rolename = $role->getOne ( array (
  4027. 'where' => 'rid=' . $v [0],
  4028. 'asArray' => true
  4029. ) );
  4030. foreach ( $roleVerify as $o => $p ) {
  4031. $staffID = explode ( '_', $p );
  4032. $staffInfo = $staff->getOne ( array (
  4033. 'where' => 'sid=' . $staffID [0],
  4034. 'asArray' => true
  4035. ) );
  4036. // print_r($staffID);
  4037. $exp = array (
  4038. 0 => $staffInfo ['sid'],
  4039. 1 => $staffID [1],
  4040. 2 => $staffInfo ['avatar'],
  4041. 'date' => '',
  4042. 'date' => '',
  4043. 'opinion' => '',
  4044. 'status' => '',
  4045. 'rolename' => $rolename ['name']
  4046. );
  4047. array_push ( $roleArray, $exp );
  4048. }
  4049. $roleArrayCopy [$v [0]] = $roleArray;
  4050. // $verifyList[$k]['roleArray']=$roleArray;
  4051. }
  4052. $verifyList [$k] ['date'] = "";
  4053. $verifyList [$k] ['opinion'] = "";
  4054. $verifyList [$k] ['status'] = "";
  4055. if (empty ( $verifyStaff )) {
  4056. $verifyList [$k] ['date'] = "";
  4057. $verifyList [$k] ['opinion'] = "";
  4058. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4059. $verifyList [$k] ['status'] = 4;
  4060. $flag = false;
  4061. }
  4062. } else {
  4063. foreach ( $verifyStaff as $m => $u ) {
  4064. if ($v [0] == $m) {
  4065. $verifyList [$k] ['date'] = $u ['date'];
  4066. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4067. $verifyList [$k] ['status'] = $u ['status'];
  4068. $flag = false;
  4069. break;
  4070. }
  4071. }
  4072. $endStaffArray = end ( $verifyStaff );
  4073. if (isset ( $endStaffArray ['ROLE'] )) {
  4074. } else {
  4075. // $endKey=key($verifyStaff);
  4076. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4077. // $button=4;
  4078. // $verifyList[$k]['status']=4;
  4079. // }
  4080. }
  4081. }
  4082. }
  4083. $rolename ['name'] = '';
  4084. if (! empty ( $roleId )) {
  4085. Doo::loadModel ( 'role' );
  4086. $role = new role ();
  4087. $rolename = $role->getOne ( array (
  4088. 'where' => 'rid=' . $roleId,
  4089. 'asArray' => true
  4090. ) );
  4091. }
  4092. if (! empty ( $verifyStaff ))
  4093. $endStaffArray = end ( $verifyStaff );
  4094. $KOP = false;
  4095. foreach ( $roleArrayCopy as $P => $A ) {
  4096. foreach ( $A as $MKI => $AVL ) {
  4097. if (! empty ( $verifyStaff )) {
  4098. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4099. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4100. $button = 4;
  4101. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4102. }
  4103. foreach ( $verifyStaff as $m => $u ) {
  4104. $AVLFK = $AVL [0] . '_R';
  4105. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4106. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4107. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4108. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4109. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4110. break;
  4111. }
  4112. }
  4113. } else {
  4114. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4115. $button = 4;
  4116. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4117. }
  4118. }
  4119. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4120. $KOP = true;
  4121. }
  4122. }
  4123. foreach ( $roleArrayCopy as $k => $v ) {
  4124. foreach ( $verifyList as $m => $n ) {
  4125. if ($n [0] == $k) {
  4126. array_splice ( $verifyList, $m, 1, $v );
  4127. }
  4128. }
  4129. }
  4130. $receiptList [$key] ['verifyList'] = $verifyList;
  4131. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4132. 'where' => 'sid=' . $value ['staff'],
  4133. 'asArray' => true
  4134. ) );
  4135. $receiptList [$key] ['button'] = $button;
  4136. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4137. }
  4138. // print_r($receiptList);die;
  4139. $mothHtml = "";
  4140. for($i = 1; $i <= 12; $i ++) {
  4141. if ($moth == $i)
  4142. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4143. else
  4144. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4145. }
  4146. $dateHtml = "";
  4147. $now = date ( "Y" );
  4148. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4149. if ($YEARD <= $now) {
  4150. $dateHtml .= '<option ';
  4151. if ($year == $YEARD) {
  4152. $dateHtml .= 'selected ';
  4153. }
  4154. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4155. }
  4156. }
  4157. $data ['dateHtml'] = $dateHtml;
  4158. $data ['mothHtml'] = $mothHtml;
  4159. $data ['receiptList'] = $receiptList;
  4160. $data ['memu'] = "receipt";
  4161. $data ['staff'] = $this->staff;
  4162. $data ['receiptMemu'] = 'expenses';
  4163. $data ['verifyId'] = $this->verifyId;
  4164. $data ['executeId'] = $this->executeId;
  4165. $data ['item'] = $item;
  4166. $data ['year'] = $year;
  4167. $this->render ( "/admin/expenses", $data );
  4168. }
  4169. function expensesCollect() {
  4170. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4171. Doo::loadModel ( 'receipt' );
  4172. $receipt = new receipt ();
  4173. Doo::loadModel ( 'L_category' );
  4174. $Lcategory = new L_category ();
  4175. Doo::loadModel ( 'verify' );
  4176. Doo::loadModel ( 'statistics' );
  4177. $statistics = new statistics ();
  4178. $verify = new verify ();
  4179. Doo::loadModel ( 'staff' );
  4180. $staff = new staff ();
  4181. Doo::loadModel ( 'loanReceipt' );
  4182. $loanReceipt = new loanReceipt ();
  4183. $receiptList = $receipt->find ( array (//去掉
  4184. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4185. 'desc' => 'rid',
  4186. 'asArray' => true
  4187. ) );
  4188. $loanList = $loanReceipt->find ( array (
  4189. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4190. 'desc' => 'rid',
  4191. 'asArray' => true
  4192. ) );
  4193. /*
  4194. * $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;
  4195. */
  4196. $data ['explanation'] = '';
  4197. if (! empty ( $loanList ))
  4198. $data ['explanation'] = $loanList [0] ['explanation'];
  4199. $Locate = 0;
  4200. $roleId = 0;
  4201. $button = 0;
  4202. foreach ( $receiptList as $key => $value ) {
  4203. $receiptList [$key] ['Locate'] = $Locate;
  4204. $Locate ++;
  4205. $receiptList [$key] ['reviseDetail'] = array ();
  4206. if (! empty ( $value ['reviseDetail'] ))
  4207. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4208. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4209. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4210. $categoryDetil = $Lcategory->getOne ( array (
  4211. 'where' => 'cid=' . $value ['cid'],
  4212. 'asArray' => true
  4213. ) );
  4214. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4215. // 检测编辑状态
  4216. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4217. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4218. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4219. else
  4220. $verifyList ['staff'] = $value ['verifyBreakup'];
  4221. } else
  4222. $verifyList = $verify->getOne ( array (
  4223. 'where' => 'vid=' . $value ['verify'],
  4224. 'asArray' => true
  4225. ) );
  4226. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4227. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4228. Doo::loadModel ( 'role' );
  4229. $role = new role ();
  4230. $flag = true;
  4231. $roleKey = 0;
  4232. $endStaffArray = array ();
  4233. $roleArrayCopy = array ();
  4234. foreach ( $verifyList as $k => $v ) {
  4235. // init verifyStaff
  4236. if ($v [1] == 'ROLE') {
  4237. if (! empty ( $verifyStaff )) {
  4238. $endStaffArray = end ( $verifyStaff );
  4239. // if ($v[0]==$endStaffArray['nextStaff']){
  4240. // $roleId=$v[0];
  4241. // }
  4242. }
  4243. $roleVerify = json_decode ( $v [3], true );
  4244. $roleKey = $k;
  4245. $roleArray = array ();
  4246. $rolename = $role->getOne ( array (
  4247. 'where' => 'rid=' . $v [0],
  4248. 'asArray' => true
  4249. ) );
  4250. foreach ( $roleVerify as $o => $p ) {
  4251. $staffID = explode ( '_', $p );
  4252. $staffInfo = $staff->getOne ( array (
  4253. 'where' => 'sid=' . $staffID [0],
  4254. 'asArray' => true
  4255. ) );
  4256. // print_r($staffID);
  4257. $exp = array (
  4258. 0 => $staffInfo ['sid'],
  4259. 1 => $staffID [1],
  4260. 2 => $staffInfo ['avatar'],
  4261. 'date' => '',
  4262. 'date' => '',
  4263. 'opinion' => '',
  4264. 'status' => '',
  4265. 'rolename' => $rolename ['name']
  4266. );
  4267. array_push ( $roleArray, $exp );
  4268. }
  4269. $roleArrayCopy [$v [0]] = $roleArray;
  4270. // $verifyList[$k]['roleArray']=$roleArray;
  4271. }
  4272. $verifyList [$k] ['date'] = "";
  4273. $verifyList [$k] ['opinion'] = "";
  4274. $verifyList [$k] ['status'] = "";
  4275. if (empty ( $verifyStaff )) {
  4276. $verifyList [$k] ['date'] = "";
  4277. $verifyList [$k] ['opinion'] = "";
  4278. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4279. $verifyList [$k] ['status'] = 4;
  4280. $flag = false;
  4281. }
  4282. } else {
  4283. foreach ( $verifyStaff as $m => $u ) {
  4284. if ($v [0] == $m) {
  4285. $verifyList [$k] ['date'] = $u ['date'];
  4286. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4287. $verifyList [$k] ['status'] = $u ['status'];
  4288. $flag = false;
  4289. break;
  4290. }
  4291. }
  4292. $endStaffArray = end ( $verifyStaff );
  4293. if (isset ( $endStaffArray ['ROLE'] )) {
  4294. } else {
  4295. // $endKey=key($verifyStaff);
  4296. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4297. // $button=4;
  4298. // $verifyList[$k]['status']=4;
  4299. // }
  4300. }
  4301. }
  4302. }
  4303. $rolename ['name'] = '';
  4304. if (! empty ( $roleId )) {
  4305. Doo::loadModel ( 'role' );
  4306. $role = new role ();
  4307. $rolename = $role->getOne ( array (
  4308. 'where' => 'rid=' . $roleId,
  4309. 'asArray' => true
  4310. ) );
  4311. }
  4312. if (! empty ( $verifyStaff ))
  4313. $endStaffArray = end ( $verifyStaff );
  4314. $KOP = false;
  4315. foreach ( $roleArrayCopy as $P => $A ) {
  4316. foreach ( $A as $MKI => $AVL ) {
  4317. if (! empty ( $verifyStaff )) {
  4318. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4319. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4320. $button = 4;
  4321. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4322. }
  4323. foreach ( $verifyStaff as $m => $u ) {
  4324. $AVLFK = $AVL [0] . '_R';
  4325. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4326. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4327. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4328. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4329. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4330. break;
  4331. }
  4332. }
  4333. } else {
  4334. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4335. $button = 4;
  4336. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4337. }
  4338. }
  4339. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4340. $KOP = true;
  4341. }
  4342. }
  4343. foreach ( $roleArrayCopy as $k => $v ) {
  4344. foreach ( $verifyList as $m => $n ) {
  4345. if ($n [0] == $k) {
  4346. array_splice ( $verifyList, $m, 1, $v );
  4347. }
  4348. }
  4349. }
  4350. // 费用执行人相关数据
  4351. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4352. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4353. foreach ( $executeCopy as $k => $v ) {
  4354. $executeCopy [$k] ['date'] = '';
  4355. $executeCopy [$k] ['opinion'] = '';
  4356. $executeCopy [$k] ['status'] = '';
  4357. if (! empty ( $executeStaff ))
  4358. foreach ( $executeStaff as $m => $u ) {
  4359. if ($v [0] == $m) {
  4360. $executeCopy [$k] ['date'] = $u ['date'];
  4361. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4362. $executeCopy [$k] ['status'] = $u ['status'];
  4363. break;
  4364. }
  4365. }
  4366. }
  4367. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4368. $receiptList [$key] ['verifyList'] = $verifyList;
  4369. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4370. 'where' => 'sid=' . $value ['staff'],
  4371. 'asArray' => true
  4372. ) );
  4373. $receiptList [$key] ['button'] = $button;
  4374. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4375. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4376. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4377. $receiptList [$key] ['relust'] = $relust;
  4378. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4379. }
  4380. Doo::loadModel ( 'enclosur' );
  4381. $enclosur = new enclosur ();
  4382. $enclosurList = $enclosur->find ( array (
  4383. 'where' => 'rid=' . $rid,
  4384. 'asArray' => true
  4385. ) );
  4386. $enclosurHtml = '';
  4387. foreach ( $enclosurList as $value ) {
  4388. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4389. }
  4390. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  4391. $data ['enclosurHtml'] = $enclosurHtml;
  4392. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4393. $data ['receiptList'] = $receiptList;
  4394. $data ['memu'] = "receipt";
  4395. $data ['staff'] = $this->staff;
  4396. $data ['receiptMemu'] = 'expenses';
  4397. $data ['verifyId'] = $this->verifyId;
  4398. $data ['executeId'] = $this->executeId;
  4399. if($receiptList[0]['receiptClass']==2){
  4400. if(!empty($receiptList[0]['itinerary2'])){
  4401. $this->render ( "/receipt/feeTraveDetail2", $data );
  4402. }else{
  4403. $this->render ( "/receipt/feeTraveDetail", $data );
  4404. }
  4405. }else{
  4406. $this->render ( "/admin/expensesCollect", $data );
  4407. }
  4408. }
  4409. function approvalExpenses() {
  4410. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4411. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4412. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4413. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4414. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4415. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4416. // echo $rdate;
  4417. if (empty ( $status ))
  4418. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4419. $page_size = 8;
  4420. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4421. $vidList = array ();
  4422. $button = 0;
  4423. Doo::loadModel ( 'verify' );
  4424. $verify = new verify ();
  4425. Doo::loadModel ( 'receipt' );
  4426. $receipt = new receipt ();
  4427. Doo::loadModel ( 'staff' );
  4428. $staff = new staff ();
  4429. Doo::loadModel ( 'L_category' );
  4430. $Lcategory = new L_category ();
  4431. // user verify ID
  4432. $verifyDetail = $verify->find ( array (
  4433. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4434. 'asArray' => true
  4435. ) );
  4436. foreach ( $verifyDetail as $key => $value ) {
  4437. array_push ( $vidList, $value ['vid'] );
  4438. }
  4439. $vid = implode ( ",", $vidList );
  4440. if (empty ( $verifyDetail )){
  4441. $vid = 0;
  4442. }
  4443. $dateCondition = " ";
  4444. // if (! empty ( $month ))
  4445. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4446. if ($status == 'done' || $status == 'termination') {
  4447. if (! empty ( $year )) {
  4448. $dateCondition = " and Year(pastDate) =" . $year;
  4449. if (! empty ( $month ))
  4450. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4451. }
  4452. } elseif ($status == 'finish') {
  4453. if (! empty ( $year )) {
  4454. $dateCondition = " and Year(pastDate) =" . $year;
  4455. if (! empty ( $month ))
  4456. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4457. }
  4458. }
  4459. // date ( 'Y-m' )
  4460. // if (! empty ( $rdate ) && $status == 'done')
  4461. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4462. // elseif (! empty ( $rdate ))
  4463. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4464. $categoryList = $Lcategory->find ( array (
  4465. 'asArray' => true
  4466. ) );
  4467. $staffList = $staff->find ( array (
  4468. 'where' => 'cid=' . $cid,
  4469. 'asArray' => true
  4470. ) );
  4471. $cateCondition = "";
  4472. $staffCondition = "";
  4473. $approvalCondition = "";
  4474. if (! empty ( $cid )) {
  4475. $cateCondition = ' and cid=' . $cid;
  4476. }
  4477. if (! empty ( $sid )) {
  4478. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4479. $cateCondition = "";
  4480. }
  4481. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4482. if ($status == 'pendApproval') {
  4483. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4484. }
  4485. if ($status == 'ongoing') {
  4486. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4487. }
  4488. if ($status == 'done') {
  4489. $approvalCondition = ' and (status=8 or status=9 ) ';
  4490. }
  4491. if ($status == 'termination') {
  4492. $approvalCondition = " and status=3";
  4493. }
  4494. if ($status == 'finish') {
  4495. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4496. }
  4497. if($status == 'loan'){
  4498. $approvalCondition = " and (status=8 or status=7) and Rtype=1";
  4499. }
  4500. $pageinfo ['page'] = array (
  4501. 'previous' => ''
  4502. );
  4503. if(!empty($receiptOrder)){
  4504. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4505. $receiptList = $receipt->find ( array ( // $dateCondition
  4506. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4507. 'desc' => 'rid',
  4508. 'asArray' => true
  4509. ) );
  4510. }else{
  4511. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4512. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4513. $receiptList = $receipt->find ( array ( // $dateCondition.
  4514. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4515. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4516. 'desc' => 'rid',
  4517. 'asArray' => true
  4518. ) );
  4519. } else {
  4520. $receiptList = $receipt->find ( array ( // $dateCondition
  4521. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4522. 'desc' => 'rid',
  4523. 'asArray' => true
  4524. ) );
  4525. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4526. }
  4527. }
  4528. $rLRes = $receipt->find ( array (
  4529. '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 . ')',
  4530. 'desc' => 'rid',
  4531. 'asArray' => true
  4532. ) );
  4533. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4534. // print_r($receiptList);
  4535. Doo::loadClass ( 'XDeode' );
  4536. $XDeode = new XDeode ( 7 );
  4537. $XDeode9 = new XDeode ( 9 );
  4538. $Locate = 0;
  4539. //
  4540. $reportList = $reportCateList = array ();
  4541. foreach ( $receiptList as $key => $value ) {
  4542. $receiptList [$key] ['rid_cld'] = $XDeode9->encode ( $value ['rid'] );
  4543. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4544. $receiptList [$key] ['Locate'] = $Locate;
  4545. $Locate ++;
  4546. $receiptList [$key] ['reviseDetail'] = array ();
  4547. if (! empty ( $value ['reviseDetail'] ))
  4548. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4549. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4550. $categoryDetil = $Lcategory->getOne ( array (
  4551. 'where' => 'cid=' . $value ['cid'],
  4552. 'asArray' => true
  4553. ) );
  4554. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4555. $verifyList = $verify->getOne ( array (
  4556. 'where' => 'vid=' . $value ['verify'],
  4557. 'asArray' => true
  4558. ) );
  4559. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4560. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4561. foreach ( $verifyList as $k => $v ) {
  4562. // init verifyStaff
  4563. $verifyList [$k] ['date'] = "";
  4564. $verifyList [$k] ['opinion'] = "";
  4565. $verifyList [$k] ['status'] = "";
  4566. if (empty ( $verifyStaff )) {
  4567. $verifyList [$k] ['date'] = "";
  4568. $verifyList [$k] ['opinion'] = "";
  4569. if ($v [0] == $this->staff [0] ['sid']) {
  4570. $verifyList [$k] ['status'] = 4;
  4571. $button = 4;
  4572. }
  4573. } else {
  4574. $flag = true;
  4575. foreach ( $verifyStaff as $m => $u ) {
  4576. if ($v [0] == $m) {
  4577. $verifyList [$k] ['date'] = $u ['date'];
  4578. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4579. $verifyList [$k] ['status'] = $u ['status'];
  4580. $flag = false;
  4581. break;
  4582. }
  4583. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4584. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4585. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4586. }
  4587. if ($flag) { // 检测可编辑
  4588. if ($v [0] == $this->staff [0] ['sid']) {
  4589. $verifyList [$k] ['status'] = 4;
  4590. $button = 4;
  4591. }
  4592. }
  4593. }
  4594. }
  4595. $receiptList [$key] ['verifyList'] = $verifyList;
  4596. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4597. 'where' => 'sid=' . $value ['staff'],
  4598. 'asArray' => true
  4599. ) );
  4600. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4601. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4602. $receiptList [$key] ['button'] = $button;
  4603. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4604. //获得培训班结算RID 借款费用--已经锁定
  4605. if($value['status']==10){
  4606. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4607. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4608. }
  4609. }
  4610. $reportList = array_unique ( $reportList );
  4611. $reportHtml = '';
  4612. foreach ( $reportList as $key => $value ) {
  4613. $v = explode ( "-", $value );
  4614. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4615. }
  4616. // print_r($reportList)
  4617. $data ['reportHtml'] = $reportHtml;
  4618. $reportCateList = array_unique ( $reportCateList );
  4619. $reportCateHtml = '';
  4620. foreach ( $reportCateList as $key => $value ) {
  4621. $v = explode ( "-", $value );
  4622. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4623. }
  4624. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4625. $data ['reportCateHtml'] = $reportCateHtml;
  4626. // print_r($receiptList);die;
  4627. // $data['verifyDetail']=$verifyDetail;
  4628. $mothHtml = "";
  4629. for($i = 1; $i <= 12; $i ++) {
  4630. if ($month == $i)
  4631. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4632. else
  4633. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4634. }
  4635. $data ['mothHtml'] = $mothHtml;
  4636. $dateHtml = "";
  4637. $now = date ( "Y" );
  4638. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4639. if ($YEARD <= $now) {
  4640. $dateHtml .= '<option ';
  4641. if ($year == $YEARD) {
  4642. $dateHtml .= 'selected ';
  4643. }
  4644. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4645. }
  4646. }
  4647. $data ['dateHtml'] = $dateHtml;
  4648. $data ['page'] = $pageinfo;
  4649. $data ['receiptList'] = $receiptList;
  4650. $data ['receiptApprovalCount'] = count ( $rLRes );
  4651. $data ['status'] = $status;
  4652. $data ['year'] = $year;
  4653. $data ['month'] = $month;
  4654. $data ['categoryList'] = $categoryList;
  4655. $data ['staffList'] = $staffList;
  4656. $data ['cid'] = $cid;
  4657. $data ['sid'] = $sid;
  4658. // print_r($receiptList);
  4659. $data['receiptOrder']=$receiptOrder;
  4660. $data ['memu'] = "receipt";
  4661. $data ['staff'] = $this->staff;
  4662. $data ['receiptMemu'] = 'approvalExpenses';
  4663. $data ['verifyId'] = $this->verifyId;
  4664. $data ['executeId'] = $this->executeId;
  4665. $this->render ( "/admin/approvalExpenses", $data );
  4666. }
  4667. private function _expensesDoc(){
  4668. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4669. Doo::loadClass ( 'XDeode' );
  4670. $XDeode = new XDeode ( 5 );
  4671. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4672. $rid = $XDeode->decode ( $rid );
  4673. if (! is_numeric ( $rid ))
  4674. die ( 'illegal request' );
  4675. Doo::loadModel ( 'receipt' );
  4676. $receipt = new receipt ();
  4677. Doo::loadModel ( 'L_category' );
  4678. $Lcategory = new L_category ();
  4679. Doo::loadModel ( 'verify' );
  4680. Doo::loadModel ( 'statistics' );
  4681. $statistics = new statistics ();
  4682. $verify = new verify ();
  4683. Doo::loadModel ( 'staff' );
  4684. $staff = new staff ();
  4685. Doo::loadModel ( 'loanReceipt' );
  4686. $loanReceipt = new loanReceipt ();
  4687. $receiptList = $receipt->find ( array (
  4688. 'where' => ' rid=' . $rid,
  4689. 'desc' => 'rid',
  4690. 'asArray' => true
  4691. ) );
  4692. $loanList = array ();
  4693. if (! empty ( $receiptList ))
  4694. $loanList = $loanReceipt->find ( array (
  4695. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4696. 'desc' => 'rid',
  4697. 'asArray' => true
  4698. ) );
  4699. $Locate = 0;
  4700. $roleId = 0;
  4701. $button = 0;
  4702. foreach ( $loanList as $key => $value ) {
  4703. $loanList [$key] ['Locate'] = $Locate;
  4704. $Locate ++;
  4705. $loanList [$key] ['reviseDetail'] = array ();
  4706. if (! empty ( $value ['reviseDetail'] ))
  4707. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4708. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4709. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4710. $categoryDetil = $Lcategory->getOne ( array (
  4711. 'where' => 'cid=' . $value ['cid'],
  4712. 'asArray' => true
  4713. ) );
  4714. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4715. // 检测编辑状态
  4716. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4717. $verifyList ['staff'] = $value ['verifyBreakup'];
  4718. else
  4719. $verifyList = $verify->getOne ( array (
  4720. 'where' => 'vid=' . $value ['verify'],
  4721. 'asArray' => true
  4722. ) );
  4723. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4724. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4725. Doo::loadModel ( 'role' );
  4726. $role = new role ();
  4727. $flag = true;
  4728. $roleKey = 0;
  4729. $endStaffArray = array ();
  4730. $roleArrayCopy = array ();
  4731. foreach ( $verifyList as $k => $v ) {
  4732. // init verifyStaff
  4733. if ($v [1] == 'ROLE') {
  4734. if (! empty ( $verifyStaff )) {
  4735. $endStaffArray = end ( $verifyStaff );
  4736. // if ($v[0]==$endStaffArray['nextStaff']){
  4737. // $roleId=$v[0];
  4738. // }
  4739. }
  4740. $roleVerify = json_decode ( $v [3], true );
  4741. $roleKey = $k;
  4742. $roleArray = array ();
  4743. $rolename = $role->getOne ( array (
  4744. 'where' => 'rid=' . $v [0],
  4745. 'asArray' => true
  4746. ) );
  4747. foreach ( $roleVerify as $o => $p ) {
  4748. $staffID = explode ( '_', $p );
  4749. $staffInfo = $staff->getOne ( array (
  4750. 'where' => 'sid=' . $staffID [0],
  4751. 'asArray' => true
  4752. ) );
  4753. // print_r($staffID);
  4754. $exp = array (
  4755. 0 => $staffInfo ['sid'],
  4756. 1 => $staffID [1],
  4757. 2 => $staffInfo ['avatar'],
  4758. 'date' => '',
  4759. 'date' => '',
  4760. 'opinion' => '',
  4761. 'status' => '',
  4762. 'rolename' => $rolename ['name']
  4763. );
  4764. array_push ( $roleArray, $exp );
  4765. }
  4766. $roleArrayCopy [$v [0]] = $roleArray;
  4767. // $verifyList[$k]['roleArray']=$roleArray;
  4768. }
  4769. $verifyList [$k] ['date'] = "";
  4770. $verifyList [$k] ['opinion'] = "";
  4771. $verifyList [$k] ['status'] = "";
  4772. if (empty ( $verifyStaff )) {
  4773. $verifyList [$k] ['date'] = "";
  4774. $verifyList [$k] ['opinion'] = "";
  4775. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4776. $verifyList [$k] ['status'] = 4;
  4777. $flag = false;
  4778. }
  4779. } else {
  4780. foreach ( $verifyStaff as $m => $u ) {
  4781. if ($v [0] == $m) {
  4782. $verifyList [$k] ['date'] = $u ['date'];
  4783. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4784. $verifyList [$k] ['status'] = $u ['status'];
  4785. $flag = false;
  4786. break;
  4787. }
  4788. }
  4789. $endStaffArray = end ( $verifyStaff );
  4790. if (isset ( $endStaffArray ['ROLE'] )) {
  4791. } else {
  4792. // $endKey=key($verifyStaff);
  4793. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4794. // $button=4;
  4795. // $verifyList[$k]['status']=4;
  4796. // }
  4797. }
  4798. }
  4799. }
  4800. $rolename ['name'] = '';
  4801. if (! empty ( $roleId )) {
  4802. Doo::loadModel ( 'role' );
  4803. $role = new role ();
  4804. $rolename = $role->getOne ( array (
  4805. 'where' => 'rid=' . $roleId,
  4806. 'asArray' => true
  4807. ) );
  4808. }
  4809. if (! empty ( $verifyStaff ))
  4810. $endStaffArray = end ( $verifyStaff );
  4811. $KOP = false;
  4812. foreach ( $roleArrayCopy as $P => $A ) {
  4813. foreach ( $A as $MKI => $AVL ) {
  4814. if (! empty ( $verifyStaff )) {
  4815. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4816. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4817. $button = 4;
  4818. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4819. }
  4820. foreach ( $verifyStaff as $m => $u ) {
  4821. $AVLFK = $AVL [0] . '_R';
  4822. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4823. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4824. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4825. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4826. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4827. break;
  4828. }
  4829. }
  4830. } else {
  4831. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4832. $button = 4;
  4833. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4834. }
  4835. }
  4836. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4837. $KOP = true;
  4838. }
  4839. }
  4840. foreach ( $roleArrayCopy as $k => $v ) {
  4841. foreach ( $verifyList as $m => $n ) {
  4842. if ($n [0] == $k) {
  4843. array_splice ( $verifyList, $m, 1, $v );
  4844. }
  4845. }
  4846. }
  4847. $loanList [$key] ['verifyList'] = $verifyList;
  4848. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4849. 'where' => 'sid=' . $value ['staff'],
  4850. 'asArray' => true
  4851. ) );
  4852. $loanList [$key] ['button'] = $button;
  4853. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4854. }
  4855. $data ['loanList'] = $loanList;
  4856. //print_r($loanList);
  4857. $Locate = 0;
  4858. $roleId = 0;
  4859. $button = 0;
  4860. foreach ( $receiptList as $key => $value ) {
  4861. $receiptList [$key] ['Locate'] = $Locate;
  4862. $Locate ++;
  4863. $receiptList [$key] ['reviseDetail'] = array ();
  4864. if (! empty ( $value ['reviseDetail'] ))
  4865. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4866. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4867. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4868. $categoryDetil = $Lcategory->getOne ( array (
  4869. 'where' => 'cid=' . $value ['cid'],
  4870. 'asArray' => true
  4871. ) );
  4872. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4873. // 检测编辑状态
  4874. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4875. $verifyList ['staff'] = $value ['verifyBreakup'];
  4876. } else
  4877. $verifyList = $verify->getOne ( array (
  4878. 'where' => 'vid=' . $value ['verify'],
  4879. 'asArray' => true
  4880. ) );
  4881. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4882. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4883. Doo::loadModel ( 'role' );
  4884. $role = new role ();
  4885. if ($verifyList == NULL)
  4886. $verifyList = array ();
  4887. $flag = true;
  4888. $roleKey = 0;
  4889. $endStaffArray = array ();
  4890. $roleArrayCopy = array ();
  4891. foreach ( $verifyList as $k => $v ) {
  4892. // init verifyStaff
  4893. if ($v [1] == 'ROLE') {
  4894. if (! empty ( $verifyStaff )) {
  4895. $endStaffArray = end ( $verifyStaff );
  4896. // if ($v[0]==$endStaffArray['nextStaff']){
  4897. // $roleId=$v[0];
  4898. // }
  4899. }
  4900. $roleVerify = json_decode ( $v [3], true );
  4901. $roleKey = $k;
  4902. $roleArray = array ();
  4903. $rolename = $role->getOne ( array (
  4904. 'where' => 'rid=' . $v [0],
  4905. 'asArray' => true
  4906. ) );
  4907. foreach ( $roleVerify as $o => $p ) {
  4908. $staffID = explode ( '_', $p );
  4909. $staffInfo = $staff->getOne ( array (
  4910. 'where' => 'sid=' . $staffID [0],
  4911. 'asArray' => true
  4912. ) );
  4913. // print_r($staffID);
  4914. $exp = array (
  4915. 0 => $staffInfo ['sid'],
  4916. 1 => $staffID [1],
  4917. 2 => $staffInfo ['avatar'],
  4918. 'date' => '',
  4919. 'date' => '',
  4920. 'opinion' => '',
  4921. 'status' => '',
  4922. 'rolename' => $rolename ['name']
  4923. );
  4924. array_push ( $roleArray, $exp );
  4925. }
  4926. $roleArrayCopy [$v [0]] = $roleArray;
  4927. // $verifyList[$k]['roleArray']=$roleArray;
  4928. }
  4929. $verifyList [$k] ['date'] = "";
  4930. $verifyList [$k] ['opinion'] = "";
  4931. $verifyList [$k] ['status'] = "";
  4932. if (empty ( $verifyStaff )) {
  4933. $verifyList [$k] ['date'] = "";
  4934. $verifyList [$k] ['opinion'] = "";
  4935. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4936. $verifyList [$k] ['status'] = 4;
  4937. $flag = false;
  4938. }
  4939. } else {
  4940. foreach ( $verifyStaff as $m => $u ) {
  4941. if ($v [0] == $m) {
  4942. $verifyList [$k] ['date'] = $u ['date'];
  4943. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4944. $verifyList [$k] ['status'] = $u ['status'];
  4945. $flag = false;
  4946. break;
  4947. }
  4948. }
  4949. $endStaffArray = end ( $verifyStaff );
  4950. if (isset ( $endStaffArray ['ROLE'] )) {
  4951. } else {
  4952. // $endKey=key($verifyStaff);
  4953. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4954. // $button=4;
  4955. // $verifyList[$k]['status']=4;
  4956. // }
  4957. }
  4958. }
  4959. }
  4960. $FC = @$rolename ['name'];
  4961. $rolename ['name'] = '';
  4962. if (! empty ( $roleId )) {
  4963. Doo::loadModel ( 'role' );
  4964. $role = new role ();
  4965. $rolename = $role->getOne ( array (
  4966. 'where' => 'rid=' . $roleId,
  4967. 'asArray' => true
  4968. ) );
  4969. }
  4970. if (! empty ( $verifyStaff ))
  4971. $endStaffArray = end ( $verifyStaff );
  4972. $KOP = false;
  4973. foreach ( $roleArrayCopy as $P => $A ) {
  4974. foreach ( $A as $MKI => $AVL ) {
  4975. if (! empty ( $verifyStaff )) {
  4976. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4977. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4978. $button = 4;
  4979. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4980. }
  4981. foreach ( $verifyStaff as $m => $u ) {
  4982. $AVLFK = $AVL [0] . '_R';
  4983. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4984. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4985. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4986. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4987. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4988. break;
  4989. }
  4990. }
  4991. } else {
  4992. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4993. $button = 4;
  4994. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4995. }
  4996. }
  4997. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4998. $KOP = true;
  4999. }
  5000. }
  5001. foreach ( $roleArrayCopy as $k => $v ) {
  5002. foreach ( $verifyList as $m => $n ) {
  5003. if ($n [0] == $k) {
  5004. array_splice ( $verifyList, $m, 1, $v );
  5005. }
  5006. }
  5007. }
  5008. // 费用执行人相关数据
  5009. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5010. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5011. foreach ( $executeCopy as $k => $v ) {
  5012. $executeCopy [$k] ['date'] = '';
  5013. $executeCopy [$k] ['opinion'] = '';
  5014. $executeCopy [$k] ['status'] = '';
  5015. if (! empty ( $executeStaff ))
  5016. foreach ( $executeStaff as $m => $u ) {
  5017. if ($v [0] == $m) {
  5018. $executeCopy [$k] ['date'] = $u ['date'];
  5019. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5020. $executeCopy [$k] ['status'] = $u ['status'];
  5021. break;
  5022. }
  5023. }
  5024. }
  5025. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5026. // print_r($verifyList);
  5027. $receiptList [$key] ['verifyList'] = $verifyList;
  5028. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5029. 'where' => 'sid=' . $value ['staff'],
  5030. 'asArray' => true
  5031. ) );
  5032. $receiptList [$key] ['button'] = $button;
  5033. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5034. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5035. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5036. $receiptList [$key] ['relust'] = $relust;
  5037. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5038. }
  5039. // print_r($receiptList);
  5040. // 获取审批日志
  5041. Doo::loadModel ( 'receiptLog' );
  5042. $receiptLog = new receiptLog ();
  5043. $rlList = array ();
  5044. $rlInfo = $receiptLog->getOne ( array (
  5045. 'where' => 'rid=' . $rid . ' and status=4',
  5046. 'asArray' => true
  5047. ) );
  5048. // $tijdate = $receiptLog->getOne ( array (
  5049. // 'where' => 'rid=' . $rid . ' and status=2',
  5050. // 'asc' => 'rlid',
  5051. // 'asArray' => true
  5052. // ) );
  5053. if (! empty ( $rlInfo )) {
  5054. $rlList = $receiptLog->find ( array (
  5055. 'where' => 'rid=' . $rid,
  5056. 'asc' => 'rlid',
  5057. 'asArray' => true
  5058. ) );
  5059. }
  5060. $RN=array();
  5061. if (!empty( $rolename ['staff'])){
  5062. $RN = @json_decode ( $rolename ['staff'] );
  5063. }
  5064. //
  5065. foreach ( $rlList as $key => $value ) {
  5066. $rlList [$key] ['rolename'] = '';
  5067. foreach ( $RN as $k => $v ) {
  5068. $id = explode ( "_", $v );
  5069. if ($id [0] == $value ['uid']) {
  5070. $rlList [$key] ['rolename'] = $FC;
  5071. break;
  5072. }
  5073. }
  5074. }
  5075. Doo::loadModel ( 'enclosur' );
  5076. $enclosur = new enclosur ();
  5077. $enclosurList = $enclosur->find ( array (
  5078. 'where' => 'rid=' . $rid,
  5079. 'asArray' => true
  5080. ) );
  5081. $enclosurHtml = '';
  5082. foreach ( $enclosurList as $value ) {
  5083. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5084. }
  5085. $data ['enclosurHtml'] = $enclosurHtml;
  5086. $receiptList [0] ['rlList'] = $rlList;
  5087. $data ['receiptList'] = $receiptList;
  5088. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5089. // print_r($receiptList);
  5090. $data ['memu'] = "receipt";
  5091. $data ['staff'] = $this->staff;
  5092. $data ['receiptMemu'] = 'approvalExpenses';
  5093. $data ['verifyId'] = $this->verifyId;
  5094. $data ['executeId'] = $this->executeId;
  5095. return $data;
  5096. }
  5097. function expensesDoc() {
  5098. $data=$this->_expensesDoc();
  5099. if(!empty($data['receiptList'][0]['itinerary2'])){
  5100. $this->render ( "/receipt/feeTraveView", $data );
  5101. }else{
  5102. $this->render ( "/admin/expensesDoc", $data );
  5103. }
  5104. }
  5105. function expensesDocPrint(){
  5106. $data=$this->_expensesDoc();
  5107. $this->render ( "/receipt/expensesDocPrint", $data );
  5108. }
  5109. function expensesEdi() {
  5110. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5111. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5112. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5113. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5114. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5115. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5116. if (empty ( $status ))
  5117. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5118. $vidList = array ();
  5119. $button = 0;
  5120. Doo::loadModel ( 'verify' );
  5121. Doo::loadModel ( 'receipt' );
  5122. Doo::loadModel ( 'staff' );
  5123. $staff = new staff ();
  5124. $receipt = new receipt ();
  5125. $verify = new verify ();
  5126. Doo::loadModel ( 'L_category' );
  5127. $Lcategory = new L_category ();
  5128. Doo::loadModel ( 'enclosur' );
  5129. $enclosur = new enclosur ();
  5130. // user verify ID
  5131. $verifyDetail = $verify->find ( array (
  5132. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5133. 'asArray' => true
  5134. ) );
  5135. foreach ( $verifyDetail as $key => $value ) {
  5136. array_push ( $vidList, $value ['vid'] );
  5137. }
  5138. $vid = implode ( ",", $vidList );
  5139. if (empty ( $verifyDetail ))
  5140. $vid = 0;
  5141. $categoryList = $Lcategory->find ( array (
  5142. 'asArray' => true
  5143. ) );
  5144. $staffList = $staff->find ( array (
  5145. 'where' => 'cid=' . $cid,
  5146. 'asArray' => true
  5147. ) );
  5148. $ap = "";
  5149. if ($status == 4) {
  5150. $ap = 4;
  5151. $status = 2;
  5152. }
  5153. // get Receipt By verifyID status 2
  5154. $receiptList = $receipt->find ( array (
  5155. 'where' => 'rid =' . $rid . ' and status=2',
  5156. 'desc' => 'rid',
  5157. 'asArray' => true
  5158. ) );
  5159. if (empty ( $receiptList )) {
  5160. die ( 'illegal request' );
  5161. }
  5162. $Locate = 0;
  5163. $roleId = 0;
  5164. if ($ap == 4)
  5165. $status = 4;
  5166. foreach ( $receiptList as $key => $value ) {
  5167. $receiptList [$key] ['Locate'] = $Locate;
  5168. $Locate ++;
  5169. $receiptList [$key] ['reviseDetail'] = array ();
  5170. if (! empty ( $value ['reviseDetail'] ))
  5171. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5172. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5173. $categoryDetil = $Lcategory->getOne ( array (
  5174. 'where' => 'cid=' . $value ['cid'],
  5175. 'asArray' => true
  5176. ) );
  5177. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5178. // 检测编辑状态
  5179. $verifyList = $verify->getOne ( array (
  5180. 'where' => 'vid=' . $value ['verify'],
  5181. 'asArray' => true
  5182. ) );
  5183. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5184. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5185. Doo::loadModel ( 'role' );
  5186. $role = new role ();
  5187. // print_r($verifyList);
  5188. $flag = true;
  5189. $roleKey = 0;
  5190. $endStaffArray = array ();
  5191. $roleArrayCopy = array ();
  5192. foreach ( $verifyList as $k => $v ) {
  5193. // init verifyStaff
  5194. if ($v [1] == 'ROLE') {
  5195. if (! empty ( $verifyStaff )) {
  5196. $endStaffArray = end ( $verifyStaff );
  5197. if ($v [0] == $endStaffArray ['nextStaff']) {
  5198. $roleId = $v [0];
  5199. }
  5200. }
  5201. $roleVerify = json_decode ( $v [3], true );
  5202. $roleKey = $k;
  5203. $roleArray = array ();
  5204. $rolename = $role->getOne ( array (
  5205. 'where' => 'rid=' . $v [0],
  5206. 'asArray' => true
  5207. ) );
  5208. foreach ( $roleVerify as $o => $p ) {
  5209. $staffID = explode ( '_', $p );
  5210. $staffInfo = $staff->getOne ( array (
  5211. 'where' => 'sid=' . $staffID [0],
  5212. 'asArray' => true
  5213. ) );
  5214. // print_r($staffID);
  5215. $exp = array (
  5216. 0 => $staffInfo ['sid'],
  5217. 1 => $staffID [1],
  5218. 2 => $staffInfo ['avatar'],
  5219. 'date' => '',
  5220. 'date' => '',
  5221. 'opinion' => '',
  5222. 'status' => '',
  5223. 'rolename' => $rolename ['name']
  5224. );
  5225. array_push ( $roleArray, $exp );
  5226. }
  5227. $roleArrayCopy [$v [0]] = $roleArray;
  5228. // $verifyList[$k]['roleArray']=$roleArray;
  5229. }
  5230. // print_r($roleArray);
  5231. $verifyList [$k] ['date'] = "";
  5232. $verifyList [$k] ['opinion'] = "";
  5233. $verifyList [$k] ['status'] = "";
  5234. if (empty ( $verifyStaff )) {
  5235. $verifyList [$k] ['date'] = "";
  5236. $verifyList [$k] ['opinion'] = "";
  5237. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5238. $verifyList [$k] ['status'] = 4;
  5239. $button = 4;
  5240. $flag = false;
  5241. }
  5242. } else {
  5243. foreach ( $verifyStaff as $m => $u ) {
  5244. if ($v [0] == $m) {
  5245. $verifyList [$k] ['date'] = $u ['date'];
  5246. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5247. $verifyList [$k] ['status'] = $u ['status'];
  5248. $flag = false;
  5249. break;
  5250. }
  5251. }
  5252. $endStaffArray = end ( $verifyStaff );
  5253. if (isset ( $endStaffArray ['ROLE'] )) {
  5254. } else {
  5255. $endKey = key ( $verifyStaff );
  5256. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5257. $button = 4;
  5258. $verifyList [$k] ['status'] = 4;
  5259. }
  5260. }
  5261. }
  5262. }
  5263. $rolename ['name'] = '';
  5264. if (! empty ( $roleId )) {
  5265. Doo::loadModel ( 'role' );
  5266. $role = new role ();
  5267. $rolename = $role->getOne ( array (
  5268. 'where' => 'rid=' . $roleId,
  5269. 'asArray' => true
  5270. ) );
  5271. }
  5272. if (! empty ( $verifyStaff ))
  5273. $endStaffArray = end ( $verifyStaff );
  5274. $KOP = false;
  5275. foreach ( $roleArrayCopy as $P => $A ) {
  5276. foreach ( $A as $MKI => $AVL ) {
  5277. if (! empty ( $verifyStaff )) {
  5278. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5279. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5280. $button = 4;
  5281. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5282. }
  5283. foreach ( $verifyStaff as $m => $u ) {
  5284. $AVLFK = $AVL [0] . '_R';
  5285. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5286. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5287. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5288. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5289. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5290. break;
  5291. }
  5292. }
  5293. } else {
  5294. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5295. $button = 4;
  5296. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5297. }
  5298. }
  5299. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5300. $KOP = true;
  5301. }
  5302. }
  5303. // print_r($roleArrayCopy);
  5304. // echo $roleKey;
  5305. foreach ( $roleArrayCopy as $k => $v ) {
  5306. foreach ( $verifyList as $m => $n ) {
  5307. if ($n [0] == $k) {
  5308. array_splice ( $verifyList, $m, 1, $v );
  5309. }
  5310. }
  5311. }
  5312. $receiptList [$key] ['verifyList'] = $verifyList;
  5313. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5314. 'where' => 'sid=' . $value ['staff'],
  5315. 'asArray' => true
  5316. ) );
  5317. $receiptList [$key] ['button'] = $button;
  5318. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5319. }
  5320. // $data['verifyDetail']=$verifyDetail;
  5321. $mothHtml = "";
  5322. for($i = 1; $i <= 12; $i ++) {
  5323. if ($month == $i)
  5324. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5325. else
  5326. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5327. }
  5328. // 获取审批日志
  5329. Doo::loadModel ( 'receiptLog' );
  5330. $receiptLog = new receiptLog ();
  5331. $rlList = array ();
  5332. $rlInfo = $receiptLog->getOne ( array (
  5333. 'where' => 'rid=' . $rid . ' and status=4',
  5334. 'asArray' => true
  5335. ) );
  5336. $tijdate = $receiptLog->getOne ( array (
  5337. 'where' => 'rid=' . $rid . ' and status=2',
  5338. 'asc' => 'rlid',
  5339. 'asArray' => true
  5340. ) );
  5341. if (! empty ( $rlInfo )) {
  5342. $rlList = $receiptLog->find ( array (
  5343. 'where' => 'rid=' . $rid,
  5344. 'asc' => 'rlid',
  5345. 'asArray' => true
  5346. ) );
  5347. }
  5348. $receiptList [0] ['rlList'] = $rlList;
  5349. $enclosurList = $enclosur->find ( array (
  5350. 'where' => 'rid=' . $rid,
  5351. 'asArray' => true
  5352. ) );
  5353. $enclosurHtml = '';
  5354. foreach ( $enclosurList as $value ) {
  5355. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5356. }
  5357. // print_r($receiptList);
  5358. $data ['rid'] = $rid;
  5359. $data ['enclosurHtml'] = $enclosurHtml;
  5360. $data ['rolename'] = $rolename ['name'];
  5361. $data ['datetij'] = $tijdate ['date'];
  5362. $data ['mothHtml'] = $mothHtml;
  5363. $data ['receiptList'] = $receiptList;
  5364. $data ['receiptApprovalCount'] = count ( $receiptList );
  5365. $data ['status'] = $status;
  5366. $data ['year'] = $year;
  5367. $data ['categoryList'] = $categoryList;
  5368. $data ['staffList'] = $staffList;
  5369. $data ['cid'] = $cid;
  5370. $data ['sid'] = $sid;
  5371. $data ['ap'] = $ap;
  5372. $data ['memu'] = "receipt";
  5373. $data ['staff'] = $this->staff;
  5374. $data ['receiptMemu'] = 'approvalExpenses';
  5375. $data ['verifyId'] = $this->verifyId;
  5376. $data ['executeId'] = $this->executeId;
  5377. $this->render ( "/admin/expensesEdi", $data );
  5378. }
  5379. function expensesDefray() {
  5380. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5381. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5382. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5383. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5384. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5385. if (! empty ( $rid )) {
  5386. Doo::loadModel ( "verify" );
  5387. $verify = new verify ();
  5388. Doo::loadModel ( "receiptDetail" );
  5389. $receiptDetailObj = new receiptDetail ();
  5390. Doo::loadModel ( "itemStatistics" );
  5391. Doo::loadModel ( "statistics" );
  5392. $statistics = new statistics ();
  5393. $itemStatistics = new itemStatistics ();
  5394. Doo::loadModel ( "receipt" );
  5395. $receipt = new receipt ();
  5396. Doo::loadModel ( "loanReceipt" );
  5397. $loanReceipt = new loanReceipt ();
  5398. $receiptDetail = $receipt->getOne ( array (
  5399. 'where' => 'rid=' . $rid . ' and status=2 ',
  5400. 'asArray' => true
  5401. ) );
  5402. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5403. $nsflag = true;
  5404. foreach ( $nslist as $value ) {
  5405. if ($value == $this->staff ['0'] ['sid']) {
  5406. $nsflag = false;
  5407. break;
  5408. }
  5409. }
  5410. // print_r($nslist);die;
  5411. if (empty ( $receiptDetail ) || $nsflag)
  5412. return "/approvalExpenses/pendApproval";
  5413. $verifyDetail = $verify->getOne ( array (
  5414. 'where' => ' vid =' . $receiptDetail ['verify'],
  5415. 'asArray' => true
  5416. ) );
  5417. $verifyString = $verifyDetail ['staff'];
  5418. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5419. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5420. if (empty ( $opinion )) {
  5421. if ($status == 3)
  5422. $opinion = "终止";
  5423. else
  5424. $opinion = "同意支付";
  5425. }
  5426. $nowStaff = 0;
  5427. $nowStaffList = array ();
  5428. if (empty ( $verifyStaff )) {
  5429. // 还需加入是否已经进入角色审批
  5430. if ($verifyDetail [0] [1] == 'ROLE') {
  5431. // print_r($verifyDetail);echo "ddd";
  5432. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5433. foreach ( $vStaffString as $key => $value ) {
  5434. $staffK = explode ( "_", $value );
  5435. if ($staffK [0] != $this->staff [0] ['sid'])
  5436. array_push ( $nowStaffList, $staffK [0] );
  5437. }
  5438. // print_r($verifyDetail);
  5439. // die;
  5440. if (! empty ( $nowStaffList )) {
  5441. $nowStaff = implode ( ',', $nowStaffList );
  5442. $verifyStaff = array (
  5443. $this->staff [0] ['sid'] . "_R" => array (
  5444. 'date' => date ( 'Y-m-d' ),
  5445. 'opinion' => $opinion,
  5446. 'status' => $status,
  5447. 'nextStaff' => $verifyDetail [0] [0],
  5448. 'ROLE' => 1
  5449. )
  5450. );
  5451. } else {
  5452. $nowStaff = $verifyDetail [1] [0];
  5453. $verifyStaff = array (
  5454. $this->staff [0] ['sid'] . "_R" => array (
  5455. 'date' => date ( 'Y-m-d' ),
  5456. 'opinion' => $opinion,
  5457. 'status' => $status,
  5458. 'nextStaff' => $verifyDetail [1] [0]
  5459. )
  5460. );
  5461. }
  5462. } else {
  5463. if ($verifyDetail [1] [1] == 'ROLE') {
  5464. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5465. // echo "dd";
  5466. foreach ( $vStaffString as $key => $value ) {
  5467. $staffK = explode ( "_", $value );
  5468. array_push ( $nowStaffList, $staffK [0] );
  5469. }
  5470. $nowStaff = implode ( ',', $nowStaffList );
  5471. $verifyStaff = array (
  5472. $this->staff [0] ['sid'] => array (
  5473. 'date' => date ( 'Y-m-d' ),
  5474. 'opinion' => $opinion,
  5475. 'status' => $status,
  5476. 'nextStaff' => $verifyDetail [1] [0],
  5477. 'ROLE' => 1
  5478. )
  5479. );
  5480. } else {
  5481. $nowStaff = $verifyDetail [1] [0];
  5482. $verifyStaff = array (
  5483. $this->staff [0] ['sid'] => array (
  5484. 'date' => date ( 'Y-m-d' ),
  5485. 'opinion' => $opinion,
  5486. 'status' => $status,
  5487. 'nextStaff' => $verifyDetail [1] [0]
  5488. )
  5489. );
  5490. }
  5491. }
  5492. if ($status == 3)
  5493. $verifyStaff = array (
  5494. 'final' => $status,
  5495. $this->staff [0] ['sid'] => array (
  5496. 'date' => date ( 'Y-m-d' ),
  5497. 'opinion' => $opinion,
  5498. 'status' => $status
  5499. )
  5500. );
  5501. $vStaffString = json_encode ( $verifyStaff );
  5502. $receipt->nowStaff = $nowStaff;
  5503. $receipt->verifyStaff = $vStaffString;
  5504. $loanReceipt->nowStaff = $nowStaff;
  5505. $loanReceipt->verifyStaff = $vStaffString;
  5506. } else {
  5507. $VS = end ( $verifyStaff );
  5508. // 非角色审批
  5509. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5510. $nextStaff = 0;
  5511. $roleSTF = false;
  5512. foreach ( $verifyDetail as $key => $value ) {
  5513. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5514. if (isset ( $verifyDetail [$key + 1] )) {
  5515. $nextStaff = $verifyDetail [$key + 1] [0];
  5516. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5517. $roleSTF = true;
  5518. }
  5519. break;
  5520. }
  5521. }
  5522. if (! $roleSTF) {
  5523. $nowStaff = $nextStaff;
  5524. $verifyStaff [$this->staff [0] ['sid']] = array (
  5525. 'date' => date ( 'Y-m-d' ),
  5526. 'opinion' => $opinion,
  5527. 'status' => $status,
  5528. 'nextStaff' => $nextStaff
  5529. );
  5530. } else {
  5531. // 获取角色下的所有用户ID
  5532. $nowStaffList = array ();
  5533. foreach ( $verifyDetail as $vfk ) {
  5534. if ($vfk [1] == 'ROLE') {
  5535. $vStaffString = json_decode ( $vfk [3] );
  5536. foreach ( $vStaffString as $key => $value ) {
  5537. $staffK = explode ( "_", $value );
  5538. array_push ( $nowStaffList, $staffK [0] );
  5539. }
  5540. }
  5541. }
  5542. $nowStaff = implode ( ',', $nowStaffList );
  5543. $verifyStaff [$this->staff [0] ['sid']] = array (
  5544. 'date' => date ( 'Y-m-d' ),
  5545. 'opinion' => $opinion,
  5546. 'status' => $status,
  5547. 'nextStaff' => $nextStaff,
  5548. 'ROLE' => 0
  5549. );
  5550. }
  5551. if ($status == 3) {
  5552. $verifyStaff ['final'] = $status;
  5553. $verifyStaff [$this->staff [0] ['sid']] = array (
  5554. 'date' => date ( 'Y-m-d' ),
  5555. 'opinion' => $opinion,
  5556. 'status' => $status
  5557. );
  5558. }
  5559. $vStaffString = json_encode ( $verifyStaff );
  5560. $receipt->nowStaff = $nowStaff;
  5561. $receipt->verifyStaff = $vStaffString;
  5562. $loanReceipt->nowStaff = $nowStaff;
  5563. $loanReceipt->verifyStaff = $vStaffString;
  5564. }
  5565. // 角色审批
  5566. if (isset ( $VS ['ROLE'] )) {
  5567. // 找出角色人 当前审批角色组
  5568. $verifyJSStaff = array ();
  5569. $nowStaffList2 = array ();
  5570. foreach ( $verifyDetail as $key => $value ) {
  5571. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5572. $verifyJSStaff = json_decode ( $value [3] );
  5573. foreach ( $verifyJSStaff as $m ) {
  5574. $staffK = explode ( "_", $m );
  5575. array_push ( $nowStaffList2, $staffK [0] );
  5576. }
  5577. // print_r($nowStaffList2);
  5578. }
  5579. }
  5580. $RoleVerifyStaff = array ();
  5581. foreach ( $verifyStaff as $key => $value ) {
  5582. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5583. foreach ( $nowStaffList2 as $m ) {
  5584. if ($key == $m . "_R")
  5585. $RoleVerifyStaff [$key] = $value;
  5586. }
  5587. }
  5588. }
  5589. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5590. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5591. // 下一个审批人ID
  5592. $nextStaff = 0;
  5593. $falg = false;
  5594. foreach ( $verifyDetail as $key => $value ) {
  5595. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5596. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5597. $falg = true;
  5598. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5599. $nowStaffList = array ();
  5600. foreach ( $vStaffString as $v ) {
  5601. $staffK = explode ( "_", $v );
  5602. array_push ( $nowStaffList, $staffK [0] );
  5603. }
  5604. $nowStaff = implode ( ',', $nowStaffList );
  5605. $nextStaff = $verifyDetail [$key + 1] [0];
  5606. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5607. $nextStaff = $verifyDetail [$key + 1] [0];
  5608. $nowStaff = $nextStaff;
  5609. } else
  5610. $nowStaff = '';
  5611. break;
  5612. }
  5613. }
  5614. if ($falg)
  5615. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5616. 'date' => date ( 'Y-m-d' ),
  5617. 'opinion' => $opinion,
  5618. 'status' => $status,
  5619. 'nextStaff' => $nextStaff,
  5620. 'ROLE' => 1
  5621. );
  5622. else
  5623. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5624. 'date' => date ( 'Y-m-d' ),
  5625. 'opinion' => $opinion,
  5626. 'status' => $status,
  5627. 'nextStaff' => $nextStaff
  5628. );
  5629. // print_r($verifyStaff);
  5630. // echo $nowStaff;die;
  5631. } else { // 进入下一个角色或者审批人
  5632. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5633. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5634. 'date' => date ( 'Y-m-d' ),
  5635. 'opinion' => $opinion,
  5636. 'status' => $status,
  5637. 'nextStaff' => $VS ['nextStaff'],
  5638. 'ROLE' => 1
  5639. );
  5640. }
  5641. if ($status == 3) {
  5642. $verifyStaff ['final'] = $status;
  5643. $verifyStaff [$this->staff [0] ['sid']] = array (
  5644. 'date' => date ( 'Y-m-d' ),
  5645. 'opinion' => $opinion,
  5646. 'status' => $status
  5647. );
  5648. }
  5649. $vStaffString = json_encode ( $verifyStaff );
  5650. $receipt->verifyStaff = $vStaffString;
  5651. $receipt->nowStaff = $nowStaff;
  5652. $loanReceipt->nowStaff = $nowStaff;
  5653. $loanReceipt->verifyStaff = $vStaffString;
  5654. }
  5655. // print_r($verifyStaff);die;
  5656. }
  5657. $roleKey = 0;
  5658. $roleId = 0;
  5659. $verifyDetailCopy = array ();
  5660. foreach ( $verifyDetail as $k => $v ) {
  5661. if ($v [1] == 'ROLE') {
  5662. $roleId = $v [0];
  5663. $roleVerify = json_decode ( $v [3], true );
  5664. $roleKey = $k;
  5665. $roleArray = array ();
  5666. foreach ( $roleVerify as $o => $p ) {
  5667. $staffID = explode ( '_', $p );
  5668. $exp = array (
  5669. 0 => $staffID [0],
  5670. 1 => $staffID [1]
  5671. );
  5672. array_push ( $roleArray, $exp );
  5673. }
  5674. $verifyDetailCopy [$v [0]] = $roleArray;
  5675. }
  5676. }
  5677. // print_r($verifyDetail);
  5678. foreach ( $verifyDetailCopy as $k => $v ) {
  5679. foreach ( $verifyDetail as $m => $n ) {
  5680. if ($n [0] == $k) {
  5681. array_splice ( $verifyDetail, $m, 1, $v );
  5682. }
  5683. }
  5684. }
  5685. // 审批日志
  5686. if (! isset ( $verifyStaff ['final'] )) {
  5687. Doo::loadModel ( "receiptLog" );
  5688. $receiptLog = new receiptLog ();
  5689. if (! empty ( $roleId )) {
  5690. Doo::loadModel ( "role" );
  5691. $role = new role ();
  5692. $roleInfo = $role->getOne ( array (
  5693. 'where' => 'rid=' . $roleId,
  5694. 'asArray' => true
  5695. ) );
  5696. $receiptLog->rolename = $roleInfo ['name'];
  5697. }
  5698. $receiptLog->username = $this->staff [0] ['username'];
  5699. $receiptLog->uid = $this->staff [0] ['sid'];
  5700. $receiptLog->date = date ( "Y-m-d" );
  5701. $receiptLog->opinion = $opinion;
  5702. $receiptLog->img = $this->staff [0] ['avatar'];
  5703. $receiptLog->status = 1;
  5704. $receiptLog->rid = $rid;
  5705. $receiptLog->insert ();
  5706. }
  5707. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5708. $receipt->status = 3;
  5709. $receipt->verifyBreakup = $verifyString;
  5710. $receiptDetailObj->status = 3;
  5711. $receiptDetailObj->update ( array (
  5712. 'where' => 'rid=' . $rid
  5713. ) );
  5714. // 微信企业号通知
  5715. $this->setWXMsg ( $rid, 3 );
  5716. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5717. $receipt->status = 6;
  5718. $receipt->pastDate = date ( "Y-m-d" );
  5719. $receipt->isBK = 1;
  5720. $loanReceipt->verifyBreakup = $verifyString;
  5721. $loanReceipt->status = 1;
  5722. $loanReceipt->pastDate = date ( "Y-m-d" );
  5723. //生成流水后 不更新汇款金额
  5724. Doo::loadModel ( 'wasteBook' );
  5725. $wasteBook = new wasteBook ();
  5726. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5727. if (empty($wbDetail)){
  5728. $loanReceipt->amount = $receiptDetail ['amount'];
  5729. }
  5730. $loanReceipt->update ( array (
  5731. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5732. ) );
  5733. // 微信企业号通知
  5734. $this->setWXMsg ( $rid, 1 );
  5735. }
  5736. $receipt->amount = $receiptDetail['sum'];
  5737. $receipt->update ( array (
  5738. 'where' => ' rid = ' . $rid
  5739. ) );
  5740. // 进入下一条审批费用新加需求
  5741. $vidList = array ();
  5742. $verifyDetail = $verify->find ( array (
  5743. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5744. 'asArray' => true
  5745. ) );
  5746. foreach ( $verifyDetail as $key => $value ) {
  5747. array_push ( $vidList, $value ['vid'] );
  5748. }
  5749. $vid = implode ( ",", $vidList );
  5750. if (empty ( $verifyDetail ))
  5751. $vid = 0;
  5752. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5753. $receipt = new receipt ();
  5754. $rd = $receipt->getOne ( array (
  5755. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5756. 'asc' => 'rid',
  5757. 'asArray' => true
  5758. ) );
  5759. if (empty ( $rd )) {
  5760. return '/approvalExpenses/pendApproval';
  5761. }
  5762. if ($rd ['Rtype'] == 1) {
  5763. if ($rd ['isBK'] == 1) {
  5764. return '/receiptburEdi/' . $rd ['rid'];
  5765. } else {
  5766. return '/expensesEdi/' . $rd ['rid'];
  5767. }
  5768. } elseif ($rd ['Rtype'] == 2) {
  5769. return '/remitApproval/' . $rd ['rid'];
  5770. } else {
  5771. return '/receiptburEdi/' . $rd ['rid'];
  5772. }
  5773. // return "/approvalExpenses/pendApproval";
  5774. }
  5775. }
  5776. function ajaxExamineExe() {
  5777. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5778. Doo::loadModel ( 'receipt' );
  5779. $receipt = new receipt ();
  5780. Doo::loadClass ( 'XDeode' );
  5781. $XDeode = new XDeode ( 5 );
  5782. if (! empty ( $rid )) {
  5783. $rLRes = $receipt->find ( array (
  5784. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5785. 'asArray' => true
  5786. ) );
  5787. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5788. echo json_encode ( array (
  5789. 'status' => 1,
  5790. 'receipt' => $rLRes [0]
  5791. ) );
  5792. die ();
  5793. }
  5794. echo json_encode ( array (
  5795. 'status' => 0,
  5796. 'receipt' => array ()
  5797. ) );
  5798. die ();
  5799. }
  5800. function implement() {
  5801. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5802. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5803. Doo::loadClass ( 'XDeode' );
  5804. $XDeode = new XDeode ( 5 );
  5805. Doo::loadModel ( 'receipt' );
  5806. $receipt = new receipt ();
  5807. Doo::loadModel ( 'L_category' );
  5808. $Lcategory = new L_category ();
  5809. Doo::loadModel ( 'verify' );
  5810. $verify = new verify ();
  5811. Doo::loadModel ( 'staff' );
  5812. $staff = new staff ();
  5813. Doo::loadModel ( "execute" );
  5814. $execute = new execute ();
  5815. $rid = $XDeode->decode ( $rid );
  5816. $receiptList = $receipt->find ( array (
  5817. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5818. 'desc' => 'rid',
  5819. 'asArray' => true
  5820. ) );
  5821. Doo::loadModel ( 'loanReceipt' );
  5822. $loanReceipt = new loanReceipt ();
  5823. // print_r($receiptList);
  5824. $loanList = array ();
  5825. if (! isset ( $receiptList ))
  5826. $loanList = $loanReceipt->find ( array (
  5827. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5828. 'desc' => 'rid',
  5829. 'asArray' => true
  5830. ) );
  5831. $Locate = 0;
  5832. $roleId = 0;
  5833. $button = 0;
  5834. foreach ( $loanList as $key => $value ) {
  5835. $loanList [$key] ['Locate'] = $Locate;
  5836. $Locate ++;
  5837. $loanList [$key] ['reviseDetail'] = array ();
  5838. if (! empty ( $value ['reviseDetail'] ))
  5839. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5840. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5841. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5842. $categoryDetil = $Lcategory->getOne ( array (
  5843. 'where' => 'cid=' . $value ['cid'],
  5844. 'asArray' => true
  5845. ) );
  5846. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5847. // 检测编辑状态
  5848. $verifyList = $verify->getOne ( array (
  5849. 'where' => 'vid=' . $value ['verify'],
  5850. 'asArray' => true
  5851. ) );
  5852. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5853. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5854. Doo::loadModel ( 'role' );
  5855. $role = new role ();
  5856. $flag = true;
  5857. $roleKey = 0;
  5858. $endStaffArray = array ();
  5859. $roleArrayCopy = array ();
  5860. foreach ( $verifyList as $k => $v ) {
  5861. // init verifyStaff
  5862. if ($v [1] == 'ROLE') {
  5863. if (! empty ( $verifyStaff )) {
  5864. $endStaffArray = end ( $verifyStaff );
  5865. // if ($v[0]==$endStaffArray['nextStaff']){
  5866. // $roleId=$v[0];
  5867. // }
  5868. }
  5869. $roleVerify = json_decode ( $v [3], true );
  5870. $roleKey = $k;
  5871. $roleArray = array ();
  5872. $rolename = $role->getOne ( array (
  5873. 'where' => 'rid=' . $v [0],
  5874. 'asArray' => true
  5875. ) );
  5876. foreach ( $roleVerify as $o => $p ) {
  5877. $staffID = explode ( '_', $p );
  5878. $staffInfo = $staff->getOne ( array (
  5879. 'where' => 'sid=' . $staffID [0],
  5880. 'asArray' => true
  5881. ) );
  5882. // print_r($staffID);
  5883. $exp = array (
  5884. 0 => $staffInfo ['sid'],
  5885. 1 => $staffID [1],
  5886. 2 => $staffInfo ['avatar'],
  5887. 'date' => '',
  5888. 'date' => '',
  5889. 'opinion' => '',
  5890. 'status' => '',
  5891. 'rolename' => $rolename ['name']
  5892. );
  5893. array_push ( $roleArray, $exp );
  5894. }
  5895. $roleArrayCopy [$v [0]] = $roleArray;
  5896. // $verifyList[$k]['roleArray']=$roleArray;
  5897. }
  5898. $verifyList [$k] ['date'] = "";
  5899. $verifyList [$k] ['opinion'] = "";
  5900. $verifyList [$k] ['status'] = "";
  5901. if (empty ( $verifyStaff )) {
  5902. $verifyList [$k] ['date'] = "";
  5903. $verifyList [$k] ['opinion'] = "";
  5904. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5905. $verifyList [$k] ['status'] = 4;
  5906. $flag = false;
  5907. }
  5908. } else {
  5909. foreach ( $verifyStaff as $m => $u ) {
  5910. if ($v [0] == $m) {
  5911. $verifyList [$k] ['date'] = $u ['date'];
  5912. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5913. $verifyList [$k] ['status'] = $u ['status'];
  5914. $flag = false;
  5915. break;
  5916. }
  5917. }
  5918. $endStaffArray = end ( $verifyStaff );
  5919. if (isset ( $endStaffArray ['ROLE'] )) {
  5920. } else {
  5921. // $endKey=key($verifyStaff);
  5922. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5923. // $button=4;
  5924. // $verifyList[$k]['status']=4;
  5925. // }
  5926. }
  5927. }
  5928. }
  5929. $rolename ['name'] = '';
  5930. if (! empty ( $roleId )) {
  5931. Doo::loadModel ( 'role' );
  5932. $role = new role ();
  5933. $rolename = $role->getOne ( array (
  5934. 'where' => 'rid=' . $roleId,
  5935. 'asArray' => true
  5936. ) );
  5937. }
  5938. if (! empty ( $verifyStaff ))
  5939. $endStaffArray = end ( $verifyStaff );
  5940. $KOP = false;
  5941. foreach ( $roleArrayCopy as $P => $A ) {
  5942. foreach ( $A as $MKI => $AVL ) {
  5943. if (! empty ( $verifyStaff )) {
  5944. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5945. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5946. $button = 4;
  5947. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5948. }
  5949. foreach ( $verifyStaff as $m => $u ) {
  5950. $AVLFK = $AVL [0] . '_R';
  5951. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5952. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5953. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5954. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5955. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5956. break;
  5957. }
  5958. }
  5959. } else {
  5960. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5961. $button = 4;
  5962. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5963. }
  5964. }
  5965. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5966. $KOP = true;
  5967. }
  5968. }
  5969. foreach ( $roleArrayCopy as $k => $v ) {
  5970. foreach ( $verifyList as $m => $n ) {
  5971. if ($n [0] == $k) {
  5972. array_splice ( $verifyList, $m, 1, $v );
  5973. }
  5974. }
  5975. }
  5976. $loanList [$key] ['verifyList'] = $verifyList;
  5977. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5978. 'where' => 'sid=' . $value ['staff'],
  5979. 'asArray' => true
  5980. ) );
  5981. }
  5982. $data ['loanList'] = $loanList;
  5983. $Locate = 0;
  5984. $roleId = 0;
  5985. $button = 0;
  5986. Doo::loadClass ( 'XDeode' );
  5987. $XDeode = new XDeode ( 5 );
  5988. foreach ( $receiptList as $key => $value ) {
  5989. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5990. $button2 = 0;
  5991. $receiptList [$key] ['Locate'] = $Locate;
  5992. $Locate ++;
  5993. $receiptList [$key] ['reviseDetail'] = array ();
  5994. if (! empty ( $value ['reviseDetail'] ))
  5995. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5996. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5997. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5998. $categoryDetil = $Lcategory->getOne ( array (
  5999. 'where' => 'cid=' . $value ['cid'],
  6000. 'asArray' => true
  6001. ) );
  6002. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6003. $executeList = json_decode ( $value ['executeCopy'], true );
  6004. $executeStaff = array ();
  6005. if (! empty ( $value ['executeStaff'] ))
  6006. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6007. if (isset ( $executeList )) {
  6008. foreach ( $executeList as $op => $lo ) {
  6009. $executeList [$op] ['date'] = "";
  6010. $executeList [$op] ['opinion'] = "";
  6011. $executeList [$op] ['status'] = "";
  6012. foreach ( $executeStaff as $m => $u ) {
  6013. if ($lo [0] == $m) {
  6014. $executeList [$op] ['date'] = $u ['date'];
  6015. $executeList [$op] ['opinion'] = $u ['opinion'];
  6016. $executeList [$op] ['status'] = $u ['status'];
  6017. break;
  6018. }
  6019. }
  6020. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6021. $button2 = 1;
  6022. $executeList [$op] ['status'] = 4;
  6023. }
  6024. }
  6025. }
  6026. // 检测编辑状态
  6027. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6028. $verifyList ['staff'] = $value ['verifyBreakup'];
  6029. } else
  6030. $verifyList = $verify->getOne ( array (
  6031. 'where' => 'vid=' . $value ['verify'],
  6032. 'asArray' => true
  6033. ) );
  6034. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6035. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6036. Doo::loadModel ( 'role' );
  6037. $role = new role ();
  6038. if ($verifyList == NULL)
  6039. $verifyList = array ();
  6040. $flag = true;
  6041. $roleKey = 0;
  6042. $endStaffArray = array ();
  6043. $roleArrayCopy = array ();
  6044. foreach ( $verifyList as $k => $v ) {
  6045. // init verifyStaff
  6046. if ($v [1] == 'ROLE') {
  6047. if (! empty ( $verifyStaff )) {
  6048. $endStaffArray = end ( $verifyStaff );
  6049. // if ($v[0]==$endStaffArray['nextStaff']){
  6050. // $roleId=$v[0];
  6051. // }
  6052. }
  6053. $roleVerify = json_decode ( $v [3], true );
  6054. $roleKey = $k;
  6055. $roleArray = array ();
  6056. $rolename = $role->getOne ( array (
  6057. 'where' => 'rid=' . $v [0],
  6058. 'asArray' => true
  6059. ) );
  6060. foreach ( $roleVerify as $o => $p ) {
  6061. $staffID = explode ( '_', $p );
  6062. $staffInfo = $staff->getOne ( array (
  6063. 'where' => 'sid=' . $staffID [0],
  6064. 'asArray' => true
  6065. ) );
  6066. // print_r($staffID);
  6067. $exp = array (
  6068. 0 => $staffInfo ['sid'],
  6069. 1 => $staffID [1],
  6070. 2 => $staffInfo ['avatar'],
  6071. 'date' => '',
  6072. 'date' => '',
  6073. 'opinion' => '',
  6074. 'status' => '',
  6075. 'rolename' => $rolename ['name']
  6076. );
  6077. array_push ( $roleArray, $exp );
  6078. }
  6079. $roleArrayCopy [$v [0]] = $roleArray;
  6080. // $verifyList[$k]['roleArray']=$roleArray;
  6081. }
  6082. $verifyList [$k] ['date'] = "";
  6083. $verifyList [$k] ['opinion'] = "";
  6084. $verifyList [$k] ['status'] = "";
  6085. if (empty ( $verifyStaff )) {
  6086. $verifyList [$k] ['date'] = "";
  6087. $verifyList [$k] ['opinion'] = "";
  6088. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6089. $verifyList [$k] ['status'] = 4;
  6090. $flag = false;
  6091. }
  6092. } else {
  6093. foreach ( $verifyStaff as $m => $u ) {
  6094. if ($v [0] == $m) {
  6095. $verifyList [$k] ['date'] = $u ['date'];
  6096. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6097. $verifyList [$k] ['status'] = $u ['status'];
  6098. $flag = false;
  6099. break;
  6100. }
  6101. }
  6102. $endStaffArray = end ( $verifyStaff );
  6103. if (isset ( $endStaffArray ['ROLE'] )) {
  6104. } else {
  6105. // $endKey=key($verifyStaff);
  6106. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6107. // $button=4;
  6108. // $verifyList[$k]['status']=4;
  6109. // }
  6110. }
  6111. }
  6112. }
  6113. $rolename ['name'] = '';
  6114. if (! empty ( $roleId )) {
  6115. Doo::loadModel ( 'role' );
  6116. $role = new role ();
  6117. $rolename = $role->getOne ( array (
  6118. 'where' => 'rid=' . $roleId,
  6119. 'asArray' => true
  6120. ) );
  6121. }
  6122. if (! empty ( $verifyStaff ))
  6123. $endStaffArray = end ( $verifyStaff );
  6124. $KOP = false;
  6125. foreach ( $roleArrayCopy as $P => $A ) {
  6126. foreach ( $A as $MKI => $AVL ) {
  6127. if (! empty ( $verifyStaff )) {
  6128. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6129. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6130. $button = 4;
  6131. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6132. }
  6133. foreach ( $verifyStaff as $m => $u ) {
  6134. $AVLFK = $AVL [0] . '_R';
  6135. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6136. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6137. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6138. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6139. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6140. break;
  6141. }
  6142. }
  6143. } else {
  6144. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6145. $button = 4;
  6146. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6147. }
  6148. }
  6149. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6150. $KOP = true;
  6151. }
  6152. }
  6153. foreach ( $roleArrayCopy as $k => $v ) {
  6154. foreach ( $verifyList as $m => $n ) {
  6155. if ($n [0] == $k) {
  6156. array_splice ( $verifyList, $m, 1, $v );
  6157. }
  6158. }
  6159. }
  6160. $receiptList [$key] ['verifyList'] = $verifyList;
  6161. $receiptList [$key] ['executeList'] = $executeList;
  6162. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6163. 'where' => 'sid=' . $value ['staff'],
  6164. 'asArray' => true
  6165. ) );
  6166. $receiptList [$key] ['button2'] = $button2;
  6167. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6168. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6169. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6170. $receiptList [$key] ['relust'] = $relust;
  6171. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6172. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6173. }
  6174. //执行人是否是最后一位
  6175. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6176. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6177. $executePrimary=count($executeCopy)-1;
  6178. $lastOne=true;
  6179. if($executePrimary!=count($executeStaff)){
  6180. $lastOne=false;
  6181. }
  6182. $data['lastOne']=$lastOne;
  6183. // 是否写入过流水
  6184. $accountType = 0;
  6185. if ($receiptList [0] ['Rtype'] == 0) {
  6186. $accountType = 3;
  6187. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6188. if (!empty($receiptList [0]['accountItem']) )
  6189. $accountType = 2;
  6190. else
  6191. $accountType = 1;
  6192. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6193. $accountType = 4;
  6194. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6195. $accountType = 12;
  6196. }
  6197. Doo::loadModel ( 'wasteBook' );
  6198. $wasteBook = new wasteBook ();
  6199. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6200. $data ['wbDetail'] = $wbDetail;
  6201. $wbDetailLoan=array();
  6202. if ($accountType==2){
  6203. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6204. }
  6205. $data ['wbDetailLoan'] = $wbDetailLoan;
  6206. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6207. //print_r($wbDetail);
  6208. if($receiptList[0]['version']==1){
  6209. require "protected/class/comm_cld.php";
  6210. $receiptList=makeReceiptDataVersion1($receiptList);
  6211. }
  6212. $data ['receiptList'] = $receiptList;
  6213. $data ['memu'] = "receipt";
  6214. $data ['staff'] = $this->staff;
  6215. $data ['receiptMemu'] = 'implement';
  6216. $data ['verifyId'] = $this->verifyId;
  6217. $data ['executeId'] = $this->executeId;
  6218. if ($Rtype=="loan"){
  6219. $this->render ( "/receipt/receiptImplementLoan", $data );
  6220. }elseif($Rtype=="receipt"){
  6221. if($receiptList[0]['receiptClass']==2){
  6222. //TODO 费用执行行程单2.0
  6223. if(!empty($receiptList[0]['itinerary2'])){
  6224. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6225. }else{
  6226. $this->render ( "/receipt/receiptImplementTrave", $data );
  6227. }
  6228. }else{
  6229. $this->render ( "/receipt/receiptImplement", $data );
  6230. }
  6231. }elseif($Rtype=="public"){
  6232. $this->render ( "/receipt/receiptImplementPublic", $data );
  6233. }else{
  6234. //$this->render ( "/admin/implement", $data );
  6235. }
  6236. }
  6237. function implementDo() {
  6238. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6239. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6240. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6241. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6242. // $ab = '';
  6243. // if ($accountBank == 'CGBDeposit')
  6244. // $ab = '纵横广发';
  6245. // elseif ($accountBank == 'ICBCDeposit')
  6246. // $ab = '纵横工行';
  6247. // elseif ($accountBank == 'HUADeposit')
  6248. // $ab = '华润银行';
  6249. // elseif ($accountBank == 'PersonalDeposit')
  6250. // $ab = '个人广发';
  6251. // if (empty ( $ab ))
  6252. // die ( 'illegal request--22' );
  6253. if (! empty ( $rid )) {
  6254. Doo::loadModel ( 'receipt' );
  6255. $receipt = new receipt ();
  6256. Doo::loadClass ( 'XDeode' );
  6257. $XDeode = new XDeode ( 5 );
  6258. $rid=$XDeode->decode($rid);
  6259. if (!is_numeric($rid)){
  6260. die;
  6261. }
  6262. // $rinfo = $receipt->getOne ( array (
  6263. // 'where' => 'rid=' . $rid,
  6264. // 'asArray' => true
  6265. // ) );
  6266. $rinfo = $receipt->getReceiptByRid ( $rid );
  6267. // $accountType = '';
  6268. // if ($rinfo ['Rtype'] == 1) {
  6269. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6270. // $accountType = 2;
  6271. // else
  6272. // $accountType = 1;
  6273. // } elseif ($rinfo ['Rtype'] == 2) {
  6274. // $accountType = 4;
  6275. // } elseif ($rinfo ['Rtype'] == 0)
  6276. // $accountType = 3;
  6277. // if (empty ( $accountType ))
  6278. // die ( 'illegal request' );
  6279. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6280. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6281. if (empty ( $executeStaff )) {
  6282. $executeStaff = array (
  6283. $this->staff [0] ['sid'] => array (
  6284. 'date' => date ( 'Y-m-d' ),
  6285. 'opinion' => $implementOpinions,
  6286. 'status' => 1
  6287. )
  6288. );
  6289. } else {
  6290. $executeStaff [$this->staff [0] ['sid']] = array (
  6291. 'date' => date ( 'Y-m-d' ),
  6292. 'opinion' => $implementOpinions,
  6293. 'status' => 1
  6294. );
  6295. }
  6296. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6297. $receipt->executeStaff = json_encode ( $executeStaff );
  6298. $receipt->status = 8;
  6299. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6300. $receipt->status = 9;
  6301. if ($rinfo ['status'] == 6) {
  6302. $receipt->loanDate = date ( "Y-m-d" );
  6303. }
  6304. $receipt->executeDate = date ( "Y-m-d" );
  6305. } else {
  6306. $receipt->executeStaff = json_encode ( $executeStaff );
  6307. }
  6308. //$receipt->amount = $amount;
  6309. $receipt->update ( array (
  6310. 'where' => 'rid=' . $rid
  6311. ) );
  6312. // 公司流水记录
  6313. // Doo::loadModel ( 'wasteBook' );
  6314. // $wasteBook = new wasteBook ();
  6315. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6316. // // 银行
  6317. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6318. // $item = array (
  6319. // 'dataID' => $rid,
  6320. // 'expensesType' => 2,
  6321. // 'accountType' => $accountType,
  6322. // 'accountPriceShow' => $amount,
  6323. // 'accountPrice' => - $amount,
  6324. // 'accountBank' => $accountBank,
  6325. // 'category' => $rinfo ['category'] [0] ['title'],
  6326. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6327. // 'name' => $rinfo ['staffDetail'] ['username'],
  6328. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6329. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6330. // );
  6331. // $wasteBook->setAccountBookStatistics ( $item );
  6332. // }
  6333. }
  6334. //$ridKey = $XDeode->encode ( $rid );
  6335. return "/hisImplement";
  6336. // return "/implement/" . $ridKey . ".html";
  6337. }
  6338. function receiptburEdi() {
  6339. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6340. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6341. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6342. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6343. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6344. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6345. if (empty ( $status ))
  6346. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6347. $vidList = array ();
  6348. $button = 0;
  6349. Doo::loadModel ( 'verify' );
  6350. Doo::loadModel ( 'receipt' );
  6351. Doo::loadModel ( 'staff' );
  6352. $staff = new staff ();
  6353. $receipt = new receipt ();
  6354. $verify = new verify ();
  6355. Doo::loadModel ( 'L_category' );
  6356. $Lcategory = new L_category ();
  6357. Doo::loadModel ( 'enclosur' );
  6358. $enclosur = new enclosur ();
  6359. Doo::loadModel ( 'loanReceipt' );
  6360. $loanReceipt = new loanReceipt ();
  6361. // user verify ID
  6362. $verifyDetail = $verify->find ( array (
  6363. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6364. 'asArray' => true
  6365. ) );
  6366. foreach ( $verifyDetail as $key => $value ) {
  6367. array_push ( $vidList, $value ['vid'] );
  6368. }
  6369. $vid = implode ( ",", $vidList );
  6370. if (empty ( $verifyDetail ))
  6371. $vid = 0;
  6372. $categoryList = $Lcategory->find ( array (
  6373. 'asArray' => true
  6374. ) );
  6375. $staffList = $staff->find ( array (
  6376. 'where' => 'cid=' . $cid,
  6377. 'asArray' => true
  6378. ) );
  6379. $ap = "";
  6380. if ($status == 4) {
  6381. $ap = 4;
  6382. $status = 2;
  6383. }
  6384. // get Receipt By verifyID status 2
  6385. $receiptList = $receipt->find ( array (
  6386. 'where' => 'rid =' . $rid . ' and status=2',
  6387. 'desc' => 'rid',
  6388. 'asArray' => true
  6389. ) );
  6390. if (empty ( $receiptList )) {
  6391. die ( 'illegal request' );
  6392. }
  6393. $loanList = $loanReceipt->find ( array (
  6394. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6395. 'desc' => 'rid',
  6396. 'asArray' => true
  6397. ) );
  6398. $data ['explanation'] = '';
  6399. if (! empty ( $loanList ))
  6400. $data ['explanation'] = $loanList [0] ['explanation'];
  6401. $Locate = 0;
  6402. $roleId = 0;
  6403. $button = 0;
  6404. foreach ( $loanList as $key => $value ) {
  6405. $loanList [$key] ['Locate'] = $Locate;
  6406. $Locate ++;
  6407. $loanList [$key] ['reviseDetail'] = array ();
  6408. if (! empty ( $value ['reviseDetail'] ))
  6409. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6410. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6411. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6412. $categoryDetil = $Lcategory->getOne ( array (
  6413. 'where' => 'cid=' . $value ['cid'],
  6414. 'asArray' => true
  6415. ) );
  6416. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6417. // 检测编辑状态
  6418. $verifyList = $verify->getOne ( array (
  6419. 'where' => 'vid=' . $value ['verify'],
  6420. 'asArray' => true
  6421. ) );
  6422. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6423. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6424. Doo::loadModel ( 'role' );
  6425. $role = new role ();
  6426. $flag = true;
  6427. $roleKey = 0;
  6428. $endStaffArray = array ();
  6429. $roleArrayCopy = array ();
  6430. foreach ( $verifyList as $k => $v ) {
  6431. // init verifyStaff
  6432. if ($v [1] == 'ROLE') {
  6433. if (! empty ( $verifyStaff )) {
  6434. $endStaffArray = end ( $verifyStaff );
  6435. }
  6436. $roleVerify = json_decode ( $v [3], true );
  6437. $roleKey = $k;
  6438. $roleArray = array ();
  6439. $rolename = $role->getOne ( array (
  6440. 'where' => 'rid=' . $v [0],
  6441. 'asArray' => true
  6442. ) );
  6443. foreach ( $roleVerify as $o => $p ) {
  6444. $staffID = explode ( '_', $p );
  6445. $staffInfo = $staff->getOne ( array (
  6446. 'where' => 'sid=' . $staffID [0],
  6447. 'asArray' => true
  6448. ) );
  6449. // print_r($staffID);
  6450. $exp = array (
  6451. 0 => $staffInfo ['sid'],
  6452. 1 => $staffID [1],
  6453. 2 => $staffInfo ['avatar'],
  6454. 'date' => '',
  6455. 'date' => '',
  6456. 'opinion' => '',
  6457. 'status' => '',
  6458. 'rolename' => $rolename ['name']
  6459. );
  6460. array_push ( $roleArray, $exp );
  6461. }
  6462. $roleArrayCopy [$v [0]] = $roleArray;
  6463. // $verifyList[$k]['roleArray']=$roleArray;
  6464. }
  6465. $verifyList [$k] ['date'] = "";
  6466. $verifyList [$k] ['opinion'] = "";
  6467. $verifyList [$k] ['status'] = "";
  6468. if (empty ( $verifyStaff )) {
  6469. $verifyList [$k] ['date'] = "";
  6470. $verifyList [$k] ['opinion'] = "";
  6471. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6472. $verifyList [$k] ['status'] = 4;
  6473. $flag = false;
  6474. }
  6475. } else {
  6476. foreach ( $verifyStaff as $m => $u ) {
  6477. if ($v [0] == $m) {
  6478. $verifyList [$k] ['date'] = $u ['date'];
  6479. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6480. $verifyList [$k] ['status'] = $u ['status'];
  6481. $flag = false;
  6482. break;
  6483. }
  6484. }
  6485. $endStaffArray = end ( $verifyStaff );
  6486. if (isset ( $endStaffArray ['ROLE'] )) {
  6487. } else {
  6488. }
  6489. }
  6490. }
  6491. $rolename ['name'] = '';
  6492. if (! empty ( $roleId )) {
  6493. Doo::loadModel ( 'role' );
  6494. $role = new role ();
  6495. $rolename = $role->getOne ( array (
  6496. 'where' => 'rid=' . $roleId,
  6497. 'asArray' => true
  6498. ) );
  6499. }
  6500. if (! empty ( $verifyStaff ))
  6501. $endStaffArray = end ( $verifyStaff );
  6502. $KOP = false;
  6503. foreach ( $roleArrayCopy as $P => $A ) {
  6504. foreach ( $A as $MKI => $AVL ) {
  6505. if (! empty ( $verifyStaff )) {
  6506. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6507. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6508. $button = 4;
  6509. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6510. }
  6511. foreach ( $verifyStaff as $m => $u ) {
  6512. $AVLFK = $AVL [0] . '_R';
  6513. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6514. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6515. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6516. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6517. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6518. break;
  6519. }
  6520. }
  6521. } else {
  6522. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6523. $button = 4;
  6524. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6525. }
  6526. }
  6527. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6528. $KOP = true;
  6529. }
  6530. }
  6531. foreach ( $roleArrayCopy as $k => $v ) {
  6532. foreach ( $verifyList as $m => $n ) {
  6533. if ($n [0] == $k) {
  6534. array_splice ( $verifyList, $m, 1, $v );
  6535. }
  6536. }
  6537. }
  6538. $loanList [$key] ['verifyList'] = $verifyList;
  6539. }
  6540. $htmlLoan = '';
  6541. $data ['loanReceiptDate'] = '';
  6542. if (isset ( $loanList [0] )) {
  6543. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6544. if ($value ['status'] == 1)
  6545. $htmlLoan .= '<li class="done" >';
  6546. elseif ($value ['status'] == 3)
  6547. $htmlLoan .= '<li class="undone" >';
  6548. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6549. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6550. if (isset ( $value ['rolename'] ))
  6551. $htmlLoan .= $value ['rolename'];
  6552. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6553. }
  6554. $data ['loanDate'] = $loanList [0] ['date'];
  6555. } else {
  6556. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6557. }
  6558. $data ['htmlLoan'] = $htmlLoan;
  6559. // $data ['LoanReceipt']=$loanList[0];
  6560. // print_r($loanList);
  6561. $Locate = 0;
  6562. $roleId = 0;
  6563. $button = 0;
  6564. if ($ap == 4)
  6565. $status = 4;
  6566. Doo::loadClass ( 'XDeode' );
  6567. $XDeode = new XDeode ( 5 );
  6568. foreach ( $receiptList as $key => $value ) {
  6569. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6570. $receiptList [$key] ['Locate'] = $Locate;
  6571. $Locate ++;
  6572. $receiptList [$key] ['reviseDetail'] = array ();
  6573. // 调整金额 代码调整
  6574. if (! empty ( $value ['reviseDetail'] )) {
  6575. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6576. foreach ( $reviseDetail as $ry => $re ) {
  6577. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6578. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6579. }
  6580. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6581. // print_r($reviseDetail);
  6582. }
  6583. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6584. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6585. $categoryDetil = $Lcategory->getOne ( array (
  6586. 'where' => 'cid=' . $value ['cid'],
  6587. 'asArray' => true
  6588. ) );
  6589. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6590. // 检测编辑状态
  6591. $verifyList = $verify->getOne ( array (
  6592. 'where' => 'vid=' . $value ['verify'],
  6593. 'asArray' => true
  6594. ) );
  6595. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6596. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6597. Doo::loadModel ( 'role' );
  6598. $role = new role ();
  6599. // print_r($verifyList);
  6600. $flag = true;
  6601. $roleKey = 0;
  6602. $endStaffArray = array ();
  6603. $roleArrayCopy = array ();
  6604. foreach ( $verifyList as $k => $v ) {
  6605. // init verifyStaff
  6606. if ($v [1] == 'ROLE') {
  6607. if (! empty ( $verifyStaff )) {
  6608. $endStaffArray = end ( $verifyStaff );
  6609. if ($v [0] == $endStaffArray ['nextStaff']) {
  6610. $roleId = $v [0];
  6611. }
  6612. }
  6613. $roleVerify = json_decode ( $v [3], true );
  6614. $roleKey = $k;
  6615. $roleArray = array ();
  6616. $rolename = $role->getOne ( array (
  6617. 'where' => 'rid=' . $v [0],
  6618. 'asArray' => true
  6619. ) );
  6620. foreach ( $roleVerify as $o => $p ) {
  6621. $staffID = explode ( '_', $p );
  6622. $staffInfo = $staff->getOne ( array (
  6623. 'where' => 'sid=' . $staffID [0],
  6624. 'asArray' => true
  6625. ) );
  6626. // print_r($staffID);
  6627. $exp = array (
  6628. 0 => $staffInfo ['sid'],
  6629. 1 => $staffID [1],
  6630. 2 => $staffInfo ['avatar'],
  6631. 'date' => '',
  6632. 'date' => '',
  6633. 'opinion' => '',
  6634. 'status' => '',
  6635. 'rolename' => $rolename ['name']
  6636. );
  6637. array_push ( $roleArray, $exp );
  6638. }
  6639. $roleArrayCopy [$v [0]] = $roleArray;
  6640. // $verifyList[$k]['roleArray']=$roleArray;
  6641. }
  6642. // print_r($roleArray);
  6643. $verifyList [$k] ['date'] = "";
  6644. $verifyList [$k] ['opinion'] = "";
  6645. $verifyList [$k] ['status'] = "";
  6646. if (empty ( $verifyStaff )) {
  6647. $verifyList [$k] ['date'] = "";
  6648. $verifyList [$k] ['opinion'] = "";
  6649. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6650. $verifyList [$k] ['status'] = 4;
  6651. $button = 4;
  6652. $flag = false;
  6653. }
  6654. } else {
  6655. foreach ( $verifyStaff as $m => $u ) {
  6656. if ($v [0] == $m) {
  6657. $verifyList [$k] ['date'] = $u ['date'];
  6658. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6659. $verifyList [$k] ['status'] = $u ['status'];
  6660. $flag = false;
  6661. break;
  6662. }
  6663. }
  6664. $endStaffArray = end ( $verifyStaff );
  6665. if (isset ( $endStaffArray ['ROLE'] )) {
  6666. } else {
  6667. $endKey = key ( $verifyStaff );
  6668. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6669. $button = 4;
  6670. $verifyList [$k] ['status'] = 4;
  6671. }
  6672. }
  6673. }
  6674. }
  6675. $rolename ['name'] = '';
  6676. if (! empty ( $roleId )) {
  6677. Doo::loadModel ( 'role' );
  6678. $role = new role ();
  6679. $rolename = $role->getOne ( array (
  6680. 'where' => 'rid=' . $roleId,
  6681. 'asArray' => true
  6682. ) );
  6683. }
  6684. if (! empty ( $verifyStaff ))
  6685. $endStaffArray = end ( $verifyStaff );
  6686. $KOP = false;
  6687. foreach ( $roleArrayCopy as $P => $A ) {
  6688. foreach ( $A as $MKI => $AVL ) {
  6689. if (! empty ( $verifyStaff )) {
  6690. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6691. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6692. $button = 4;
  6693. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6694. }
  6695. foreach ( $verifyStaff as $m => $u ) {
  6696. $AVLFK = $AVL [0] . '_R';
  6697. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6698. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6699. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6700. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6701. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6702. break;
  6703. }
  6704. }
  6705. } else {
  6706. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6707. $button = 4;
  6708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6709. }
  6710. }
  6711. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6712. $KOP = true;
  6713. }
  6714. }
  6715. foreach ( $roleArrayCopy as $k => $v ) {
  6716. foreach ( $verifyList as $m => $n ) {
  6717. if ($n [0] == $k) {
  6718. array_splice ( $verifyList, $m, 1, $v );
  6719. }
  6720. }
  6721. }
  6722. // print_r($verifyList);
  6723. $receiptList [$key] ['verifyList'] = $verifyList;
  6724. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6725. 'where' => 'sid=' . $value ['staff'],
  6726. 'asArray' => true
  6727. ) );
  6728. $receiptList [$key] ['button'] = $button;
  6729. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6730. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6731. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6732. $receiptList [$key] ['relust'] = $relust;
  6733. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6734. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6735. }
  6736. //print_r($receiptList);die;
  6737. // $data['verifyDetail']=$verifyDetail;
  6738. $mothHtml = "";
  6739. for($i = 1; $i <= 12; $i ++) {
  6740. if ($month == $i)
  6741. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6742. else
  6743. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6744. }
  6745. // 获取审批日志
  6746. Doo::loadModel ( 'receiptLog' );
  6747. $receiptLog = new receiptLog ();
  6748. $rlList = array ();
  6749. $rlInfo = $receiptLog->getOne ( array (
  6750. 'where' => 'rid=' . $rid . ' and status=4',
  6751. 'asArray' => true
  6752. ) );
  6753. $tijdate = $receiptLog->getOne ( array (
  6754. 'where' => 'rid=' . $rid . ' and status=2',
  6755. 'asc' => 'rlid',
  6756. 'asArray' => true
  6757. ) );
  6758. if (! empty ( $rlInfo )) {
  6759. $rlList = $receiptLog->find ( array (
  6760. 'where' => 'rid=' . $rid,
  6761. 'asc' => 'rlid',
  6762. 'asArray' => true
  6763. ) );
  6764. }
  6765. // echo $rid;
  6766. // print_r($receiptList);
  6767. $receiptList [0] ['rlList'] = $rlList;
  6768. // print_r($receiptList);
  6769. $enclosurList = $enclosur->find ( array (
  6770. 'where' => 'rid=' . $rid,
  6771. 'asArray' => true
  6772. ) );
  6773. $enclosurHtml = '';
  6774. foreach ( $enclosurList as $value ) {
  6775. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6776. }
  6777. $data ['enclosurHtml'] = $enclosurHtml;
  6778. $data ['rolename'] = $rolename ['name'];
  6779. $data ['mothHtml'] = $mothHtml;
  6780. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6781. if($receiptList[0]['version']==1){
  6782. require "protected/class/comm_cld.php";
  6783. $receiptList=makeReceiptDataVersion1($receiptList);
  6784. // //办事处费用
  6785. // $receiptList[0]['officeJson']=json_decode($receiptList[0]['officeJson'],true);
  6786. // if (!empty($receiptList[0]['officeJson'])){
  6787. // $receiptList[0]['officeExplain']="<pre>".$receiptList[0]['officeJson']['officeExplain'][0]['officeExplain']."</pre>";
  6788. // $total=0;
  6789. // foreach ($receiptList[0]['officeJson']['daily'] as $value){
  6790. // $total=bcadd($total,$value['price'],2);
  6791. // }
  6792. // $receiptList[0]['dailyTotal']=$total;
  6793. // $total=0;
  6794. // foreach ($receiptList[0]['officeJson']['other'] as $value){
  6795. // $total=bcadd($total,$value['price'],2);
  6796. // }
  6797. // $receiptList[0]['otherTotal']=$total;
  6798. // $receiptList[0]['officeTotal']=bcadd($receiptList[0]['otherTotal'],$receiptList[0]['dailyTotal'],2);
  6799. // }
  6800. // //差旅费用
  6801. // $traveJson=json_decode($receiptList[0]['traveJson'],true);
  6802. // $receiptList[0]['traveJson']=$traveJson;
  6803. // if (!empty($receiptList[0]['traveJson'])){
  6804. // $receiptList[0]['traveExplain']="<pre>".$receiptList[0]['traveJson']['traveExplain'][0]['traveExplain']."</pre>";
  6805. // $total=0;
  6806. // foreach ($traveJson['traveList'] as $key=>$value){
  6807. // $receiptList[0]['traveJson']['traveList'][$key]['index']=$key+1;
  6808. // $detailCity='';
  6809. // $tripTotal=0;
  6810. // $tripItem=array();
  6811. // //1.行程list
  6812. // foreach ($value['tripList'] as $k=>$v){
  6813. // //2.组合各个城市
  6814. // $detailCity.=$v['city'].' ';
  6815. // //3.组合列详情
  6816. // foreach ($v['tripItem'] as $tk=>$tv){
  6817. // if (!isset($tripItem[$tv['name']])){
  6818. // $tripItem[$tv['name']]=0;
  6819. // }
  6820. // $tripItem[$tv['name']]=bcadd($tripItem[$tv['name']],$tv['price'],2);
  6821. // //3.行程金额小计
  6822. // $tripTotal=bcadd($tripTotal,$tv['price'],2);
  6823. // }
  6824. // $count=count($value['tripList'])-1;
  6825. // if($count>$k){
  6826. // $index=$k+1;
  6827. // $receiptList[0]['traveJson']['traveList'][$key]['tripList'][$k]['goCome']=$v['city'].'-'.$value['tripList'][$index]['city'];
  6828. // }
  6829. // $total=bcadd($total,$v['subtotal'],2);
  6830. // }
  6831. // $receiptList[0]['traveJson']['traveList'][$key]['detailCity']=$detailCity;
  6832. // $receiptList[0]['traveJson']['traveList'][$key]['detailTrip']=$tripItem;
  6833. // $receiptList[0]['traveJson']['traveList'][$key]['tripTotal']=$tripTotal;
  6834. // }
  6835. // $receiptList[0]['traveTotal']=$total;
  6836. // //print_r($receiptList[0]['traveJson']);
  6837. // }
  6838. // //内训费用
  6839. // $receiptList[0]['trainJson']=json_decode($receiptList[0]['trainJson'],true);
  6840. // if (!empty($receiptList[0]['trainJson'])){
  6841. // $receiptList[0]['trainExplain']="<pre>".$receiptList[0]['trainJson']['trainExplain'][0]['trainExplain']."</pre>";
  6842. // $total=0;
  6843. // foreach ($receiptList[0]['trainJson']['train'] as $value){
  6844. // $total=bcadd($total,$value['price'],2);
  6845. // }
  6846. // $receiptList[0]['trainTotal']=$total;
  6847. // }
  6848. }
  6849. $data ['rid'] = $rid;
  6850. $data ['tijdate'] = $tijdate ['date'];
  6851. $data ['receiptList'] = $receiptList;
  6852. $data ['receiptApprovalCount'] = count ( $receiptList );
  6853. $data ['status'] = $status;
  6854. $data ['year'] = $year;
  6855. $data ['categoryList'] = $categoryList;
  6856. $data ['staffList'] = $staffList;
  6857. $data ['cid'] = $cid;
  6858. $data ['sid'] = $sid;
  6859. $data ['ap'] = $ap;
  6860. $data ['memu'] = "receipt";
  6861. $data ['staff'] = $this->staff;
  6862. $data ['receiptMemu'] = 'approvalExpenses';
  6863. $data ['verifyId'] = $this->verifyId;
  6864. $data ['executeId'] = $this->executeId;
  6865. if($receiptList[0]['version']==1){
  6866. $this->render ( "/fee/approval/receipt_compatible", $data );
  6867. die;
  6868. }
  6869. if($receiptList[0]['receiptClass']==1){
  6870. $this->render ( "/receipt/feeAgencyApproval", $data );
  6871. }elseif($receiptList[0]['receiptClass']==2){
  6872. //TODO 行程单2.0
  6873. if(!empty($receiptList[0]['itinerary2'])){
  6874. $this->render ( "/receipt/feeTraveApproval2", $data );
  6875. }else{
  6876. $this->render ( "/receipt/feeTraveApproval", $data );
  6877. }
  6878. }elseif($receiptList[0]['receiptClass']==3){
  6879. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6880. }else{
  6881. $this->render ( "/admin/receiptburEdi", $data );
  6882. }
  6883. }
  6884. function hisImplement() {
  6885. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6886. if (empty ( $item ))
  6887. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6888. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6889. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6890. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6891. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6892. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6893. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6894. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6895. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6896. Doo::loadClass ( 'XDeode' );
  6897. $XDeode = new XDeode ( 5 );
  6898. Doo::loadModel ( 'receipt' );
  6899. $receipt = new receipt ();
  6900. Doo::loadModel ( 'L_category' );
  6901. $Lcategory = new L_category ();
  6902. Doo::loadModel ( 'verify' );
  6903. Doo::loadModel ( 'statistics' );
  6904. $statistics = new statistics ();
  6905. $verify = new verify ();
  6906. Doo::loadModel ( 'staff' );
  6907. $staff = new staff ();
  6908. Doo::loadClass ( 'XDeode' );
  6909. $XDeode = new XDeode ( 5 );
  6910. $XDeode7 = new XDeode ( 7 );
  6911. $cid = $XDeode->decode ( $cidKey );
  6912. $condition = "";
  6913. if ($item == "expenses")
  6914. $condition = " and Rtype=1 ";
  6915. elseif ($item == "receipts")
  6916. $condition = " and Rtype=0 ";
  6917. elseif ($item == "remits")
  6918. $condition = " and Rtype=2 ";
  6919. elseif($item == "train")
  6920. $condition = " and Rtype=3 ";
  6921. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6922. $sopString = $cidString = "";
  6923. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6924. if (empty ( $rdate ))
  6925. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6926. else
  6927. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6928. if ($status == 'pendImplement') {
  6929. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and (executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" or executeStaff is null ) ) ';
  6930. } elseif ($status == 'alerpts') {
  6931. $statusCon = '(status=8 or status=9 )';
  6932. if (empty ( $rdate )){
  6933. $dateCondition = " and Year(date) =" . $year;
  6934. }else{
  6935. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6936. }
  6937. }
  6938. if ($sop != 'SOP')
  6939. $sopString = " and staff=" . $sop;
  6940. if ($cidKey != 'ALL')
  6941. $cidString = " and cid=" . $cid;
  6942. //汇款信息需要提取出来
  6943. if(!empty($receiptOrder)){
  6944. $receiptList = $receipt->find ( array (
  6945. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6946. 'desc' => 'rid',
  6947. 'asArray' => true
  6948. ) );
  6949. // 员工筛选
  6950. $receiptList2 = $receipt->find ( array (
  6951. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6952. 'desc' => 'rid',
  6953. 'asArray' => true
  6954. ) );
  6955. }else{
  6956. $receiptList = $receipt->find ( array (
  6957. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6958. 'desc' => 'rid',
  6959. 'asArray' => true
  6960. ) );
  6961. // 员工筛选
  6962. $receiptList2 = $receipt->find ( array (
  6963. 'where' => $statusCon . $condition . $dateCondition,
  6964. 'desc' => 'rid',
  6965. 'asArray' => true
  6966. ) );
  6967. }
  6968. $sopStaff = array ();
  6969. foreach ( $receiptList2 as $key => $value ) {
  6970. $staffDetail = $staff->getOne ( array (
  6971. 'select' => 'username',
  6972. 'where' => 'sid=' . $value ['staff'],
  6973. 'asArray' => true
  6974. ) );
  6975. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6976. }
  6977. // 办事处筛选
  6978. $categoryScreen = array ();
  6979. $categorList = $Lcategory->getCategory ();
  6980. foreach ( $receiptList2 as $key => $value ) {
  6981. foreach ( $categorList as $k => $v ) {
  6982. if ($value ['cid'] == $v ['cid']) {
  6983. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6984. break;
  6985. }
  6986. }
  6987. }
  6988. $categoryScreenHtml = "";
  6989. foreach ( $categoryScreen as $key => $value ) {
  6990. if ($cidKey == $key)
  6991. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6992. else
  6993. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6994. }
  6995. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6996. $data ['cidKey'] = $cidKey;
  6997. $Locate = 0;
  6998. $roleId = 0;
  6999. $button = 0;
  7000. $staffBatchNumber = 100001;
  7001. $remittanceList = array ();
  7002. foreach ( $receiptList as $key => $value ) {
  7003. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  7004. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  7005. $receiptList [$key] ['Texe'] = 'false';
  7006. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  7007. $receiptList [$key] ['Texe'] = 'true';
  7008. }
  7009. $receiptList [$key] ['TRexe'] = 'true';
  7010. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  7011. $receiptList [$key] ['TRexe'] = 'false';
  7012. }
  7013. $receiptList [$key] ['Locate'] = $Locate;
  7014. $Locate ++;
  7015. $receiptList [$key] ['reviseDetail'] = array ();
  7016. if (! empty ( $value ['reviseDetail'] ))
  7017. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7018. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7019. $categoryDetil = $Lcategory->getOne ( array (
  7020. 'where' => 'cid=' . $value ['cid'],
  7021. 'asArray' => true
  7022. ) );
  7023. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7024. // 检测编辑状态
  7025. $verifyList = $verify->getOne ( array (
  7026. 'where' => 'vid=' . $value ['verify'],
  7027. 'asArray' => true
  7028. ) );
  7029. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7030. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7031. Doo::loadModel ( 'role' );
  7032. $role = new role ();
  7033. $flag = true;
  7034. $roleKey = 0;
  7035. $endStaffArray = array ();
  7036. $roleArrayCopy = array ();
  7037. foreach ( $verifyList as $k => $v ) {
  7038. // init verifyStaff
  7039. if ($v [1] == 'ROLE') {
  7040. if (! empty ( $verifyStaff )) {
  7041. $endStaffArray = end ( $verifyStaff );
  7042. }
  7043. $roleVerify = json_decode ( $v [3], true );
  7044. $roleKey = $k;
  7045. $roleArray = array ();
  7046. $rolename = $role->getOne ( array (
  7047. 'where' => 'rid=' . $v [0],
  7048. 'asArray' => true
  7049. ) );
  7050. foreach ( $roleVerify as $o => $p ) {
  7051. $staffID = explode ( '_', $p );
  7052. $staffInfo = $staff->getOne ( array (
  7053. 'where' => 'sid=' . $staffID [0],
  7054. 'asArray' => true
  7055. ) );
  7056. $exp = array (
  7057. 0 => $staffInfo ['sid'],
  7058. 1 => $staffID [1],
  7059. 2 => $staffInfo ['avatar'],
  7060. 'date' => '',
  7061. 'date' => '',
  7062. 'opinion' => '',
  7063. 'status' => '',
  7064. 'rolename' => $rolename ['name']
  7065. );
  7066. array_push ( $roleArray, $exp );
  7067. }
  7068. $roleArrayCopy [$v [0]] = $roleArray;
  7069. }
  7070. $verifyList [$k] ['date'] = "";
  7071. $verifyList [$k] ['opinion'] = "";
  7072. $verifyList [$k] ['status'] = "";
  7073. if (empty ( $verifyStaff )) {
  7074. $verifyList [$k] ['date'] = "";
  7075. $verifyList [$k] ['opinion'] = "";
  7076. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7077. $verifyList [$k] ['status'] = 4;
  7078. $flag = false;
  7079. }
  7080. } else {
  7081. foreach ( $verifyStaff as $m => $u ) {
  7082. if ($v [0] == $m) {
  7083. $verifyList [$k] ['date'] = $u ['date'];
  7084. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7085. $verifyList [$k] ['status'] = $u ['status'];
  7086. $flag = false;
  7087. break;
  7088. }
  7089. }
  7090. $endStaffArray = end ( $verifyStaff );
  7091. }
  7092. }
  7093. $rolename ['name'] = '';
  7094. if (! empty ( $roleId )) {
  7095. Doo::loadModel ( 'role' );
  7096. $role = new role ();
  7097. $rolename = $role->getOne ( array (
  7098. 'where' => 'rid=' . $roleId,
  7099. 'asArray' => true
  7100. ) );
  7101. }
  7102. if (! empty ( $verifyStaff ))
  7103. $endStaffArray = end ( $verifyStaff );
  7104. $KOP = false;
  7105. foreach ( $roleArrayCopy as $P => $A ) {
  7106. foreach ( $A as $MKI => $AVL ) {
  7107. if (! empty ( $verifyStaff )) {
  7108. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7109. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7110. $button = 4;
  7111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7112. }
  7113. foreach ( $verifyStaff as $m => $u ) {
  7114. $AVLFK = $AVL [0] . '_R';
  7115. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7116. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7117. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7118. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7119. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7120. break;
  7121. }
  7122. }
  7123. } else {
  7124. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7125. $button = 4;
  7126. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7127. }
  7128. }
  7129. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7130. $KOP = true;
  7131. }
  7132. }
  7133. foreach ( $roleArrayCopy as $k => $v ) {
  7134. foreach ( $verifyList as $m => $n ) {
  7135. if ($n [0] == $k) {
  7136. array_splice ( $verifyList, $m, 1, $v );
  7137. }
  7138. }
  7139. }
  7140. $receiptList [$key] ['verifyList'] = $verifyList;
  7141. $staffDetail = $staff->getOne ( array (
  7142. 'where' => 'sid=' . $value ['staff'],
  7143. 'asArray' => true
  7144. ) );
  7145. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7146. $receiptList [$key] ['button'] = $button;
  7147. if ($value['Rtype']==1){
  7148. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7149. $receiptList [$key] ['relustABS'] = sprintf("%.2f",abs($receiptList [$key] ['relust']));
  7150. }elseif($value['Rtype']==3){
  7151. // 收入合计
  7152. Doo::loadModel ( 'invoiceTraining' );
  7153. $invoiceTraining = new invoiceTraining ();
  7154. $invoiceTrainingDetail = array (
  7155. 'invoiceArriveAmount' => '0.00',
  7156. 'RIAmount' => '0.00',
  7157. 'invoiceTotalAmount' => '0.00',
  7158. 'invoiceCompanyAmount' => '0.00',
  7159. 'invoiceArriveAmountM'=>'0.00',
  7160. 'invoiceCompanyAmountM'=>'0.00'
  7161. );
  7162. if ($value ['invoiceTrainId'] != 0) {
  7163. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7164. }
  7165. $invoiceArriveAmount = $RIAmount = 0;
  7166. if (! empty ( $invoiceTrainingDetail )) {
  7167. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7168. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7169. }
  7170. // 备用金
  7171. $sum = 0;
  7172. if (! empty ( $value ['trainLoanRid'] )) {
  7173. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7174. foreach ($receiptLoanList as $kll=>$vll){
  7175. $sum+=$vll['sum'];
  7176. }
  7177. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7178. // $sum = $receiptLoanDetailBak ['sum'];
  7179. }
  7180. // 支出项金额详情
  7181. // 项目金额合计
  7182. Doo::loadModel ( 'RItem' );
  7183. $RItem = new RItem ();
  7184. Doo::loadModel ( 'accountItem' );
  7185. $accountItem = new accountItem ();
  7186. // 讲师获得
  7187. Doo::loadModel ( 'RILecturer' );
  7188. $RILecturer = new RILecturer ();
  7189. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7190. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7191. // 支出项金额详情
  7192. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7193. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7194. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7195. $receiptList [$key] ['payment'] =$payment;
  7196. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7197. }
  7198. // 设置导出汇款execl
  7199. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7200. $remittanceDetail = array (
  7201. $staffBatchNumber,
  7202. $value ['remittanceName'],
  7203. $value ['bankNumber'],
  7204. $value ['bankName'],
  7205. $value ['remittanceBankType'],
  7206. $value ['coupletNumber'],
  7207. $value ['sum']
  7208. );
  7209. array_push ( $remittanceList, $remittanceDetail );
  7210. $staffBatchNumber ++;
  7211. }
  7212. }
  7213. $data ['remittanceList'] = json_encode ( $remittanceList );
  7214. // print_r($receiptList);
  7215. $mothHtml = "";
  7216. for($i = 1; $i <= 12; $i ++) {
  7217. if ($moth == $i)
  7218. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7219. else
  7220. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7221. }
  7222. $dayHtml = "";
  7223. if ($day != "DAY" || $moth != "MONTH") {
  7224. for($i = 1; $i <= 31; $i ++) {
  7225. if ($day == $i)
  7226. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7227. else
  7228. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7229. }
  7230. }
  7231. $sopHtml = "";
  7232. foreach ( $sopStaff as $key => $value ) {
  7233. if ($sop == $key)
  7234. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7235. else
  7236. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7237. }
  7238. $data ['status'] = $status;
  7239. $data ['rdate'] = $rdate;
  7240. $data ['sopHtml'] = $sopHtml;
  7241. $data ['dayHtml'] = $dayHtml;
  7242. $data ['mothHtml'] = $mothHtml;
  7243. $data ['receiptList'] = $receiptList;
  7244. $data ['memu'] = "receipt";
  7245. $data ['staff'] = $this->staff;
  7246. $data ['receiptMemu'] = 'implement';
  7247. $data ['verifyId'] = $this->verifyId;
  7248. $data ['executeId'] = $this->executeId;
  7249. $data ['item'] = $item;
  7250. $data ['year'] = $year;
  7251. $data ['moth'] = $moth;
  7252. $data['receiptOrder']=$receiptOrder;
  7253. $data ['day'] = $day;
  7254. $data ['sop'] = $sop;
  7255. $this->render ( "/admin/hisImplement", $data );
  7256. }
  7257. /**
  7258. * 导出汇款信息的exelc
  7259. */
  7260. function exportRemittance() {
  7261. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7262. if (empty ( $remittanceInfo ))
  7263. die ( 'illegal request' );
  7264. $title = array (
  7265. '员工编号',
  7266. '姓名',
  7267. '员工账号',
  7268. '员工账户开户行',
  7269. '转账类型',
  7270. '联行号',
  7271. '金额'
  7272. );
  7273. $data = json_decode ( $remittanceInfo, true );
  7274. if (empty ( $data ))
  7275. die ( 'illegal request' );
  7276. Doo::loadClass ( 'receipt.func' );
  7277. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7278. header ( 'Content-Type:text/html;charset=utf-8' );
  7279. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7280. }
  7281. function ajaxExamine() {
  7282. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7283. Doo::loadModel ( 'receipt' );
  7284. $receipt = new receipt ();
  7285. if (! empty ( $rid )) {
  7286. $rLRes = $receipt->find ( array (
  7287. '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,
  7288. 'asArray' => true
  7289. ) );
  7290. if(!empty($rLRes)){
  7291. Doo::loadClass ( 'XDeode' );
  7292. $XDeode = new XDeode ( 7 );
  7293. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7294. echo json_encode ( array (
  7295. 'status' => 1,
  7296. 'receipt' => $rLRes [0]
  7297. ) );
  7298. die ();
  7299. }else{
  7300. echo json_encode ( array (
  7301. 'status' => 1,
  7302. 'receipt' => array ()
  7303. ) );
  7304. die ();
  7305. }
  7306. }
  7307. echo json_encode ( array (
  7308. 'status' => 0,
  7309. 'receipt' => array ()
  7310. ) );
  7311. die ();
  7312. }
  7313. /*
  7314. * 废弃
  7315. */
  7316. function myReceipt() {
  7317. // all approval past withdraw
  7318. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7319. if (empty ( $item ))
  7320. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7321. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7322. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7323. Doo::loadModel ( 'receipt' );
  7324. $receipt = new receipt ();
  7325. // pre-loaded
  7326. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7327. // have cache
  7328. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7329. if (! empty ( $moth )) // yearPage
  7330. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7331. $this->showCache ( $path );
  7332. }
  7333. Doo::loadModel ( 'L_category' );
  7334. $Lcategory = new L_category ();
  7335. Doo::loadModel ( 'verify' );
  7336. Doo::loadModel ( 'statistics' );
  7337. $statistics = new statistics ();
  7338. $verify = new verify ();
  7339. Doo::loadModel ( 'staff' );
  7340. $staff = new staff ();
  7341. $condition = " and status!=0 ";
  7342. if ($item == "approval")
  7343. $condition = " and status=2 ";
  7344. elseif ($item == "withdraw")
  7345. $condition = " and status=3 ";
  7346. elseif ($item == "past")
  7347. $condition = " and status=1 ";
  7348. elseif ($item == "whdw")
  7349. $condition = " and status=4 ";
  7350. $dateCondition = " and Year(date) =" . $year;
  7351. if (! empty ( $moth )) {
  7352. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7353. $stList = $statistics->getOne ( array (
  7354. 'select' => 'rePrice ,agPrice',
  7355. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7356. 'asArray' => true
  7357. ) );
  7358. } else
  7359. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7360. if (empty ( $stList ))
  7361. $stList = array (
  7362. 'rePrice' => 0,
  7363. 'agPrice' => 0
  7364. );
  7365. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7366. $data ['stList'] = array (
  7367. 'rePrice' => $stList ['rePrice'],
  7368. 'agPrice' => $stList ['agPrice'],
  7369. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7370. );
  7371. $receiptList = $receipt->find ( array (
  7372. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7373. 'desc' => 'rid',
  7374. 'asArray' => true
  7375. ) );
  7376. $Locate = 0;
  7377. $roleId = 0;
  7378. $button = 0;
  7379. foreach ( $receiptList as $key => $value ) {
  7380. $receiptList [$key] ['Locate'] = $Locate;
  7381. $Locate ++;
  7382. $receiptList [$key] ['reviseDetail'] = array ();
  7383. if (! empty ( $value ['reviseDetail'] ))
  7384. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7385. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7386. $categoryDetil = $Lcategory->getOne ( array (
  7387. 'where' => 'cid=' . $value ['cid'],
  7388. 'asArray' => true
  7389. ) );
  7390. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7391. // 检测编辑状态
  7392. $verifyList = $verify->getOne ( array (
  7393. 'where' => 'vid=' . $value ['verify'],
  7394. 'asArray' => true
  7395. ) );
  7396. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7397. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7398. Doo::loadModel ( 'role' );
  7399. $role = new role ();
  7400. $flag = true;
  7401. $roleKey = 0;
  7402. $endStaffArray = array ();
  7403. $roleArrayCopy = array ();
  7404. foreach ( $verifyList as $k => $v ) {
  7405. // init verifyStaff
  7406. if ($v [1] == 'ROLE') {
  7407. if (! empty ( $verifyStaff )) {
  7408. $endStaffArray = end ( $verifyStaff );
  7409. // if ($v[0]==$endStaffArray['nextStaff']){
  7410. // $roleId=$v[0];
  7411. // }
  7412. }
  7413. $roleVerify = json_decode ( $v [3], true );
  7414. $roleKey = $k;
  7415. $roleArray = array ();
  7416. $rolename = $role->getOne ( array (
  7417. 'where' => 'rid=' . $v [0],
  7418. 'asArray' => true
  7419. ) );
  7420. foreach ( $roleVerify as $o => $p ) {
  7421. $staffID = explode ( '_', $p );
  7422. $staffInfo = $staff->getOne ( array (
  7423. 'where' => 'sid=' . $staffID [0],
  7424. 'asArray' => true
  7425. ) );
  7426. // print_r($staffID);
  7427. $exp = array (
  7428. 0 => $staffInfo ['sid'],
  7429. 1 => $staffID [1],
  7430. 2 => $staffInfo ['avatar'],
  7431. 'date' => '',
  7432. 'date' => '',
  7433. 'opinion' => '',
  7434. 'status' => '',
  7435. 'rolename' => $rolename ['name']
  7436. );
  7437. array_push ( $roleArray, $exp );
  7438. }
  7439. $roleArrayCopy [$v [0]] = $roleArray;
  7440. // $verifyList[$k]['roleArray']=$roleArray;
  7441. }
  7442. $verifyList [$k] ['date'] = "";
  7443. $verifyList [$k] ['opinion'] = "";
  7444. $verifyList [$k] ['status'] = "";
  7445. if (empty ( $verifyStaff )) {
  7446. $verifyList [$k] ['date'] = "";
  7447. $verifyList [$k] ['opinion'] = "";
  7448. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7449. $verifyList [$k] ['status'] = 4;
  7450. $flag = false;
  7451. }
  7452. } else {
  7453. foreach ( $verifyStaff as $m => $u ) {
  7454. if ($v [0] == $m) {
  7455. $verifyList [$k] ['date'] = $u ['date'];
  7456. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7457. $verifyList [$k] ['status'] = $u ['status'];
  7458. $flag = false;
  7459. break;
  7460. }
  7461. }
  7462. $endStaffArray = end ( $verifyStaff );
  7463. if (isset ( $endStaffArray ['ROLE'] )) {
  7464. } else {
  7465. // $endKey=key($verifyStaff);
  7466. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7467. // $button=4;
  7468. // $verifyList[$k]['status']=4;
  7469. // }
  7470. }
  7471. }
  7472. }
  7473. $rolename ['name'] = '';
  7474. if (! empty ( $roleId )) {
  7475. Doo::loadModel ( 'role' );
  7476. $role = new role ();
  7477. $rolename = $role->getOne ( array (
  7478. 'where' => 'rid=' . $roleId,
  7479. 'asArray' => true
  7480. ) );
  7481. }
  7482. if (! empty ( $verifyStaff ))
  7483. $endStaffArray = end ( $verifyStaff );
  7484. $KOP = false;
  7485. foreach ( $roleArrayCopy as $P => $A ) {
  7486. foreach ( $A as $MKI => $AVL ) {
  7487. if (! empty ( $verifyStaff )) {
  7488. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7489. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7490. $button = 4;
  7491. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7492. }
  7493. foreach ( $verifyStaff as $m => $u ) {
  7494. $AVLFK = $AVL [0] . '_R';
  7495. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7496. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7497. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7498. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7499. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7500. break;
  7501. }
  7502. }
  7503. } else {
  7504. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7505. $button = 4;
  7506. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7507. }
  7508. }
  7509. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7510. $KOP = true;
  7511. }
  7512. }
  7513. foreach ( $roleArrayCopy as $k => $v ) {
  7514. foreach ( $verifyList as $m => $n ) {
  7515. if ($n [0] == $k) {
  7516. array_splice ( $verifyList, $m, 1, $v );
  7517. }
  7518. }
  7519. }
  7520. $receiptList [$key] ['verifyList'] = $verifyList;
  7521. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7522. 'where' => 'sid=' . $value ['staff'],
  7523. 'asArray' => true
  7524. ) );
  7525. $receiptList [$key] ['button'] = $button;
  7526. }
  7527. // print_r($receiptList);die;
  7528. $mothHtml = "";
  7529. for($i = 1; $i <= 12; $i ++) {
  7530. if ($moth == $i)
  7531. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7532. else
  7533. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7534. }
  7535. $data ['mothHtml'] = $mothHtml;
  7536. $data ['receiptList'] = $receiptList;
  7537. $data ['memu'] = "receipt";
  7538. $data ['staff'] = $this->staff;
  7539. $data ['receiptMemu'] = 'receipt';
  7540. $data ['verifyId'] = $this->verifyId;
  7541. $data ['executeId'] = $this->executeId;
  7542. $data ['item'] = $item;
  7543. $data ['year'] = $year;
  7544. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7545. // sufficient condition to generate cache
  7546. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7547. $receiptList = $receipt->find ( array (
  7548. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7549. 'asArray' => true
  7550. ) );
  7551. if (empty ( $receiptList )) { // generated files
  7552. ob_start ();
  7553. $this->render ( "/admin/saea_myList", $data );
  7554. $this->cacheFile ( $path );
  7555. die ();
  7556. // $content = ob_get_contents();
  7557. // $fp = fopen($path, "w");
  7558. // fwrite($fp, $content);
  7559. // fclose($fp);
  7560. }
  7561. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7562. $receiptList = $receipt->find ( array (
  7563. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7564. 'asArray' => true
  7565. ) );
  7566. if (empty ( $receiptList )) { // generated files
  7567. ob_start ();
  7568. $this->render ( "/admin/saea_myList", $data );
  7569. $this->cacheFile ( $path );
  7570. die ();
  7571. }
  7572. }
  7573. }
  7574. $this->render ( "/admin/saea_myList", $data );
  7575. }
  7576. function approvedReceipt() {
  7577. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7578. Doo::loadModel ( 'receipt' );
  7579. Doo::loadModel ( 'receiptDetail' );
  7580. $receipt = new receipt ();
  7581. $receiptDetail = new receiptDetail ();
  7582. Doo::loadModel ( 'statistics' );
  7583. Doo::loadModel ( 'itemStatistics' );
  7584. $statistics = new statistics ();
  7585. $itemStatistics = new itemStatistics ();
  7586. Doo::loadModel ( "verify" );
  7587. $verify = new verify ();
  7588. // 审批状态的判定
  7589. $receiptDetailList = $receipt->getOne ( array (
  7590. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7591. 'asArray' => true
  7592. ) );
  7593. if (empty ( $receiptDetailList ))
  7594. return "/saeaBorad";
  7595. $verifyDetail = $verify->getOne ( array (
  7596. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7597. 'asArray' => true
  7598. ) );
  7599. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7600. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7601. $nowStaff = "";
  7602. $nowStaffList = array ();
  7603. if ($verifyDetail [0] [1] == 'ROLE') {
  7604. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7605. foreach ( $vStaffString as $key => $value ) {
  7606. $staffK = explode ( "_", $value );
  7607. array_push ( $nowStaffList, $staffK [0] );
  7608. }
  7609. $nowStaff = implode ( ',', $nowStaffList );
  7610. } else {
  7611. $nowStaff = $verifyDetail [0] [0];
  7612. }
  7613. $receipt->nowStaff = $nowStaff;
  7614. }
  7615. // echo $nowStaff;
  7616. // print_r($verifyDetail);die;
  7617. $receipt->rid = $receiptDetailList ['rid'];
  7618. $receipt->date = date ( "Y-m-d" );
  7619. $receipt->status = 2;
  7620. $receipt->update ();
  7621. $receiptDetail->status = 2;
  7622. $receiptDetail->update ( array (
  7623. 'where' => 'rid=' . $receiptDetailList ['rid']
  7624. ) );
  7625. Doo::loadModel ( "receiptLog" );
  7626. $receiptLog = new receiptLog ();
  7627. Doo::loadModel ( "verify" );
  7628. $verify = new verify ();
  7629. $receiptInfo = $receipt->getOne ( array (
  7630. 'where' => 'rid=' . $rid,
  7631. 'asArray' => true
  7632. ) );
  7633. $vr = $verify->getOne ( array (
  7634. 'where' => 'vid=' . $receiptInfo ['verify'],
  7635. 'asArray' => true
  7636. ) );
  7637. $jd = json_decode ( $vr ['staff'] );
  7638. $roleId = 0;
  7639. foreach ( $jd as $key => $value ) {
  7640. if ($value [1] == 'ROLE') {
  7641. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7642. if ($pos !== false) {
  7643. $roleId = $value [0];
  7644. }
  7645. }
  7646. }
  7647. // 审批日志
  7648. // echo $roleId;die;
  7649. if (! empty ( $roleId )) {
  7650. Doo::loadModel ( "role" );
  7651. $role = new role ();
  7652. $roleInfo = $role->getOne ( array (
  7653. 'where' => 'rid=' . $roleId,
  7654. 'asArray' => true
  7655. ) );
  7656. // $receiptLog->rolename = $roleInfo ['name'];
  7657. }
  7658. $receiptLog->username = $this->staff [0] ['username'];
  7659. $receiptLog->uid = $this->staff [0] ['sid'];
  7660. $receiptLog->date = date ( "Y-m-d" );
  7661. $receiptLog->opinion = '提交审批';
  7662. $receiptLog->img = $this->staff [0] ['avatar'];
  7663. $receiptLog->status = 2;
  7664. $receiptLog->rid = $rid;
  7665. $receiptLog->insert ();
  7666. // statistics item
  7667. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7668. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7669. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7670. $stat = $statistics->getOne ( array (
  7671. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7672. 'asArray' => true
  7673. ) );
  7674. if (empty ( $stat )) {
  7675. $statistics->date = date ( "Y-m-d" );
  7676. $statistics->cid = $this->staff [0] ['cid'];
  7677. $statistics->staff = $this->staff [0] ['sid'];
  7678. $statistics->agPrice = 0;
  7679. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7680. $statistics->insert ();
  7681. } else {
  7682. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7683. $statistics->update ( array (
  7684. 'where' => 'sid=' . $stat ['sid']
  7685. ) );
  7686. }
  7687. return "/expenses";
  7688. }
  7689. function approval() {
  7690. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7691. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7692. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7693. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7694. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7695. if (empty ( $status ))
  7696. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7697. $vidList = array ();
  7698. $button = 0;
  7699. Doo::loadModel ( 'verify' );
  7700. $verify = new verify ();
  7701. Doo::loadModel ( 'receipt' );
  7702. $receipt = new receipt ();
  7703. Doo::loadModel ( 'staff' );
  7704. $staff = new staff ();
  7705. Doo::loadModel ( 'L_category' );
  7706. $Lcategory = new L_category ();
  7707. // user verify ID
  7708. $verifyDetail = $verify->find ( array (
  7709. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7710. 'asArray' => true
  7711. ) );
  7712. foreach ( $verifyDetail as $key => $value ) {
  7713. array_push ( $vidList, $value ['vid'] );
  7714. }
  7715. $vid = implode ( ",", $vidList );
  7716. if (empty ( $verifyDetail ))
  7717. $vid = 0;
  7718. /*
  7719. */
  7720. $dateCondition = " and Year(date) =" . $year;
  7721. if (! empty ( $month ))
  7722. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7723. $categoryList = $Lcategory->find ( array (
  7724. 'asArray' => true
  7725. ) );
  7726. $staffList = $staff->find ( array (
  7727. 'where' => 'cid=' . $cid,
  7728. 'asArray' => true
  7729. ) );
  7730. $cateCondition = "";
  7731. $staffCondition = "";
  7732. $approvalCondition = "";
  7733. if (! empty ( $cid ))
  7734. $cateCondition = ' and cid=' . $cid;
  7735. if (! empty ( $sid )) {
  7736. $staffCondition = ' and staff=' . $sid;
  7737. $cateCondition = "";
  7738. }
  7739. // elseif($status==1){
  7740. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7741. // }
  7742. if ($status == 2) {
  7743. // 查找角色审批人
  7744. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7745. }
  7746. $ap = "";
  7747. if ($status == 4) {
  7748. $ap = 4;
  7749. $status = 2;
  7750. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7751. }
  7752. if ($status == 5) {
  7753. $status = 4;
  7754. $ap = 5;
  7755. }
  7756. // echo $vid;
  7757. // get Receipt By verifyID status 2 .$approvalCondition
  7758. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7759. $receiptList = $receipt->find ( array (
  7760. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7761. 'desc' => 'rid',
  7762. 'asArray' => true
  7763. ) );
  7764. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7765. $Locate = 0;
  7766. if ($ap == 4)
  7767. $status = 4;
  7768. elseif ($ap == 5)
  7769. $status = 5;
  7770. foreach ( $receiptList as $key => $value ) {
  7771. $receiptList [$key] ['Locate'] = $Locate;
  7772. $Locate ++;
  7773. $receiptList [$key] ['reviseDetail'] = array ();
  7774. if (! empty ( $value ['reviseDetail'] ))
  7775. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7776. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7777. $categoryDetil = $Lcategory->getOne ( array (
  7778. 'where' => 'cid=' . $value ['cid'],
  7779. 'asArray' => true
  7780. ) );
  7781. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7782. $verifyList = $verify->getOne ( array (
  7783. 'where' => 'vid=' . $value ['verify'],
  7784. 'asArray' => true
  7785. ) );
  7786. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7787. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7788. foreach ( $verifyList as $k => $v ) {
  7789. // init verifyStaff
  7790. $verifyList [$k] ['date'] = "";
  7791. $verifyList [$k] ['opinion'] = "";
  7792. $verifyList [$k] ['status'] = "";
  7793. if (empty ( $verifyStaff )) {
  7794. $verifyList [$k] ['date'] = "";
  7795. $verifyList [$k] ['opinion'] = "";
  7796. if ($v [0] == $this->staff [0] ['sid']) {
  7797. $verifyList [$k] ['status'] = 4;
  7798. $button = 4;
  7799. }
  7800. } else {
  7801. $flag = true;
  7802. foreach ( $verifyStaff as $m => $u ) {
  7803. if ($v [0] == $m) {
  7804. $verifyList [$k] ['date'] = $u ['date'];
  7805. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7806. $verifyList [$k] ['status'] = $u ['status'];
  7807. $flag = false;
  7808. break;
  7809. }
  7810. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7811. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7812. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7813. }
  7814. if ($flag) { // 检测可编辑
  7815. if ($v [0] == $this->staff [0] ['sid']) {
  7816. $verifyList [$k] ['status'] = 4;
  7817. $button = 4;
  7818. }
  7819. }
  7820. }
  7821. }
  7822. $receiptList [$key] ['verifyList'] = $verifyList;
  7823. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7824. 'where' => 'sid=' . $value ['staff'],
  7825. 'asArray' => true
  7826. ) );
  7827. $receiptList [$key] ['button'] = $button;
  7828. }
  7829. // print_r($receiptList);die;
  7830. // $data['verifyDetail']=$verifyDetail;
  7831. $mothHtml = "";
  7832. for($i = 1; $i <= 12; $i ++) {
  7833. if ($month == $i)
  7834. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7835. else
  7836. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7837. }
  7838. $data ['mothHtml'] = $mothHtml;
  7839. $data ['receiptList'] = $receiptList;
  7840. $data ['receiptApprovalCount'] = count ( $receiptList );
  7841. $data ['status'] = $status;
  7842. $data ['year'] = $year;
  7843. $data ['categoryList'] = $categoryList;
  7844. $data ['staffList'] = $staffList;
  7845. $data ['cid'] = $cid;
  7846. $data ['sid'] = $sid;
  7847. $data ['ap'] = $ap;
  7848. $data ['memu'] = "receipt";
  7849. $data ['staff'] = $this->staff;
  7850. $data ['receiptMemu'] = 'approval';
  7851. $data ['verifyId'] = $this->verifyId;
  7852. $data ['executeId'] = $this->executeId;
  7853. $this->render ( "/admin/saea_reportList", $data );
  7854. }
  7855. function approvalDetails() {
  7856. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7857. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7858. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7859. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7860. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7861. Doo::loadModel ( 'verify' );
  7862. $verify = new verify ();
  7863. Doo::loadModel ( 'receipt' );
  7864. $receipt = new receipt ();
  7865. Doo::loadModel ( 'staff' );
  7866. $staff = new staff ();
  7867. Doo::loadModel ( 'L_category' );
  7868. $Lcategory = new L_category ();
  7869. Doo::loadModel ( 'enclosur' );
  7870. $enclosur = new enclosur ();
  7871. $vidList = array ();
  7872. $verifyDetail = $verify->find ( array (
  7873. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7874. 'asArray' => true
  7875. ) );
  7876. foreach ( $verifyDetail as $key => $value ) {
  7877. array_push ( $vidList, $value ['vid'] );
  7878. }
  7879. $vid = implode ( ",", $vidList );
  7880. if (empty ( $verifyDetail ))
  7881. $vid = 0;
  7882. $categoryList = $Lcategory->find ( array (
  7883. 'asArray' => true
  7884. ) );
  7885. $staffList = $staff->find ( array (
  7886. 'where' => 'cid=' . $cid,
  7887. 'asArray' => true
  7888. ) );
  7889. $ap = 0;
  7890. $receiptList = $receipt->find ( array (
  7891. 'where' => 'rid =' . $rid,
  7892. 'desc' => 'rid',
  7893. 'asArray' => true
  7894. ) );
  7895. $Locate = 0;
  7896. $roleId = 0;
  7897. $button = 0;
  7898. foreach ( $receiptList as $key => $value ) {
  7899. $receiptList [$key] ['Locate'] = $Locate;
  7900. $Locate ++;
  7901. $receiptList [$key] ['reviseDetail'] = array ();
  7902. if (! empty ( $value ['reviseDetail'] ))
  7903. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7904. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7905. $categoryDetil = $Lcategory->getOne ( array (
  7906. 'where' => 'cid=' . $value ['cid'],
  7907. 'asArray' => true
  7908. ) );
  7909. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7910. // 检测编辑状态
  7911. $verifyList = $verify->getOne ( array (
  7912. 'where' => 'vid=' . $value ['verify'],
  7913. 'asArray' => true
  7914. ) );
  7915. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7916. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7917. Doo::loadModel ( 'role' );
  7918. $role = new role ();
  7919. // print_r($verifyList);
  7920. $flag = true;
  7921. $roleKey = 0;
  7922. $endStaffArray = array ();
  7923. $roleArrayCopy = array ();
  7924. foreach ( $verifyList as $k => $v ) {
  7925. // init verifyStaff
  7926. if ($v [1] == 'ROLE') {
  7927. if (! empty ( $verifyStaff )) {
  7928. $endStaffArray = end ( $verifyStaff );
  7929. if ($v [0] == $endStaffArray ['nextStaff']) {
  7930. $roleId = $v [0];
  7931. }
  7932. }
  7933. $roleVerify = json_decode ( $v [3], true );
  7934. $roleKey = $k;
  7935. $roleArray = array ();
  7936. $rolename = $role->getOne ( array (
  7937. 'where' => 'rid=' . $v [0],
  7938. 'asArray' => true
  7939. ) );
  7940. foreach ( $roleVerify as $o => $p ) {
  7941. $staffID = explode ( '_', $p );
  7942. $staffInfo = $staff->getOne ( array (
  7943. 'where' => 'sid=' . $staffID [0],
  7944. 'asArray' => true
  7945. ) );
  7946. // print_r($staffID);
  7947. $exp = array (
  7948. 0 => $staffInfo ['sid'],
  7949. 1 => $staffID [1],
  7950. 2 => $staffInfo ['avatar'],
  7951. 'date' => '',
  7952. 'date' => '',
  7953. 'opinion' => '',
  7954. 'status' => '',
  7955. 'rolename' => $rolename ['name']
  7956. );
  7957. array_push ( $roleArray, $exp );
  7958. }
  7959. $roleArrayCopy [$v [0]] = $roleArray;
  7960. // $verifyList[$k]['roleArray']=$roleArray;
  7961. }
  7962. // print_r($roleArray);
  7963. $verifyList [$k] ['date'] = "";
  7964. $verifyList [$k] ['opinion'] = "";
  7965. $verifyList [$k] ['status'] = "";
  7966. if (empty ( $verifyStaff )) {
  7967. $verifyList [$k] ['date'] = "";
  7968. $verifyList [$k] ['opinion'] = "";
  7969. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7970. $verifyList [$k] ['status'] = 4;
  7971. $button = 4;
  7972. $flag = false;
  7973. }
  7974. } else {
  7975. foreach ( $verifyStaff as $m => $u ) {
  7976. if ($v [0] == $m) {
  7977. $verifyList [$k] ['date'] = $u ['date'];
  7978. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7979. $verifyList [$k] ['status'] = $u ['status'];
  7980. $flag = false;
  7981. break;
  7982. }
  7983. }
  7984. $endStaffArray = end ( $verifyStaff );
  7985. if (isset ( $endStaffArray ['ROLE'] )) {
  7986. } else {
  7987. $endKey = key ( $verifyStaff );
  7988. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7989. $button = 4;
  7990. $verifyList [$k] ['status'] = 4;
  7991. }
  7992. }
  7993. }
  7994. }
  7995. $rolename ['name'] = '';
  7996. if (! empty ( $roleId )) {
  7997. Doo::loadModel ( 'role' );
  7998. $role = new role ();
  7999. $rolename = $role->getOne ( array (
  8000. 'where' => 'rid=' . $roleId,
  8001. 'asArray' => true
  8002. ) );
  8003. }
  8004. if (! empty ( $verifyStaff ))
  8005. $endStaffArray = end ( $verifyStaff );
  8006. $KOP = false;
  8007. foreach ( $roleArrayCopy as $P => $A ) {
  8008. foreach ( $A as $MKI => $AVL ) {
  8009. if (! empty ( $verifyStaff )) {
  8010. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8011. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8012. $button = 4;
  8013. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8014. }
  8015. foreach ( $verifyStaff as $m => $u ) {
  8016. $AVLFK = $AVL [0] . '_R';
  8017. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8018. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8019. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8020. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8021. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8022. break;
  8023. }
  8024. }
  8025. } else {
  8026. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8027. $button = 4;
  8028. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8029. }
  8030. }
  8031. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8032. $KOP = true;
  8033. }
  8034. }
  8035. foreach ( $roleArrayCopy as $k => $v ) {
  8036. foreach ( $verifyList as $m => $n ) {
  8037. if ($n [0] == $k) {
  8038. array_splice ( $verifyList, $m, 1, $v );
  8039. }
  8040. }
  8041. }
  8042. $receiptList [$key] ['verifyList'] = $verifyList;
  8043. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8044. 'where' => 'sid=' . $value ['staff'],
  8045. 'asArray' => true
  8046. ) );
  8047. $receiptList [$key] ['button'] = $button;
  8048. }
  8049. $mothHtml = "";
  8050. for($i = 1; $i <= 12; $i ++) {
  8051. if ($month == $i)
  8052. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8053. else
  8054. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8055. }
  8056. // 获取审批日志
  8057. Doo::loadModel ( 'receiptLog' );
  8058. $receiptLog = new receiptLog ();
  8059. $rlList = array ();
  8060. $rlInfo = $receiptLog->getOne ( array (
  8061. 'where' => 'rid=' . $rid . ' and status=4',
  8062. 'asArray' => true
  8063. ) );
  8064. $tijdate = $receiptLog->getOne ( array (
  8065. 'where' => 'rid=' . $rid . ' and status=2',
  8066. 'asc' => 'rlid',
  8067. 'asArray' => true
  8068. ) );
  8069. if (! empty ( $rlInfo )) {
  8070. $rlList = $receiptLog->find ( array (
  8071. 'where' => 'rid=' . $rid,
  8072. 'asc' => 'rlid',
  8073. 'asArray' => true
  8074. ) );
  8075. }
  8076. $receiptList [0] ['rlList'] = $rlList;
  8077. $enclosurList = $enclosur->find ( array (
  8078. 'where' => 'rid=' . $rid,
  8079. 'asArray' => true
  8080. ) );
  8081. $enclosurHtml = '';
  8082. foreach ( $enclosurList as $value ) {
  8083. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8084. }
  8085. $data ['enclosurHtml'] = $enclosurHtml;
  8086. $data ['rolename'] = $rolename ['name'];
  8087. $data ['datetij'] = $tijdate ['date'];
  8088. $data ['mothHtml'] = $mothHtml;
  8089. $data ['receiptList'] = $receiptList;
  8090. $data ['receiptApprovalCount'] = count ( $receiptList );
  8091. $data ['year'] = $year;
  8092. $data ['categoryList'] = $categoryList;
  8093. $data ['staffList'] = $staffList;
  8094. $data ['cid'] = $cid;
  8095. $data ['sid'] = $sid;
  8096. $data ['status'] = 0;
  8097. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8098. $ap = 4;
  8099. } else
  8100. $data ['status'] = $receiptList [0] ['status'];
  8101. if ($receiptList [0] ['status'] == 4) {
  8102. $data ['status'] = 5;
  8103. $ap = 0;
  8104. }
  8105. $data ['ap'] = $ap;
  8106. $data ['memu'] = "receipt";
  8107. $data ['staff'] = $this->staff;
  8108. $data ['receiptMemu'] = 'approval';
  8109. $data ['verifyId'] = $this->verifyId;
  8110. $data ['executeId'] = $this->executeId;
  8111. $this->render ( "/admin/saeaReportListReport", $data );
  8112. }
  8113. function approvalEdi() {
  8114. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8115. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8116. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8117. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8118. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8119. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8120. if (empty ( $status ))
  8121. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8122. $vidList = array ();
  8123. $button = 0;
  8124. Doo::loadModel ( 'verify' );
  8125. Doo::loadModel ( 'receipt' );
  8126. Doo::loadModel ( 'staff' );
  8127. $staff = new staff ();
  8128. $receipt = new receipt ();
  8129. $verify = new verify ();
  8130. Doo::loadModel ( 'L_category' );
  8131. $Lcategory = new L_category ();
  8132. Doo::loadModel ( 'enclosur' );
  8133. $enclosur = new enclosur ();
  8134. // user verify ID
  8135. $verifyDetail = $verify->find ( array (
  8136. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8137. 'asArray' => true
  8138. ) );
  8139. foreach ( $verifyDetail as $key => $value ) {
  8140. array_push ( $vidList, $value ['vid'] );
  8141. }
  8142. $vid = implode ( ",", $vidList );
  8143. if (empty ( $verifyDetail ))
  8144. $vid = 0;
  8145. $categoryList = $Lcategory->find ( array (
  8146. 'asArray' => true
  8147. ) );
  8148. $staffList = $staff->find ( array (
  8149. 'where' => 'cid=' . $cid,
  8150. 'asArray' => true
  8151. ) );
  8152. $ap = "";
  8153. if ($status == 4) {
  8154. $ap = 4;
  8155. $status = 2;
  8156. }
  8157. // get Receipt By verifyID status 2
  8158. $receiptList = $receipt->find ( array (
  8159. 'where' => 'rid =' . $rid,
  8160. 'desc' => 'rid',
  8161. 'asArray' => true
  8162. ) );
  8163. $Locate = 0;
  8164. $roleId = 0;
  8165. if ($ap == 4)
  8166. $status = 4;
  8167. foreach ( $receiptList as $key => $value ) {
  8168. $receiptList [$key] ['Locate'] = $Locate;
  8169. $Locate ++;
  8170. $receiptList [$key] ['reviseDetail'] = array ();
  8171. if (! empty ( $value ['reviseDetail'] ))
  8172. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8173. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8174. $categoryDetil = $Lcategory->getOne ( array (
  8175. 'where' => 'cid=' . $value ['cid'],
  8176. 'asArray' => true
  8177. ) );
  8178. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8179. // 检测编辑状态
  8180. $verifyList = $verify->getOne ( array (
  8181. 'where' => 'vid=' . $value ['verify'],
  8182. 'asArray' => true
  8183. ) );
  8184. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8185. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8186. // print_r($verifyList);
  8187. //
  8188. // if (empty($verifyStaff)){
  8189. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8190. // $verifyList[0]['status']=4;$button=4;
  8191. // }
  8192. //
  8193. // }else{
  8194. //
  8195. // }
  8196. // die;
  8197. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8198. // echo array_search("green",$a);
  8199. //
  8200. Doo::loadModel ( 'role' );
  8201. $role = new role ();
  8202. // print_r($verifyList);
  8203. $flag = true;
  8204. $roleKey = 0;
  8205. $endStaffArray = array ();
  8206. $roleArrayCopy = array ();
  8207. foreach ( $verifyList as $k => $v ) {
  8208. // init verifyStaff
  8209. if ($v [1] == 'ROLE') {
  8210. if (! empty ( $verifyStaff )) {
  8211. $endStaffArray = end ( $verifyStaff );
  8212. if ($v [0] == $endStaffArray ['nextStaff']) {
  8213. $roleId = $v [0];
  8214. }
  8215. }
  8216. $roleVerify = json_decode ( $v [3], true );
  8217. $roleKey = $k;
  8218. $roleArray = array ();
  8219. $rolename = $role->getOne ( array (
  8220. 'where' => 'rid=' . $v [0],
  8221. 'asArray' => true
  8222. ) );
  8223. foreach ( $roleVerify as $o => $p ) {
  8224. $staffID = explode ( '_', $p );
  8225. $staffInfo = $staff->getOne ( array (
  8226. 'where' => 'sid=' . $staffID [0],
  8227. 'asArray' => true
  8228. ) );
  8229. // print_r($staffID);
  8230. $exp = array (
  8231. 0 => $staffInfo ['sid'],
  8232. 1 => $staffID [1],
  8233. 2 => $staffInfo ['avatar'],
  8234. 'date' => '',
  8235. 'date' => '',
  8236. 'opinion' => '',
  8237. 'status' => '',
  8238. 'rolename' => $rolename ['name']
  8239. );
  8240. array_push ( $roleArray, $exp );
  8241. }
  8242. $roleArrayCopy [$v [0]] = $roleArray;
  8243. // $verifyList[$k]['roleArray']=$roleArray;
  8244. }
  8245. // print_r($roleArray);
  8246. $verifyList [$k] ['date'] = "";
  8247. $verifyList [$k] ['opinion'] = "";
  8248. $verifyList [$k] ['status'] = "";
  8249. if (empty ( $verifyStaff )) {
  8250. $verifyList [$k] ['date'] = "";
  8251. $verifyList [$k] ['opinion'] = "";
  8252. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8253. $verifyList [$k] ['status'] = 4;
  8254. $button = 4;
  8255. $flag = false;
  8256. }
  8257. } else {
  8258. foreach ( $verifyStaff as $m => $u ) {
  8259. if ($v [0] == $m) {
  8260. $verifyList [$k] ['date'] = $u ['date'];
  8261. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8262. $verifyList [$k] ['status'] = $u ['status'];
  8263. $flag = false;
  8264. break;
  8265. }
  8266. }
  8267. $endStaffArray = end ( $verifyStaff );
  8268. if (isset ( $endStaffArray ['ROLE'] )) {
  8269. } else {
  8270. $endKey = key ( $verifyStaff );
  8271. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8272. $button = 4;
  8273. $verifyList [$k] ['status'] = 4;
  8274. }
  8275. }
  8276. // print_r($endStaffArray);die;
  8277. // if (empty($verifyStaff)){
  8278. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8279. // $verifyList[$k]['status']=4;$button=4;
  8280. // }
  8281. //
  8282. // }else{
  8283. //
  8284. // }
  8285. // if($flag){//检测可编辑
  8286. // if($v[0]==$this->staff[0]['sid']){
  8287. // $verifyList[$k]['status']=4;$button=4;
  8288. // }
  8289. // }
  8290. }
  8291. }
  8292. $rolename ['name'] = '';
  8293. if (! empty ( $roleId )) {
  8294. Doo::loadModel ( 'role' );
  8295. $role = new role ();
  8296. $rolename = $role->getOne ( array (
  8297. 'where' => 'rid=' . $roleId,
  8298. 'asArray' => true
  8299. ) );
  8300. }
  8301. if (! empty ( $verifyStaff ))
  8302. $endStaffArray = end ( $verifyStaff );
  8303. $KOP = false;
  8304. foreach ( $roleArrayCopy as $P => $A ) {
  8305. foreach ( $A as $MKI => $AVL ) {
  8306. if (! empty ( $verifyStaff )) {
  8307. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8308. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8309. $button = 4;
  8310. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8311. }
  8312. foreach ( $verifyStaff as $m => $u ) {
  8313. $AVLFK = $AVL [0] . '_R';
  8314. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8315. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8316. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8317. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8318. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8319. break;
  8320. }
  8321. }
  8322. } else {
  8323. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8324. $button = 4;
  8325. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8326. }
  8327. }
  8328. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8329. $KOP = true;
  8330. }
  8331. }
  8332. // print_r($roleArrayCopy);
  8333. // echo $roleKey;
  8334. foreach ( $roleArrayCopy as $k => $v ) {
  8335. foreach ( $verifyList as $m => $n ) {
  8336. if ($n [0] == $k) {
  8337. array_splice ( $verifyList, $m, 1, $v );
  8338. }
  8339. }
  8340. }
  8341. // if ($KOP)
  8342. // array_splice($verifyList,$roleKey,1,$roleArray);
  8343. // print_r($verifyList);
  8344. $receiptList [$key] ['verifyList'] = $verifyList;
  8345. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8346. 'where' => 'sid=' . $value ['staff'],
  8347. 'asArray' => true
  8348. ) );
  8349. $receiptList [$key] ['button'] = $button;
  8350. }
  8351. // $data['verifyDetail']=$verifyDetail;
  8352. $mothHtml = "";
  8353. for($i = 1; $i <= 12; $i ++) {
  8354. if ($month == $i)
  8355. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8356. else
  8357. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8358. }
  8359. // 获取审批日志
  8360. Doo::loadModel ( 'receiptLog' );
  8361. $receiptLog = new receiptLog ();
  8362. $rlList = array ();
  8363. $rlInfo = $receiptLog->getOne ( array (
  8364. 'where' => 'rid=' . $rid . ' and status=4',
  8365. 'asArray' => true
  8366. ) );
  8367. $tijdate = $receiptLog->getOne ( array (
  8368. 'where' => 'rid=' . $rid . ' and status=2',
  8369. 'asc' => 'rlid',
  8370. 'asArray' => true
  8371. ) );
  8372. if (! empty ( $rlInfo )) {
  8373. $rlList = $receiptLog->find ( array (
  8374. 'where' => 'rid=' . $rid,
  8375. 'asc' => 'rlid',
  8376. 'asArray' => true
  8377. ) );
  8378. }
  8379. $receiptList [0] ['rlList'] = $rlList;
  8380. $enclosurList = $enclosur->find ( array (
  8381. 'where' => 'rid=' . $rid,
  8382. 'asArray' => true
  8383. ) );
  8384. $enclosurHtml = '';
  8385. foreach ( $enclosurList as $value ) {
  8386. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8387. }
  8388. $data ['enclosurHtml'] = $enclosurHtml;
  8389. $data ['rolename'] = $rolename ['name'];
  8390. $data ['datetij'] = $tijdate ['date'];
  8391. $data ['mothHtml'] = $mothHtml;
  8392. $data ['receiptList'] = $receiptList;
  8393. $data ['receiptApprovalCount'] = count ( $receiptList );
  8394. $data ['status'] = $status;
  8395. $data ['year'] = $year;
  8396. $data ['categoryList'] = $categoryList;
  8397. $data ['staffList'] = $staffList;
  8398. $data ['cid'] = $cid;
  8399. $data ['sid'] = $sid;
  8400. $data ['ap'] = $ap;
  8401. $data ['memu'] = "receipt";
  8402. $data ['staff'] = $this->staff;
  8403. $data ['receiptMemu'] = 'approval';
  8404. $data ['verifyId'] = $this->verifyId;
  8405. $data ['executeId'] = $this->executeId;
  8406. $this->render ( "/admin/saeaReportListReport", $data );
  8407. }
  8408. function remittanceHky() {
  8409. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8410. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8411. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8412. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8413. $page_size = 15;
  8414. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8415. Doo::loadModel ( 'receipt' );
  8416. $receipt = new receipt ();
  8417. Doo::loadModel ( 'staff' );
  8418. $staff = new staff ();
  8419. $dateCondition = " and Year(executeDate) =" . $year;
  8420. if ($moth != 'MONTH')
  8421. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8422. if ($day != 'DAY' && $moth != 'MONTH')
  8423. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8424. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8425. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8426. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8427. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8428. $dayList = $receipt->find ( array (
  8429. 'select' => 'executeDate,sum(amount) as amount',
  8430. 'where' => $sql,
  8431. 'desc' => 'executeDate',
  8432. 'groupby' => 'executeDate',
  8433. 'limit' => $limit,
  8434. 'asArray' => true
  8435. ) );
  8436. // print_r($dayList);
  8437. foreach ( $dayList as $key => $value ) {
  8438. $remitString = "";
  8439. $receiptList = $receipt->find ( array (
  8440. 'select' => 'rid,executeDate,amount,staff,cid',
  8441. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8442. 'desc' => 'executeDate',
  8443. 'asArray' => true
  8444. ) );
  8445. foreach ( $receiptList as $k => $v ) {
  8446. $sinfo = $staff->getOne ( array (
  8447. 'select' => 'username,category',
  8448. 'where' => ' sid=' . $v ['staff'],
  8449. 'asArray' => true
  8450. ) );
  8451. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8452. }
  8453. $dayList [$key] ['staff'] = $remitString;
  8454. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8455. }
  8456. // print_r($dayList);
  8457. $mothHtml = "";
  8458. for($i = 1; $i <= 12; $i ++) {
  8459. if ($moth == $i)
  8460. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8461. else
  8462. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8463. }
  8464. $dayHtml = "";
  8465. if ($day != "DAY" || $moth != "MONTH") {
  8466. for($i = 1; $i <= 31; $i ++) {
  8467. if ($day == $i)
  8468. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8469. else
  8470. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8471. }
  8472. }
  8473. $dateHtml = "";
  8474. $now = date ( "Y" );
  8475. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8476. if ($YEARD <= $now) {
  8477. $dateHtml .= '<option ';
  8478. if ($year == $YEARD) {
  8479. $dateHtml .= 'selected ';
  8480. }
  8481. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8482. }
  8483. }
  8484. $data ['dateHtml'] = $dateHtml;
  8485. $data ['page'] = $pageinfo;
  8486. $data ['year'] = $year;
  8487. $data ['moth'] = $moth;
  8488. $data ['day'] = $day;
  8489. $data ['get'] = $get;
  8490. $data ['dayHtml'] = $dayHtml;
  8491. $data ['mothHtml'] = $mothHtml;
  8492. $data ['receiptList'] = $dayList;
  8493. $data ['memu'] = "receipt";
  8494. $data ['staff'] = $this->staff;
  8495. $data ['receiptMemu'] = 'remittanceHky';
  8496. $data ['verifyId'] = $this->verifyId;
  8497. $data ['executeId'] = $this->executeId;
  8498. $this->render ( "/admin/remittanceHky", $data );
  8499. }
  8500. function remittancep() {
  8501. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8502. Doo::loadModel ( 'receipt' );
  8503. $receipt = new receipt ();
  8504. Doo::loadModel ( 'staff' );
  8505. $staff = new staff ();
  8506. Doo::loadClass ( 'XDeode' );
  8507. $XDeode = new XDeode ( 5 );
  8508. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8509. $rplist = $receipt->find ( array (
  8510. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8511. 'asArray' => true
  8512. ) );
  8513. $dayList = $receipt->find ( array (
  8514. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8515. 'desc' => 'executeDate',
  8516. 'groupby' => 'staff',
  8517. 'asArray' => true
  8518. ) );
  8519. $html = '';
  8520. foreach ( $dayList as $key => $value ) {
  8521. $sinfo = $staff->getOne ( array (
  8522. 'select' => 'username,category',
  8523. 'where' => ' sid=' . $value ['staff'],
  8524. 'asArray' => true
  8525. ) );
  8526. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8527. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8528. $au = 0;
  8529. foreach ( $rplist as $k => $v ) {
  8530. if ($value ['staff'] == $v ['staff']) {
  8531. $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>';
  8532. $au += $v ['amount'];
  8533. }
  8534. }
  8535. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8536. }
  8537. $data ['html'] = $html;
  8538. $data ['memu'] = "receipt";
  8539. $data ['staff'] = $this->staff;
  8540. $data ['receiptMemu'] = 'remittanceHky';
  8541. $data ['verifyId'] = $this->verifyId;
  8542. $data ['executeId'] = $this->executeId;
  8543. $this->render ( "/admin/remittancep", $data );
  8544. }
  8545. function ajaxGetReceiptDetails() {
  8546. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8547. Doo::loadClass ( 'XDeode' );
  8548. $XDeode = new XDeode ( 5 );
  8549. $rid = $XDeode->decode ( $rid );
  8550. if (empty ( $rid )) {
  8551. echo json_encode ( array (
  8552. 'status' => 2,
  8553. 'msg' => 'illegal request'
  8554. ) );
  8555. die ();
  8556. }
  8557. Doo::loadModel ( 'receipt' );
  8558. $receipt = new receipt ();
  8559. Doo::loadModel ( 'staff' );
  8560. $staff = new staff ();
  8561. $rinfo = $receipt->getOne ( array (
  8562. 'where' => 'rid= ' . $rid,
  8563. 'asArray' => true
  8564. ) );
  8565. $sinfo = $staff->getOne ( array (
  8566. 'select' => 'username,category',
  8567. 'where' => ' sid=' . $rinfo ['staff'],
  8568. 'asArray' => true
  8569. ) );
  8570. $rinfo ['reviseDetail'] = array ();
  8571. if (! empty ( $rinfo ['reviseDetail'] ))
  8572. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8573. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8574. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8575. $rinfo ['category'] = $sinfo ['category'];
  8576. $verifyStaff = array ();
  8577. if (! empty ( $rinfo ['verifyStaff'] ))
  8578. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8579. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8580. $rinfo ['relust'] = $relust;
  8581. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8582. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8583. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8584. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8585. // 费用执行人相关数据
  8586. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8587. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8588. foreach ( $executeCopy as $k => $v ) {
  8589. $executeCopy [$k] ['date'] = '';
  8590. $executeCopy [$k] ['opinion'] = '';
  8591. $executeCopy [$k] ['status'] = '';
  8592. if (! empty ( $executeStaff ))
  8593. foreach ( $executeStaff as $m => $u ) {
  8594. if ($v [0] == $m) {
  8595. $executeCopy [$k] ['date'] = $u ['date'];
  8596. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8597. $executeCopy [$k] ['status'] = $u ['status'];
  8598. break;
  8599. }
  8600. }
  8601. }
  8602. $rinfo ['executeCopy'] = $executeCopy;
  8603. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8604. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8605. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8606. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8607. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8608. $html .= '<tr><th>' . $value ['name'] . '</th>
  8609. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8610. }
  8611. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8612. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8613. <tr><th class="taC" colspan="2">费用说明</th>
  8614. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8615. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8616. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8617. </tbody></table>';
  8618. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8619. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8620. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8621. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8622. $html .= '<tr><th>' . $value ['name'] . '</th>
  8623. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8624. }
  8625. $html .= '<tr><th class="taR">合计</th>
  8626. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8627. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8628. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8629. $html .= '<tr><th>' . $value ['name'] . '</th>
  8630. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8631. }
  8632. $html .= '<tr><th class="taR">合计</th>
  8633. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8634. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8635. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8636. $html .= '<tr><th>' . $value ['name'] . '</th>
  8637. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8638. }
  8639. $html .= '<tr><th class="taR">合计</th>
  8640. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8641. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8642. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8643. $html .= '<tr><th>' . $value ['name'] . '</th>
  8644. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8645. }
  8646. $html .= '<tr><th class="taR">合计</th>
  8647. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8648. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8649. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8650. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8651. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8652. }
  8653. $html .= '<tr><th class="taR">合计</th>
  8654. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8655. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8656. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8657. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8658. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8659. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8660. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8661. <tr';
  8662. if ($rinfo ['relust'] >= 0) {
  8663. $html .= 'class="success"';
  8664. } else {
  8665. $html .= 'class="error"';
  8666. }
  8667. $html .= '><td class="taR"><b>借款结余</b></td>
  8668. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8669. </tbody></table>
  8670. ';
  8671. }
  8672. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8673. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8674. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8675. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8676. $html .= '<tr><th>' . $value ['name'] . '</th>
  8677. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8678. }
  8679. $html .= '<tr><th class="taR">合计</th>
  8680. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8681. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8682. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8683. <tr><th class="taC" colspan="2">费用说明</th>
  8684. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8685. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8686. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8687. </tbody></table>';
  8688. } else {
  8689. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8690. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8691. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8692. $html .= '<tr><th>' . $value ['name'] . '</th>
  8693. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8694. }
  8695. $html .= '<tr><th class="taR">合计</th>
  8696. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8697. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8698. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8699. $html .= '<tr><th>' . $value ['name'] . '</th>
  8700. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8701. }
  8702. $html .= '<tr><th class="taR">合计</th>
  8703. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8704. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8705. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8706. $html .= '<tr><th>' . $value ['name'] . '</th>
  8707. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8708. }
  8709. $html .= '<tr><th class="taR">合计</th>
  8710. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8711. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8712. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8713. $html .= '<tr><th>' . $value ['name'] . '</th>
  8714. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8715. }
  8716. $html .= '<tr><th class="taR">合计</th>
  8717. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8718. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8719. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8720. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8721. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8722. }
  8723. $html .= '<tr><th class="taR">合计</th>
  8724. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8725. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8726. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8727. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8728. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8729. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8730. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8731. $html .= '</tbody></table>';
  8732. /*
  8733. * <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>
  8734. */
  8735. }
  8736. // print_r($verifyStaff);die;
  8737. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8738. foreach ( $verifyStaff as $key => $value ) {
  8739. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8740. $sinfo = $staff->getOne ( array (
  8741. 'select' => 'username',
  8742. 'where' => ' sid=' . $key,
  8743. 'asArray' => true
  8744. ) );
  8745. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8746. }
  8747. $html .= '</tbody></table>';
  8748. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8749. foreach ( $rinfo ['executeCopy'] as $value ) {
  8750. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8751. }
  8752. $html .= '</tbody></table>';
  8753. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8754. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8755. </tr></table>';
  8756. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8757. echo json_encode ( array (
  8758. 'status' => 1,
  8759. 'html' => $html
  8760. ) );
  8761. die ();
  8762. }
  8763. /**
  8764. * 删除附件
  8765. */
  8766. function ajaxRemEnclousur() {
  8767. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8768. if (empty ( $key ))
  8769. echo json_encode ( array (
  8770. 'status' => 2
  8771. ) );
  8772. Doo::loadModel ( 'enclosur' );
  8773. $enclosur = new enclosur ();
  8774. $enclosur->delEnclosurByEid ( $key );
  8775. echo json_encode ( array (
  8776. 'status' => 1
  8777. ) );
  8778. }
  8779. function remittance() {
  8780. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8781. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8782. Doo::loadModel ( 'receipt' );
  8783. $receipt = new receipt ();
  8784. Doo::loadModel ( 'staff' );
  8785. $staff = new staff ();
  8786. $dateCondition = " and Year(pastDate) =" . $year;
  8787. if (! empty ( $month ))
  8788. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8789. // get Receipt By verifyID status 1
  8790. $receiptList = $receipt->find ( array (
  8791. 'select' => 'sum(sum) as sum,staff,pastDate',
  8792. 'where' => ' status=1' . $dateCondition,
  8793. 'desc' => 'pastDate',
  8794. 'groupby' => 'staff,pastDate',
  8795. 'asArray' => true
  8796. ) );
  8797. $dateList = $receipt->find ( array (
  8798. 'select' => 'pastDate,verifyStaff',
  8799. 'where' => ' status=1' . $dateCondition,
  8800. 'desc' => 'pastDate',
  8801. 'groupby' => 'pastDate',
  8802. 'asArray' => true
  8803. ) );
  8804. $dataList = array ();
  8805. foreach ( $dateList as $d => $a ) {
  8806. $dataList [$a ['pastDate']] = array ();
  8807. $daySum = 0;
  8808. foreach ( $receiptList as $key => $value ) {
  8809. if ($a ['pastDate'] == $value ['pastDate']) {
  8810. $oderList = $receipt->find ( array (
  8811. 'select' => 'receiptOrder',
  8812. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8813. 'asArray' => true
  8814. ) );
  8815. $list = array ();
  8816. $html = "";
  8817. foreach ( $oderList as $v ) {
  8818. array_push ( $list, $v ['receiptOrder'] );
  8819. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8820. }
  8821. $receiptList [$key] ['receiptOrder'] = $html;
  8822. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8823. $sinfo = $staff->getOne ( array (
  8824. 'select' => 'username ',
  8825. 'where' => ' sid=' . $value ['staff'],
  8826. 'asArray' => true
  8827. ) );
  8828. $receiptList [$key] ['username'] = $sinfo ['username'];
  8829. $daySum += $value ['sum'];
  8830. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8831. }
  8832. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8833. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8834. }
  8835. }
  8836. // print_r($dataList);
  8837. $data ['dataList'] = $dataList;
  8838. $mothHtml = "";
  8839. for($i = 1; $i <= 12; $i ++) {
  8840. if ($month == $i)
  8841. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8842. else
  8843. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8844. }
  8845. $data ['year'] = $year;
  8846. $data ['mothHtml'] = $mothHtml;
  8847. $data ['memu'] = "receipt";
  8848. $data ['staff'] = $this->staff;
  8849. $data ['receiptMemu'] = 'approval';
  8850. $data ['verifyId'] = $this->verifyId;
  8851. $data ['executeId'] = $this->executeId;
  8852. $this->render ( "/admin/saeaReportListPay", $data );
  8853. }
  8854. /**
  8855. * 金额调整,提高稳定性
  8856. * @return string
  8857. */
  8858. function revocationAdjustment() {
  8859. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8860. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8861. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8862. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8863. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8864. Doo::loadClass ( 'XDeode' );
  8865. $XDeode = new XDeode ( 5 );
  8866. Doo::loadModel ( 'receipt' );
  8867. $receipt = new receipt ();
  8868. $sid = $XDeode->decode ( $sidKey );
  8869. $rid = $XDeode->decode ( $ridKey );
  8870. $reviseKey = $XDeode->decode ( $reviseKey );
  8871. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8872. die ( 'illegal request' );
  8873. $receiptDetail = $receipt->getOne ( array (
  8874. 'where' => 'rid=' . $rid,
  8875. 'asArray' => true
  8876. ) );
  8877. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8878. die ( 'illegal request' );
  8879. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8880. if (! isset ( $reviseDetail [$reviseKey] ))
  8881. die ( 'illegal request' );
  8882. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8883. unset ( $reviseDetail [$reviseKey] );
  8884. $revisePrice = 0;
  8885. foreach ( $reviseDetail as $key => $value ) {
  8886. $revisePrice += $value ['price'];
  8887. }
  8888. $reviseDetailString = json_encode ( $reviseDetail );
  8889. $receipt->reviseDetail = $reviseDetailString;
  8890. $receipt->sum = $receiptDetail ['sum'] - $price;
  8891. $receipt->revisePrice = $revisePrice;
  8892. $receipt->update ( array (
  8893. 'where' => 'rid=' . $rid
  8894. ) );
  8895. return '/receiptburEdi/' . $rid;
  8896. } else
  8897. die ( 'illegal request2' );
  8898. }
  8899. function updateApprovalReceipt() {
  8900. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8901. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8902. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8903. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8904. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8905. if (! empty ( $rid )) {
  8906. Doo::loadModel ( "verify" );
  8907. $verify = new verify ();
  8908. Doo::loadModel ( "receiptDetail" );
  8909. $receiptDetailObj = new receiptDetail ();
  8910. Doo::loadModel ( "itemStatistics" );
  8911. Doo::loadModel ( "statistics" );
  8912. $statistics = new statistics ();
  8913. $itemStatistics = new itemStatistics ();
  8914. Doo::loadModel ( "receipt" );
  8915. $receipt = new receipt ();
  8916. $receiptDetail = $receipt->getOne ( array (
  8917. 'where' => 'rid=' . $rid . ' and status=2 ',
  8918. 'asArray' => true
  8919. ) );
  8920. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8921. $nsflag = true;
  8922. foreach ( $nslist as $value ) {
  8923. if ($value == $this->staff ['0'] ['sid']) {
  8924. $nsflag = false;
  8925. break;
  8926. }
  8927. }
  8928. if (empty ( $receiptDetail ) || $nsflag)
  8929. return "/approvalExpenses/pendApproval";
  8930. $verifyDetail = $verify->getOne ( array (
  8931. 'where' => ' vid =' . $receiptDetail ['verify'],
  8932. 'asArray' => true
  8933. ) );
  8934. $verifyString = $verifyDetail ['staff'];
  8935. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8936. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8937. if (empty ( $opinion )) {
  8938. if ($status == 3)
  8939. $opinion = "终止";
  8940. else
  8941. $opinion = "同意支付";
  8942. }
  8943. $nowStaff = 0;
  8944. $nowStaffList = array ();
  8945. if (empty ( $verifyStaff )) {
  8946. // 还需加入是否已经进入角色审批
  8947. if ($verifyDetail [0] [1] == 'ROLE') {
  8948. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8949. foreach ( $vStaffString as $key => $value ) {
  8950. $staffK = explode ( "_", $value );
  8951. if ($staffK [0] != $this->staff [0] ['sid'])
  8952. array_push ( $nowStaffList, $staffK [0] );
  8953. }
  8954. // print_r($verifyDetail);
  8955. // die;
  8956. if (! empty ( $nowStaffList )) {
  8957. $nowStaff = implode ( ',', $nowStaffList );
  8958. $verifyStaff = array (
  8959. $this->staff [0] ['sid'] . "_R" => array (
  8960. 'date' => date ( 'Y-m-d' ),
  8961. 'opinion' => $opinion,
  8962. 'status' => $status,
  8963. 'nextStaff' => $verifyDetail [0] [0],
  8964. 'ROLE' => 1
  8965. )
  8966. );
  8967. } else {
  8968. $nowStaff = $verifyDetail [1] [0];
  8969. $verifyStaff = array (
  8970. $this->staff [0] ['sid'] . "_R" => array (
  8971. 'date' => date ( 'Y-m-d' ),
  8972. 'opinion' => $opinion,
  8973. 'status' => $status,
  8974. 'nextStaff' => $verifyDetail [1] [0]
  8975. )
  8976. );
  8977. }
  8978. } else {
  8979. if ($verifyDetail [1] [1] == 'ROLE') {
  8980. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8981. // echo "dd";
  8982. foreach ( $vStaffString as $key => $value ) {
  8983. $staffK = explode ( "_", $value );
  8984. array_push ( $nowStaffList, $staffK [0] );
  8985. }
  8986. $nowStaff = implode ( ',', $nowStaffList );
  8987. $verifyStaff = array (
  8988. $this->staff [0] ['sid'] => array (
  8989. 'date' => date ( 'Y-m-d' ),
  8990. 'opinion' => $opinion,
  8991. 'status' => $status,
  8992. 'nextStaff' => $verifyDetail [1] [0],
  8993. 'ROLE' => 1
  8994. )
  8995. );
  8996. } else {
  8997. $nowStaff = $verifyDetail [1] [0];
  8998. $verifyStaff = array (
  8999. $this->staff [0] ['sid'] => array (
  9000. 'date' => date ( 'Y-m-d' ),
  9001. 'opinion' => $opinion,
  9002. 'status' => $status,
  9003. 'nextStaff' => $verifyDetail [1] [0]
  9004. )
  9005. );
  9006. }
  9007. }
  9008. if ($status == 3)
  9009. $verifyStaff = array (
  9010. 'final' => $status,
  9011. $this->staff [0] ['sid'] => array (
  9012. 'date' => date ( 'Y-m-d' ),
  9013. 'opinion' => $opinion,
  9014. 'status' => $status
  9015. )
  9016. );
  9017. $vStaffString = json_encode ( $verifyStaff );
  9018. $receipt->nowStaff = $nowStaff;
  9019. $receipt->verifyStaff = $vStaffString;
  9020. } else {
  9021. $VS = end ( $verifyStaff );
  9022. // 非角色审批
  9023. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9024. $nextStaff = 0;
  9025. $roleSTF = false;
  9026. foreach ( $verifyDetail as $key => $value ) {
  9027. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9028. if (isset ( $verifyDetail [$key + 1] )) {
  9029. $nextStaff = $verifyDetail [$key + 1] [0];
  9030. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9031. $roleSTF = true;
  9032. }
  9033. break;
  9034. }
  9035. }
  9036. if (! $roleSTF) {
  9037. $nowStaff = $nextStaff;
  9038. $verifyStaff [$this->staff [0] ['sid']] = array (
  9039. 'date' => date ( 'Y-m-d' ),
  9040. 'opinion' => $opinion,
  9041. 'status' => $status,
  9042. 'nextStaff' => $nextStaff
  9043. );
  9044. } else {
  9045. // 获取角色下的所有用户ID
  9046. $nowStaffList = array ();
  9047. foreach ( $verifyDetail as $vfk ) {
  9048. if ($vfk [1] == 'ROLE') {
  9049. $vStaffString = json_decode ( $vfk [3] );
  9050. foreach ( $vStaffString as $key => $value ) {
  9051. $staffK = explode ( "_", $value );
  9052. array_push ( $nowStaffList, $staffK [0] );
  9053. }
  9054. }
  9055. }
  9056. $nowStaff = implode ( ',', $nowStaffList );
  9057. $verifyStaff [$this->staff [0] ['sid']] = array (
  9058. 'date' => date ( 'Y-m-d' ),
  9059. 'opinion' => $opinion,
  9060. 'status' => $status,
  9061. 'nextStaff' => $nextStaff,
  9062. 'ROLE' => 0
  9063. );
  9064. }
  9065. if ($status == 3) {
  9066. $verifyStaff ['final'] = $status;
  9067. $verifyStaff [$this->staff [0] ['sid']] = array (
  9068. 'date' => date ( 'Y-m-d' ),
  9069. 'opinion' => $opinion,
  9070. 'status' => $status
  9071. );
  9072. }
  9073. $vStaffString = json_encode ( $verifyStaff );
  9074. $receipt->nowStaff = $nowStaff;
  9075. $receipt->verifyStaff = $vStaffString;
  9076. }
  9077. // 角色审批
  9078. if (isset ( $VS ['ROLE'] )) {
  9079. // 找出角色人 当前审批角色组
  9080. $verifyJSStaff = array ();
  9081. $nowStaffList2 = array ();
  9082. foreach ( $verifyDetail as $key => $value ) {
  9083. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9084. $verifyJSStaff = json_decode ( $value [3] );
  9085. foreach ( $verifyJSStaff as $m ) {
  9086. $staffK = explode ( "_", $m );
  9087. array_push ( $nowStaffList2, $staffK [0] );
  9088. }
  9089. // print_r($nowStaffList2);
  9090. }
  9091. }
  9092. $RoleVerifyStaff = array ();
  9093. foreach ( $verifyStaff as $key => $value ) {
  9094. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9095. foreach ( $nowStaffList2 as $m ) {
  9096. if ($key == $m . "_R")
  9097. $RoleVerifyStaff [$key] = $value;
  9098. }
  9099. }
  9100. }
  9101. // print_r($verifyStaff);
  9102. // print_r($nowStaffList2);
  9103. // print_r($RoleVerifyStaff);
  9104. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9105. // print_r($verifyJSStaff);
  9106. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9107. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9108. // 下一个审批人ID
  9109. $nextStaff = 0;
  9110. $falg = false;
  9111. foreach ( $verifyDetail as $key => $value ) {
  9112. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9113. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9114. $falg = true;
  9115. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9116. $nowStaffList = array ();
  9117. foreach ( $vStaffString as $v ) {
  9118. $staffK = explode ( "_", $v );
  9119. array_push ( $nowStaffList, $staffK [0] );
  9120. }
  9121. $nowStaff = implode ( ',', $nowStaffList );
  9122. $nextStaff = $verifyDetail [$key + 1] [0];
  9123. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9124. $nextStaff = $verifyDetail [$key + 1] [0];
  9125. $nowStaff = $nextStaff;
  9126. } else
  9127. $nowStaff = '';
  9128. break;
  9129. }
  9130. }
  9131. if ($falg)
  9132. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9133. 'date' => date ( 'Y-m-d' ),
  9134. 'opinion' => $opinion,
  9135. 'status' => $status,
  9136. 'nextStaff' => $nextStaff,
  9137. 'ROLE' => 1
  9138. );
  9139. else
  9140. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9141. 'date' => date ( 'Y-m-d' ),
  9142. 'opinion' => $opinion,
  9143. 'status' => $status,
  9144. 'nextStaff' => $nextStaff
  9145. );
  9146. // print_r($verifyStaff);
  9147. // echo $nowStaff;die;
  9148. } else { // 进入下一个角色或者审批人
  9149. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9150. //
  9151. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9152. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9153. 'date' => date ( 'Y-m-d' ),
  9154. 'opinion' => $opinion,
  9155. 'status' => $status,
  9156. 'nextStaff' => $VS ['nextStaff'],
  9157. 'ROLE' => 1
  9158. );
  9159. // print_r($verifyStaff);
  9160. // die;
  9161. }
  9162. if ($status == 3) {
  9163. $verifyStaff ['final'] = $status;
  9164. $verifyStaff [$this->staff [0] ['sid']] = array (
  9165. 'date' => date ( 'Y-m-d' ),
  9166. 'opinion' => $opinion,
  9167. 'status' => $status
  9168. );
  9169. }
  9170. $vStaffString = json_encode ( $verifyStaff );
  9171. $receipt->verifyStaff = $vStaffString;
  9172. $receipt->nowStaff = $nowStaff;
  9173. // die;
  9174. // }
  9175. // print_r($verifyStaff);
  9176. // die;
  9177. }
  9178. // print_r($verifyStaff);die;
  9179. }
  9180. // print_r($verifyDetail);
  9181. $roleKey = 0;
  9182. $roleId = 0;
  9183. $verifyDetailCopy = array ();
  9184. foreach ( $verifyDetail as $k => $v ) {
  9185. if ($v [1] == 'ROLE') {
  9186. $roleId = $v [0];
  9187. $roleVerify = json_decode ( $v [3], true );
  9188. $roleKey = $k;
  9189. $roleArray = array ();
  9190. foreach ( $roleVerify as $o => $p ) {
  9191. $staffID = explode ( '_', $p );
  9192. $exp = array (
  9193. 0 => $staffID [0],
  9194. 1 => $staffID [1]
  9195. );
  9196. array_push ( $roleArray, $exp );
  9197. }
  9198. $verifyDetailCopy [$v [0]] = $roleArray;
  9199. }
  9200. }
  9201. // print_r($verifyDetail);
  9202. foreach ( $verifyDetailCopy as $k => $v ) {
  9203. foreach ( $verifyDetail as $m => $n ) {
  9204. if ($n [0] == $k) {
  9205. array_splice ( $verifyDetail, $m, 1, $v );
  9206. }
  9207. }
  9208. }
  9209. // die;
  9210. // if (!empty($roleArray))
  9211. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9212. // echo $roleId;
  9213. // print_r($verifyStaff);
  9214. // print_r($verifyDetail);
  9215. // die;
  9216. Doo::loadModel ( "receiptLog" );
  9217. $receiptLog = new receiptLog ();
  9218. // 审批日志
  9219. if (! isset ( $verifyStaff ['final'] )) {
  9220. if (! empty ( $roleId )) {
  9221. Doo::loadModel ( "role" );
  9222. $role = new role ();
  9223. $roleInfo = $role->getOne ( array (
  9224. 'where' => 'rid=' . $roleId,
  9225. 'asArray' => true
  9226. ) );
  9227. $receiptLog->rolename = $roleInfo ['name'];
  9228. }
  9229. $receiptLog->username = $this->staff [0] ['username'];
  9230. $receiptLog->uid = $this->staff [0] ['sid'];
  9231. $receiptLog->date = date ( "Y-m-d" );
  9232. $receiptLog->opinion = $opinion;
  9233. $receiptLog->img = $this->staff [0] ['avatar'];
  9234. $receiptLog->status = 1;
  9235. $receiptLog->rid = $rid;
  9236. $receiptLog->insert ();
  9237. }
  9238. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9239. $receipt->verifyBreakup = $verifyString;
  9240. $receipt->status = 3;
  9241. $receiptDetailObj->status = 3;
  9242. $receiptDetailObj->update ( array (
  9243. 'where' => 'rid=' . $rid
  9244. ) );
  9245. if (! empty ( $roleId )) {
  9246. Doo::loadModel ( "role" );
  9247. $role = new role ();
  9248. $roleInfo = $role->getOne ( array (
  9249. 'where' => 'rid=' . $roleId,
  9250. 'asArray' => true
  9251. ) );
  9252. $receiptLog->rolename = $roleInfo ['name'];
  9253. }
  9254. $receiptLog->username = $this->staff [0] ['username'];
  9255. $receiptLog->uid = $this->staff [0] ['sid'];
  9256. $receiptLog->date = date ( "Y-m-d" );
  9257. $receiptLog->opinion = $opinion;
  9258. $receiptLog->img = $this->staff [0] ['avatar'];
  9259. $receiptLog->status = 3;
  9260. $receiptLog->rid = $rid;
  9261. $receiptLog->insert ();
  9262. //删除行程单
  9263. Doo::loadModel ( 'itinerary' );
  9264. $itinerary = new itinerary ();
  9265. $itinerary->delete ( array (
  9266. 'where' => 'rid="' . $rid . '"'
  9267. ) );
  9268. // 微信企业号通知
  9269. $this->setWXMsg ( $rid, 3 );
  9270. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9271. $receipt->status = 1;
  9272. $reviseSum = 0;
  9273. $receipt->verifyBreakup = $verifyString;
  9274. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9275. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9276. foreach ( $reviseDetail as $key => $value ) {
  9277. $receiptDetailObj = new receiptDetail ();
  9278. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9279. $receiptDetailObj->item = $value ['description'];
  9280. $receiptDetailObj->itemCategory = "报销金额调整";
  9281. $receiptDetailObj->price = $value ['price'];
  9282. $receiptDetailObj->date = $receiptDetail ['date'];
  9283. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9284. $receiptDetailObj->rid = $rid;
  9285. $receiptDetailObj->status = 1;
  9286. $receiptDetailObj->insert ();
  9287. $reviseSum += $value ['price'];
  9288. }
  9289. $itemStatistics = new itemStatistics ();
  9290. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9291. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9292. $itemStatistics->price = $reviseSum;
  9293. $itemStatistics->itemCategory = "报销金额调整";
  9294. $itemStatistics->date = $receiptDetail ['date'];
  9295. $itemStatistics->insert ();
  9296. }
  9297. $receiptDetailObj = new receiptDetail ();
  9298. $receiptDetailObj->status = 1;
  9299. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9300. $receiptDetailObj->update ( array (
  9301. 'where' => 'rid=' . $rid
  9302. ) );
  9303. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9304. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9305. $stat = $statistics->getOne ( array (
  9306. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9307. 'asArray' => true
  9308. ) );
  9309. if (empty ( $stat )) {
  9310. $statistics->date = $receiptDetail ['date'];
  9311. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9312. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9313. $statistics->agPrice = $receiptDetail ['sum'];
  9314. $statistics->rePrice = $reviseSum;
  9315. $statistics->insert ();
  9316. } else {
  9317. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9318. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9319. $statistics->update ( array (
  9320. 'where' => 'sid=' . $stat ['sid']
  9321. ) );
  9322. }
  9323. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9324. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9325. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9326. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9327. if ($key == "agencySum") {
  9328. $iStatistics = $itemStatistics->getOne ( array (
  9329. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9330. 'asArray' => true
  9331. ) );
  9332. if (empty ( $iStatistics )) {
  9333. $itemStatistics->cid = $receiptDetail ['cid'];
  9334. ;
  9335. $itemStatistics->staff = $receiptDetail ['staff'];
  9336. $itemStatistics->price = $value;
  9337. $itemStatistics->itemCategory = $this->AGENCY;
  9338. $itemStatistics->date = $receiptDetail ['date'];
  9339. $itemStatistics->insert ();
  9340. } else {
  9341. if (! empty ( $value )) {
  9342. $itemStatistics->price = $value + $iStatistics ['price'];
  9343. $itemStatistics->update ( array (
  9344. 'where' => 'sid=' . $iStatistics ['sid']
  9345. ) );
  9346. }
  9347. }
  9348. } elseif ($key == "travelSum") {
  9349. $iStatistics = $itemStatistics->getOne ( array (
  9350. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9351. 'asArray' => true
  9352. ) );
  9353. if (empty ( $iStatistics )) {
  9354. $itemStatistics->cid = $receiptDetail ['cid'];
  9355. $itemStatistics->staff = $receiptDetail ['staff'];
  9356. $itemStatistics->price = $value;
  9357. $itemStatistics->itemCategory = $this->TRAVEL;
  9358. $itemStatistics->date = $receiptDetail ['date'];
  9359. $itemStatistics->insert ();
  9360. } else {
  9361. if (! empty ( $value )) {
  9362. $itemStatistics->price = $value + $iStatistics ['price'];
  9363. $itemStatistics->update ( array (
  9364. 'where' => 'sid=' . $iStatistics ['sid']
  9365. ) );
  9366. }
  9367. }
  9368. } elseif ($key == "trainSum") {
  9369. $iStatistics = $itemStatistics->getOne ( array (
  9370. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9371. 'asArray' => true
  9372. ) );
  9373. if (empty ( $iStatistics )) {
  9374. $itemStatistics->cid = $receiptDetail ['cid'];
  9375. $itemStatistics->staff = $receiptDetail ['staff'];
  9376. $itemStatistics->price = $value;
  9377. $itemStatistics->itemCategory = $this->TRAIN;
  9378. $itemStatistics->date = $receiptDetail ['date'];
  9379. $itemStatistics->insert ();
  9380. } else {
  9381. if (! empty ( $value )) {
  9382. $itemStatistics->price = $value + $iStatistics ['price'];
  9383. $itemStatistics->update ( array (
  9384. 'where' => 'sid=' . $iStatistics ['sid']
  9385. ) );
  9386. }
  9387. }
  9388. } elseif ($key == "otherSum") {
  9389. $iStatistics = $itemStatistics->getOne ( array (
  9390. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9391. 'asArray' => true
  9392. ) );
  9393. if (empty ( $iStatistics )) {
  9394. $itemStatistics->cid = $receiptDetail ['cid'];
  9395. $itemStatistics->staff = $receiptDetail ['staff'];
  9396. $itemStatistics->price = $value;
  9397. $itemStatistics->itemCategory = $this->OTHER;
  9398. $itemStatistics->date = $receiptDetail ['date'];
  9399. $itemStatistics->insert ();
  9400. } else {
  9401. if (! empty ( $value )) {
  9402. $itemStatistics->price = $value + $iStatistics ['price'];
  9403. $itemStatistics->update ( array (
  9404. 'where' => 'sid=' . $iStatistics ['sid']
  9405. ) );
  9406. }
  9407. }
  9408. }
  9409. }
  9410. $receipt->pastDate = date ( "Y-m-d" );
  9411. // 微信企业号通知
  9412. $this->setWXMsg ( $rid, 1 );
  9413. }
  9414. //是否有流水
  9415. Doo::loadModel ( 'wasteBook' );
  9416. $wasteBook = new wasteBook ();
  9417. $accountType=3;
  9418. if ($receiptDetail['Rtype']==1){
  9419. $accountType=2;
  9420. }elseif($receiptDetail['Rtype']==2){
  9421. $accountType=4;
  9422. }
  9423. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9424. if (empty($wbDetail)){
  9425. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9426. $receipt->amount = $rsum;//$amount;
  9427. }
  9428. $receipt->update ( array (
  9429. 'where' => ' rid = ' . $rid
  9430. ) );
  9431. // 进入下一条审批费用新加需求
  9432. $vidList = array ();
  9433. $verifyDetail = $verify->find ( array (
  9434. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9435. 'asArray' => true
  9436. ) );
  9437. foreach ( $verifyDetail as $key => $value ) {
  9438. array_push ( $vidList, $value ['vid'] );
  9439. }
  9440. $vid = implode ( ",", $vidList );
  9441. if (empty ( $verifyDetail ))
  9442. $vid = 0;
  9443. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9444. $receipt = new receipt ();
  9445. $rd = $receipt->getOne ( array (
  9446. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9447. 'asc' => 'rid',
  9448. 'asArray' => true
  9449. ) );
  9450. if (empty ( $rd )) {
  9451. return '/approvalExpenses/pendApproval';
  9452. }
  9453. if ($rd ['Rtype'] == 1) {
  9454. if ($rd ['isBK'] == 1) {
  9455. return '/receiptburEdi/' . $rd ['rid'];
  9456. } else {
  9457. return '/expensesEdi/' . $rd ['rid'];
  9458. }
  9459. } elseif ($rd ['Rtype'] == 2) {
  9460. return '/remitApproval/' . $rd ['rid'];
  9461. } else {
  9462. return '/receiptburEdi/' . $rd ['rid'];
  9463. }
  9464. // return "/approvalExpenses/pendApproval";
  9465. }
  9466. }
  9467. function expensesRetreats() {
  9468. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9469. if (! empty ( $rid )) {
  9470. // 操作记录
  9471. Doo::loadModel ( "receipt" );
  9472. $receipt = new receipt ();
  9473. Doo::loadModel ( "receiptLog" );
  9474. $receiptLog = new receiptLog ();
  9475. Doo::loadModel ( "verify" );
  9476. $verify = new verify ();
  9477. $receiptInfo = $receipt->getOne ( array (
  9478. 'where' => 'rid=' . $rid,
  9479. 'asArray' => true
  9480. ) );
  9481. $vr = $verify->getOne ( array (
  9482. 'where' => 'vid=' . $receiptInfo ['verify'],
  9483. 'asArray' => true
  9484. ) );
  9485. $jd = json_decode ( $vr ['staff'] );
  9486. $roleId = 0;
  9487. foreach ( $jd as $key => $value ) {
  9488. if ($value [1] == 'ROLE') {
  9489. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9490. if ($pos !== false) {
  9491. $roleId = $value [0];
  9492. }
  9493. }
  9494. }
  9495. // 审批日志
  9496. // echo $roleId;die;
  9497. if (! empty ( $roleId )) {
  9498. Doo::loadModel ( "role" );
  9499. $role = new role ();
  9500. $roleInfo = $role->getOne ( array (
  9501. 'where' => 'rid=' . $roleId,
  9502. 'asArray' => true
  9503. ) );
  9504. $receiptLog->rolename = $roleInfo ['name'];
  9505. }
  9506. $receiptLog->username = $this->staff [0] ['username'];
  9507. $receiptLog->uid = $this->staff [0] ['sid'];
  9508. $receiptLog->date = date ( "Y-m-d" );
  9509. $receiptLog->opinion = '撤回';
  9510. $receiptLog->img = $this->staff [0] ['avatar'];
  9511. $receiptLog->status = 4;
  9512. $receiptLog->rid = $rid;
  9513. $receiptLog->insert ();
  9514. $receipt->status = 4;
  9515. $receipt->update ( array (
  9516. 'where' => 'rid=' . $rid
  9517. ) );
  9518. // 微信企业号通知
  9519. $this->setWXMsg ( $rid, 2 );
  9520. }
  9521. // echo "ddd";
  9522. return '/approvalExpenses/pendApproval';
  9523. }
  9524. function updateCheReceipt() {
  9525. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9526. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9527. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9528. if (! empty ( $rid )) {
  9529. // 操作记录
  9530. Doo::loadModel ( "receipt" );
  9531. $receipt = new receipt ();
  9532. Doo::loadModel ( "receiptLog" );
  9533. $receiptLog = new receiptLog ();
  9534. Doo::loadModel ( "verify" );
  9535. $verify = new verify ();
  9536. $receiptInfo = $receipt->getOne ( array (
  9537. 'where' => 'rid=' . $rid . ' and status=2',
  9538. 'asArray' => true
  9539. ) );
  9540. if (empty ( $receiptInfo )) {
  9541. echo json_encode ( array (
  9542. 'status' => 2
  9543. ) );
  9544. die ();
  9545. }
  9546. $vr = $verify->getOne ( array (
  9547. 'where' => 'vid=' . $receiptInfo ['verify'],
  9548. 'asArray' => true
  9549. ) );
  9550. $jd = json_decode ( $vr ['staff'] );
  9551. $roleId = 0;
  9552. foreach ( $jd as $key => $value ) {
  9553. if ($value [1] == 'ROLE') {
  9554. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9555. if ($pos !== false) {
  9556. $roleId = $value [0];
  9557. }
  9558. }
  9559. }
  9560. // 审批日志
  9561. // echo $roleId;die;
  9562. if (! empty ( $roleId )) {
  9563. Doo::loadModel ( "role" );
  9564. $role = new role ();
  9565. $roleInfo = $role->getOne ( array (
  9566. 'where' => 'rid=' . $roleId,
  9567. 'asArray' => true
  9568. ) );
  9569. $receiptLog->rolename = $roleInfo ['name'];
  9570. }
  9571. $receiptLog->username = $this->staff [0] ['username'];
  9572. $receiptLog->uid = $this->staff [0] ['sid'];
  9573. $receiptLog->date = date ( "Y-m-d" );
  9574. $receiptLog->opinion = $opinion;
  9575. $receiptLog->img = $this->staff [0] ['avatar'];
  9576. $receiptLog->status = 4;
  9577. $receiptLog->rid = $rid;
  9578. $receiptLog->insert ();
  9579. $receipt->status = 4;
  9580. $receipt->update ( array (
  9581. 'where' => 'rid=' . $rid
  9582. ) );
  9583. // 微信企业号通知
  9584. $this->setWXMsg ( $rid, 2 );
  9585. echo json_encode ( array (
  9586. 'status' => 1
  9587. ) );
  9588. // Header("HTTP/1.1 303 See Other");
  9589. // Header("Location: /approvalExpenses/pendApproval");
  9590. die ();
  9591. }
  9592. echo json_encode ( array (
  9593. 'status' => 2
  9594. ) );
  9595. die ();
  9596. // echo "ddd";
  9597. // return '/saeaBorad';
  9598. }
  9599. function revisePrice() {
  9600. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9601. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9602. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9603. // echo $price;die;
  9604. if (! empty ( $rid )) {
  9605. Doo::loadModel ( "receipt" );
  9606. $receipt = new receipt ();
  9607. $receiptDetail = $receipt->getOne ( array (
  9608. 'where' => 'rid=' . $rid . ' and status=2 ',
  9609. 'asArray' => true
  9610. ) );
  9611. if (empty ( $receiptDetail ))
  9612. die ( 'illegal request' );
  9613. $reviseDetail = array ();
  9614. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9615. array_push ( $reviseDetail, array (
  9616. 'sid' => $this->staff [0] ['sid'],
  9617. 'name' => $this->staff [0] ['username'],
  9618. 'description' => $description,
  9619. 'price' => $price
  9620. ) );
  9621. $reviseDetailString = json_encode ( $reviseDetail );
  9622. $receipt->reviseDetail = $reviseDetailString;
  9623. $receipt->revisePrice = $price;
  9624. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9625. } else {
  9626. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9627. array_push ( $reviseDetail, array (
  9628. 'sid' => $this->staff [0] ['sid'],
  9629. 'name' => $this->staff [0] ['username'],
  9630. 'description' => $description,
  9631. 'price' => $price
  9632. ) );
  9633. $reviseDetailString = json_encode ( $reviseDetail );
  9634. $receipt->reviseDetail = $reviseDetailString;
  9635. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9636. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9637. }
  9638. $receipt->update ( array (
  9639. 'where' => 'rid=' . $rid
  9640. ) );
  9641. if ($receiptDetail ['Rtype'] == 1) {
  9642. if ($receiptDetail ['isBK'] == 1) {
  9643. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9644. }
  9645. } elseif ($receiptDetail ['Rtype'] == 2) {
  9646. } else {
  9647. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9648. }
  9649. }
  9650. die ( 'illegal request' );
  9651. }
  9652. function personalCollect() {
  9653. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9654. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9655. $this->showCache ( $path );
  9656. Doo::loadModel ( "receiptDetail" );
  9657. Doo::loadModel ( "itemStatistics" );
  9658. Doo::loadModel ( 'statistics' );
  9659. $statistics = new statistics ();
  9660. $itemStatistics = new itemStatistics ();
  9661. $receiptDetail = new receiptDetail ();
  9662. $receiptCollectList = $receiptDetail->find ( array (
  9663. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9664. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9665. 'groupby' => 'itemCategory,Month(date)',
  9666. 'asArray' => true
  9667. ) );
  9668. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9669. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9670. 'asArray' => true
  9671. ) );
  9672. // create collect html
  9673. $collectArray = array (
  9674. '日常相关费用' => array (),
  9675. '差旅相关费用' => array (),
  9676. '培训班费用' => array (),
  9677. '其他' => array ()
  9678. );
  9679. $adjustment = array ();
  9680. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9681. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9682. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9683. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9684. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9685. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9686. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9687. array_push ( $collectArray ['其他'], $collectHtml );
  9688. $data ['collectArray'] = $collectArray;
  9689. // statistics html
  9690. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9691. if (empty ( $stList ))
  9692. $stList = array (
  9693. 'rePrice' => 0,
  9694. 'agPrice' => 0
  9695. );
  9696. $data ['stList'] = array (
  9697. 'rePrice' => $stList ['rePrice'],
  9698. 'agPrice' => $stList ['agPrice'],
  9699. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9700. );
  9701. // Adjustment price html
  9702. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9703. array_push ( $adjustment, $collectHtml );
  9704. $data ['adjustment'] = $adjustment;
  9705. // total price html
  9706. $collectHtml = "";
  9707. $total = 0;
  9708. for($i = 1; $i <= 12; $i ++) {
  9709. $sumPrice = 0;
  9710. foreach ( $receiptCollectList as $key => $value ) {
  9711. if ($value ['month'] == $i) {
  9712. $sumPrice += $value ['price'];
  9713. }
  9714. }
  9715. if ($sumPrice == 0)
  9716. $collectHtml .= '<td class="taR">-</td>';
  9717. else
  9718. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9719. $total += $sumPrice;
  9720. }
  9721. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9722. $data ['totalPrice'] = $collectHtml;
  9723. $dateHtml = "";
  9724. $now = date ( "Y" );
  9725. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9726. if ($YEARD <= $now) {
  9727. $dateHtml .= '<option ';
  9728. if ($year == $YEARD) {
  9729. $dateHtml .= 'selected ';
  9730. }
  9731. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9732. }
  9733. }
  9734. $data ['dateHtml'] = $dateHtml;
  9735. $data ['year'] = $year;
  9736. $data ['totalYear'] = $total;
  9737. $data ['memu'] = "receipt";
  9738. $data ['staff'] = $this->staff;
  9739. $data ['receiptMemu'] = 'personalCollect';
  9740. $data ['verifyId'] = $this->verifyId;
  9741. $data ['executeId'] = $this->executeId;
  9742. // year staff status 2,4
  9743. if ($year < date ( "Y" )) {
  9744. Doo::loadModel ( 'receipt' );
  9745. $receipt = new receipt ();
  9746. $receiptList = $receipt->find ( array (
  9747. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9748. 'asArray' => true
  9749. ) );
  9750. if (empty ( $receiptList )) {
  9751. ob_start ();
  9752. $this->render ( "/admin/saea_slist_collect", $data );
  9753. $this->cacheFile ( $path );
  9754. die ();
  9755. }
  9756. }
  9757. $this->render ( "/admin/saea_slist_collect", $data );
  9758. }
  9759. function personalCollectDetail() {
  9760. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9761. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9762. $this->showCache ( $path );
  9763. Doo::loadModel ( "receiptDetail" );
  9764. Doo::loadModel ( "itemStatistics" );
  9765. Doo::loadModel ( 'statistics' );
  9766. Doo::loadModel ( 'accountItem' );
  9767. $accountItem = new accountItem ();
  9768. $statistics = new statistics ();
  9769. $itemStatistics = new itemStatistics ();
  9770. $receiptDetail = new receiptDetail ();
  9771. $receiptCollectList = $receiptDetail->find ( array (
  9772. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9773. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9774. 'groupby' => 'item,Month(date)',
  9775. 'asArray' => true
  9776. ) );
  9777. $accountList = $accountItem->find ( array (
  9778. 'asArray' => true
  9779. ) );
  9780. // create CollectDetail HTML
  9781. $collectHtml = array ();
  9782. foreach ( $accountList as $key => $value ) {
  9783. $html = "";
  9784. $asum = 0;
  9785. for($i = 1; $i <= 12; $i ++) {
  9786. $falg = true;
  9787. foreach ( $receiptCollectList as $v ) {
  9788. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9789. $asum += $v ['price'];
  9790. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9791. $falg = false;
  9792. break;
  9793. }
  9794. }
  9795. if ($falg)
  9796. $html .= '<td class="taR">-</td>';
  9797. }
  9798. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9799. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9800. }
  9801. $data ['collectHtml'] = $collectHtml;
  9802. // create Adjustment price html
  9803. $receiptCollectList = $receiptDetail->find ( array (
  9804. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9805. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9806. 'groupby' => 'itemCategory,Month(date)',
  9807. 'asArray' => true
  9808. ) );
  9809. $adjustment = array ();
  9810. $collectArray = array (
  9811. '日常相关费用' => array (),
  9812. '差旅相关费用' => array (),
  9813. '培训班费用' => array (),
  9814. '其他' => array ()
  9815. );
  9816. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9817. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9818. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9819. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9820. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9821. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9822. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9823. array_push ( $collectArray ['其他'], $collectHtml );
  9824. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9825. array_push ( $adjustment, $collectHtml );
  9826. // total price html
  9827. $collectHtml = "";
  9828. $total = 0;
  9829. for($i = 1; $i <= 12; $i ++) {
  9830. $sumPrice = 0;
  9831. foreach ( $receiptCollectList as $key => $value ) {
  9832. if ($value ['month'] == $i) {
  9833. $sumPrice += $value ['price'];
  9834. }
  9835. }
  9836. if ($sumPrice == 0)
  9837. $collectHtml .= '<td class="taR">-</td>';
  9838. else
  9839. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9840. $total += $sumPrice;
  9841. }
  9842. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9843. // statistics html
  9844. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9845. if (empty ( $stList ))
  9846. $stList = array (
  9847. 'rePrice' => 0,
  9848. 'agPrice' => 0
  9849. );
  9850. $data ['stList'] = array (
  9851. 'rePrice' => $stList ['rePrice'],
  9852. 'agPrice' => $stList ['agPrice'],
  9853. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9854. );
  9855. $data ['collectArray'] = $collectArray;
  9856. $data ['adjustment'] = $adjustment;
  9857. $data ['totalPrice'] = $collectHtml;
  9858. $data ['totalYear'] = $total;
  9859. $data ['year'] = $year;
  9860. $dateHtml = "";
  9861. $now = date ( "Y" );
  9862. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9863. if ($YEARD <= $now) {
  9864. $dateHtml .= '<option ';
  9865. if ($year == $YEARD) {
  9866. $dateHtml .= 'selected ';
  9867. }
  9868. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9869. }
  9870. }
  9871. $data ['dateHtml'] = $dateHtml;
  9872. $data ['memu'] = "receipt";
  9873. $data ['staff'] = $this->staff;
  9874. $data ['receiptMemu'] = 'personalCollect';
  9875. $data ['verifyId'] = $this->verifyId;
  9876. $data ['executeId'] = $this->executeId;
  9877. // year staff status 2,4
  9878. if ($year < date ( "Y" )) {
  9879. Doo::loadModel ( 'receipt' );
  9880. $receipt = new receipt ();
  9881. $receiptList = $receipt->find ( array (
  9882. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9883. 'asArray' => true
  9884. ) );
  9885. if (empty ( $receiptList )) {
  9886. ob_start ();
  9887. $this->render ( "/admin/saeaCollectArticles", $data );
  9888. $this->cacheFile ( $path );
  9889. die ();
  9890. }
  9891. }
  9892. $this->render ( "/admin/saeaCollectArticles", $data );
  9893. }
  9894. function companyCategoryCollect() {
  9895. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9896. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9897. $this->showCache ( $path );
  9898. Doo::loadModel ( 'L_category' );
  9899. Doo::loadModel ( 'itemStatistics' );
  9900. Doo::loadModel ( 'statistics' );
  9901. $statistics = new statistics ();
  9902. $Lcategory = new L_category ();
  9903. $itemStatistics = new itemStatistics ();
  9904. Doo::loadModel ( "receiptAuthorityManage" );
  9905. $receiptAuthorityManage = new receiptAuthorityManage ();
  9906. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9907. $cidList = array ();
  9908. foreach ( $imcStaff as $key => $value ) {
  9909. array_push ( $cidList, $value ['cid'] );
  9910. }
  9911. $cidString = implode ( ',', $cidList );
  9912. $LcategoryList = $Lcategory->find ( array (
  9913. 'where' => ' cid in (' . $cidString . ')',
  9914. 'asArray' => true
  9915. ) ); // 'staff='.$this->staff[0]['sid']." and
  9916. $itemStatisticsList = $itemStatistics->find ( array (
  9917. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9918. 'where' => " Year(date)=" . $year,
  9919. 'groupby' => 'cid,Month(date)',
  9920. 'asArray' => true
  9921. ) );
  9922. // ceatre companyCollectHtml
  9923. foreach ( $LcategoryList as $value ) {
  9924. $html = "";
  9925. $asum = 0;
  9926. for($i = 1; $i <= 12; $i ++) {
  9927. $falg = true;
  9928. foreach ( $itemStatisticsList as $v ) {
  9929. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9930. $asum += $v ['price'];
  9931. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9932. $falg = false;
  9933. break;
  9934. }
  9935. }
  9936. if ($falg)
  9937. $html .= '<td class="taR">-</td>';
  9938. }
  9939. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9940. $collectHtml [$value ['title']] = array (
  9941. 'html' => $html,
  9942. 'cid' => $value ['cid']
  9943. );
  9944. }
  9945. $data ['companyHtml'] = $collectHtml;
  9946. // total price html
  9947. $collectHtml = "";
  9948. $total = 0;
  9949. for($i = 1; $i <= 12; $i ++) {
  9950. $sumPrice = 0;
  9951. foreach ( $itemStatisticsList as $key => $value ) {
  9952. if ($value ['month'] == $i) {
  9953. $sumPrice += $value ['price'];
  9954. }
  9955. }
  9956. if ($sumPrice == 0)
  9957. $collectHtml .= '<td class="taR">-</td>';
  9958. else
  9959. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9960. $total += $sumPrice;
  9961. }
  9962. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9963. $data ['companyTotalHtml'] = $collectHtml;
  9964. $data ['total'] = $total;
  9965. // statistics html
  9966. // echo $cidString;
  9967. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9968. if (empty ( $stList ))
  9969. $stList = array (
  9970. 'rePrice' => 0,
  9971. 'agPrice' => 0
  9972. );
  9973. $data ['stList'] = array (
  9974. 'rePrice' => $stList ['rePrice'],
  9975. 'agPrice' => $stList ['agPrice'],
  9976. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9977. );
  9978. $data ['year'] = $year;
  9979. $data ['memu'] = "receipt";
  9980. $data ['staff'] = $this->staff;
  9981. $data ['receiptMemu'] = 'companyCategoryCollect';
  9982. $data ['verifyId'] = $this->verifyId;
  9983. $data ['executeId'] = $this->executeId;
  9984. $dateHtml = "";
  9985. $now = date ( "Y" );
  9986. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9987. if ($YEARD <= $now) {
  9988. $dateHtml .= '<option ';
  9989. if ($year == $YEARD) {
  9990. $dateHtml .= 'selected ';
  9991. }
  9992. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9993. }
  9994. }
  9995. $data ['dateHtml'] = $dateHtml;
  9996. // year staff status 2,4
  9997. if ($year < date ( "Y" )) {
  9998. Doo::loadModel ( 'receipt' );
  9999. $receipt = new receipt ();
  10000. $receiptList = $receipt->find ( array (
  10001. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10002. 'asArray' => true
  10003. ) );
  10004. if (empty ( $receiptList )) {
  10005. ob_start ();
  10006. $this->render ( "/admin/saeaCompanyCollect", $data );
  10007. $this->cacheFile ( $path );
  10008. die ();
  10009. }
  10010. }
  10011. $this->render ( "/admin/saeaCompanyCollect", $data );
  10012. }
  10013. function categoryCollectDetail() {
  10014. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10015. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10016. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10017. $this->showCache ( $path ); */
  10018. Doo::loadModel ( 'statistics' );
  10019. $statistics = new statistics ();
  10020. Doo::loadModel ( "receiptDetail" );
  10021. $receiptDetail = new receiptDetail ();
  10022. Doo::loadModel ( 'L_category' );
  10023. $Lcategory = new L_category ();
  10024. Doo::loadModel ( 'accountItem' );
  10025. $accountItem = new accountItem ();
  10026. Doo::loadModel ( "receiptAuthorityManage" );
  10027. $receiptAuthorityManage = new receiptAuthorityManage ();
  10028. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10029. $cidList = array ();
  10030. foreach ( $imcStaff as $key => $value ) {
  10031. array_push ( $cidList, $value ['cid'] );
  10032. }
  10033. $cidString = implode ( ',', $cidList );
  10034. $LcategoryList = $Lcategory->find ( array (
  10035. 'where' => 'cid in (' . $cidString . ')',
  10036. 'asArray' => true
  10037. ) );
  10038. if ($cid == 0) {
  10039. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10040. if ($cid == 0)
  10041. $cid = $LcategoryList [0] ['cid'];
  10042. }
  10043. $data ['LcategoryList'] = $LcategoryList;
  10044. $receiptCollectList = $receiptDetail->find ( array (
  10045. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10046. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10047. 'groupby' => 'item,Month(pastDate)',
  10048. 'asArray' => true
  10049. ) );
  10050. $accountList = $accountItem->find ( array (
  10051. 'asArray' => true
  10052. ) );
  10053. // create CollectDetail HTML
  10054. $collectHtml = array ();
  10055. foreach ( $accountList as $key => $value ) {
  10056. $html = "";
  10057. $asum = 0;
  10058. for($i = 1; $i <= 12; $i ++) {
  10059. $falg = true;
  10060. foreach ( $receiptCollectList as $v ) {
  10061. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10062. $asum += $v ['price'];
  10063. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10064. $falg = false;
  10065. break;
  10066. }
  10067. }
  10068. if ($falg)
  10069. $html .= '<td class="taR">-</td>';
  10070. }
  10071. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10072. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10073. }
  10074. $data ['collectHtml'] = $collectHtml;
  10075. // create Adjustment price html
  10076. $receiptCollectList = $receiptDetail->find ( array (
  10077. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10078. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10079. 'groupby' => 'itemCategory,Month(pastDate)',
  10080. 'asArray' => true
  10081. ) );
  10082. $adjustment = array ();
  10083. $collectArray = array (
  10084. '日常相关费用' => array (),
  10085. '差旅相关费用' => array (),
  10086. '培训班费用' => array (),
  10087. '内部培训费用'=>array(),
  10088. '其他' => array ()
  10089. );
  10090. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10091. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10092. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10093. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10094. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10095. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10096. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10097. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10098. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10099. array_push ( $collectArray ['其他'], $collectHtml );
  10100. $data ['collectArray'] = $collectArray;
  10101. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10102. array_push ( $adjustment, $collectHtml );
  10103. $data ['adjustment'] = $adjustment;
  10104. // total price html
  10105. $collectHtml = "";
  10106. $total = 0;
  10107. for($i = 1; $i <= 12; $i ++) {
  10108. $sumPrice = 0;
  10109. foreach ( $receiptCollectList as $key => $value ) {
  10110. if ($value ['month'] == $i) {
  10111. $sumPrice += $value ['price'];
  10112. }
  10113. }
  10114. if ($sumPrice == 0)
  10115. $collectHtml .= '<td class="taR">-</td>';
  10116. else
  10117. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10118. $total += $sumPrice;
  10119. }
  10120. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10121. // statistics html
  10122. $stList = $statistics->statisticsByCid ( $year, $cid );
  10123. if (empty ( $stList ))
  10124. $stList = array (
  10125. 'rePrice' => 0,
  10126. 'agPrice' => 0
  10127. );
  10128. $data ['stList'] = array (
  10129. 'rePrice' => $stList ['rePrice'],
  10130. 'agPrice' => $stList ['agPrice'],
  10131. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10132. );
  10133. $data ['totalYear'] = $total;
  10134. $data ['year'] = $year;
  10135. $data ['cid'] = $cid;
  10136. $data ['memu'] = "receipt";
  10137. $data ['staff'] = $this->staff;
  10138. $data ['receiptMemu'] = 'companyCategoryCollect';
  10139. $data ['verifyId'] = $this->verifyId;
  10140. $data ['executeId'] = $this->executeId;
  10141. // year staff status 2,4
  10142. /* if ($year < date ( "Y" )) {
  10143. Doo::loadModel ( 'receipt' );
  10144. $receipt = new receipt ();
  10145. $receiptList = $receipt->find ( array (
  10146. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10147. 'asArray' => true
  10148. ) );
  10149. if (empty ( $receiptList )) {
  10150. ob_start ();
  10151. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10152. $this->cacheFile ( $path );
  10153. die ();
  10154. }
  10155. } */
  10156. $dateHtml = "";
  10157. $now = date ( "Y" );
  10158. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10159. if ($YEARD <= $now) {
  10160. $dateHtml .= '<option ';
  10161. if ($year == $YEARD) {
  10162. $dateHtml .= 'selected ';
  10163. }
  10164. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10165. }
  10166. }
  10167. $data ['dateHtml'] = $dateHtml;
  10168. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10169. }
  10170. function staffCollect() {
  10171. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10172. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10173. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10174. // $this->showCache($path);
  10175. Doo::loadModel ( 'statistics' );
  10176. $statistics = new statistics ();
  10177. Doo::loadModel ( "receiptDetail" );
  10178. $receiptDetail = new receiptDetail ();
  10179. Doo::loadModel ( 'L_category' );
  10180. $Lcategory = new L_category ();
  10181. Doo::loadModel ( 'accountItem' );
  10182. $accountItem = new accountItem ();
  10183. Doo::loadModel ( 'staff' );
  10184. $staff = new staff ();
  10185. Doo::loadModel ( 'itemStatistics' );
  10186. $itemStatistics = new itemStatistics ();
  10187. Doo::loadModel ( "receiptAuthorityManage" );
  10188. $receiptAuthorityManage = new receiptAuthorityManage ();
  10189. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10190. $cidList = array ();
  10191. foreach ( $imcStaff as $key => $value ) {
  10192. array_push ( $cidList, $value ['cid'] );
  10193. }
  10194. $cidString = implode ( ',', $cidList );
  10195. $naturecon='';
  10196. if ($nature=='ONJOB'){
  10197. $naturecon=' and (nature!=4 )';
  10198. }elseif($nature=='LEAVEJOB'){
  10199. $naturecon=' and (nature=4 )';
  10200. }else{
  10201. die ( 'illegal request--nature' );
  10202. }
  10203. // statistics html
  10204. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10205. if (empty ( $stList ))
  10206. $stList = array (
  10207. 'rePrice' => 0,
  10208. 'agPrice' => 0
  10209. );
  10210. $data ['stList'] = array (
  10211. 'rePrice' => $stList ['rePrice'],
  10212. 'agPrice' => $stList ['agPrice'],
  10213. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10214. );
  10215. // ---
  10216. $staffList = $staff->find ( array (
  10217. 'where' => 'username !="admin" '.$naturecon,
  10218. 'asArray' => true
  10219. ) );
  10220. $LcategoryList = $Lcategory->find ( array (
  10221. 'asArray' => true
  10222. ) ); // 'staff='.$this->staff[0]['sid']." and
  10223. $itemStatisticsList = $itemStatistics->find ( array (
  10224. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10225. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10226. 'groupby' => 'staff,Month(date)',
  10227. 'asArray' => true
  10228. ) );
  10229. $categoryList = $staff->find ( array (
  10230. 'select' => 'COUNT(*) as count,cid,category',
  10231. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10232. 'groupby' => 'cid',
  10233. 'asArray' => true
  10234. ) );
  10235. // print_r($itemStatisticsList);die;
  10236. // ceatre companyCollectHtml
  10237. foreach ( $categoryList as $vlu ) {
  10238. $count = $vlu ['count'] + 1;
  10239. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10240. $m1 = 0;
  10241. $m2 = 0;
  10242. $m3 = 0;
  10243. $m4 = 0;
  10244. $m5 = 0;
  10245. $m6 = 0;
  10246. $m7 = 0;
  10247. $m8 = 0;
  10248. $m9 = 0;
  10249. $m10 = 0;
  10250. $m11 = 0;
  10251. $m12 = 0;
  10252. $m13 = 0;
  10253. foreach ( $staffList as $value ) {
  10254. if ($vlu ['cid'] == $value ['cid']) {
  10255. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10256. $asum = 0;
  10257. for($i = 1; $i <= 12; $i ++) {
  10258. $falg = true;
  10259. foreach ( $itemStatisticsList as $v ) {
  10260. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10261. if ($v ['month'] == 1)
  10262. $m1 += $v ['price'];
  10263. if ($v ['month'] == 2)
  10264. $m2 += $v ['price'];
  10265. if ($v ['month'] == 3)
  10266. $m3 += $v ['price'];
  10267. if ($v ['month'] == 4)
  10268. $m4 += $v ['price'];
  10269. if ($v ['month'] == 5)
  10270. $m5 += $v ['price'];
  10271. if ($v ['month'] == 6)
  10272. $m6 += $v ['price'];
  10273. if ($v ['month'] == 7)
  10274. $m7 += $v ['price'];
  10275. if ($v ['month'] == 8)
  10276. $m8 += $v ['price'];
  10277. if ($v ['month'] == 9)
  10278. $m9 += $v ['price'];
  10279. if ($v ['month'] == 10)
  10280. $m10 += $v ['price'];
  10281. if ($v ['month'] == 11)
  10282. $m11 += $v ['price'];
  10283. if ($v ['month'] == 12)
  10284. $m12 += $v ['price'];
  10285. $asum += $v ['price'];
  10286. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10287. $falg = false;
  10288. break;
  10289. }
  10290. }
  10291. if ($falg)
  10292. $html .= '<td class="taR">-</td>';
  10293. }
  10294. $m13 += $asum;
  10295. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10296. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10297. 'html' => $html,
  10298. 'sid' => $value ['sid']
  10299. );
  10300. $html = "";
  10301. }
  10302. }
  10303. $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>
  10304. <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>
  10305. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10306. $collectHtml [$vlu ['cid']] = array (
  10307. 'html' => $hl,
  10308. 'sid' => ''
  10309. );
  10310. }
  10311. $data ['companyHtml'] = $collectHtml;
  10312. // total price html
  10313. $collectHtml = "";
  10314. $total = 0;
  10315. for($i = 1; $i <= 12; $i ++) {
  10316. $sumPrice = 0;
  10317. foreach ( $itemStatisticsList as $key => $value ) {
  10318. if ($value ['month'] == $i) {
  10319. $sumPrice += $value ['price'];
  10320. }
  10321. }
  10322. if ($sumPrice == 0)
  10323. $collectHtml .= '<td class="taR">-</td>';
  10324. else
  10325. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10326. $total += $sumPrice;
  10327. }
  10328. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10329. $data ['companyTotalHtml'] = $collectHtml;
  10330. $data ['total'] = $total;
  10331. $data ['nature'] =$nature;
  10332. $data ['year'] = $year;
  10333. $data ['memu'] = "receipt";
  10334. $data ['staff'] = $this->staff;
  10335. $data ['receiptMemu'] = 'companyCategoryCollect';
  10336. $data ['verifyId'] = $this->verifyId;
  10337. $data ['executeId'] = $this->executeId;
  10338. if ($year <= date ( "Y" )) {
  10339. Doo::loadModel ( 'receipt' );
  10340. $receipt = new receipt ();
  10341. $receiptList = $receipt->find ( array (
  10342. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10343. 'asArray' => true
  10344. ) );
  10345. if (empty ( $receiptList )) { // generated files
  10346. ob_start ();
  10347. $this->render ( "/admin/saeaStaffCollectB", $data );
  10348. $this->cacheFile ( $path );
  10349. die ();
  10350. }
  10351. }
  10352. $this->render ( "/admin/saeaStaffCollectB", $data );
  10353. }
  10354. function staffCollectBak() {
  10355. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10356. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10357. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10358. $this->showCache ( $path );
  10359. Doo::loadModel ( 'statistics' );
  10360. $statistics = new statistics ();
  10361. Doo::loadModel ( "receiptDetail" );
  10362. $receiptDetail = new receiptDetail ();
  10363. Doo::loadModel ( 'L_category' );
  10364. $Lcategory = new L_category ();
  10365. Doo::loadModel ( 'accountItem' );
  10366. $accountItem = new accountItem ();
  10367. Doo::loadModel ( 'staff' );
  10368. $staff = new staff ();
  10369. Doo::loadModel ( 'itemStatistics' );
  10370. $itemStatistics = new itemStatistics ();
  10371. $itemStatisticsList = $itemStatistics->find ( array (
  10372. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10373. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10374. 'groupby' => 'staff,itemCategory,Month(date)',
  10375. 'asArray' => true
  10376. ) );
  10377. $itemCategoryList = $itemStatistics->find ( array (
  10378. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10379. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10380. 'groupby' => 'cid,itemCategory,Month(date)',
  10381. 'asArray' => true
  10382. ) );
  10383. $LcategoryList = $Lcategory->find ( array (
  10384. 'asArray' => true
  10385. ) );
  10386. $staffList = $staff->find ( array (
  10387. 'asArray' => true
  10388. ) );
  10389. $htmlArray = array ();
  10390. foreach ( $LcategoryList as $value ) {
  10391. $htmlArray [$value ['title']] = array ();
  10392. foreach ( $staffList as $v ) {
  10393. if ($value ['cid'] == $v ['cid']) {
  10394. $html = "";
  10395. $falg = true;
  10396. $staffSumPrice = 0;
  10397. foreach ( $itemStatisticsList as $a ) {
  10398. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10399. if (empty ( $a ['price'] )) {
  10400. $html .= '<td class="taR">-</td>';
  10401. $falg = false;
  10402. break;
  10403. } else {
  10404. $staffSumPrice += $a ['price'];
  10405. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10406. $falg = false;
  10407. break;
  10408. }
  10409. }
  10410. }
  10411. if ($falg) {
  10412. $html .= '<td class="taR">-</td>';
  10413. $falg = true;
  10414. }
  10415. $falg = true;
  10416. foreach ( $itemStatisticsList as $a ) {
  10417. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10418. if (empty ( $a ['price'] )) {
  10419. $html .= '<td class="taR">-</td>';
  10420. $falg = false;
  10421. break;
  10422. } else {
  10423. $staffSumPrice += $a ['price'];
  10424. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10425. $falg = false;
  10426. break;
  10427. }
  10428. }
  10429. }
  10430. if ($falg) {
  10431. $html .= '<td class="taR">-</td>';
  10432. $falg = true;
  10433. }
  10434. $falg = true;
  10435. foreach ( $itemStatisticsList as $a ) {
  10436. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10437. if (empty ( $a ['price'] )) {
  10438. $html .= '<td class="taR">-</td>';
  10439. $falg = false;
  10440. break;
  10441. } else {
  10442. $staffSumPrice += $a ['price'];
  10443. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10444. $falg = false;
  10445. break;
  10446. }
  10447. }
  10448. }
  10449. if ($falg) {
  10450. $html .= '<td class="taR">-</td>';
  10451. $falg = true;
  10452. }
  10453. $falg = true;
  10454. foreach ( $itemStatisticsList as $a ) {
  10455. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10456. if (! empty ( $a ['price'] )) {
  10457. $staffSumPrice += $a ['price'];
  10458. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10459. $falg = false;
  10460. break;
  10461. } else {
  10462. $html .= '<td class="taR">-</td>';
  10463. $falg = false;
  10464. break;
  10465. }
  10466. }
  10467. }
  10468. if ($falg) {
  10469. $html .= '<td class="taR">-</td>';
  10470. $falg = true;
  10471. }
  10472. $falg = true;
  10473. foreach ( $itemStatisticsList as $a ) {
  10474. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10475. if (! empty ( $a ['price'] )) {
  10476. $staffSumPrice += $a ['price'];
  10477. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10478. $falg = false;
  10479. break;
  10480. } else {
  10481. $html .= '<td class="taR">-</td>';
  10482. $falg = false;
  10483. break;
  10484. }
  10485. }
  10486. }
  10487. if ($falg) {
  10488. $html .= '<td class="taR">-</td>';
  10489. $falg = true;
  10490. }
  10491. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10492. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10493. }
  10494. }
  10495. /* -- --- */
  10496. // 合计费用
  10497. $cateHtml = "";
  10498. $catePrice = 0;
  10499. $cateFalg = true;
  10500. foreach ( $itemCategoryList as $l ) {
  10501. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10502. if (empty ( $l ['price'] )) {
  10503. $cateHtml .= '<td class="colGreen taR">-</td>';
  10504. $cateFalg = false;
  10505. break;
  10506. } else {
  10507. $catePrice += $l ['price'];
  10508. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10509. $cateFalg = false;
  10510. break;
  10511. }
  10512. }
  10513. }
  10514. if ($cateFalg) {
  10515. $cateHtml .= '<td class="colGreen taR">-</td>';
  10516. $cateFalg = true;
  10517. }
  10518. $cateFalg = true;
  10519. foreach ( $itemCategoryList as $l ) {
  10520. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10521. if (empty ( $l ['price'] )) {
  10522. $cateHtml .= '<td class="colGreen taR">-</td>';
  10523. $cateFalg = false;
  10524. break;
  10525. } else {
  10526. $catePrice += $l ['price'];
  10527. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10528. $cateFalg = false;
  10529. break;
  10530. }
  10531. }
  10532. }
  10533. if ($cateFalg) {
  10534. $cateHtml .= '<td class="colGreen taR">-</td>';
  10535. $cateFalg = true;
  10536. }
  10537. $cateFalg = true;
  10538. foreach ( $itemCategoryList as $l ) {
  10539. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10540. if (empty ( $l ['price'] )) {
  10541. $cateHtml .= '<td class="colGreen taR">-</td>';
  10542. $cateFalg = false;
  10543. break;
  10544. } else {
  10545. $catePrice += $l ['price'];
  10546. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10547. $cateFalg = false;
  10548. break;
  10549. }
  10550. }
  10551. }
  10552. if ($cateFalg) {
  10553. $cateHtml .= '<td class="colGreen taR">-</td>';
  10554. $cateFalg = true;
  10555. }
  10556. $cateFalg = true;
  10557. foreach ( $itemCategoryList as $l ) {
  10558. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10559. if (empty ( $l ['price'] )) {
  10560. $cateHtml .= '<td class="colGreen taR">-</td>';
  10561. $cateFalg = false;
  10562. break;
  10563. } else {
  10564. $catePrice += $l ['price'];
  10565. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10566. $cateFalg = false;
  10567. break;
  10568. }
  10569. }
  10570. }
  10571. if ($cateFalg) {
  10572. $cateHtml .= '<td class="colGreen taR">-</td>';
  10573. $cateFalg = true;
  10574. }
  10575. $cateFalg = true;
  10576. foreach ( $itemCategoryList as $l ) {
  10577. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10578. if (empty ( $l ['price'] )) {
  10579. $cateHtml .= '<td class="colGreen taR">-</td>';
  10580. $cateFalg = false;
  10581. break;
  10582. } else {
  10583. $catePrice += $l ['price'];
  10584. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10585. $cateFalg = false;
  10586. break;
  10587. }
  10588. }
  10589. }
  10590. if ($cateFalg) {
  10591. $cateHtml .= '<td class="colGreen taR">-</td>';
  10592. $cateFalg = true;
  10593. }
  10594. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10595. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10596. /* -- --- */
  10597. }
  10598. // print_r($htmlArray);die;
  10599. $data ['htmlArray'] = $htmlArray;
  10600. // statistics html
  10601. $stList = $statistics->getOne ( array (
  10602. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10603. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10604. 'groupby' => 'Month(date)',
  10605. 'asArray' => true
  10606. ) );
  10607. if (empty ( $stList ))
  10608. $stList = array (
  10609. 'rePrice' => 0,
  10610. 'agPrice' => 0
  10611. );
  10612. $data ['stList'] = array (
  10613. 'rePrice' => $stList ['rePrice'],
  10614. 'agPrice' => $stList ['agPrice'],
  10615. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10616. );
  10617. $monthHtml = "";
  10618. for($i = 1; $i <= 12; $i ++) {
  10619. if ($i == $month)
  10620. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10621. else
  10622. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10623. }
  10624. $data ['monthHtml'] = $monthHtml;
  10625. $data ['year'] = $year;
  10626. $data ['month'] = $month;
  10627. $data ['memu'] = "receipt";
  10628. $data ['staff'] = $this->staff;
  10629. $data ['receiptMemu'] = 'companyCategoryCollect';
  10630. $data ['verifyId'] = $this->verifyId;
  10631. $data ['executeId'] = $this->executeId;
  10632. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10633. Doo::loadModel ( 'receipt' );
  10634. $receipt = new receipt ();
  10635. $receiptList = $receipt->find ( array (
  10636. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10637. 'asArray' => true
  10638. ) );
  10639. if (empty ( $receiptList )) { // generated files
  10640. ob_start ();
  10641. $this->render ( "/admin/saeaStaffCollect", $data );
  10642. $this->cacheFile ( $path );
  10643. die ();
  10644. }
  10645. }
  10646. $this->render ( "/admin/saeaStaffCollect", $data );
  10647. }
  10648. /**
  10649. * 日常收支
  10650. */
  10651. function payments() {
  10652. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10653. Doo::loadModel ( "execute" );
  10654. $execute = new execute ();
  10655. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10656. die ( 'illegal request' );
  10657. }
  10658. Doo::loadModel ( "accountBook" );
  10659. $accountBook = new accountBook ();
  10660. Doo::loadModel ( "accountBookStatistics" );
  10661. $accountBookStatistics = new accountBookStatistics ();
  10662. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10663. $list = $accountBook->getAccountBookByLimit ( 10 );
  10664. $data ['date'] = date ( "Y-m-d" );
  10665. $data ['statisticsList'] = $statisticsList;
  10666. $data ['list'] = $list;
  10667. $data ['memu'] = "receipt";
  10668. $data ['staff'] = $this->staff;
  10669. $data ['receiptMemu'] = 'payments';
  10670. $data ['verifyId'] = $this->verifyId;
  10671. $data ['executeId'] = $this->executeId;
  10672. $this->render ( "/expenses/payments", $data );
  10673. }
  10674. function paymentsIncomeDo() {
  10675. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10676. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10677. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10678. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10679. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10680. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10681. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10682. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10683. Doo::loadClass ( 'XDeode' );
  10684. $XDeode = new XDeode ( 5 );
  10685. Doo::loadModel ( "accountBook" );
  10686. Doo::loadModel ( "accountBookStatistics" );
  10687. Doo::loadModel ( 'wasteBook' );
  10688. // 记录流水时银行的转换
  10689. $accountBank = '';
  10690. if ($receivedBank == '纵横广发') {
  10691. $accountBank = 'CGBDeposit';
  10692. } elseif ($receivedBank == '纵横工行') {
  10693. $accountBank = 'ICBCDeposit';
  10694. } elseif ($receivedBank == '华润银行') {
  10695. $accountBank = 'HUADeposit';
  10696. } elseif ($receivedBank == '个人广发') {
  10697. $accountBank = 'PersonalDeposit';
  10698. }
  10699. if (empty ( $accountBank ))
  10700. die ( 'illegal request-bank' );
  10701. //TODO -存款功能 提取
  10702. if($accountType == 11 || $accountType == 12){
  10703. if($accountType == 11){
  10704. $receivedBank = '纵横广发';
  10705. }elseif($accountType == 12){
  10706. $receivedBank = '纵横工行';
  10707. }
  10708. // 添加一条收入
  10709. $accountBook = new accountBook ();
  10710. $accountBook->accountType = $accountType;
  10711. $accountBook->accountMsg = $accountMsg;
  10712. $accountBook->receivedPrice = $receivedPrice;
  10713. $accountBook->receivedMsg = $receivedMsg;
  10714. $accountBook->receivedBank = $receivedBank;
  10715. $accountBook->receivedDate = $receivedDate;
  10716. $accountBook->remarks = $remarks;
  10717. $accountBook->expensesType = 1;
  10718. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10719. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10720. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10721. $inComeId = $accountBook->insert ();
  10722. // 收支汇总-添加一条收入日常汇总
  10723. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10724. $accountBookStatistics = new accountBookStatistics ();
  10725. $item = array (
  10726. 'date' => date ( "Y-m-d" ),
  10727. 'accountType' => $abDetail ['accountType'],
  10728. 'accountMsg' => $abDetail ['accountMsg'],
  10729. 'aid' => $abDetail ['aid'],
  10730. 'inComePrice' => $abDetail ['receivedPrice'],
  10731. 'expensesType' => $abDetail ['expensesType']
  10732. );
  10733. $accountBookStatistics->setAccountBookStatistics ( $item );
  10734. // 添加收入流水
  10735. if($accountType == 11){
  10736. $accountBank = 'CGBDeposit';
  10737. }elseif($accountType == 12){
  10738. $accountBank = 'ICBCDeposit';
  10739. }
  10740. $wasteBook = new wasteBook ();
  10741. $itemWaste = array (
  10742. 'accountPriceShow' => $receivedPrice,
  10743. 'accountPrice' => $receivedPrice,
  10744. 'expensesType' => 1,
  10745. 'accountType' => 6, // 流水类型
  10746. 'dataID' => $inComeId,
  10747. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10748. 'accountBank' => $accountBank,
  10749. 'category' => $this->staff [0] ['category'],
  10750. 'cid' => $this->staff [0] ['cid'],
  10751. 'name' => $this->staff [0] ['username'],
  10752. 'sid' => $this->staff [0] ['sid'],
  10753. 'inputDate' => $receivedDate,
  10754. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10755. 'synPaymentDate'=>1,
  10756. );
  10757. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10758. }
  10759. //TODO --移除理财相关
  10760. // elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10761. // // if ($receivedBank == '个人广发') {
  10762. // // die ( '个人广发 illegal request' );
  10763. // // }
  10764. // // echo $receivedBank;
  10765. // die;
  10766. // // 添加一条收入
  10767. // $accountBook = new accountBook ();
  10768. // $accountBook->accountType = 10;
  10769. // $accountBook->accountMsg = $accountMsg;
  10770. // $accountBook->receivedPrice = $receivedPrice;
  10771. // $accountBook->receivedMsg = $receivedMsg;
  10772. // $accountBook->receivedBank = $receivedBank;
  10773. // $accountBook->receivedDate = $receivedDate;
  10774. // $accountBook->remarks = $remarks;
  10775. // $accountBook->expensesType = 1;
  10776. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10777. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10778. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10779. // $inComeId = $accountBook->insert ();
  10780. // // 收支汇总-添加一条收入日常汇总
  10781. // $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10782. // $accountBookStatistics = new accountBookStatistics ();
  10783. // $item = array (
  10784. // 'date' => date ( "Y-m-d" ),
  10785. // 'accountType' => $abDetail ['accountType'],
  10786. // 'accountMsg' => $abDetail ['accountMsg'],
  10787. // 'aid' => $abDetail ['aid'],
  10788. // 'inComePrice' => $abDetail ['receivedPrice'],
  10789. // 'expensesType' => $abDetail ['expensesType']
  10790. // );
  10791. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10792. // // 添加收入流水
  10793. // $wasteBook = new wasteBook ();
  10794. // $itemWaste = array (
  10795. // 'accountPriceShow' => $receivedPrice,
  10796. // 'accountPrice' => $receivedPrice,
  10797. // 'expensesType' => 1,
  10798. // 'accountType' => 6, // 流水类型
  10799. // 'dataID' => $inComeId,
  10800. // 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10801. // 'accountBank' => $accountBank,
  10802. // 'category' => $this->staff [0] ['category'],
  10803. // 'cid' => $this->staff [0] ['cid'],
  10804. // 'name' => $this->staff [0] ['username'],
  10805. // 'sid' => $this->staff [0] ['sid'],
  10806. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10807. // );
  10808. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10809. // // 添加一条理财支出
  10810. // $accountBank = 'CGBDeposit';
  10811. // $expenditureBank = '纵横广发';
  10812. // if($accountMsg=='个人(GR)'){
  10813. // $expenditureBank = '个人广发';
  10814. // }
  10815. // $dailyExpenditureType = 4;
  10816. // if ($accountType == 9) {
  10817. // $accountBank = 'ICBCDeposit';
  10818. // $expenditureBank = '纵横工行';
  10819. // $dailyExpenditureType = 6;
  10820. // }
  10821. // $accountBook = new accountBook ();
  10822. // $accountBook->expensesType = 2;
  10823. // $accountBook->expenditureType = $dailyExpenditureType;
  10824. // $accountBook->expenditureMsg = $accountMsg;
  10825. // $accountBook->expenditurePrice = $receivedPrice;
  10826. // $accountBook->expenditureBank = $expenditureBank;
  10827. // $accountBook->expenditureDate = $receivedDate;
  10828. // $accountBook->remarks = $remarks;
  10829. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10830. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10831. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10832. // $id = $accountBook->insert ();
  10833. // // 收支汇总-添加一条理财支出汇总
  10834. // $abDetail = $accountBook->getAccountBookByAid ( $id );
  10835. // $accountBookStatistics = new accountBookStatistics ();
  10836. // $item = array (
  10837. // 'date' => date ( "Y-m-d" ),
  10838. // 'accountType' => $abDetail ['accountType'],
  10839. // 'accountMsg' => $abDetail ['accountMsg'],
  10840. // 'aid' => $abDetail ['aid'],
  10841. // 'financingPrice' => - $receivedPrice,
  10842. // 'expensesType' => 3
  10843. // );
  10844. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10845. // //TODO -新增理财为个人时的情况 添加一条支出理财流水
  10846. // $accountTypeWaste = 5;
  10847. // if ($accountMsg == '公司固定') {
  10848. // $accountTypeWaste = 9;
  10849. // } elseif ($accountMsg == '公司活期') {
  10850. // $accountTypeWaste = 10;
  10851. // } elseif ($receivedBank == '个人广发') {
  10852. // $accountTypeWaste = 9;
  10853. // $accountBank = 'ICBCDeposit';
  10854. // }
  10855. // $itemWaste = array (
  10856. // 'expensesType' => 2,
  10857. // 'accountType' => $accountTypeWaste,
  10858. // 'accountPriceShow' => $receivedPrice,
  10859. // 'accountPrice' => - $receivedPrice,
  10860. // 'dataID' => $id,
  10861. // 'dailyExpenditureType' => $dailyExpenditureType,
  10862. // 'accountBank' => $accountBank,
  10863. // 'category' => $this->staff [0] ['category'],
  10864. // 'cid' => $this->staff [0] ['cid'],
  10865. // 'name' => $this->staff [0] ['username'],
  10866. // 'sid' => $this->staff [0] ['sid'],
  10867. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10868. // );
  10869. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10870. // }
  10871. elseif ($accountType == 1) {
  10872. // if ($receivedBank == '个人广发')
  10873. // die ( 'illegal request--no man' );
  10874. // 添加一条收入
  10875. $accountBook = new accountBook ();
  10876. $accountBook->accountType = $accountType;
  10877. $accountBook->accountMsg = $accountMsg;
  10878. $accountBook->receivedPrice = $receivedPrice;
  10879. $accountBook->receivedMsg = $receivedMsg;
  10880. $accountBook->receivedBank = $receivedBank;
  10881. $accountBook->receivedDate = $receivedDate;
  10882. $accountBook->remarks = $remarks;
  10883. $accountBook->expensesType = 1;
  10884. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10885. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10886. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10887. $id = $accountBook->insert ();
  10888. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10889. // 收支汇总-添加一条收入日常汇总
  10890. $accountBookStatistics = new accountBookStatistics ();
  10891. $item = array (
  10892. 'date' => date ( "Y-m-d" ),
  10893. 'accountType' => $abDetail ['accountType'],
  10894. 'accountMsg' => $abDetail ['accountMsg'],
  10895. 'aid' => $abDetail ['aid'],
  10896. 'expensesType' => $abDetail ['expensesType']
  10897. );
  10898. if ($abDetail ['accountType'] == 8) {
  10899. $item += array (
  10900. 'inComePrice' => $abDetail ['receivedPrice']
  10901. );
  10902. } else {
  10903. $item += array (
  10904. 'inComePrice' => $abDetail ['receivedPrice']
  10905. );
  10906. }
  10907. $accountBookStatistics->setAccountBookStatistics ( $item );
  10908. // 流水存储方向
  10909. $itemWaste = array (
  10910. 'accountType' => 6
  10911. ); // 流水类型
  10912. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10913. // }else
  10914. if ($accountMsg == '活期理财收益') {
  10915. $itemWaste = array (
  10916. 'accountType' => 10
  10917. ); // 流水类型
  10918. }
  10919. // 添加收入流水
  10920. $wasteBook = new wasteBook ();
  10921. $itemWaste += array (
  10922. 'accountPrice' => $receivedPrice,
  10923. 'accountPriceShow' => $receivedPrice,
  10924. 'expensesType' => 1,
  10925. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10926. 'dataID' => $id,
  10927. 'accountBank' => $accountBank,
  10928. 'category' => $this->staff [0] ['category'],
  10929. 'cid' => $this->staff [0] ['cid'],
  10930. 'name' => $this->staff [0] ['username'],
  10931. 'sid' => $this->staff [0] ['sid'],
  10932. 'inputDate' => $receivedDate,
  10933. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10934. 'synPaymentDate'=>1,
  10935. );
  10936. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10937. } else { // 普通日常收入处理
  10938. // 添加一条收入
  10939. $accountBook = new accountBook ();
  10940. $accountBook->accountType = $accountType;
  10941. $accountBook->accountMsg = $accountMsg;
  10942. $accountBook->receivedPrice = $receivedPrice;
  10943. $accountBook->receivedMsg = $receivedMsg;
  10944. $accountBook->receivedBank = $receivedBank;
  10945. $accountBook->receivedDate = $receivedDate;
  10946. $accountBook->remarks = $remarks;
  10947. $accountBook->expensesType = 1;
  10948. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10949. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10950. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10951. $id = $accountBook->insert ();
  10952. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10953. // 收支汇总-添加一条收入日常汇总
  10954. $accountBookStatistics = new accountBookStatistics ();
  10955. $item = array (
  10956. 'date' => date ( "Y-m-d" ),
  10957. 'accountType' => $abDetail ['accountType'],
  10958. 'accountMsg' => $abDetail ['accountMsg'],
  10959. 'aid' => $abDetail ['aid'],
  10960. 'expensesType' => $abDetail ['expensesType']
  10961. );
  10962. if ($abDetail ['accountType'] == 8) {
  10963. $item += array (
  10964. 'inComePrice' => $abDetail ['receivedPrice']
  10965. );
  10966. } else {
  10967. $item += array (
  10968. 'inComePrice' => $abDetail ['receivedPrice']
  10969. );
  10970. }
  10971. $accountBookStatistics->setAccountBookStatistics ( $item );
  10972. // 添加收入流水
  10973. // $itemWaste = array (
  10974. // 'accountPrice' => $receivedPrice
  10975. // );
  10976. // if ($receivedBank == '个人广发') {
  10977. // $itemWaste = array (
  10978. // 'accountPrice' => - $receivedPrice
  10979. // );
  10980. // }
  10981. $wasteBook = new wasteBook ();
  10982. $itemWaste = array (
  10983. 'accountPriceShow' => $receivedPrice,
  10984. 'accountPrice' => $receivedPrice,
  10985. 'expensesType' => 1,
  10986. 'accountType' => 6, // 流水类型
  10987. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10988. 'dataID' => $id,
  10989. 'accountBank' => $accountBank,
  10990. 'category' => $this->staff [0] ['category'],
  10991. 'cid' => $this->staff [0] ['cid'],
  10992. 'name' => $this->staff [0] ['username'],
  10993. 'sid' => $this->staff [0] ['sid'],
  10994. 'inputDate' => $receivedDate,
  10995. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10996. 'synPaymentDate'=>1,
  10997. );
  10998. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10999. }
  11000. }
  11001. return '/payments';
  11002. }
  11003. function paymentsExpenditureDo() {
  11004. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11005. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11006. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11007. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11008. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11009. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11010. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11011. // 理财支出特殊处理
  11012. Doo::loadModel ( "accountBook" );
  11013. Doo::loadModel ( "accountBookStatistics" );
  11014. Doo::loadModel ( 'wasteBook' );
  11015. $accountBank = '';
  11016. if ($expenditureBank == '纵横广发') {
  11017. $accountBank = 'CGBDeposit';
  11018. } elseif ($expenditureBank == '纵横工行') {
  11019. $accountBank = 'ICBCDeposit';
  11020. } elseif ($expenditureBank == '华润银行') {
  11021. $accountBank = 'HUADeposit';
  11022. } elseif ($expenditureBank == '个人广发') {
  11023. $accountBank = 'PersonalDeposit';
  11024. }
  11025. if (empty ( $accountBank ))
  11026. die ( 'illegal request' );
  11027. if($expenditureType == 8 || $expenditureType == 9){
  11028. // if($expenditureType == 8 ){
  11029. // $expenditureBank='纵横广发';
  11030. // }elseif($expenditureType == 9){
  11031. // $expenditureBank='纵横工行';
  11032. // }
  11033. // // 添加一笔日常支出
  11034. // $accountBook = new accountBook ();
  11035. // $accountBook->expensesType = 2;
  11036. // $accountBook->expenditureType = $expenditureType;
  11037. // $accountBook->expenditureMsg = $expenditureMsg;
  11038. // $accountBook->expenditurePrice = $expenditurePrice;
  11039. // $accountBook->expenditureBank = $expenditureBank;
  11040. // $accountBook->expenditureDate = $expenditureDate;
  11041. // $accountBook->remarks = $remarks;
  11042. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11043. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11044. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11045. // $expenditureId = $accountBook->insert ();
  11046. // // 添加日常支出汇总
  11047. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11048. // $accountBookStatistics = new accountBookStatistics ();
  11049. // $item = array (
  11050. // 'date' => date ( "Y-m-d" ),
  11051. // 'expenditureType' => $abDetail ['expenditureType'],
  11052. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11053. // 'aid' => $abDetail ['aid'],
  11054. // 'payPrice' => $abDetail ['expenditurePrice'],
  11055. // 'expensesType' => $abDetail ['expensesType']
  11056. // );
  11057. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11058. // // 公司日常支出流水
  11059. // if($expenditureType == 8 ){
  11060. // $accountBank = 'CGBDeposit';
  11061. // }elseif($expenditureType == 9){
  11062. // $accountBank = 'ICBCDeposit';
  11063. // }
  11064. // if($accountBank=='CGBDeposit'){
  11065. // $dailyExpenditureType='8';
  11066. // }elseif($accountBank=='ICBCDeposit'){
  11067. // $dailyExpenditureType='9';
  11068. // }elseif($accountBank=='PersonalDeposit'){
  11069. // $dailyExpenditureType='10';
  11070. // }elseif($accountBank=='HUADeposit'){
  11071. // $dailyExpenditureType='11';
  11072. // }
  11073. // $wasteBook = new wasteBook ();
  11074. // $itemWaste = array (
  11075. // 'expensesType' => 2,
  11076. // 'accountType' => 5,
  11077. // 'dailyExpenditureType' => $dailyExpenditureType,
  11078. // 'accountPriceShow' => $expenditurePrice,
  11079. // 'accountPrice' => - $expenditurePrice,
  11080. // 'dataID' => $expenditureId,
  11081. // 'accountBank' => $accountBank,
  11082. // 'category' => $this->staff [0] ['category'],
  11083. // 'cid' => $this->staff [0] ['cid'],
  11084. // 'name' => $this->staff [0] ['username'],
  11085. // 'sid' => $this->staff [0] ['sid'],
  11086. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11087. // );
  11088. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11089. //TODO 日常支出 个人理财情况的相关修改
  11090. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11091. // if ($expenditureBank == '个人广发') {
  11092. // die ( '个人广发 illegal request' );
  11093. // }
  11094. // echo $expenditureMsg;
  11095. die;
  11096. // // 添加一笔日常支出
  11097. // $accountBook = new accountBook ();
  11098. // $accountBook->expensesType = 2;
  11099. // $accountBook->expenditureType = 7;
  11100. // $accountBook->expenditureMsg = $expenditureMsg;
  11101. // $accountBook->expenditurePrice = $expenditurePrice;
  11102. // $accountBook->expenditureBank = $expenditureBank;
  11103. // $accountBook->expenditureDate = $expenditureDate;
  11104. // $accountBook->remarks = $remarks;
  11105. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11106. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11107. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11108. // $expenditureId = $accountBook->insert ();
  11109. // // 添加日常支出汇总
  11110. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11111. // $accountBookStatistics = new accountBookStatistics ();
  11112. // $item = array (
  11113. // 'date' => date ( "Y-m-d" ),
  11114. // 'expenditureType' => $abDetail ['expenditureType'],
  11115. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11116. // 'aid' => $abDetail ['aid'],
  11117. // 'payPrice' => $abDetail ['expenditurePrice'],
  11118. // 'expensesType' => $abDetail ['expensesType']
  11119. // );
  11120. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11121. // // 公司日常支出流水
  11122. // $wasteBook = new wasteBook ();
  11123. // $itemWaste = array (
  11124. // 'accountPrice' => - $expenditurePrice
  11125. // );
  11126. // if($expenditureMsg!='个人(GR)'){
  11127. // if ($expenditureBank == '个人广发') {
  11128. // $itemWaste = array (
  11129. // 'accountPrice' => $expenditurePrice
  11130. // );
  11131. // }
  11132. // }
  11133. // $itemWaste += array (
  11134. // 'expensesType' => 2,
  11135. // 'accountType' => 5,
  11136. // 'dailyExpenditureType' => $expenditureType,
  11137. // 'accountPriceShow' => $expenditurePrice,
  11138. // 'accountPrice' => - $expenditurePrice,
  11139. // 'dataID' => $expenditureId,
  11140. // 'accountBank' => $accountBank,
  11141. // 'category' => $this->staff [0] ['category'],
  11142. // 'cid' => $this->staff [0] ['cid'],
  11143. // 'name' => $this->staff [0] ['username'],
  11144. // 'sid' => $this->staff [0] ['sid'],
  11145. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11146. // );
  11147. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11148. // // 添加一笔理财收入
  11149. // $accountBank = 'CGBDeposit';
  11150. // $dailyIncomeType = 7;
  11151. // $receivedBank = '纵横广发';
  11152. // if ($expenditureType == 6) {
  11153. // $accountBank = 'ICBCDeposit';
  11154. // $receivedBank = '纵横工行';
  11155. // $dailyIncomeType = 9;
  11156. // }elseif($expenditureMsg=='个人(GR)'){
  11157. // $receivedBank = '个人广发';
  11158. // }
  11159. // $accountBook = new accountBook ();
  11160. // $accountBook->expensesType = 1;
  11161. // $accountBook->accountType = $dailyIncomeType;
  11162. // $accountBook->accountMsg = $expenditureMsg;
  11163. // $accountBook->receivedPrice = $expenditurePrice;
  11164. // $accountBook->receivedBank = $receivedBank;
  11165. // $accountBook->receivedDate = $expenditureDate;
  11166. // $accountBook->remarks = $remarks;
  11167. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11168. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11169. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11170. // $id = $accountBook->insert ();
  11171. // // 添加日常理财收入汇总
  11172. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11173. // $accountBookStatistics = new accountBookStatistics ();
  11174. // $item = array (
  11175. // 'date' => date ( "Y-m-d" ),
  11176. // 'expenditureType' => $abDetail ['expenditureType'],
  11177. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11178. // 'aid' => $abDetail ['aid'],
  11179. // 'financingPrice' => $expenditurePrice,
  11180. // 'expensesType' => 3
  11181. // );
  11182. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11183. // //TODO 修改理财收入 添加一笔收入流水
  11184. // if ($expenditureMsg == '公司固定') {
  11185. // $accountTypeWaste = 9;
  11186. // } elseif ($expenditureMsg == '公司活期') {
  11187. // $accountTypeWaste = 10;
  11188. // } elseif ($expenditureMsg == '个人(GR)') {
  11189. // $accountTypeWaste = 9;
  11190. // $accountBank = 'ICBCDeposit';
  11191. // }
  11192. // $itemWaste = array (
  11193. // 'expensesType' => 1,
  11194. // 'accountType' => $accountTypeWaste,
  11195. // 'accountPriceShow' => $expenditurePrice,
  11196. // 'accountPrice' => $expenditurePrice,
  11197. // 'dataID' => $id,
  11198. // 'dailyIncomeType' => $dailyIncomeType,
  11199. // 'accountBank' => $accountBank,
  11200. // 'category' => $this->staff [0] ['category'],
  11201. // 'cid' => $this->staff [0] ['cid'],
  11202. // 'name' => $this->staff [0] ['username'],
  11203. // 'sid' => $this->staff [0] ['sid'],
  11204. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11205. // );
  11206. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11207. } else {
  11208. // 添加一笔日常支出
  11209. $accountBook = new accountBook ();
  11210. $accountBook->expensesType = 2;
  11211. $accountBook->expenditureType = $expenditureType;
  11212. $accountBook->expenditureMsg = $expenditureMsg;
  11213. $accountBook->expenditurePrice = $expenditurePrice;
  11214. $accountBook->expenditureBank = $expenditureBank;
  11215. $accountBook->expenditureDate = $expenditureDate;
  11216. $accountBook->remarks = $remarks;
  11217. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11218. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11219. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11220. $id = $accountBook->insert ();
  11221. // 添加日常支出汇总
  11222. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11223. $accountBookStatistics = new accountBookStatistics ();
  11224. $item = array (
  11225. 'date' => date ( "Y-m-d" ),
  11226. 'expenditureType' => $abDetail ['expenditureType'],
  11227. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11228. 'aid' => $abDetail ['aid'],
  11229. 'expensesType' => $abDetail ['expensesType']
  11230. );
  11231. if ($expenditureType == 5) {
  11232. $item += array (
  11233. 'payPrice' => - $abDetail ['expenditurePrice']
  11234. );
  11235. } else {
  11236. $item += array (
  11237. 'payPrice' => $abDetail ['expenditurePrice']
  11238. );
  11239. }
  11240. $accountBookStatistics->setAccountBookStatistics ( $item );
  11241. // 公司日常支出流水
  11242. $wasteBook = new wasteBook ();
  11243. $itemWaste = array (
  11244. 'accountPrice' => - $expenditurePrice
  11245. );
  11246. if ($expenditureBank == '个人广发') {
  11247. $itemWaste = array (
  11248. 'accountPrice' => $expenditurePrice
  11249. );
  11250. }
  11251. $itemWaste += array (
  11252. 'expensesType' => 2,
  11253. 'accountType' => 5,
  11254. 'accountPriceShow' => $expenditurePrice,
  11255. 'dataID' => $id,
  11256. 'dailyExpenditureType' => $expenditureType,
  11257. 'accountBank' => $accountBank,
  11258. 'category' => $this->staff [0] ['category'],
  11259. 'cid' => $this->staff [0] ['cid'],
  11260. 'name' => $this->staff [0] ['username'],
  11261. 'sid' => $this->staff [0] ['sid'],
  11262. 'inputDate' => date ( "Y-m-d H:i:s" )
  11263. );
  11264. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11265. }
  11266. }
  11267. return '/payments';
  11268. }
  11269. /**
  11270. * 添加支出
  11271. */
  11272. function paymentsExpenditureDo_() {
  11273. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11274. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11275. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11276. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11277. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11278. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11279. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11280. $dailyExpenditureType = '';
  11281. $accountTypeWaste = 5;
  11282. $accountBank = '';
  11283. if ($expenditureBank == '纵横广发') {
  11284. $accountBank = 'CGBDeposit';
  11285. } elseif ($expenditureBank == '纵横工行') {
  11286. $accountBank = 'ICBCDeposit';
  11287. } elseif ($expenditureBank == '华润银行') {
  11288. $accountBank = 'HUADeposit';
  11289. } elseif ($expenditureBank == '个人广发') {
  11290. $accountBank = 'PersonalDeposit';
  11291. }
  11292. if (empty ( $accountBank ))
  11293. die ( 'illegal request' );
  11294. $itemWaste = array (
  11295. 'accountPrice' => - $expenditurePrice
  11296. );
  11297. if ($expenditureBank == '个人广发') {
  11298. $itemWaste = array (
  11299. 'accountPrice' => $expenditurePrice
  11300. );
  11301. }
  11302. if ($expenditureType == 4 || $expenditureType == 6) {
  11303. $dailyExpenditureType = 4;
  11304. if ($expenditureMsg == '公司固定') {
  11305. $accountTypeWaste = 9;
  11306. } elseif ($expenditureMsg == '公司活期') {
  11307. $accountTypeWaste = 10;
  11308. } elseif ($expenditureMsg == '个人(GR)') {
  11309. $accountBank = 'PersonalDeposit';
  11310. }
  11311. $itemWaste = array (
  11312. 'accountPrice' => $expenditurePrice
  11313. );
  11314. } elseif ($expenditureType == 1) {
  11315. $dailyExpenditureType = 1;
  11316. } elseif ($expenditureType == 2) {
  11317. $dailyExpenditureType = 2;
  11318. } elseif ($expenditureType == 3) {
  11319. $dailyExpenditureType = 3;
  11320. } elseif ($expenditureType == 5) {
  11321. $dailyExpenditureType = 5;
  11322. }
  11323. if (empty ( $dailyExpenditureType ))
  11324. die ( 'illegal request' );
  11325. Doo::loadModel ( "accountBook" );
  11326. $accountBook = new accountBook ();
  11327. $accountBook->expenditureType = $expenditureType;
  11328. $accountBook->expenditureMsg = $expenditureMsg;
  11329. $accountBook->expenditurePrice = $expenditurePrice;
  11330. $accountBook->expenditureBank = $expenditureBank;
  11331. $accountBook->expenditureDate = $expenditureDate;
  11332. $accountBook->remarks = $remarks;
  11333. $accountBook->expensesType = 2;
  11334. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11335. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11336. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11337. $id = $accountBook->insert ();
  11338. //
  11339. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11340. Doo::loadModel ( "accountBookStatistics" );
  11341. $accountBookStatistics = new accountBookStatistics ();
  11342. $item = array (
  11343. 'date' => date ( "Y-m-d" ),
  11344. 'expenditureType' => $abDetail ['expenditureType'],
  11345. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11346. 'aid' => $abDetail ['aid']
  11347. );
  11348. if ($abDetail ['expensesType'] == 2) {
  11349. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11350. $item += array (
  11351. 'financingPrice' => $expenditurePrice,
  11352. 'expensesType' => 3
  11353. );
  11354. } elseif ($abDetail ['expenditureType'] == 5) {
  11355. $item += array (
  11356. 'payPrice' => $abDetail ['expenditurePrice'],
  11357. 'expensesType' => $abDetail ['expensesType']
  11358. );
  11359. } else {
  11360. $item += array (
  11361. 'payPrice' => $abDetail ['expenditurePrice'],
  11362. 'expensesType' => $abDetail ['expensesType']
  11363. );
  11364. }
  11365. }
  11366. $accountBookStatistics->setAccountBookStatistics ( $item );
  11367. // 公司流水记录
  11368. Doo::loadModel ( 'wasteBook' );
  11369. $wasteBook = new wasteBook ();
  11370. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11371. // 银行
  11372. if (empty ( $abDetail )) {
  11373. $itemWaste += array (
  11374. 'accountPriceShow' => $expenditurePrice,
  11375. 'dataID' => $id,
  11376. 'expensesType' => 2,
  11377. 'accountType' => $accountTypeWaste,
  11378. 'dailyExpenditureType' => $expenditureType,
  11379. 'accountBank' => $accountBank,
  11380. 'category' => $this->staff [0] ['category'],
  11381. 'cid' => $this->staff [0] ['cid'],
  11382. 'name' => $this->staff [0] ['username'],
  11383. 'sid' => $this->staff [0] ['sid'],
  11384. 'inputDate' => date ( "Y-m-d H:i:s" )
  11385. );
  11386. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11387. }
  11388. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11389. if ($expenditureType == 4 || $expenditureType == 6) {
  11390. $accountBank = 'CGBDeposit';
  11391. $dailyIncomeType = 7;
  11392. $receivedBank = '纵横广发';
  11393. if ($expenditureType == 6) {
  11394. $accountBank = 'ICBCDeposit';
  11395. $receivedBank = '纵横工行';
  11396. $dailyIncomeType = 9;
  11397. }
  11398. // 添加一笔收入
  11399. $accountBook = new accountBook ();
  11400. $accountBook->accountType = $dailyIncomeType;
  11401. $accountBook->accountMsg = $expenditureMsg;
  11402. $accountBook->receivedPrice = $expenditurePrice;
  11403. $accountBook->receivedBank = $receivedBank;
  11404. $accountBook->receivedDate = $expenditureDate;
  11405. $accountBook->remarks = $remarks;
  11406. $accountBook->expensesType = 1;
  11407. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11408. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11409. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11410. $id = $accountBook->insert ();
  11411. // 添加一笔收入流水
  11412. $itemWaste = array (
  11413. 'accountPriceShow' => $expenditurePrice,
  11414. 'accountPrice' => - $expenditurePrice,
  11415. 'dataID' => $id,
  11416. 'expensesType' => 1,
  11417. 'accountType' => $accountTypeWaste,
  11418. 'dailyIncomeType' => $dailyIncomeType,
  11419. 'accountBank' => $accountBank,
  11420. 'category' => $this->staff [0] ['category'],
  11421. 'cid' => $this->staff [0] ['cid'],
  11422. 'name' => $this->staff [0] ['username'],
  11423. 'sid' => $this->staff [0] ['sid'],
  11424. 'inputDate' => date ( "Y-m-d H:i:s" )
  11425. );
  11426. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11427. }
  11428. }
  11429. return '/payments';
  11430. }
  11431. /**
  11432. * 所有收支
  11433. */
  11434. function paymentsAchieve() {
  11435. $page_size = 12;
  11436. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11437. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11438. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11439. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11440. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11441. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11442. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11443. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11444. Doo::loadModel ( "accountBookStatistics" );
  11445. $accountBookStatistics = new accountBookStatistics ();
  11446. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11447. $data ['statisticsList'] = $statisticsList;
  11448. Doo::loadModel ( "accountBook" );
  11449. $accountBook = new accountBook ();
  11450. $con = '';
  11451. if ($expensesType == 'INCOME')
  11452. $con = ' and expensesType=1 ';
  11453. elseif ($expensesType == 'PAY')
  11454. $con = ' and expensesType=2 ';
  11455. $dateArr = explode ( ':', $date );
  11456. $D1 = $dateString = '';
  11457. $D2 = '';
  11458. if (! empty ( $date )) {
  11459. $D1 = $dateArr [0];
  11460. if (isset ( $dateArr [1] ))
  11461. $D2 = $dateArr [1];
  11462. else
  11463. $D2 = '';
  11464. $dateString = $D1 . " : " . $D2;
  11465. }
  11466. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11467. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11468. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11469. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11470. if (! empty ( $price ))
  11471. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11472. if ($submitType == 1) {
  11473. if ($accountType != '') {
  11474. $expenditureType = '';
  11475. $con .= ' and accountType=' . $accountType;
  11476. if (! empty ( $accountMsg ))
  11477. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11478. }
  11479. } elseif ($submitType == 2) {
  11480. if ($expenditureType != '') {
  11481. $accountType = $accountMsg = '';
  11482. $con .= ' and expenditureType=' . $expenditureType;
  11483. }
  11484. } else {
  11485. $accountType = $accountMsg = $expenditureType = '';
  11486. }
  11487. $sql = "" . $con;
  11488. $action = "paymentsAchieve";
  11489. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11490. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11491. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11492. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11493. $data ['expenditureType'] = $expenditureType;
  11494. $data ['accountMsg'] = $accountMsg;
  11495. $data ['accountType'] = $accountType;
  11496. $data ['inputDate'] = $date;
  11497. $data ['price'] = $price;
  11498. $data ['expensesType'] = $expensesType;
  11499. $data ['page'] = $pageinfo;
  11500. $data ['list'] = $list;
  11501. $data ['memu'] = "receipt";
  11502. $data ['staff'] = $this->staff;
  11503. $data ['receiptMemu'] = 'payments';
  11504. $data ['verifyId'] = $this->verifyId;
  11505. $data ['executeId'] = $this->executeId;
  11506. $this->render ( "/expenses/paymentsAchieve", $data );
  11507. }
  11508. function paymentsIncomeUpdateDo() {
  11509. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11510. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11511. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11512. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11513. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11514. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11515. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11516. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11517. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11518. Doo::loadClass ( 'XDeode' );
  11519. $XDeode = new XDeode ( 5 );
  11520. $aid = $XDeode->decode ( $aidKey );
  11521. Doo::loadModel ( "accountBook" );
  11522. $accountBook = new accountBook ();
  11523. //
  11524. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11525. $price = $receivedPrice - $abDetail [inComePrice];
  11526. Doo::loadModel ( "accountBookStatistics" );
  11527. $accountBookStatistics = new accountBookStatistics ();
  11528. if ($abDetail ['accountType'] == 7) {
  11529. $item += array (
  11530. 'date' => date ( "Y-m-d" ),
  11531. 'financingPrice' => - $price,
  11532. 'expensesType' => 3,
  11533. 'aid' => $abDetail ['aid']
  11534. );
  11535. } elseif ($abDetail ['accountType'] == 8) {
  11536. $item += array (
  11537. 'date' => date ( "Y-m-d" ),
  11538. 'expensesType' => $abDetail ['expensesType'],
  11539. 'inComePrice' => - $price,
  11540. 'aid' => $abDetail ['aid']
  11541. );
  11542. } else {
  11543. $item = array (
  11544. 'date' => date ( "Y-m-d" ),
  11545. 'expensesType' => $abDetail ['expensesType'],
  11546. 'inComePrice' => $price,
  11547. 'aid' => $abDetail ['aid']
  11548. );
  11549. }
  11550. $accountBookStatistics->setAccountBookStatistics ( $item );
  11551. $accountBook->accountType = $accountType;
  11552. $accountBook->accountMsg = $accountMsg;
  11553. $accountBook->receivedPrice = $receivedPrice;
  11554. $accountBook->receivedMsg = $receivedMsg;
  11555. $accountBook->receivedBank = $receivedBank;
  11556. $accountBook->receivedDate = $receivedDate;
  11557. $accountBook->remarks = $remarks;
  11558. $accountBook->aid = $aid;
  11559. $accountBook->update ();
  11560. }
  11561. return '/paymentsAchieve';
  11562. }
  11563. function paymentsExpenditureEdiDo() {
  11564. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11565. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11566. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11567. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11568. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11569. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11570. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11571. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11572. Doo::loadClass ( 'XDeode' );
  11573. $XDeode = new XDeode ( 5 );
  11574. $aid = $XDeode->decode ( $aidKey );
  11575. Doo::loadModel ( "accountBook" );
  11576. $accountBook = new accountBook ();
  11577. // 汇总信息
  11578. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11579. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11580. Doo::loadModel ( "accountBookStatistics" );
  11581. $accountBookStatistics = new accountBookStatistics ();
  11582. if ($abDetail ['expenditureType'] == 4) {
  11583. $item += array (
  11584. 'date' => date ( "Y-m-d" ),
  11585. 'financingPrice' => $price,
  11586. 'expensesType' => 3,
  11587. 'aid' => $abDetail ['aid']
  11588. );
  11589. } elseif ($abDetail ['expenditureType'] == 5) {
  11590. $item += array (
  11591. 'date' => date ( "Y-m-d" ),
  11592. 'expensesType' => $abDetail ['expensesType'],
  11593. 'payPrice' => $price,
  11594. 'aid' => $abDetail ['aid']
  11595. );
  11596. } else {
  11597. $item = array (
  11598. 'date' => date ( "Y-m-d" ),
  11599. 'expensesType' => $abDetail ['expensesType'],
  11600. 'payPrice' => $price,
  11601. 'aid' => $abDetail ['aid']
  11602. );
  11603. }
  11604. $accountBookStatistics->setAccountBookStatistics ( $item );
  11605. //
  11606. $accountBook->expenditureType = $expenditureType;
  11607. $accountBook->expenditureMsg = $expenditureMsg;
  11608. $accountBook->expenditurePrice = $expenditurePrice;
  11609. $accountBook->expenditureBank = $expenditureBank;
  11610. $accountBook->remarks = $remarks;
  11611. $accountBook->expenditureDate = $expenditureDate;
  11612. $accountBook->aid = $aid;
  11613. $id = $accountBook->update ();
  11614. }
  11615. return '/paymentsAchieve';
  11616. }
  11617. function paymentsDelDo() {
  11618. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11619. if (! empty ( $aidKey )) {
  11620. Doo::loadClass ( 'XDeode' );
  11621. $XDeode = new XDeode ( 5 );
  11622. $aid = $XDeode->decode ( $aidKey );
  11623. Doo::loadModel ( "accountBook" );
  11624. $accountBook = new accountBook ();
  11625. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11626. if (empty ( $abDetail ))
  11627. die ( 'illegal request' );
  11628. // 删除收支
  11629. Doo::loadModel ( "accountBookStatistics" );
  11630. $accountBookStatistics = new accountBookStatistics ();
  11631. $item = array (
  11632. 'date' => date ( "Y-m-d" ),
  11633. 'aid' => $abDetail ['aid']
  11634. );
  11635. $accountType = '';
  11636. if ($abDetail ['expensesType'] == 1) {
  11637. $accountType = 6;
  11638. if ($abDetail ['accountType'] != 7) {
  11639. $item += array (
  11640. 'expensesType' => $abDetail ['expensesType'],
  11641. 'inComePrice' => - $abDetail ['receivedPrice']
  11642. );
  11643. } else {
  11644. $item += array (
  11645. 'financingPrice' => $abDetail ['receivedPrice'],
  11646. 'expensesType' => 3
  11647. );
  11648. }
  11649. } elseif ($abDetail ['expensesType'] == 2) {
  11650. $accountType = 5;
  11651. if ($abDetail ['accountType'] != 7) {
  11652. $item += array (
  11653. 'expensesType' => $abDetail ['expensesType'],
  11654. 'payPrice' => - $abDetail ['expenditurePrice']
  11655. );
  11656. } else {
  11657. $item += array (
  11658. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11659. 'expensesType' => 3
  11660. );
  11661. }
  11662. }
  11663. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11664. if ($abDetail ['expenditureMsg'] == '公司固定')
  11665. $accountType = 9;
  11666. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11667. $accountType = 10;
  11668. }
  11669. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11670. if ($abDetail ['accountMsg'] == '公司固定')
  11671. $accountType = 9;
  11672. elseif ($abDetail ['accountMsg'] == '公司活期')
  11673. $accountType = 10;
  11674. }
  11675. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11676. $accountType = 10;
  11677. }
  11678. $accountBookStatistics->setAccountBookStatistics ( $item );
  11679. $accountBook->delete ( array (
  11680. 'where' => 'aid=' . $aid,
  11681. 'limit' => 1
  11682. ) );
  11683. // 删除收入流水
  11684. //TODO 2020-07-23 删除新增理财和银行存款流水
  11685. if (! empty ( $accountType )) {
  11686. Doo::loadModel ( 'wasteBook' );
  11687. $wasteBook = new wasteBook ();
  11688. $wasteBook->delete ( array (
  11689. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11690. 'limit' => 1
  11691. ) );
  11692. }
  11693. }
  11694. return '/paymentsAchieve';
  11695. }
  11696. function paymentsCollect() {
  11697. Doo::loadModel ( "execute" );
  11698. $execute = new execute ();
  11699. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11700. die ( 'illegal request' );
  11701. }
  11702. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11703. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11704. Doo::loadModel ( "accountBookStatistics" );
  11705. $accountBookStatistics = new accountBookStatistics ();
  11706. Doo::loadClass ( 'receipt.func' );
  11707. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11708. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11709. $data ['html'] = $html ['html'];
  11710. $data ['inSum'] = $html ['sum'];
  11711. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11712. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11713. $data ['payHtml'] = $html ['html'];
  11714. $data ['paySum'] = $html ['sum'];
  11715. // 余额统计
  11716. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11717. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11718. include './protected/config/wasteBook.conf.php';
  11719. Doo::loadModel ( 'wasteBook' );
  11720. $wasteBook = new wasteBook ();
  11721. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11722. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11723. // 获得年份之前所有金额
  11724. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11725. // print_r($detail);
  11726. // $waste['total'];
  11727. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11728. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11729. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11730. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11731. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11732. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11733. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11734. if (date ( 'Y' ) > $year) {
  11735. $limitMonth = 12;
  11736. }
  11737. for($i = 1; $i <= 12; $i ++) {
  11738. $inComeA = $payB = 0;
  11739. $falg = true;
  11740. foreach ( $inComePay as $key => $value ) {
  11741. if ($value ['month'] == $i) {
  11742. $falg = false;
  11743. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11744. $inSum += $value ['accountPrice'];
  11745. $showInSum += $value ['accountPriceShow'];
  11746. $inComeA = $value ['accountPrice'];
  11747. break;
  11748. }
  11749. }
  11750. if ($falg)
  11751. $inComeHtml .= '<td class="taR">-</td>';
  11752. $payFalg = true;
  11753. foreach ( $pay as $key => $value ) {
  11754. if ($value ['month'] == $i) {
  11755. $payFalg = false;
  11756. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11757. $paySum += $value ['accountPrice'];
  11758. $showPaySum += $value ['accountPriceShow'];
  11759. $payB = $value ['accountPrice'];
  11760. break;
  11761. }
  11762. }
  11763. if ($payFalg)
  11764. $payHtml .= '<td class="taR">-</td>';
  11765. if (empty ( $balanceC ) || $limitMonth < $i)
  11766. $lastBalanceHtml .= '<td class="taR">-</td>';
  11767. else
  11768. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11769. $balanceC = $balanceC + $inComeA + $payB;
  11770. $balanceSum += $balanceC;
  11771. if (empty ( $balanceC ) || $limitMonth < $i)
  11772. $BalanceHtml .= '<td class="taR">-</td>';
  11773. else
  11774. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11775. // 余额统计
  11776. }
  11777. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11778. $data ['inComeHtml'] = $inComeHtml;
  11779. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11780. $data ['payBalanceHtml'] = $payHtml;
  11781. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11782. $data ['BalanceHtml'] = $BalanceHtml;
  11783. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11784. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11785. $mothHtml = "";
  11786. for($i = 1; $i <= 12; $i ++) {
  11787. if ($moth == $i)
  11788. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11789. else
  11790. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11791. }
  11792. $data ['mothHtml'] = $mothHtml;
  11793. $dateHtml = "";
  11794. $now = date ( "Y" );
  11795. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11796. if ($YEARD <= $now) {
  11797. $dateHtml .= '<option ';
  11798. if ($year == $YEARD) {
  11799. $dateHtml .= 'selected ';
  11800. }
  11801. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11802. }
  11803. }
  11804. $data ['dateHtml'] = $dateHtml;
  11805. $data ['year'] = $year;
  11806. $data ['memu'] = "receipt";
  11807. $data ['staff'] = $this->staff;
  11808. $data ['receiptMemu'] = 'paymentsCollect';
  11809. $data ['verifyId'] = $this->verifyId;
  11810. $data ['executeId'] = $this->executeId;
  11811. $this->render ( "/expenses/paymentsCollect", $data );
  11812. }
  11813. function paymentsCollectDay() {
  11814. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11815. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11816. if (empty ( $moth ))
  11817. return 'paymentsCollect';
  11818. Doo::loadModel ( "accountBookStatistics" );
  11819. $accountBookStatistics = new accountBookStatistics ();
  11820. $i = 2;
  11821. $y = 2013;
  11822. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11823. Doo::loadClass ( 'receipt.func' );
  11824. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11825. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11826. $data ['html'] = $html ['html'];
  11827. $data ['inSum'] = $html ['sum'];
  11828. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11829. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11830. $data ['payHtml'] = $html ['html'];
  11831. $data ['paySum'] = $html ['sum'];
  11832. $mothHtml = "";
  11833. for($i = 1; $i <= 12; $i ++) {
  11834. if ($moth == $i)
  11835. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11836. else
  11837. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11838. }
  11839. $data ['mothHtml'] = $mothHtml;
  11840. $data ['year'] = $year;
  11841. // 余额
  11842. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11843. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11844. include './protected/config/wasteBook.conf.php';
  11845. Doo::loadModel ( 'wasteBook' );
  11846. $wasteBook = new wasteBook ();
  11847. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11848. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11849. // 获得年份之前所有金额
  11850. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11851. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11852. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11853. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11854. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11855. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11856. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11857. // $balanceC = 0;
  11858. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11859. $limitDay = date ( 'd' );
  11860. $monthLK = ( int ) date ( 'm' );
  11861. if (date ( 'Y' ) > $year) {
  11862. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11863. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11864. $limitDay = 0;
  11865. }
  11866. for($i = 1; $i <= $day; $i ++) {
  11867. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11868. $inComeA = $payB = 0;
  11869. $falg = true;
  11870. foreach ( $inComePay as $key => $value ) {
  11871. if ($value ['day'] == $i) {
  11872. $falg = false;
  11873. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11874. $inSum += $value ['accountPrice'];
  11875. $showInSum += $value ['accountPriceShow'];
  11876. $inComeA = $value ['accountPrice'];
  11877. break;
  11878. }
  11879. }
  11880. if ($falg)
  11881. $inComeHtml .= '<td class="taR">-</td>';
  11882. $payFalg = true;
  11883. foreach ( $pay as $key => $value ) {
  11884. if ($value ['day'] == $i) {
  11885. $payFalg = false;
  11886. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11887. $paySum += $value ['accountPrice'];
  11888. $showPaySum += $value ['accountPriceShow'];
  11889. $payB = $value ['accountPrice'];
  11890. break;
  11891. }
  11892. }
  11893. if ($payFalg)
  11894. $payHtml .= '<td class="taR">-</td>';
  11895. if (empty ( $balanceC ) || $limitDay < $i)
  11896. $lastBalanceHtml .= '<td class="taR">-</td>';
  11897. else
  11898. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11899. $balanceC = $balanceC + $inComeA + $payB;
  11900. $balanceSum += $balanceC;
  11901. if (empty ( $balanceC ) || $limitDay < $i)
  11902. $BalanceHtml .= '<td class="taR">-</td>';
  11903. else
  11904. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11905. }
  11906. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11907. $data ['inComeHtml'] = $inComeHtml;
  11908. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11909. $data ['payBalanceHtml'] = $payHtml;
  11910. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11911. $data ['BalanceHtml'] = $BalanceHtml;
  11912. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11913. $data ['dayHtml'] = $dayHtml;
  11914. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11915. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11916. $dateHtml = "";
  11917. $now = date ( "Y" );
  11918. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11919. if ($YEARD <= $now) {
  11920. $dateHtml .= '<option ';
  11921. if ($year == $YEARD) {
  11922. $dateHtml .= 'selected ';
  11923. }
  11924. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11925. }
  11926. }
  11927. $data ['dateHtml'] = $dateHtml;
  11928. $data ['memu'] = "receipt";
  11929. $data ['staff'] = $this->staff;
  11930. $data ['receiptMemu'] = 'paymentsCollect';
  11931. $data ['verifyId'] = $this->verifyId;
  11932. $data ['executeId'] = $this->executeId;
  11933. $this->render ( "/expenses/paymentsCollectDay", $data );
  11934. }
  11935. // 公司流水
  11936. function wasteBook() {
  11937. Doo::loadModel ( "execute" );
  11938. $execute = new execute ();
  11939. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11940. die ( 'illegal request' );
  11941. }
  11942. include './protected/config/wasteBook.conf.php';
  11943. Doo::loadModel ( 'wasteBook' );
  11944. $wasteBook = new wasteBook ();
  11945. $data ['store']=$waste;
  11946. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11947. //print_r($waste);
  11948. //1-收入支出流水金额合计
  11949. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11950. //echo $waste['bank']['CGBDeposit'].'</br>';
  11951. //2020-07-20 -理财相关-面板数据
  11952. Doo::loadClass ( 'wasteBook.finances.func' );
  11953. $financesStatistics=$wasteBook->getFinancesStatistics();
  11954. //print_r($waste);
  11955. // 展示使用
  11956. //收入
  11957. //print_r($inComeStatistics);
  11958. $wasteStatistics['CGBDeposit']=0;
  11959. $wasteStatistics['ICBCDeposit']=0;
  11960. $wasteStatistics['HUADeposit']=0;
  11961. $wasteStatistics['PersonalDeposit']=0;
  11962. foreach ($inComeStatistics['incomeStatistics'] as $value ){
  11963. if($value['accountBank']=='CGBDeposit'){
  11964. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11965. }
  11966. if($value['accountBank']=='ICBCDeposit'){
  11967. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11968. }
  11969. if($value['accountBank']=='HUADeposit'){
  11970. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11971. }
  11972. if($value['accountBank']=='PersonalDeposit'){
  11973. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11974. }
  11975. }
  11976. $data ['wasteStatistics']=$wasteStatistics;
  11977. //支出
  11978. $wasteStatistics['CGBDeposit']=0;
  11979. $wasteStatistics['ICBCDeposit']=0;
  11980. $wasteStatistics['HUADeposit']=0;
  11981. $wasteStatistics['PersonalDeposit']=0;
  11982. foreach ($inComeStatistics['expenditureStatistics'] as $value ){
  11983. if($value['accountBank']=='CGBDeposit'){
  11984. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11985. }
  11986. if($value['accountBank']=='ICBCDeposit'){
  11987. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11988. }
  11989. if($value['accountBank']=='HUADeposit'){
  11990. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11991. }
  11992. if($value['accountBank']=='PersonalDeposit'){
  11993. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11994. }
  11995. }
  11996. $data ['wastePay']=$wasteStatistics;
  11997. //理财公司账号部分
  11998. $wasteStatistics['CGBDeposit']=0;
  11999. $wasteStatistics['ICBCDeposit']=0;
  12000. $wasteStatistics['HUADeposit']=0;
  12001. $wasteStatistics['PersonalDeposit']=0;
  12002. foreach ($financesStatistics['companyAccount'] as $value ){
  12003. //(纵横广发)广发存款
  12004. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12005. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12006. }
  12007. //工行存款
  12008. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12009. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12010. }
  12011. //个人存款
  12012. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12013. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12014. }
  12015. }
  12016. $data ['wasteCompanyAccount']=$wasteStatistics;
  12017. //理财部分的金额计算
  12018. $waste =_getFinancesWBS ( $waste, $financesStatistics );
  12019. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12020. //存款面板数据--日常收支改变后的金额汇总
  12021. $bankSavingsStatistics=$wasteBook->getBankSavingsStatistics();
  12022. $waste =_getBankSavingsWBS ( $waste, $bankSavingsStatistics );
  12023. //展示调试BUG-使用
  12024. //print_r($bankSavingsStatistics);
  12025. $wasteStatistics['CGBDeposit']=0;
  12026. $wasteStatistics['ICBCDeposit']=0;
  12027. $wasteStatistics['PersonalDeposit']=0;
  12028. foreach ($bankSavingsStatistics as $value ){
  12029. //(纵横广发)广发存款
  12030. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12031. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12032. }
  12033. //工行存款
  12034. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12035. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12036. }
  12037. //个人存款
  12038. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12039. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12040. }
  12041. }
  12042. $data ['wasteNewPay']=$wasteStatistics;
  12043. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12044. //
  12045. $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'];
  12046. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12047. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12048. // print_r($waste);
  12049. $data ['total'] = number_format($total,2);
  12050. $data ['CGBDeposit_total'] = number_format($CGBDeposit_total,2);
  12051. $cashBalance=$CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12052. $data['cashBalance']= number_format($cashBalance,2);
  12053. $waste ['bank'] ['CGBDeposit']=sprintf("%.2f", round($waste ['bank'] ['CGBDeposit'], 2));
  12054. $data ['waste'] = $waste;
  12055. // 月流水数据结构
  12056. $monthStatistics = array ();
  12057. $incomeMothStatistics = array ();
  12058. $expenditureMothStatistics = array ();
  12059. for($i = 1; $i <= 12; $i ++) {
  12060. $month = date ( 'Y' ) . '-' . $i;
  12061. if ($i < 10)
  12062. $month = date ( 'Y' ) . '-0' . $i;
  12063. array_push ( $monthStatistics, $month );
  12064. }
  12065. foreach ( $monthStatistics as $value ) {
  12066. $falg = true;
  12067. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12068. if ($value == $v ['inputDate']) {
  12069. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12070. $falg = false;
  12071. }
  12072. }
  12073. if ($falg) {
  12074. array_push ( $incomeMothStatistics, '' );
  12075. }
  12076. $falgEx = true;
  12077. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12078. if ($value == $v ['inputDate']) {
  12079. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12080. $falg = false;
  12081. }
  12082. }
  12083. if ($falgEx) {
  12084. array_push ( $expenditureMothStatistics, '' );
  12085. }
  12086. }
  12087. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12088. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12089. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12090. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12091. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12092. // print_r($incomeList);
  12093. $data ['expenditureList'] = $expenditureList;
  12094. $data ['incomeList'] = $incomeList;
  12095. $data ['memu'] = "receipt";
  12096. $data ['staff'] = $this->staff;
  12097. $data ['receiptMemu'] = 'wasteBook';
  12098. $data ['verifyId'] = $this->verifyId;
  12099. $data ['executeId'] = $this->executeId;
  12100. $this->render ( "/expenses/wasteBook", $data );
  12101. }
  12102. function wasteBookIncome() {
  12103. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12104. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12105. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12106. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12107. $data ['dailyIncomeType'] = $dailyIncomeType;
  12108. Doo::loadModel ( 'wasteBook' );
  12109. $wasteBook = new wasteBook ();
  12110. Doo::loadModel ( 'L_category' );
  12111. $L_category = new L_category ();
  12112. Doo::loadClass ( 'XDeode' );
  12113. $XDeode = new XDeode ( 5 );
  12114. $year=date("Y");
  12115. $theDay=date("Y-m-d");
  12116. $dateArr = explode ( ':', $date );
  12117. $D1 = '';
  12118. $D2 = '';
  12119. $con = '';
  12120. if (! empty ( $date )) {
  12121. $D1 = $dateArr [0];
  12122. $D2 = $dateArr [1];
  12123. }
  12124. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12125. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12126. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12127. $con = ' and inputDate = "' . $D1 . '"';
  12128. else{
  12129. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12130. }
  12131. if ($cid != 'ALL') {
  12132. $cid = $XDeode->decode ( $cid );
  12133. $con .= ' and cid = "' . $cid . '"';
  12134. }
  12135. if ($accountType != 'ALL') {
  12136. if ($accountType == 'INVOICE') {
  12137. $con .= ' and (accountType = 7 or accountType = 8)';
  12138. } elseif ($accountType == 'PAYMENTS') {
  12139. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12140. if ($dailyIncomeType != 'ALL') {
  12141. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12142. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12143. }
  12144. }
  12145. }
  12146. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12147. foreach ($incomeList as $key=>$value){
  12148. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12149. $wasteBook = new wasteBook ();
  12150. $wasteBook->wid = $value['wid'];
  12151. $wasteBook->synPaymentDate = 1;
  12152. $wasteBook->inputDate = $value['data']['receivedDate'];
  12153. $wasteBook->update();
  12154. }
  12155. }
  12156. $sum = 0;$thsDaySum=0;
  12157. foreach ( $incomeList as $key => $value ) {
  12158. $sum += $value ['accountPrice'];
  12159. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12160. $thsDaySum+=$value ['accountPrice'];
  12161. }
  12162. }
  12163. // print_r($incomeList);
  12164. // 获得办事和部门
  12165. $categoryList = $L_category->getCategory ();
  12166. $data ['accountType'] = $accountType;
  12167. $data ['cid'] = $cid;
  12168. $data ['categoryList'] = $categoryList;
  12169. $data ['sum'] = $sum;
  12170. $data ['incomeList'] = $incomeList;
  12171. $data ['inputDate'] = $date;
  12172. $data['year']=$year;
  12173. $data ['thsDay'] =$theDay;
  12174. $data ['thsDaySum'] =$thsDaySum;
  12175. $data ['memu'] = "receipt";
  12176. $data ['staff'] = $this->staff;
  12177. $data ['receiptMemu'] = 'wasteBook';
  12178. $data ['verifyId'] = $this->verifyId;
  12179. $data ['executeId'] = $this->executeId;
  12180. $this->render ( "/expenses/wasteBookIncome", $data );
  12181. }
  12182. /**
  12183. * 所有支出
  12184. */
  12185. function wasteBookExpenditure() {
  12186. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12187. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12188. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12189. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12190. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12191. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12192. $data ['receiptType'] = $receiptType;
  12193. Doo::loadModel ( 'wasteBook' );
  12194. $wasteBook = new wasteBook ();
  12195. Doo::loadModel ( 'L_category' );
  12196. $L_category = new L_category ();
  12197. Doo::loadClass ( 'XDeode' );
  12198. $XDeode = new XDeode ( 5 );
  12199. $year=date("Y");
  12200. $theDay=date("Y-m-d");
  12201. $dateArr = explode ( ':', $date );
  12202. $D1 = '';
  12203. $D2 = '';
  12204. $con = '';
  12205. if (! empty ( $date )) {
  12206. $D1 = $dateArr [0];
  12207. $D2 = $dateArr [1];
  12208. }
  12209. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12210. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12211. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12212. $con = ' and inputDate = "' . $D1 . '"';
  12213. else{
  12214. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12215. }
  12216. if ($cid != 'ALL') {
  12217. $cid = $XDeode->decode ( $cid );
  12218. $con .= ' and cid = "' . $cid . '"';
  12219. }
  12220. if ($accountType != 'ALL') {
  12221. if ($accountType == 'INVOICE') {
  12222. $con .= ' and accountType = 11';
  12223. } elseif ($accountType == 'PAYMENTS') {
  12224. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12225. if ($dailyExpenditureType != 'ALL') {
  12226. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12227. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12228. }
  12229. } elseif ($accountType == 'RECEIPT') {
  12230. if ($receiptType == 'ALL') {
  12231. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12232. } else {
  12233. $receiptType = $XDeode->decode ( $receiptType );
  12234. echo $receiptType;
  12235. if ($receiptType == 1) {
  12236. $con .= ' and (accountType = 1 or accountType=2)';
  12237. } else {
  12238. $con .= ' and accountType = ' . $receiptType;
  12239. }
  12240. }
  12241. }
  12242. }
  12243. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12244. foreach ($incomeList as $key=>$value){
  12245. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12246. $wasteBook = new wasteBook ();
  12247. $wasteBook->wid = $value['wid'];
  12248. $wasteBook->synPaymentDate = 1;
  12249. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12250. $wasteBook->update();
  12251. }
  12252. }
  12253. $sum = 0;$thsDaySum=0;
  12254. foreach ( $incomeList as $key => $value ) {
  12255. $sum += $value ['accountPriceShow'];
  12256. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12257. $thsDaySum+=$value ['accountPriceShow'];
  12258. }
  12259. }
  12260. // print_r($incomeList);
  12261. // 获得办事和部门
  12262. $categoryList = $L_category->getCategory ();
  12263. $data ['accountType'] = $accountType;
  12264. $data ['cid'] = $cid;
  12265. $data ['categoryList'] = $categoryList;
  12266. $data ['sum'] = $sum;
  12267. $data ['incomeList'] = $incomeList;
  12268. $data ['inputDate'] = $date;
  12269. $data['year']=$year;
  12270. $data ['thsDay'] =$theDay;
  12271. $data ['thsDaySum'] =$thsDaySum;
  12272. $data ['memu'] = "receipt";
  12273. $data ['staff'] = $this->staff;
  12274. $data ['receiptMemu'] = 'wasteBook';
  12275. $data ['verifyId'] = $this->verifyId;
  12276. $data ['executeId'] = $this->executeId;
  12277. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12278. }
  12279. function ajaxGetWasteinvoiceReceivables() {
  12280. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12281. Doo::loadClass ( 'XDeode' );
  12282. $XDeode = new XDeode ( 5 );
  12283. $irid = $XDeode->decode ( $serial );
  12284. Doo::loadModel ( 'invoiceReceivables' );
  12285. $invoiceReceivables = new invoiceReceivables ();
  12286. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12287. echo json_encode ( array (
  12288. 'status' => 1,
  12289. 'detail' => $detail
  12290. ) );
  12291. }
  12292. function ajaxGetPaymentsByAid() {
  12293. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12294. Doo::loadModel ( "accountBook" );
  12295. $accountBook = new accountBook ();
  12296. $detail = $accountBook->getAccountBookByAid ( $serial );
  12297. echo json_encode ( array (
  12298. 'status' => 1,
  12299. 'detail' => $detail
  12300. ) );
  12301. }
  12302. function ajaxGetWasteInvoice() {
  12303. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12304. Doo::loadModel ( 'invoice' );
  12305. $invoice = new invoice ();
  12306. Doo::loadModel ( 'invoiceReceivables' );
  12307. $invoiceReceivables = new invoiceReceivables ();
  12308. $detail = $invoice->getInvoiceByIid ( $serial );
  12309. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12310. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12311. echo json_encode ( array (
  12312. 'status' => 1,
  12313. 'detail' => $detail
  12314. ) );
  12315. }
  12316. /**
  12317. */
  12318. function ajaxGetWasteReceipt() {
  12319. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12320. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12321. Doo::loadModel ( 'receipt' );
  12322. $receipt = new receipt ();
  12323. Doo::loadClass ( 'XDeode' );
  12324. $XDeode = new XDeode ( 5 );
  12325. $rid = $XDeode->decode ( $serial );
  12326. $accountType= $XDeode->decode ( $accountTypeKey );
  12327. // 获得个数据
  12328. $detail = $receipt->getReceiptByRid ( $rid );
  12329. // 初始化
  12330. $detail ['reviseDetail'] = array ();
  12331. if (! empty ( $value ['reviseDetail'] ))
  12332. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12333. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12334. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12335. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12336. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12337. // 获得费用html
  12338. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12339. // 获得费用审批人数据
  12340. $detail = $this->getReceiptApproverHtml ( $detail );
  12341. // 审批执行
  12342. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12343. <th class="taC" width="90">审批人</th>
  12344. <th class="taC">审批意见</th></tr>';
  12345. foreach ( $detail ['verifyList'] as $key => $value ) {
  12346. $html .= '<tr>
  12347. <td>' . $value [1] . '</td>
  12348. <td>' . $value ['opinion'] . '</td>
  12349. </tr>
  12350. ';
  12351. }
  12352. $html .= ' </tbody></table>';
  12353. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12354. <th class="taC" width="90">执行人</th>
  12355. <th class="taC">执行意见</th></tr>';
  12356. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12357. $html .= '<tr>
  12358. <td>' . $value [1] . '</td>
  12359. <td>' . $value ['opinion'] . '</td>
  12360. </tr>
  12361. ';
  12362. }
  12363. $html .= ' </tbody></table>';
  12364. if($accountType==1){
  12365. Doo::loadModel ( 'loanReceipt' );
  12366. $loanReceipt = new loanReceipt ();
  12367. $loanList = $loanReceipt->getOne ( array (
  12368. 'where' => 'rid=' . $detail ['loanRid'],
  12369. 'desc' => 'rid',
  12370. 'asArray' => true
  12371. ) );
  12372. $html .= '<table class="table table-bordered table-condensed">
  12373. <tr class="warning">
  12374. <td class="taR"><b>汇款金额</b></td>
  12375. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12376. </tr>
  12377. </table>';
  12378. }else{
  12379. $html .= '<table class="table table-bordered table-condensed">
  12380. <tr class="warning">
  12381. <td class="taR"><b>汇款金额</b></td>
  12382. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12383. </tr>
  12384. </table>';
  12385. }
  12386. // print_r($detail['verifyList']);
  12387. // header ( 'Content-Type:text/html;charset=utf-8' );
  12388. // echo $html;
  12389. echo json_encode ( array (
  12390. 'status' => 1,
  12391. 'html' => $html,
  12392. 'detail' => $detail
  12393. ) );
  12394. }
  12395. function getReceiptApproverHtml($detail = array()) {
  12396. Doo::loadModel ( 'loanReceipt' );
  12397. $loanReceipt = new loanReceipt ();
  12398. Doo::loadModel ( 'verify' );
  12399. $verify = new verify ();
  12400. Doo::loadModel ( 'staff' );
  12401. $staff = new staff ();
  12402. if (empty ( $detail ))
  12403. return array ();
  12404. $loanList = $loanReceipt->getOne ( array (
  12405. 'where' => 'rid=' . $detail ['loanRid'],
  12406. 'desc' => 'rid',
  12407. 'asArray' => true
  12408. ) );
  12409. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12410. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12411. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12412. else
  12413. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12414. } else
  12415. $verifyList = $verify->getOne ( array (
  12416. 'where' => 'vid=' . $detail ['verify'],
  12417. 'asArray' => true
  12418. ) );
  12419. $verifyList = json_decode ( $verifyList ['staff'], true );
  12420. Doo::loadModel ( 'role' );
  12421. $role = new role ();
  12422. $roleId = 0;
  12423. $flag = true;
  12424. $roleKey = 0;
  12425. $endStaffArray = array ();
  12426. $roleArrayCopy = array ();
  12427. foreach ( $verifyList as $k => $v ) {
  12428. // init verifyStaff
  12429. if ($v [1] == 'ROLE') {
  12430. if (! empty ( $verifyStaff )) {
  12431. $endStaffArray = end ( $verifyStaff );
  12432. }
  12433. $roleVerify = json_decode ( $v [3], true );
  12434. $roleKey = $k;
  12435. $roleArray = array ();
  12436. $rolename = $role->getOne ( array (
  12437. 'where' => 'rid=' . $v [0],
  12438. 'asArray' => true
  12439. ) );
  12440. foreach ( $roleVerify as $o => $p ) {
  12441. $staffID = explode ( '_', $p );
  12442. $staffInfo = $staff->getOne ( array (
  12443. 'where' => 'sid=' . $staffID [0],
  12444. 'asArray' => true
  12445. ) );
  12446. // print_r($staffID);
  12447. $exp = array (
  12448. 0 => $staffInfo ['sid'],
  12449. 1 => $staffID [1],
  12450. 2 => $staffInfo ['avatar'],
  12451. 'date' => '',
  12452. 'date' => '',
  12453. 'opinion' => '',
  12454. 'status' => '',
  12455. 'rolename' => $rolename ['name']
  12456. );
  12457. array_push ( $roleArray, $exp );
  12458. }
  12459. $roleArrayCopy [$v [0]] = $roleArray;
  12460. // $verifyList[$k]['roleArray']=$roleArray;
  12461. }
  12462. $verifyList [$k] ['date'] = "";
  12463. $verifyList [$k] ['opinion'] = "";
  12464. $verifyList [$k] ['status'] = "";
  12465. if (empty ( $verifyStaff )) {
  12466. $verifyList [$k] ['date'] = "";
  12467. $verifyList [$k] ['opinion'] = "";
  12468. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12469. $verifyList [$k] ['status'] = 4;
  12470. $flag = false;
  12471. }
  12472. } else {
  12473. foreach ( $verifyStaff as $m => $u ) {
  12474. if ($v [0] == $m) {
  12475. $verifyList [$k] ['date'] = $u ['date'];
  12476. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12477. $verifyList [$k] ['status'] = $u ['status'];
  12478. $flag = false;
  12479. break;
  12480. }
  12481. }
  12482. $endStaffArray = end ( $verifyStaff );
  12483. }
  12484. }
  12485. $rolename ['name'] = '';
  12486. if (! empty ( $roleId )) {
  12487. Doo::loadModel ( 'role' );
  12488. $role = new role ();
  12489. $rolename = $role->getOne ( array (
  12490. 'where' => 'rid=' . $roleId,
  12491. 'asArray' => true
  12492. ) );
  12493. }
  12494. if (! empty ( $verifyStaff ))
  12495. $endStaffArray = end ( $verifyStaff );
  12496. $KOP = false;
  12497. foreach ( $roleArrayCopy as $P => $A ) {
  12498. foreach ( $A as $MKI => $AVL ) {
  12499. if (! empty ( $verifyStaff )) {
  12500. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12501. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12502. $button = 4;
  12503. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12504. }
  12505. foreach ( $verifyStaff as $m => $u ) {
  12506. $AVLFK = $AVL [0] . '_R';
  12507. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12508. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12509. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12510. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12511. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12512. break;
  12513. }
  12514. }
  12515. } else {
  12516. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12517. $button = 4;
  12518. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12519. }
  12520. }
  12521. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12522. $KOP = true;
  12523. }
  12524. }
  12525. foreach ( $roleArrayCopy as $k => $v ) {
  12526. foreach ( $verifyList as $m => $n ) {
  12527. if ($n [0] == $k) {
  12528. array_splice ( $verifyList, $m, 1, $v );
  12529. }
  12530. }
  12531. }
  12532. // 费用执行人相关数据
  12533. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12534. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12535. foreach ( $executeCopy as $k => $v ) {
  12536. $executeCopy [$k] ['date'] = '';
  12537. $executeCopy [$k] ['opinion'] = '';
  12538. $executeCopy [$k] ['status'] = '';
  12539. if (! empty ( $executeStaff ))
  12540. foreach ( $executeStaff as $m => $u ) {
  12541. if ($v [0] == $m) {
  12542. $executeCopy [$k] ['date'] = $u ['date'];
  12543. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12544. $executeCopy [$k] ['status'] = $u ['status'];
  12545. break;
  12546. }
  12547. }
  12548. }
  12549. $detail ['executeCopy'] = $executeCopy;
  12550. $detail ['verifyList'] = $verifyList;
  12551. return $detail;
  12552. }
  12553. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12554. if (empty ( $detail ))
  12555. return '';
  12556. $html = '';
  12557. if ($detail ['Rtype'] == 0) { // 报销单
  12558. $html .= '<table class="table table-bordered table-condensed">
  12559. <tbody>
  12560. <tr>
  12561. <th colspan="2" class="taC">日常相关费用</th>
  12562. </tr>';
  12563. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12564. $html .= '
  12565. <tr>
  12566. <th>' . $value ['name'] . '</th>
  12567. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12568. </tr>';
  12569. }
  12570. $html .= '
  12571. <tr>
  12572. <th class="taR">合计</th>
  12573. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12574. </tr>';
  12575. $html .= '<tr>
  12576. <th colspan="2" class="taC">差旅相关费用</th>
  12577. </tr>';
  12578. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12579. $html .= '
  12580. <tr>
  12581. <th>' . $value ['name'] . '</th>
  12582. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12583. </tr>';
  12584. }
  12585. $html .= '
  12586. <tr>
  12587. <th class="taR">合计</th>
  12588. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12589. </tr>';
  12590. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12591. $html .= '<tr>
  12592. <th colspan="2" class="taC">内部培训费用</th>
  12593. </tr>';
  12594. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12595. $html .= '
  12596. <tr>
  12597. <th>' . $value ['name'] . '</th>
  12598. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12599. </tr>';
  12600. }
  12601. $html .= '
  12602. <tr>
  12603. <th class="taR">合计</th>
  12604. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12605. </tr>';
  12606. }
  12607. $html .= '<tr>
  12608. <th colspan="2" class="taC">其他</th>
  12609. </tr>';
  12610. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12611. $html .= '
  12612. <tr>
  12613. <th>' . $value ['name'] . '</th>
  12614. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12615. </tr>';
  12616. }
  12617. $html .= '
  12618. <tr>
  12619. <th class="taR">合计</th>
  12620. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12621. </tr>';
  12622. $html .= '<tr>
  12623. <th colspan="2" class="taC">报销金额调整</th>
  12624. </tr>';
  12625. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12626. $html .= '
  12627. <tr>
  12628. <th>' . $value ['name'] . '</th>
  12629. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12630. </tr>';
  12631. }
  12632. $html .= '
  12633. <tr>
  12634. <th class="taR">合计</th>
  12635. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12636. </tr>';
  12637. $html .= '
  12638. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12639. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12640. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12641. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12642. <tr class="warning">
  12643. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12644. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12645. </tr>
  12646. </tbody>
  12647. </table>';
  12648. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12649. $html .= '
  12650. <table class="table table-bordered table-condensed">
  12651. <tbody>
  12652. <tr>
  12653. <th colspan="2" class="taC">办事处相关费用</th>
  12654. </tr>';
  12655. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12656. $html .= '
  12657. <tr>
  12658. <th>' . $value ['name'] . '</th>
  12659. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12660. </tr>';
  12661. }
  12662. $html .= '
  12663. <tr>
  12664. <th class="taR">合计</th>
  12665. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12666. </tr>';
  12667. $html .= '
  12668. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12669. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12670. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12671. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12672. <tr class="warning">
  12673. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12674. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12675. </tr>
  12676. </tbody>
  12677. </table>';
  12678. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12679. Doo::loadModel ( 'loanReceipt' );
  12680. $loanReceipt = new loanReceipt ();
  12681. $loanList = $loanReceipt->getOne ( array (
  12682. 'where' => 'rid=' . $detail ['loanRid'],
  12683. 'desc' => 'rid',
  12684. 'asArray' => true
  12685. ) );
  12686. // print_r($loanList);
  12687. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12688. $html .= '<table class="table table-bordered table-condensed">
  12689. <tbody>
  12690. <tr>
  12691. <th colspan="2" class="taC">借款费用</th>
  12692. </tr>';
  12693. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12694. $html .= '<tr>
  12695. <th>' . $value ['name'] . '</th>
  12696. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12697. </tr>';
  12698. }
  12699. $html .= '<tr>
  12700. <th class="taC" colspan="2">产生费用所在办事处</th>
  12701. </tr>
  12702. <tr>
  12703. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12704. </tr>
  12705. <tr>
  12706. <th class="taC" colspan="2">费用说明</th>
  12707. </tr>
  12708. <tr>
  12709. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12710. </tr>
  12711. <tr class="warning">
  12712. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12713. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12714. </tr>
  12715. </tbody>
  12716. </table>
  12717. ';
  12718. if ( $accountType==2) {
  12719. $balance=$detail ['sum']-$loanList ['sum'];
  12720. $balanceCN=$this->num_to_rmb($balance);
  12721. $html .= '<table class="table table-bordered table-condensed">
  12722. <tbody>
  12723. <tr>
  12724. <th colspan="2" class="taC">日常相关费用</th>
  12725. </tr>';
  12726. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12727. $html .= '
  12728. <tr>
  12729. <th>' . $value ['name'] . '</th>
  12730. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12731. </tr>';
  12732. }
  12733. $html .= '
  12734. <tr>
  12735. <th class="taR">合计</th>
  12736. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12737. </tr>';
  12738. $html .= '<tr>
  12739. <th colspan="2" class="taC">差旅相关费用</th>
  12740. </tr>';
  12741. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12742. $html .= '
  12743. <tr>
  12744. <th>' . $value ['name'] . '</th>
  12745. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12746. </tr>';
  12747. }
  12748. $html .= '
  12749. <tr>
  12750. <th class="taR">合计</th>
  12751. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12752. </tr>';
  12753. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12754. $html .= '<tr>
  12755. <th colspan="2" class="taC">内部培训费用</th>
  12756. </tr>';
  12757. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12758. $html .= '
  12759. <tr>
  12760. <th>' . $value ['name'] . '</th>
  12761. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12762. </tr>';
  12763. }
  12764. $html .= '
  12765. <tr>
  12766. <th class="taR">合计</th>
  12767. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12768. </tr>';
  12769. }
  12770. $html .= '<tr>
  12771. <th colspan="2" class="taC">其他</th>
  12772. </tr>';
  12773. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12774. $html .= '
  12775. <tr>
  12776. <th>' . $value ['name'] . '</th>
  12777. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12778. </tr>';
  12779. }
  12780. $html .= '
  12781. <tr>
  12782. <th class="taR">合计</th>
  12783. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12784. </tr>';
  12785. $html .= '<tr>
  12786. <th colspan="2" class="taC">报销金额调整</th>
  12787. </tr>';
  12788. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12789. $html .= '
  12790. <tr>
  12791. <th>' . $value ['name'] . '</th>
  12792. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12793. </tr>';
  12794. }
  12795. $html .= '
  12796. <tr>
  12797. <th class="taR">合计</th>
  12798. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12799. </tr>';
  12800. $html .= '
  12801. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12802. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12803. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12804. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12805. <tr class="warning">
  12806. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12807. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12808. </tr>
  12809. <tr class="success">
  12810. <td class="taR"><b>借款结余</b></td>
  12811. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12812. </tr>
  12813. </tbody>
  12814. </table>';
  12815. }
  12816. }
  12817. return $html;
  12818. }
  12819. /**
  12820. * 计算流水
  12821. */
  12822. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12823. $bakWaste ['bank'] = array (
  12824. 'CGBDeposit' => 0,
  12825. 'ICBCDeposit' => 0,
  12826. 'HUADeposit' => 0,
  12827. 'PersonalDeposit' => 0
  12828. );
  12829. $bakWaste ['financial'] = array (
  12830. 'current' => array (
  12831. 'CGBDeposit' => 0,
  12832. 'ICBCDeposit' => 0
  12833. ),
  12834. 'fixed' => array (
  12835. 'CGBDeposit' => 0,
  12836. 'ICBCDeposit' => 0
  12837. )
  12838. );
  12839. // 存款
  12840. foreach ( $waste ['bank'] as $key => $value ) {
  12841. // 收入
  12842. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12843. // 广发
  12844. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12845. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12846. }
  12847. // 工商
  12848. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12849. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12850. }
  12851. // 华润
  12852. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12853. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12854. }
  12855. // 个人
  12856. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12857. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12858. }
  12859. }
  12860. }
  12861. foreach ( $waste ['bank'] as $key => $value ) {
  12862. // 支出
  12863. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12864. // 广发
  12865. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12866. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12867. }
  12868. // 工商
  12869. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12870. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12871. }
  12872. // 华润
  12873. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12874. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12875. }
  12876. // 个人
  12877. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12878. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12879. }
  12880. }
  12881. }
  12882. // 活期
  12883. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12884. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12885. // 广发
  12886. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12887. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12888. }
  12889. // 工商
  12890. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12891. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12892. }
  12893. // 个人
  12894. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12895. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12896. }
  12897. }
  12898. }
  12899. // print_r($inComeStatistics ['fixedStatistics']);
  12900. // 固期
  12901. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12902. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12903. // 广发
  12904. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12905. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12906. }
  12907. // 工商---已经转变成个人理财固定代表含义
  12908. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12909. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12910. }
  12911. // 个人
  12912. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12913. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12914. }
  12915. }
  12916. }
  12917. $waste ['bank'] ['ICBCDeposit'] = sprintf("%.2f", $waste ['bank'] ['ICBCDeposit']);
  12918. return $waste;
  12919. }
  12920. function lyt() {
  12921. Doo::loadModel ( "receiptDetail" );
  12922. $receiptDetail = new receiptDetail ();
  12923. $receiptCollectList = $receiptDetail->find ( array (
  12924. 'where' => 'status=1 ',
  12925. 'asArray' => true
  12926. ) );
  12927. foreach ( $receiptCollectList as $key => $value ) {
  12928. $receiptDetail = new receiptDetail ();
  12929. $receiptDetail->pastDate = $value ['date'];
  12930. $receiptDetail->update ( array (
  12931. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12932. ) );
  12933. }
  12934. }
  12935. function staffCollectMonthDetail() {
  12936. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12937. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12938. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12939. if (! $year)
  12940. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12941. if (! $month)
  12942. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12943. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12944. if (! $nature){
  12945. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12946. }
  12947. Doo::loadModel ( 'staff' );
  12948. $staff = new staff ();
  12949. Doo::loadModel ( "receiptDetail" );
  12950. $receiptDetail = new receiptDetail ();
  12951. Doo::loadModel ( 'accountItem' );
  12952. $accountItem = new accountItem ();
  12953. Doo::loadModel ( 'statistics' );
  12954. $statistics = new statistics ();
  12955. Doo::loadModel ( "receiptAuthorityManage" );
  12956. $receiptAuthorityManage = new receiptAuthorityManage ();
  12957. $aiList=$accountItem->getAccountItem();
  12958. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12959. $cidList = array ();
  12960. foreach ( $imcStaff as $key => $value ) {
  12961. array_push ( $cidList, $value ['cid'] );
  12962. }
  12963. $cidString = implode ( ',', $cidList );
  12964. $naturecon='';
  12965. if ($nature=='ONJOB'){
  12966. $naturecon=' and (nature!=4 )';
  12967. }elseif($nature=='LEAVEJOB'){
  12968. $naturecon=' and (nature=4 )';
  12969. }else{
  12970. die ( 'illegal request--nature' );
  12971. }
  12972. $staffList = $staff->find ( array (
  12973. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12974. 'asArray' => true
  12975. ) );
  12976. $categoryList = $staff->find ( array (
  12977. 'select' => 'COUNT(*) as count,cid,category',
  12978. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12979. 'groupby' => 'cid',
  12980. 'asArray' => true
  12981. ) );
  12982. $list = array ();
  12983. foreach($aiList as $key=>$value){
  12984. foreach ($value as $v){
  12985. $subtotal[$key][$v['name']]=0;
  12986. }
  12987. }
  12988. foreach ( $categoryList as $vlu ) {
  12989. $s1 = 0;
  12990. $m1 = 0;
  12991. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12992. foreach ( $staffList as $value ) {
  12993. if ($vlu ['cid'] == $value ['cid']) {
  12994. // pastDate
  12995. $receiptCollectList = $receiptDetail->find ( array (
  12996. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12997. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12998. 'groupby' => 'item,Month(pastDate),itemCategory',
  12999. 'asArray' => true
  13000. ) );
  13001. if (! empty ( $receiptCollectList )) {
  13002. $receiptL = array (
  13003. '日常相关费用' => array (),
  13004. '差旅相关费用' => array (),
  13005. '内部培训费用' => array (),
  13006. '培训班费用' => array (),
  13007. '其他' => array ()
  13008. );
  13009. $html = "";
  13010. $psum = 0;
  13011. foreach ( $aiList[$this->AGENCY] as $va ) {
  13012. $falg = true;
  13013. foreach ( $receiptCollectList as $v ) {
  13014. if ($v ['itemCategory'] == '日常相关费用') {
  13015. if ($v ['item'] == $va['name']) {
  13016. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13017. $psum += $v ['price'];
  13018. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13019. $falg = false;
  13020. break;
  13021. }
  13022. }
  13023. }
  13024. if ($falg)
  13025. $html .= '<td class="taR">-</td>';
  13026. }
  13027. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13028. if (! empty ( $psum ))
  13029. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13030. else
  13031. $psum = '<td class="colGreen taR">-</td>';
  13032. $receiptL ['日常相关费用'] = $psum . $html;
  13033. /* ----------------------------------- */
  13034. $html = "";
  13035. $psum = 0;
  13036. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13037. $falg = true;
  13038. foreach ( $receiptCollectList as $v ) {
  13039. if ($v ['itemCategory'] == '差旅相关费用') {
  13040. if ($v ['item'] == $va['name']) {
  13041. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13042. $psum += $v ['price'];
  13043. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13044. $falg = false;
  13045. break;
  13046. }
  13047. }
  13048. }
  13049. if ($falg)
  13050. $html .= '<td class="taR">-</td>';
  13051. }
  13052. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13053. if (! empty ( $psum ))
  13054. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13055. else
  13056. $psum = '<td class="colGreen taR">-</td>';
  13057. $receiptL ['差旅相关费用'] = $psum . $html;
  13058. /* ------------------------------------- */
  13059. $html = "";
  13060. $psum = 0;
  13061. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13062. $falg = true;
  13063. foreach ( $receiptCollectList as $v ) {
  13064. if ($v ['itemCategory'] == '内部培训费用') {
  13065. if ($v ['item'] == $va['name']) {
  13066. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13067. $psum += $v ['price'];
  13068. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13069. $falg = false;
  13070. break;
  13071. }
  13072. }
  13073. }
  13074. if ($falg)
  13075. $html .= '<td class="taR">-</td>';
  13076. }
  13077. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13078. if (! empty ( $psum ))
  13079. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13080. else
  13081. $psum = '<td class="colGreen taR">-</td>';
  13082. $receiptL ['内部培训费用'] = $psum . $html;
  13083. /* ----------------------------------- */
  13084. $html = "";
  13085. $psum = 0;
  13086. foreach ( $aiList[$this->TRAIN] as $va ) {
  13087. $falg = true;
  13088. foreach ( $receiptCollectList as $v ) {
  13089. if ($v ['itemCategory'] == '培训班费用') {
  13090. if ($v ['item'] == $va['name']) {
  13091. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13092. $psum += $v ['price'];
  13093. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13094. $falg = false;
  13095. break;
  13096. }
  13097. }
  13098. }
  13099. if ($falg)
  13100. $html .= '<td class="taR">-</td>';
  13101. }
  13102. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13103. if (! empty ( $psum ))
  13104. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13105. else
  13106. $psum = '<td class="colGreen taR">-</td>';
  13107. $receiptL ['培训班费用'] = $psum . $html;
  13108. /* ------------------------------------- */
  13109. $html = "";
  13110. $psum = 0;
  13111. foreach ( $aiList[$this->OTHER] as $va ) {
  13112. $falg = true;
  13113. foreach ( $receiptCollectList as $v ) {
  13114. if ($v ['itemCategory'] == '其他') {
  13115. if (trim ( $v ['item'] ) == $va['name']) {
  13116. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13117. $psum += $v ['price'];
  13118. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13119. $falg = false;
  13120. break;
  13121. }
  13122. }
  13123. }
  13124. if ($falg)
  13125. $html .= '<td class="taR">-</td>';
  13126. }
  13127. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13128. if (! empty ( $psum ))
  13129. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13130. else
  13131. $psum = '<td class="colGreen taR">-</td>';
  13132. $receiptL ['其他'] = $psum . $html;
  13133. /* ------------------------------------- */
  13134. $html = "";
  13135. $psum = 0;
  13136. foreach ( $receiptCollectList as $v ) {
  13137. if ($v ['itemCategory'] == '报销金额调整') {
  13138. if (! empty ( $v ['price'] )) {
  13139. $psum += $v ['price'];
  13140. }
  13141. }
  13142. }
  13143. $s1 += $psum;
  13144. if (! empty ( $psum ))
  13145. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13146. else
  13147. $psum = '<td class="taR colOrange">-</td>';
  13148. $receiptL ['报销金额调整'] = $psum . $html;
  13149. } else {
  13150. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13151. foreach ( $aiList[$this->AGENCY] as $va ) {
  13152. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13153. }
  13154. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13155. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13156. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13157. }
  13158. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13159. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13160. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13161. }
  13162. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13163. foreach ( $aiList[$this->TRAIN] as $va ) {
  13164. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13165. }
  13166. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13167. foreach ( $aiList[$this->OTHER] as $va ) {
  13168. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13169. }
  13170. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13171. }
  13172. $monthStaffPrice = $receiptDetail->find ( array (
  13173. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13174. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13175. 'groupby' => 'Month(pastDate)',
  13176. 'asArray' => true
  13177. ) );
  13178. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13179. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13180. $m1 += $monthStaffPrice [0] ['price'];
  13181. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13182. } else
  13183. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13184. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13185. $list [$value ['username']] = $receiptL;
  13186. }
  13187. }
  13188. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13189. foreach ( $aiList[$this->AGENCY] as $va ) {
  13190. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13191. $subtotal[$this->AGENCY][$va['name']]=0;
  13192. }
  13193. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13194. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13195. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13196. $subtotal[$this->TRAVEL][$va['name']]=0;
  13197. }
  13198. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13199. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13200. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13201. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13202. }
  13203. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13204. foreach ( $aiList[$this->TRAIN] as $va ) {
  13205. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13206. $subtotal[$this->TRAIN][$va['name']]=0;
  13207. }
  13208. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13209. foreach ( $aiList[$this->OTHER] as $va ) {
  13210. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13211. $subtotal[$this->OTHER][$va['name']]=0;
  13212. }
  13213. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13214. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13215. $receiptL ['usernameEn'] =false;
  13216. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13217. }
  13218. $data ['list'] = $list;
  13219. // print_r($list);
  13220. $receiptCollectList = $receiptDetail->find ( array (
  13221. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13222. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13223. 'groupby' => 'item,Month(pastDate),itemCategory',
  13224. 'asArray' => true
  13225. ) );
  13226. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13227. // statistics html
  13228. $stList = $statistics->getOne ( array (
  13229. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13230. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13231. 'groupby' => 'Month(date)',
  13232. 'asArray' => true
  13233. ) );
  13234. if (empty ( $stList ))
  13235. $stList = array (
  13236. 'rePrice' => 0,
  13237. 'agPrice' => 0
  13238. );
  13239. $data ['stList'] = array (
  13240. 'rePrice' => $stList ['rePrice'],
  13241. 'agPrice' => $stList ['agPrice'],
  13242. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13243. );
  13244. $monthHtml = "";
  13245. for($i = 1; $i <= 12; $i ++) {
  13246. if ($i == $month)
  13247. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13248. else
  13249. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13250. }
  13251. $data ['monthHtml'] = $monthHtml;
  13252. $data ['year'] = $year;
  13253. $data ['month'] = $month;
  13254. $data ['nature'] = $nature;
  13255. $data ['aiList'] = $aiList;
  13256. $data ['memu'] = "receipt";
  13257. $data ['staff'] = $this->staff;
  13258. $data ['receiptMemu'] = 'companyCategoryCollect';
  13259. $data ['verifyId'] = $this->verifyId;
  13260. $data ['executeId'] = $this->executeId;
  13261. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13262. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13263. }
  13264. function staffCollectMonthDetail2() {
  13265. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13266. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13267. if (! $year)
  13268. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13269. if (! $month)
  13270. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13271. Doo::loadModel ( 'staff' );
  13272. $staff = new staff ();
  13273. Doo::loadModel ( "receiptDetail" );
  13274. $receiptDetail = new receiptDetail ();
  13275. Doo::loadModel ( 'accountItem' );
  13276. $accountItem = new accountItem ();
  13277. Doo::loadModel ( 'statistics' );
  13278. $statistics = new statistics ();
  13279. Doo::loadModel ( 'L_category' );
  13280. $lCategory = new L_category ();
  13281. $staffList = $staff->find ( array (
  13282. 'where' => 'username!="admin"',
  13283. 'asArray' => true
  13284. ) );
  13285. $categoryList = $staff->find ( array (
  13286. 'select' => 'COUNT(*) as count,cid,category',
  13287. 'where' => 'username !="admin"',
  13288. 'groupby' => 'cid',
  13289. 'asArray' => true
  13290. ) );
  13291. $list = array ();
  13292. foreach ( $categoryList as $vlu ) {
  13293. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13294. $r1 = 0;
  13295. $r2 = 0;
  13296. $r3 = 0;
  13297. $r4 = 0;
  13298. $r5 = 0;
  13299. $r6 = 0;
  13300. $r7 = 0;
  13301. $r8 = 0;
  13302. $r9 = 0;
  13303. $r10 = 0;
  13304. $r11 = 0;
  13305. $r12 = 0;
  13306. $r13 = 0;
  13307. $r14 = 0;
  13308. $r15 = 0;
  13309. $c1 = 0;
  13310. $c2 = 0;
  13311. $c3 = 0;
  13312. $c4 = 0;
  13313. $c5 = 0;
  13314. $c6 = 0;
  13315. $p1 = 0;
  13316. $p2 = 0;
  13317. $p3 = 0;
  13318. $p4 = 0;
  13319. $p5 = 0;
  13320. $p6 = 0;
  13321. $p7 = 0;
  13322. $p8 = 0;
  13323. $p9 = 0;
  13324. $t1 = 0;
  13325. $t2 = 0;
  13326. $t3 = 0;
  13327. $t4 = 0;
  13328. $t5 = 0;
  13329. $s1 = 0;
  13330. $m1 = 0;
  13331. foreach ( $staffList as $value ) {
  13332. if ($vlu ['cid'] == $value ['cid']) {
  13333. $receiptCollectList = $receiptDetail->find ( array (
  13334. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13335. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13336. 'groupby' => 'item,Month(date),itemCategory',
  13337. 'asArray' => true
  13338. ) );
  13339. if (! empty ( $receiptCollectList )) {
  13340. $receiptL = array (
  13341. '日常相关费用' => array (),
  13342. '差旅相关费用' => array (),
  13343. '培训班费用' => array (),
  13344. '其他' => array ()
  13345. );
  13346. $html = "";
  13347. $psum = 0;
  13348. $item = array (
  13349. '市内交通费',
  13350. '市内出租费',
  13351. '办事处房租',
  13352. '电话费',
  13353. '水费',
  13354. '电费',
  13355. '办公费用',
  13356. '邮寄费',
  13357. '其他费用',
  13358. '车辆费用',
  13359. '广告费',
  13360. '团队建设费',
  13361. '物业管理费',
  13362. '宽带费'
  13363. );
  13364. foreach ( $item as $va ) {
  13365. $falg = true;
  13366. foreach ( $receiptCollectList as $v ) {
  13367. if ($v ['itemCategory'] == '日常相关费用') {
  13368. if ($v ['item'] == $va) {
  13369. if ($va == '市内交通费')
  13370. $r1 += $v ['price'];
  13371. if ($va == '市内出租费')
  13372. $r2 += $v ['price'];
  13373. if ($va == '办事处房租')
  13374. $r3 += $v ['price'];
  13375. if ($va == '电话费')
  13376. $r4 += $v ['price'];
  13377. if ($va == '水费')
  13378. $r5 += $v ['price'];
  13379. if ($va == '电费')
  13380. $r6 += $v ['price'];
  13381. if ($va == '办公费用')
  13382. $r7 += $v ['price'];
  13383. if ($va == '邮寄费')
  13384. $r8 += $v ['price'];
  13385. if ($va == '其他费用')
  13386. $r9 += $v ['price'];
  13387. if ($va == '车辆费用')
  13388. $r10 += $v ['price'];
  13389. if ($va == '广告费')
  13390. $r11 += $v ['price'];
  13391. if ($va == '团队建设费')
  13392. $r13 += $v ['price'];
  13393. if ($va == '物业管理费')
  13394. $r14 += $v ['price'];
  13395. if ($va == '宽带费')
  13396. $r15 += $v ['price'];
  13397. $psum += $v ['price'];
  13398. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13399. $falg = false;
  13400. break;
  13401. }
  13402. }
  13403. }
  13404. if ($falg)
  13405. $html .= '<td class="taR">-</td>';
  13406. }
  13407. $r12 += $psum;
  13408. if (! empty ( $psum ))
  13409. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13410. else
  13411. $psum = '<td class="colGreen taR">-</td>';
  13412. $receiptL ['日常相关费用'] = $psum . $html;
  13413. /* ----------------------------------- */
  13414. $html = "";
  13415. $psum = 0;
  13416. $item = array (
  13417. '往来交通费',
  13418. '市内交通费',
  13419. '出差住宿费',
  13420. '出差补助',
  13421. '其他费用'
  13422. );
  13423. foreach ( $item as $va ) {
  13424. $falg = true;
  13425. foreach ( $receiptCollectList as $v ) {
  13426. if ($v ['itemCategory'] == '差旅相关费用') {
  13427. if ($v ['item'] == $va) {
  13428. if ($va == '往来交通费')
  13429. $c1 += $v ['price'];
  13430. if ($va == '市内交通费')
  13431. $c2 += $v ['price'];
  13432. if ($va == '出差住宿费')
  13433. $c3 += $v ['price'];
  13434. if ($va == '出差补助')
  13435. $c4 += $v ['price'];
  13436. if ($va == '其他费用')
  13437. $c5 += $v ['price'];
  13438. $psum += $v ['price'];
  13439. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13440. $falg = false;
  13441. break;
  13442. }
  13443. }
  13444. }
  13445. if ($falg)
  13446. $html .= '<td class="taR">-</td>';
  13447. }
  13448. $c6 += $psum;
  13449. if (! empty ( $psum ))
  13450. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13451. else
  13452. $psum = '<td class="colGreen taR">-</td>';
  13453. $receiptL ['差旅相关费用'] = $psum . $html;
  13454. /* ------------------------------------- */
  13455. $html = "";
  13456. $psum = 0;
  13457. $item = array (
  13458. '场租费',
  13459. '薪酬',
  13460. '住宿费',
  13461. '交通费',
  13462. '餐饮费',
  13463. '办公费',
  13464. '公关费',
  13465. '其他'
  13466. );
  13467. foreach ( $item as $va ) {
  13468. $falg = true;
  13469. foreach ( $receiptCollectList as $v ) {
  13470. if ($v ['itemCategory'] == '培训班费用') {
  13471. if ($v ['item'] == $va) {
  13472. if ($va == '场租费')
  13473. $p1 += $v ['price'];
  13474. if ($va == '薪酬')
  13475. $p2 += $v ['price'];
  13476. if ($va == '住宿费')
  13477. $p3 += $v ['price'];
  13478. if ($va == '交通费')
  13479. $p4 += $v ['price'];
  13480. if ($va == '餐饮费')
  13481. $p5 += $v ['price'];
  13482. if ($va == '办公费')
  13483. $p6 += $v ['price'];
  13484. if ($va == '公关费')
  13485. $p7 += $v ['price'];
  13486. if ($va == '其他')
  13487. $p8 += $v ['price'];
  13488. $psum += $v ['price'];
  13489. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13490. $falg = false;
  13491. break;
  13492. }
  13493. }
  13494. }
  13495. if ($falg)
  13496. $html .= '<td class="taR">-</td>';
  13497. }
  13498. $p9 += $psum;
  13499. if (! empty ( $psum ))
  13500. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13501. else
  13502. $psum = '<td class="colGreen taR">-</td>';
  13503. $receiptL ['培训班费用'] = $psum . $html;
  13504. /* ------------------------------------- */
  13505. $html = "";
  13506. $psum = 0;
  13507. $item = array (
  13508. '公关费',
  13509. '广告费',
  13510. '借款',
  13511. '可自加费用'
  13512. );
  13513. foreach ( $item as $va ) {
  13514. $falg = true;
  13515. foreach ( $receiptCollectList as $v ) {
  13516. if ($v ['itemCategory'] == '其他') {
  13517. if ($v ['item'] == $va) {
  13518. if ($va == '公关费')
  13519. $t1 += $v ['price'];
  13520. if ($va == '广告费')
  13521. $t2 += $v ['price'];
  13522. if ($va == '借款')
  13523. $t3 += $v ['price'];
  13524. if ($va == '可自加费用')
  13525. $t4 += $v ['price'];
  13526. $psum += $v ['price'];
  13527. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13528. $falg = false;
  13529. break;
  13530. }
  13531. }
  13532. }
  13533. if ($falg)
  13534. $html .= '<td class="taR">-</td>';
  13535. }
  13536. $t5 += $psum;
  13537. if (! empty ( $psum ))
  13538. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13539. else
  13540. $psum = '<td class="colGreen taR">-</td>';
  13541. $receiptL ['其他'] = $psum . $html;
  13542. /* ------------------------------------- */
  13543. $html = "";
  13544. $psum = 0;
  13545. foreach ( $receiptCollectList as $v ) {
  13546. if ($v ['itemCategory'] == '报销金额调整') {
  13547. if (! empty ( $v ['price'] )) {
  13548. $psum += $v ['price'];
  13549. }
  13550. }
  13551. }
  13552. $s1 += $psum;
  13553. if (! empty ( $psum ))
  13554. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13555. else
  13556. $psum = '<td class="taR colOrange">-</td>';
  13557. $receiptL ['报销金额调整'] = $psum . $html;
  13558. } else {
  13559. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13560. <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>';
  13561. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13562. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13563. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13564. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13565. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13566. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13567. }
  13568. $monthStaffPrice = $receiptDetail->find ( array (
  13569. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13570. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13571. 'asArray' => true
  13572. ) );
  13573. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13574. $m1 += $monthStaffPrice [0] ['price'];
  13575. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13576. } else
  13577. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13578. $list [$value ['username']] = $receiptL;
  13579. }
  13580. }
  13581. $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>
  13582. <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>
  13583. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13584. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13585. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13586. $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>
  13587. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13588. $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>';
  13589. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13590. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13591. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13592. }
  13593. $data ['list'] = $list;
  13594. $receiptCollectList = $receiptDetail->find ( array (
  13595. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13596. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13597. 'groupby' => 'item,Month(date),itemCategory',
  13598. 'asArray' => true
  13599. ) );
  13600. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13601. // statistics html
  13602. $stList = $statistics->getOne ( array (
  13603. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13604. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13605. 'groupby' => 'Month(date)',
  13606. 'asArray' => true
  13607. ) );
  13608. if (empty ( $stList ))
  13609. $stList = array (
  13610. 'rePrice' => 0,
  13611. 'agPrice' => 0
  13612. );
  13613. $data ['stList'] = array (
  13614. 'rePrice' => $stList ['rePrice'],
  13615. 'agPrice' => $stList ['agPrice'],
  13616. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13617. );
  13618. $monthHtml = "";
  13619. for($i = 1; $i <= 12; $i ++) {
  13620. if ($i == $month)
  13621. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13622. else
  13623. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13624. }
  13625. $data ['monthHtml'] = $monthHtml;
  13626. $data ['year'] = $year;
  13627. $data ['month'] = $month;
  13628. $data ['memu'] = "receipt";
  13629. $data ['staff'] = $this->staff;
  13630. $data ['receiptMemu'] = 'companyCategoryCollect';
  13631. $data ['verifyId'] = $this->verifyId;
  13632. $data ['executeId'] = $this->executeId;
  13633. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13634. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13635. }
  13636. /**
  13637. * 用户报销单列表
  13638. */
  13639. function receiptStatisticsStaffDetail() {
  13640. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13641. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13642. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13643. Doo::loadModel ( "receipt" );
  13644. $receipt = new receipt ();
  13645. Doo::loadModel ( "receiptDetail" );
  13646. $receiptDetail = new receiptDetail ();
  13647. Doo::loadModel ( 'staff' );
  13648. $staff = new staff ();
  13649. Doo::loadModel ( 'accountItem' );
  13650. $accountItem = new accountItem ();
  13651. Doo::loadModel ( 'statistics' );
  13652. $statistics = new statistics ();
  13653. if (! empty ( $username )) {
  13654. $username = addslashes ( urldecode ( $username ) );
  13655. $staffDetail = $staff->getStaffByName ( $username );
  13656. if (empty ( $staffDetail ))
  13657. die ( 'illegal request' );
  13658. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13659. $itemList = $accountItem->getAccountItem ();
  13660. $itemHtml = '';
  13661. $categoryHtml = '';
  13662. $itemKeyList = array_keys ( $itemList );
  13663. $revisePrice = 0;
  13664. // 报销单内容详情
  13665. foreach ( $list as $key => $value ) {
  13666. $accountItemList = json_decode ( $value ['accountItem'], true );
  13667. $list [$key] ['accountItemList'] = $accountItemList;
  13668. $receiptItemHtml = '';
  13669. foreach ( $itemKeyList as $v ) {
  13670. if ($v == '日常相关费用')
  13671. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13672. elseif ($v == '差旅相关费用')
  13673. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13674. elseif ($v == '培训班费用')
  13675. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13676. elseif ($v == '内部培训费用'){
  13677. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13678. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13679. }else{
  13680. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13681. }
  13682. }elseif ($v == '其他')
  13683. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13684. foreach ( $itemList [$v] as $ke => $va ) {
  13685. $falg = true;
  13686. if (! empty ( $accountItemList [$v] )) {
  13687. foreach ( $accountItemList [$v] as $ve ) {
  13688. if ($va ['name'] == $ve ['name']) {
  13689. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13690. $falg = false;
  13691. break;
  13692. }
  13693. }
  13694. }
  13695. if ($falg)
  13696. $receiptItemHtml .= '<td class="taR"></td>';
  13697. }
  13698. }
  13699. // 金额调整和费用查看
  13700. $revisePrice += $value ['revisePrice'];
  13701. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13702. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13703. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13704. }
  13705. // 报销单合计
  13706. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13707. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13708. $receiptTotalHtml = '';
  13709. // 报销单项目抬头
  13710. foreach ( $itemKeyList as $value ) {
  13711. $count = count ( $itemList [$value] ) + 1;
  13712. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13713. $categoryHtml .= '<th class="taC">合计</th>';
  13714. $sumfalg=true;
  13715. foreach ( $rtl as $rtlValue ) {
  13716. if ($rtlValue ['itemCategory'] == $value) {
  13717. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13718. $sumfalg=false;
  13719. break;
  13720. }
  13721. }
  13722. if ($sumfalg)
  13723. $receiptTotalHtml .= '<th></th>';
  13724. foreach ( $itemList [$value] as $k => $v ) {
  13725. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13726. // 合计
  13727. $falg = true;
  13728. foreach ( $receiptTotalList as $ve ) {
  13729. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13730. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13731. $falg = false;
  13732. break;
  13733. }
  13734. }
  13735. if ($falg)
  13736. $receiptTotalHtml .= '<th></th>';
  13737. }
  13738. }
  13739. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13740. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13741. if (empty ( $stList ))
  13742. $stList = array (
  13743. 'rePrice' => 0,
  13744. 'agPrice' => 0
  13745. );
  13746. $data ['stList'] = array (
  13747. 'rePrice' => $stList ['rePrice'],
  13748. 'agPrice' => $stList ['agPrice'],
  13749. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13750. );
  13751. $monthHtml = "";
  13752. for($i = 1; $i <= 12; $i ++) {
  13753. if ($i == $month)
  13754. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13755. else
  13756. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13757. }
  13758. $data ['username'] = urlencode ( $username );
  13759. $data ['usernameEN'] = $username;
  13760. $data ['monthHtml'] = $monthHtml;
  13761. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13762. $data ['list'] = $list;
  13763. $data ['categoryHtml'] = $categoryHtml;
  13764. $data ['itemHtml'] = $itemHtml;
  13765. $data ['itemList'] = $itemList;
  13766. $data ['year'] = $year;
  13767. $data ['month'] = $month;
  13768. $data ['memu'] = "receipt";
  13769. $data ['staff'] = $this->staff;
  13770. $data ['receiptMemu'] = 'companyCategoryCollect';
  13771. $data ['verifyId'] = $this->verifyId;
  13772. $data ['executeId'] = $this->executeId;
  13773. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13774. }
  13775. die ( 'illegal request' );
  13776. }
  13777. function companyMonthCollectDetail() {
  13778. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13779. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13780. if (! $year)
  13781. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13782. if (! $month)
  13783. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13784. Doo::loadModel ( 'staff' );
  13785. $staff = new staff ();
  13786. Doo::loadModel ( "receiptDetail" );
  13787. $receiptDetail = new receiptDetail ();
  13788. Doo::loadModel ( 'accountItem' );
  13789. $accountItem = new accountItem ();
  13790. Doo::loadModel ( 'statistics' );
  13791. $statistics = new statistics ();
  13792. Doo::loadModel ( 'L_category' );
  13793. $lCategory = new L_category ();
  13794. $staffList = $staff->find ( array (
  13795. 'where' => 'username!="admin"',
  13796. 'asArray' => true
  13797. ) );
  13798. $categoryList = $lCategory->find ( array (
  13799. 'asArray' => true
  13800. ) );
  13801. $aiList=$accountItem->getAccountItem();
  13802. $list = array ();
  13803. foreach ( $categoryList as $value ) {
  13804. $receiptCollectList = $receiptDetail->find ( array (
  13805. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13806. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13807. 'groupby' => 'item,Month(pastDate),itemCategory',
  13808. 'asArray' => true
  13809. ) );
  13810. if (! empty ( $receiptCollectList )) {
  13811. $receiptL = array (
  13812. '日常相关费用' => array (),
  13813. '差旅相关费用' => array (),
  13814. '内部培训费用' => array (),
  13815. '培训班费用' => array (),
  13816. '其他' => array ()
  13817. );
  13818. $html = "";
  13819. $psum = 0;
  13820. foreach ( $aiList[$this->AGENCY] as $va ) {
  13821. $falg = true;
  13822. foreach ( $receiptCollectList as $v ) {
  13823. if ($v ['itemCategory'] == $this->AGENCY) {
  13824. if ($v ['item'] == $va['name']) {
  13825. $psum += $v ['price'];
  13826. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13827. $falg = false;
  13828. break;
  13829. }
  13830. }
  13831. }
  13832. if ($falg)
  13833. $html .= '<td class="taR">-</td>';
  13834. }
  13835. if (! empty ( $psum ))
  13836. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13837. else
  13838. $psum = '<td class="colGreen taR">-</td>';
  13839. $receiptL [$this->AGENCY] = $psum . $html;
  13840. /* ----------------------------------- */
  13841. $html = "";
  13842. $psum = 0;
  13843. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13844. $falg = true;
  13845. foreach ( $receiptCollectList as $v ) {
  13846. if ($v ['itemCategory'] == $this->TRAVEL) {
  13847. if ($v ['item'] == $va['name']) {
  13848. $psum += $v ['price'];
  13849. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13850. $falg = false;
  13851. break;
  13852. }
  13853. }
  13854. }
  13855. if ($falg)
  13856. $html .= '<td class="taR">-</td>';
  13857. }
  13858. if (! empty ( $psum ))
  13859. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13860. else
  13861. $psum = '<td class="colGreen taR">-</td>';
  13862. $receiptL [$this->TRAVEL] = $psum . $html;
  13863. /* ------------------------------------- */
  13864. $html = "";
  13865. $psum = 0;
  13866. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13867. $falg = true;
  13868. foreach ( $receiptCollectList as $v ) {
  13869. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13870. if ($v ['item'] == $va['name']) {
  13871. $psum += $v ['price'];
  13872. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13873. $falg = false;
  13874. break;
  13875. }
  13876. }
  13877. }
  13878. if ($falg)
  13879. $html .= '<td class="taR">-</td>';
  13880. }
  13881. if (! empty ( $psum ))
  13882. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13883. else
  13884. $psum = '<td class="colGreen taR">-</td>';
  13885. $receiptL [$this->INTTRAIN] = $psum . $html;
  13886. /* ------------------------------------- */
  13887. $html = "";
  13888. $psum = 0;
  13889. foreach ( $aiList[$this->TRAIN] as $va ) {
  13890. $falg = true;
  13891. foreach ( $receiptCollectList as $v ) {
  13892. if ($v ['itemCategory'] == $this->TRAIN) {
  13893. if ($v ['item'] == $va['name']) {
  13894. $psum += $v ['price'];
  13895. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13896. $falg = false;
  13897. break;
  13898. }
  13899. }
  13900. }
  13901. if ($falg)
  13902. $html .= '<td class="taR">-</td>';
  13903. }
  13904. if (! empty ( $psum ))
  13905. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13906. else
  13907. $psum = '<td class="colGreen taR">-</td>';
  13908. $receiptL [$this->TRAIN] = $psum . $html;
  13909. /* ------------------------------------- */
  13910. $html = "";
  13911. $psum = 0;
  13912. foreach ( $aiList[$this->OTHER] as $va ) {
  13913. $falg = true;
  13914. foreach ( $receiptCollectList as $v ) {
  13915. if ($v ['itemCategory'] == $this->OTHER) {
  13916. if ($v ['item'] == $va['name']) {
  13917. $psum += $v ['price'];
  13918. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13919. $falg = false;
  13920. break;
  13921. }
  13922. }
  13923. }
  13924. if ($falg)
  13925. $html .= '<td class="taR">-</td>';
  13926. }
  13927. if (! empty ( $psum ))
  13928. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13929. else
  13930. $psum = '<td class="colGreen taR">-</td>';
  13931. $receiptL [$this->OTHER] = $psum . $html;
  13932. /* ------------------------------------- */
  13933. $html = "";
  13934. $psum = 0;
  13935. foreach ( $receiptCollectList as $v ) {
  13936. if ($v ['itemCategory'] == '报销金额调整') {
  13937. if (! empty ( $v ['price'] ))
  13938. $psum += $v ['price'];
  13939. }
  13940. }
  13941. if (! empty ( $psum ))
  13942. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13943. else
  13944. $psum = '<td class="taR colOrange">-</td>';
  13945. $receiptL ['报销金额调整'] = $psum . $html;
  13946. } else {
  13947. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13948. foreach ( $aiList[$this->AGENCY] as $va ) {
  13949. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13950. }
  13951. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13952. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13953. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13954. }
  13955. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13956. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13957. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13958. }
  13959. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13960. foreach ( $aiList[$this->TRAIN] as $va ) {
  13961. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13962. }
  13963. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13964. foreach ( $aiList[$this->OTHER] as $va ) {
  13965. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13966. }
  13967. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13968. }
  13969. $monthStaffPrice = $receiptDetail->find ( array (
  13970. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13971. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13972. 'asArray' => true
  13973. ) );
  13974. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13975. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13976. else
  13977. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13978. $list [$value ['title']] = $receiptL;
  13979. }
  13980. $data ['list'] = $list;
  13981. $receiptCollectList = $receiptDetail->find ( array (
  13982. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13983. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13984. 'groupby' => 'item,Month(pastDate),itemCategory',
  13985. 'asArray' => true
  13986. ) );
  13987. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13988. //print_r($data['monthPriceHtml']);
  13989. // foreach ($data['monthPriceHtml'] as $value){
  13990. // echo $value;
  13991. // }
  13992. // die;
  13993. // statistics html
  13994. $stList = $statistics->getOne ( array (
  13995. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13996. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13997. 'groupby' => 'Month(date)',
  13998. 'asArray' => true
  13999. ) );
  14000. if (empty ( $stList ))
  14001. $stList = array (
  14002. 'rePrice' => 0,
  14003. 'agPrice' => 0
  14004. );
  14005. $data ['stList'] = array (
  14006. 'rePrice' => $stList ['rePrice'],
  14007. 'agPrice' => $stList ['agPrice'],
  14008. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14009. );
  14010. $monthHtml = "";
  14011. for($i = 1; $i <= 12; $i ++) {
  14012. if ($i == $month)
  14013. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14014. else
  14015. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14016. }
  14017. $data ['aiList'] = $aiList;
  14018. $dateHtml = "";
  14019. $now = date ( "Y" );
  14020. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14021. if ($YEARD <= $now) {
  14022. $dateHtml .= '<option ';
  14023. if ($year == $YEARD) {
  14024. $dateHtml .= 'selected ';
  14025. }
  14026. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14027. }
  14028. }
  14029. $data ['dateHtml'] = $dateHtml;
  14030. $data ['monthHtml'] = $monthHtml;
  14031. $data ['year'] = $year;
  14032. $data ['month'] = $month;
  14033. $data ['memu'] = "receipt";
  14034. $data ['staff'] = $this->staff;
  14035. $data ['receiptMemu'] = 'companyCategoryCollect';
  14036. $data ['verifyId'] = $this->verifyId;
  14037. $data ['executeId'] = $this->executeId;
  14038. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14039. }
  14040. function staffCollectDetail() {
  14041. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14042. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14043. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14044. if (! $staffname) {
  14045. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14046. $staffname = urldecode ( $staffname );
  14047. }
  14048. Doo::loadModel ( 'staff' );
  14049. $staff = new staff ();
  14050. Doo::loadModel ( "receiptDetail" );
  14051. $receiptDetail = new receiptDetail ();
  14052. Doo::loadModel ( 'accountItem' );
  14053. $accountItem = new accountItem ();
  14054. Doo::loadModel ( 'statistics' );
  14055. $statistics = new statistics ();
  14056. Doo::loadModel ( 'L_category' );
  14057. $lCategory = new L_category ();
  14058. Doo::loadModel ( "receiptAuthorityManage" );
  14059. $receiptAuthorityManage = new receiptAuthorityManage ();
  14060. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14061. $cidList = array ();
  14062. foreach ( $imcStaff as $key => $value ) {
  14063. array_push ( $cidList, $value ['cid'] );
  14064. }
  14065. $cidString = implode ( ',', $cidList );
  14066. $staffList = $staff->find ( array (
  14067. 'where' => ' cid in (' . $cidString . ')',
  14068. 'asArray' => true
  14069. ) );
  14070. $stHtml = '';
  14071. $stTitle = "";
  14072. $staffId = 0;
  14073. $cid = 0;
  14074. $ocid = 0;
  14075. foreach ( $staffList as $value ) {
  14076. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14077. $stTitle = $value ['category'] . '-' . $value ['username'];
  14078. $staffId = $value ['sid'];
  14079. $cid = $value ['cid'];
  14080. $ocid = $value ['cid'];
  14081. if (! empty ( $value ['othercid'] ))
  14082. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14083. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14084. } elseif ($value ['username'] != 'admin')
  14085. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14086. }
  14087. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14088. 'where' => 'cid in(' . $cid . ')',
  14089. 'asArray' => true
  14090. ) );
  14091. if (empty ( $pcid ))
  14092. $pcid = $ocid;
  14093. $data ['ocid'] = $pcid;
  14094. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14095. $this->showCache ( $path );
  14096. //
  14097. $receiptCollectList = $receiptDetail->find ( array (
  14098. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14099. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14100. 'groupby' => 'item,Month(pastDate),itemCategory',
  14101. 'asArray' => true
  14102. ) );
  14103. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14104. // print_r($receiptCollectList);
  14105. $accountList = $accountItem->find ( array (
  14106. 'asArray' => true
  14107. ) );
  14108. // create CollectDetail HTML
  14109. $collectHtml = array ();
  14110. foreach ( $accountList as $key => $value ) {
  14111. $html = "";
  14112. $asum = 0;
  14113. for($i = 1; $i <= 12; $i ++) {
  14114. $falg = true;
  14115. foreach ( $receiptCollectList as $v ) {
  14116. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14117. if ($v ['item'] == '可自加费用') {
  14118. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14119. }
  14120. $asum += $v ['price'];
  14121. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14122. $falg = false;
  14123. break;
  14124. }
  14125. }
  14126. if ($falg)
  14127. $html .= '<td class="taR">-</td>';
  14128. }
  14129. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14130. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14131. }
  14132. $data ['collectHtml'] = $collectHtml;
  14133. // print_r($collectHtml);
  14134. // create Adjustment price html
  14135. $receiptCollectList = $receiptDetail->find ( array (
  14136. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14137. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14138. 'groupby' => 'itemCategory,Month(pastDate)',
  14139. 'asArray' => true
  14140. ) );
  14141. $adjustment = array ();
  14142. $collectArray = array (
  14143. '日常相关费用' => array (),
  14144. '差旅相关费用' => array (),
  14145. '培训班费用' => array (),
  14146. '内部培训费用'=>array(),
  14147. '其他' => array ()
  14148. );
  14149. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14150. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14151. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14152. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14153. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14154. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14155. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14156. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14157. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14158. array_push ( $collectArray ['其他'], $collectHtml );
  14159. $data ['collectArray'] = $collectArray;
  14160. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14161. array_push ( $adjustment, $collectHtml );
  14162. $data ['adjustment'] = $adjustment;
  14163. // total price html
  14164. $collectHtml = "";
  14165. $total = 0;
  14166. for($i = 1; $i <= 12; $i ++) {
  14167. $sumPrice = 0;
  14168. foreach ( $receiptCollectList as $key => $value ) {
  14169. if ($value ['month'] == $i) {
  14170. $sumPrice += $value ['price'];
  14171. }
  14172. }
  14173. if ($sumPrice == 0)
  14174. $collectHtml .= '<td class="taR">-</td>';
  14175. else
  14176. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14177. $total += $sumPrice;
  14178. }
  14179. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14180. // statistics html
  14181. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14182. if (empty ( $stList ))
  14183. $stList = array (
  14184. 'rePrice' => 0,
  14185. 'agPrice' => 0
  14186. );
  14187. $data ['stList'] = array (
  14188. 'rePrice' => $stList ['rePrice'],
  14189. 'agPrice' => $stList ['agPrice'],
  14190. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14191. );
  14192. $data ['totalPrice'] = $collectHtml;
  14193. $data ['totalYear'] = $total;
  14194. $data ['stHtml'] = $stHtml;
  14195. $data ['year'] = $year;
  14196. $data ['stTitle'] = $stTitle;
  14197. $data ['staffname'] = urlencode ( $staffname );
  14198. $data ['memu'] = "receipt";
  14199. $data ['staff'] = $this->staff;
  14200. $data ['receiptMemu'] = 'companyCategoryCollect';
  14201. $data ['verifyId'] = $this->verifyId;
  14202. $data ['executeId'] = $this->executeId;
  14203. if ($year < date ( "Y" )) {
  14204. Doo::loadModel ( 'receipt' );
  14205. $receipt = new receipt ();
  14206. $receiptList = $receipt->find ( array (
  14207. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14208. 'asArray' => true
  14209. ) );
  14210. if (empty ( $receiptList )) { // generated files
  14211. ob_start ();
  14212. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14213. $this->cacheFile ( $path );
  14214. die ();
  14215. }
  14216. }
  14217. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14218. }
  14219. function BUGFLAG() {
  14220. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14221. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14222. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14223. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14224. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14225. if (empty ( $status ))
  14226. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14227. $page_size = 12;
  14228. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14229. $vidList = array ();
  14230. $button = 0;
  14231. Doo::loadModel ( 'verify' );
  14232. $verify = new verify ();
  14233. Doo::loadModel ( 'receipt' );
  14234. $receipt = new receipt ();
  14235. Doo::loadModel ( 'staff' );
  14236. $staff = new staff ();
  14237. Doo::loadModel ( 'L_category' );
  14238. $Lcategory = new L_category ();
  14239. $dateCondition = " and Year(date) =" . $year;
  14240. if (! empty ( $month ))
  14241. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14242. $categoryList = $Lcategory->find ( array (
  14243. 'asArray' => true
  14244. ) );
  14245. $staffList = $staff->find ( array (
  14246. 'where' => 'cid=' . $cid,
  14247. 'asArray' => true
  14248. ) );
  14249. $cateCondition = "";
  14250. $staffCondition = "";
  14251. $approvalCondition = "";
  14252. if (! empty ( $cid ))
  14253. $cateCondition = ' and cid=' . $cid;
  14254. if (! empty ( $sid )) {
  14255. $staffCondition = ' and staff=' . $sid;
  14256. $cateCondition = "";
  14257. }
  14258. $approvalCondition = " and status=" . $status;
  14259. if ($status == 2) {
  14260. // 查找角色审批人
  14261. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14262. }
  14263. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14264. $approvalCondition = ' and status=2 ';
  14265. }
  14266. if ($status == 1) {
  14267. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14268. }
  14269. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14270. $pageinfo ['page'] = array (
  14271. 'previous' => ''
  14272. );
  14273. if ($status == 0) {
  14274. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14275. $receiptList = $receipt->find ( array (
  14276. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14277. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14278. 'desc' => 'rid',
  14279. 'asArray' => true
  14280. ) );
  14281. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14282. } else
  14283. $receiptList = $receipt->find ( array (
  14284. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14285. 'desc' => 'rid',
  14286. 'asArray' => true
  14287. ) );
  14288. $rLRes = $receipt->find ( array (
  14289. '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,
  14290. 'desc' => 'rid',
  14291. 'asArray' => true
  14292. ) );
  14293. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14294. // print_r($pageinfo);
  14295. $Locate = 0;
  14296. foreach ( $receiptList as $key => $value ) {
  14297. $receiptList [$key] ['Locate'] = $Locate;
  14298. $Locate ++;
  14299. $receiptList [$key] ['reviseDetail'] = array ();
  14300. if (! empty ( $value ['reviseDetail'] ))
  14301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14303. $categoryDetil = $Lcategory->getOne ( array (
  14304. 'where' => 'cid=' . $value ['cid'],
  14305. 'asArray' => true
  14306. ) );
  14307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14308. $verifyList = $verify->getOne ( array (
  14309. 'where' => 'vid=' . $value ['verify'],
  14310. 'asArray' => true
  14311. ) );
  14312. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14313. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14314. foreach ( $verifyList as $k => $v ) {
  14315. // init verifyStaff
  14316. $verifyList [$k] ['date'] = "";
  14317. $verifyList [$k] ['opinion'] = "";
  14318. $verifyList [$k] ['status'] = "";
  14319. if (empty ( $verifyStaff )) {
  14320. $verifyList [$k] ['date'] = "";
  14321. $verifyList [$k] ['opinion'] = "";
  14322. if ($v [0] == $this->staff [0] ['sid']) {
  14323. $verifyList [$k] ['status'] = 4;
  14324. $button = 4;
  14325. }
  14326. } else {
  14327. $flag = true;
  14328. foreach ( $verifyStaff as $m => $u ) {
  14329. if ($v [0] == $m) {
  14330. $verifyList [$k] ['date'] = $u ['date'];
  14331. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14332. $verifyList [$k] ['status'] = $u ['status'];
  14333. $flag = false;
  14334. break;
  14335. }
  14336. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14337. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14338. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14339. }
  14340. if ($flag) { // 检测可编辑
  14341. if ($v [0] == $this->staff [0] ['sid']) {
  14342. $verifyList [$k] ['status'] = 4;
  14343. $button = 4;
  14344. }
  14345. }
  14346. }
  14347. }
  14348. $receiptList [$key] ['verifyList'] = $verifyList;
  14349. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14350. 'where' => 'sid=' . $value ['staff'],
  14351. 'asArray' => true
  14352. ) );
  14353. $receiptList [$key] ['button'] = $button;
  14354. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14355. }
  14356. // print_r($receiptList);die;
  14357. // $data['verifyDetail']=$verifyDetail;
  14358. $mothHtml = "";
  14359. for($i = 1; $i <= 12; $i ++) {
  14360. if ($month == $i)
  14361. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14362. else
  14363. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14364. }
  14365. $data ['mothHtml'] = $mothHtml;
  14366. $data ['page'] = $pageinfo;
  14367. $data ['receiptList'] = $receiptList;
  14368. $data ['receiptApprovalCount'] = count ( $rLRes );
  14369. $data ['status'] = $status;
  14370. $data ['year'] = $year;
  14371. $data ['categoryList'] = $categoryList;
  14372. $data ['staffList'] = $staffList;
  14373. $data ['cid'] = $cid;
  14374. $data ['sid'] = $sid;
  14375. // print_r($receiptList);
  14376. $data ['memu'] = "receipt";
  14377. $data ['staff'] = $this->staff;
  14378. $data ['receiptMemu'] = 'approvalExpenses';
  14379. $data ['verifyId'] = $this->verifyId;
  14380. $data ['executeId'] = $this->executeId;
  14381. $this->render ( "/admin/FALG", $data );
  14382. }
  14383. function ajaxGetReceiptOrder() {
  14384. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14385. if (! empty ( $receiptOrder )) {
  14386. Doo::loadModel ( 'receipt' );
  14387. $receipt = new receipt ();
  14388. Doo::loadModel ( 'staff' );
  14389. $staff = new staff ();
  14390. $receiptInfo = $receipt->getOne ( array (
  14391. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14392. 'asArray' => true
  14393. ) );
  14394. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14395. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14396. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14397. </tbody></table><table class="table table table-bordered"><tbody>';
  14398. foreach ( $verifyStaff as $key => $value ) {
  14399. $staffInfo = $staff->getOne ( array (
  14400. 'select' => 'username',
  14401. 'where' => ' sid="' . $key . '"',
  14402. 'asArray' => true
  14403. ) );
  14404. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14405. }
  14406. $html .= '</tbody></table></div></div>';
  14407. echo json_encode ( array (
  14408. 'status' => 1,
  14409. 'receiptHtml' => $html
  14410. ) );
  14411. die ();
  14412. }
  14413. echo json_encode ( array (
  14414. 'status' => 2,
  14415. 'receiptHtml' => ''
  14416. ) );
  14417. die ();
  14418. }
  14419. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14420. if (! empty ( $receiptCollectList )) {
  14421. $receiptL = array (
  14422. '日常相关费用' => array (),
  14423. '差旅相关费用' => array (),
  14424. '内部培训费用'=>array(),
  14425. '培训班费用' => array (),
  14426. '其他' => array ()
  14427. );
  14428. $html = "";
  14429. $psum = 0;
  14430. foreach ( $aiList[$this->AGENCY] as $value ) {
  14431. $falg = true;
  14432. foreach ( $receiptCollectList as $v ) {
  14433. if ($v ['itemCategory'] == '日常相关费用') {
  14434. if ($v ['item'] == $value['name']) {
  14435. $psum += $v ['price'];
  14436. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14437. $falg = false;
  14438. break;
  14439. }
  14440. }
  14441. }
  14442. if ($falg)
  14443. $html .= '<td class="taR">-</td>';
  14444. }
  14445. if (! empty ( $psum ))
  14446. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14447. else
  14448. $psum = '<td class="colGreen taR">-</td>';
  14449. $receiptL ['日常相关费用'] = $psum . $html;
  14450. /* ----------------------------------- */
  14451. $html = "";
  14452. $psum = 0;
  14453. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14454. $falg = true;
  14455. foreach ( $receiptCollectList as $v ) {
  14456. if ($v ['itemCategory'] == '差旅相关费用') {
  14457. if ($v ['item'] == $value['name']) {
  14458. $psum += $v ['price'];
  14459. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14460. $falg = false;
  14461. break;
  14462. }
  14463. }
  14464. }
  14465. if ($falg)
  14466. $html .= '<td class="taR">-</td>';
  14467. }
  14468. if (! empty ( $psum ))
  14469. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14470. else
  14471. $psum = '<td class="colGreen taR">-</td>';
  14472. $receiptL ['差旅相关费用'] = $psum . $html;
  14473. /* ----------------------------------- */
  14474. $html = "";
  14475. $psum = 0;
  14476. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14477. $falg = true;
  14478. foreach ( $receiptCollectList as $v ) {
  14479. if ($v ['itemCategory'] == '内部培训费用') {
  14480. if ($v ['item'] == $value['name']) {
  14481. $psum += $v ['price'];
  14482. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14483. $falg = false;
  14484. break;
  14485. }
  14486. }
  14487. }
  14488. if ($falg)
  14489. $html .= '<td class="taR">-</td>';
  14490. }
  14491. if (! empty ( $psum ))
  14492. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14493. else
  14494. $psum = '<td class="colGreen taR">-</td>';
  14495. $receiptL ['内部培训费用'] = $psum . $html;
  14496. /* ------------------------------------- */
  14497. $html = "";
  14498. $psum = 0;
  14499. foreach ( $aiList[$this->TRAIN] as $value ) {
  14500. $falg = true;
  14501. foreach ( $receiptCollectList as $v ) {
  14502. if ($v ['itemCategory'] == '培训班费用') {
  14503. if ($v ['item'] == $value['name']) {
  14504. $psum += $v ['price'];
  14505. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14506. $falg = false;
  14507. break;
  14508. }
  14509. }
  14510. }
  14511. if ($falg)
  14512. $html .= '<td class="taR">-</td>';
  14513. }
  14514. if (! empty ( $psum ))
  14515. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14516. else
  14517. $psum = '<td class="colGreen taR">-</td>';
  14518. $receiptL ['培训班费用'] = $psum . $html;
  14519. /* ------------------------------------- */
  14520. $html = "";
  14521. $psum = 0;
  14522. foreach ( $aiList[$this->OTHER] as $value ) {
  14523. $falg = true;
  14524. foreach ( $receiptCollectList as $v ) {
  14525. if ($v ['itemCategory'] == '其他') {
  14526. if ($v ['item'] == $value['name']) {
  14527. $psum += $v ['price'];
  14528. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14529. $falg = false;
  14530. break;
  14531. }
  14532. }
  14533. }
  14534. if ($falg)
  14535. $html .= '<td class="taR">-</td>';
  14536. }
  14537. if (! empty ( $psum ))
  14538. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14539. else
  14540. $psum = '<td class="colGreen taR">-</td>';
  14541. $receiptL ['其他'] = $psum . $html;
  14542. /* ------------------------------------- */
  14543. $html = "";
  14544. $psum = 0;
  14545. foreach ( $receiptCollectList as $v ) {
  14546. if ($v ['itemCategory'] == '报销金额调整') {
  14547. if (! empty ( $v ['price'] ))
  14548. $psum += $v ['price'];
  14549. }
  14550. }
  14551. if (! empty ( $psum ))
  14552. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14553. else
  14554. $psum = '<td class="taR colOrange">-</td>';
  14555. $receiptL ['报销金额调整'] = $psum . $html;
  14556. } else {
  14557. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14558. foreach ( $aiList[$this->AGENCY] as $va ) {
  14559. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14560. }
  14561. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14562. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14563. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14564. }
  14565. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14566. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14567. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14568. }
  14569. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14570. foreach ( $aiList[$this->TRAIN] as $va ) {
  14571. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14572. }
  14573. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14574. foreach ( $aiList[$this->OTHER] as $va ) {
  14575. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14576. }
  14577. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14578. }
  14579. return $receiptL;
  14580. }
  14581. function eMail() {
  14582. Doo::loadModel ( 'staff' );
  14583. $staff = new staff ();
  14584. Doo::loadModel ( 'receipt' );
  14585. $receipt = new receipt ();
  14586. Doo::loadModel ( 'L_category' );
  14587. $Lcategory = new L_category ();
  14588. Doo::loadModel ( "verify" );
  14589. $verify = new verify ();
  14590. $staffList = $staff->find ( array (
  14591. 'asArray' => true
  14592. ) );
  14593. foreach ( $staffList as $key => $value ) {
  14594. if ($value ['username'] != 'admin') {
  14595. // 提交人
  14596. $receiptList = $receipt->find ( array (
  14597. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14598. 'asArray' => true
  14599. ) );
  14600. if (! empty ( $receiptList )) {
  14601. $html = '<br><div><style></style>
  14602. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14603. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14604. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14605. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14606. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14607. <tbody><tr>
  14608. <td style="padding: 0 40px;" align="left">
  14609. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14610. </td></tr><tr>
  14611. <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>
  14612. </tr>
  14613. </tbody> </table></td> </tr> <tr><td>
  14614. <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">
  14615. <tbody> <tr><td>
  14616. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14617. 以下报销单完成了审批,等着收款吧:</p>
  14618. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14619. foreach ( $receiptList as $k => $v ) {
  14620. $category = $Lcategory->getOne ( array (
  14621. 'where' => 'cid=' . $v ['cid'],
  14622. 'asArray' => true
  14623. ) );
  14624. $html .= '
  14625. <tr>
  14626. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14627. <td align="left">
  14628. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14629. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14630. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14631. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14632. </tr>';
  14633. }
  14634. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14635. <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>
  14636. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14637. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14638. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14639. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14640. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14641. $receipt = new receipt ();
  14642. $receipt->notice = 1;
  14643. $receipt->update ( array (
  14644. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14645. ) );
  14646. }
  14647. }
  14648. // 审批人
  14649. $verifyList = $verify->find ( array (
  14650. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14651. 'asArray' => true
  14652. ) );
  14653. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14654. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14655. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14656. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14657. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14658. <tbody><tr><td style="padding: 0 40px;" align="left">
  14659. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14660. </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>
  14661. </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">
  14662. <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>
  14663. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14664. foreach ( $verifyList as $k => $v ) {
  14665. $receiptList = $receipt->find ( array (
  14666. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14667. 'asArray' => true
  14668. ) );
  14669. foreach ( $receiptList as $r => $l ) {
  14670. $category = $Lcategory->getOne ( array (
  14671. 'where' => 'cid=' . $l ['cid'],
  14672. 'asArray' => true
  14673. ) );
  14674. $staffDetile = $staff->getOne ( array (
  14675. 'where' => 'sid=' . $l ['staff'],
  14676. 'asArray' => true
  14677. ) );
  14678. $html .= '
  14679. <tr>
  14680. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14681. <td align="left">
  14682. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14683. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14684. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14685. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14686. </tr>';
  14687. }
  14688. }
  14689. $html .= '
  14690. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14691. <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>
  14692. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14693. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14694. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14695. // $receipt=new receipt();
  14696. // $receipt->notice=1;
  14697. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14698. }
  14699. }
  14700. }
  14701. }
  14702. function setWXMsg($rid, $type) {
  14703. Doo::loadModel ( "receipt" );
  14704. $receipt = new receipt ();
  14705. $receiptDetail = $receipt->getOne ( array (
  14706. 'where' => 'rid=' . $rid,
  14707. 'asArray' => true
  14708. ) );
  14709. if (! empty ( $receiptDetail )) {
  14710. Doo::loadModel ( 'staff' );
  14711. $staff = new staff ();
  14712. $staffmsg = $staff->getOne ( array (
  14713. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14714. 'asArray' => TRUE
  14715. ) );
  14716. if (! empty ( $staffmsg ['wxid'] )) {
  14717. require_once (SITE_PATH . '/protected/class/client.php');
  14718. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14719. $user = $staffmsg ['wxid'];
  14720. $receiptName = '';
  14721. $msg = '';
  14722. switch ($receiptDetail ['Rtype']) {
  14723. case 0 :
  14724. $receiptName = '报销';
  14725. break;
  14726. case 1 :
  14727. $receiptName = '借款';
  14728. break;
  14729. case 2 :
  14730. $receiptName = '对公汇款';
  14731. break;
  14732. }
  14733. switch ($type) {
  14734. case 1 :
  14735. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14736. break;
  14737. case 2 :
  14738. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14739. break;
  14740. case 3 :
  14741. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14742. break;
  14743. }
  14744. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14745. }
  14746. }
  14747. }
  14748. // Email发送函数
  14749. function SMail($toemail, $subject, $contents) {
  14750. Doo::loadClass ( 'class.phpmailer' );
  14751. $mail = new PHPMailer ();
  14752. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14753. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14754. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14755. $mail->Password = "cDO1GjtY1seH"; // 密码
  14756. $mail->CharSet = "UTF8";
  14757. $mail->SMTPAuth = true;
  14758. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14759. $mail->Mailer = "smtp";
  14760. $mail->Port = 25;
  14761. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14762. $mail->MsgHTML ( $contents );
  14763. $mail->AddAddress ( $toemail );
  14764. $mail->CharSet = "UTF-8";
  14765. return $mail->Send ();
  14766. }
  14767. function h5Upload() {
  14768. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14769. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14770. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14771. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14772. header ( "HTTP/1.1 500 Internal Server Error" );
  14773. echo "POST exceeded maximum allowed size.";
  14774. exit ( 0 );
  14775. }
  14776. // Settings
  14777. $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)
  14778. $upload_name = "Filedata";
  14779. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14780. $extension_whitelist = array (
  14781. "doc",
  14782. "txt",
  14783. "jpg",
  14784. "gif",
  14785. "png"
  14786. ); // Allowed file extensions
  14787. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14788. // Other variables
  14789. $MAX_FILENAME_LENGTH = 260;
  14790. $file_name = "";
  14791. $file_extension = "";
  14792. $uploadErrors = array (
  14793. 0 => "文件上传成功",
  14794. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14795. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14796. 3 => "上传的文件仅为部分文件",
  14797. 4 => "没有文件上传",
  14798. 6 => "缺少临时文件夹"
  14799. );
  14800. $nk = time ();
  14801. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14802. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14803. echo "文件无法保存.";
  14804. exit ( 0 );
  14805. }
  14806. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14807. echo json_encode ( array (
  14808. 'filename' => $file_name,
  14809. 'id' => $nk
  14810. ) );
  14811. exit ( 0 );
  14812. }
  14813. function swfupload() {
  14814. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14815. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14816. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14817. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14818. header ( "HTTP/1.1 500 Internal Server Error" );
  14819. echo "POST exceeded maximum allowed size.";
  14820. exit ( 0 );
  14821. }
  14822. // Settings
  14823. $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)
  14824. $upload_name = "Filedata";
  14825. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14826. $extension_whitelist = array (
  14827. "doc",
  14828. "txt",
  14829. "jpg",
  14830. "gif",
  14831. "png"
  14832. ); // Allowed file extensions
  14833. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14834. // Other variables
  14835. $MAX_FILENAME_LENGTH = 260;
  14836. $file_name = "";
  14837. $file_extension = "";
  14838. $uploadErrors = array (
  14839. 0 => "文件上传成功",
  14840. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14841. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14842. 3 => "上传的文件仅为部分文件",
  14843. 4 => "没有文件上传",
  14844. 6 => "缺少临时文件夹"
  14845. );
  14846. $nk = time ();
  14847. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14848. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14849. echo "文件无法保存.";
  14850. exit ( 0 );
  14851. }
  14852. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14853. echo json_encode ( array (
  14854. 'filename' => $file_name,
  14855. 'id' => $nk
  14856. ) );
  14857. exit ( 0 );
  14858. }
  14859. function _GetFileEXT($filename) {
  14860. $pics = explode ( '.', $filename );
  14861. $num = count ( $pics );
  14862. return $pics [$num - 1];
  14863. }
  14864. /**
  14865. * 获取get或者POST值
  14866. * @param string $name 属性名称
  14867. * @return fixed 值
  14868. */
  14869. function get_args($name) {
  14870. if (isset ( $_GET [$name] )) {
  14871. if (is_array ( $_GET [$name] ))
  14872. return $_GET [$name];
  14873. else
  14874. return addslashes ( $_GET [$name] );
  14875. } elseif (isset ( $_POST [$name] )) {
  14876. if (is_array ( $_POST [$name] ))
  14877. return $_POST [$name];
  14878. else
  14879. return addslashes ( $_POST [$name] );
  14880. } else
  14881. return false;
  14882. }
  14883. function num_to_rmb($num) {
  14884. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14885. $c2 = "分角元拾佰仟万拾佰仟亿";
  14886. // 精确到分后面就不要了,所以只留两个小数位
  14887. $num = round ( $num, 2 );
  14888. // 将数字转化为整数
  14889. $num = $num * 100;
  14890. if (strlen ( $num ) > 10) {
  14891. return "金额太大,请检查";
  14892. }
  14893. $i = 0;
  14894. $c = "";
  14895. while ( 1 ) {
  14896. if ($i == 0) {
  14897. // 获取最后一位数字
  14898. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14899. } else {
  14900. $n = $num % 10;
  14901. }
  14902. // 每次将最后一位数字转化为中文
  14903. $p1 = substr ( $c1, 3 * $n, 3 );
  14904. $p2 = substr ( $c2, 3 * $i, 3 );
  14905. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14906. $c = $p1 . $p2 . $c;
  14907. } else {
  14908. $c = $p1 . $c;
  14909. }
  14910. $i = $i + 1;
  14911. // 去掉数字最后一位了
  14912. $num = $num / 10;
  14913. // echo $num.'</br>';
  14914. $num = ( int ) $num;
  14915. // $num =floor($num);
  14916. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14917. // echo $num.'</br>';
  14918. // 结束循环
  14919. if ($num == 0) {
  14920. break;
  14921. }
  14922. }
  14923. // echo $c.'</br>';
  14924. $j = 0;
  14925. $slen = strlen ( $c );
  14926. while ( $j < $slen ) {
  14927. // utf8一个汉字相当3个字符
  14928. $m = substr ( $c, $j, 6 );
  14929. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14930. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14931. $left = substr ( $c, 0, $j );
  14932. $right = substr ( $c, $j + 3 );
  14933. $c = $left . $right;
  14934. $j = $j - 3;
  14935. $slen = $slen - 3;
  14936. }
  14937. $j = $j + 3;
  14938. }
  14939. // 这个是为了去掉类似23.0中最后一个“零”字
  14940. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14941. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14942. }
  14943. // 将处理的汉字加上“整”
  14944. if (empty ( $c )) {
  14945. return "零元整";
  14946. } else {
  14947. return $c . "整";
  14948. }
  14949. }
  14950. /**
  14951. * 获得分页数据
  14952. * @param unknown_type $table
  14953. * @param unknown_type $condition
  14954. * @param unknown_type $on_page
  14955. * @param unknown_type $page_size
  14956. */
  14957. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14958. $page_c = "";
  14959. $page ['previous'] = $this->get_previous ( $on_page );
  14960. $page ['on_page'] = $on_page;
  14961. $total_count = $this->get_table_count ( $table, $condition );
  14962. $total = intval ( $total_count / $page_size );
  14963. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14964. $page ['total_data'] = $total_count;
  14965. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14966. $i = 1;
  14967. $page_max = 1;
  14968. $page_width = 3;
  14969. if ($on_page >= $page_width) {
  14970. $page_max = intval ( $on_page / $page_width ) + 1;
  14971. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14972. }
  14973. for(; $i <= $page ['total_page']; $i ++) {
  14974. if ($i == $on_page)
  14975. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14976. else
  14977. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14978. if ($i == ($page_width * $page_max))
  14979. break;
  14980. }
  14981. $page ['page'] = $page_c;
  14982. $page ['lower'] = (-- $on_page) * $page_size;
  14983. return $page;
  14984. }
  14985. /**
  14986. * 获取总页数
  14987. * @param unknown_type $table
  14988. * @param unknown_type $condition
  14989. */
  14990. public function get_table_count($table = "", $condition = "") {
  14991. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14992. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14993. // echo $sql;die;
  14994. $query = Doo::db ()->query ( $sql );
  14995. $result = $query->fetch ();
  14996. return $result ['count'];
  14997. }
  14998. /**
  14999. * 获取上一页
  15000. * @param unknown_type $on_page
  15001. */
  15002. function get_previous($on_page = 1) {
  15003. return $on_page != 0 ? $on_page - 1 : $on_page;
  15004. }
  15005. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15006. // 收入合计
  15007. Doo::loadModel ( 'invoiceTraining' );
  15008. $invoiceTraining = new invoiceTraining ();
  15009. Doo::loadModel ( 'receipt' );
  15010. $receipt = new receipt ();
  15011. $invoiceTrainingDetail = array (
  15012. 'invoiceArriveAmount' => '0.00',
  15013. 'RIAmount' => '0.00',
  15014. 'invoiceTotalAmount' => '0.00',
  15015. 'invoiceCompanyAmount' => '0.00',
  15016. 'invoiceArriveAmountM'=>'0.00',
  15017. 'invoiceCompanyAmountM'=>'0.00'
  15018. );
  15019. if ($invoiceTrainId != 0) {
  15020. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15021. }
  15022. $invoiceArriveAmount = $RIAmount = 0;
  15023. if (! empty ( $invoiceTrainingDetail )) {
  15024. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15025. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15026. }
  15027. // 备用金
  15028. $sum = 0;
  15029. if (! empty ( $trainLoanRid )) {
  15030. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15031. foreach ($receiptLoanList as $key=>$value){
  15032. $sum+=$value['sum'];
  15033. }
  15034. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15035. // $sum = $receiptLoanDetailBak ['sum'];
  15036. }
  15037. // 支出项金额详情
  15038. // 项目金额合计
  15039. Doo::loadModel ( 'RItem' );
  15040. $RItem = new RItem ();
  15041. Doo::loadModel ( 'accountItem' );
  15042. $accountItem = new accountItem ();
  15043. // 讲师获得
  15044. Doo::loadModel ( 'RILecturer' );
  15045. $RILecturer = new RILecturer ();
  15046. $RItemList = $RItem->getRItemByRid ($rid );
  15047. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15048. // 支出项金额详情
  15049. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15050. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15051. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15052. return $payment;
  15053. }
  15054. }
  15055. ?>