ReceiptController.php 569 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449
  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. $this->verifyId = $list;
  145. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  146. // 检测用户信息完成
  147. $this->data ['isStaffCompleteMsg'] = false;
  148. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  149. if (! empty ( $detail ))
  150. $this->data ['isStaffCompleteMsg'] = true;
  151. return "/";
  152. }
  153. }
  154. Doo::loadCore ( 'uri/DooUriRouter' );
  155. $router = new DooUriRouter ();
  156. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  157. if ($routeRs ['1'] != "login") {
  158. header ( 'Content-Type:text/html;charset=utf-8' );
  159. @header ( "Location: /login" );
  160. }
  161. }
  162. /**
  163. * 费用首页
  164. */
  165. function saeaBorad() {
  166. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  167. Doo::loadModel ( 'receipt' );
  168. $receipt = new receipt ();
  169. Doo::loadModel ( 'verify' );
  170. $verify = new verify ();
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. Doo::loadModel ( "receiptLog" );
  176. $receiptLog = new receiptLog ();
  177. Doo::loadModel ( 'accountItem' );
  178. $accountItem = new accountItem ();
  179. Doo::loadClass ( 'XDeode' );
  180. $XDeode = new XDeode ( 7 );
  181. $XDeode9 = new XDeode ( 9 );
  182. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  183. $receiptDetail = $receipt->find ( array (
  184. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  185. 'desc' => 'rid',
  186. 'asArray' => true
  187. ) );
  188. foreach ( $receiptDetail as $key => $value ) {
  189. $receiptDetail [$key] ['receiptId'] = $XDeode9->encode ( $value ['rid'] );
  190. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  191. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  192. $veList = $verify->getOne ( array (
  193. 'where' => 'vid=' . $value ['verify'],
  194. 'asArray' => true
  195. ) );
  196. $v = json_decode ( $veList ['staff'] );
  197. array_push ( $v [0], $veList ['description'] );
  198. foreach ( $v as $n => $m ) {
  199. if ($m ['1'] == 'ROLE') {
  200. $roleInfo = $role->getOne ( array (
  201. 'where' => 'rid=' . $m [0],
  202. 'asArray' => true
  203. ) );
  204. $v [$n] [1] = $roleInfo ['name'];
  205. }
  206. }
  207. $receiptDetail [$key] ['staff'] = $v;
  208. $category = $lCategory->getOne ( array (
  209. 'where' => 'cid=' . $value ['cid'],
  210. 'asArray' => true
  211. ) );
  212. $receiptDetail [$key] ['category'] = $category ['title'];
  213. }
  214. // print_r($receiptLogList);
  215. // 协助修改TODO,只显示未完成的
  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. if($receiptList[0]['version']==1){
  4394. require "protected/class/comm_cld.php";
  4395. $receiptList=makeReceiptDataVersion1($receiptList);
  4396. }
  4397. $data ['receiptList'] = $receiptList;
  4398. $data ['memu'] = "receipt";
  4399. $data ['staff'] = $this->staff;
  4400. $data ['receiptMemu'] = 'expenses';
  4401. $data ['verifyId'] = $this->verifyId;
  4402. $data ['executeId'] = $this->executeId;
  4403. if($receiptList[0]['version']==1){
  4404. $this->render ( "/fee/detail/receipt_compatible", $data );
  4405. die;
  4406. }
  4407. if($receiptList[0]['receiptClass']==2){
  4408. if(!empty($receiptList[0]['itinerary2'])){
  4409. $this->render ( "/receipt/feeTraveDetail2", $data );
  4410. }else{
  4411. $this->render ( "/receipt/feeTraveDetail", $data );
  4412. }
  4413. }else{
  4414. $this->render ( "/admin/expensesCollect", $data );
  4415. }
  4416. }
  4417. function approvalExpenses() {
  4418. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4419. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4420. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4421. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4422. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4423. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4424. // echo $rdate;
  4425. if (empty ( $status ))
  4426. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4427. $page_size = 8;
  4428. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4429. $vidList = array ();
  4430. $button = 0;
  4431. Doo::loadModel ( 'verify' );
  4432. $verify = new verify ();
  4433. Doo::loadModel ( 'receipt' );
  4434. $receipt = new receipt ();
  4435. Doo::loadModel ( 'staff' );
  4436. $staff = new staff ();
  4437. Doo::loadModel ( 'L_category' );
  4438. $Lcategory = new L_category ();
  4439. // user verify ID
  4440. $verifyDetail = $verify->find ( array (
  4441. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4442. 'asArray' => true
  4443. ) );
  4444. foreach ( $verifyDetail as $key => $value ) {
  4445. array_push ( $vidList, $value ['vid'] );
  4446. }
  4447. $vid = implode ( ",", $vidList );
  4448. if (empty ( $verifyDetail )){
  4449. $vid = 0;
  4450. }
  4451. $dateCondition = " ";
  4452. // if (! empty ( $month ))
  4453. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4454. if ($status == 'done' || $status == 'termination') {
  4455. if (! empty ( $year )) {
  4456. $dateCondition = " and Year(pastDate) =" . $year;
  4457. if (! empty ( $month ))
  4458. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4459. }
  4460. } elseif ($status == 'finish') {
  4461. if (! empty ( $year )) {
  4462. $dateCondition = " and Year(pastDate) =" . $year;
  4463. if (! empty ( $month ))
  4464. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4465. }
  4466. }
  4467. // date ( 'Y-m' )
  4468. // if (! empty ( $rdate ) && $status == 'done')
  4469. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4470. // elseif (! empty ( $rdate ))
  4471. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4472. $categoryList = $Lcategory->find ( array (
  4473. 'asArray' => true
  4474. ) );
  4475. $staffList = $staff->find ( array (
  4476. 'where' => 'cid=' . $cid,
  4477. 'asArray' => true
  4478. ) );
  4479. $cateCondition = "";
  4480. $staffCondition = "";
  4481. $approvalCondition = "";
  4482. if (! empty ( $cid )) {
  4483. $cateCondition = ' and cid=' . $cid;
  4484. }
  4485. if (! empty ( $sid )) {
  4486. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4487. $cateCondition = "";
  4488. }
  4489. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4490. if ($status == 'pendApproval') {
  4491. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4492. }
  4493. if ($status == 'ongoing') {
  4494. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4495. }
  4496. if ($status == 'done') {
  4497. $approvalCondition = ' and (status=8 or status=9 ) ';
  4498. }
  4499. if ($status == 'termination') {
  4500. $approvalCondition = " and status=3";
  4501. }
  4502. if ($status == 'finish') {
  4503. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4504. }
  4505. if($status == 'loan'){
  4506. $approvalCondition = " and (status=8 or status=7) and Rtype=1";
  4507. }
  4508. $pageinfo ['page'] = array (
  4509. 'previous' => ''
  4510. );
  4511. if(!empty($receiptOrder)){
  4512. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4513. $receiptList = $receipt->find ( array ( // $dateCondition
  4514. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4515. 'desc' => 'rid',
  4516. 'asArray' => true
  4517. ) );
  4518. }else{
  4519. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4520. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4521. $receiptList = $receipt->find ( array ( // $dateCondition.
  4522. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4523. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4524. 'desc' => 'rid',
  4525. 'asArray' => true
  4526. ) );
  4527. } else {
  4528. $receiptList = $receipt->find ( array ( // $dateCondition
  4529. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4530. 'desc' => 'rid',
  4531. 'asArray' => true
  4532. ) );
  4533. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4534. }
  4535. }
  4536. $rLRes = $receipt->find ( array (
  4537. '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 . ')',
  4538. 'desc' => 'rid',
  4539. 'asArray' => true
  4540. ) );
  4541. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4542. // print_r($receiptList);
  4543. Doo::loadClass ( 'XDeode' );
  4544. $XDeode = new XDeode ( 7 );
  4545. $XDeode9 = new XDeode ( 9 );
  4546. $Locate = 0;
  4547. //
  4548. $reportList = $reportCateList = array ();
  4549. foreach ( $receiptList as $key => $value ) {
  4550. $receiptList [$key] ['rid_cld'] = $XDeode9->encode ( $value ['rid'] );
  4551. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4552. $receiptList [$key] ['Locate'] = $Locate;
  4553. $Locate ++;
  4554. $receiptList [$key] ['reviseDetail'] = array ();
  4555. if (! empty ( $value ['reviseDetail'] ))
  4556. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4557. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4558. $categoryDetil = $Lcategory->getOne ( array (
  4559. 'where' => 'cid=' . $value ['cid'],
  4560. 'asArray' => true
  4561. ) );
  4562. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4563. $verifyList = $verify->getOne ( array (
  4564. 'where' => 'vid=' . $value ['verify'],
  4565. 'asArray' => true
  4566. ) );
  4567. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4568. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4569. foreach ( $verifyList as $k => $v ) {
  4570. // init verifyStaff
  4571. $verifyList [$k] ['date'] = "";
  4572. $verifyList [$k] ['opinion'] = "";
  4573. $verifyList [$k] ['status'] = "";
  4574. if (empty ( $verifyStaff )) {
  4575. $verifyList [$k] ['date'] = "";
  4576. $verifyList [$k] ['opinion'] = "";
  4577. if ($v [0] == $this->staff [0] ['sid']) {
  4578. $verifyList [$k] ['status'] = 4;
  4579. $button = 4;
  4580. }
  4581. } else {
  4582. $flag = true;
  4583. foreach ( $verifyStaff as $m => $u ) {
  4584. if ($v [0] == $m) {
  4585. $verifyList [$k] ['date'] = $u ['date'];
  4586. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4587. $verifyList [$k] ['status'] = $u ['status'];
  4588. $flag = false;
  4589. break;
  4590. }
  4591. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4592. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4593. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4594. }
  4595. if ($flag) { // 检测可编辑
  4596. if ($v [0] == $this->staff [0] ['sid']) {
  4597. $verifyList [$k] ['status'] = 4;
  4598. $button = 4;
  4599. }
  4600. }
  4601. }
  4602. }
  4603. $receiptList [$key] ['verifyList'] = $verifyList;
  4604. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4605. 'where' => 'sid=' . $value ['staff'],
  4606. 'asArray' => true
  4607. ) );
  4608. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4609. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4610. $receiptList [$key] ['button'] = $button;
  4611. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4612. //获得培训班结算RID 借款费用--已经锁定
  4613. if($value['status']==10){
  4614. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4615. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4616. }
  4617. if($value['version']==1){
  4618. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4619. }
  4620. }
  4621. $reportList = array_unique ( $reportList );
  4622. $reportHtml = '';
  4623. foreach ( $reportList as $key => $value ) {
  4624. $v = explode ( "-", $value );
  4625. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4626. }
  4627. // print_r($reportList)
  4628. $data ['reportHtml'] = $reportHtml;
  4629. $reportCateList = array_unique ( $reportCateList );
  4630. $reportCateHtml = '';
  4631. foreach ( $reportCateList as $key => $value ) {
  4632. $v = explode ( "-", $value );
  4633. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4634. }
  4635. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4636. $data ['reportCateHtml'] = $reportCateHtml;
  4637. // print_r($receiptList);die;
  4638. // $data['verifyDetail']=$verifyDetail;
  4639. $mothHtml = "";
  4640. for($i = 1; $i <= 12; $i ++) {
  4641. if ($month == $i)
  4642. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4643. else
  4644. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4645. }
  4646. $data ['mothHtml'] = $mothHtml;
  4647. $dateHtml = "";
  4648. $now = date ( "Y" );
  4649. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4650. if ($YEARD <= $now) {
  4651. $dateHtml .= '<option ';
  4652. if ($year == $YEARD) {
  4653. $dateHtml .= 'selected ';
  4654. }
  4655. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4656. }
  4657. }
  4658. $data ['dateHtml'] = $dateHtml;
  4659. $data ['page'] = $pageinfo;
  4660. $data ['receiptList'] = $receiptList;
  4661. $data ['receiptApprovalCount'] = count ( $rLRes );
  4662. $data ['status'] = $status;
  4663. $data ['year'] = $year;
  4664. $data ['month'] = $month;
  4665. $data ['categoryList'] = $categoryList;
  4666. $data ['staffList'] = $staffList;
  4667. $data ['cid'] = $cid;
  4668. $data ['sid'] = $sid;
  4669. // print_r($receiptList);
  4670. $data['receiptOrder']=$receiptOrder;
  4671. $data ['memu'] = "receipt";
  4672. $data ['staff'] = $this->staff;
  4673. $data ['receiptMemu'] = 'approvalExpenses';
  4674. $data ['verifyId'] = $this->verifyId;
  4675. $data ['executeId'] = $this->executeId;
  4676. $this->render ( "/admin/approvalExpenses", $data );
  4677. }
  4678. private function _expensesDoc(){
  4679. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4680. Doo::loadClass ( 'XDeode' );
  4681. $XDeode = new XDeode ( 5 );
  4682. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4683. $rid = $XDeode->decode ( $rid );
  4684. if (! is_numeric ( $rid ))
  4685. die ( 'illegal request' );
  4686. Doo::loadModel ( 'receipt' );
  4687. $receipt = new receipt ();
  4688. Doo::loadModel ( 'L_category' );
  4689. $Lcategory = new L_category ();
  4690. Doo::loadModel ( 'verify' );
  4691. Doo::loadModel ( 'statistics' );
  4692. $statistics = new statistics ();
  4693. $verify = new verify ();
  4694. Doo::loadModel ( 'staff' );
  4695. $staff = new staff ();
  4696. Doo::loadModel ( 'loanReceipt' );
  4697. $loanReceipt = new loanReceipt ();
  4698. $receiptList = $receipt->find ( array (
  4699. 'where' => ' rid=' . $rid,
  4700. 'desc' => 'rid',
  4701. 'asArray' => true
  4702. ) );
  4703. $loanList = array ();
  4704. if (! empty ( $receiptList ))
  4705. $loanList = $loanReceipt->find ( array (
  4706. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4707. 'desc' => 'rid',
  4708. 'asArray' => true
  4709. ) );
  4710. $Locate = 0;
  4711. $roleId = 0;
  4712. $button = 0;
  4713. foreach ( $loanList as $key => $value ) {
  4714. $loanList [$key] ['Locate'] = $Locate;
  4715. $Locate ++;
  4716. $loanList [$key] ['reviseDetail'] = array ();
  4717. if (! empty ( $value ['reviseDetail'] ))
  4718. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4719. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4720. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4721. $categoryDetil = $Lcategory->getOne ( array (
  4722. 'where' => 'cid=' . $value ['cid'],
  4723. 'asArray' => true
  4724. ) );
  4725. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4726. // 检测编辑状态
  4727. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4728. $verifyList ['staff'] = $value ['verifyBreakup'];
  4729. else
  4730. $verifyList = $verify->getOne ( array (
  4731. 'where' => 'vid=' . $value ['verify'],
  4732. 'asArray' => true
  4733. ) );
  4734. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4735. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4736. Doo::loadModel ( 'role' );
  4737. $role = new role ();
  4738. $flag = true;
  4739. $roleKey = 0;
  4740. $endStaffArray = array ();
  4741. $roleArrayCopy = array ();
  4742. foreach ( $verifyList as $k => $v ) {
  4743. // init verifyStaff
  4744. if ($v [1] == 'ROLE') {
  4745. if (! empty ( $verifyStaff )) {
  4746. $endStaffArray = end ( $verifyStaff );
  4747. // if ($v[0]==$endStaffArray['nextStaff']){
  4748. // $roleId=$v[0];
  4749. // }
  4750. }
  4751. $roleVerify = json_decode ( $v [3], true );
  4752. $roleKey = $k;
  4753. $roleArray = array ();
  4754. $rolename = $role->getOne ( array (
  4755. 'where' => 'rid=' . $v [0],
  4756. 'asArray' => true
  4757. ) );
  4758. foreach ( $roleVerify as $o => $p ) {
  4759. $staffID = explode ( '_', $p );
  4760. $staffInfo = $staff->getOne ( array (
  4761. 'where' => 'sid=' . $staffID [0],
  4762. 'asArray' => true
  4763. ) );
  4764. // print_r($staffID);
  4765. $exp = array (
  4766. 0 => $staffInfo ['sid'],
  4767. 1 => $staffID [1],
  4768. 2 => $staffInfo ['avatar'],
  4769. 'date' => '',
  4770. 'date' => '',
  4771. 'opinion' => '',
  4772. 'status' => '',
  4773. 'rolename' => $rolename ['name']
  4774. );
  4775. array_push ( $roleArray, $exp );
  4776. }
  4777. $roleArrayCopy [$v [0]] = $roleArray;
  4778. // $verifyList[$k]['roleArray']=$roleArray;
  4779. }
  4780. $verifyList [$k] ['date'] = "";
  4781. $verifyList [$k] ['opinion'] = "";
  4782. $verifyList [$k] ['status'] = "";
  4783. if (empty ( $verifyStaff )) {
  4784. $verifyList [$k] ['date'] = "";
  4785. $verifyList [$k] ['opinion'] = "";
  4786. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4787. $verifyList [$k] ['status'] = 4;
  4788. $flag = false;
  4789. }
  4790. } else {
  4791. foreach ( $verifyStaff as $m => $u ) {
  4792. if ($v [0] == $m) {
  4793. $verifyList [$k] ['date'] = $u ['date'];
  4794. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4795. $verifyList [$k] ['status'] = $u ['status'];
  4796. $flag = false;
  4797. break;
  4798. }
  4799. }
  4800. $endStaffArray = end ( $verifyStaff );
  4801. if (isset ( $endStaffArray ['ROLE'] )) {
  4802. } else {
  4803. // $endKey=key($verifyStaff);
  4804. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4805. // $button=4;
  4806. // $verifyList[$k]['status']=4;
  4807. // }
  4808. }
  4809. }
  4810. }
  4811. $rolename ['name'] = '';
  4812. if (! empty ( $roleId )) {
  4813. Doo::loadModel ( 'role' );
  4814. $role = new role ();
  4815. $rolename = $role->getOne ( array (
  4816. 'where' => 'rid=' . $roleId,
  4817. 'asArray' => true
  4818. ) );
  4819. }
  4820. if (! empty ( $verifyStaff ))
  4821. $endStaffArray = end ( $verifyStaff );
  4822. $KOP = false;
  4823. foreach ( $roleArrayCopy as $P => $A ) {
  4824. foreach ( $A as $MKI => $AVL ) {
  4825. if (! empty ( $verifyStaff )) {
  4826. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4827. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4828. $button = 4;
  4829. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4830. }
  4831. foreach ( $verifyStaff as $m => $u ) {
  4832. $AVLFK = $AVL [0] . '_R';
  4833. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4834. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4835. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4836. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4837. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4838. break;
  4839. }
  4840. }
  4841. } else {
  4842. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4843. $button = 4;
  4844. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4845. }
  4846. }
  4847. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4848. $KOP = true;
  4849. }
  4850. }
  4851. foreach ( $roleArrayCopy as $k => $v ) {
  4852. foreach ( $verifyList as $m => $n ) {
  4853. if ($n [0] == $k) {
  4854. array_splice ( $verifyList, $m, 1, $v );
  4855. }
  4856. }
  4857. }
  4858. $loanList [$key] ['verifyList'] = $verifyList;
  4859. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4860. 'where' => 'sid=' . $value ['staff'],
  4861. 'asArray' => true
  4862. ) );
  4863. $loanList [$key] ['button'] = $button;
  4864. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4865. }
  4866. $data ['loanList'] = $loanList;
  4867. $data ['explanation'] = '';
  4868. if (! empty ( $loanList )){
  4869. $data ['explanation'] = $loanList [0] ['explanation'];
  4870. }
  4871. //print_r($loanList);
  4872. $Locate = 0;
  4873. $roleId = 0;
  4874. $button = 0;
  4875. foreach ( $receiptList as $key => $value ) {
  4876. $receiptList [$key] ['Locate'] = $Locate;
  4877. $Locate ++;
  4878. $receiptList [$key] ['reviseDetail'] = array ();
  4879. if (! empty ( $value ['reviseDetail'] ))
  4880. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4881. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4882. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4883. $categoryDetil = $Lcategory->getOne ( array (
  4884. 'where' => 'cid=' . $value ['cid'],
  4885. 'asArray' => true
  4886. ) );
  4887. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4888. // 检测编辑状态
  4889. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4890. $verifyList ['staff'] = $value ['verifyBreakup'];
  4891. } else
  4892. $verifyList = $verify->getOne ( array (
  4893. 'where' => 'vid=' . $value ['verify'],
  4894. 'asArray' => true
  4895. ) );
  4896. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4897. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4898. Doo::loadModel ( 'role' );
  4899. $role = new role ();
  4900. if ($verifyList == NULL)
  4901. $verifyList = array ();
  4902. $flag = true;
  4903. $roleKey = 0;
  4904. $endStaffArray = array ();
  4905. $roleArrayCopy = array ();
  4906. foreach ( $verifyList as $k => $v ) {
  4907. // init verifyStaff
  4908. if ($v [1] == 'ROLE') {
  4909. if (! empty ( $verifyStaff )) {
  4910. $endStaffArray = end ( $verifyStaff );
  4911. // if ($v[0]==$endStaffArray['nextStaff']){
  4912. // $roleId=$v[0];
  4913. // }
  4914. }
  4915. $roleVerify = json_decode ( $v [3], true );
  4916. $roleKey = $k;
  4917. $roleArray = array ();
  4918. $rolename = $role->getOne ( array (
  4919. 'where' => 'rid=' . $v [0],
  4920. 'asArray' => true
  4921. ) );
  4922. foreach ( $roleVerify as $o => $p ) {
  4923. $staffID = explode ( '_', $p );
  4924. $staffInfo = $staff->getOne ( array (
  4925. 'where' => 'sid=' . $staffID [0],
  4926. 'asArray' => true
  4927. ) );
  4928. // print_r($staffID);
  4929. $exp = array (
  4930. 0 => $staffInfo ['sid'],
  4931. 1 => $staffID [1],
  4932. 2 => $staffInfo ['avatar'],
  4933. 'date' => '',
  4934. 'date' => '',
  4935. 'opinion' => '',
  4936. 'status' => '',
  4937. 'rolename' => $rolename ['name']
  4938. );
  4939. array_push ( $roleArray, $exp );
  4940. }
  4941. $roleArrayCopy [$v [0]] = $roleArray;
  4942. // $verifyList[$k]['roleArray']=$roleArray;
  4943. }
  4944. $verifyList [$k] ['date'] = "";
  4945. $verifyList [$k] ['opinion'] = "";
  4946. $verifyList [$k] ['status'] = "";
  4947. if (empty ( $verifyStaff )) {
  4948. $verifyList [$k] ['date'] = "";
  4949. $verifyList [$k] ['opinion'] = "";
  4950. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4951. $verifyList [$k] ['status'] = 4;
  4952. $flag = false;
  4953. }
  4954. } else {
  4955. foreach ( $verifyStaff as $m => $u ) {
  4956. if ($v [0] == $m) {
  4957. $verifyList [$k] ['date'] = $u ['date'];
  4958. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4959. $verifyList [$k] ['status'] = $u ['status'];
  4960. $flag = false;
  4961. break;
  4962. }
  4963. }
  4964. $endStaffArray = end ( $verifyStaff );
  4965. if (isset ( $endStaffArray ['ROLE'] )) {
  4966. } else {
  4967. // $endKey=key($verifyStaff);
  4968. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4969. // $button=4;
  4970. // $verifyList[$k]['status']=4;
  4971. // }
  4972. }
  4973. }
  4974. }
  4975. $FC = @$rolename ['name'];
  4976. $rolename ['name'] = '';
  4977. if (! empty ( $roleId )) {
  4978. Doo::loadModel ( 'role' );
  4979. $role = new role ();
  4980. $rolename = $role->getOne ( array (
  4981. 'where' => 'rid=' . $roleId,
  4982. 'asArray' => true
  4983. ) );
  4984. }
  4985. if (! empty ( $verifyStaff ))
  4986. $endStaffArray = end ( $verifyStaff );
  4987. $KOP = false;
  4988. foreach ( $roleArrayCopy as $P => $A ) {
  4989. foreach ( $A as $MKI => $AVL ) {
  4990. if (! empty ( $verifyStaff )) {
  4991. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4992. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4993. $button = 4;
  4994. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4995. }
  4996. foreach ( $verifyStaff as $m => $u ) {
  4997. $AVLFK = $AVL [0] . '_R';
  4998. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4999. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5000. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5001. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5002. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5003. break;
  5004. }
  5005. }
  5006. } else {
  5007. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5008. $button = 4;
  5009. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5010. }
  5011. }
  5012. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5013. $KOP = true;
  5014. }
  5015. }
  5016. foreach ( $roleArrayCopy as $k => $v ) {
  5017. foreach ( $verifyList as $m => $n ) {
  5018. if ($n [0] == $k) {
  5019. array_splice ( $verifyList, $m, 1, $v );
  5020. }
  5021. }
  5022. }
  5023. // 费用执行人相关数据
  5024. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5025. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5026. foreach ( $executeCopy as $k => $v ) {
  5027. $executeCopy [$k] ['date'] = '';
  5028. $executeCopy [$k] ['opinion'] = '';
  5029. $executeCopy [$k] ['status'] = '';
  5030. if (! empty ( $executeStaff ))
  5031. foreach ( $executeStaff as $m => $u ) {
  5032. if ($v [0] == $m) {
  5033. $executeCopy [$k] ['date'] = $u ['date'];
  5034. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5035. $executeCopy [$k] ['status'] = $u ['status'];
  5036. break;
  5037. }
  5038. }
  5039. }
  5040. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5041. // print_r($verifyList);
  5042. $receiptList [$key] ['verifyList'] = $verifyList;
  5043. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5044. 'where' => 'sid=' . $value ['staff'],
  5045. 'asArray' => true
  5046. ) );
  5047. $receiptList [$key] ['button'] = $button;
  5048. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5049. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5050. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5051. $receiptList [$key] ['relust'] = $relust;
  5052. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5053. }
  5054. // print_r($receiptList);
  5055. // 获取审批日志
  5056. Doo::loadModel ( 'receiptLog' );
  5057. $receiptLog = new receiptLog ();
  5058. $rlList = array ();
  5059. $rlInfo = $receiptLog->getOne ( array (
  5060. 'where' => 'rid=' . $rid . ' and status=4',
  5061. 'asArray' => true
  5062. ) );
  5063. // $tijdate = $receiptLog->getOne ( array (
  5064. // 'where' => 'rid=' . $rid . ' and status=2',
  5065. // 'asc' => 'rlid',
  5066. // 'asArray' => true
  5067. // ) );
  5068. if (! empty ( $rlInfo )) {
  5069. $rlList = $receiptLog->find ( array (
  5070. 'where' => 'rid=' . $rid,
  5071. 'asc' => 'rlid',
  5072. 'asArray' => true
  5073. ) );
  5074. }
  5075. $RN=array();
  5076. if (!empty( $rolename ['staff'])){
  5077. $RN = @json_decode ( $rolename ['staff'] );
  5078. }
  5079. //
  5080. foreach ( $rlList as $key => $value ) {
  5081. $rlList [$key] ['rolename'] = '';
  5082. foreach ( $RN as $k => $v ) {
  5083. $id = explode ( "_", $v );
  5084. if ($id [0] == $value ['uid']) {
  5085. $rlList [$key] ['rolename'] = $FC;
  5086. break;
  5087. }
  5088. }
  5089. }
  5090. Doo::loadModel ( 'enclosur' );
  5091. $enclosur = new enclosur ();
  5092. $enclosurList = $enclosur->find ( array (
  5093. 'where' => 'rid=' . $rid,
  5094. 'asArray' => true
  5095. ) );
  5096. $enclosurHtml = '';
  5097. foreach ( $enclosurList as $value ) {
  5098. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5099. }
  5100. if($receiptList[0]['version']==1){
  5101. require "protected/class/comm_cld.php";
  5102. $receiptList=makeReceiptDataVersion1($receiptList);
  5103. }
  5104. $data ['enclosurHtml'] = $enclosurHtml;
  5105. $receiptList [0] ['rlList'] = $rlList;
  5106. $data ['receiptList'] = $receiptList;
  5107. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5108. // print_r($receiptList);
  5109. $data ['memu'] = "receipt";
  5110. $data ['staff'] = $this->staff;
  5111. $data ['receiptMemu'] = 'approvalExpenses';
  5112. $data ['verifyId'] = $this->verifyId;
  5113. $data ['executeId'] = $this->executeId;
  5114. return $data;
  5115. }
  5116. function expensesDoc() {
  5117. $data=$this->_expensesDoc();
  5118. if($data['receiptList'][0]['version']==1){
  5119. $this->render ( "/fee/detail/receipt_compatible", $data );
  5120. die;
  5121. }
  5122. if(!empty($data['receiptList'][0]['itinerary2'])){
  5123. $this->render ( "/receipt/feeTraveView", $data );
  5124. }else{
  5125. $this->render ( "/admin/expensesDoc", $data );
  5126. }
  5127. }
  5128. function expensesDocPrint(){
  5129. $data=$this->_expensesDoc();
  5130. if($data['receiptList'][0]['version']==1){
  5131. $this->render ( "/fee/detail/receiptPrint_compatible", $data );
  5132. die;
  5133. }
  5134. $this->render ( "/receipt/expensesDocPrint", $data );
  5135. }
  5136. function expensesEdi() {
  5137. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5138. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5139. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5140. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5141. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5142. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5143. if (empty ( $status ))
  5144. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5145. $vidList = array ();
  5146. $button = 0;
  5147. Doo::loadModel ( 'verify' );
  5148. Doo::loadModel ( 'receipt' );
  5149. Doo::loadModel ( 'staff' );
  5150. $staff = new staff ();
  5151. $receipt = new receipt ();
  5152. $verify = new verify ();
  5153. Doo::loadModel ( 'L_category' );
  5154. $Lcategory = new L_category ();
  5155. Doo::loadModel ( 'enclosur' );
  5156. $enclosur = new enclosur ();
  5157. // user verify ID
  5158. $verifyDetail = $verify->find ( array (
  5159. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5160. 'asArray' => true
  5161. ) );
  5162. foreach ( $verifyDetail as $key => $value ) {
  5163. array_push ( $vidList, $value ['vid'] );
  5164. }
  5165. $vid = implode ( ",", $vidList );
  5166. if (empty ( $verifyDetail ))
  5167. $vid = 0;
  5168. $categoryList = $Lcategory->find ( array (
  5169. 'asArray' => true
  5170. ) );
  5171. $staffList = $staff->find ( array (
  5172. 'where' => 'cid=' . $cid,
  5173. 'asArray' => true
  5174. ) );
  5175. $ap = "";
  5176. if ($status == 4) {
  5177. $ap = 4;
  5178. $status = 2;
  5179. }
  5180. // get Receipt By verifyID status 2
  5181. $receiptList = $receipt->find ( array (
  5182. 'where' => 'rid =' . $rid . ' and status=2',
  5183. 'desc' => 'rid',
  5184. 'asArray' => true
  5185. ) );
  5186. if (empty ( $receiptList )) {
  5187. die ( 'illegal request' );
  5188. }
  5189. $Locate = 0;
  5190. $roleId = 0;
  5191. if ($ap == 4)
  5192. $status = 4;
  5193. foreach ( $receiptList as $key => $value ) {
  5194. $receiptList [$key] ['Locate'] = $Locate;
  5195. $Locate ++;
  5196. $receiptList [$key] ['reviseDetail'] = array ();
  5197. if (! empty ( $value ['reviseDetail'] ))
  5198. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5199. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5200. $categoryDetil = $Lcategory->getOne ( array (
  5201. 'where' => 'cid=' . $value ['cid'],
  5202. 'asArray' => true
  5203. ) );
  5204. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5205. // 检测编辑状态
  5206. $verifyList = $verify->getOne ( array (
  5207. 'where' => 'vid=' . $value ['verify'],
  5208. 'asArray' => true
  5209. ) );
  5210. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5211. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5212. Doo::loadModel ( 'role' );
  5213. $role = new role ();
  5214. // print_r($verifyList);
  5215. $flag = true;
  5216. $roleKey = 0;
  5217. $endStaffArray = array ();
  5218. $roleArrayCopy = array ();
  5219. foreach ( $verifyList as $k => $v ) {
  5220. // init verifyStaff
  5221. if ($v [1] == 'ROLE') {
  5222. if (! empty ( $verifyStaff )) {
  5223. $endStaffArray = end ( $verifyStaff );
  5224. if ($v [0] == $endStaffArray ['nextStaff']) {
  5225. $roleId = $v [0];
  5226. }
  5227. }
  5228. $roleVerify = json_decode ( $v [3], true );
  5229. $roleKey = $k;
  5230. $roleArray = array ();
  5231. $rolename = $role->getOne ( array (
  5232. 'where' => 'rid=' . $v [0],
  5233. 'asArray' => true
  5234. ) );
  5235. foreach ( $roleVerify as $o => $p ) {
  5236. $staffID = explode ( '_', $p );
  5237. $staffInfo = $staff->getOne ( array (
  5238. 'where' => 'sid=' . $staffID [0],
  5239. 'asArray' => true
  5240. ) );
  5241. // print_r($staffID);
  5242. $exp = array (
  5243. 0 => $staffInfo ['sid'],
  5244. 1 => $staffID [1],
  5245. 2 => $staffInfo ['avatar'],
  5246. 'date' => '',
  5247. 'date' => '',
  5248. 'opinion' => '',
  5249. 'status' => '',
  5250. 'rolename' => $rolename ['name']
  5251. );
  5252. array_push ( $roleArray, $exp );
  5253. }
  5254. $roleArrayCopy [$v [0]] = $roleArray;
  5255. // $verifyList[$k]['roleArray']=$roleArray;
  5256. }
  5257. // print_r($roleArray);
  5258. $verifyList [$k] ['date'] = "";
  5259. $verifyList [$k] ['opinion'] = "";
  5260. $verifyList [$k] ['status'] = "";
  5261. if (empty ( $verifyStaff )) {
  5262. $verifyList [$k] ['date'] = "";
  5263. $verifyList [$k] ['opinion'] = "";
  5264. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5265. $verifyList [$k] ['status'] = 4;
  5266. $button = 4;
  5267. $flag = false;
  5268. }
  5269. } else {
  5270. foreach ( $verifyStaff as $m => $u ) {
  5271. if ($v [0] == $m) {
  5272. $verifyList [$k] ['date'] = $u ['date'];
  5273. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5274. $verifyList [$k] ['status'] = $u ['status'];
  5275. $flag = false;
  5276. break;
  5277. }
  5278. }
  5279. $endStaffArray = end ( $verifyStaff );
  5280. if (isset ( $endStaffArray ['ROLE'] )) {
  5281. } else {
  5282. $endKey = key ( $verifyStaff );
  5283. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5284. $button = 4;
  5285. $verifyList [$k] ['status'] = 4;
  5286. }
  5287. }
  5288. }
  5289. }
  5290. $rolename ['name'] = '';
  5291. if (! empty ( $roleId )) {
  5292. Doo::loadModel ( 'role' );
  5293. $role = new role ();
  5294. $rolename = $role->getOne ( array (
  5295. 'where' => 'rid=' . $roleId,
  5296. 'asArray' => true
  5297. ) );
  5298. }
  5299. if (! empty ( $verifyStaff ))
  5300. $endStaffArray = end ( $verifyStaff );
  5301. $KOP = false;
  5302. foreach ( $roleArrayCopy as $P => $A ) {
  5303. foreach ( $A as $MKI => $AVL ) {
  5304. if (! empty ( $verifyStaff )) {
  5305. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5306. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5307. $button = 4;
  5308. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5309. }
  5310. foreach ( $verifyStaff as $m => $u ) {
  5311. $AVLFK = $AVL [0] . '_R';
  5312. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5313. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5314. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5315. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5316. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5317. break;
  5318. }
  5319. }
  5320. } else {
  5321. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5322. $button = 4;
  5323. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5324. }
  5325. }
  5326. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5327. $KOP = true;
  5328. }
  5329. }
  5330. // print_r($roleArrayCopy);
  5331. // echo $roleKey;
  5332. foreach ( $roleArrayCopy as $k => $v ) {
  5333. foreach ( $verifyList as $m => $n ) {
  5334. if ($n [0] == $k) {
  5335. array_splice ( $verifyList, $m, 1, $v );
  5336. }
  5337. }
  5338. }
  5339. $receiptList [$key] ['verifyList'] = $verifyList;
  5340. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5341. 'where' => 'sid=' . $value ['staff'],
  5342. 'asArray' => true
  5343. ) );
  5344. $receiptList [$key] ['button'] = $button;
  5345. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5346. }
  5347. // $data['verifyDetail']=$verifyDetail;
  5348. $mothHtml = "";
  5349. for($i = 1; $i <= 12; $i ++) {
  5350. if ($month == $i)
  5351. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5352. else
  5353. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5354. }
  5355. // 获取审批日志
  5356. Doo::loadModel ( 'receiptLog' );
  5357. $receiptLog = new receiptLog ();
  5358. $rlList = array ();
  5359. $rlInfo = $receiptLog->getOne ( array (
  5360. 'where' => 'rid=' . $rid . ' and status=4',
  5361. 'asArray' => true
  5362. ) );
  5363. $tijdate = $receiptLog->getOne ( array (
  5364. 'where' => 'rid=' . $rid . ' and status=2',
  5365. 'asc' => 'rlid',
  5366. 'asArray' => true
  5367. ) );
  5368. if (! empty ( $rlInfo )) {
  5369. $rlList = $receiptLog->find ( array (
  5370. 'where' => 'rid=' . $rid,
  5371. 'asc' => 'rlid',
  5372. 'asArray' => true
  5373. ) );
  5374. }
  5375. $receiptList [0] ['rlList'] = $rlList;
  5376. $enclosurList = $enclosur->find ( array (
  5377. 'where' => 'rid=' . $rid,
  5378. 'asArray' => true
  5379. ) );
  5380. $enclosurHtml = '';
  5381. foreach ( $enclosurList as $value ) {
  5382. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5383. }
  5384. // print_r($receiptList);
  5385. $data ['rid'] = $rid;
  5386. $data ['enclosurHtml'] = $enclosurHtml;
  5387. $data ['rolename'] = $rolename ['name'];
  5388. $data ['datetij'] = $tijdate ['date'];
  5389. $data ['mothHtml'] = $mothHtml;
  5390. $data ['receiptList'] = $receiptList;
  5391. $data ['receiptApprovalCount'] = count ( $receiptList );
  5392. $data ['status'] = $status;
  5393. $data ['year'] = $year;
  5394. $data ['categoryList'] = $categoryList;
  5395. $data ['staffList'] = $staffList;
  5396. $data ['cid'] = $cid;
  5397. $data ['sid'] = $sid;
  5398. $data ['ap'] = $ap;
  5399. $data ['memu'] = "receipt";
  5400. $data ['staff'] = $this->staff;
  5401. $data ['receiptMemu'] = 'approvalExpenses';
  5402. $data ['verifyId'] = $this->verifyId;
  5403. $data ['executeId'] = $this->executeId;
  5404. $this->render ( "/admin/expensesEdi", $data );
  5405. }
  5406. function expensesDefray() {
  5407. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5408. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5409. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5410. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5411. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5412. if (! empty ( $rid )) {
  5413. Doo::loadModel ( "verify" );
  5414. $verify = new verify ();
  5415. Doo::loadModel ( "receiptDetail" );
  5416. $receiptDetailObj = new receiptDetail ();
  5417. Doo::loadModel ( "itemStatistics" );
  5418. Doo::loadModel ( "statistics" );
  5419. $statistics = new statistics ();
  5420. $itemStatistics = new itemStatistics ();
  5421. Doo::loadModel ( "receipt" );
  5422. $receipt = new receipt ();
  5423. Doo::loadModel ( "loanReceipt" );
  5424. $loanReceipt = new loanReceipt ();
  5425. $receiptDetail = $receipt->getOne ( array (
  5426. 'where' => 'rid=' . $rid . ' and status=2 ',
  5427. 'asArray' => true
  5428. ) );
  5429. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5430. $nsflag = true;
  5431. foreach ( $nslist as $value ) {
  5432. if ($value == $this->staff ['0'] ['sid']) {
  5433. $nsflag = false;
  5434. break;
  5435. }
  5436. }
  5437. // print_r($nslist);die;
  5438. if (empty ( $receiptDetail ) || $nsflag)
  5439. return "/approvalExpenses/pendApproval";
  5440. $verifyDetail = $verify->getOne ( array (
  5441. 'where' => ' vid =' . $receiptDetail ['verify'],
  5442. 'asArray' => true
  5443. ) );
  5444. $verifyString = $verifyDetail ['staff'];
  5445. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5446. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5447. if (empty ( $opinion )) {
  5448. if ($status == 3)
  5449. $opinion = "终止";
  5450. else
  5451. $opinion = "同意支付";
  5452. }
  5453. $nowStaff = 0;
  5454. $nowStaffList = array ();
  5455. if (empty ( $verifyStaff )) {
  5456. // 还需加入是否已经进入角色审批
  5457. if ($verifyDetail [0] [1] == 'ROLE') {
  5458. // print_r($verifyDetail);echo "ddd";
  5459. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5460. foreach ( $vStaffString as $key => $value ) {
  5461. $staffK = explode ( "_", $value );
  5462. if ($staffK [0] != $this->staff [0] ['sid'])
  5463. array_push ( $nowStaffList, $staffK [0] );
  5464. }
  5465. // print_r($verifyDetail);
  5466. // die;
  5467. if (! empty ( $nowStaffList )) {
  5468. $nowStaff = implode ( ',', $nowStaffList );
  5469. $verifyStaff = array (
  5470. $this->staff [0] ['sid'] . "_R" => array (
  5471. 'date' => date ( 'Y-m-d' ),
  5472. 'opinion' => $opinion,
  5473. 'status' => $status,
  5474. 'nextStaff' => $verifyDetail [0] [0],
  5475. 'ROLE' => 1
  5476. )
  5477. );
  5478. } else {
  5479. $nowStaff = $verifyDetail [1] [0];
  5480. $verifyStaff = array (
  5481. $this->staff [0] ['sid'] . "_R" => array (
  5482. 'date' => date ( 'Y-m-d' ),
  5483. 'opinion' => $opinion,
  5484. 'status' => $status,
  5485. 'nextStaff' => $verifyDetail [1] [0]
  5486. )
  5487. );
  5488. }
  5489. } else {
  5490. if ($verifyDetail [1] [1] == 'ROLE') {
  5491. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5492. // echo "dd";
  5493. foreach ( $vStaffString as $key => $value ) {
  5494. $staffK = explode ( "_", $value );
  5495. array_push ( $nowStaffList, $staffK [0] );
  5496. }
  5497. $nowStaff = implode ( ',', $nowStaffList );
  5498. $verifyStaff = array (
  5499. $this->staff [0] ['sid'] => array (
  5500. 'date' => date ( 'Y-m-d' ),
  5501. 'opinion' => $opinion,
  5502. 'status' => $status,
  5503. 'nextStaff' => $verifyDetail [1] [0],
  5504. 'ROLE' => 1
  5505. )
  5506. );
  5507. } else {
  5508. $nowStaff = $verifyDetail [1] [0];
  5509. $verifyStaff = array (
  5510. $this->staff [0] ['sid'] => array (
  5511. 'date' => date ( 'Y-m-d' ),
  5512. 'opinion' => $opinion,
  5513. 'status' => $status,
  5514. 'nextStaff' => $verifyDetail [1] [0]
  5515. )
  5516. );
  5517. }
  5518. }
  5519. if ($status == 3)
  5520. $verifyStaff = array (
  5521. 'final' => $status,
  5522. $this->staff [0] ['sid'] => array (
  5523. 'date' => date ( 'Y-m-d' ),
  5524. 'opinion' => $opinion,
  5525. 'status' => $status
  5526. )
  5527. );
  5528. $vStaffString = json_encode ( $verifyStaff );
  5529. $receipt->nowStaff = $nowStaff;
  5530. $receipt->verifyStaff = $vStaffString;
  5531. $loanReceipt->nowStaff = $nowStaff;
  5532. $loanReceipt->verifyStaff = $vStaffString;
  5533. } else {
  5534. $VS = end ( $verifyStaff );
  5535. // 非角色审批
  5536. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5537. $nextStaff = 0;
  5538. $roleSTF = false;
  5539. foreach ( $verifyDetail as $key => $value ) {
  5540. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5541. if (isset ( $verifyDetail [$key + 1] )) {
  5542. $nextStaff = $verifyDetail [$key + 1] [0];
  5543. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5544. $roleSTF = true;
  5545. }
  5546. break;
  5547. }
  5548. }
  5549. if (! $roleSTF) {
  5550. $nowStaff = $nextStaff;
  5551. $verifyStaff [$this->staff [0] ['sid']] = array (
  5552. 'date' => date ( 'Y-m-d' ),
  5553. 'opinion' => $opinion,
  5554. 'status' => $status,
  5555. 'nextStaff' => $nextStaff
  5556. );
  5557. } else {
  5558. // 获取角色下的所有用户ID
  5559. $nowStaffList = array ();
  5560. foreach ( $verifyDetail as $vfk ) {
  5561. if ($vfk [1] == 'ROLE') {
  5562. $vStaffString = json_decode ( $vfk [3] );
  5563. foreach ( $vStaffString as $key => $value ) {
  5564. $staffK = explode ( "_", $value );
  5565. array_push ( $nowStaffList, $staffK [0] );
  5566. }
  5567. }
  5568. }
  5569. $nowStaff = implode ( ',', $nowStaffList );
  5570. $verifyStaff [$this->staff [0] ['sid']] = array (
  5571. 'date' => date ( 'Y-m-d' ),
  5572. 'opinion' => $opinion,
  5573. 'status' => $status,
  5574. 'nextStaff' => $nextStaff,
  5575. 'ROLE' => 0
  5576. );
  5577. }
  5578. if ($status == 3) {
  5579. $verifyStaff ['final'] = $status;
  5580. $verifyStaff [$this->staff [0] ['sid']] = array (
  5581. 'date' => date ( 'Y-m-d' ),
  5582. 'opinion' => $opinion,
  5583. 'status' => $status
  5584. );
  5585. }
  5586. $vStaffString = json_encode ( $verifyStaff );
  5587. $receipt->nowStaff = $nowStaff;
  5588. $receipt->verifyStaff = $vStaffString;
  5589. $loanReceipt->nowStaff = $nowStaff;
  5590. $loanReceipt->verifyStaff = $vStaffString;
  5591. }
  5592. // 角色审批
  5593. if (isset ( $VS ['ROLE'] )) {
  5594. // 找出角色人 当前审批角色组
  5595. $verifyJSStaff = array ();
  5596. $nowStaffList2 = array ();
  5597. foreach ( $verifyDetail as $key => $value ) {
  5598. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5599. $verifyJSStaff = json_decode ( $value [3] );
  5600. foreach ( $verifyJSStaff as $m ) {
  5601. $staffK = explode ( "_", $m );
  5602. array_push ( $nowStaffList2, $staffK [0] );
  5603. }
  5604. // print_r($nowStaffList2);
  5605. }
  5606. }
  5607. $RoleVerifyStaff = array ();
  5608. foreach ( $verifyStaff as $key => $value ) {
  5609. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5610. foreach ( $nowStaffList2 as $m ) {
  5611. if ($key == $m . "_R")
  5612. $RoleVerifyStaff [$key] = $value;
  5613. }
  5614. }
  5615. }
  5616. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5617. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5618. // 下一个审批人ID
  5619. $nextStaff = 0;
  5620. $falg = false;
  5621. foreach ( $verifyDetail as $key => $value ) {
  5622. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5623. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5624. $falg = true;
  5625. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5626. $nowStaffList = array ();
  5627. foreach ( $vStaffString as $v ) {
  5628. $staffK = explode ( "_", $v );
  5629. array_push ( $nowStaffList, $staffK [0] );
  5630. }
  5631. $nowStaff = implode ( ',', $nowStaffList );
  5632. $nextStaff = $verifyDetail [$key + 1] [0];
  5633. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5634. $nextStaff = $verifyDetail [$key + 1] [0];
  5635. $nowStaff = $nextStaff;
  5636. } else
  5637. $nowStaff = '';
  5638. break;
  5639. }
  5640. }
  5641. if ($falg)
  5642. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5643. 'date' => date ( 'Y-m-d' ),
  5644. 'opinion' => $opinion,
  5645. 'status' => $status,
  5646. 'nextStaff' => $nextStaff,
  5647. 'ROLE' => 1
  5648. );
  5649. else
  5650. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5651. 'date' => date ( 'Y-m-d' ),
  5652. 'opinion' => $opinion,
  5653. 'status' => $status,
  5654. 'nextStaff' => $nextStaff
  5655. );
  5656. // print_r($verifyStaff);
  5657. // echo $nowStaff;die;
  5658. } else { // 进入下一个角色或者审批人
  5659. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5660. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5661. 'date' => date ( 'Y-m-d' ),
  5662. 'opinion' => $opinion,
  5663. 'status' => $status,
  5664. 'nextStaff' => $VS ['nextStaff'],
  5665. 'ROLE' => 1
  5666. );
  5667. }
  5668. if ($status == 3) {
  5669. $verifyStaff ['final'] = $status;
  5670. $verifyStaff [$this->staff [0] ['sid']] = array (
  5671. 'date' => date ( 'Y-m-d' ),
  5672. 'opinion' => $opinion,
  5673. 'status' => $status
  5674. );
  5675. }
  5676. $vStaffString = json_encode ( $verifyStaff );
  5677. $receipt->verifyStaff = $vStaffString;
  5678. $receipt->nowStaff = $nowStaff;
  5679. $loanReceipt->nowStaff = $nowStaff;
  5680. $loanReceipt->verifyStaff = $vStaffString;
  5681. }
  5682. // print_r($verifyStaff);die;
  5683. }
  5684. $roleKey = 0;
  5685. $roleId = 0;
  5686. $verifyDetailCopy = array ();
  5687. foreach ( $verifyDetail as $k => $v ) {
  5688. if ($v [1] == 'ROLE') {
  5689. $roleId = $v [0];
  5690. $roleVerify = json_decode ( $v [3], true );
  5691. $roleKey = $k;
  5692. $roleArray = array ();
  5693. foreach ( $roleVerify as $o => $p ) {
  5694. $staffID = explode ( '_', $p );
  5695. $exp = array (
  5696. 0 => $staffID [0],
  5697. 1 => $staffID [1]
  5698. );
  5699. array_push ( $roleArray, $exp );
  5700. }
  5701. $verifyDetailCopy [$v [0]] = $roleArray;
  5702. }
  5703. }
  5704. // print_r($verifyDetail);
  5705. foreach ( $verifyDetailCopy as $k => $v ) {
  5706. foreach ( $verifyDetail as $m => $n ) {
  5707. if ($n [0] == $k) {
  5708. array_splice ( $verifyDetail, $m, 1, $v );
  5709. }
  5710. }
  5711. }
  5712. // 审批日志
  5713. if (! isset ( $verifyStaff ['final'] )) {
  5714. Doo::loadModel ( "receiptLog" );
  5715. $receiptLog = new receiptLog ();
  5716. if (! empty ( $roleId )) {
  5717. Doo::loadModel ( "role" );
  5718. $role = new role ();
  5719. $roleInfo = $role->getOne ( array (
  5720. 'where' => 'rid=' . $roleId,
  5721. 'asArray' => true
  5722. ) );
  5723. $receiptLog->rolename = $roleInfo ['name'];
  5724. }
  5725. $receiptLog->username = $this->staff [0] ['username'];
  5726. $receiptLog->uid = $this->staff [0] ['sid'];
  5727. $receiptLog->date = date ( "Y-m-d" );
  5728. $receiptLog->opinion = $opinion;
  5729. $receiptLog->img = $this->staff [0] ['avatar'];
  5730. $receiptLog->status = 1;
  5731. $receiptLog->rid = $rid;
  5732. $receiptLog->insert ();
  5733. }
  5734. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5735. $receipt->status = 3;
  5736. $receipt->verifyBreakup = $verifyString;
  5737. $receiptDetailObj->status = 3;
  5738. $receiptDetailObj->update ( array (
  5739. 'where' => 'rid=' . $rid
  5740. ) );
  5741. // 微信企业号通知
  5742. $this->setWXMsg ( $rid, 3 );
  5743. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5744. $receipt->status = 6;
  5745. $receipt->pastDate = date ( "Y-m-d" );
  5746. $receipt->isBK = 1;
  5747. $loanReceipt->verifyBreakup = $verifyString;
  5748. $loanReceipt->status = 1;
  5749. $loanReceipt->pastDate = date ( "Y-m-d" );
  5750. //生成流水后 不更新汇款金额
  5751. Doo::loadModel ( 'wasteBook' );
  5752. $wasteBook = new wasteBook ();
  5753. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5754. if (empty($wbDetail)){
  5755. $loanReceipt->amount = $receiptDetail ['amount'];
  5756. }
  5757. $loanReceipt->update ( array (
  5758. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5759. ) );
  5760. // 微信企业号通知
  5761. $this->setWXMsg ( $rid, 1 );
  5762. }
  5763. $receipt->amount = $receiptDetail['sum'];
  5764. $receipt->update ( array (
  5765. 'where' => ' rid = ' . $rid
  5766. ) );
  5767. // 进入下一条审批费用新加需求
  5768. $vidList = array ();
  5769. $verifyDetail = $verify->find ( array (
  5770. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5771. 'asArray' => true
  5772. ) );
  5773. foreach ( $verifyDetail as $key => $value ) {
  5774. array_push ( $vidList, $value ['vid'] );
  5775. }
  5776. $vid = implode ( ",", $vidList );
  5777. if (empty ( $verifyDetail ))
  5778. $vid = 0;
  5779. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5780. $receipt = new receipt ();
  5781. $rd = $receipt->getOne ( array (
  5782. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5783. 'asc' => 'rid',
  5784. 'asArray' => true
  5785. ) );
  5786. if (empty ( $rd )) {
  5787. return '/approvalExpenses/pendApproval';
  5788. }
  5789. if ($rd ['Rtype'] == 1) {
  5790. if ($rd ['isBK'] == 1) {
  5791. return '/receiptburEdi/' . $rd ['rid'];
  5792. } else {
  5793. return '/expensesEdi/' . $rd ['rid'];
  5794. }
  5795. } elseif ($rd ['Rtype'] == 2) {
  5796. return '/remitApproval/' . $rd ['rid'];
  5797. } else {
  5798. return '/receiptburEdi/' . $rd ['rid'];
  5799. }
  5800. // return "/approvalExpenses/pendApproval";
  5801. }
  5802. }
  5803. function ajaxExamineExe() {
  5804. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5805. Doo::loadModel ( 'receipt' );
  5806. $receipt = new receipt ();
  5807. Doo::loadClass ( 'XDeode' );
  5808. $XDeode = new XDeode ( 5 );
  5809. if (! empty ( $rid )) {
  5810. $rLRes = $receipt->find ( array (
  5811. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5812. 'asArray' => true
  5813. ) );
  5814. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5815. echo json_encode ( array (
  5816. 'status' => 1,
  5817. 'receipt' => $rLRes [0]
  5818. ) );
  5819. die ();
  5820. }
  5821. echo json_encode ( array (
  5822. 'status' => 0,
  5823. 'receipt' => array ()
  5824. ) );
  5825. die ();
  5826. }
  5827. function implement() {
  5828. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5829. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5830. Doo::loadClass ( 'XDeode' );
  5831. $XDeode = new XDeode ( 5 );
  5832. Doo::loadModel ( 'receipt' );
  5833. $receipt = new receipt ();
  5834. Doo::loadModel ( 'L_category' );
  5835. $Lcategory = new L_category ();
  5836. Doo::loadModel ( 'verify' );
  5837. $verify = new verify ();
  5838. Doo::loadModel ( 'staff' );
  5839. $staff = new staff ();
  5840. Doo::loadModel ( "execute" );
  5841. $execute = new execute ();
  5842. $rid = $XDeode->decode ( $rid );
  5843. $receiptList = $receipt->find ( array (
  5844. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5845. 'desc' => 'rid',
  5846. 'asArray' => true
  5847. ) );
  5848. Doo::loadModel ( 'loanReceipt' );
  5849. $loanReceipt = new loanReceipt ();
  5850. // print_r($receiptList);
  5851. $loanList = array ();
  5852. if (! isset ( $receiptList ))
  5853. $loanList = $loanReceipt->find ( array (
  5854. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5855. 'desc' => 'rid',
  5856. 'asArray' => true
  5857. ) );
  5858. $Locate = 0;
  5859. $roleId = 0;
  5860. $button = 0;
  5861. foreach ( $loanList as $key => $value ) {
  5862. $loanList [$key] ['Locate'] = $Locate;
  5863. $Locate ++;
  5864. $loanList [$key] ['reviseDetail'] = array ();
  5865. if (! empty ( $value ['reviseDetail'] ))
  5866. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5867. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5868. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5869. $categoryDetil = $Lcategory->getOne ( array (
  5870. 'where' => 'cid=' . $value ['cid'],
  5871. 'asArray' => true
  5872. ) );
  5873. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5874. // 检测编辑状态
  5875. $verifyList = $verify->getOne ( array (
  5876. 'where' => 'vid=' . $value ['verify'],
  5877. 'asArray' => true
  5878. ) );
  5879. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5880. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5881. Doo::loadModel ( 'role' );
  5882. $role = new role ();
  5883. $flag = true;
  5884. $roleKey = 0;
  5885. $endStaffArray = array ();
  5886. $roleArrayCopy = array ();
  5887. foreach ( $verifyList as $k => $v ) {
  5888. // init verifyStaff
  5889. if ($v [1] == 'ROLE') {
  5890. if (! empty ( $verifyStaff )) {
  5891. $endStaffArray = end ( $verifyStaff );
  5892. // if ($v[0]==$endStaffArray['nextStaff']){
  5893. // $roleId=$v[0];
  5894. // }
  5895. }
  5896. $roleVerify = json_decode ( $v [3], true );
  5897. $roleKey = $k;
  5898. $roleArray = array ();
  5899. $rolename = $role->getOne ( array (
  5900. 'where' => 'rid=' . $v [0],
  5901. 'asArray' => true
  5902. ) );
  5903. foreach ( $roleVerify as $o => $p ) {
  5904. $staffID = explode ( '_', $p );
  5905. $staffInfo = $staff->getOne ( array (
  5906. 'where' => 'sid=' . $staffID [0],
  5907. 'asArray' => true
  5908. ) );
  5909. // print_r($staffID);
  5910. $exp = array (
  5911. 0 => $staffInfo ['sid'],
  5912. 1 => $staffID [1],
  5913. 2 => $staffInfo ['avatar'],
  5914. 'date' => '',
  5915. 'date' => '',
  5916. 'opinion' => '',
  5917. 'status' => '',
  5918. 'rolename' => $rolename ['name']
  5919. );
  5920. array_push ( $roleArray, $exp );
  5921. }
  5922. $roleArrayCopy [$v [0]] = $roleArray;
  5923. // $verifyList[$k]['roleArray']=$roleArray;
  5924. }
  5925. $verifyList [$k] ['date'] = "";
  5926. $verifyList [$k] ['opinion'] = "";
  5927. $verifyList [$k] ['status'] = "";
  5928. if (empty ( $verifyStaff )) {
  5929. $verifyList [$k] ['date'] = "";
  5930. $verifyList [$k] ['opinion'] = "";
  5931. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5932. $verifyList [$k] ['status'] = 4;
  5933. $flag = false;
  5934. }
  5935. } else {
  5936. foreach ( $verifyStaff as $m => $u ) {
  5937. if ($v [0] == $m) {
  5938. $verifyList [$k] ['date'] = $u ['date'];
  5939. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5940. $verifyList [$k] ['status'] = $u ['status'];
  5941. $flag = false;
  5942. break;
  5943. }
  5944. }
  5945. $endStaffArray = end ( $verifyStaff );
  5946. if (isset ( $endStaffArray ['ROLE'] )) {
  5947. } else {
  5948. // $endKey=key($verifyStaff);
  5949. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5950. // $button=4;
  5951. // $verifyList[$k]['status']=4;
  5952. // }
  5953. }
  5954. }
  5955. }
  5956. $rolename ['name'] = '';
  5957. if (! empty ( $roleId )) {
  5958. Doo::loadModel ( 'role' );
  5959. $role = new role ();
  5960. $rolename = $role->getOne ( array (
  5961. 'where' => 'rid=' . $roleId,
  5962. 'asArray' => true
  5963. ) );
  5964. }
  5965. if (! empty ( $verifyStaff ))
  5966. $endStaffArray = end ( $verifyStaff );
  5967. $KOP = false;
  5968. foreach ( $roleArrayCopy as $P => $A ) {
  5969. foreach ( $A as $MKI => $AVL ) {
  5970. if (! empty ( $verifyStaff )) {
  5971. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5972. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5973. $button = 4;
  5974. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5975. }
  5976. foreach ( $verifyStaff as $m => $u ) {
  5977. $AVLFK = $AVL [0] . '_R';
  5978. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5979. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5980. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5981. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5982. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5983. break;
  5984. }
  5985. }
  5986. } else {
  5987. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5988. $button = 4;
  5989. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5990. }
  5991. }
  5992. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5993. $KOP = true;
  5994. }
  5995. }
  5996. foreach ( $roleArrayCopy as $k => $v ) {
  5997. foreach ( $verifyList as $m => $n ) {
  5998. if ($n [0] == $k) {
  5999. array_splice ( $verifyList, $m, 1, $v );
  6000. }
  6001. }
  6002. }
  6003. $loanList [$key] ['verifyList'] = $verifyList;
  6004. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6005. 'where' => 'sid=' . $value ['staff'],
  6006. 'asArray' => true
  6007. ) );
  6008. }
  6009. $data ['loanList'] = $loanList;
  6010. $Locate = 0;
  6011. $roleId = 0;
  6012. $button = 0;
  6013. Doo::loadClass ( 'XDeode' );
  6014. $XDeode = new XDeode ( 5 );
  6015. foreach ( $receiptList as $key => $value ) {
  6016. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6017. $button2 = 0;
  6018. $receiptList [$key] ['Locate'] = $Locate;
  6019. $Locate ++;
  6020. $receiptList [$key] ['reviseDetail'] = array ();
  6021. if (! empty ( $value ['reviseDetail'] ))
  6022. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6023. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6024. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6025. $categoryDetil = $Lcategory->getOne ( array (
  6026. 'where' => 'cid=' . $value ['cid'],
  6027. 'asArray' => true
  6028. ) );
  6029. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6030. $executeList = json_decode ( $value ['executeCopy'], true );
  6031. $executeStaff = array ();
  6032. if (! empty ( $value ['executeStaff'] ))
  6033. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6034. if (isset ( $executeList )) {
  6035. foreach ( $executeList as $op => $lo ) {
  6036. $executeList [$op] ['date'] = "";
  6037. $executeList [$op] ['opinion'] = "";
  6038. $executeList [$op] ['status'] = "";
  6039. foreach ( $executeStaff as $m => $u ) {
  6040. if ($lo [0] == $m) {
  6041. $executeList [$op] ['date'] = $u ['date'];
  6042. $executeList [$op] ['opinion'] = $u ['opinion'];
  6043. $executeList [$op] ['status'] = $u ['status'];
  6044. break;
  6045. }
  6046. }
  6047. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6048. $button2 = 1;
  6049. $executeList [$op] ['status'] = 4;
  6050. }
  6051. }
  6052. }
  6053. // 检测编辑状态
  6054. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6055. $verifyList ['staff'] = $value ['verifyBreakup'];
  6056. } else
  6057. $verifyList = $verify->getOne ( array (
  6058. 'where' => 'vid=' . $value ['verify'],
  6059. 'asArray' => true
  6060. ) );
  6061. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6062. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6063. Doo::loadModel ( 'role' );
  6064. $role = new role ();
  6065. if ($verifyList == NULL)
  6066. $verifyList = array ();
  6067. $flag = true;
  6068. $roleKey = 0;
  6069. $endStaffArray = array ();
  6070. $roleArrayCopy = array ();
  6071. foreach ( $verifyList as $k => $v ) {
  6072. // init verifyStaff
  6073. if ($v [1] == 'ROLE') {
  6074. if (! empty ( $verifyStaff )) {
  6075. $endStaffArray = end ( $verifyStaff );
  6076. // if ($v[0]==$endStaffArray['nextStaff']){
  6077. // $roleId=$v[0];
  6078. // }
  6079. }
  6080. $roleVerify = json_decode ( $v [3], true );
  6081. $roleKey = $k;
  6082. $roleArray = array ();
  6083. $rolename = $role->getOne ( array (
  6084. 'where' => 'rid=' . $v [0],
  6085. 'asArray' => true
  6086. ) );
  6087. foreach ( $roleVerify as $o => $p ) {
  6088. $staffID = explode ( '_', $p );
  6089. $staffInfo = $staff->getOne ( array (
  6090. 'where' => 'sid=' . $staffID [0],
  6091. 'asArray' => true
  6092. ) );
  6093. // print_r($staffID);
  6094. $exp = array (
  6095. 0 => $staffInfo ['sid'],
  6096. 1 => $staffID [1],
  6097. 2 => $staffInfo ['avatar'],
  6098. 'date' => '',
  6099. 'date' => '',
  6100. 'opinion' => '',
  6101. 'status' => '',
  6102. 'rolename' => $rolename ['name']
  6103. );
  6104. array_push ( $roleArray, $exp );
  6105. }
  6106. $roleArrayCopy [$v [0]] = $roleArray;
  6107. // $verifyList[$k]['roleArray']=$roleArray;
  6108. }
  6109. $verifyList [$k] ['date'] = "";
  6110. $verifyList [$k] ['opinion'] = "";
  6111. $verifyList [$k] ['status'] = "";
  6112. if (empty ( $verifyStaff )) {
  6113. $verifyList [$k] ['date'] = "";
  6114. $verifyList [$k] ['opinion'] = "";
  6115. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6116. $verifyList [$k] ['status'] = 4;
  6117. $flag = false;
  6118. }
  6119. } else {
  6120. foreach ( $verifyStaff as $m => $u ) {
  6121. if ($v [0] == $m) {
  6122. $verifyList [$k] ['date'] = $u ['date'];
  6123. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6124. $verifyList [$k] ['status'] = $u ['status'];
  6125. $flag = false;
  6126. break;
  6127. }
  6128. }
  6129. $endStaffArray = end ( $verifyStaff );
  6130. if (isset ( $endStaffArray ['ROLE'] )) {
  6131. } else {
  6132. // $endKey=key($verifyStaff);
  6133. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6134. // $button=4;
  6135. // $verifyList[$k]['status']=4;
  6136. // }
  6137. }
  6138. }
  6139. }
  6140. $rolename ['name'] = '';
  6141. if (! empty ( $roleId )) {
  6142. Doo::loadModel ( 'role' );
  6143. $role = new role ();
  6144. $rolename = $role->getOne ( array (
  6145. 'where' => 'rid=' . $roleId,
  6146. 'asArray' => true
  6147. ) );
  6148. }
  6149. if (! empty ( $verifyStaff ))
  6150. $endStaffArray = end ( $verifyStaff );
  6151. $KOP = false;
  6152. foreach ( $roleArrayCopy as $P => $A ) {
  6153. foreach ( $A as $MKI => $AVL ) {
  6154. if (! empty ( $verifyStaff )) {
  6155. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6156. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6157. $button = 4;
  6158. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6159. }
  6160. foreach ( $verifyStaff as $m => $u ) {
  6161. $AVLFK = $AVL [0] . '_R';
  6162. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6163. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6164. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6165. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6166. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6167. break;
  6168. }
  6169. }
  6170. } else {
  6171. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6172. $button = 4;
  6173. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6174. }
  6175. }
  6176. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6177. $KOP = true;
  6178. }
  6179. }
  6180. foreach ( $roleArrayCopy as $k => $v ) {
  6181. foreach ( $verifyList as $m => $n ) {
  6182. if ($n [0] == $k) {
  6183. array_splice ( $verifyList, $m, 1, $v );
  6184. }
  6185. }
  6186. }
  6187. $receiptList [$key] ['verifyList'] = $verifyList;
  6188. $receiptList [$key] ['executeList'] = $executeList;
  6189. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6190. 'where' => 'sid=' . $value ['staff'],
  6191. 'asArray' => true
  6192. ) );
  6193. $receiptList [$key] ['button2'] = $button2;
  6194. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6195. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6196. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6197. $receiptList [$key] ['relust'] = $relust;
  6198. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6199. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6200. }
  6201. //执行人是否是最后一位
  6202. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6203. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6204. $executePrimary=count($executeCopy)-1;
  6205. $lastOne=true;
  6206. if($executePrimary!=count($executeStaff)){
  6207. $lastOne=false;
  6208. }
  6209. $data['lastOne']=$lastOne;
  6210. // 是否写入过流水
  6211. $accountType = 0;
  6212. if ($receiptList [0] ['Rtype'] == 0) {
  6213. $accountType = 3;
  6214. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6215. if($receiptList [0]['version']==1){
  6216. $accountType = 2;
  6217. }else{
  6218. if (!empty($receiptList [0]['accountItem']) ){
  6219. // if (!empty($receiptList [0]['loanRid']) ){
  6220. $accountType = 2;
  6221. }else{
  6222. $accountType = 1;
  6223. }
  6224. }
  6225. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6226. $accountType = 4;
  6227. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6228. $accountType = 12;
  6229. }
  6230. Doo::loadModel ( 'wasteBook' );
  6231. $wasteBook = new wasteBook ();
  6232. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6233. $data ['wbDetail'] = $wbDetail;
  6234. $wbDetailLoan=array();
  6235. if ($accountType==2){
  6236. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6237. }
  6238. $data ['wbDetailLoan'] = $wbDetailLoan;
  6239. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6240. //print_r($wbDetail);
  6241. if($receiptList[0]['version']==1){
  6242. require "protected/class/comm_cld.php";
  6243. $receiptList=makeReceiptDataVersion1($receiptList);
  6244. }
  6245. $data ['receiptList'] = $receiptList;
  6246. $data ['memu'] = "receipt";
  6247. $data ['staff'] = $this->staff;
  6248. $data ['receiptMemu'] = 'implement';
  6249. $data ['verifyId'] = $this->verifyId;
  6250. $data ['executeId'] = $this->executeId;
  6251. if($receiptList[0]['version']==1){
  6252. if ($Rtype=="loan"){
  6253. $this->render ( "/fee/implement/loan_compatible", $data );
  6254. }else{
  6255. $this->render ( "/fee/implement/receipt_compatible", $data );
  6256. }
  6257. die;
  6258. }
  6259. if ($Rtype=="loan"){
  6260. $this->render ( "/receipt/receiptImplementLoan", $data );
  6261. }elseif($Rtype=="receipt"){
  6262. if($receiptList[0]['receiptClass']==2){
  6263. //TODO 费用执行行程单2.0
  6264. if(!empty($receiptList[0]['itinerary2'])){
  6265. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6266. }else{
  6267. $this->render ( "/receipt/receiptImplementTrave", $data );
  6268. }
  6269. }else{
  6270. $this->render ( "/receipt/receiptImplement", $data );
  6271. }
  6272. }elseif($Rtype=="public"){
  6273. $this->render ( "/receipt/receiptImplementPublic", $data );
  6274. }else{
  6275. //$this->render ( "/admin/implement", $data );
  6276. }
  6277. }
  6278. function implementDo() {
  6279. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6280. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6281. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6282. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6283. // $ab = '';
  6284. // if ($accountBank == 'CGBDeposit')
  6285. // $ab = '纵横广发';
  6286. // elseif ($accountBank == 'ICBCDeposit')
  6287. // $ab = '纵横工行';
  6288. // elseif ($accountBank == 'HUADeposit')
  6289. // $ab = '华润银行';
  6290. // elseif ($accountBank == 'PersonalDeposit')
  6291. // $ab = '个人广发';
  6292. // if (empty ( $ab ))
  6293. // die ( 'illegal request--22' );
  6294. if (! empty ( $rid )) {
  6295. Doo::loadModel ( 'receipt' );
  6296. $receipt = new receipt ();
  6297. Doo::loadClass ( 'XDeode' );
  6298. $XDeode = new XDeode ( 5 );
  6299. $rid=$XDeode->decode($rid);
  6300. if (!is_numeric($rid)){
  6301. die;
  6302. }
  6303. // $rinfo = $receipt->getOne ( array (
  6304. // 'where' => 'rid=' . $rid,
  6305. // 'asArray' => true
  6306. // ) );
  6307. $rinfo = $receipt->getReceiptByRid ( $rid );
  6308. // $accountType = '';
  6309. // if ($rinfo ['Rtype'] == 1) {
  6310. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6311. // $accountType = 2;
  6312. // else
  6313. // $accountType = 1;
  6314. // } elseif ($rinfo ['Rtype'] == 2) {
  6315. // $accountType = 4;
  6316. // } elseif ($rinfo ['Rtype'] == 0)
  6317. // $accountType = 3;
  6318. // if (empty ( $accountType ))
  6319. // die ( 'illegal request' );
  6320. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6321. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6322. if (empty ( $executeStaff )) {
  6323. $executeStaff = array (
  6324. $this->staff [0] ['sid'] => array (
  6325. 'date' => date ( 'Y-m-d' ),
  6326. 'opinion' => $implementOpinions,
  6327. 'status' => 1
  6328. )
  6329. );
  6330. } else {
  6331. $executeStaff [$this->staff [0] ['sid']] = array (
  6332. 'date' => date ( 'Y-m-d' ),
  6333. 'opinion' => $implementOpinions,
  6334. 'status' => 1
  6335. );
  6336. }
  6337. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6338. $receipt->executeStaff = json_encode ( $executeStaff );
  6339. $receipt->status = 8;
  6340. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6341. $receipt->status = 9;
  6342. if ($rinfo ['status'] == 6) {
  6343. $receipt->loanDate = date ( "Y-m-d" );
  6344. }
  6345. $receipt->executeDate = date ( "Y-m-d" );
  6346. } else {
  6347. $receipt->executeStaff = json_encode ( $executeStaff );
  6348. }
  6349. //$receipt->amount = $amount;
  6350. $receipt->update ( array (
  6351. 'where' => 'rid=' . $rid
  6352. ) );
  6353. // 公司流水记录
  6354. // Doo::loadModel ( 'wasteBook' );
  6355. // $wasteBook = new wasteBook ();
  6356. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6357. // // 银行
  6358. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6359. // $item = array (
  6360. // 'dataID' => $rid,
  6361. // 'expensesType' => 2,
  6362. // 'accountType' => $accountType,
  6363. // 'accountPriceShow' => $amount,
  6364. // 'accountPrice' => - $amount,
  6365. // 'accountBank' => $accountBank,
  6366. // 'category' => $rinfo ['category'] [0] ['title'],
  6367. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6368. // 'name' => $rinfo ['staffDetail'] ['username'],
  6369. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6370. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6371. // );
  6372. // $wasteBook->setAccountBookStatistics ( $item );
  6373. // }
  6374. }
  6375. //$ridKey = $XDeode->encode ( $rid );
  6376. return "/hisImplement";
  6377. // return "/implement/" . $ridKey . ".html";
  6378. }
  6379. function receiptburEdi() {
  6380. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6381. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6382. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6383. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6384. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6385. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6386. if (empty ( $status ))
  6387. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6388. $vidList = array ();
  6389. $button = 0;
  6390. Doo::loadModel ( 'verify' );
  6391. Doo::loadModel ( 'receipt' );
  6392. Doo::loadModel ( 'staff' );
  6393. $staff = new staff ();
  6394. $receipt = new receipt ();
  6395. $verify = new verify ();
  6396. Doo::loadModel ( 'L_category' );
  6397. $Lcategory = new L_category ();
  6398. Doo::loadModel ( 'enclosur' );
  6399. $enclosur = new enclosur ();
  6400. Doo::loadModel ( 'loanReceipt' );
  6401. $loanReceipt = new loanReceipt ();
  6402. // user verify ID
  6403. $verifyDetail = $verify->find ( array (
  6404. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6405. 'asArray' => true
  6406. ) );
  6407. foreach ( $verifyDetail as $key => $value ) {
  6408. array_push ( $vidList, $value ['vid'] );
  6409. }
  6410. $vid = implode ( ",", $vidList );
  6411. if (empty ( $verifyDetail ))
  6412. $vid = 0;
  6413. $categoryList = $Lcategory->find ( array (
  6414. 'asArray' => true
  6415. ) );
  6416. $staffList = $staff->find ( array (
  6417. 'where' => 'cid=' . $cid,
  6418. 'asArray' => true
  6419. ) );
  6420. $ap = "";
  6421. if ($status == 4) {
  6422. $ap = 4;
  6423. $status = 2;
  6424. }
  6425. // get Receipt By verifyID status 2
  6426. $receiptList = $receipt->find ( array (
  6427. 'where' => 'rid =' . $rid . ' and status=2',
  6428. 'desc' => 'rid',
  6429. 'asArray' => true
  6430. ) );
  6431. if (empty ( $receiptList )) {
  6432. die ( 'illegal request' );
  6433. }
  6434. $loanList = $loanReceipt->find ( array (
  6435. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6436. 'desc' => 'rid',
  6437. 'asArray' => true
  6438. ) );
  6439. $data ['explanation'] = '';
  6440. if (! empty ( $loanList ))
  6441. $data ['explanation'] = $loanList [0] ['explanation'];
  6442. $Locate = 0;
  6443. $roleId = 0;
  6444. $button = 0;
  6445. foreach ( $loanList as $key => $value ) {
  6446. $loanList [$key] ['Locate'] = $Locate;
  6447. $Locate ++;
  6448. $loanList [$key] ['reviseDetail'] = array ();
  6449. if (! empty ( $value ['reviseDetail'] ))
  6450. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6451. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6452. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6453. $categoryDetil = $Lcategory->getOne ( array (
  6454. 'where' => 'cid=' . $value ['cid'],
  6455. 'asArray' => true
  6456. ) );
  6457. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6458. // 检测编辑状态
  6459. $verifyList = $verify->getOne ( array (
  6460. 'where' => 'vid=' . $value ['verify'],
  6461. 'asArray' => true
  6462. ) );
  6463. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6464. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6465. Doo::loadModel ( 'role' );
  6466. $role = new role ();
  6467. $flag = true;
  6468. $roleKey = 0;
  6469. $endStaffArray = array ();
  6470. $roleArrayCopy = array ();
  6471. foreach ( $verifyList as $k => $v ) {
  6472. // init verifyStaff
  6473. if ($v [1] == 'ROLE') {
  6474. if (! empty ( $verifyStaff )) {
  6475. $endStaffArray = end ( $verifyStaff );
  6476. }
  6477. $roleVerify = json_decode ( $v [3], true );
  6478. $roleKey = $k;
  6479. $roleArray = array ();
  6480. $rolename = $role->getOne ( array (
  6481. 'where' => 'rid=' . $v [0],
  6482. 'asArray' => true
  6483. ) );
  6484. foreach ( $roleVerify as $o => $p ) {
  6485. $staffID = explode ( '_', $p );
  6486. $staffInfo = $staff->getOne ( array (
  6487. 'where' => 'sid=' . $staffID [0],
  6488. 'asArray' => true
  6489. ) );
  6490. // print_r($staffID);
  6491. $exp = array (
  6492. 0 => $staffInfo ['sid'],
  6493. 1 => $staffID [1],
  6494. 2 => $staffInfo ['avatar'],
  6495. 'date' => '',
  6496. 'date' => '',
  6497. 'opinion' => '',
  6498. 'status' => '',
  6499. 'rolename' => $rolename ['name']
  6500. );
  6501. array_push ( $roleArray, $exp );
  6502. }
  6503. $roleArrayCopy [$v [0]] = $roleArray;
  6504. // $verifyList[$k]['roleArray']=$roleArray;
  6505. }
  6506. $verifyList [$k] ['date'] = "";
  6507. $verifyList [$k] ['opinion'] = "";
  6508. $verifyList [$k] ['status'] = "";
  6509. if (empty ( $verifyStaff )) {
  6510. $verifyList [$k] ['date'] = "";
  6511. $verifyList [$k] ['opinion'] = "";
  6512. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6513. $verifyList [$k] ['status'] = 4;
  6514. $flag = false;
  6515. }
  6516. } else {
  6517. foreach ( $verifyStaff as $m => $u ) {
  6518. if ($v [0] == $m) {
  6519. $verifyList [$k] ['date'] = $u ['date'];
  6520. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6521. $verifyList [$k] ['status'] = $u ['status'];
  6522. $flag = false;
  6523. break;
  6524. }
  6525. }
  6526. $endStaffArray = end ( $verifyStaff );
  6527. if (isset ( $endStaffArray ['ROLE'] )) {
  6528. } else {
  6529. }
  6530. }
  6531. }
  6532. $rolename ['name'] = '';
  6533. if (! empty ( $roleId )) {
  6534. Doo::loadModel ( 'role' );
  6535. $role = new role ();
  6536. $rolename = $role->getOne ( array (
  6537. 'where' => 'rid=' . $roleId,
  6538. 'asArray' => true
  6539. ) );
  6540. }
  6541. if (! empty ( $verifyStaff ))
  6542. $endStaffArray = end ( $verifyStaff );
  6543. $KOP = false;
  6544. foreach ( $roleArrayCopy as $P => $A ) {
  6545. foreach ( $A as $MKI => $AVL ) {
  6546. if (! empty ( $verifyStaff )) {
  6547. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6548. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6549. $button = 4;
  6550. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6551. }
  6552. foreach ( $verifyStaff as $m => $u ) {
  6553. $AVLFK = $AVL [0] . '_R';
  6554. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6555. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6556. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6557. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6558. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6559. break;
  6560. }
  6561. }
  6562. } else {
  6563. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6564. $button = 4;
  6565. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6566. }
  6567. }
  6568. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6569. $KOP = true;
  6570. }
  6571. }
  6572. foreach ( $roleArrayCopy as $k => $v ) {
  6573. foreach ( $verifyList as $m => $n ) {
  6574. if ($n [0] == $k) {
  6575. array_splice ( $verifyList, $m, 1, $v );
  6576. }
  6577. }
  6578. }
  6579. $loanList [$key] ['verifyList'] = $verifyList;
  6580. }
  6581. $htmlLoan = '';
  6582. $data ['loanReceiptDate'] = '';
  6583. if (isset ( $loanList [0] )) {
  6584. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6585. if ($value ['status'] == 1)
  6586. $htmlLoan .= '<li class="done" >';
  6587. elseif ($value ['status'] == 3)
  6588. $htmlLoan .= '<li class="undone" >';
  6589. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6590. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6591. if (isset ( $value ['rolename'] ))
  6592. $htmlLoan .= $value ['rolename'];
  6593. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6594. }
  6595. $data ['loanDate'] = $loanList [0] ['date'];
  6596. } else {
  6597. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6598. }
  6599. $data ['htmlLoan'] = $htmlLoan;
  6600. // $data ['LoanReceipt']=$loanList[0];
  6601. // print_r($loanList);
  6602. $Locate = 0;
  6603. $roleId = 0;
  6604. $button = 0;
  6605. if ($ap == 4)
  6606. $status = 4;
  6607. Doo::loadClass ( 'XDeode' );
  6608. $XDeode = new XDeode ( 5 );
  6609. foreach ( $receiptList as $key => $value ) {
  6610. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6611. $receiptList [$key] ['Locate'] = $Locate;
  6612. $Locate ++;
  6613. $receiptList [$key] ['reviseDetail'] = array ();
  6614. // 调整金额 代码调整
  6615. if (! empty ( $value ['reviseDetail'] )) {
  6616. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6617. foreach ( $reviseDetail as $ry => $re ) {
  6618. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6619. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6620. }
  6621. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6622. // print_r($reviseDetail);
  6623. }
  6624. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6625. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6626. $categoryDetil = $Lcategory->getOne ( array (
  6627. 'where' => 'cid=' . $value ['cid'],
  6628. 'asArray' => true
  6629. ) );
  6630. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6631. // 检测编辑状态
  6632. $verifyList = $verify->getOne ( array (
  6633. 'where' => 'vid=' . $value ['verify'],
  6634. 'asArray' => true
  6635. ) );
  6636. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6637. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6638. Doo::loadModel ( 'role' );
  6639. $role = new role ();
  6640. // print_r($verifyList);
  6641. $flag = true;
  6642. $roleKey = 0;
  6643. $endStaffArray = array ();
  6644. $roleArrayCopy = array ();
  6645. foreach ( $verifyList as $k => $v ) {
  6646. // init verifyStaff
  6647. if ($v [1] == 'ROLE') {
  6648. if (! empty ( $verifyStaff )) {
  6649. $endStaffArray = end ( $verifyStaff );
  6650. if ($v [0] == $endStaffArray ['nextStaff']) {
  6651. $roleId = $v [0];
  6652. }
  6653. }
  6654. $roleVerify = json_decode ( $v [3], true );
  6655. $roleKey = $k;
  6656. $roleArray = array ();
  6657. $rolename = $role->getOne ( array (
  6658. 'where' => 'rid=' . $v [0],
  6659. 'asArray' => true
  6660. ) );
  6661. foreach ( $roleVerify as $o => $p ) {
  6662. $staffID = explode ( '_', $p );
  6663. $staffInfo = $staff->getOne ( array (
  6664. 'where' => 'sid=' . $staffID [0],
  6665. 'asArray' => true
  6666. ) );
  6667. // print_r($staffID);
  6668. $exp = array (
  6669. 0 => $staffInfo ['sid'],
  6670. 1 => $staffID [1],
  6671. 2 => $staffInfo ['avatar'],
  6672. 'date' => '',
  6673. 'date' => '',
  6674. 'opinion' => '',
  6675. 'status' => '',
  6676. 'rolename' => $rolename ['name']
  6677. );
  6678. array_push ( $roleArray, $exp );
  6679. }
  6680. $roleArrayCopy [$v [0]] = $roleArray;
  6681. // $verifyList[$k]['roleArray']=$roleArray;
  6682. }
  6683. // print_r($roleArray);
  6684. $verifyList [$k] ['date'] = "";
  6685. $verifyList [$k] ['opinion'] = "";
  6686. $verifyList [$k] ['status'] = "";
  6687. if (empty ( $verifyStaff )) {
  6688. $verifyList [$k] ['date'] = "";
  6689. $verifyList [$k] ['opinion'] = "";
  6690. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6691. $verifyList [$k] ['status'] = 4;
  6692. $button = 4;
  6693. $flag = false;
  6694. }
  6695. } else {
  6696. foreach ( $verifyStaff as $m => $u ) {
  6697. if ($v [0] == $m) {
  6698. $verifyList [$k] ['date'] = $u ['date'];
  6699. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6700. $verifyList [$k] ['status'] = $u ['status'];
  6701. $flag = false;
  6702. break;
  6703. }
  6704. }
  6705. $endStaffArray = end ( $verifyStaff );
  6706. if (isset ( $endStaffArray ['ROLE'] )) {
  6707. } else {
  6708. $endKey = key ( $verifyStaff );
  6709. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6710. $button = 4;
  6711. $verifyList [$k] ['status'] = 4;
  6712. }
  6713. }
  6714. }
  6715. }
  6716. $rolename ['name'] = '';
  6717. if (! empty ( $roleId )) {
  6718. Doo::loadModel ( 'role' );
  6719. $role = new role ();
  6720. $rolename = $role->getOne ( array (
  6721. 'where' => 'rid=' . $roleId,
  6722. 'asArray' => true
  6723. ) );
  6724. }
  6725. if (! empty ( $verifyStaff ))
  6726. $endStaffArray = end ( $verifyStaff );
  6727. $KOP = false;
  6728. foreach ( $roleArrayCopy as $P => $A ) {
  6729. foreach ( $A as $MKI => $AVL ) {
  6730. if (! empty ( $verifyStaff )) {
  6731. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6732. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6733. $button = 4;
  6734. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6735. }
  6736. foreach ( $verifyStaff as $m => $u ) {
  6737. $AVLFK = $AVL [0] . '_R';
  6738. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6739. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6740. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6741. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6742. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6743. break;
  6744. }
  6745. }
  6746. } else {
  6747. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6748. $button = 4;
  6749. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6750. }
  6751. }
  6752. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6753. $KOP = true;
  6754. }
  6755. }
  6756. foreach ( $roleArrayCopy as $k => $v ) {
  6757. foreach ( $verifyList as $m => $n ) {
  6758. if ($n [0] == $k) {
  6759. array_splice ( $verifyList, $m, 1, $v );
  6760. }
  6761. }
  6762. }
  6763. // print_r($verifyList);
  6764. $receiptList [$key] ['verifyList'] = $verifyList;
  6765. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6766. 'where' => 'sid=' . $value ['staff'],
  6767. 'asArray' => true
  6768. ) );
  6769. $receiptList [$key] ['button'] = $button;
  6770. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6771. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6772. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6773. $receiptList [$key] ['relust'] = $relust;
  6774. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6775. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6776. }
  6777. //print_r($receiptList);die;
  6778. // $data['verifyDetail']=$verifyDetail;
  6779. $mothHtml = "";
  6780. for($i = 1; $i <= 12; $i ++) {
  6781. if ($month == $i)
  6782. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6783. else
  6784. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6785. }
  6786. // 获取审批日志
  6787. Doo::loadModel ( 'receiptLog' );
  6788. $receiptLog = new receiptLog ();
  6789. $rlList = array ();
  6790. $rlInfo = $receiptLog->getOne ( array (
  6791. 'where' => 'rid=' . $rid . ' and status=4',
  6792. 'asArray' => true
  6793. ) );
  6794. $tijdate = $receiptLog->getOne ( array (
  6795. 'where' => 'rid=' . $rid . ' and status=2',
  6796. 'asc' => 'rlid',
  6797. 'asArray' => true
  6798. ) );
  6799. if (! empty ( $rlInfo )) {
  6800. $rlList = $receiptLog->find ( array (
  6801. 'where' => 'rid=' . $rid,
  6802. 'asc' => 'rlid',
  6803. 'asArray' => true
  6804. ) );
  6805. }
  6806. // echo $rid;
  6807. // print_r($receiptList);
  6808. $receiptList [0] ['rlList'] = $rlList;
  6809. // print_r($receiptList);
  6810. $enclosurList = $enclosur->find ( array (
  6811. 'where' => 'rid=' . $rid,
  6812. 'asArray' => true
  6813. ) );
  6814. $enclosurHtml = '';
  6815. foreach ( $enclosurList as $value ) {
  6816. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6817. }
  6818. $data ['enclosurHtml'] = $enclosurHtml;
  6819. $data ['rolename'] = $rolename ['name'];
  6820. $data ['mothHtml'] = $mothHtml;
  6821. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6822. if($receiptList[0]['version']==1){
  6823. require "protected/class/comm_cld.php";
  6824. $receiptList=makeReceiptDataVersion1($receiptList);
  6825. }
  6826. $data ['rid'] = $rid;
  6827. $data ['tijdate'] = $tijdate ['date'];
  6828. $data ['receiptList'] = $receiptList;
  6829. $data ['receiptApprovalCount'] = count ( $receiptList );
  6830. $data ['status'] = $status;
  6831. $data ['year'] = $year;
  6832. $data ['categoryList'] = $categoryList;
  6833. $data ['staffList'] = $staffList;
  6834. $data ['cid'] = $cid;
  6835. $data ['sid'] = $sid;
  6836. $data ['ap'] = $ap;
  6837. $data ['memu'] = "receipt";
  6838. $data ['staff'] = $this->staff;
  6839. $data ['receiptMemu'] = 'approvalExpenses';
  6840. $data ['verifyId'] = $this->verifyId;
  6841. $data ['executeId'] = $this->executeId;
  6842. if($receiptList[0]['version']==1){
  6843. $this->render ( "/fee/approval/receipt_compatible", $data );
  6844. die;
  6845. }
  6846. if($receiptList[0]['receiptClass']==1){
  6847. $this->render ( "/receipt/feeAgencyApproval", $data );
  6848. }elseif($receiptList[0]['receiptClass']==2){
  6849. //TODO 行程单2.0
  6850. if(!empty($receiptList[0]['itinerary2'])){
  6851. $this->render ( "/receipt/feeTraveApproval2", $data );
  6852. }else{
  6853. $this->render ( "/receipt/feeTraveApproval", $data );
  6854. }
  6855. }elseif($receiptList[0]['receiptClass']==3){
  6856. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6857. }else{
  6858. $this->render ( "/admin/receiptburEdi", $data );
  6859. }
  6860. }
  6861. function hisImplement() {
  6862. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6863. if (empty ( $item ))
  6864. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6865. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6866. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6867. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6868. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6869. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6870. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6871. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6872. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6873. Doo::loadClass ( 'XDeode' );
  6874. $XDeode = new XDeode ( 5 );
  6875. Doo::loadModel ( 'receipt' );
  6876. $receipt = new receipt ();
  6877. Doo::loadModel ( 'L_category' );
  6878. $Lcategory = new L_category ();
  6879. Doo::loadModel ( 'verify' );
  6880. Doo::loadModel ( 'statistics' );
  6881. $statistics = new statistics ();
  6882. $verify = new verify ();
  6883. Doo::loadModel ( 'staff' );
  6884. $staff = new staff ();
  6885. Doo::loadClass ( 'XDeode' );
  6886. $XDeode = new XDeode ( 5 );
  6887. $XDeode7 = new XDeode ( 7 );
  6888. $cid = $XDeode->decode ( $cidKey );
  6889. $condition = "";
  6890. if ($item == "expenses")
  6891. $condition = " and Rtype=1 ";
  6892. elseif ($item == "receipts")
  6893. $condition = " and Rtype=0 ";
  6894. elseif ($item == "remits")
  6895. $condition = " and Rtype=2 ";
  6896. elseif($item == "train")
  6897. $condition = " and Rtype=3 ";
  6898. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6899. $sopString = $cidString = "";
  6900. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6901. if (empty ( $rdate ))
  6902. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6903. else
  6904. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6905. if ($status == 'pendImplement') {
  6906. $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 ) ) ';
  6907. } elseif ($status == 'alerpts') {
  6908. $statusCon = '(status=8 or status=9 )';
  6909. if (empty ( $rdate )){
  6910. $dateCondition = " and Year(date) =" . $year;
  6911. }else{
  6912. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6913. }
  6914. }
  6915. if ($sop != 'SOP')
  6916. $sopString = " and staff=" . $sop;
  6917. if ($cidKey != 'ALL')
  6918. $cidString = " and cid=" . $cid;
  6919. //汇款信息需要提取出来
  6920. if(!empty($receiptOrder)){
  6921. $receiptList = $receipt->find ( array (
  6922. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6923. 'desc' => 'rid',
  6924. 'asArray' => true
  6925. ) );
  6926. // 员工筛选
  6927. $receiptList2 = $receipt->find ( array (
  6928. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6929. 'desc' => 'rid',
  6930. 'asArray' => true
  6931. ) );
  6932. }else{
  6933. $receiptList = $receipt->find ( array (
  6934. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6935. 'desc' => 'rid',
  6936. 'asArray' => true
  6937. ) );
  6938. // 员工筛选
  6939. $receiptList2 = $receipt->find ( array (
  6940. 'where' => $statusCon . $condition . $dateCondition,
  6941. 'desc' => 'rid',
  6942. 'asArray' => true
  6943. ) );
  6944. }
  6945. $sopStaff = array ();
  6946. foreach ( $receiptList2 as $key => $value ) {
  6947. $staffDetail = $staff->getOne ( array (
  6948. 'select' => 'username',
  6949. 'where' => 'sid=' . $value ['staff'],
  6950. 'asArray' => true
  6951. ) );
  6952. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6953. }
  6954. // 办事处筛选
  6955. $categoryScreen = array ();
  6956. $categorList = $Lcategory->getCategory ();
  6957. foreach ( $receiptList2 as $key => $value ) {
  6958. foreach ( $categorList as $k => $v ) {
  6959. if ($value ['cid'] == $v ['cid']) {
  6960. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6961. break;
  6962. }
  6963. }
  6964. }
  6965. $categoryScreenHtml = "";
  6966. foreach ( $categoryScreen as $key => $value ) {
  6967. if ($cidKey == $key)
  6968. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6969. else
  6970. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6971. }
  6972. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6973. $data ['cidKey'] = $cidKey;
  6974. $Locate = 0;
  6975. $roleId = 0;
  6976. $button = 0;
  6977. $staffBatchNumber = 100001;
  6978. $remittanceList = array ();
  6979. foreach ( $receiptList as $key => $value ) {
  6980. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6981. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6982. $receiptList [$key] ['Texe'] = 'false';
  6983. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6984. $receiptList [$key] ['Texe'] = 'true';
  6985. }
  6986. $receiptList [$key] ['TRexe'] = 'true';
  6987. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6988. $receiptList [$key] ['TRexe'] = 'false';
  6989. }
  6990. $receiptList [$key] ['Locate'] = $Locate;
  6991. $Locate ++;
  6992. $receiptList [$key] ['reviseDetail'] = array ();
  6993. if (! empty ( $value ['reviseDetail'] ))
  6994. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6995. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6996. $categoryDetil = $Lcategory->getOne ( array (
  6997. 'where' => 'cid=' . $value ['cid'],
  6998. 'asArray' => true
  6999. ) );
  7000. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7001. // 检测编辑状态
  7002. $verifyList = $verify->getOne ( array (
  7003. 'where' => 'vid=' . $value ['verify'],
  7004. 'asArray' => true
  7005. ) );
  7006. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7007. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7008. Doo::loadModel ( 'role' );
  7009. $role = new role ();
  7010. $flag = true;
  7011. $roleKey = 0;
  7012. $endStaffArray = array ();
  7013. $roleArrayCopy = array ();
  7014. foreach ( $verifyList as $k => $v ) {
  7015. // init verifyStaff
  7016. if ($v [1] == 'ROLE') {
  7017. if (! empty ( $verifyStaff )) {
  7018. $endStaffArray = end ( $verifyStaff );
  7019. }
  7020. $roleVerify = json_decode ( $v [3], true );
  7021. $roleKey = $k;
  7022. $roleArray = array ();
  7023. $rolename = $role->getOne ( array (
  7024. 'where' => 'rid=' . $v [0],
  7025. 'asArray' => true
  7026. ) );
  7027. foreach ( $roleVerify as $o => $p ) {
  7028. $staffID = explode ( '_', $p );
  7029. $staffInfo = $staff->getOne ( array (
  7030. 'where' => 'sid=' . $staffID [0],
  7031. 'asArray' => true
  7032. ) );
  7033. $exp = array (
  7034. 0 => $staffInfo ['sid'],
  7035. 1 => $staffID [1],
  7036. 2 => $staffInfo ['avatar'],
  7037. 'date' => '',
  7038. 'date' => '',
  7039. 'opinion' => '',
  7040. 'status' => '',
  7041. 'rolename' => $rolename ['name']
  7042. );
  7043. array_push ( $roleArray, $exp );
  7044. }
  7045. $roleArrayCopy [$v [0]] = $roleArray;
  7046. }
  7047. $verifyList [$k] ['date'] = "";
  7048. $verifyList [$k] ['opinion'] = "";
  7049. $verifyList [$k] ['status'] = "";
  7050. if (empty ( $verifyStaff )) {
  7051. $verifyList [$k] ['date'] = "";
  7052. $verifyList [$k] ['opinion'] = "";
  7053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7054. $verifyList [$k] ['status'] = 4;
  7055. $flag = false;
  7056. }
  7057. } else {
  7058. foreach ( $verifyStaff as $m => $u ) {
  7059. if ($v [0] == $m) {
  7060. $verifyList [$k] ['date'] = $u ['date'];
  7061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7062. $verifyList [$k] ['status'] = $u ['status'];
  7063. $flag = false;
  7064. break;
  7065. }
  7066. }
  7067. $endStaffArray = end ( $verifyStaff );
  7068. }
  7069. }
  7070. $rolename ['name'] = '';
  7071. if (! empty ( $roleId )) {
  7072. Doo::loadModel ( 'role' );
  7073. $role = new role ();
  7074. $rolename = $role->getOne ( array (
  7075. 'where' => 'rid=' . $roleId,
  7076. 'asArray' => true
  7077. ) );
  7078. }
  7079. if (! empty ( $verifyStaff ))
  7080. $endStaffArray = end ( $verifyStaff );
  7081. $KOP = false;
  7082. foreach ( $roleArrayCopy as $P => $A ) {
  7083. foreach ( $A as $MKI => $AVL ) {
  7084. if (! empty ( $verifyStaff )) {
  7085. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7086. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7087. $button = 4;
  7088. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7089. }
  7090. foreach ( $verifyStaff as $m => $u ) {
  7091. $AVLFK = $AVL [0] . '_R';
  7092. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7093. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7094. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7095. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7096. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7097. break;
  7098. }
  7099. }
  7100. } else {
  7101. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7102. $button = 4;
  7103. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7104. }
  7105. }
  7106. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7107. $KOP = true;
  7108. }
  7109. }
  7110. foreach ( $roleArrayCopy as $k => $v ) {
  7111. foreach ( $verifyList as $m => $n ) {
  7112. if ($n [0] == $k) {
  7113. array_splice ( $verifyList, $m, 1, $v );
  7114. }
  7115. }
  7116. }
  7117. $receiptList [$key] ['verifyList'] = $verifyList;
  7118. $staffDetail = $staff->getOne ( array (
  7119. 'where' => 'sid=' . $value ['staff'],
  7120. 'asArray' => true
  7121. ) );
  7122. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7123. $receiptList [$key] ['button'] = $button;
  7124. if ($value['Rtype']==1){
  7125. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7126. $receiptList [$key] ['relustABS'] = sprintf("%.2f",abs($receiptList [$key] ['relust']));
  7127. }elseif($value['Rtype']==3){
  7128. // 收入合计
  7129. Doo::loadModel ( 'invoiceTraining' );
  7130. $invoiceTraining = new invoiceTraining ();
  7131. $invoiceTrainingDetail = array (
  7132. 'invoiceArriveAmount' => '0.00',
  7133. 'RIAmount' => '0.00',
  7134. 'invoiceTotalAmount' => '0.00',
  7135. 'invoiceCompanyAmount' => '0.00',
  7136. 'invoiceArriveAmountM'=>'0.00',
  7137. 'invoiceCompanyAmountM'=>'0.00'
  7138. );
  7139. if ($value ['invoiceTrainId'] != 0) {
  7140. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7141. }
  7142. $invoiceArriveAmount = $RIAmount = 0;
  7143. if (! empty ( $invoiceTrainingDetail )) {
  7144. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7145. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7146. }
  7147. // 备用金
  7148. $sum = 0;
  7149. if (! empty ( $value ['trainLoanRid'] )) {
  7150. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7151. foreach ($receiptLoanList as $kll=>$vll){
  7152. $sum+=$vll['sum'];
  7153. }
  7154. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7155. // $sum = $receiptLoanDetailBak ['sum'];
  7156. }
  7157. // 支出项金额详情
  7158. // 项目金额合计
  7159. Doo::loadModel ( 'RItem' );
  7160. $RItem = new RItem ();
  7161. Doo::loadModel ( 'accountItem' );
  7162. $accountItem = new accountItem ();
  7163. // 讲师获得
  7164. Doo::loadModel ( 'RILecturer' );
  7165. $RILecturer = new RILecturer ();
  7166. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7167. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7168. // 支出项金额详情
  7169. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7170. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7171. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7172. $receiptList [$key] ['payment'] =$payment;
  7173. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7174. }
  7175. // 设置导出汇款execl
  7176. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7177. $remittanceDetail = array (
  7178. $staffBatchNumber,
  7179. $value ['remittanceName'],
  7180. $value ['bankNumber'],
  7181. $value ['bankName'],
  7182. $value ['remittanceBankType'],
  7183. $value ['coupletNumber'],
  7184. $value ['sum']
  7185. );
  7186. array_push ( $remittanceList, $remittanceDetail );
  7187. $staffBatchNumber ++;
  7188. }
  7189. if($value['version']==1){
  7190. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  7191. }
  7192. }
  7193. $data ['remittanceList'] = json_encode ( $remittanceList );
  7194. // print_r($receiptList);
  7195. $mothHtml = "";
  7196. for($i = 1; $i <= 12; $i ++) {
  7197. if ($moth == $i)
  7198. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7199. else
  7200. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7201. }
  7202. $dayHtml = "";
  7203. if ($day != "DAY" || $moth != "MONTH") {
  7204. for($i = 1; $i <= 31; $i ++) {
  7205. if ($day == $i)
  7206. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7207. else
  7208. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7209. }
  7210. }
  7211. $sopHtml = "";
  7212. foreach ( $sopStaff as $key => $value ) {
  7213. if ($sop == $key)
  7214. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7215. else
  7216. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7217. }
  7218. $data ['status'] = $status;
  7219. $data ['rdate'] = $rdate;
  7220. $data ['sopHtml'] = $sopHtml;
  7221. $data ['dayHtml'] = $dayHtml;
  7222. $data ['mothHtml'] = $mothHtml;
  7223. $data ['receiptList'] = $receiptList;
  7224. $data ['memu'] = "receipt";
  7225. $data ['staff'] = $this->staff;
  7226. $data ['receiptMemu'] = 'implement';
  7227. $data ['verifyId'] = $this->verifyId;
  7228. $data ['executeId'] = $this->executeId;
  7229. $data ['item'] = $item;
  7230. $data ['year'] = $year;
  7231. $data ['moth'] = $moth;
  7232. $data['receiptOrder']=$receiptOrder;
  7233. $data ['day'] = $day;
  7234. $data ['sop'] = $sop;
  7235. $this->render ( "/admin/hisImplement", $data );
  7236. }
  7237. /**
  7238. * 导出汇款信息的exelc
  7239. */
  7240. function exportRemittance() {
  7241. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7242. if (empty ( $remittanceInfo ))
  7243. die ( 'illegal request' );
  7244. $title = array (
  7245. '员工编号',
  7246. '姓名',
  7247. '员工账号',
  7248. '员工账户开户行',
  7249. '转账类型',
  7250. '联行号',
  7251. '金额'
  7252. );
  7253. $data = json_decode ( $remittanceInfo, true );
  7254. if (empty ( $data ))
  7255. die ( 'illegal request' );
  7256. Doo::loadClass ( 'receipt.func' );
  7257. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7258. header ( 'Content-Type:text/html;charset=utf-8' );
  7259. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7260. }
  7261. function ajaxExamine() {
  7262. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7263. Doo::loadModel ( 'receipt' );
  7264. $receipt = new receipt ();
  7265. if (! empty ( $rid )) {
  7266. $rLRes = $receipt->find ( array (
  7267. '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,
  7268. 'asArray' => true
  7269. ) );
  7270. if(!empty($rLRes)){
  7271. Doo::loadClass ( 'XDeode' );
  7272. $XDeode = new XDeode ( 7 );
  7273. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7274. echo json_encode ( array (
  7275. 'status' => 1,
  7276. 'receipt' => $rLRes [0]
  7277. ) );
  7278. die ();
  7279. }else{
  7280. echo json_encode ( array (
  7281. 'status' => 1,
  7282. 'receipt' => array ()
  7283. ) );
  7284. die ();
  7285. }
  7286. }
  7287. echo json_encode ( array (
  7288. 'status' => 0,
  7289. 'receipt' => array ()
  7290. ) );
  7291. die ();
  7292. }
  7293. /*
  7294. * 废弃
  7295. */
  7296. function myReceipt() {
  7297. // all approval past withdraw
  7298. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7299. if (empty ( $item ))
  7300. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7301. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7302. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7303. Doo::loadModel ( 'receipt' );
  7304. $receipt = new receipt ();
  7305. // pre-loaded
  7306. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7307. // have cache
  7308. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7309. if (! empty ( $moth )) // yearPage
  7310. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7311. $this->showCache ( $path );
  7312. }
  7313. Doo::loadModel ( 'L_category' );
  7314. $Lcategory = new L_category ();
  7315. Doo::loadModel ( 'verify' );
  7316. Doo::loadModel ( 'statistics' );
  7317. $statistics = new statistics ();
  7318. $verify = new verify ();
  7319. Doo::loadModel ( 'staff' );
  7320. $staff = new staff ();
  7321. $condition = " and status!=0 ";
  7322. if ($item == "approval")
  7323. $condition = " and status=2 ";
  7324. elseif ($item == "withdraw")
  7325. $condition = " and status=3 ";
  7326. elseif ($item == "past")
  7327. $condition = " and status=1 ";
  7328. elseif ($item == "whdw")
  7329. $condition = " and status=4 ";
  7330. $dateCondition = " and Year(date) =" . $year;
  7331. if (! empty ( $moth )) {
  7332. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7333. $stList = $statistics->getOne ( array (
  7334. 'select' => 'rePrice ,agPrice',
  7335. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7336. 'asArray' => true
  7337. ) );
  7338. } else
  7339. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7340. if (empty ( $stList ))
  7341. $stList = array (
  7342. 'rePrice' => 0,
  7343. 'agPrice' => 0
  7344. );
  7345. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7346. $data ['stList'] = array (
  7347. 'rePrice' => $stList ['rePrice'],
  7348. 'agPrice' => $stList ['agPrice'],
  7349. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7350. );
  7351. $receiptList = $receipt->find ( array (
  7352. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7353. 'desc' => 'rid',
  7354. 'asArray' => true
  7355. ) );
  7356. $Locate = 0;
  7357. $roleId = 0;
  7358. $button = 0;
  7359. foreach ( $receiptList as $key => $value ) {
  7360. $receiptList [$key] ['Locate'] = $Locate;
  7361. $Locate ++;
  7362. $receiptList [$key] ['reviseDetail'] = array ();
  7363. if (! empty ( $value ['reviseDetail'] ))
  7364. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7365. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7366. $categoryDetil = $Lcategory->getOne ( array (
  7367. 'where' => 'cid=' . $value ['cid'],
  7368. 'asArray' => true
  7369. ) );
  7370. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7371. // 检测编辑状态
  7372. $verifyList = $verify->getOne ( array (
  7373. 'where' => 'vid=' . $value ['verify'],
  7374. 'asArray' => true
  7375. ) );
  7376. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7377. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7378. Doo::loadModel ( 'role' );
  7379. $role = new role ();
  7380. $flag = true;
  7381. $roleKey = 0;
  7382. $endStaffArray = array ();
  7383. $roleArrayCopy = array ();
  7384. foreach ( $verifyList as $k => $v ) {
  7385. // init verifyStaff
  7386. if ($v [1] == 'ROLE') {
  7387. if (! empty ( $verifyStaff )) {
  7388. $endStaffArray = end ( $verifyStaff );
  7389. // if ($v[0]==$endStaffArray['nextStaff']){
  7390. // $roleId=$v[0];
  7391. // }
  7392. }
  7393. $roleVerify = json_decode ( $v [3], true );
  7394. $roleKey = $k;
  7395. $roleArray = array ();
  7396. $rolename = $role->getOne ( array (
  7397. 'where' => 'rid=' . $v [0],
  7398. 'asArray' => true
  7399. ) );
  7400. foreach ( $roleVerify as $o => $p ) {
  7401. $staffID = explode ( '_', $p );
  7402. $staffInfo = $staff->getOne ( array (
  7403. 'where' => 'sid=' . $staffID [0],
  7404. 'asArray' => true
  7405. ) );
  7406. // print_r($staffID);
  7407. $exp = array (
  7408. 0 => $staffInfo ['sid'],
  7409. 1 => $staffID [1],
  7410. 2 => $staffInfo ['avatar'],
  7411. 'date' => '',
  7412. 'date' => '',
  7413. 'opinion' => '',
  7414. 'status' => '',
  7415. 'rolename' => $rolename ['name']
  7416. );
  7417. array_push ( $roleArray, $exp );
  7418. }
  7419. $roleArrayCopy [$v [0]] = $roleArray;
  7420. // $verifyList[$k]['roleArray']=$roleArray;
  7421. }
  7422. $verifyList [$k] ['date'] = "";
  7423. $verifyList [$k] ['opinion'] = "";
  7424. $verifyList [$k] ['status'] = "";
  7425. if (empty ( $verifyStaff )) {
  7426. $verifyList [$k] ['date'] = "";
  7427. $verifyList [$k] ['opinion'] = "";
  7428. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7429. $verifyList [$k] ['status'] = 4;
  7430. $flag = false;
  7431. }
  7432. } else {
  7433. foreach ( $verifyStaff as $m => $u ) {
  7434. if ($v [0] == $m) {
  7435. $verifyList [$k] ['date'] = $u ['date'];
  7436. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7437. $verifyList [$k] ['status'] = $u ['status'];
  7438. $flag = false;
  7439. break;
  7440. }
  7441. }
  7442. $endStaffArray = end ( $verifyStaff );
  7443. if (isset ( $endStaffArray ['ROLE'] )) {
  7444. } else {
  7445. // $endKey=key($verifyStaff);
  7446. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7447. // $button=4;
  7448. // $verifyList[$k]['status']=4;
  7449. // }
  7450. }
  7451. }
  7452. }
  7453. $rolename ['name'] = '';
  7454. if (! empty ( $roleId )) {
  7455. Doo::loadModel ( 'role' );
  7456. $role = new role ();
  7457. $rolename = $role->getOne ( array (
  7458. 'where' => 'rid=' . $roleId,
  7459. 'asArray' => true
  7460. ) );
  7461. }
  7462. if (! empty ( $verifyStaff ))
  7463. $endStaffArray = end ( $verifyStaff );
  7464. $KOP = false;
  7465. foreach ( $roleArrayCopy as $P => $A ) {
  7466. foreach ( $A as $MKI => $AVL ) {
  7467. if (! empty ( $verifyStaff )) {
  7468. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7469. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7470. $button = 4;
  7471. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7472. }
  7473. foreach ( $verifyStaff as $m => $u ) {
  7474. $AVLFK = $AVL [0] . '_R';
  7475. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7476. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7477. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7478. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7479. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7480. break;
  7481. }
  7482. }
  7483. } else {
  7484. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7485. $button = 4;
  7486. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7487. }
  7488. }
  7489. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7490. $KOP = true;
  7491. }
  7492. }
  7493. foreach ( $roleArrayCopy as $k => $v ) {
  7494. foreach ( $verifyList as $m => $n ) {
  7495. if ($n [0] == $k) {
  7496. array_splice ( $verifyList, $m, 1, $v );
  7497. }
  7498. }
  7499. }
  7500. $receiptList [$key] ['verifyList'] = $verifyList;
  7501. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7502. 'where' => 'sid=' . $value ['staff'],
  7503. 'asArray' => true
  7504. ) );
  7505. $receiptList [$key] ['button'] = $button;
  7506. }
  7507. // print_r($receiptList);die;
  7508. $mothHtml = "";
  7509. for($i = 1; $i <= 12; $i ++) {
  7510. if ($moth == $i)
  7511. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7512. else
  7513. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7514. }
  7515. $data ['mothHtml'] = $mothHtml;
  7516. $data ['receiptList'] = $receiptList;
  7517. $data ['memu'] = "receipt";
  7518. $data ['staff'] = $this->staff;
  7519. $data ['receiptMemu'] = 'receipt';
  7520. $data ['verifyId'] = $this->verifyId;
  7521. $data ['executeId'] = $this->executeId;
  7522. $data ['item'] = $item;
  7523. $data ['year'] = $year;
  7524. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7525. // sufficient condition to generate cache
  7526. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7527. $receiptList = $receipt->find ( array (
  7528. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7529. 'asArray' => true
  7530. ) );
  7531. if (empty ( $receiptList )) { // generated files
  7532. ob_start ();
  7533. $this->render ( "/admin/saea_myList", $data );
  7534. $this->cacheFile ( $path );
  7535. die ();
  7536. // $content = ob_get_contents();
  7537. // $fp = fopen($path, "w");
  7538. // fwrite($fp, $content);
  7539. // fclose($fp);
  7540. }
  7541. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7542. $receiptList = $receipt->find ( array (
  7543. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7544. 'asArray' => true
  7545. ) );
  7546. if (empty ( $receiptList )) { // generated files
  7547. ob_start ();
  7548. $this->render ( "/admin/saea_myList", $data );
  7549. $this->cacheFile ( $path );
  7550. die ();
  7551. }
  7552. }
  7553. }
  7554. $this->render ( "/admin/saea_myList", $data );
  7555. }
  7556. function approvedReceipt() {
  7557. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7558. Doo::loadModel ( 'receipt' );
  7559. Doo::loadModel ( 'receiptDetail' );
  7560. $receipt = new receipt ();
  7561. $receiptDetail = new receiptDetail ();
  7562. Doo::loadModel ( 'statistics' );
  7563. Doo::loadModel ( 'itemStatistics' );
  7564. $statistics = new statistics ();
  7565. $itemStatistics = new itemStatistics ();
  7566. Doo::loadModel ( "verify" );
  7567. $verify = new verify ();
  7568. // 审批状态的判定
  7569. $receiptDetailList = $receipt->getOne ( array (
  7570. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7571. 'asArray' => true
  7572. ) );
  7573. if (empty ( $receiptDetailList )){
  7574. return "/saeaBorad";
  7575. }
  7576. // 如果是新报销单,有差旅的情况下写入日期
  7577. if($receiptDetailList['version']==1){
  7578. if(!empty($receiptDetailList['traveJson'])){
  7579. $traveJson=json_decode($receiptDetailList['traveJson'],true)['traveList'];
  7580. foreach ($traveJson as $key=>$value){
  7581. Doo::loadModel ( 'cld/traveDate_cld' );
  7582. $traveDate = new traveDate_cld ();
  7583. $traveDate->sid=$this->staff [0] ['sid'];
  7584. $traveDate->rid=$receiptDetailList['rid'];
  7585. $tripTime = explode(" - ", $value['tripTime']);
  7586. $traveDate->start=$tripTime[0];
  7587. $traveDate->end=$tripTime[1];
  7588. $traveDate->insert ();
  7589. }
  7590. }
  7591. }
  7592. $verifyDetail = $verify->getOne ( array (
  7593. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7594. 'asArray' => true
  7595. ) );
  7596. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7597. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7598. $nowStaff = "";
  7599. $nowStaffList = array ();
  7600. if ($verifyDetail [0] [1] == 'ROLE') {
  7601. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7602. foreach ( $vStaffString as $key => $value ) {
  7603. $staffK = explode ( "_", $value );
  7604. array_push ( $nowStaffList, $staffK [0] );
  7605. }
  7606. $nowStaff = implode ( ',', $nowStaffList );
  7607. } else {
  7608. $nowStaff = $verifyDetail [0] [0];
  7609. }
  7610. $receipt->nowStaff = $nowStaff;
  7611. }
  7612. // echo $nowStaff;
  7613. // print_r($verifyDetail);die;
  7614. $receipt->rid = $receiptDetailList ['rid'];
  7615. $receipt->date = date ( "Y-m-d" );
  7616. $receipt->status = 2;
  7617. $receipt->update ();
  7618. $receiptDetail->status = 2;
  7619. $receiptDetail->update ( array (
  7620. 'where' => 'rid=' . $receiptDetailList ['rid']
  7621. ) );
  7622. Doo::loadModel ( "receiptLog" );
  7623. $receiptLog = new receiptLog ();
  7624. Doo::loadModel ( "verify" );
  7625. $verify = new verify ();
  7626. $receiptInfo = $receipt->getOne ( array (
  7627. 'where' => 'rid=' . $rid,
  7628. 'asArray' => true
  7629. ) );
  7630. $vr = $verify->getOne ( array (
  7631. 'where' => 'vid=' . $receiptInfo ['verify'],
  7632. 'asArray' => true
  7633. ) );
  7634. $jd = json_decode ( $vr ['staff'] );
  7635. $roleId = 0;
  7636. foreach ( $jd as $key => $value ) {
  7637. if ($value [1] == 'ROLE') {
  7638. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7639. if ($pos !== false) {
  7640. $roleId = $value [0];
  7641. }
  7642. }
  7643. }
  7644. // 审批日志
  7645. // echo $roleId;die;
  7646. if (! empty ( $roleId )) {
  7647. Doo::loadModel ( "role" );
  7648. $role = new role ();
  7649. $roleInfo = $role->getOne ( array (
  7650. 'where' => 'rid=' . $roleId,
  7651. 'asArray' => true
  7652. ) );
  7653. // $receiptLog->rolename = $roleInfo ['name'];
  7654. }
  7655. $receiptLog->username = $this->staff [0] ['username'];
  7656. $receiptLog->uid = $this->staff [0] ['sid'];
  7657. $receiptLog->date = date ( "Y-m-d" );
  7658. $receiptLog->opinion = '提交审批';
  7659. $receiptLog->img = $this->staff [0] ['avatar'];
  7660. $receiptLog->status = 2;
  7661. $receiptLog->rid = $rid;
  7662. $receiptLog->insert ();
  7663. // statistics item
  7664. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7665. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7666. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7667. $stat = $statistics->getOne ( array (
  7668. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7669. 'asArray' => true
  7670. ) );
  7671. if (empty ( $stat )) {
  7672. $statistics->date = date ( "Y-m-d" );
  7673. $statistics->cid = $this->staff [0] ['cid'];
  7674. $statistics->staff = $this->staff [0] ['sid'];
  7675. $statistics->agPrice = 0;
  7676. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7677. $statistics->insert ();
  7678. } else {
  7679. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7680. $statistics->update ( array (
  7681. 'where' => 'sid=' . $stat ['sid']
  7682. ) );
  7683. }
  7684. return "/expenses";
  7685. }
  7686. function approval() {
  7687. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7688. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7689. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7690. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7691. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7692. if (empty ( $status ))
  7693. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7694. $vidList = array ();
  7695. $button = 0;
  7696. Doo::loadModel ( 'verify' );
  7697. $verify = new verify ();
  7698. Doo::loadModel ( 'receipt' );
  7699. $receipt = new receipt ();
  7700. Doo::loadModel ( 'staff' );
  7701. $staff = new staff ();
  7702. Doo::loadModel ( 'L_category' );
  7703. $Lcategory = new L_category ();
  7704. // user verify ID
  7705. $verifyDetail = $verify->find ( array (
  7706. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7707. 'asArray' => true
  7708. ) );
  7709. foreach ( $verifyDetail as $key => $value ) {
  7710. array_push ( $vidList, $value ['vid'] );
  7711. }
  7712. $vid = implode ( ",", $vidList );
  7713. if (empty ( $verifyDetail ))
  7714. $vid = 0;
  7715. /*
  7716. */
  7717. $dateCondition = " and Year(date) =" . $year;
  7718. if (! empty ( $month ))
  7719. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7720. $categoryList = $Lcategory->find ( array (
  7721. 'asArray' => true
  7722. ) );
  7723. $staffList = $staff->find ( array (
  7724. 'where' => 'cid=' . $cid,
  7725. 'asArray' => true
  7726. ) );
  7727. $cateCondition = "";
  7728. $staffCondition = "";
  7729. $approvalCondition = "";
  7730. if (! empty ( $cid ))
  7731. $cateCondition = ' and cid=' . $cid;
  7732. if (! empty ( $sid )) {
  7733. $staffCondition = ' and staff=' . $sid;
  7734. $cateCondition = "";
  7735. }
  7736. // elseif($status==1){
  7737. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7738. // }
  7739. if ($status == 2) {
  7740. // 查找角色审批人
  7741. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7742. }
  7743. $ap = "";
  7744. if ($status == 4) {
  7745. $ap = 4;
  7746. $status = 2;
  7747. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7748. }
  7749. if ($status == 5) {
  7750. $status = 4;
  7751. $ap = 5;
  7752. }
  7753. // echo $vid;
  7754. // get Receipt By verifyID status 2 .$approvalCondition
  7755. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7756. $receiptList = $receipt->find ( array (
  7757. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7758. 'desc' => 'rid',
  7759. 'asArray' => true
  7760. ) );
  7761. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7762. $Locate = 0;
  7763. if ($ap == 4)
  7764. $status = 4;
  7765. elseif ($ap == 5)
  7766. $status = 5;
  7767. foreach ( $receiptList as $key => $value ) {
  7768. $receiptList [$key] ['Locate'] = $Locate;
  7769. $Locate ++;
  7770. $receiptList [$key] ['reviseDetail'] = array ();
  7771. if (! empty ( $value ['reviseDetail'] ))
  7772. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7773. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7774. $categoryDetil = $Lcategory->getOne ( array (
  7775. 'where' => 'cid=' . $value ['cid'],
  7776. 'asArray' => true
  7777. ) );
  7778. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7779. $verifyList = $verify->getOne ( array (
  7780. 'where' => 'vid=' . $value ['verify'],
  7781. 'asArray' => true
  7782. ) );
  7783. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7784. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7785. foreach ( $verifyList as $k => $v ) {
  7786. // init verifyStaff
  7787. $verifyList [$k] ['date'] = "";
  7788. $verifyList [$k] ['opinion'] = "";
  7789. $verifyList [$k] ['status'] = "";
  7790. if (empty ( $verifyStaff )) {
  7791. $verifyList [$k] ['date'] = "";
  7792. $verifyList [$k] ['opinion'] = "";
  7793. if ($v [0] == $this->staff [0] ['sid']) {
  7794. $verifyList [$k] ['status'] = 4;
  7795. $button = 4;
  7796. }
  7797. } else {
  7798. $flag = true;
  7799. foreach ( $verifyStaff as $m => $u ) {
  7800. if ($v [0] == $m) {
  7801. $verifyList [$k] ['date'] = $u ['date'];
  7802. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7803. $verifyList [$k] ['status'] = $u ['status'];
  7804. $flag = false;
  7805. break;
  7806. }
  7807. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7808. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7809. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7810. }
  7811. if ($flag) { // 检测可编辑
  7812. if ($v [0] == $this->staff [0] ['sid']) {
  7813. $verifyList [$k] ['status'] = 4;
  7814. $button = 4;
  7815. }
  7816. }
  7817. }
  7818. }
  7819. $receiptList [$key] ['verifyList'] = $verifyList;
  7820. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7821. 'where' => 'sid=' . $value ['staff'],
  7822. 'asArray' => true
  7823. ) );
  7824. $receiptList [$key] ['button'] = $button;
  7825. }
  7826. // print_r($receiptList);die;
  7827. // $data['verifyDetail']=$verifyDetail;
  7828. $mothHtml = "";
  7829. for($i = 1; $i <= 12; $i ++) {
  7830. if ($month == $i)
  7831. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7832. else
  7833. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7834. }
  7835. $data ['mothHtml'] = $mothHtml;
  7836. $data ['receiptList'] = $receiptList;
  7837. $data ['receiptApprovalCount'] = count ( $receiptList );
  7838. $data ['status'] = $status;
  7839. $data ['year'] = $year;
  7840. $data ['categoryList'] = $categoryList;
  7841. $data ['staffList'] = $staffList;
  7842. $data ['cid'] = $cid;
  7843. $data ['sid'] = $sid;
  7844. $data ['ap'] = $ap;
  7845. $data ['memu'] = "receipt";
  7846. $data ['staff'] = $this->staff;
  7847. $data ['receiptMemu'] = 'approval';
  7848. $data ['verifyId'] = $this->verifyId;
  7849. $data ['executeId'] = $this->executeId;
  7850. $this->render ( "/admin/saea_reportList", $data );
  7851. }
  7852. function approvalDetails() {
  7853. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7854. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7855. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7856. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7857. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7858. Doo::loadModel ( 'verify' );
  7859. $verify = new verify ();
  7860. Doo::loadModel ( 'receipt' );
  7861. $receipt = new receipt ();
  7862. Doo::loadModel ( 'staff' );
  7863. $staff = new staff ();
  7864. Doo::loadModel ( 'L_category' );
  7865. $Lcategory = new L_category ();
  7866. Doo::loadModel ( 'enclosur' );
  7867. $enclosur = new enclosur ();
  7868. $vidList = array ();
  7869. $verifyDetail = $verify->find ( array (
  7870. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7871. 'asArray' => true
  7872. ) );
  7873. foreach ( $verifyDetail as $key => $value ) {
  7874. array_push ( $vidList, $value ['vid'] );
  7875. }
  7876. $vid = implode ( ",", $vidList );
  7877. if (empty ( $verifyDetail ))
  7878. $vid = 0;
  7879. $categoryList = $Lcategory->find ( array (
  7880. 'asArray' => true
  7881. ) );
  7882. $staffList = $staff->find ( array (
  7883. 'where' => 'cid=' . $cid,
  7884. 'asArray' => true
  7885. ) );
  7886. $ap = 0;
  7887. $receiptList = $receipt->find ( array (
  7888. 'where' => 'rid =' . $rid,
  7889. 'desc' => 'rid',
  7890. 'asArray' => true
  7891. ) );
  7892. $Locate = 0;
  7893. $roleId = 0;
  7894. $button = 0;
  7895. foreach ( $receiptList as $key => $value ) {
  7896. $receiptList [$key] ['Locate'] = $Locate;
  7897. $Locate ++;
  7898. $receiptList [$key] ['reviseDetail'] = array ();
  7899. if (! empty ( $value ['reviseDetail'] ))
  7900. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7901. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7902. $categoryDetil = $Lcategory->getOne ( array (
  7903. 'where' => 'cid=' . $value ['cid'],
  7904. 'asArray' => true
  7905. ) );
  7906. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7907. // 检测编辑状态
  7908. $verifyList = $verify->getOne ( array (
  7909. 'where' => 'vid=' . $value ['verify'],
  7910. 'asArray' => true
  7911. ) );
  7912. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7913. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7914. Doo::loadModel ( 'role' );
  7915. $role = new role ();
  7916. // print_r($verifyList);
  7917. $flag = true;
  7918. $roleKey = 0;
  7919. $endStaffArray = array ();
  7920. $roleArrayCopy = array ();
  7921. foreach ( $verifyList as $k => $v ) {
  7922. // init verifyStaff
  7923. if ($v [1] == 'ROLE') {
  7924. if (! empty ( $verifyStaff )) {
  7925. $endStaffArray = end ( $verifyStaff );
  7926. if ($v [0] == $endStaffArray ['nextStaff']) {
  7927. $roleId = $v [0];
  7928. }
  7929. }
  7930. $roleVerify = json_decode ( $v [3], true );
  7931. $roleKey = $k;
  7932. $roleArray = array ();
  7933. $rolename = $role->getOne ( array (
  7934. 'where' => 'rid=' . $v [0],
  7935. 'asArray' => true
  7936. ) );
  7937. foreach ( $roleVerify as $o => $p ) {
  7938. $staffID = explode ( '_', $p );
  7939. $staffInfo = $staff->getOne ( array (
  7940. 'where' => 'sid=' . $staffID [0],
  7941. 'asArray' => true
  7942. ) );
  7943. // print_r($staffID);
  7944. $exp = array (
  7945. 0 => $staffInfo ['sid'],
  7946. 1 => $staffID [1],
  7947. 2 => $staffInfo ['avatar'],
  7948. 'date' => '',
  7949. 'date' => '',
  7950. 'opinion' => '',
  7951. 'status' => '',
  7952. 'rolename' => $rolename ['name']
  7953. );
  7954. array_push ( $roleArray, $exp );
  7955. }
  7956. $roleArrayCopy [$v [0]] = $roleArray;
  7957. // $verifyList[$k]['roleArray']=$roleArray;
  7958. }
  7959. // print_r($roleArray);
  7960. $verifyList [$k] ['date'] = "";
  7961. $verifyList [$k] ['opinion'] = "";
  7962. $verifyList [$k] ['status'] = "";
  7963. if (empty ( $verifyStaff )) {
  7964. $verifyList [$k] ['date'] = "";
  7965. $verifyList [$k] ['opinion'] = "";
  7966. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7967. $verifyList [$k] ['status'] = 4;
  7968. $button = 4;
  7969. $flag = false;
  7970. }
  7971. } else {
  7972. foreach ( $verifyStaff as $m => $u ) {
  7973. if ($v [0] == $m) {
  7974. $verifyList [$k] ['date'] = $u ['date'];
  7975. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7976. $verifyList [$k] ['status'] = $u ['status'];
  7977. $flag = false;
  7978. break;
  7979. }
  7980. }
  7981. $endStaffArray = end ( $verifyStaff );
  7982. if (isset ( $endStaffArray ['ROLE'] )) {
  7983. } else {
  7984. $endKey = key ( $verifyStaff );
  7985. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7986. $button = 4;
  7987. $verifyList [$k] ['status'] = 4;
  7988. }
  7989. }
  7990. }
  7991. }
  7992. $rolename ['name'] = '';
  7993. if (! empty ( $roleId )) {
  7994. Doo::loadModel ( 'role' );
  7995. $role = new role ();
  7996. $rolename = $role->getOne ( array (
  7997. 'where' => 'rid=' . $roleId,
  7998. 'asArray' => true
  7999. ) );
  8000. }
  8001. if (! empty ( $verifyStaff ))
  8002. $endStaffArray = end ( $verifyStaff );
  8003. $KOP = false;
  8004. foreach ( $roleArrayCopy as $P => $A ) {
  8005. foreach ( $A as $MKI => $AVL ) {
  8006. if (! empty ( $verifyStaff )) {
  8007. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8008. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8009. $button = 4;
  8010. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8011. }
  8012. foreach ( $verifyStaff as $m => $u ) {
  8013. $AVLFK = $AVL [0] . '_R';
  8014. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8015. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8016. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8017. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8018. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8019. break;
  8020. }
  8021. }
  8022. } else {
  8023. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8024. $button = 4;
  8025. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8026. }
  8027. }
  8028. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8029. $KOP = true;
  8030. }
  8031. }
  8032. foreach ( $roleArrayCopy as $k => $v ) {
  8033. foreach ( $verifyList as $m => $n ) {
  8034. if ($n [0] == $k) {
  8035. array_splice ( $verifyList, $m, 1, $v );
  8036. }
  8037. }
  8038. }
  8039. $receiptList [$key] ['verifyList'] = $verifyList;
  8040. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8041. 'where' => 'sid=' . $value ['staff'],
  8042. 'asArray' => true
  8043. ) );
  8044. $receiptList [$key] ['button'] = $button;
  8045. }
  8046. $mothHtml = "";
  8047. for($i = 1; $i <= 12; $i ++) {
  8048. if ($month == $i)
  8049. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8050. else
  8051. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8052. }
  8053. // 获取审批日志
  8054. Doo::loadModel ( 'receiptLog' );
  8055. $receiptLog = new receiptLog ();
  8056. $rlList = array ();
  8057. $rlInfo = $receiptLog->getOne ( array (
  8058. 'where' => 'rid=' . $rid . ' and status=4',
  8059. 'asArray' => true
  8060. ) );
  8061. $tijdate = $receiptLog->getOne ( array (
  8062. 'where' => 'rid=' . $rid . ' and status=2',
  8063. 'asc' => 'rlid',
  8064. 'asArray' => true
  8065. ) );
  8066. if (! empty ( $rlInfo )) {
  8067. $rlList = $receiptLog->find ( array (
  8068. 'where' => 'rid=' . $rid,
  8069. 'asc' => 'rlid',
  8070. 'asArray' => true
  8071. ) );
  8072. }
  8073. $receiptList [0] ['rlList'] = $rlList;
  8074. $enclosurList = $enclosur->find ( array (
  8075. 'where' => 'rid=' . $rid,
  8076. 'asArray' => true
  8077. ) );
  8078. $enclosurHtml = '';
  8079. foreach ( $enclosurList as $value ) {
  8080. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8081. }
  8082. $data ['enclosurHtml'] = $enclosurHtml;
  8083. $data ['rolename'] = $rolename ['name'];
  8084. $data ['datetij'] = $tijdate ['date'];
  8085. $data ['mothHtml'] = $mothHtml;
  8086. $data ['receiptList'] = $receiptList;
  8087. $data ['receiptApprovalCount'] = count ( $receiptList );
  8088. $data ['year'] = $year;
  8089. $data ['categoryList'] = $categoryList;
  8090. $data ['staffList'] = $staffList;
  8091. $data ['cid'] = $cid;
  8092. $data ['sid'] = $sid;
  8093. $data ['status'] = 0;
  8094. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8095. $ap = 4;
  8096. } else
  8097. $data ['status'] = $receiptList [0] ['status'];
  8098. if ($receiptList [0] ['status'] == 4) {
  8099. $data ['status'] = 5;
  8100. $ap = 0;
  8101. }
  8102. $data ['ap'] = $ap;
  8103. $data ['memu'] = "receipt";
  8104. $data ['staff'] = $this->staff;
  8105. $data ['receiptMemu'] = 'approval';
  8106. $data ['verifyId'] = $this->verifyId;
  8107. $data ['executeId'] = $this->executeId;
  8108. $this->render ( "/admin/saeaReportListReport", $data );
  8109. }
  8110. function approvalEdi() {
  8111. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8112. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8113. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8114. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8115. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8116. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8117. if (empty ( $status ))
  8118. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8119. $vidList = array ();
  8120. $button = 0;
  8121. Doo::loadModel ( 'verify' );
  8122. Doo::loadModel ( 'receipt' );
  8123. Doo::loadModel ( 'staff' );
  8124. $staff = new staff ();
  8125. $receipt = new receipt ();
  8126. $verify = new verify ();
  8127. Doo::loadModel ( 'L_category' );
  8128. $Lcategory = new L_category ();
  8129. Doo::loadModel ( 'enclosur' );
  8130. $enclosur = new enclosur ();
  8131. // user verify ID
  8132. $verifyDetail = $verify->find ( array (
  8133. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8134. 'asArray' => true
  8135. ) );
  8136. foreach ( $verifyDetail as $key => $value ) {
  8137. array_push ( $vidList, $value ['vid'] );
  8138. }
  8139. $vid = implode ( ",", $vidList );
  8140. if (empty ( $verifyDetail ))
  8141. $vid = 0;
  8142. $categoryList = $Lcategory->find ( array (
  8143. 'asArray' => true
  8144. ) );
  8145. $staffList = $staff->find ( array (
  8146. 'where' => 'cid=' . $cid,
  8147. 'asArray' => true
  8148. ) );
  8149. $ap = "";
  8150. if ($status == 4) {
  8151. $ap = 4;
  8152. $status = 2;
  8153. }
  8154. // get Receipt By verifyID status 2
  8155. $receiptList = $receipt->find ( array (
  8156. 'where' => 'rid =' . $rid,
  8157. 'desc' => 'rid',
  8158. 'asArray' => true
  8159. ) );
  8160. $Locate = 0;
  8161. $roleId = 0;
  8162. if ($ap == 4)
  8163. $status = 4;
  8164. foreach ( $receiptList as $key => $value ) {
  8165. $receiptList [$key] ['Locate'] = $Locate;
  8166. $Locate ++;
  8167. $receiptList [$key] ['reviseDetail'] = array ();
  8168. if (! empty ( $value ['reviseDetail'] ))
  8169. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8170. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8171. $categoryDetil = $Lcategory->getOne ( array (
  8172. 'where' => 'cid=' . $value ['cid'],
  8173. 'asArray' => true
  8174. ) );
  8175. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8176. // 检测编辑状态
  8177. $verifyList = $verify->getOne ( array (
  8178. 'where' => 'vid=' . $value ['verify'],
  8179. 'asArray' => true
  8180. ) );
  8181. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8182. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8183. // print_r($verifyList);
  8184. //
  8185. // if (empty($verifyStaff)){
  8186. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8187. // $verifyList[0]['status']=4;$button=4;
  8188. // }
  8189. //
  8190. // }else{
  8191. //
  8192. // }
  8193. // die;
  8194. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8195. // echo array_search("green",$a);
  8196. //
  8197. Doo::loadModel ( 'role' );
  8198. $role = new role ();
  8199. // print_r($verifyList);
  8200. $flag = true;
  8201. $roleKey = 0;
  8202. $endStaffArray = array ();
  8203. $roleArrayCopy = array ();
  8204. foreach ( $verifyList as $k => $v ) {
  8205. // init verifyStaff
  8206. if ($v [1] == 'ROLE') {
  8207. if (! empty ( $verifyStaff )) {
  8208. $endStaffArray = end ( $verifyStaff );
  8209. if ($v [0] == $endStaffArray ['nextStaff']) {
  8210. $roleId = $v [0];
  8211. }
  8212. }
  8213. $roleVerify = json_decode ( $v [3], true );
  8214. $roleKey = $k;
  8215. $roleArray = array ();
  8216. $rolename = $role->getOne ( array (
  8217. 'where' => 'rid=' . $v [0],
  8218. 'asArray' => true
  8219. ) );
  8220. foreach ( $roleVerify as $o => $p ) {
  8221. $staffID = explode ( '_', $p );
  8222. $staffInfo = $staff->getOne ( array (
  8223. 'where' => 'sid=' . $staffID [0],
  8224. 'asArray' => true
  8225. ) );
  8226. // print_r($staffID);
  8227. $exp = array (
  8228. 0 => $staffInfo ['sid'],
  8229. 1 => $staffID [1],
  8230. 2 => $staffInfo ['avatar'],
  8231. 'date' => '',
  8232. 'date' => '',
  8233. 'opinion' => '',
  8234. 'status' => '',
  8235. 'rolename' => $rolename ['name']
  8236. );
  8237. array_push ( $roleArray, $exp );
  8238. }
  8239. $roleArrayCopy [$v [0]] = $roleArray;
  8240. // $verifyList[$k]['roleArray']=$roleArray;
  8241. }
  8242. // print_r($roleArray);
  8243. $verifyList [$k] ['date'] = "";
  8244. $verifyList [$k] ['opinion'] = "";
  8245. $verifyList [$k] ['status'] = "";
  8246. if (empty ( $verifyStaff )) {
  8247. $verifyList [$k] ['date'] = "";
  8248. $verifyList [$k] ['opinion'] = "";
  8249. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8250. $verifyList [$k] ['status'] = 4;
  8251. $button = 4;
  8252. $flag = false;
  8253. }
  8254. } else {
  8255. foreach ( $verifyStaff as $m => $u ) {
  8256. if ($v [0] == $m) {
  8257. $verifyList [$k] ['date'] = $u ['date'];
  8258. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8259. $verifyList [$k] ['status'] = $u ['status'];
  8260. $flag = false;
  8261. break;
  8262. }
  8263. }
  8264. $endStaffArray = end ( $verifyStaff );
  8265. if (isset ( $endStaffArray ['ROLE'] )) {
  8266. } else {
  8267. $endKey = key ( $verifyStaff );
  8268. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8269. $button = 4;
  8270. $verifyList [$k] ['status'] = 4;
  8271. }
  8272. }
  8273. // print_r($endStaffArray);die;
  8274. // if (empty($verifyStaff)){
  8275. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8276. // $verifyList[$k]['status']=4;$button=4;
  8277. // }
  8278. //
  8279. // }else{
  8280. //
  8281. // }
  8282. // if($flag){//检测可编辑
  8283. // if($v[0]==$this->staff[0]['sid']){
  8284. // $verifyList[$k]['status']=4;$button=4;
  8285. // }
  8286. // }
  8287. }
  8288. }
  8289. $rolename ['name'] = '';
  8290. if (! empty ( $roleId )) {
  8291. Doo::loadModel ( 'role' );
  8292. $role = new role ();
  8293. $rolename = $role->getOne ( array (
  8294. 'where' => 'rid=' . $roleId,
  8295. 'asArray' => true
  8296. ) );
  8297. }
  8298. if (! empty ( $verifyStaff ))
  8299. $endStaffArray = end ( $verifyStaff );
  8300. $KOP = false;
  8301. foreach ( $roleArrayCopy as $P => $A ) {
  8302. foreach ( $A as $MKI => $AVL ) {
  8303. if (! empty ( $verifyStaff )) {
  8304. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8305. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8306. $button = 4;
  8307. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8308. }
  8309. foreach ( $verifyStaff as $m => $u ) {
  8310. $AVLFK = $AVL [0] . '_R';
  8311. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8312. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8313. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8314. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8315. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8316. break;
  8317. }
  8318. }
  8319. } else {
  8320. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8321. $button = 4;
  8322. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8323. }
  8324. }
  8325. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8326. $KOP = true;
  8327. }
  8328. }
  8329. // print_r($roleArrayCopy);
  8330. // echo $roleKey;
  8331. foreach ( $roleArrayCopy as $k => $v ) {
  8332. foreach ( $verifyList as $m => $n ) {
  8333. if ($n [0] == $k) {
  8334. array_splice ( $verifyList, $m, 1, $v );
  8335. }
  8336. }
  8337. }
  8338. // if ($KOP)
  8339. // array_splice($verifyList,$roleKey,1,$roleArray);
  8340. // print_r($verifyList);
  8341. $receiptList [$key] ['verifyList'] = $verifyList;
  8342. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8343. 'where' => 'sid=' . $value ['staff'],
  8344. 'asArray' => true
  8345. ) );
  8346. $receiptList [$key] ['button'] = $button;
  8347. }
  8348. // $data['verifyDetail']=$verifyDetail;
  8349. $mothHtml = "";
  8350. for($i = 1; $i <= 12; $i ++) {
  8351. if ($month == $i)
  8352. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8353. else
  8354. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8355. }
  8356. // 获取审批日志
  8357. Doo::loadModel ( 'receiptLog' );
  8358. $receiptLog = new receiptLog ();
  8359. $rlList = array ();
  8360. $rlInfo = $receiptLog->getOne ( array (
  8361. 'where' => 'rid=' . $rid . ' and status=4',
  8362. 'asArray' => true
  8363. ) );
  8364. $tijdate = $receiptLog->getOne ( array (
  8365. 'where' => 'rid=' . $rid . ' and status=2',
  8366. 'asc' => 'rlid',
  8367. 'asArray' => true
  8368. ) );
  8369. if (! empty ( $rlInfo )) {
  8370. $rlList = $receiptLog->find ( array (
  8371. 'where' => 'rid=' . $rid,
  8372. 'asc' => 'rlid',
  8373. 'asArray' => true
  8374. ) );
  8375. }
  8376. $receiptList [0] ['rlList'] = $rlList;
  8377. $enclosurList = $enclosur->find ( array (
  8378. 'where' => 'rid=' . $rid,
  8379. 'asArray' => true
  8380. ) );
  8381. $enclosurHtml = '';
  8382. foreach ( $enclosurList as $value ) {
  8383. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8384. }
  8385. $data ['enclosurHtml'] = $enclosurHtml;
  8386. $data ['rolename'] = $rolename ['name'];
  8387. $data ['datetij'] = $tijdate ['date'];
  8388. $data ['mothHtml'] = $mothHtml;
  8389. $data ['receiptList'] = $receiptList;
  8390. $data ['receiptApprovalCount'] = count ( $receiptList );
  8391. $data ['status'] = $status;
  8392. $data ['year'] = $year;
  8393. $data ['categoryList'] = $categoryList;
  8394. $data ['staffList'] = $staffList;
  8395. $data ['cid'] = $cid;
  8396. $data ['sid'] = $sid;
  8397. $data ['ap'] = $ap;
  8398. $data ['memu'] = "receipt";
  8399. $data ['staff'] = $this->staff;
  8400. $data ['receiptMemu'] = 'approval';
  8401. $data ['verifyId'] = $this->verifyId;
  8402. $data ['executeId'] = $this->executeId;
  8403. $this->render ( "/admin/saeaReportListReport", $data );
  8404. }
  8405. function remittanceHky() {
  8406. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8407. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8408. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8409. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8410. $page_size = 15;
  8411. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8412. Doo::loadModel ( 'receipt' );
  8413. $receipt = new receipt ();
  8414. Doo::loadModel ( 'staff' );
  8415. $staff = new staff ();
  8416. $dateCondition = " and Year(executeDate) =" . $year;
  8417. if ($moth != 'MONTH')
  8418. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8419. if ($day != 'DAY' && $moth != 'MONTH')
  8420. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8421. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8422. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8423. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8424. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8425. $dayList = $receipt->find ( array (
  8426. 'select' => 'executeDate,sum(amount) as amount',
  8427. 'where' => $sql,
  8428. 'desc' => 'executeDate',
  8429. 'groupby' => 'executeDate',
  8430. 'limit' => $limit,
  8431. 'asArray' => true
  8432. ) );
  8433. // print_r($dayList);
  8434. foreach ( $dayList as $key => $value ) {
  8435. $remitString = "";
  8436. $receiptList = $receipt->find ( array (
  8437. 'select' => 'rid,executeDate,amount,staff,cid',
  8438. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8439. 'desc' => 'executeDate',
  8440. 'asArray' => true
  8441. ) );
  8442. foreach ( $receiptList as $k => $v ) {
  8443. $sinfo = $staff->getOne ( array (
  8444. 'select' => 'username,category',
  8445. 'where' => ' sid=' . $v ['staff'],
  8446. 'asArray' => true
  8447. ) );
  8448. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8449. }
  8450. $dayList [$key] ['staff'] = $remitString;
  8451. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8452. }
  8453. // print_r($dayList);
  8454. $mothHtml = "";
  8455. for($i = 1; $i <= 12; $i ++) {
  8456. if ($moth == $i)
  8457. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8458. else
  8459. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8460. }
  8461. $dayHtml = "";
  8462. if ($day != "DAY" || $moth != "MONTH") {
  8463. for($i = 1; $i <= 31; $i ++) {
  8464. if ($day == $i)
  8465. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8466. else
  8467. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8468. }
  8469. }
  8470. $dateHtml = "";
  8471. $now = date ( "Y" );
  8472. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8473. if ($YEARD <= $now) {
  8474. $dateHtml .= '<option ';
  8475. if ($year == $YEARD) {
  8476. $dateHtml .= 'selected ';
  8477. }
  8478. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8479. }
  8480. }
  8481. $data ['dateHtml'] = $dateHtml;
  8482. $data ['page'] = $pageinfo;
  8483. $data ['year'] = $year;
  8484. $data ['moth'] = $moth;
  8485. $data ['day'] = $day;
  8486. $data ['get'] = $get;
  8487. $data ['dayHtml'] = $dayHtml;
  8488. $data ['mothHtml'] = $mothHtml;
  8489. $data ['receiptList'] = $dayList;
  8490. $data ['memu'] = "receipt";
  8491. $data ['staff'] = $this->staff;
  8492. $data ['receiptMemu'] = 'remittanceHky';
  8493. $data ['verifyId'] = $this->verifyId;
  8494. $data ['executeId'] = $this->executeId;
  8495. $this->render ( "/admin/remittanceHky", $data );
  8496. }
  8497. function remittancep() {
  8498. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8499. Doo::loadModel ( 'receipt' );
  8500. $receipt = new receipt ();
  8501. Doo::loadModel ( 'staff' );
  8502. $staff = new staff ();
  8503. Doo::loadClass ( 'XDeode' );
  8504. $XDeode = new XDeode ( 5 );
  8505. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8506. $rplist = $receipt->find ( array (
  8507. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8508. 'asArray' => true
  8509. ) );
  8510. $dayList = $receipt->find ( array (
  8511. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8512. 'desc' => 'executeDate',
  8513. 'groupby' => 'staff',
  8514. 'asArray' => true
  8515. ) );
  8516. $html = '';
  8517. foreach ( $dayList as $key => $value ) {
  8518. $sinfo = $staff->getOne ( array (
  8519. 'select' => 'username,category',
  8520. 'where' => ' sid=' . $value ['staff'],
  8521. 'asArray' => true
  8522. ) );
  8523. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8524. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8525. $au = 0;
  8526. foreach ( $rplist as $k => $v ) {
  8527. if ($value ['staff'] == $v ['staff']) {
  8528. $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>';
  8529. $au += $v ['amount'];
  8530. }
  8531. }
  8532. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8533. }
  8534. $data ['html'] = $html;
  8535. $data ['memu'] = "receipt";
  8536. $data ['staff'] = $this->staff;
  8537. $data ['receiptMemu'] = 'remittanceHky';
  8538. $data ['verifyId'] = $this->verifyId;
  8539. $data ['executeId'] = $this->executeId;
  8540. $this->render ( "/admin/remittancep", $data );
  8541. }
  8542. function ajaxGetReceiptDetails() {
  8543. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8544. Doo::loadClass ( 'XDeode' );
  8545. $XDeode = new XDeode ( 5 );
  8546. $rid = $XDeode->decode ( $rid );
  8547. if (empty ( $rid )) {
  8548. echo json_encode ( array (
  8549. 'status' => 2,
  8550. 'msg' => 'illegal request'
  8551. ) );
  8552. die ();
  8553. }
  8554. Doo::loadModel ( 'receipt' );
  8555. $receipt = new receipt ();
  8556. Doo::loadModel ( 'staff' );
  8557. $staff = new staff ();
  8558. $rinfo = $receipt->getOne ( array (
  8559. 'where' => 'rid= ' . $rid,
  8560. 'asArray' => true
  8561. ) );
  8562. $sinfo = $staff->getOne ( array (
  8563. 'select' => 'username,category',
  8564. 'where' => ' sid=' . $rinfo ['staff'],
  8565. 'asArray' => true
  8566. ) );
  8567. $rinfo ['reviseDetail'] = array ();
  8568. if (! empty ( $rinfo ['reviseDetail'] ))
  8569. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8570. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8571. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8572. $rinfo ['category'] = $sinfo ['category'];
  8573. $verifyStaff = array ();
  8574. if (! empty ( $rinfo ['verifyStaff'] ))
  8575. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8576. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8577. $rinfo ['relust'] = $relust;
  8578. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8579. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8580. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8581. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8582. // 费用执行人相关数据
  8583. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8584. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8585. foreach ( $executeCopy as $k => $v ) {
  8586. $executeCopy [$k] ['date'] = '';
  8587. $executeCopy [$k] ['opinion'] = '';
  8588. $executeCopy [$k] ['status'] = '';
  8589. if (! empty ( $executeStaff ))
  8590. foreach ( $executeStaff as $m => $u ) {
  8591. if ($v [0] == $m) {
  8592. $executeCopy [$k] ['date'] = $u ['date'];
  8593. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8594. $executeCopy [$k] ['status'] = $u ['status'];
  8595. break;
  8596. }
  8597. }
  8598. }
  8599. $rinfo ['executeCopy'] = $executeCopy;
  8600. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8601. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8602. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8603. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8604. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8605. $html .= '<tr><th>' . $value ['name'] . '</th>
  8606. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8607. }
  8608. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8609. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8610. <tr><th class="taC" colspan="2">费用说明</th>
  8611. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8612. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8613. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8614. </tbody></table>';
  8615. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8616. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8617. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8618. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8619. $html .= '<tr><th>' . $value ['name'] . '</th>
  8620. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8621. }
  8622. $html .= '<tr><th class="taR">合计</th>
  8623. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8624. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8625. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8626. $html .= '<tr><th>' . $value ['name'] . '</th>
  8627. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8628. }
  8629. $html .= '<tr><th class="taR">合计</th>
  8630. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8631. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8632. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8633. $html .= '<tr><th>' . $value ['name'] . '</th>
  8634. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8635. }
  8636. $html .= '<tr><th class="taR">合计</th>
  8637. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8638. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8639. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8640. $html .= '<tr><th>' . $value ['name'] . '</th>
  8641. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8642. }
  8643. $html .= '<tr><th class="taR">合计</th>
  8644. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8645. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8646. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8647. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8648. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8649. }
  8650. $html .= '<tr><th class="taR">合计</th>
  8651. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8652. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8653. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8654. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8655. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8656. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8657. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8658. <tr';
  8659. if ($rinfo ['relust'] >= 0) {
  8660. $html .= 'class="success"';
  8661. } else {
  8662. $html .= 'class="error"';
  8663. }
  8664. $html .= '><td class="taR"><b>借款结余</b></td>
  8665. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8666. </tbody></table>
  8667. ';
  8668. }
  8669. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8670. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8671. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8672. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8673. $html .= '<tr><th>' . $value ['name'] . '</th>
  8674. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8675. }
  8676. $html .= '<tr><th class="taR">合计</th>
  8677. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8678. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8679. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8680. <tr><th class="taC" colspan="2">费用说明</th>
  8681. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8682. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8683. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8684. </tbody></table>';
  8685. } else {
  8686. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8687. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8688. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8689. $html .= '<tr><th>' . $value ['name'] . '</th>
  8690. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8691. }
  8692. $html .= '<tr><th class="taR">合计</th>
  8693. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8694. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8695. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8696. $html .= '<tr><th>' . $value ['name'] . '</th>
  8697. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8698. }
  8699. $html .= '<tr><th class="taR">合计</th>
  8700. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8701. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8702. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8703. $html .= '<tr><th>' . $value ['name'] . '</th>
  8704. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8705. }
  8706. $html .= '<tr><th class="taR">合计</th>
  8707. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8708. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8709. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8710. $html .= '<tr><th>' . $value ['name'] . '</th>
  8711. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8712. }
  8713. $html .= '<tr><th class="taR">合计</th>
  8714. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8715. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8716. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8717. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8718. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8719. }
  8720. $html .= '<tr><th class="taR">合计</th>
  8721. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8722. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8723. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8724. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8725. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8726. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8727. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8728. $html .= '</tbody></table>';
  8729. /*
  8730. * <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>
  8731. */
  8732. }
  8733. // print_r($verifyStaff);die;
  8734. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8735. foreach ( $verifyStaff as $key => $value ) {
  8736. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8737. $sinfo = $staff->getOne ( array (
  8738. 'select' => 'username',
  8739. 'where' => ' sid=' . $key,
  8740. 'asArray' => true
  8741. ) );
  8742. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8743. }
  8744. $html .= '</tbody></table>';
  8745. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8746. foreach ( $rinfo ['executeCopy'] as $value ) {
  8747. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8748. }
  8749. $html .= '</tbody></table>';
  8750. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8751. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8752. </tr></table>';
  8753. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8754. echo json_encode ( array (
  8755. 'status' => 1,
  8756. 'html' => $html
  8757. ) );
  8758. die ();
  8759. }
  8760. /**
  8761. * 删除附件
  8762. */
  8763. function ajaxRemEnclousur() {
  8764. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8765. if (empty ( $key ))
  8766. echo json_encode ( array (
  8767. 'status' => 2
  8768. ) );
  8769. Doo::loadModel ( 'enclosur' );
  8770. $enclosur = new enclosur ();
  8771. $enclosur->delEnclosurByEid ( $key );
  8772. echo json_encode ( array (
  8773. 'status' => 1
  8774. ) );
  8775. }
  8776. function remittance() {
  8777. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8778. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8779. Doo::loadModel ( 'receipt' );
  8780. $receipt = new receipt ();
  8781. Doo::loadModel ( 'staff' );
  8782. $staff = new staff ();
  8783. $dateCondition = " and Year(pastDate) =" . $year;
  8784. if (! empty ( $month ))
  8785. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8786. // get Receipt By verifyID status 1
  8787. $receiptList = $receipt->find ( array (
  8788. 'select' => 'sum(sum) as sum,staff,pastDate',
  8789. 'where' => ' status=1' . $dateCondition,
  8790. 'desc' => 'pastDate',
  8791. 'groupby' => 'staff,pastDate',
  8792. 'asArray' => true
  8793. ) );
  8794. $dateList = $receipt->find ( array (
  8795. 'select' => 'pastDate,verifyStaff',
  8796. 'where' => ' status=1' . $dateCondition,
  8797. 'desc' => 'pastDate',
  8798. 'groupby' => 'pastDate',
  8799. 'asArray' => true
  8800. ) );
  8801. $dataList = array ();
  8802. foreach ( $dateList as $d => $a ) {
  8803. $dataList [$a ['pastDate']] = array ();
  8804. $daySum = 0;
  8805. foreach ( $receiptList as $key => $value ) {
  8806. if ($a ['pastDate'] == $value ['pastDate']) {
  8807. $oderList = $receipt->find ( array (
  8808. 'select' => 'receiptOrder',
  8809. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8810. 'asArray' => true
  8811. ) );
  8812. $list = array ();
  8813. $html = "";
  8814. foreach ( $oderList as $v ) {
  8815. array_push ( $list, $v ['receiptOrder'] );
  8816. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8817. }
  8818. $receiptList [$key] ['receiptOrder'] = $html;
  8819. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8820. $sinfo = $staff->getOne ( array (
  8821. 'select' => 'username ',
  8822. 'where' => ' sid=' . $value ['staff'],
  8823. 'asArray' => true
  8824. ) );
  8825. $receiptList [$key] ['username'] = $sinfo ['username'];
  8826. $daySum += $value ['sum'];
  8827. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8828. }
  8829. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8830. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8831. }
  8832. }
  8833. // print_r($dataList);
  8834. $data ['dataList'] = $dataList;
  8835. $mothHtml = "";
  8836. for($i = 1; $i <= 12; $i ++) {
  8837. if ($month == $i)
  8838. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8839. else
  8840. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8841. }
  8842. $data ['year'] = $year;
  8843. $data ['mothHtml'] = $mothHtml;
  8844. $data ['memu'] = "receipt";
  8845. $data ['staff'] = $this->staff;
  8846. $data ['receiptMemu'] = 'approval';
  8847. $data ['verifyId'] = $this->verifyId;
  8848. $data ['executeId'] = $this->executeId;
  8849. $this->render ( "/admin/saeaReportListPay", $data );
  8850. }
  8851. /**
  8852. * 金额调整,提高稳定性
  8853. * @return string
  8854. */
  8855. function revocationAdjustment() {
  8856. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8857. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8858. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8859. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8860. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8861. Doo::loadClass ( 'XDeode' );
  8862. $XDeode = new XDeode ( 5 );
  8863. Doo::loadModel ( 'receipt' );
  8864. $receipt = new receipt ();
  8865. $sid = $XDeode->decode ( $sidKey );
  8866. $rid = $XDeode->decode ( $ridKey );
  8867. $reviseKey = $XDeode->decode ( $reviseKey );
  8868. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8869. die ( 'illegal request' );
  8870. $receiptDetail = $receipt->getOne ( array (
  8871. 'where' => 'rid=' . $rid,
  8872. 'asArray' => true
  8873. ) );
  8874. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8875. die ( 'illegal request' );
  8876. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8877. if (! isset ( $reviseDetail [$reviseKey] ))
  8878. die ( 'illegal request' );
  8879. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8880. unset ( $reviseDetail [$reviseKey] );
  8881. $revisePrice = 0;
  8882. foreach ( $reviseDetail as $key => $value ) {
  8883. $revisePrice += $value ['price'];
  8884. }
  8885. $reviseDetailString = json_encode ( $reviseDetail );
  8886. $receipt->reviseDetail = $reviseDetailString;
  8887. $receipt->sum = $receiptDetail ['sum'] - $price;
  8888. $receipt->revisePrice = $revisePrice;
  8889. $receipt->update ( array (
  8890. 'where' => 'rid=' . $rid
  8891. ) );
  8892. return '/receiptburEdi/' . $rid;
  8893. } else
  8894. die ( 'illegal request2' );
  8895. }
  8896. function updateApprovalReceipt() {
  8897. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8898. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8899. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8900. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8901. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8902. if (! empty ( $rid )) {
  8903. Doo::loadModel ( "verify" );
  8904. $verify = new verify ();
  8905. Doo::loadModel ( "receiptDetail" );
  8906. $receiptDetailObj = new receiptDetail ();
  8907. Doo::loadModel ( "itemStatistics" );
  8908. Doo::loadModel ( "statistics" );
  8909. $statistics = new statistics ();
  8910. $itemStatistics = new itemStatistics ();
  8911. Doo::loadModel ( "receipt" );
  8912. $receipt = new receipt ();
  8913. $receiptDetail = $receipt->getOne ( array (
  8914. 'where' => 'rid=' . $rid . ' and status=2 ',
  8915. 'asArray' => true
  8916. ) );
  8917. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8918. $nsflag = true;
  8919. foreach ( $nslist as $value ) {
  8920. if ($value == $this->staff ['0'] ['sid']) {
  8921. $nsflag = false;
  8922. break;
  8923. }
  8924. }
  8925. if (empty ( $receiptDetail ) || $nsflag)
  8926. return "/approvalExpenses/pendApproval";
  8927. $verifyDetail = $verify->getOne ( array (
  8928. 'where' => ' vid =' . $receiptDetail ['verify'],
  8929. 'asArray' => true
  8930. ) );
  8931. $verifyString = $verifyDetail ['staff'];
  8932. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8933. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8934. if (empty ( $opinion )) {
  8935. if ($status == 3)
  8936. $opinion = "终止";
  8937. else
  8938. $opinion = "同意支付";
  8939. }
  8940. $nowStaff = 0;
  8941. $nowStaffList = array ();
  8942. if (empty ( $verifyStaff )) {
  8943. // 还需加入是否已经进入角色审批
  8944. if ($verifyDetail [0] [1] == 'ROLE') {
  8945. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8946. foreach ( $vStaffString as $key => $value ) {
  8947. $staffK = explode ( "_", $value );
  8948. if ($staffK [0] != $this->staff [0] ['sid'])
  8949. array_push ( $nowStaffList, $staffK [0] );
  8950. }
  8951. // print_r($verifyDetail);
  8952. // die;
  8953. if (! empty ( $nowStaffList )) {
  8954. $nowStaff = implode ( ',', $nowStaffList );
  8955. $verifyStaff = array (
  8956. $this->staff [0] ['sid'] . "_R" => array (
  8957. 'date' => date ( 'Y-m-d' ),
  8958. 'opinion' => $opinion,
  8959. 'status' => $status,
  8960. 'nextStaff' => $verifyDetail [0] [0],
  8961. 'ROLE' => 1
  8962. )
  8963. );
  8964. } else {
  8965. $nowStaff = $verifyDetail [1] [0];
  8966. $verifyStaff = array (
  8967. $this->staff [0] ['sid'] . "_R" => array (
  8968. 'date' => date ( 'Y-m-d' ),
  8969. 'opinion' => $opinion,
  8970. 'status' => $status,
  8971. 'nextStaff' => $verifyDetail [1] [0]
  8972. )
  8973. );
  8974. }
  8975. } else {
  8976. if ($verifyDetail [1] [1] == 'ROLE') {
  8977. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8978. // echo "dd";
  8979. foreach ( $vStaffString as $key => $value ) {
  8980. $staffK = explode ( "_", $value );
  8981. array_push ( $nowStaffList, $staffK [0] );
  8982. }
  8983. $nowStaff = implode ( ',', $nowStaffList );
  8984. $verifyStaff = array (
  8985. $this->staff [0] ['sid'] => array (
  8986. 'date' => date ( 'Y-m-d' ),
  8987. 'opinion' => $opinion,
  8988. 'status' => $status,
  8989. 'nextStaff' => $verifyDetail [1] [0],
  8990. 'ROLE' => 1
  8991. )
  8992. );
  8993. } else {
  8994. $nowStaff = $verifyDetail [1] [0];
  8995. $verifyStaff = array (
  8996. $this->staff [0] ['sid'] => array (
  8997. 'date' => date ( 'Y-m-d' ),
  8998. 'opinion' => $opinion,
  8999. 'status' => $status,
  9000. 'nextStaff' => $verifyDetail [1] [0]
  9001. )
  9002. );
  9003. }
  9004. }
  9005. if ($status == 3)
  9006. $verifyStaff = array (
  9007. 'final' => $status,
  9008. $this->staff [0] ['sid'] => array (
  9009. 'date' => date ( 'Y-m-d' ),
  9010. 'opinion' => $opinion,
  9011. 'status' => $status
  9012. )
  9013. );
  9014. $vStaffString = json_encode ( $verifyStaff );
  9015. $receipt->nowStaff = $nowStaff;
  9016. $receipt->verifyStaff = $vStaffString;
  9017. } else {
  9018. $VS = end ( $verifyStaff );
  9019. // 非角色审批
  9020. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9021. $nextStaff = 0;
  9022. $roleSTF = false;
  9023. foreach ( $verifyDetail as $key => $value ) {
  9024. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9025. if (isset ( $verifyDetail [$key + 1] )) {
  9026. $nextStaff = $verifyDetail [$key + 1] [0];
  9027. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9028. $roleSTF = true;
  9029. }
  9030. break;
  9031. }
  9032. }
  9033. if (! $roleSTF) {
  9034. $nowStaff = $nextStaff;
  9035. $verifyStaff [$this->staff [0] ['sid']] = array (
  9036. 'date' => date ( 'Y-m-d' ),
  9037. 'opinion' => $opinion,
  9038. 'status' => $status,
  9039. 'nextStaff' => $nextStaff
  9040. );
  9041. } else {
  9042. // 获取角色下的所有用户ID
  9043. $nowStaffList = array ();
  9044. foreach ( $verifyDetail as $vfk ) {
  9045. if ($vfk [1] == 'ROLE') {
  9046. $vStaffString = json_decode ( $vfk [3] );
  9047. foreach ( $vStaffString as $key => $value ) {
  9048. $staffK = explode ( "_", $value );
  9049. array_push ( $nowStaffList, $staffK [0] );
  9050. }
  9051. }
  9052. }
  9053. $nowStaff = implode ( ',', $nowStaffList );
  9054. $verifyStaff [$this->staff [0] ['sid']] = array (
  9055. 'date' => date ( 'Y-m-d' ),
  9056. 'opinion' => $opinion,
  9057. 'status' => $status,
  9058. 'nextStaff' => $nextStaff,
  9059. 'ROLE' => 0
  9060. );
  9061. }
  9062. if ($status == 3) {
  9063. $verifyStaff ['final'] = $status;
  9064. $verifyStaff [$this->staff [0] ['sid']] = array (
  9065. 'date' => date ( 'Y-m-d' ),
  9066. 'opinion' => $opinion,
  9067. 'status' => $status
  9068. );
  9069. }
  9070. $vStaffString = json_encode ( $verifyStaff );
  9071. $receipt->nowStaff = $nowStaff;
  9072. $receipt->verifyStaff = $vStaffString;
  9073. }
  9074. // 角色审批
  9075. if (isset ( $VS ['ROLE'] )) {
  9076. // 找出角色人 当前审批角色组
  9077. $verifyJSStaff = array ();
  9078. $nowStaffList2 = array ();
  9079. foreach ( $verifyDetail as $key => $value ) {
  9080. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9081. $verifyJSStaff = json_decode ( $value [3] );
  9082. foreach ( $verifyJSStaff as $m ) {
  9083. $staffK = explode ( "_", $m );
  9084. array_push ( $nowStaffList2, $staffK [0] );
  9085. }
  9086. // print_r($nowStaffList2);
  9087. }
  9088. }
  9089. $RoleVerifyStaff = array ();
  9090. foreach ( $verifyStaff as $key => $value ) {
  9091. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9092. foreach ( $nowStaffList2 as $m ) {
  9093. if ($key == $m . "_R")
  9094. $RoleVerifyStaff [$key] = $value;
  9095. }
  9096. }
  9097. }
  9098. // print_r($verifyStaff);
  9099. // print_r($nowStaffList2);
  9100. // print_r($RoleVerifyStaff);
  9101. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9102. // print_r($verifyJSStaff);
  9103. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9104. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9105. // 下一个审批人ID
  9106. $nextStaff = 0;
  9107. $falg = false;
  9108. foreach ( $verifyDetail as $key => $value ) {
  9109. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9110. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9111. $falg = true;
  9112. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9113. $nowStaffList = array ();
  9114. foreach ( $vStaffString as $v ) {
  9115. $staffK = explode ( "_", $v );
  9116. array_push ( $nowStaffList, $staffK [0] );
  9117. }
  9118. $nowStaff = implode ( ',', $nowStaffList );
  9119. $nextStaff = $verifyDetail [$key + 1] [0];
  9120. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9121. $nextStaff = $verifyDetail [$key + 1] [0];
  9122. $nowStaff = $nextStaff;
  9123. } else
  9124. $nowStaff = '';
  9125. break;
  9126. }
  9127. }
  9128. if ($falg)
  9129. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9130. 'date' => date ( 'Y-m-d' ),
  9131. 'opinion' => $opinion,
  9132. 'status' => $status,
  9133. 'nextStaff' => $nextStaff,
  9134. 'ROLE' => 1
  9135. );
  9136. else
  9137. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9138. 'date' => date ( 'Y-m-d' ),
  9139. 'opinion' => $opinion,
  9140. 'status' => $status,
  9141. 'nextStaff' => $nextStaff
  9142. );
  9143. // print_r($verifyStaff);
  9144. // echo $nowStaff;die;
  9145. } else { // 进入下一个角色或者审批人
  9146. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9147. //
  9148. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9149. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9150. 'date' => date ( 'Y-m-d' ),
  9151. 'opinion' => $opinion,
  9152. 'status' => $status,
  9153. 'nextStaff' => $VS ['nextStaff'],
  9154. 'ROLE' => 1
  9155. );
  9156. // print_r($verifyStaff);
  9157. // die;
  9158. }
  9159. if ($status == 3) {
  9160. $verifyStaff ['final'] = $status;
  9161. $verifyStaff [$this->staff [0] ['sid']] = array (
  9162. 'date' => date ( 'Y-m-d' ),
  9163. 'opinion' => $opinion,
  9164. 'status' => $status
  9165. );
  9166. }
  9167. $vStaffString = json_encode ( $verifyStaff );
  9168. $receipt->verifyStaff = $vStaffString;
  9169. $receipt->nowStaff = $nowStaff;
  9170. // die;
  9171. // }
  9172. // print_r($verifyStaff);
  9173. // die;
  9174. }
  9175. // print_r($verifyStaff);die;
  9176. }
  9177. // print_r($verifyDetail);
  9178. $roleKey = 0;
  9179. $roleId = 0;
  9180. $verifyDetailCopy = array ();
  9181. foreach ( $verifyDetail as $k => $v ) {
  9182. if ($v [1] == 'ROLE') {
  9183. $roleId = $v [0];
  9184. $roleVerify = json_decode ( $v [3], true );
  9185. $roleKey = $k;
  9186. $roleArray = array ();
  9187. foreach ( $roleVerify as $o => $p ) {
  9188. $staffID = explode ( '_', $p );
  9189. $exp = array (
  9190. 0 => $staffID [0],
  9191. 1 => $staffID [1]
  9192. );
  9193. array_push ( $roleArray, $exp );
  9194. }
  9195. $verifyDetailCopy [$v [0]] = $roleArray;
  9196. }
  9197. }
  9198. // print_r($verifyDetail);
  9199. foreach ( $verifyDetailCopy as $k => $v ) {
  9200. foreach ( $verifyDetail as $m => $n ) {
  9201. if ($n [0] == $k) {
  9202. array_splice ( $verifyDetail, $m, 1, $v );
  9203. }
  9204. }
  9205. }
  9206. // die;
  9207. // if (!empty($roleArray))
  9208. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9209. // echo $roleId;
  9210. // print_r($verifyStaff);
  9211. // print_r($verifyDetail);
  9212. // die;
  9213. Doo::loadModel ( "receiptLog" );
  9214. $receiptLog = new receiptLog ();
  9215. // 审批日志
  9216. if (! isset ( $verifyStaff ['final'] )) {
  9217. if (! empty ( $roleId )) {
  9218. Doo::loadModel ( "role" );
  9219. $role = new role ();
  9220. $roleInfo = $role->getOne ( array (
  9221. 'where' => 'rid=' . $roleId,
  9222. 'asArray' => true
  9223. ) );
  9224. $receiptLog->rolename = $roleInfo ['name'];
  9225. }
  9226. $receiptLog->username = $this->staff [0] ['username'];
  9227. $receiptLog->uid = $this->staff [0] ['sid'];
  9228. $receiptLog->date = date ( "Y-m-d" );
  9229. $receiptLog->opinion = $opinion;
  9230. $receiptLog->img = $this->staff [0] ['avatar'];
  9231. $receiptLog->status = 1;
  9232. $receiptLog->rid = $rid;
  9233. $receiptLog->insert ();
  9234. }
  9235. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9236. $receipt->verifyBreakup = $verifyString;
  9237. $receipt->status = 3;
  9238. $receiptDetailObj->status = 3;
  9239. $receiptDetailObj->update ( array (
  9240. 'where' => 'rid=' . $rid
  9241. ) );
  9242. if (! empty ( $roleId )) {
  9243. Doo::loadModel ( "role" );
  9244. $role = new role ();
  9245. $roleInfo = $role->getOne ( array (
  9246. 'where' => 'rid=' . $roleId,
  9247. 'asArray' => true
  9248. ) );
  9249. $receiptLog->rolename = $roleInfo ['name'];
  9250. }
  9251. $receiptLog->username = $this->staff [0] ['username'];
  9252. $receiptLog->uid = $this->staff [0] ['sid'];
  9253. $receiptLog->date = date ( "Y-m-d" );
  9254. $receiptLog->opinion = $opinion;
  9255. $receiptLog->img = $this->staff [0] ['avatar'];
  9256. $receiptLog->status = 3;
  9257. $receiptLog->rid = $rid;
  9258. $receiptLog->insert ();
  9259. //删除行程单
  9260. Doo::loadModel ( 'itinerary' );
  9261. $itinerary = new itinerary ();
  9262. $itinerary->delete ( array (
  9263. 'where' => 'rid="' . $rid . '"'
  9264. ) );
  9265. // 微信企业号通知
  9266. $this->setWXMsg ( $rid, 3 );
  9267. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9268. $receipt->status = 1;
  9269. $reviseSum = 0;
  9270. $receipt->verifyBreakup = $verifyString;
  9271. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9272. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9273. foreach ( $reviseDetail as $key => $value ) {
  9274. $receiptDetailObj = new receiptDetail ();
  9275. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9276. $receiptDetailObj->item = $value ['description'];
  9277. $receiptDetailObj->itemCategory = "报销金额调整";
  9278. $receiptDetailObj->price = $value ['price'];
  9279. $receiptDetailObj->date = $receiptDetail ['date'];
  9280. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9281. $receiptDetailObj->rid = $rid;
  9282. $receiptDetailObj->status = 1;
  9283. $receiptDetailObj->insert ();
  9284. $reviseSum += $value ['price'];
  9285. }
  9286. $itemStatistics = new itemStatistics ();
  9287. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9288. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9289. $itemStatistics->price = $reviseSum;
  9290. $itemStatistics->itemCategory = "报销金额调整";
  9291. $itemStatistics->date = $receiptDetail ['date'];
  9292. $itemStatistics->insert ();
  9293. }
  9294. $receiptDetailObj = new receiptDetail ();
  9295. $receiptDetailObj->status = 1;
  9296. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9297. $receiptDetailObj->update ( array (
  9298. 'where' => 'rid=' . $rid
  9299. ) );
  9300. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9301. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9302. $stat = $statistics->getOne ( array (
  9303. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9304. 'asArray' => true
  9305. ) );
  9306. if (empty ( $stat )) {
  9307. $statistics->date = $receiptDetail ['date'];
  9308. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9309. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9310. $statistics->agPrice = $receiptDetail ['sum'];
  9311. $statistics->rePrice = $reviseSum;
  9312. $statistics->insert ();
  9313. } else {
  9314. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9315. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9316. $statistics->update ( array (
  9317. 'where' => 'sid=' . $stat ['sid']
  9318. ) );
  9319. }
  9320. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9321. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9322. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9323. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9324. if ($key == "agencySum") {
  9325. $iStatistics = $itemStatistics->getOne ( array (
  9326. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9327. 'asArray' => true
  9328. ) );
  9329. if (empty ( $iStatistics )) {
  9330. $itemStatistics->cid = $receiptDetail ['cid'];
  9331. ;
  9332. $itemStatistics->staff = $receiptDetail ['staff'];
  9333. $itemStatistics->price = $value;
  9334. $itemStatistics->itemCategory = $this->AGENCY;
  9335. $itemStatistics->date = $receiptDetail ['date'];
  9336. $itemStatistics->insert ();
  9337. } else {
  9338. if (! empty ( $value )) {
  9339. $itemStatistics->price = $value + $iStatistics ['price'];
  9340. $itemStatistics->update ( array (
  9341. 'where' => 'sid=' . $iStatistics ['sid']
  9342. ) );
  9343. }
  9344. }
  9345. } elseif ($key == "travelSum") {
  9346. $iStatistics = $itemStatistics->getOne ( array (
  9347. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9348. 'asArray' => true
  9349. ) );
  9350. if (empty ( $iStatistics )) {
  9351. $itemStatistics->cid = $receiptDetail ['cid'];
  9352. $itemStatistics->staff = $receiptDetail ['staff'];
  9353. $itemStatistics->price = $value;
  9354. $itemStatistics->itemCategory = $this->TRAVEL;
  9355. $itemStatistics->date = $receiptDetail ['date'];
  9356. $itemStatistics->insert ();
  9357. } else {
  9358. if (! empty ( $value )) {
  9359. $itemStatistics->price = $value + $iStatistics ['price'];
  9360. $itemStatistics->update ( array (
  9361. 'where' => 'sid=' . $iStatistics ['sid']
  9362. ) );
  9363. }
  9364. }
  9365. } elseif ($key == "trainSum") {
  9366. $iStatistics = $itemStatistics->getOne ( array (
  9367. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9368. 'asArray' => true
  9369. ) );
  9370. if (empty ( $iStatistics )) {
  9371. $itemStatistics->cid = $receiptDetail ['cid'];
  9372. $itemStatistics->staff = $receiptDetail ['staff'];
  9373. $itemStatistics->price = $value;
  9374. $itemStatistics->itemCategory = $this->TRAIN;
  9375. $itemStatistics->date = $receiptDetail ['date'];
  9376. $itemStatistics->insert ();
  9377. } else {
  9378. if (! empty ( $value )) {
  9379. $itemStatistics->price = $value + $iStatistics ['price'];
  9380. $itemStatistics->update ( array (
  9381. 'where' => 'sid=' . $iStatistics ['sid']
  9382. ) );
  9383. }
  9384. }
  9385. } elseif ($key == "otherSum") {
  9386. $iStatistics = $itemStatistics->getOne ( array (
  9387. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9388. 'asArray' => true
  9389. ) );
  9390. if (empty ( $iStatistics )) {
  9391. $itemStatistics->cid = $receiptDetail ['cid'];
  9392. $itemStatistics->staff = $receiptDetail ['staff'];
  9393. $itemStatistics->price = $value;
  9394. $itemStatistics->itemCategory = $this->OTHER;
  9395. $itemStatistics->date = $receiptDetail ['date'];
  9396. $itemStatistics->insert ();
  9397. } else {
  9398. if (! empty ( $value )) {
  9399. $itemStatistics->price = $value + $iStatistics ['price'];
  9400. $itemStatistics->update ( array (
  9401. 'where' => 'sid=' . $iStatistics ['sid']
  9402. ) );
  9403. }
  9404. }
  9405. }
  9406. }
  9407. $receipt->pastDate = date ( "Y-m-d" );
  9408. // 微信企业号通知
  9409. $this->setWXMsg ( $rid, 1 );
  9410. }
  9411. //是否有流水
  9412. Doo::loadModel ( 'wasteBook' );
  9413. $wasteBook = new wasteBook ();
  9414. $accountType=3;
  9415. if ($receiptDetail['Rtype']==1){
  9416. $accountType=2;
  9417. }elseif($receiptDetail['Rtype']==2){
  9418. $accountType=4;
  9419. }
  9420. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9421. if (empty($wbDetail)){
  9422. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9423. $receipt->amount = $rsum;//$amount;
  9424. }
  9425. $receipt->update ( array (
  9426. 'where' => ' rid = ' . $rid
  9427. ) );
  9428. // 进入下一条审批费用新加需求
  9429. $vidList = array ();
  9430. $verifyDetail = $verify->find ( array (
  9431. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9432. 'asArray' => true
  9433. ) );
  9434. foreach ( $verifyDetail as $key => $value ) {
  9435. array_push ( $vidList, $value ['vid'] );
  9436. }
  9437. $vid = implode ( ",", $vidList );
  9438. if (empty ( $verifyDetail ))
  9439. $vid = 0;
  9440. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9441. $receipt = new receipt ();
  9442. $rd = $receipt->getOne ( array (
  9443. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9444. 'asc' => 'rid',
  9445. 'asArray' => true
  9446. ) );
  9447. if (empty ( $rd )) {
  9448. return '/approvalExpenses/pendApproval';
  9449. }
  9450. if ($rd ['Rtype'] == 1) {
  9451. if ($rd ['isBK'] == 1) {
  9452. return '/receiptburEdi/' . $rd ['rid'];
  9453. } else {
  9454. return '/expensesEdi/' . $rd ['rid'];
  9455. }
  9456. } elseif ($rd ['Rtype'] == 2) {
  9457. return '/remitApproval/' . $rd ['rid'];
  9458. } else {
  9459. return '/receiptburEdi/' . $rd ['rid'];
  9460. }
  9461. // return "/approvalExpenses/pendApproval";
  9462. }
  9463. }
  9464. function expensesRetreats() {
  9465. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9466. if (! empty ( $rid )) {
  9467. // 操作记录
  9468. Doo::loadModel ( "receipt" );
  9469. $receipt = new receipt ();
  9470. Doo::loadModel ( "receiptLog" );
  9471. $receiptLog = new receiptLog ();
  9472. Doo::loadModel ( "verify" );
  9473. $verify = new verify ();
  9474. $receiptInfo = $receipt->getOne ( array (
  9475. 'where' => 'rid=' . $rid,
  9476. 'asArray' => true
  9477. ) );
  9478. $vr = $verify->getOne ( array (
  9479. 'where' => 'vid=' . $receiptInfo ['verify'],
  9480. 'asArray' => true
  9481. ) );
  9482. $jd = json_decode ( $vr ['staff'] );
  9483. $roleId = 0;
  9484. foreach ( $jd as $key => $value ) {
  9485. if ($value [1] == 'ROLE') {
  9486. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9487. if ($pos !== false) {
  9488. $roleId = $value [0];
  9489. }
  9490. }
  9491. }
  9492. // 审批日志
  9493. // echo $roleId;die;
  9494. if (! empty ( $roleId )) {
  9495. Doo::loadModel ( "role" );
  9496. $role = new role ();
  9497. $roleInfo = $role->getOne ( array (
  9498. 'where' => 'rid=' . $roleId,
  9499. 'asArray' => true
  9500. ) );
  9501. $receiptLog->rolename = $roleInfo ['name'];
  9502. }
  9503. $receiptLog->username = $this->staff [0] ['username'];
  9504. $receiptLog->uid = $this->staff [0] ['sid'];
  9505. $receiptLog->date = date ( "Y-m-d" );
  9506. $receiptLog->opinion = '撤回';
  9507. $receiptLog->img = $this->staff [0] ['avatar'];
  9508. $receiptLog->status = 4;
  9509. $receiptLog->rid = $rid;
  9510. $receiptLog->insert ();
  9511. $receipt->status = 4;
  9512. $receipt->update ( array (
  9513. 'where' => 'rid=' . $rid
  9514. ) );
  9515. // 微信企业号通知
  9516. $this->setWXMsg ( $rid, 2 );
  9517. }
  9518. // echo "ddd";
  9519. return '/approvalExpenses/pendApproval';
  9520. }
  9521. function updateCheReceipt() {
  9522. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9523. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9524. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9525. if (! empty ( $rid )) {
  9526. // 操作记录
  9527. Doo::loadModel ( "receipt" );
  9528. $receipt = new receipt ();
  9529. Doo::loadModel ( "receiptLog" );
  9530. $receiptLog = new receiptLog ();
  9531. Doo::loadModel ( "verify" );
  9532. $verify = new verify ();
  9533. $receiptInfo = $receipt->getOne ( array (
  9534. 'where' => 'rid=' . $rid . ' and status=2',
  9535. 'asArray' => true
  9536. ) );
  9537. if (empty ( $receiptInfo )) {
  9538. echo json_encode ( array (
  9539. 'status' => 2
  9540. ) );
  9541. die ();
  9542. }
  9543. $vr = $verify->getOne ( array (
  9544. 'where' => 'vid=' . $receiptInfo ['verify'],
  9545. 'asArray' => true
  9546. ) );
  9547. $jd = json_decode ( $vr ['staff'] );
  9548. $roleId = 0;
  9549. foreach ( $jd as $key => $value ) {
  9550. if ($value [1] == 'ROLE') {
  9551. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9552. if ($pos !== false) {
  9553. $roleId = $value [0];
  9554. }
  9555. }
  9556. }
  9557. // 审批日志
  9558. // echo $roleId;die;
  9559. if (! empty ( $roleId )) {
  9560. Doo::loadModel ( "role" );
  9561. $role = new role ();
  9562. $roleInfo = $role->getOne ( array (
  9563. 'where' => 'rid=' . $roleId,
  9564. 'asArray' => true
  9565. ) );
  9566. $receiptLog->rolename = $roleInfo ['name'];
  9567. }
  9568. $receiptLog->username = $this->staff [0] ['username'];
  9569. $receiptLog->uid = $this->staff [0] ['sid'];
  9570. $receiptLog->date = date ( "Y-m-d" );
  9571. $receiptLog->opinion = $opinion;
  9572. $receiptLog->img = $this->staff [0] ['avatar'];
  9573. $receiptLog->status = 4;
  9574. $receiptLog->rid = $rid;
  9575. $receiptLog->insert ();
  9576. $receipt->status = 4;
  9577. $receipt->update ( array (
  9578. 'where' => 'rid=' . $rid
  9579. ) );
  9580. // 微信企业号通知
  9581. $this->setWXMsg ( $rid, 2 );
  9582. echo json_encode ( array (
  9583. 'status' => 1
  9584. ) );
  9585. // Header("HTTP/1.1 303 See Other");
  9586. // Header("Location: /approvalExpenses/pendApproval");
  9587. die ();
  9588. }
  9589. echo json_encode ( array (
  9590. 'status' => 2
  9591. ) );
  9592. die ();
  9593. // echo "ddd";
  9594. // return '/saeaBorad';
  9595. }
  9596. function revisePrice() {
  9597. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9598. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9599. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9600. // echo $price;die;
  9601. if (! empty ( $rid )) {
  9602. Doo::loadModel ( "receipt" );
  9603. $receipt = new receipt ();
  9604. $receiptDetail = $receipt->getOne ( array (
  9605. 'where' => 'rid=' . $rid . ' and status=2 ',
  9606. 'asArray' => true
  9607. ) );
  9608. if (empty ( $receiptDetail ))
  9609. die ( 'illegal request' );
  9610. $reviseDetail = array ();
  9611. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9612. array_push ( $reviseDetail, array (
  9613. 'sid' => $this->staff [0] ['sid'],
  9614. 'name' => $this->staff [0] ['username'],
  9615. 'description' => $description,
  9616. 'price' => $price
  9617. ) );
  9618. $reviseDetailString = json_encode ( $reviseDetail );
  9619. $receipt->reviseDetail = $reviseDetailString;
  9620. $receipt->revisePrice = $price;
  9621. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9622. } else {
  9623. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9624. array_push ( $reviseDetail, array (
  9625. 'sid' => $this->staff [0] ['sid'],
  9626. 'name' => $this->staff [0] ['username'],
  9627. 'description' => $description,
  9628. 'price' => $price
  9629. ) );
  9630. $reviseDetailString = json_encode ( $reviseDetail );
  9631. $receipt->reviseDetail = $reviseDetailString;
  9632. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9633. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9634. }
  9635. $receipt->update ( array (
  9636. 'where' => 'rid=' . $rid
  9637. ) );
  9638. if ($receiptDetail ['Rtype'] == 1) {
  9639. if ($receiptDetail ['isBK'] == 1) {
  9640. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9641. }
  9642. } elseif ($receiptDetail ['Rtype'] == 2) {
  9643. } else {
  9644. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9645. }
  9646. }
  9647. die ( 'illegal request' );
  9648. }
  9649. function personalCollect() {
  9650. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9651. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9652. $this->showCache ( $path );
  9653. Doo::loadModel ( "receiptDetail" );
  9654. Doo::loadModel ( "itemStatistics" );
  9655. Doo::loadModel ( 'statistics' );
  9656. $statistics = new statistics ();
  9657. $itemStatistics = new itemStatistics ();
  9658. $receiptDetail = new receiptDetail ();
  9659. $receiptCollectList = $receiptDetail->find ( array (
  9660. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9661. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9662. 'groupby' => 'itemCategory,Month(date)',
  9663. 'asArray' => true
  9664. ) );
  9665. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9666. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9667. 'asArray' => true
  9668. ) );
  9669. // create collect html
  9670. $collectArray = array (
  9671. '日常相关费用' => array (),
  9672. '差旅相关费用' => array (),
  9673. '培训班费用' => array (),
  9674. '其他' => array ()
  9675. );
  9676. $adjustment = array ();
  9677. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9678. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9679. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9680. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9681. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9682. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9683. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9684. array_push ( $collectArray ['其他'], $collectHtml );
  9685. $data ['collectArray'] = $collectArray;
  9686. // statistics html
  9687. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9688. if (empty ( $stList ))
  9689. $stList = array (
  9690. 'rePrice' => 0,
  9691. 'agPrice' => 0
  9692. );
  9693. $data ['stList'] = array (
  9694. 'rePrice' => $stList ['rePrice'],
  9695. 'agPrice' => $stList ['agPrice'],
  9696. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9697. );
  9698. // Adjustment price html
  9699. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9700. array_push ( $adjustment, $collectHtml );
  9701. $data ['adjustment'] = $adjustment;
  9702. // total price html
  9703. $collectHtml = "";
  9704. $total = 0;
  9705. for($i = 1; $i <= 12; $i ++) {
  9706. $sumPrice = 0;
  9707. foreach ( $receiptCollectList as $key => $value ) {
  9708. if ($value ['month'] == $i) {
  9709. $sumPrice += $value ['price'];
  9710. }
  9711. }
  9712. if ($sumPrice == 0)
  9713. $collectHtml .= '<td class="taR">-</td>';
  9714. else
  9715. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9716. $total += $sumPrice;
  9717. }
  9718. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9719. $data ['totalPrice'] = $collectHtml;
  9720. $dateHtml = "";
  9721. $now = date ( "Y" );
  9722. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9723. if ($YEARD <= $now) {
  9724. $dateHtml .= '<option ';
  9725. if ($year == $YEARD) {
  9726. $dateHtml .= 'selected ';
  9727. }
  9728. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9729. }
  9730. }
  9731. $data ['dateHtml'] = $dateHtml;
  9732. $data ['year'] = $year;
  9733. $data ['totalYear'] = $total;
  9734. $data ['memu'] = "receipt";
  9735. $data ['staff'] = $this->staff;
  9736. $data ['receiptMemu'] = 'personalCollect';
  9737. $data ['verifyId'] = $this->verifyId;
  9738. $data ['executeId'] = $this->executeId;
  9739. // year staff status 2,4
  9740. if ($year < date ( "Y" )) {
  9741. Doo::loadModel ( 'receipt' );
  9742. $receipt = new receipt ();
  9743. $receiptList = $receipt->find ( array (
  9744. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9745. 'asArray' => true
  9746. ) );
  9747. if (empty ( $receiptList )) {
  9748. ob_start ();
  9749. $this->render ( "/admin/saea_slist_collect", $data );
  9750. $this->cacheFile ( $path );
  9751. die ();
  9752. }
  9753. }
  9754. $this->render ( "/admin/saea_slist_collect", $data );
  9755. }
  9756. function personalCollectDetail() {
  9757. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9758. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9759. $this->showCache ( $path );
  9760. Doo::loadModel ( "receiptDetail" );
  9761. Doo::loadModel ( "itemStatistics" );
  9762. Doo::loadModel ( 'statistics' );
  9763. Doo::loadModel ( 'accountItem' );
  9764. $accountItem = new accountItem ();
  9765. $statistics = new statistics ();
  9766. $itemStatistics = new itemStatistics ();
  9767. $receiptDetail = new receiptDetail ();
  9768. $receiptCollectList = $receiptDetail->find ( array (
  9769. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9770. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9771. 'groupby' => 'item,Month(date)',
  9772. 'asArray' => true
  9773. ) );
  9774. $accountList = $accountItem->find ( array (
  9775. 'asArray' => true
  9776. ) );
  9777. // create CollectDetail HTML
  9778. $collectHtml = array ();
  9779. foreach ( $accountList as $key => $value ) {
  9780. $html = "";
  9781. $asum = 0;
  9782. for($i = 1; $i <= 12; $i ++) {
  9783. $falg = true;
  9784. foreach ( $receiptCollectList as $v ) {
  9785. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9786. $asum += $v ['price'];
  9787. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9788. $falg = false;
  9789. break;
  9790. }
  9791. }
  9792. if ($falg)
  9793. $html .= '<td class="taR">-</td>';
  9794. }
  9795. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9796. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9797. }
  9798. $data ['collectHtml'] = $collectHtml;
  9799. // create Adjustment price html
  9800. $receiptCollectList = $receiptDetail->find ( array (
  9801. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9802. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9803. 'groupby' => 'itemCategory,Month(date)',
  9804. 'asArray' => true
  9805. ) );
  9806. $adjustment = array ();
  9807. $collectArray = array (
  9808. '日常相关费用' => array (),
  9809. '差旅相关费用' => array (),
  9810. '培训班费用' => array (),
  9811. '其他' => array ()
  9812. );
  9813. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9814. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9815. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9816. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9817. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9818. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9819. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9820. array_push ( $collectArray ['其他'], $collectHtml );
  9821. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9822. array_push ( $adjustment, $collectHtml );
  9823. // total price html
  9824. $collectHtml = "";
  9825. $total = 0;
  9826. for($i = 1; $i <= 12; $i ++) {
  9827. $sumPrice = 0;
  9828. foreach ( $receiptCollectList as $key => $value ) {
  9829. if ($value ['month'] == $i) {
  9830. $sumPrice += $value ['price'];
  9831. }
  9832. }
  9833. if ($sumPrice == 0)
  9834. $collectHtml .= '<td class="taR">-</td>';
  9835. else
  9836. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9837. $total += $sumPrice;
  9838. }
  9839. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9840. // statistics html
  9841. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9842. if (empty ( $stList ))
  9843. $stList = array (
  9844. 'rePrice' => 0,
  9845. 'agPrice' => 0
  9846. );
  9847. $data ['stList'] = array (
  9848. 'rePrice' => $stList ['rePrice'],
  9849. 'agPrice' => $stList ['agPrice'],
  9850. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9851. );
  9852. $data ['collectArray'] = $collectArray;
  9853. $data ['adjustment'] = $adjustment;
  9854. $data ['totalPrice'] = $collectHtml;
  9855. $data ['totalYear'] = $total;
  9856. $data ['year'] = $year;
  9857. $dateHtml = "";
  9858. $now = date ( "Y" );
  9859. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9860. if ($YEARD <= $now) {
  9861. $dateHtml .= '<option ';
  9862. if ($year == $YEARD) {
  9863. $dateHtml .= 'selected ';
  9864. }
  9865. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9866. }
  9867. }
  9868. $data ['dateHtml'] = $dateHtml;
  9869. $data ['memu'] = "receipt";
  9870. $data ['staff'] = $this->staff;
  9871. $data ['receiptMemu'] = 'personalCollect';
  9872. $data ['verifyId'] = $this->verifyId;
  9873. $data ['executeId'] = $this->executeId;
  9874. // year staff status 2,4
  9875. if ($year < date ( "Y" )) {
  9876. Doo::loadModel ( 'receipt' );
  9877. $receipt = new receipt ();
  9878. $receiptList = $receipt->find ( array (
  9879. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9880. 'asArray' => true
  9881. ) );
  9882. if (empty ( $receiptList )) {
  9883. ob_start ();
  9884. $this->render ( "/admin/saeaCollectArticles", $data );
  9885. $this->cacheFile ( $path );
  9886. die ();
  9887. }
  9888. }
  9889. $this->render ( "/admin/saeaCollectArticles", $data );
  9890. }
  9891. function companyCategoryCollect() {
  9892. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9893. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9894. $this->showCache ( $path );
  9895. Doo::loadModel ( 'L_category' );
  9896. Doo::loadModel ( 'itemStatistics' );
  9897. Doo::loadModel ( 'statistics' );
  9898. $statistics = new statistics ();
  9899. $Lcategory = new L_category ();
  9900. $itemStatistics = new itemStatistics ();
  9901. Doo::loadModel ( "receiptAuthorityManage" );
  9902. $receiptAuthorityManage = new receiptAuthorityManage ();
  9903. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9904. $cidList = array ();
  9905. foreach ( $imcStaff as $key => $value ) {
  9906. array_push ( $cidList, $value ['cid'] );
  9907. }
  9908. $cidString = implode ( ',', $cidList );
  9909. $LcategoryList = $Lcategory->find ( array (
  9910. 'where' => ' cid in (' . $cidString . ')',
  9911. 'asArray' => true
  9912. ) ); // 'staff='.$this->staff[0]['sid']." and
  9913. $itemStatisticsList = $itemStatistics->find ( array (
  9914. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9915. 'where' => " Year(date)=" . $year,
  9916. 'groupby' => 'cid,Month(date)',
  9917. 'asArray' => true
  9918. ) );
  9919. // ceatre companyCollectHtml
  9920. foreach ( $LcategoryList as $value ) {
  9921. $html = "";
  9922. $asum = 0;
  9923. for($i = 1; $i <= 12; $i ++) {
  9924. $falg = true;
  9925. foreach ( $itemStatisticsList as $v ) {
  9926. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9927. $asum += $v ['price'];
  9928. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9929. $falg = false;
  9930. break;
  9931. }
  9932. }
  9933. if ($falg)
  9934. $html .= '<td class="taR">-</td>';
  9935. }
  9936. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9937. $collectHtml [$value ['title']] = array (
  9938. 'html' => $html,
  9939. 'cid' => $value ['cid']
  9940. );
  9941. }
  9942. $data ['companyHtml'] = $collectHtml;
  9943. // total price html
  9944. $collectHtml = "";
  9945. $total = 0;
  9946. for($i = 1; $i <= 12; $i ++) {
  9947. $sumPrice = 0;
  9948. foreach ( $itemStatisticsList as $key => $value ) {
  9949. if ($value ['month'] == $i) {
  9950. $sumPrice += $value ['price'];
  9951. }
  9952. }
  9953. if ($sumPrice == 0)
  9954. $collectHtml .= '<td class="taR">-</td>';
  9955. else
  9956. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9957. $total += $sumPrice;
  9958. }
  9959. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9960. $data ['companyTotalHtml'] = $collectHtml;
  9961. $data ['total'] = $total;
  9962. // statistics html
  9963. // echo $cidString;
  9964. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9965. if (empty ( $stList ))
  9966. $stList = array (
  9967. 'rePrice' => 0,
  9968. 'agPrice' => 0
  9969. );
  9970. $data ['stList'] = array (
  9971. 'rePrice' => $stList ['rePrice'],
  9972. 'agPrice' => $stList ['agPrice'],
  9973. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9974. );
  9975. $data ['year'] = $year;
  9976. $data ['memu'] = "receipt";
  9977. $data ['staff'] = $this->staff;
  9978. $data ['receiptMemu'] = 'companyCategoryCollect';
  9979. $data ['verifyId'] = $this->verifyId;
  9980. $data ['executeId'] = $this->executeId;
  9981. $dateHtml = "";
  9982. $now = date ( "Y" );
  9983. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9984. if ($YEARD <= $now) {
  9985. $dateHtml .= '<option ';
  9986. if ($year == $YEARD) {
  9987. $dateHtml .= 'selected ';
  9988. }
  9989. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9990. }
  9991. }
  9992. $data ['dateHtml'] = $dateHtml;
  9993. // year staff status 2,4
  9994. if ($year < date ( "Y" )) {
  9995. Doo::loadModel ( 'receipt' );
  9996. $receipt = new receipt ();
  9997. $receiptList = $receipt->find ( array (
  9998. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9999. 'asArray' => true
  10000. ) );
  10001. if (empty ( $receiptList )) {
  10002. ob_start ();
  10003. $this->render ( "/admin/saeaCompanyCollect", $data );
  10004. $this->cacheFile ( $path );
  10005. die ();
  10006. }
  10007. }
  10008. $this->render ( "/admin/saeaCompanyCollect", $data );
  10009. }
  10010. function categoryCollectDetail() {
  10011. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10012. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10013. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10014. $this->showCache ( $path ); */
  10015. Doo::loadModel ( 'statistics' );
  10016. $statistics = new statistics ();
  10017. Doo::loadModel ( "receiptDetail" );
  10018. $receiptDetail = new receiptDetail ();
  10019. Doo::loadModel ( 'L_category' );
  10020. $Lcategory = new L_category ();
  10021. Doo::loadModel ( 'accountItem' );
  10022. $accountItem = new accountItem ();
  10023. Doo::loadModel ( "receiptAuthorityManage" );
  10024. $receiptAuthorityManage = new receiptAuthorityManage ();
  10025. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10026. $cidList = array ();
  10027. foreach ( $imcStaff as $key => $value ) {
  10028. array_push ( $cidList, $value ['cid'] );
  10029. }
  10030. $cidString = implode ( ',', $cidList );
  10031. $LcategoryList = $Lcategory->find ( array (
  10032. 'where' => 'cid in (' . $cidString . ')',
  10033. 'asArray' => true
  10034. ) );
  10035. if ($cid == 0) {
  10036. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10037. if ($cid == 0)
  10038. $cid = $LcategoryList [0] ['cid'];
  10039. }
  10040. $data ['LcategoryList'] = $LcategoryList;
  10041. $receiptCollectList = $receiptDetail->find ( array (
  10042. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10043. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10044. 'groupby' => 'item,Month(pastDate)',
  10045. 'asArray' => true
  10046. ) );
  10047. $accountList = $accountItem->find ( array (
  10048. 'asArray' => true
  10049. ) );
  10050. // create CollectDetail HTML
  10051. $collectHtml = array ();
  10052. foreach ( $accountList as $key => $value ) {
  10053. $html = "";
  10054. $asum = 0;
  10055. for($i = 1; $i <= 12; $i ++) {
  10056. $falg = true;
  10057. foreach ( $receiptCollectList as $v ) {
  10058. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10059. $asum += $v ['price'];
  10060. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10061. $falg = false;
  10062. break;
  10063. }
  10064. }
  10065. if ($falg)
  10066. $html .= '<td class="taR">-</td>';
  10067. }
  10068. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10069. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10070. }
  10071. $data ['collectHtml'] = $collectHtml;
  10072. // create Adjustment price html
  10073. $receiptCollectList = $receiptDetail->find ( array (
  10074. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10075. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10076. 'groupby' => 'itemCategory,Month(pastDate)',
  10077. 'asArray' => true
  10078. ) );
  10079. $adjustment = array ();
  10080. $collectArray = array (
  10081. '日常相关费用' => array (),
  10082. '差旅相关费用' => array (),
  10083. '培训班费用' => array (),
  10084. '内部培训费用'=>array(),
  10085. '其他' => array ()
  10086. );
  10087. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10088. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10089. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10090. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10091. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10092. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10093. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10094. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10095. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10096. array_push ( $collectArray ['其他'], $collectHtml );
  10097. $data ['collectArray'] = $collectArray;
  10098. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10099. array_push ( $adjustment, $collectHtml );
  10100. $data ['adjustment'] = $adjustment;
  10101. // total price html
  10102. $collectHtml = "";
  10103. $total = 0;
  10104. for($i = 1; $i <= 12; $i ++) {
  10105. $sumPrice = 0;
  10106. foreach ( $receiptCollectList as $key => $value ) {
  10107. if ($value ['month'] == $i) {
  10108. $sumPrice += $value ['price'];
  10109. }
  10110. }
  10111. if ($sumPrice == 0)
  10112. $collectHtml .= '<td class="taR">-</td>';
  10113. else
  10114. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10115. $total += $sumPrice;
  10116. }
  10117. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10118. // statistics html
  10119. $stList = $statistics->statisticsByCid ( $year, $cid );
  10120. if (empty ( $stList ))
  10121. $stList = array (
  10122. 'rePrice' => 0,
  10123. 'agPrice' => 0
  10124. );
  10125. $data ['stList'] = array (
  10126. 'rePrice' => $stList ['rePrice'],
  10127. 'agPrice' => $stList ['agPrice'],
  10128. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10129. );
  10130. $data ['totalYear'] = $total;
  10131. $data ['year'] = $year;
  10132. $data ['cid'] = $cid;
  10133. $data ['memu'] = "receipt";
  10134. $data ['staff'] = $this->staff;
  10135. $data ['receiptMemu'] = 'companyCategoryCollect';
  10136. $data ['verifyId'] = $this->verifyId;
  10137. $data ['executeId'] = $this->executeId;
  10138. // year staff status 2,4
  10139. /* if ($year < date ( "Y" )) {
  10140. Doo::loadModel ( 'receipt' );
  10141. $receipt = new receipt ();
  10142. $receiptList = $receipt->find ( array (
  10143. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10144. 'asArray' => true
  10145. ) );
  10146. if (empty ( $receiptList )) {
  10147. ob_start ();
  10148. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10149. $this->cacheFile ( $path );
  10150. die ();
  10151. }
  10152. } */
  10153. $dateHtml = "";
  10154. $now = date ( "Y" );
  10155. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10156. if ($YEARD <= $now) {
  10157. $dateHtml .= '<option ';
  10158. if ($year == $YEARD) {
  10159. $dateHtml .= 'selected ';
  10160. }
  10161. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10162. }
  10163. }
  10164. $data ['dateHtml'] = $dateHtml;
  10165. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10166. }
  10167. function staffCollect() {
  10168. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10169. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10170. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10171. // $this->showCache($path);
  10172. Doo::loadModel ( 'statistics' );
  10173. $statistics = new statistics ();
  10174. Doo::loadModel ( "receiptDetail" );
  10175. $receiptDetail = new receiptDetail ();
  10176. Doo::loadModel ( 'L_category' );
  10177. $Lcategory = new L_category ();
  10178. Doo::loadModel ( 'accountItem' );
  10179. $accountItem = new accountItem ();
  10180. Doo::loadModel ( 'staff' );
  10181. $staff = new staff ();
  10182. Doo::loadModel ( 'itemStatistics' );
  10183. $itemStatistics = new itemStatistics ();
  10184. Doo::loadModel ( "receiptAuthorityManage" );
  10185. $receiptAuthorityManage = new receiptAuthorityManage ();
  10186. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10187. $cidList = array ();
  10188. foreach ( $imcStaff as $key => $value ) {
  10189. array_push ( $cidList, $value ['cid'] );
  10190. }
  10191. $cidString = implode ( ',', $cidList );
  10192. $naturecon='';
  10193. if ($nature=='ONJOB'){
  10194. $naturecon=' and (nature!=4 )';
  10195. }elseif($nature=='LEAVEJOB'){
  10196. $naturecon=' and (nature=4 )';
  10197. }else{
  10198. die ( 'illegal request--nature' );
  10199. }
  10200. // statistics html
  10201. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10202. if (empty ( $stList ))
  10203. $stList = array (
  10204. 'rePrice' => 0,
  10205. 'agPrice' => 0
  10206. );
  10207. $data ['stList'] = array (
  10208. 'rePrice' => $stList ['rePrice'],
  10209. 'agPrice' => $stList ['agPrice'],
  10210. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10211. );
  10212. // ---
  10213. $staffList = $staff->find ( array (
  10214. 'where' => 'username !="admin" '.$naturecon,
  10215. 'asArray' => true
  10216. ) );
  10217. $LcategoryList = $Lcategory->find ( array (
  10218. 'asArray' => true
  10219. ) ); // 'staff='.$this->staff[0]['sid']." and
  10220. $itemStatisticsList = $itemStatistics->find ( array (
  10221. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10222. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10223. 'groupby' => 'staff,Month(date)',
  10224. 'asArray' => true
  10225. ) );
  10226. $categoryList = $staff->find ( array (
  10227. 'select' => 'COUNT(*) as count,cid,category',
  10228. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10229. 'groupby' => 'cid',
  10230. 'asArray' => true
  10231. ) );
  10232. // print_r($itemStatisticsList);die;
  10233. // ceatre companyCollectHtml
  10234. foreach ( $categoryList as $vlu ) {
  10235. $count = $vlu ['count'] + 1;
  10236. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10237. $m1 = 0;
  10238. $m2 = 0;
  10239. $m3 = 0;
  10240. $m4 = 0;
  10241. $m5 = 0;
  10242. $m6 = 0;
  10243. $m7 = 0;
  10244. $m8 = 0;
  10245. $m9 = 0;
  10246. $m10 = 0;
  10247. $m11 = 0;
  10248. $m12 = 0;
  10249. $m13 = 0;
  10250. foreach ( $staffList as $value ) {
  10251. if ($vlu ['cid'] == $value ['cid']) {
  10252. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10253. $asum = 0;
  10254. for($i = 1; $i <= 12; $i ++) {
  10255. $falg = true;
  10256. foreach ( $itemStatisticsList as $v ) {
  10257. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10258. if ($v ['month'] == 1)
  10259. $m1 += $v ['price'];
  10260. if ($v ['month'] == 2)
  10261. $m2 += $v ['price'];
  10262. if ($v ['month'] == 3)
  10263. $m3 += $v ['price'];
  10264. if ($v ['month'] == 4)
  10265. $m4 += $v ['price'];
  10266. if ($v ['month'] == 5)
  10267. $m5 += $v ['price'];
  10268. if ($v ['month'] == 6)
  10269. $m6 += $v ['price'];
  10270. if ($v ['month'] == 7)
  10271. $m7 += $v ['price'];
  10272. if ($v ['month'] == 8)
  10273. $m8 += $v ['price'];
  10274. if ($v ['month'] == 9)
  10275. $m9 += $v ['price'];
  10276. if ($v ['month'] == 10)
  10277. $m10 += $v ['price'];
  10278. if ($v ['month'] == 11)
  10279. $m11 += $v ['price'];
  10280. if ($v ['month'] == 12)
  10281. $m12 += $v ['price'];
  10282. $asum += $v ['price'];
  10283. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10284. $falg = false;
  10285. break;
  10286. }
  10287. }
  10288. if ($falg)
  10289. $html .= '<td class="taR">-</td>';
  10290. }
  10291. $m13 += $asum;
  10292. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10293. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10294. 'html' => $html,
  10295. 'sid' => $value ['sid']
  10296. );
  10297. $html = "";
  10298. }
  10299. }
  10300. $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>
  10301. <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>
  10302. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10303. $collectHtml [$vlu ['cid']] = array (
  10304. 'html' => $hl,
  10305. 'sid' => ''
  10306. );
  10307. }
  10308. $data ['companyHtml'] = $collectHtml;
  10309. // total price html
  10310. $collectHtml = "";
  10311. $total = 0;
  10312. for($i = 1; $i <= 12; $i ++) {
  10313. $sumPrice = 0;
  10314. foreach ( $itemStatisticsList as $key => $value ) {
  10315. if ($value ['month'] == $i) {
  10316. $sumPrice += $value ['price'];
  10317. }
  10318. }
  10319. if ($sumPrice == 0)
  10320. $collectHtml .= '<td class="taR">-</td>';
  10321. else
  10322. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10323. $total += $sumPrice;
  10324. }
  10325. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10326. $data ['companyTotalHtml'] = $collectHtml;
  10327. $data ['total'] = $total;
  10328. $data ['nature'] =$nature;
  10329. $data ['year'] = $year;
  10330. $data ['memu'] = "receipt";
  10331. $data ['staff'] = $this->staff;
  10332. $data ['receiptMemu'] = 'companyCategoryCollect';
  10333. $data ['verifyId'] = $this->verifyId;
  10334. $data ['executeId'] = $this->executeId;
  10335. if ($year <= date ( "Y" )) {
  10336. Doo::loadModel ( 'receipt' );
  10337. $receipt = new receipt ();
  10338. $receiptList = $receipt->find ( array (
  10339. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10340. 'asArray' => true
  10341. ) );
  10342. if (empty ( $receiptList )) { // generated files
  10343. ob_start ();
  10344. $this->render ( "/admin/saeaStaffCollectB", $data );
  10345. $this->cacheFile ( $path );
  10346. die ();
  10347. }
  10348. }
  10349. $this->render ( "/admin/saeaStaffCollectB", $data );
  10350. }
  10351. function staffCollectBak() {
  10352. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10353. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10354. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10355. $this->showCache ( $path );
  10356. Doo::loadModel ( 'statistics' );
  10357. $statistics = new statistics ();
  10358. Doo::loadModel ( "receiptDetail" );
  10359. $receiptDetail = new receiptDetail ();
  10360. Doo::loadModel ( 'L_category' );
  10361. $Lcategory = new L_category ();
  10362. Doo::loadModel ( 'accountItem' );
  10363. $accountItem = new accountItem ();
  10364. Doo::loadModel ( 'staff' );
  10365. $staff = new staff ();
  10366. Doo::loadModel ( 'itemStatistics' );
  10367. $itemStatistics = new itemStatistics ();
  10368. $itemStatisticsList = $itemStatistics->find ( array (
  10369. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10370. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10371. 'groupby' => 'staff,itemCategory,Month(date)',
  10372. 'asArray' => true
  10373. ) );
  10374. $itemCategoryList = $itemStatistics->find ( array (
  10375. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10376. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10377. 'groupby' => 'cid,itemCategory,Month(date)',
  10378. 'asArray' => true
  10379. ) );
  10380. $LcategoryList = $Lcategory->find ( array (
  10381. 'asArray' => true
  10382. ) );
  10383. $staffList = $staff->find ( array (
  10384. 'asArray' => true
  10385. ) );
  10386. $htmlArray = array ();
  10387. foreach ( $LcategoryList as $value ) {
  10388. $htmlArray [$value ['title']] = array ();
  10389. foreach ( $staffList as $v ) {
  10390. if ($value ['cid'] == $v ['cid']) {
  10391. $html = "";
  10392. $falg = true;
  10393. $staffSumPrice = 0;
  10394. foreach ( $itemStatisticsList as $a ) {
  10395. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10396. if (empty ( $a ['price'] )) {
  10397. $html .= '<td class="taR">-</td>';
  10398. $falg = false;
  10399. break;
  10400. } else {
  10401. $staffSumPrice += $a ['price'];
  10402. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10403. $falg = false;
  10404. break;
  10405. }
  10406. }
  10407. }
  10408. if ($falg) {
  10409. $html .= '<td class="taR">-</td>';
  10410. $falg = true;
  10411. }
  10412. $falg = true;
  10413. foreach ( $itemStatisticsList as $a ) {
  10414. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10415. if (empty ( $a ['price'] )) {
  10416. $html .= '<td class="taR">-</td>';
  10417. $falg = false;
  10418. break;
  10419. } else {
  10420. $staffSumPrice += $a ['price'];
  10421. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10422. $falg = false;
  10423. break;
  10424. }
  10425. }
  10426. }
  10427. if ($falg) {
  10428. $html .= '<td class="taR">-</td>';
  10429. $falg = true;
  10430. }
  10431. $falg = true;
  10432. foreach ( $itemStatisticsList as $a ) {
  10433. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10434. if (empty ( $a ['price'] )) {
  10435. $html .= '<td class="taR">-</td>';
  10436. $falg = false;
  10437. break;
  10438. } else {
  10439. $staffSumPrice += $a ['price'];
  10440. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10441. $falg = false;
  10442. break;
  10443. }
  10444. }
  10445. }
  10446. if ($falg) {
  10447. $html .= '<td class="taR">-</td>';
  10448. $falg = true;
  10449. }
  10450. $falg = true;
  10451. foreach ( $itemStatisticsList as $a ) {
  10452. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10453. if (! empty ( $a ['price'] )) {
  10454. $staffSumPrice += $a ['price'];
  10455. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10456. $falg = false;
  10457. break;
  10458. } else {
  10459. $html .= '<td class="taR">-</td>';
  10460. $falg = false;
  10461. break;
  10462. }
  10463. }
  10464. }
  10465. if ($falg) {
  10466. $html .= '<td class="taR">-</td>';
  10467. $falg = true;
  10468. }
  10469. $falg = true;
  10470. foreach ( $itemStatisticsList as $a ) {
  10471. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10472. if (! empty ( $a ['price'] )) {
  10473. $staffSumPrice += $a ['price'];
  10474. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10475. $falg = false;
  10476. break;
  10477. } else {
  10478. $html .= '<td class="taR">-</td>';
  10479. $falg = false;
  10480. break;
  10481. }
  10482. }
  10483. }
  10484. if ($falg) {
  10485. $html .= '<td class="taR">-</td>';
  10486. $falg = true;
  10487. }
  10488. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10489. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10490. }
  10491. }
  10492. /* -- --- */
  10493. // 合计费用
  10494. $cateHtml = "";
  10495. $catePrice = 0;
  10496. $cateFalg = true;
  10497. foreach ( $itemCategoryList as $l ) {
  10498. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10499. if (empty ( $l ['price'] )) {
  10500. $cateHtml .= '<td class="colGreen taR">-</td>';
  10501. $cateFalg = false;
  10502. break;
  10503. } else {
  10504. $catePrice += $l ['price'];
  10505. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10506. $cateFalg = false;
  10507. break;
  10508. }
  10509. }
  10510. }
  10511. if ($cateFalg) {
  10512. $cateHtml .= '<td class="colGreen taR">-</td>';
  10513. $cateFalg = true;
  10514. }
  10515. $cateFalg = true;
  10516. foreach ( $itemCategoryList as $l ) {
  10517. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10518. if (empty ( $l ['price'] )) {
  10519. $cateHtml .= '<td class="colGreen taR">-</td>';
  10520. $cateFalg = false;
  10521. break;
  10522. } else {
  10523. $catePrice += $l ['price'];
  10524. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10525. $cateFalg = false;
  10526. break;
  10527. }
  10528. }
  10529. }
  10530. if ($cateFalg) {
  10531. $cateHtml .= '<td class="colGreen taR">-</td>';
  10532. $cateFalg = true;
  10533. }
  10534. $cateFalg = true;
  10535. foreach ( $itemCategoryList as $l ) {
  10536. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10537. if (empty ( $l ['price'] )) {
  10538. $cateHtml .= '<td class="colGreen taR">-</td>';
  10539. $cateFalg = false;
  10540. break;
  10541. } else {
  10542. $catePrice += $l ['price'];
  10543. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10544. $cateFalg = false;
  10545. break;
  10546. }
  10547. }
  10548. }
  10549. if ($cateFalg) {
  10550. $cateHtml .= '<td class="colGreen taR">-</td>';
  10551. $cateFalg = true;
  10552. }
  10553. $cateFalg = true;
  10554. foreach ( $itemCategoryList as $l ) {
  10555. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10556. if (empty ( $l ['price'] )) {
  10557. $cateHtml .= '<td class="colGreen taR">-</td>';
  10558. $cateFalg = false;
  10559. break;
  10560. } else {
  10561. $catePrice += $l ['price'];
  10562. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10563. $cateFalg = false;
  10564. break;
  10565. }
  10566. }
  10567. }
  10568. if ($cateFalg) {
  10569. $cateHtml .= '<td class="colGreen taR">-</td>';
  10570. $cateFalg = true;
  10571. }
  10572. $cateFalg = true;
  10573. foreach ( $itemCategoryList as $l ) {
  10574. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10575. if (empty ( $l ['price'] )) {
  10576. $cateHtml .= '<td class="colGreen taR">-</td>';
  10577. $cateFalg = false;
  10578. break;
  10579. } else {
  10580. $catePrice += $l ['price'];
  10581. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10582. $cateFalg = false;
  10583. break;
  10584. }
  10585. }
  10586. }
  10587. if ($cateFalg) {
  10588. $cateHtml .= '<td class="colGreen taR">-</td>';
  10589. $cateFalg = true;
  10590. }
  10591. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10592. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10593. /* -- --- */
  10594. }
  10595. // print_r($htmlArray);die;
  10596. $data ['htmlArray'] = $htmlArray;
  10597. // statistics html
  10598. $stList = $statistics->getOne ( array (
  10599. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10600. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10601. 'groupby' => 'Month(date)',
  10602. 'asArray' => true
  10603. ) );
  10604. if (empty ( $stList ))
  10605. $stList = array (
  10606. 'rePrice' => 0,
  10607. 'agPrice' => 0
  10608. );
  10609. $data ['stList'] = array (
  10610. 'rePrice' => $stList ['rePrice'],
  10611. 'agPrice' => $stList ['agPrice'],
  10612. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10613. );
  10614. $monthHtml = "";
  10615. for($i = 1; $i <= 12; $i ++) {
  10616. if ($i == $month)
  10617. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10618. else
  10619. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10620. }
  10621. $data ['monthHtml'] = $monthHtml;
  10622. $data ['year'] = $year;
  10623. $data ['month'] = $month;
  10624. $data ['memu'] = "receipt";
  10625. $data ['staff'] = $this->staff;
  10626. $data ['receiptMemu'] = 'companyCategoryCollect';
  10627. $data ['verifyId'] = $this->verifyId;
  10628. $data ['executeId'] = $this->executeId;
  10629. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10630. Doo::loadModel ( 'receipt' );
  10631. $receipt = new receipt ();
  10632. $receiptList = $receipt->find ( array (
  10633. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10634. 'asArray' => true
  10635. ) );
  10636. if (empty ( $receiptList )) { // generated files
  10637. ob_start ();
  10638. $this->render ( "/admin/saeaStaffCollect", $data );
  10639. $this->cacheFile ( $path );
  10640. die ();
  10641. }
  10642. }
  10643. $this->render ( "/admin/saeaStaffCollect", $data );
  10644. }
  10645. /**
  10646. * 日常收支
  10647. */
  10648. function payments() {
  10649. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10650. Doo::loadModel ( "execute" );
  10651. $execute = new execute ();
  10652. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10653. die ( 'illegal request' );
  10654. }
  10655. Doo::loadModel ( "accountBook" );
  10656. $accountBook = new accountBook ();
  10657. Doo::loadModel ( "accountBookStatistics" );
  10658. $accountBookStatistics = new accountBookStatistics ();
  10659. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10660. $list = $accountBook->getAccountBookByLimit ( 10 );
  10661. $data ['date'] = date ( "Y-m-d" );
  10662. $data ['statisticsList'] = $statisticsList;
  10663. $data ['list'] = $list;
  10664. $data ['memu'] = "receipt";
  10665. $data ['staff'] = $this->staff;
  10666. $data ['receiptMemu'] = 'payments';
  10667. $data ['verifyId'] = $this->verifyId;
  10668. $data ['executeId'] = $this->executeId;
  10669. $this->render ( "/expenses/payments", $data );
  10670. }
  10671. function paymentsIncomeDo() {
  10672. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10673. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10674. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10675. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10676. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10677. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10678. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10679. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10680. Doo::loadClass ( 'XDeode' );
  10681. $XDeode = new XDeode ( 5 );
  10682. Doo::loadModel ( "accountBook" );
  10683. Doo::loadModel ( "accountBookStatistics" );
  10684. Doo::loadModel ( 'wasteBook' );
  10685. // 记录流水时银行的转换
  10686. $accountBank = '';
  10687. if ($receivedBank == '纵横广发') {
  10688. $accountBank = 'CGBDeposit';
  10689. } elseif ($receivedBank == '纵横工行') {
  10690. $accountBank = 'ICBCDeposit';
  10691. } elseif ($receivedBank == '华润银行') {
  10692. $accountBank = 'HUADeposit';
  10693. } elseif ($receivedBank == '个人广发') {
  10694. $accountBank = 'PersonalDeposit';
  10695. }
  10696. if (empty ( $accountBank ))
  10697. die ( 'illegal request-bank' );
  10698. //TODO -存款功能 提取
  10699. if($accountType == 11 || $accountType == 12){
  10700. if($accountType == 11){
  10701. $receivedBank = '纵横广发';
  10702. }elseif($accountType == 12){
  10703. $receivedBank = '纵横工行';
  10704. }
  10705. // 添加一条收入
  10706. $accountBook = new accountBook ();
  10707. $accountBook->accountType = $accountType;
  10708. $accountBook->accountMsg = $accountMsg;
  10709. $accountBook->receivedPrice = $receivedPrice;
  10710. $accountBook->receivedMsg = $receivedMsg;
  10711. $accountBook->receivedBank = $receivedBank;
  10712. $accountBook->receivedDate = $receivedDate;
  10713. $accountBook->remarks = $remarks;
  10714. $accountBook->expensesType = 1;
  10715. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10716. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10717. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10718. $inComeId = $accountBook->insert ();
  10719. // 收支汇总-添加一条收入日常汇总
  10720. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10721. $accountBookStatistics = new accountBookStatistics ();
  10722. $item = array (
  10723. 'date' => date ( "Y-m-d" ),
  10724. 'accountType' => $abDetail ['accountType'],
  10725. 'accountMsg' => $abDetail ['accountMsg'],
  10726. 'aid' => $abDetail ['aid'],
  10727. 'inComePrice' => $abDetail ['receivedPrice'],
  10728. 'expensesType' => $abDetail ['expensesType']
  10729. );
  10730. $accountBookStatistics->setAccountBookStatistics ( $item );
  10731. // 添加收入流水
  10732. if($accountType == 11){
  10733. $accountBank = 'CGBDeposit';
  10734. }elseif($accountType == 12){
  10735. $accountBank = 'ICBCDeposit';
  10736. }
  10737. $wasteBook = new wasteBook ();
  10738. $itemWaste = array (
  10739. 'accountPriceShow' => $receivedPrice,
  10740. 'accountPrice' => $receivedPrice,
  10741. 'expensesType' => 1,
  10742. 'accountType' => 6, // 流水类型
  10743. 'dataID' => $inComeId,
  10744. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10745. 'accountBank' => $accountBank,
  10746. 'category' => $this->staff [0] ['category'],
  10747. 'cid' => $this->staff [0] ['cid'],
  10748. 'name' => $this->staff [0] ['username'],
  10749. 'sid' => $this->staff [0] ['sid'],
  10750. 'inputDate' => $receivedDate,
  10751. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10752. 'synPaymentDate'=>1,
  10753. );
  10754. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10755. }
  10756. //TODO --移除理财相关
  10757. // elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10758. // // if ($receivedBank == '个人广发') {
  10759. // // die ( '个人广发 illegal request' );
  10760. // // }
  10761. // // echo $receivedBank;
  10762. // die;
  10763. // // 添加一条收入
  10764. // $accountBook = new accountBook ();
  10765. // $accountBook->accountType = 10;
  10766. // $accountBook->accountMsg = $accountMsg;
  10767. // $accountBook->receivedPrice = $receivedPrice;
  10768. // $accountBook->receivedMsg = $receivedMsg;
  10769. // $accountBook->receivedBank = $receivedBank;
  10770. // $accountBook->receivedDate = $receivedDate;
  10771. // $accountBook->remarks = $remarks;
  10772. // $accountBook->expensesType = 1;
  10773. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10774. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10775. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10776. // $inComeId = $accountBook->insert ();
  10777. // // 收支汇总-添加一条收入日常汇总
  10778. // $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10779. // $accountBookStatistics = new accountBookStatistics ();
  10780. // $item = array (
  10781. // 'date' => date ( "Y-m-d" ),
  10782. // 'accountType' => $abDetail ['accountType'],
  10783. // 'accountMsg' => $abDetail ['accountMsg'],
  10784. // 'aid' => $abDetail ['aid'],
  10785. // 'inComePrice' => $abDetail ['receivedPrice'],
  10786. // 'expensesType' => $abDetail ['expensesType']
  10787. // );
  10788. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10789. // // 添加收入流水
  10790. // $wasteBook = new wasteBook ();
  10791. // $itemWaste = array (
  10792. // 'accountPriceShow' => $receivedPrice,
  10793. // 'accountPrice' => $receivedPrice,
  10794. // 'expensesType' => 1,
  10795. // 'accountType' => 6, // 流水类型
  10796. // 'dataID' => $inComeId,
  10797. // 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10798. // 'accountBank' => $accountBank,
  10799. // 'category' => $this->staff [0] ['category'],
  10800. // 'cid' => $this->staff [0] ['cid'],
  10801. // 'name' => $this->staff [0] ['username'],
  10802. // 'sid' => $this->staff [0] ['sid'],
  10803. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10804. // );
  10805. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10806. // // 添加一条理财支出
  10807. // $accountBank = 'CGBDeposit';
  10808. // $expenditureBank = '纵横广发';
  10809. // if($accountMsg=='个人(GR)'){
  10810. // $expenditureBank = '个人广发';
  10811. // }
  10812. // $dailyExpenditureType = 4;
  10813. // if ($accountType == 9) {
  10814. // $accountBank = 'ICBCDeposit';
  10815. // $expenditureBank = '纵横工行';
  10816. // $dailyExpenditureType = 6;
  10817. // }
  10818. // $accountBook = new accountBook ();
  10819. // $accountBook->expensesType = 2;
  10820. // $accountBook->expenditureType = $dailyExpenditureType;
  10821. // $accountBook->expenditureMsg = $accountMsg;
  10822. // $accountBook->expenditurePrice = $receivedPrice;
  10823. // $accountBook->expenditureBank = $expenditureBank;
  10824. // $accountBook->expenditureDate = $receivedDate;
  10825. // $accountBook->remarks = $remarks;
  10826. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10827. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10828. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10829. // $id = $accountBook->insert ();
  10830. // // 收支汇总-添加一条理财支出汇总
  10831. // $abDetail = $accountBook->getAccountBookByAid ( $id );
  10832. // $accountBookStatistics = new accountBookStatistics ();
  10833. // $item = array (
  10834. // 'date' => date ( "Y-m-d" ),
  10835. // 'accountType' => $abDetail ['accountType'],
  10836. // 'accountMsg' => $abDetail ['accountMsg'],
  10837. // 'aid' => $abDetail ['aid'],
  10838. // 'financingPrice' => - $receivedPrice,
  10839. // 'expensesType' => 3
  10840. // );
  10841. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10842. // //TODO -新增理财为个人时的情况 添加一条支出理财流水
  10843. // $accountTypeWaste = 5;
  10844. // if ($accountMsg == '公司固定') {
  10845. // $accountTypeWaste = 9;
  10846. // } elseif ($accountMsg == '公司活期') {
  10847. // $accountTypeWaste = 10;
  10848. // } elseif ($receivedBank == '个人广发') {
  10849. // $accountTypeWaste = 9;
  10850. // $accountBank = 'ICBCDeposit';
  10851. // }
  10852. // $itemWaste = array (
  10853. // 'expensesType' => 2,
  10854. // 'accountType' => $accountTypeWaste,
  10855. // 'accountPriceShow' => $receivedPrice,
  10856. // 'accountPrice' => - $receivedPrice,
  10857. // 'dataID' => $id,
  10858. // 'dailyExpenditureType' => $dailyExpenditureType,
  10859. // 'accountBank' => $accountBank,
  10860. // 'category' => $this->staff [0] ['category'],
  10861. // 'cid' => $this->staff [0] ['cid'],
  10862. // 'name' => $this->staff [0] ['username'],
  10863. // 'sid' => $this->staff [0] ['sid'],
  10864. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10865. // );
  10866. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10867. // }
  10868. elseif ($accountType == 1) {
  10869. // if ($receivedBank == '个人广发')
  10870. // die ( 'illegal request--no man' );
  10871. // 添加一条收入
  10872. $accountBook = new accountBook ();
  10873. $accountBook->accountType = $accountType;
  10874. $accountBook->accountMsg = $accountMsg;
  10875. $accountBook->receivedPrice = $receivedPrice;
  10876. $accountBook->receivedMsg = $receivedMsg;
  10877. $accountBook->receivedBank = $receivedBank;
  10878. $accountBook->receivedDate = $receivedDate;
  10879. $accountBook->remarks = $remarks;
  10880. $accountBook->expensesType = 1;
  10881. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10882. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10883. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10884. $id = $accountBook->insert ();
  10885. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10886. // 收支汇总-添加一条收入日常汇总
  10887. $accountBookStatistics = new accountBookStatistics ();
  10888. $item = array (
  10889. 'date' => date ( "Y-m-d" ),
  10890. 'accountType' => $abDetail ['accountType'],
  10891. 'accountMsg' => $abDetail ['accountMsg'],
  10892. 'aid' => $abDetail ['aid'],
  10893. 'expensesType' => $abDetail ['expensesType']
  10894. );
  10895. if ($abDetail ['accountType'] == 8) {
  10896. $item += array (
  10897. 'inComePrice' => $abDetail ['receivedPrice']
  10898. );
  10899. } else {
  10900. $item += array (
  10901. 'inComePrice' => $abDetail ['receivedPrice']
  10902. );
  10903. }
  10904. $accountBookStatistics->setAccountBookStatistics ( $item );
  10905. // 流水存储方向
  10906. $itemWaste = array (
  10907. 'accountType' => 6
  10908. ); // 流水类型
  10909. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10910. // }else
  10911. if ($accountMsg == '活期理财收益') {
  10912. $itemWaste = array (
  10913. 'accountType' => 10
  10914. ); // 流水类型
  10915. }
  10916. // 添加收入流水
  10917. $wasteBook = new wasteBook ();
  10918. $itemWaste += array (
  10919. 'accountPrice' => $receivedPrice,
  10920. 'accountPriceShow' => $receivedPrice,
  10921. 'expensesType' => 1,
  10922. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10923. 'dataID' => $id,
  10924. 'accountBank' => $accountBank,
  10925. 'category' => $this->staff [0] ['category'],
  10926. 'cid' => $this->staff [0] ['cid'],
  10927. 'name' => $this->staff [0] ['username'],
  10928. 'sid' => $this->staff [0] ['sid'],
  10929. 'inputDate' => $receivedDate,
  10930. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10931. 'synPaymentDate'=>1,
  10932. );
  10933. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10934. } else { // 普通日常收入处理
  10935. // 添加一条收入
  10936. $accountBook = new accountBook ();
  10937. $accountBook->accountType = $accountType;
  10938. $accountBook->accountMsg = $accountMsg;
  10939. $accountBook->receivedPrice = $receivedPrice;
  10940. $accountBook->receivedMsg = $receivedMsg;
  10941. $accountBook->receivedBank = $receivedBank;
  10942. $accountBook->receivedDate = $receivedDate;
  10943. $accountBook->remarks = $remarks;
  10944. $accountBook->expensesType = 1;
  10945. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10946. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10947. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10948. $id = $accountBook->insert ();
  10949. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10950. // 收支汇总-添加一条收入日常汇总
  10951. $accountBookStatistics = new accountBookStatistics ();
  10952. $item = array (
  10953. 'date' => date ( "Y-m-d" ),
  10954. 'accountType' => $abDetail ['accountType'],
  10955. 'accountMsg' => $abDetail ['accountMsg'],
  10956. 'aid' => $abDetail ['aid'],
  10957. 'expensesType' => $abDetail ['expensesType']
  10958. );
  10959. if ($abDetail ['accountType'] == 8) {
  10960. $item += array (
  10961. 'inComePrice' => $abDetail ['receivedPrice']
  10962. );
  10963. } else {
  10964. $item += array (
  10965. 'inComePrice' => $abDetail ['receivedPrice']
  10966. );
  10967. }
  10968. $accountBookStatistics->setAccountBookStatistics ( $item );
  10969. // 添加收入流水
  10970. // $itemWaste = array (
  10971. // 'accountPrice' => $receivedPrice
  10972. // );
  10973. // if ($receivedBank == '个人广发') {
  10974. // $itemWaste = array (
  10975. // 'accountPrice' => - $receivedPrice
  10976. // );
  10977. // }
  10978. $wasteBook = new wasteBook ();
  10979. $itemWaste = array (
  10980. 'accountPriceShow' => $receivedPrice,
  10981. 'accountPrice' => $receivedPrice,
  10982. 'expensesType' => 1,
  10983. 'accountType' => 6, // 流水类型
  10984. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10985. 'dataID' => $id,
  10986. 'accountBank' => $accountBank,
  10987. 'category' => $this->staff [0] ['category'],
  10988. 'cid' => $this->staff [0] ['cid'],
  10989. 'name' => $this->staff [0] ['username'],
  10990. 'sid' => $this->staff [0] ['sid'],
  10991. 'inputDate' => $receivedDate,
  10992. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10993. 'synPaymentDate'=>1,
  10994. );
  10995. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10996. }
  10997. }
  10998. return '/payments';
  10999. }
  11000. function paymentsExpenditureDo() {
  11001. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11002. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11003. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11004. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11005. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11006. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11007. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11008. // 理财支出特殊处理
  11009. Doo::loadModel ( "accountBook" );
  11010. Doo::loadModel ( "accountBookStatistics" );
  11011. Doo::loadModel ( 'wasteBook' );
  11012. $accountBank = '';
  11013. if ($expenditureBank == '纵横广发') {
  11014. $accountBank = 'CGBDeposit';
  11015. } elseif ($expenditureBank == '纵横工行') {
  11016. $accountBank = 'ICBCDeposit';
  11017. } elseif ($expenditureBank == '华润银行') {
  11018. $accountBank = 'HUADeposit';
  11019. } elseif ($expenditureBank == '个人广发') {
  11020. $accountBank = 'PersonalDeposit';
  11021. }
  11022. if (empty ( $accountBank ))
  11023. die ( 'illegal request' );
  11024. if($expenditureType == 8 || $expenditureType == 9){
  11025. // if($expenditureType == 8 ){
  11026. // $expenditureBank='纵横广发';
  11027. // }elseif($expenditureType == 9){
  11028. // $expenditureBank='纵横工行';
  11029. // }
  11030. // // 添加一笔日常支出
  11031. // $accountBook = new accountBook ();
  11032. // $accountBook->expensesType = 2;
  11033. // $accountBook->expenditureType = $expenditureType;
  11034. // $accountBook->expenditureMsg = $expenditureMsg;
  11035. // $accountBook->expenditurePrice = $expenditurePrice;
  11036. // $accountBook->expenditureBank = $expenditureBank;
  11037. // $accountBook->expenditureDate = $expenditureDate;
  11038. // $accountBook->remarks = $remarks;
  11039. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11040. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11041. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11042. // $expenditureId = $accountBook->insert ();
  11043. // // 添加日常支出汇总
  11044. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11045. // $accountBookStatistics = new accountBookStatistics ();
  11046. // $item = array (
  11047. // 'date' => date ( "Y-m-d" ),
  11048. // 'expenditureType' => $abDetail ['expenditureType'],
  11049. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11050. // 'aid' => $abDetail ['aid'],
  11051. // 'payPrice' => $abDetail ['expenditurePrice'],
  11052. // 'expensesType' => $abDetail ['expensesType']
  11053. // );
  11054. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11055. // // 公司日常支出流水
  11056. // if($expenditureType == 8 ){
  11057. // $accountBank = 'CGBDeposit';
  11058. // }elseif($expenditureType == 9){
  11059. // $accountBank = 'ICBCDeposit';
  11060. // }
  11061. // if($accountBank=='CGBDeposit'){
  11062. // $dailyExpenditureType='8';
  11063. // }elseif($accountBank=='ICBCDeposit'){
  11064. // $dailyExpenditureType='9';
  11065. // }elseif($accountBank=='PersonalDeposit'){
  11066. // $dailyExpenditureType='10';
  11067. // }elseif($accountBank=='HUADeposit'){
  11068. // $dailyExpenditureType='11';
  11069. // }
  11070. // $wasteBook = new wasteBook ();
  11071. // $itemWaste = array (
  11072. // 'expensesType' => 2,
  11073. // 'accountType' => 5,
  11074. // 'dailyExpenditureType' => $dailyExpenditureType,
  11075. // 'accountPriceShow' => $expenditurePrice,
  11076. // 'accountPrice' => - $expenditurePrice,
  11077. // 'dataID' => $expenditureId,
  11078. // 'accountBank' => $accountBank,
  11079. // 'category' => $this->staff [0] ['category'],
  11080. // 'cid' => $this->staff [0] ['cid'],
  11081. // 'name' => $this->staff [0] ['username'],
  11082. // 'sid' => $this->staff [0] ['sid'],
  11083. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11084. // );
  11085. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11086. //TODO 日常支出 个人理财情况的相关修改
  11087. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11088. // if ($expenditureBank == '个人广发') {
  11089. // die ( '个人广发 illegal request' );
  11090. // }
  11091. // echo $expenditureMsg;
  11092. die;
  11093. // // 添加一笔日常支出
  11094. // $accountBook = new accountBook ();
  11095. // $accountBook->expensesType = 2;
  11096. // $accountBook->expenditureType = 7;
  11097. // $accountBook->expenditureMsg = $expenditureMsg;
  11098. // $accountBook->expenditurePrice = $expenditurePrice;
  11099. // $accountBook->expenditureBank = $expenditureBank;
  11100. // $accountBook->expenditureDate = $expenditureDate;
  11101. // $accountBook->remarks = $remarks;
  11102. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11103. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11104. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11105. // $expenditureId = $accountBook->insert ();
  11106. // // 添加日常支出汇总
  11107. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11108. // $accountBookStatistics = new accountBookStatistics ();
  11109. // $item = array (
  11110. // 'date' => date ( "Y-m-d" ),
  11111. // 'expenditureType' => $abDetail ['expenditureType'],
  11112. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11113. // 'aid' => $abDetail ['aid'],
  11114. // 'payPrice' => $abDetail ['expenditurePrice'],
  11115. // 'expensesType' => $abDetail ['expensesType']
  11116. // );
  11117. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11118. // // 公司日常支出流水
  11119. // $wasteBook = new wasteBook ();
  11120. // $itemWaste = array (
  11121. // 'accountPrice' => - $expenditurePrice
  11122. // );
  11123. // if($expenditureMsg!='个人(GR)'){
  11124. // if ($expenditureBank == '个人广发') {
  11125. // $itemWaste = array (
  11126. // 'accountPrice' => $expenditurePrice
  11127. // );
  11128. // }
  11129. // }
  11130. // $itemWaste += array (
  11131. // 'expensesType' => 2,
  11132. // 'accountType' => 5,
  11133. // 'dailyExpenditureType' => $expenditureType,
  11134. // 'accountPriceShow' => $expenditurePrice,
  11135. // 'accountPrice' => - $expenditurePrice,
  11136. // 'dataID' => $expenditureId,
  11137. // 'accountBank' => $accountBank,
  11138. // 'category' => $this->staff [0] ['category'],
  11139. // 'cid' => $this->staff [0] ['cid'],
  11140. // 'name' => $this->staff [0] ['username'],
  11141. // 'sid' => $this->staff [0] ['sid'],
  11142. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11143. // );
  11144. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11145. // // 添加一笔理财收入
  11146. // $accountBank = 'CGBDeposit';
  11147. // $dailyIncomeType = 7;
  11148. // $receivedBank = '纵横广发';
  11149. // if ($expenditureType == 6) {
  11150. // $accountBank = 'ICBCDeposit';
  11151. // $receivedBank = '纵横工行';
  11152. // $dailyIncomeType = 9;
  11153. // }elseif($expenditureMsg=='个人(GR)'){
  11154. // $receivedBank = '个人广发';
  11155. // }
  11156. // $accountBook = new accountBook ();
  11157. // $accountBook->expensesType = 1;
  11158. // $accountBook->accountType = $dailyIncomeType;
  11159. // $accountBook->accountMsg = $expenditureMsg;
  11160. // $accountBook->receivedPrice = $expenditurePrice;
  11161. // $accountBook->receivedBank = $receivedBank;
  11162. // $accountBook->receivedDate = $expenditureDate;
  11163. // $accountBook->remarks = $remarks;
  11164. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11165. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11166. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11167. // $id = $accountBook->insert ();
  11168. // // 添加日常理财收入汇总
  11169. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11170. // $accountBookStatistics = new accountBookStatistics ();
  11171. // $item = array (
  11172. // 'date' => date ( "Y-m-d" ),
  11173. // 'expenditureType' => $abDetail ['expenditureType'],
  11174. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11175. // 'aid' => $abDetail ['aid'],
  11176. // 'financingPrice' => $expenditurePrice,
  11177. // 'expensesType' => 3
  11178. // );
  11179. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11180. // //TODO 修改理财收入 添加一笔收入流水
  11181. // if ($expenditureMsg == '公司固定') {
  11182. // $accountTypeWaste = 9;
  11183. // } elseif ($expenditureMsg == '公司活期') {
  11184. // $accountTypeWaste = 10;
  11185. // } elseif ($expenditureMsg == '个人(GR)') {
  11186. // $accountTypeWaste = 9;
  11187. // $accountBank = 'ICBCDeposit';
  11188. // }
  11189. // $itemWaste = array (
  11190. // 'expensesType' => 1,
  11191. // 'accountType' => $accountTypeWaste,
  11192. // 'accountPriceShow' => $expenditurePrice,
  11193. // 'accountPrice' => $expenditurePrice,
  11194. // 'dataID' => $id,
  11195. // 'dailyIncomeType' => $dailyIncomeType,
  11196. // 'accountBank' => $accountBank,
  11197. // 'category' => $this->staff [0] ['category'],
  11198. // 'cid' => $this->staff [0] ['cid'],
  11199. // 'name' => $this->staff [0] ['username'],
  11200. // 'sid' => $this->staff [0] ['sid'],
  11201. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11202. // );
  11203. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11204. } else {
  11205. // 添加一笔日常支出
  11206. $accountBook = new accountBook ();
  11207. $accountBook->expensesType = 2;
  11208. $accountBook->expenditureType = $expenditureType;
  11209. $accountBook->expenditureMsg = $expenditureMsg;
  11210. $accountBook->expenditurePrice = $expenditurePrice;
  11211. $accountBook->expenditureBank = $expenditureBank;
  11212. $accountBook->expenditureDate = $expenditureDate;
  11213. $accountBook->remarks = $remarks;
  11214. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11215. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11216. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11217. $id = $accountBook->insert ();
  11218. // 添加日常支出汇总
  11219. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11220. $accountBookStatistics = new accountBookStatistics ();
  11221. $item = array (
  11222. 'date' => date ( "Y-m-d" ),
  11223. 'expenditureType' => $abDetail ['expenditureType'],
  11224. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11225. 'aid' => $abDetail ['aid'],
  11226. 'expensesType' => $abDetail ['expensesType']
  11227. );
  11228. if ($expenditureType == 5) {
  11229. $item += array (
  11230. 'payPrice' => - $abDetail ['expenditurePrice']
  11231. );
  11232. } else {
  11233. $item += array (
  11234. 'payPrice' => $abDetail ['expenditurePrice']
  11235. );
  11236. }
  11237. $accountBookStatistics->setAccountBookStatistics ( $item );
  11238. // 公司日常支出流水
  11239. $wasteBook = new wasteBook ();
  11240. $itemWaste = array (
  11241. 'accountPrice' => - $expenditurePrice
  11242. );
  11243. if ($expenditureBank == '个人广发') {
  11244. $itemWaste = array (
  11245. 'accountPrice' => $expenditurePrice
  11246. );
  11247. }
  11248. $itemWaste += array (
  11249. 'expensesType' => 2,
  11250. 'accountType' => 5,
  11251. 'accountPriceShow' => $expenditurePrice,
  11252. 'dataID' => $id,
  11253. 'dailyExpenditureType' => $expenditureType,
  11254. 'accountBank' => $accountBank,
  11255. 'category' => $this->staff [0] ['category'],
  11256. 'cid' => $this->staff [0] ['cid'],
  11257. 'name' => $this->staff [0] ['username'],
  11258. 'sid' => $this->staff [0] ['sid'],
  11259. 'inputDate' => date ( "Y-m-d H:i:s" )
  11260. );
  11261. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11262. }
  11263. }
  11264. return '/payments';
  11265. }
  11266. /**
  11267. * 添加支出
  11268. */
  11269. function paymentsExpenditureDo_() {
  11270. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11271. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11272. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11273. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11274. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11275. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11276. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11277. $dailyExpenditureType = '';
  11278. $accountTypeWaste = 5;
  11279. $accountBank = '';
  11280. if ($expenditureBank == '纵横广发') {
  11281. $accountBank = 'CGBDeposit';
  11282. } elseif ($expenditureBank == '纵横工行') {
  11283. $accountBank = 'ICBCDeposit';
  11284. } elseif ($expenditureBank == '华润银行') {
  11285. $accountBank = 'HUADeposit';
  11286. } elseif ($expenditureBank == '个人广发') {
  11287. $accountBank = 'PersonalDeposit';
  11288. }
  11289. if (empty ( $accountBank ))
  11290. die ( 'illegal request' );
  11291. $itemWaste = array (
  11292. 'accountPrice' => - $expenditurePrice
  11293. );
  11294. if ($expenditureBank == '个人广发') {
  11295. $itemWaste = array (
  11296. 'accountPrice' => $expenditurePrice
  11297. );
  11298. }
  11299. if ($expenditureType == 4 || $expenditureType == 6) {
  11300. $dailyExpenditureType = 4;
  11301. if ($expenditureMsg == '公司固定') {
  11302. $accountTypeWaste = 9;
  11303. } elseif ($expenditureMsg == '公司活期') {
  11304. $accountTypeWaste = 10;
  11305. } elseif ($expenditureMsg == '个人(GR)') {
  11306. $accountBank = 'PersonalDeposit';
  11307. }
  11308. $itemWaste = array (
  11309. 'accountPrice' => $expenditurePrice
  11310. );
  11311. } elseif ($expenditureType == 1) {
  11312. $dailyExpenditureType = 1;
  11313. } elseif ($expenditureType == 2) {
  11314. $dailyExpenditureType = 2;
  11315. } elseif ($expenditureType == 3) {
  11316. $dailyExpenditureType = 3;
  11317. } elseif ($expenditureType == 5) {
  11318. $dailyExpenditureType = 5;
  11319. }
  11320. if (empty ( $dailyExpenditureType ))
  11321. die ( 'illegal request' );
  11322. Doo::loadModel ( "accountBook" );
  11323. $accountBook = new accountBook ();
  11324. $accountBook->expenditureType = $expenditureType;
  11325. $accountBook->expenditureMsg = $expenditureMsg;
  11326. $accountBook->expenditurePrice = $expenditurePrice;
  11327. $accountBook->expenditureBank = $expenditureBank;
  11328. $accountBook->expenditureDate = $expenditureDate;
  11329. $accountBook->remarks = $remarks;
  11330. $accountBook->expensesType = 2;
  11331. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11332. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11333. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11334. $id = $accountBook->insert ();
  11335. //
  11336. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11337. Doo::loadModel ( "accountBookStatistics" );
  11338. $accountBookStatistics = new accountBookStatistics ();
  11339. $item = array (
  11340. 'date' => date ( "Y-m-d" ),
  11341. 'expenditureType' => $abDetail ['expenditureType'],
  11342. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11343. 'aid' => $abDetail ['aid']
  11344. );
  11345. if ($abDetail ['expensesType'] == 2) {
  11346. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11347. $item += array (
  11348. 'financingPrice' => $expenditurePrice,
  11349. 'expensesType' => 3
  11350. );
  11351. } elseif ($abDetail ['expenditureType'] == 5) {
  11352. $item += array (
  11353. 'payPrice' => $abDetail ['expenditurePrice'],
  11354. 'expensesType' => $abDetail ['expensesType']
  11355. );
  11356. } else {
  11357. $item += array (
  11358. 'payPrice' => $abDetail ['expenditurePrice'],
  11359. 'expensesType' => $abDetail ['expensesType']
  11360. );
  11361. }
  11362. }
  11363. $accountBookStatistics->setAccountBookStatistics ( $item );
  11364. // 公司流水记录
  11365. Doo::loadModel ( 'wasteBook' );
  11366. $wasteBook = new wasteBook ();
  11367. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11368. // 银行
  11369. if (empty ( $abDetail )) {
  11370. $itemWaste += array (
  11371. 'accountPriceShow' => $expenditurePrice,
  11372. 'dataID' => $id,
  11373. 'expensesType' => 2,
  11374. 'accountType' => $accountTypeWaste,
  11375. 'dailyExpenditureType' => $expenditureType,
  11376. 'accountBank' => $accountBank,
  11377. 'category' => $this->staff [0] ['category'],
  11378. 'cid' => $this->staff [0] ['cid'],
  11379. 'name' => $this->staff [0] ['username'],
  11380. 'sid' => $this->staff [0] ['sid'],
  11381. 'inputDate' => date ( "Y-m-d H:i:s" )
  11382. );
  11383. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11384. }
  11385. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11386. if ($expenditureType == 4 || $expenditureType == 6) {
  11387. $accountBank = 'CGBDeposit';
  11388. $dailyIncomeType = 7;
  11389. $receivedBank = '纵横广发';
  11390. if ($expenditureType == 6) {
  11391. $accountBank = 'ICBCDeposit';
  11392. $receivedBank = '纵横工行';
  11393. $dailyIncomeType = 9;
  11394. }
  11395. // 添加一笔收入
  11396. $accountBook = new accountBook ();
  11397. $accountBook->accountType = $dailyIncomeType;
  11398. $accountBook->accountMsg = $expenditureMsg;
  11399. $accountBook->receivedPrice = $expenditurePrice;
  11400. $accountBook->receivedBank = $receivedBank;
  11401. $accountBook->receivedDate = $expenditureDate;
  11402. $accountBook->remarks = $remarks;
  11403. $accountBook->expensesType = 1;
  11404. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11405. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11406. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11407. $id = $accountBook->insert ();
  11408. // 添加一笔收入流水
  11409. $itemWaste = array (
  11410. 'accountPriceShow' => $expenditurePrice,
  11411. 'accountPrice' => - $expenditurePrice,
  11412. 'dataID' => $id,
  11413. 'expensesType' => 1,
  11414. 'accountType' => $accountTypeWaste,
  11415. 'dailyIncomeType' => $dailyIncomeType,
  11416. 'accountBank' => $accountBank,
  11417. 'category' => $this->staff [0] ['category'],
  11418. 'cid' => $this->staff [0] ['cid'],
  11419. 'name' => $this->staff [0] ['username'],
  11420. 'sid' => $this->staff [0] ['sid'],
  11421. 'inputDate' => date ( "Y-m-d H:i:s" )
  11422. );
  11423. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11424. }
  11425. }
  11426. return '/payments';
  11427. }
  11428. /**
  11429. * 所有收支
  11430. */
  11431. function paymentsAchieve() {
  11432. $page_size = 12;
  11433. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11434. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11435. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11436. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11437. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11438. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11439. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11440. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11441. Doo::loadModel ( "accountBookStatistics" );
  11442. $accountBookStatistics = new accountBookStatistics ();
  11443. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11444. $data ['statisticsList'] = $statisticsList;
  11445. Doo::loadModel ( "accountBook" );
  11446. $accountBook = new accountBook ();
  11447. $con = '';
  11448. if ($expensesType == 'INCOME')
  11449. $con = ' and expensesType=1 ';
  11450. elseif ($expensesType == 'PAY')
  11451. $con = ' and expensesType=2 ';
  11452. $dateArr = explode ( ':', $date );
  11453. $D1 = $dateString = '';
  11454. $D2 = '';
  11455. if (! empty ( $date )) {
  11456. $D1 = $dateArr [0];
  11457. if (isset ( $dateArr [1] ))
  11458. $D2 = $dateArr [1];
  11459. else
  11460. $D2 = '';
  11461. $dateString = $D1 . " : " . $D2;
  11462. }
  11463. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11464. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11465. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11466. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11467. if (! empty ( $price ))
  11468. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11469. if ($submitType == 1) {
  11470. if ($accountType != '') {
  11471. $expenditureType = '';
  11472. $con .= ' and accountType=' . $accountType;
  11473. if (! empty ( $accountMsg ))
  11474. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11475. }
  11476. } elseif ($submitType == 2) {
  11477. if ($expenditureType != '') {
  11478. $accountType = $accountMsg = '';
  11479. $con .= ' and expenditureType=' . $expenditureType;
  11480. }
  11481. } else {
  11482. $accountType = $accountMsg = $expenditureType = '';
  11483. }
  11484. $sql = "" . $con;
  11485. $action = "paymentsAchieve";
  11486. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11487. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11488. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11489. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11490. $data ['expenditureType'] = $expenditureType;
  11491. $data ['accountMsg'] = $accountMsg;
  11492. $data ['accountType'] = $accountType;
  11493. $data ['inputDate'] = $date;
  11494. $data ['price'] = $price;
  11495. $data ['expensesType'] = $expensesType;
  11496. $data ['page'] = $pageinfo;
  11497. $data ['list'] = $list;
  11498. $data ['memu'] = "receipt";
  11499. $data ['staff'] = $this->staff;
  11500. $data ['receiptMemu'] = 'payments';
  11501. $data ['verifyId'] = $this->verifyId;
  11502. $data ['executeId'] = $this->executeId;
  11503. $this->render ( "/expenses/paymentsAchieve", $data );
  11504. }
  11505. function paymentsIncomeUpdateDo() {
  11506. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11507. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11508. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11509. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11510. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11511. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11512. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11513. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11514. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11515. Doo::loadClass ( 'XDeode' );
  11516. $XDeode = new XDeode ( 5 );
  11517. $aid = $XDeode->decode ( $aidKey );
  11518. Doo::loadModel ( "accountBook" );
  11519. $accountBook = new accountBook ();
  11520. //
  11521. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11522. $price = $receivedPrice - $abDetail [inComePrice];
  11523. Doo::loadModel ( "accountBookStatistics" );
  11524. $accountBookStatistics = new accountBookStatistics ();
  11525. if ($abDetail ['accountType'] == 7) {
  11526. $item += array (
  11527. 'date' => date ( "Y-m-d" ),
  11528. 'financingPrice' => - $price,
  11529. 'expensesType' => 3,
  11530. 'aid' => $abDetail ['aid']
  11531. );
  11532. } elseif ($abDetail ['accountType'] == 8) {
  11533. $item += array (
  11534. 'date' => date ( "Y-m-d" ),
  11535. 'expensesType' => $abDetail ['expensesType'],
  11536. 'inComePrice' => - $price,
  11537. 'aid' => $abDetail ['aid']
  11538. );
  11539. } else {
  11540. $item = array (
  11541. 'date' => date ( "Y-m-d" ),
  11542. 'expensesType' => $abDetail ['expensesType'],
  11543. 'inComePrice' => $price,
  11544. 'aid' => $abDetail ['aid']
  11545. );
  11546. }
  11547. $accountBookStatistics->setAccountBookStatistics ( $item );
  11548. $accountBook->accountType = $accountType;
  11549. $accountBook->accountMsg = $accountMsg;
  11550. $accountBook->receivedPrice = $receivedPrice;
  11551. $accountBook->receivedMsg = $receivedMsg;
  11552. $accountBook->receivedBank = $receivedBank;
  11553. $accountBook->receivedDate = $receivedDate;
  11554. $accountBook->remarks = $remarks;
  11555. $accountBook->aid = $aid;
  11556. $accountBook->update ();
  11557. }
  11558. return '/paymentsAchieve';
  11559. }
  11560. function paymentsExpenditureEdiDo() {
  11561. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11562. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11563. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11564. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11565. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11566. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11567. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11568. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11569. Doo::loadClass ( 'XDeode' );
  11570. $XDeode = new XDeode ( 5 );
  11571. $aid = $XDeode->decode ( $aidKey );
  11572. Doo::loadModel ( "accountBook" );
  11573. $accountBook = new accountBook ();
  11574. // 汇总信息
  11575. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11576. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11577. Doo::loadModel ( "accountBookStatistics" );
  11578. $accountBookStatistics = new accountBookStatistics ();
  11579. if ($abDetail ['expenditureType'] == 4) {
  11580. $item += array (
  11581. 'date' => date ( "Y-m-d" ),
  11582. 'financingPrice' => $price,
  11583. 'expensesType' => 3,
  11584. 'aid' => $abDetail ['aid']
  11585. );
  11586. } elseif ($abDetail ['expenditureType'] == 5) {
  11587. $item += array (
  11588. 'date' => date ( "Y-m-d" ),
  11589. 'expensesType' => $abDetail ['expensesType'],
  11590. 'payPrice' => $price,
  11591. 'aid' => $abDetail ['aid']
  11592. );
  11593. } else {
  11594. $item = array (
  11595. 'date' => date ( "Y-m-d" ),
  11596. 'expensesType' => $abDetail ['expensesType'],
  11597. 'payPrice' => $price,
  11598. 'aid' => $abDetail ['aid']
  11599. );
  11600. }
  11601. $accountBookStatistics->setAccountBookStatistics ( $item );
  11602. //
  11603. $accountBook->expenditureType = $expenditureType;
  11604. $accountBook->expenditureMsg = $expenditureMsg;
  11605. $accountBook->expenditurePrice = $expenditurePrice;
  11606. $accountBook->expenditureBank = $expenditureBank;
  11607. $accountBook->remarks = $remarks;
  11608. $accountBook->expenditureDate = $expenditureDate;
  11609. $accountBook->aid = $aid;
  11610. $id = $accountBook->update ();
  11611. }
  11612. return '/paymentsAchieve';
  11613. }
  11614. function paymentsDelDo() {
  11615. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11616. if (! empty ( $aidKey )) {
  11617. Doo::loadClass ( 'XDeode' );
  11618. $XDeode = new XDeode ( 5 );
  11619. $aid = $XDeode->decode ( $aidKey );
  11620. Doo::loadModel ( "accountBook" );
  11621. $accountBook = new accountBook ();
  11622. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11623. if (empty ( $abDetail ))
  11624. die ( 'illegal request' );
  11625. // 删除收支
  11626. Doo::loadModel ( "accountBookStatistics" );
  11627. $accountBookStatistics = new accountBookStatistics ();
  11628. $item = array (
  11629. 'date' => date ( "Y-m-d" ),
  11630. 'aid' => $abDetail ['aid']
  11631. );
  11632. $accountType = '';
  11633. if ($abDetail ['expensesType'] == 1) {
  11634. $accountType = 6;
  11635. if ($abDetail ['accountType'] != 7) {
  11636. $item += array (
  11637. 'expensesType' => $abDetail ['expensesType'],
  11638. 'inComePrice' => - $abDetail ['receivedPrice']
  11639. );
  11640. } else {
  11641. $item += array (
  11642. 'financingPrice' => $abDetail ['receivedPrice'],
  11643. 'expensesType' => 3
  11644. );
  11645. }
  11646. } elseif ($abDetail ['expensesType'] == 2) {
  11647. $accountType = 5;
  11648. if ($abDetail ['accountType'] != 7) {
  11649. $item += array (
  11650. 'expensesType' => $abDetail ['expensesType'],
  11651. 'payPrice' => - $abDetail ['expenditurePrice']
  11652. );
  11653. } else {
  11654. $item += array (
  11655. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11656. 'expensesType' => 3
  11657. );
  11658. }
  11659. }
  11660. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11661. if ($abDetail ['expenditureMsg'] == '公司固定')
  11662. $accountType = 9;
  11663. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11664. $accountType = 10;
  11665. }
  11666. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11667. if ($abDetail ['accountMsg'] == '公司固定')
  11668. $accountType = 9;
  11669. elseif ($abDetail ['accountMsg'] == '公司活期')
  11670. $accountType = 10;
  11671. }
  11672. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11673. $accountType = 10;
  11674. }
  11675. $accountBookStatistics->setAccountBookStatistics ( $item );
  11676. $accountBook->delete ( array (
  11677. 'where' => 'aid=' . $aid,
  11678. 'limit' => 1
  11679. ) );
  11680. // 删除收入流水
  11681. //TODO 2020-07-23 删除新增理财和银行存款流水
  11682. if (! empty ( $accountType )) {
  11683. Doo::loadModel ( 'wasteBook' );
  11684. $wasteBook = new wasteBook ();
  11685. $wasteBook->delete ( array (
  11686. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11687. 'limit' => 1
  11688. ) );
  11689. }
  11690. }
  11691. return '/paymentsAchieve';
  11692. }
  11693. function paymentsCollect() {
  11694. Doo::loadModel ( "execute" );
  11695. $execute = new execute ();
  11696. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11697. die ( 'illegal request' );
  11698. }
  11699. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11700. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11701. Doo::loadModel ( "accountBookStatistics" );
  11702. $accountBookStatistics = new accountBookStatistics ();
  11703. Doo::loadClass ( 'receipt.func' );
  11704. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11705. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11706. $data ['html'] = $html ['html'];
  11707. $data ['inSum'] = $html ['sum'];
  11708. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11709. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11710. $data ['payHtml'] = $html ['html'];
  11711. $data ['paySum'] = $html ['sum'];
  11712. // 余额统计
  11713. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11714. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11715. include './protected/config/wasteBook.conf.php';
  11716. Doo::loadModel ( 'wasteBook' );
  11717. $wasteBook = new wasteBook ();
  11718. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11719. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11720. // 获得年份之前所有金额
  11721. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11722. // print_r($detail);
  11723. // $waste['total'];
  11724. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11725. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11726. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11727. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11728. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11729. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11730. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11731. if (date ( 'Y' ) > $year) {
  11732. $limitMonth = 12;
  11733. }
  11734. for($i = 1; $i <= 12; $i ++) {
  11735. $inComeA = $payB = 0;
  11736. $falg = true;
  11737. foreach ( $inComePay as $key => $value ) {
  11738. if ($value ['month'] == $i) {
  11739. $falg = false;
  11740. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11741. $inSum += $value ['accountPrice'];
  11742. $showInSum += $value ['accountPriceShow'];
  11743. $inComeA = $value ['accountPrice'];
  11744. break;
  11745. }
  11746. }
  11747. if ($falg)
  11748. $inComeHtml .= '<td class="taR">-</td>';
  11749. $payFalg = true;
  11750. foreach ( $pay as $key => $value ) {
  11751. if ($value ['month'] == $i) {
  11752. $payFalg = false;
  11753. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11754. $paySum += $value ['accountPrice'];
  11755. $showPaySum += $value ['accountPriceShow'];
  11756. $payB = $value ['accountPrice'];
  11757. break;
  11758. }
  11759. }
  11760. if ($payFalg)
  11761. $payHtml .= '<td class="taR">-</td>';
  11762. if (empty ( $balanceC ) || $limitMonth < $i)
  11763. $lastBalanceHtml .= '<td class="taR">-</td>';
  11764. else
  11765. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11766. $balanceC = $balanceC + $inComeA + $payB;
  11767. $balanceSum += $balanceC;
  11768. if (empty ( $balanceC ) || $limitMonth < $i)
  11769. $BalanceHtml .= '<td class="taR">-</td>';
  11770. else
  11771. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11772. // 余额统计
  11773. }
  11774. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11775. $data ['inComeHtml'] = $inComeHtml;
  11776. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11777. $data ['payBalanceHtml'] = $payHtml;
  11778. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11779. $data ['BalanceHtml'] = $BalanceHtml;
  11780. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11781. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11782. $mothHtml = "";
  11783. for($i = 1; $i <= 12; $i ++) {
  11784. if ($moth == $i)
  11785. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11786. else
  11787. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11788. }
  11789. $data ['mothHtml'] = $mothHtml;
  11790. $dateHtml = "";
  11791. $now = date ( "Y" );
  11792. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11793. if ($YEARD <= $now) {
  11794. $dateHtml .= '<option ';
  11795. if ($year == $YEARD) {
  11796. $dateHtml .= 'selected ';
  11797. }
  11798. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11799. }
  11800. }
  11801. $data ['dateHtml'] = $dateHtml;
  11802. $data ['year'] = $year;
  11803. $data ['memu'] = "receipt";
  11804. $data ['staff'] = $this->staff;
  11805. $data ['receiptMemu'] = 'paymentsCollect';
  11806. $data ['verifyId'] = $this->verifyId;
  11807. $data ['executeId'] = $this->executeId;
  11808. $this->render ( "/expenses/paymentsCollect", $data );
  11809. }
  11810. function paymentsCollectDay() {
  11811. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11812. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11813. if (empty ( $moth ))
  11814. return 'paymentsCollect';
  11815. Doo::loadModel ( "accountBookStatistics" );
  11816. $accountBookStatistics = new accountBookStatistics ();
  11817. $i = 2;
  11818. $y = 2013;
  11819. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11820. Doo::loadClass ( 'receipt.func' );
  11821. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11822. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11823. $data ['html'] = $html ['html'];
  11824. $data ['inSum'] = $html ['sum'];
  11825. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11826. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11827. $data ['payHtml'] = $html ['html'];
  11828. $data ['paySum'] = $html ['sum'];
  11829. $mothHtml = "";
  11830. for($i = 1; $i <= 12; $i ++) {
  11831. if ($moth == $i)
  11832. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11833. else
  11834. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11835. }
  11836. $data ['mothHtml'] = $mothHtml;
  11837. $data ['year'] = $year;
  11838. // 余额
  11839. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11840. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11841. include './protected/config/wasteBook.conf.php';
  11842. Doo::loadModel ( 'wasteBook' );
  11843. $wasteBook = new wasteBook ();
  11844. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11845. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11846. // 获得年份之前所有金额
  11847. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11848. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11849. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11850. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11851. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11852. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11853. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11854. // $balanceC = 0;
  11855. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11856. $limitDay = date ( 'd' );
  11857. $monthLK = ( int ) date ( 'm' );
  11858. if (date ( 'Y' ) > $year) {
  11859. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11860. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11861. $limitDay = 0;
  11862. }
  11863. for($i = 1; $i <= $day; $i ++) {
  11864. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11865. $inComeA = $payB = 0;
  11866. $falg = true;
  11867. foreach ( $inComePay as $key => $value ) {
  11868. if ($value ['day'] == $i) {
  11869. $falg = false;
  11870. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11871. $inSum += $value ['accountPrice'];
  11872. $showInSum += $value ['accountPriceShow'];
  11873. $inComeA = $value ['accountPrice'];
  11874. break;
  11875. }
  11876. }
  11877. if ($falg)
  11878. $inComeHtml .= '<td class="taR">-</td>';
  11879. $payFalg = true;
  11880. foreach ( $pay as $key => $value ) {
  11881. if ($value ['day'] == $i) {
  11882. $payFalg = false;
  11883. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11884. $paySum += $value ['accountPrice'];
  11885. $showPaySum += $value ['accountPriceShow'];
  11886. $payB = $value ['accountPrice'];
  11887. break;
  11888. }
  11889. }
  11890. if ($payFalg)
  11891. $payHtml .= '<td class="taR">-</td>';
  11892. if (empty ( $balanceC ) || $limitDay < $i)
  11893. $lastBalanceHtml .= '<td class="taR">-</td>';
  11894. else
  11895. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11896. $balanceC = $balanceC + $inComeA + $payB;
  11897. $balanceSum += $balanceC;
  11898. if (empty ( $balanceC ) || $limitDay < $i)
  11899. $BalanceHtml .= '<td class="taR">-</td>';
  11900. else
  11901. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11902. }
  11903. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11904. $data ['inComeHtml'] = $inComeHtml;
  11905. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11906. $data ['payBalanceHtml'] = $payHtml;
  11907. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11908. $data ['BalanceHtml'] = $BalanceHtml;
  11909. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11910. $data ['dayHtml'] = $dayHtml;
  11911. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11912. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11913. $dateHtml = "";
  11914. $now = date ( "Y" );
  11915. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11916. if ($YEARD <= $now) {
  11917. $dateHtml .= '<option ';
  11918. if ($year == $YEARD) {
  11919. $dateHtml .= 'selected ';
  11920. }
  11921. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11922. }
  11923. }
  11924. $data ['dateHtml'] = $dateHtml;
  11925. $data ['memu'] = "receipt";
  11926. $data ['staff'] = $this->staff;
  11927. $data ['receiptMemu'] = 'paymentsCollect';
  11928. $data ['verifyId'] = $this->verifyId;
  11929. $data ['executeId'] = $this->executeId;
  11930. $this->render ( "/expenses/paymentsCollectDay", $data );
  11931. }
  11932. // 公司流水
  11933. function wasteBook() {
  11934. Doo::loadModel ( "execute" );
  11935. $execute = new execute ();
  11936. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11937. die ( 'illegal request' );
  11938. }
  11939. include './protected/config/wasteBook.conf.php';
  11940. Doo::loadModel ( 'wasteBook' );
  11941. $wasteBook = new wasteBook ();
  11942. $data ['store']=$waste;
  11943. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11944. //print_r($waste);
  11945. //1-收入支出流水金额合计
  11946. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11947. //echo $waste['bank']['CGBDeposit'].'</br>';
  11948. //2020-07-20 -理财相关-面板数据
  11949. Doo::loadClass ( 'wasteBook.finances.func' );
  11950. $financesStatistics=$wasteBook->getFinancesStatistics();
  11951. //print_r($waste);
  11952. // 展示使用
  11953. //收入
  11954. //print_r($inComeStatistics);
  11955. $wasteStatistics['CGBDeposit']=0;
  11956. $wasteStatistics['ICBCDeposit']=0;
  11957. $wasteStatistics['HUADeposit']=0;
  11958. $wasteStatistics['PersonalDeposit']=0;
  11959. foreach ($inComeStatistics['incomeStatistics'] as $value ){
  11960. if($value['accountBank']=='CGBDeposit'){
  11961. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11962. }
  11963. if($value['accountBank']=='ICBCDeposit'){
  11964. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11965. }
  11966. if($value['accountBank']=='HUADeposit'){
  11967. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11968. }
  11969. if($value['accountBank']=='PersonalDeposit'){
  11970. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11971. }
  11972. }
  11973. $data ['wasteStatistics']=$wasteStatistics;
  11974. //支出
  11975. $wasteStatistics['CGBDeposit']=0;
  11976. $wasteStatistics['ICBCDeposit']=0;
  11977. $wasteStatistics['HUADeposit']=0;
  11978. $wasteStatistics['PersonalDeposit']=0;
  11979. foreach ($inComeStatistics['expenditureStatistics'] as $value ){
  11980. if($value['accountBank']=='CGBDeposit'){
  11981. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11982. }
  11983. if($value['accountBank']=='ICBCDeposit'){
  11984. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11985. }
  11986. if($value['accountBank']=='HUADeposit'){
  11987. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11988. }
  11989. if($value['accountBank']=='PersonalDeposit'){
  11990. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11991. }
  11992. }
  11993. $data ['wastePay']=$wasteStatistics;
  11994. //理财公司账号部分
  11995. $wasteStatistics['CGBDeposit']=0;
  11996. $wasteStatistics['ICBCDeposit']=0;
  11997. $wasteStatistics['HUADeposit']=0;
  11998. $wasteStatistics['PersonalDeposit']=0;
  11999. foreach ($financesStatistics['companyAccount'] as $value ){
  12000. //(纵横广发)广发存款
  12001. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12002. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12003. }
  12004. //工行存款
  12005. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12006. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12007. }
  12008. //个人存款
  12009. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12010. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12011. }
  12012. }
  12013. $data ['wasteCompanyAccount']=$wasteStatistics;
  12014. //理财部分的金额计算
  12015. $waste =_getFinancesWBS ( $waste, $financesStatistics );
  12016. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12017. //存款面板数据--日常收支改变后的金额汇总
  12018. $bankSavingsStatistics=$wasteBook->getBankSavingsStatistics();
  12019. $waste =_getBankSavingsWBS ( $waste, $bankSavingsStatistics );
  12020. //展示调试BUG-使用
  12021. //print_r($bankSavingsStatistics);
  12022. $wasteStatistics['CGBDeposit']=0;
  12023. $wasteStatistics['ICBCDeposit']=0;
  12024. $wasteStatistics['PersonalDeposit']=0;
  12025. foreach ($bankSavingsStatistics as $value ){
  12026. //(纵横广发)广发存款
  12027. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12028. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12029. }
  12030. //工行存款
  12031. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12032. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12033. }
  12034. //个人存款
  12035. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12036. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12037. }
  12038. }
  12039. $data ['wasteNewPay']=$wasteStatistics;
  12040. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12041. //
  12042. $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'];
  12043. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12044. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12045. // print_r($waste);
  12046. $data ['total'] = number_format($total,2);
  12047. $data ['CGBDeposit_total'] = number_format($CGBDeposit_total,2);
  12048. $cashBalance=$CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12049. $data['cashBalance']= number_format($cashBalance,2);
  12050. $waste ['bank'] ['CGBDeposit']=sprintf("%.2f", round($waste ['bank'] ['CGBDeposit'], 2));
  12051. $data ['waste'] = $waste;
  12052. // 月流水数据结构
  12053. $monthStatistics = array ();
  12054. $incomeMothStatistics = array ();
  12055. $expenditureMothStatistics = array ();
  12056. for($i = 1; $i <= 12; $i ++) {
  12057. $month = date ( 'Y' ) . '-' . $i;
  12058. if ($i < 10)
  12059. $month = date ( 'Y' ) . '-0' . $i;
  12060. array_push ( $monthStatistics, $month );
  12061. }
  12062. foreach ( $monthStatistics as $value ) {
  12063. $falg = true;
  12064. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12065. if ($value == $v ['inputDate']) {
  12066. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12067. $falg = false;
  12068. }
  12069. }
  12070. if ($falg) {
  12071. array_push ( $incomeMothStatistics, '' );
  12072. }
  12073. $falgEx = true;
  12074. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12075. if ($value == $v ['inputDate']) {
  12076. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12077. $falg = false;
  12078. }
  12079. }
  12080. if ($falgEx) {
  12081. array_push ( $expenditureMothStatistics, '' );
  12082. }
  12083. }
  12084. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12085. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12086. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12087. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12088. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12089. // print_r($incomeList);
  12090. $data ['expenditureList'] = $expenditureList;
  12091. $data ['incomeList'] = $incomeList;
  12092. $data ['memu'] = "receipt";
  12093. $data ['staff'] = $this->staff;
  12094. $data ['receiptMemu'] = 'wasteBook';
  12095. $data ['verifyId'] = $this->verifyId;
  12096. $data ['executeId'] = $this->executeId;
  12097. $this->render ( "/expenses/wasteBook", $data );
  12098. }
  12099. function wasteBookIncome() {
  12100. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12101. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12102. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12103. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12104. $data ['dailyIncomeType'] = $dailyIncomeType;
  12105. Doo::loadModel ( 'wasteBook' );
  12106. $wasteBook = new wasteBook ();
  12107. Doo::loadModel ( 'L_category' );
  12108. $L_category = new L_category ();
  12109. Doo::loadClass ( 'XDeode' );
  12110. $XDeode = new XDeode ( 5 );
  12111. $year=date("Y");
  12112. $theDay=date("Y-m-d");
  12113. $dateArr = explode ( ':', $date );
  12114. $D1 = '';
  12115. $D2 = '';
  12116. $con = '';
  12117. if (! empty ( $date )) {
  12118. $D1 = $dateArr [0];
  12119. $D2 = $dateArr [1];
  12120. }
  12121. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12122. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12123. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12124. $con = ' and inputDate = "' . $D1 . '"';
  12125. else{
  12126. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12127. }
  12128. if ($cid != 'ALL') {
  12129. $cid = $XDeode->decode ( $cid );
  12130. $con .= ' and cid = "' . $cid . '"';
  12131. }
  12132. if ($accountType != 'ALL') {
  12133. if ($accountType == 'INVOICE') {
  12134. $con .= ' and (accountType = 7 or accountType = 8)';
  12135. } elseif ($accountType == 'PAYMENTS') {
  12136. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12137. if ($dailyIncomeType != 'ALL') {
  12138. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12139. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12140. }
  12141. }
  12142. }
  12143. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12144. foreach ($incomeList as $key=>$value){
  12145. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12146. $wasteBook = new wasteBook ();
  12147. $wasteBook->wid = $value['wid'];
  12148. $wasteBook->synPaymentDate = 1;
  12149. $wasteBook->inputDate = $value['data']['receivedDate'];
  12150. $wasteBook->update();
  12151. }
  12152. }
  12153. $sum = 0;$thsDaySum=0;
  12154. foreach ( $incomeList as $key => $value ) {
  12155. $sum += $value ['accountPrice'];
  12156. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12157. $thsDaySum+=$value ['accountPrice'];
  12158. }
  12159. }
  12160. // print_r($incomeList);
  12161. // 获得办事和部门
  12162. $categoryList = $L_category->getCategory ();
  12163. $data ['accountType'] = $accountType;
  12164. $data ['cid'] = $cid;
  12165. $data ['categoryList'] = $categoryList;
  12166. $data ['sum'] = $sum;
  12167. $data ['incomeList'] = $incomeList;
  12168. $data ['inputDate'] = $date;
  12169. $data['year']=$year;
  12170. $data ['thsDay'] =$theDay;
  12171. $data ['thsDaySum'] =$thsDaySum;
  12172. $data ['memu'] = "receipt";
  12173. $data ['staff'] = $this->staff;
  12174. $data ['receiptMemu'] = 'wasteBook';
  12175. $data ['verifyId'] = $this->verifyId;
  12176. $data ['executeId'] = $this->executeId;
  12177. $this->render ( "/expenses/wasteBookIncome", $data );
  12178. }
  12179. /**
  12180. * 所有支出
  12181. */
  12182. function wasteBookExpenditure() {
  12183. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12184. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12185. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12186. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12187. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12188. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12189. $data ['receiptType'] = $receiptType;
  12190. Doo::loadModel ( 'wasteBook' );
  12191. $wasteBook = new wasteBook ();
  12192. Doo::loadModel ( 'L_category' );
  12193. $L_category = new L_category ();
  12194. Doo::loadClass ( 'XDeode' );
  12195. $XDeode = new XDeode ( 5 );
  12196. $year=date("Y");
  12197. $theDay=date("Y-m-d");
  12198. $dateArr = explode ( ':', $date );
  12199. $D1 = '';
  12200. $D2 = '';
  12201. $con = '';
  12202. if (! empty ( $date )) {
  12203. $D1 = $dateArr [0];
  12204. $D2 = $dateArr [1];
  12205. }
  12206. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12207. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12208. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12209. $con = ' and inputDate = "' . $D1 . '"';
  12210. else{
  12211. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12212. }
  12213. if ($cid != 'ALL') {
  12214. $cid = $XDeode->decode ( $cid );
  12215. $con .= ' and cid = "' . $cid . '"';
  12216. }
  12217. if ($accountType != 'ALL') {
  12218. if ($accountType == 'INVOICE') {
  12219. $con .= ' and accountType = 11';
  12220. } elseif ($accountType == 'PAYMENTS') {
  12221. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12222. if ($dailyExpenditureType != 'ALL') {
  12223. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12224. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12225. }
  12226. } elseif ($accountType == 'RECEIPT') {
  12227. if ($receiptType == 'ALL') {
  12228. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12229. } else {
  12230. $receiptType = $XDeode->decode ( $receiptType );
  12231. echo $receiptType;
  12232. if ($receiptType == 1) {
  12233. $con .= ' and (accountType = 1 or accountType=2)';
  12234. } else {
  12235. $con .= ' and accountType = ' . $receiptType;
  12236. }
  12237. }
  12238. }
  12239. }
  12240. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12241. foreach ($incomeList as $key=>$value){
  12242. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12243. $wasteBook = new wasteBook ();
  12244. $wasteBook->wid = $value['wid'];
  12245. $wasteBook->synPaymentDate = 1;
  12246. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12247. $wasteBook->update();
  12248. }
  12249. }
  12250. $sum = 0;$thsDaySum=0;
  12251. foreach ( $incomeList as $key => $value ) {
  12252. $sum += $value ['accountPriceShow'];
  12253. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12254. $thsDaySum+=$value ['accountPriceShow'];
  12255. }
  12256. }
  12257. // print_r($incomeList);
  12258. // 获得办事和部门
  12259. $categoryList = $L_category->getCategory ();
  12260. $data ['accountType'] = $accountType;
  12261. $data ['cid'] = $cid;
  12262. $data ['categoryList'] = $categoryList;
  12263. $data ['sum'] = $sum;
  12264. $data ['incomeList'] = $incomeList;
  12265. $data ['inputDate'] = $date;
  12266. $data['year']=$year;
  12267. $data ['thsDay'] =$theDay;
  12268. $data ['thsDaySum'] =$thsDaySum;
  12269. $data ['memu'] = "receipt";
  12270. $data ['staff'] = $this->staff;
  12271. $data ['receiptMemu'] = 'wasteBook';
  12272. $data ['verifyId'] = $this->verifyId;
  12273. $data ['executeId'] = $this->executeId;
  12274. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12275. }
  12276. function ajaxGetWasteinvoiceReceivables() {
  12277. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12278. Doo::loadClass ( 'XDeode' );
  12279. $XDeode = new XDeode ( 5 );
  12280. $irid = $XDeode->decode ( $serial );
  12281. Doo::loadModel ( 'invoiceReceivables' );
  12282. $invoiceReceivables = new invoiceReceivables ();
  12283. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12284. echo json_encode ( array (
  12285. 'status' => 1,
  12286. 'detail' => $detail
  12287. ) );
  12288. }
  12289. function ajaxGetPaymentsByAid() {
  12290. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12291. Doo::loadModel ( "accountBook" );
  12292. $accountBook = new accountBook ();
  12293. $detail = $accountBook->getAccountBookByAid ( $serial );
  12294. echo json_encode ( array (
  12295. 'status' => 1,
  12296. 'detail' => $detail
  12297. ) );
  12298. }
  12299. function ajaxGetWasteInvoice() {
  12300. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12301. Doo::loadModel ( 'invoice' );
  12302. $invoice = new invoice ();
  12303. Doo::loadModel ( 'invoiceReceivables' );
  12304. $invoiceReceivables = new invoiceReceivables ();
  12305. $detail = $invoice->getInvoiceByIid ( $serial );
  12306. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12307. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12308. echo json_encode ( array (
  12309. 'status' => 1,
  12310. 'detail' => $detail
  12311. ) );
  12312. }
  12313. /**
  12314. */
  12315. function ajaxGetWasteReceipt() {
  12316. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12317. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12318. Doo::loadModel ( 'receipt' );
  12319. $receipt = new receipt ();
  12320. Doo::loadClass ( 'XDeode' );
  12321. $XDeode = new XDeode ( 5 );
  12322. $rid = $XDeode->decode ( $serial );
  12323. $accountType= $XDeode->decode ( $accountTypeKey );
  12324. // 获得个数据
  12325. $detail = $receipt->getReceiptByRid ( $rid );
  12326. // 初始化
  12327. $detail ['reviseDetail'] = array ();
  12328. if (! empty ( $value ['reviseDetail'] ))
  12329. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12330. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12331. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12332. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12333. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12334. // 获得费用html
  12335. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12336. // 获得费用审批人数据
  12337. $detail = $this->getReceiptApproverHtml ( $detail );
  12338. // 审批执行
  12339. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12340. <th class="taC" width="90">审批人</th>
  12341. <th class="taC">审批意见</th></tr>';
  12342. foreach ( $detail ['verifyList'] as $key => $value ) {
  12343. $html .= '<tr>
  12344. <td>' . $value [1] . '</td>
  12345. <td>' . $value ['opinion'] . '</td>
  12346. </tr>
  12347. ';
  12348. }
  12349. $html .= ' </tbody></table>';
  12350. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12351. <th class="taC" width="90">执行人</th>
  12352. <th class="taC">执行意见</th></tr>';
  12353. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12354. $html .= '<tr>
  12355. <td>' . $value [1] . '</td>
  12356. <td>' . $value ['opinion'] . '</td>
  12357. </tr>
  12358. ';
  12359. }
  12360. $html .= ' </tbody></table>';
  12361. if($accountType==1){
  12362. Doo::loadModel ( 'loanReceipt' );
  12363. $loanReceipt = new loanReceipt ();
  12364. $loanList = $loanReceipt->getOne ( array (
  12365. 'where' => 'rid=' . $detail ['loanRid'],
  12366. 'desc' => 'rid',
  12367. 'asArray' => true
  12368. ) );
  12369. $html .= '<table class="table table-bordered table-condensed">
  12370. <tr class="warning">
  12371. <td class="taR"><b>汇款金额</b></td>
  12372. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12373. </tr>
  12374. </table>';
  12375. }else{
  12376. $html .= '<table class="table table-bordered table-condensed">
  12377. <tr class="warning">
  12378. <td class="taR"><b>汇款金额</b></td>
  12379. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12380. </tr>
  12381. </table>';
  12382. }
  12383. // print_r($detail['verifyList']);
  12384. // header ( 'Content-Type:text/html;charset=utf-8' );
  12385. // echo $html;
  12386. echo json_encode ( array (
  12387. 'status' => 1,
  12388. 'html' => $html,
  12389. 'detail' => $detail
  12390. ) );
  12391. }
  12392. function getReceiptApproverHtml($detail = array()) {
  12393. Doo::loadModel ( 'loanReceipt' );
  12394. $loanReceipt = new loanReceipt ();
  12395. Doo::loadModel ( 'verify' );
  12396. $verify = new verify ();
  12397. Doo::loadModel ( 'staff' );
  12398. $staff = new staff ();
  12399. if (empty ( $detail ))
  12400. return array ();
  12401. $loanList = $loanReceipt->getOne ( array (
  12402. 'where' => 'rid=' . $detail ['loanRid'],
  12403. 'desc' => 'rid',
  12404. 'asArray' => true
  12405. ) );
  12406. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12407. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12408. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12409. else
  12410. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12411. } else
  12412. $verifyList = $verify->getOne ( array (
  12413. 'where' => 'vid=' . $detail ['verify'],
  12414. 'asArray' => true
  12415. ) );
  12416. $verifyList = json_decode ( $verifyList ['staff'], true );
  12417. Doo::loadModel ( 'role' );
  12418. $role = new role ();
  12419. $roleId = 0;
  12420. $flag = true;
  12421. $roleKey = 0;
  12422. $endStaffArray = array ();
  12423. $roleArrayCopy = array ();
  12424. foreach ( $verifyList as $k => $v ) {
  12425. // init verifyStaff
  12426. if ($v [1] == 'ROLE') {
  12427. if (! empty ( $verifyStaff )) {
  12428. $endStaffArray = end ( $verifyStaff );
  12429. }
  12430. $roleVerify = json_decode ( $v [3], true );
  12431. $roleKey = $k;
  12432. $roleArray = array ();
  12433. $rolename = $role->getOne ( array (
  12434. 'where' => 'rid=' . $v [0],
  12435. 'asArray' => true
  12436. ) );
  12437. foreach ( $roleVerify as $o => $p ) {
  12438. $staffID = explode ( '_', $p );
  12439. $staffInfo = $staff->getOne ( array (
  12440. 'where' => 'sid=' . $staffID [0],
  12441. 'asArray' => true
  12442. ) );
  12443. // print_r($staffID);
  12444. $exp = array (
  12445. 0 => $staffInfo ['sid'],
  12446. 1 => $staffID [1],
  12447. 2 => $staffInfo ['avatar'],
  12448. 'date' => '',
  12449. 'date' => '',
  12450. 'opinion' => '',
  12451. 'status' => '',
  12452. 'rolename' => $rolename ['name']
  12453. );
  12454. array_push ( $roleArray, $exp );
  12455. }
  12456. $roleArrayCopy [$v [0]] = $roleArray;
  12457. // $verifyList[$k]['roleArray']=$roleArray;
  12458. }
  12459. $verifyList [$k] ['date'] = "";
  12460. $verifyList [$k] ['opinion'] = "";
  12461. $verifyList [$k] ['status'] = "";
  12462. if (empty ( $verifyStaff )) {
  12463. $verifyList [$k] ['date'] = "";
  12464. $verifyList [$k] ['opinion'] = "";
  12465. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12466. $verifyList [$k] ['status'] = 4;
  12467. $flag = false;
  12468. }
  12469. } else {
  12470. foreach ( $verifyStaff as $m => $u ) {
  12471. if ($v [0] == $m) {
  12472. $verifyList [$k] ['date'] = $u ['date'];
  12473. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12474. $verifyList [$k] ['status'] = $u ['status'];
  12475. $flag = false;
  12476. break;
  12477. }
  12478. }
  12479. $endStaffArray = end ( $verifyStaff );
  12480. }
  12481. }
  12482. $rolename ['name'] = '';
  12483. if (! empty ( $roleId )) {
  12484. Doo::loadModel ( 'role' );
  12485. $role = new role ();
  12486. $rolename = $role->getOne ( array (
  12487. 'where' => 'rid=' . $roleId,
  12488. 'asArray' => true
  12489. ) );
  12490. }
  12491. if (! empty ( $verifyStaff ))
  12492. $endStaffArray = end ( $verifyStaff );
  12493. $KOP = false;
  12494. foreach ( $roleArrayCopy as $P => $A ) {
  12495. foreach ( $A as $MKI => $AVL ) {
  12496. if (! empty ( $verifyStaff )) {
  12497. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12498. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12499. $button = 4;
  12500. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12501. }
  12502. foreach ( $verifyStaff as $m => $u ) {
  12503. $AVLFK = $AVL [0] . '_R';
  12504. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12505. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12506. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12507. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12508. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12509. break;
  12510. }
  12511. }
  12512. } else {
  12513. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12514. $button = 4;
  12515. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12516. }
  12517. }
  12518. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12519. $KOP = true;
  12520. }
  12521. }
  12522. foreach ( $roleArrayCopy as $k => $v ) {
  12523. foreach ( $verifyList as $m => $n ) {
  12524. if ($n [0] == $k) {
  12525. array_splice ( $verifyList, $m, 1, $v );
  12526. }
  12527. }
  12528. }
  12529. // 费用执行人相关数据
  12530. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12531. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12532. foreach ( $executeCopy as $k => $v ) {
  12533. $executeCopy [$k] ['date'] = '';
  12534. $executeCopy [$k] ['opinion'] = '';
  12535. $executeCopy [$k] ['status'] = '';
  12536. if (! empty ( $executeStaff ))
  12537. foreach ( $executeStaff as $m => $u ) {
  12538. if ($v [0] == $m) {
  12539. $executeCopy [$k] ['date'] = $u ['date'];
  12540. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12541. $executeCopy [$k] ['status'] = $u ['status'];
  12542. break;
  12543. }
  12544. }
  12545. }
  12546. $detail ['executeCopy'] = $executeCopy;
  12547. $detail ['verifyList'] = $verifyList;
  12548. return $detail;
  12549. }
  12550. //获得新版报销单费用说明
  12551. private function getReceiptVerson1Explanation($value){
  12552. if($value['version']==1){
  12553. $version_1_explanation="";
  12554. if(!empty($value['officeJson'])){
  12555. $officeJson=json_decode($value['officeJson'],true);
  12556. $version_1_explanation.=$officeJson['officeExplain'][0]['officeExplain']."\n";
  12557. }
  12558. if(!empty($value['traveJson'])){
  12559. $traveJson=json_decode($value['traveJson'],true);
  12560. $version_1_explanation.=$traveJson['traveExplain'][0]['traveExplain']."\n";
  12561. }
  12562. if(!empty($value['trainJson'])){
  12563. $trainJson=json_decode($value['trainJson'],true);
  12564. $version_1_explanation.=$trainJson['trainExplain'][0]['trainExplain']."\n";
  12565. }
  12566. }
  12567. return $version_1_explanation;
  12568. }
  12569. //获得新版报销单 详情HTML
  12570. private function getReceiptVerson1Html($detail){
  12571. $html='<table class="table table-bordered table-condensed">
  12572. <tbody>';
  12573. if($detail['version']==1){
  12574. if(!empty($detail['officeJson'])){
  12575. $officeJson=json_decode($detail['officeJson'],true);
  12576. $html .= '
  12577. <tr>
  12578. <th colspan="2" class="taC">日常相关费用</th>
  12579. </tr>';
  12580. // 日常相关费用
  12581. $total=0;
  12582. foreach ( $officeJson['daily'] as $key => $value ) {
  12583. if(!empty($value['price'])){
  12584. $html .= '
  12585. <tr>
  12586. <th>' . $value ['name'] . '</th>
  12587. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12588. </tr>';
  12589. $total=bcadd($total,$value ['price'],2);
  12590. }
  12591. }
  12592. $html .= '
  12593. <tr>
  12594. <th class="taR">合计</th>
  12595. <td class="colGreen taR">¥' .$total . '</td>
  12596. </tr>';
  12597. // 其他
  12598. $html .= '<tr>
  12599. <th colspan="2" class="taC">其他</th>
  12600. </tr>';
  12601. $total=0;
  12602. foreach ( $officeJson['other'] as $key => $value ) {
  12603. if(!empty($value['price'])){
  12604. $html .= '
  12605. <tr>
  12606. <th>' . $value ['name'] . '</th>
  12607. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12608. </tr>';
  12609. $total=bcadd($total,$value ['price'],2);
  12610. }
  12611. }
  12612. $html .= '
  12613. <tr>
  12614. <th class="taR">合计</th>
  12615. <td class="colGreen taR">¥' . $total . '</td>
  12616. </tr>';
  12617. }
  12618. if(!empty($detail['traveJson'])){
  12619. $traveJson=json_decode($detail['traveJson'],true);
  12620. // 差旅
  12621. $html .= '<tr>
  12622. <th colspan="2" class="taC">差旅相关费用</th>
  12623. </tr>';
  12624. $total=0;
  12625. foreach ( $traveJson['trave'] as $key => $value ) {
  12626. if(!empty($value['price'])){
  12627. $html .= '
  12628. <tr>
  12629. <th>' . $value ['name'] . '</th>
  12630. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12631. </tr>';
  12632. $total=bcadd($total,$value ['price'],2);
  12633. }
  12634. }
  12635. $html .= '
  12636. <tr>
  12637. <th class="taR">合计</th>
  12638. <td class="colGreen taR">¥' . $total . '</td>
  12639. </tr>';
  12640. }
  12641. if(!empty($detail['trainJson'])){
  12642. $trainJson=json_decode($detail['trainJson'],true);
  12643. // 内部培训费用
  12644. $html .= '<tr>
  12645. <th colspan="2" class="taC">内部培训费用</th>
  12646. </tr>';
  12647. $total=0;
  12648. foreach ( $trainJson['train'] as $key => $value ) {
  12649. if(!empty($value['price'])){
  12650. $html .= '
  12651. <tr>
  12652. <th>' . $value ['name'] . '</th>
  12653. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12654. </tr>';
  12655. $total=bcadd($total,$value ['price'],2);
  12656. }
  12657. }
  12658. $html .= '
  12659. <tr>
  12660. <th class="taR">合计</th>
  12661. <td class="colGreen taR">¥' . $total . '</td>
  12662. </tr>';
  12663. }
  12664. }
  12665. return $html;
  12666. }
  12667. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12668. if (empty ( $detail ))
  12669. return '';
  12670. $html = '';
  12671. // die;
  12672. if ($detail ['Rtype'] == 0) { // 报销单
  12673. if($detail ['version']==1){
  12674. $html .= $this->getReceiptVerson1Html($detail);
  12675. }else{
  12676. $html .= '<table class="table table-bordered table-condensed">
  12677. <tbody>
  12678. <tr>
  12679. <th colspan="2" class="taC">日常相关费用</th>
  12680. </tr>';
  12681. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12682. $html .= '
  12683. <tr>
  12684. <th>' . $value ['name'] . '</th>
  12685. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12686. </tr>';
  12687. }
  12688. $html .= '
  12689. <tr>
  12690. <th class="taR">合计</th>
  12691. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12692. </tr>';
  12693. $html .= '<tr>
  12694. <th colspan="2" class="taC">差旅相关费用</th>
  12695. </tr>';
  12696. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12697. $html .= '
  12698. <tr>
  12699. <th>' . $value ['name'] . '</th>
  12700. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12701. </tr>';
  12702. }
  12703. $html .= '
  12704. <tr>
  12705. <th class="taR">合计</th>
  12706. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12707. </tr>';
  12708. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12709. $html .= '<tr>
  12710. <th colspan="2" class="taC">内部培训费用</th>
  12711. </tr>';
  12712. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12713. $html .= '
  12714. <tr>
  12715. <th>' . $value ['name'] . '</th>
  12716. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12717. </tr>';
  12718. }
  12719. $html .= '
  12720. <tr>
  12721. <th class="taR">合计</th>
  12722. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12723. </tr>';
  12724. }
  12725. $html .= '<tr>
  12726. <th colspan="2" class="taC">其他</th>
  12727. </tr>';
  12728. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12729. $html .= '
  12730. <tr>
  12731. <th>' . $value ['name'] . '</th>
  12732. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12733. </tr>';
  12734. }
  12735. $html .= '
  12736. <tr>
  12737. <th class="taR">合计</th>
  12738. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12739. </tr>';
  12740. }
  12741. $html .= '<tr>
  12742. <th colspan="2" class="taC">报销金额调整</th>
  12743. </tr>';
  12744. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12745. $html .= '
  12746. <tr>
  12747. <th>' . $value ['name'] . '</th>
  12748. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12749. </tr>';
  12750. }
  12751. $html .= '
  12752. <tr>
  12753. <th class="taR">合计</th>
  12754. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12755. </tr>';
  12756. $html .= '
  12757. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12758. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12759. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12760. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12761. <tr class="warning">
  12762. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12763. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12764. </tr>
  12765. </tbody>
  12766. </table>';
  12767. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12768. $html .= '
  12769. <table class="table table-bordered table-condensed">
  12770. <tbody>
  12771. <tr>
  12772. <th colspan="2" class="taC">办事处相关费用</th>
  12773. </tr>';
  12774. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12775. $html .= '
  12776. <tr>
  12777. <th>' . $value ['name'] . '</th>
  12778. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12779. </tr>';
  12780. }
  12781. $html .= '
  12782. <tr>
  12783. <th class="taR">合计</th>
  12784. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12785. </tr>';
  12786. $html .= '
  12787. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12788. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12789. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12790. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12791. <tr class="warning">
  12792. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12793. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12794. </tr>
  12795. </tbody>
  12796. </table>';
  12797. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12798. Doo::loadModel ( 'loanReceipt' );
  12799. $loanReceipt = new loanReceipt ();
  12800. $loanList = $loanReceipt->getOne ( array (
  12801. 'where' => 'rid=' . $detail ['loanRid'],
  12802. 'desc' => 'rid',
  12803. 'asArray' => true
  12804. ) );
  12805. // print_r($loanList);
  12806. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12807. $html .= '<table class="table table-bordered table-condensed">
  12808. <tbody>
  12809. <tr>
  12810. <th colspan="2" class="taC">借款费用</th>
  12811. </tr>';
  12812. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12813. $html .= '<tr>
  12814. <th>' . $value ['name'] . '</th>
  12815. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12816. </tr>';
  12817. }
  12818. $html .= '<tr>
  12819. <th class="taC" colspan="2">产生费用所在办事处</th>
  12820. </tr>
  12821. <tr>
  12822. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12823. </tr>
  12824. <tr>
  12825. <th class="taC" colspan="2">费用说明</th>
  12826. </tr>
  12827. <tr>
  12828. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12829. </tr>
  12830. <tr class="warning">
  12831. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12832. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12833. </tr>
  12834. </tbody>
  12835. </table>
  12836. ';
  12837. if ( $accountType==2) {
  12838. $balance=$detail ['sum']-$loanList ['sum'];
  12839. $balanceCN=$this->num_to_rmb($balance);
  12840. if($detail ['version']==1){
  12841. $html .= $this->getReceiptVerson1Html($detail);
  12842. }else{
  12843. $html .= '<table class="table table-bordered table-condensed">
  12844. <tbody>
  12845. <tr>
  12846. <th colspan="2" class="taC">日常相关费用</th>
  12847. </tr>';
  12848. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12849. $html .= '
  12850. <tr>
  12851. <th>' . $value ['name'] . '</th>
  12852. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12853. </tr>';
  12854. }
  12855. $html .= '
  12856. <tr>
  12857. <th class="taR">合计</th>
  12858. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12859. </tr>';
  12860. $html .= '<tr>
  12861. <th colspan="2" class="taC">差旅相关费用</th>
  12862. </tr>';
  12863. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12864. $html .= '
  12865. <tr>
  12866. <th>' . $value ['name'] . '</th>
  12867. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12868. </tr>';
  12869. }
  12870. $html .= '
  12871. <tr>
  12872. <th class="taR">合计</th>
  12873. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12874. </tr>';
  12875. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12876. $html .= '<tr>
  12877. <th colspan="2" class="taC">内部培训费用</th>
  12878. </tr>';
  12879. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12880. $html .= '
  12881. <tr>
  12882. <th>' . $value ['name'] . '</th>
  12883. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12884. </tr>';
  12885. }
  12886. $html .= '
  12887. <tr>
  12888. <th class="taR">合计</th>
  12889. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12890. </tr>';
  12891. }
  12892. $html .= '<tr>
  12893. <th colspan="2" class="taC">其他</th>
  12894. </tr>';
  12895. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12896. $html .= '
  12897. <tr>
  12898. <th>' . $value ['name'] . '</th>
  12899. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12900. </tr>';
  12901. }
  12902. $html .= '
  12903. <tr>
  12904. <th class="taR">合计</th>
  12905. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12906. </tr>';
  12907. }
  12908. $html .= '<tr>
  12909. <th colspan="2" class="taC">报销金额调整</th>
  12910. </tr>';
  12911. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12912. $html .= '
  12913. <tr>
  12914. <th>' . $value ['name'] . '</th>
  12915. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12916. </tr>';
  12917. }
  12918. $html .= '
  12919. <tr>
  12920. <th class="taR">合计</th>
  12921. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12922. </tr>';
  12923. $html .= '
  12924. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12925. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12926. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12927. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12928. <tr class="warning">
  12929. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12930. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12931. </tr>
  12932. <tr class="success">
  12933. <td class="taR"><b>借款结余</b></td>
  12934. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12935. </tr>
  12936. </tbody>
  12937. </table>';
  12938. }
  12939. }
  12940. return $html;
  12941. }
  12942. /**
  12943. * 计算流水
  12944. */
  12945. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12946. $bakWaste ['bank'] = array (
  12947. 'CGBDeposit' => 0,
  12948. 'ICBCDeposit' => 0,
  12949. 'HUADeposit' => 0,
  12950. 'PersonalDeposit' => 0
  12951. );
  12952. $bakWaste ['financial'] = array (
  12953. 'current' => array (
  12954. 'CGBDeposit' => 0,
  12955. 'ICBCDeposit' => 0
  12956. ),
  12957. 'fixed' => array (
  12958. 'CGBDeposit' => 0,
  12959. 'ICBCDeposit' => 0
  12960. )
  12961. );
  12962. // 存款
  12963. foreach ( $waste ['bank'] as $key => $value ) {
  12964. // 收入
  12965. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12966. // 广发
  12967. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12968. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12969. }
  12970. // 工商
  12971. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12972. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12973. }
  12974. // 华润
  12975. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12976. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12977. }
  12978. // 个人
  12979. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12980. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12981. }
  12982. }
  12983. }
  12984. foreach ( $waste ['bank'] as $key => $value ) {
  12985. // 支出
  12986. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12987. // 广发
  12988. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12989. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12990. }
  12991. // 工商
  12992. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12993. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12994. }
  12995. // 华润
  12996. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12997. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12998. }
  12999. // 个人
  13000. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13001. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13002. }
  13003. }
  13004. }
  13005. // 活期
  13006. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13007. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13008. // 广发
  13009. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13010. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13011. }
  13012. // 工商
  13013. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13014. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13015. }
  13016. // 个人
  13017. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13018. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13019. }
  13020. }
  13021. }
  13022. // print_r($inComeStatistics ['fixedStatistics']);
  13023. // 固期
  13024. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13025. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13026. // 广发
  13027. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13028. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13029. }
  13030. // 工商---已经转变成个人理财固定代表含义
  13031. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13032. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13033. }
  13034. // 个人
  13035. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13036. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13037. }
  13038. }
  13039. }
  13040. $waste ['bank'] ['ICBCDeposit'] = sprintf("%.2f", $waste ['bank'] ['ICBCDeposit']);
  13041. return $waste;
  13042. }
  13043. function lyt() {
  13044. Doo::loadModel ( "receiptDetail" );
  13045. $receiptDetail = new receiptDetail ();
  13046. $receiptCollectList = $receiptDetail->find ( array (
  13047. 'where' => 'status=1 ',
  13048. 'asArray' => true
  13049. ) );
  13050. foreach ( $receiptCollectList as $key => $value ) {
  13051. $receiptDetail = new receiptDetail ();
  13052. $receiptDetail->pastDate = $value ['date'];
  13053. $receiptDetail->update ( array (
  13054. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13055. ) );
  13056. }
  13057. }
  13058. function staffCollectMonthDetail() {
  13059. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13060. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13061. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13062. if (! $year)
  13063. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13064. if (! $month)
  13065. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13066. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13067. if (! $nature){
  13068. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13069. }
  13070. Doo::loadModel ( 'staff' );
  13071. $staff = new staff ();
  13072. Doo::loadModel ( "receiptDetail" );
  13073. $receiptDetail = new receiptDetail ();
  13074. Doo::loadModel ( 'accountItem' );
  13075. $accountItem = new accountItem ();
  13076. Doo::loadModel ( 'statistics' );
  13077. $statistics = new statistics ();
  13078. Doo::loadModel ( "receiptAuthorityManage" );
  13079. $receiptAuthorityManage = new receiptAuthorityManage ();
  13080. $aiList=$accountItem->getAccountItem();
  13081. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13082. $cidList = array ();
  13083. foreach ( $imcStaff as $key => $value ) {
  13084. array_push ( $cidList, $value ['cid'] );
  13085. }
  13086. $cidString = implode ( ',', $cidList );
  13087. $naturecon='';
  13088. if ($nature=='ONJOB'){
  13089. $naturecon=' and (nature!=4 )';
  13090. }elseif($nature=='LEAVEJOB'){
  13091. $naturecon=' and (nature=4 )';
  13092. }else{
  13093. die ( 'illegal request--nature' );
  13094. }
  13095. $staffList = $staff->find ( array (
  13096. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13097. 'asArray' => true
  13098. ) );
  13099. $categoryList = $staff->find ( array (
  13100. 'select' => 'COUNT(*) as count,cid,category',
  13101. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13102. 'groupby' => 'cid',
  13103. 'asArray' => true
  13104. ) );
  13105. $list = array ();
  13106. foreach($aiList as $key=>$value){
  13107. foreach ($value as $v){
  13108. $subtotal[$key][$v['name']]=0;
  13109. }
  13110. }
  13111. foreach ( $categoryList as $vlu ) {
  13112. $s1 = 0;
  13113. $m1 = 0;
  13114. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13115. foreach ( $staffList as $value ) {
  13116. if ($vlu ['cid'] == $value ['cid']) {
  13117. // pastDate
  13118. $receiptCollectList = $receiptDetail->find ( array (
  13119. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13120. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13121. 'groupby' => 'item,Month(pastDate),itemCategory',
  13122. 'asArray' => true
  13123. ) );
  13124. if (! empty ( $receiptCollectList )) {
  13125. $receiptL = array (
  13126. '日常相关费用' => array (),
  13127. '差旅相关费用' => array (),
  13128. '内部培训费用' => array (),
  13129. '培训班费用' => array (),
  13130. '其他' => array ()
  13131. );
  13132. $html = "";
  13133. $psum = 0;
  13134. foreach ( $aiList[$this->AGENCY] as $va ) {
  13135. $falg = true;
  13136. foreach ( $receiptCollectList as $v ) {
  13137. if ($v ['itemCategory'] == '日常相关费用') {
  13138. if ($v ['item'] == $va['name']) {
  13139. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13140. $psum += $v ['price'];
  13141. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13142. $falg = false;
  13143. break;
  13144. }
  13145. }
  13146. }
  13147. if ($falg)
  13148. $html .= '<td class="taR">-</td>';
  13149. }
  13150. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13151. if (! empty ( $psum ))
  13152. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13153. else
  13154. $psum = '<td class="colGreen taR">-</td>';
  13155. $receiptL ['日常相关费用'] = $psum . $html;
  13156. /* ----------------------------------- */
  13157. $html = "";
  13158. $psum = 0;
  13159. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13160. $falg = true;
  13161. foreach ( $receiptCollectList as $v ) {
  13162. if ($v ['itemCategory'] == '差旅相关费用') {
  13163. if ($v ['item'] == $va['name']) {
  13164. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13165. $psum += $v ['price'];
  13166. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13167. $falg = false;
  13168. break;
  13169. }
  13170. }
  13171. }
  13172. if ($falg)
  13173. $html .= '<td class="taR">-</td>';
  13174. }
  13175. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13176. if (! empty ( $psum ))
  13177. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13178. else
  13179. $psum = '<td class="colGreen taR">-</td>';
  13180. $receiptL ['差旅相关费用'] = $psum . $html;
  13181. /* ------------------------------------- */
  13182. $html = "";
  13183. $psum = 0;
  13184. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13185. $falg = true;
  13186. foreach ( $receiptCollectList as $v ) {
  13187. if ($v ['itemCategory'] == '内部培训费用') {
  13188. if ($v ['item'] == $va['name']) {
  13189. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13190. $psum += $v ['price'];
  13191. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13192. $falg = false;
  13193. break;
  13194. }
  13195. }
  13196. }
  13197. if ($falg)
  13198. $html .= '<td class="taR">-</td>';
  13199. }
  13200. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13201. if (! empty ( $psum ))
  13202. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13203. else
  13204. $psum = '<td class="colGreen taR">-</td>';
  13205. $receiptL ['内部培训费用'] = $psum . $html;
  13206. /* ----------------------------------- */
  13207. $html = "";
  13208. $psum = 0;
  13209. foreach ( $aiList[$this->TRAIN] as $va ) {
  13210. $falg = true;
  13211. foreach ( $receiptCollectList as $v ) {
  13212. if ($v ['itemCategory'] == '培训班费用') {
  13213. if ($v ['item'] == $va['name']) {
  13214. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13215. $psum += $v ['price'];
  13216. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13217. $falg = false;
  13218. break;
  13219. }
  13220. }
  13221. }
  13222. if ($falg)
  13223. $html .= '<td class="taR">-</td>';
  13224. }
  13225. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13226. if (! empty ( $psum ))
  13227. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13228. else
  13229. $psum = '<td class="colGreen taR">-</td>';
  13230. $receiptL ['培训班费用'] = $psum . $html;
  13231. /* ------------------------------------- */
  13232. $html = "";
  13233. $psum = 0;
  13234. foreach ( $aiList[$this->OTHER] as $va ) {
  13235. $falg = true;
  13236. foreach ( $receiptCollectList as $v ) {
  13237. if ($v ['itemCategory'] == '其他') {
  13238. if (trim ( $v ['item'] ) == $va['name']) {
  13239. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13240. $psum += $v ['price'];
  13241. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13242. $falg = false;
  13243. break;
  13244. }
  13245. }
  13246. }
  13247. if ($falg)
  13248. $html .= '<td class="taR">-</td>';
  13249. }
  13250. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13251. if (! empty ( $psum ))
  13252. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13253. else
  13254. $psum = '<td class="colGreen taR">-</td>';
  13255. $receiptL ['其他'] = $psum . $html;
  13256. /* ------------------------------------- */
  13257. $html = "";
  13258. $psum = 0;
  13259. foreach ( $receiptCollectList as $v ) {
  13260. if ($v ['itemCategory'] == '报销金额调整') {
  13261. if (! empty ( $v ['price'] )) {
  13262. $psum += $v ['price'];
  13263. }
  13264. }
  13265. }
  13266. $s1 += $psum;
  13267. if (! empty ( $psum ))
  13268. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13269. else
  13270. $psum = '<td class="taR colOrange">-</td>';
  13271. $receiptL ['报销金额调整'] = $psum . $html;
  13272. } else {
  13273. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13274. foreach ( $aiList[$this->AGENCY] as $va ) {
  13275. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13276. }
  13277. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13278. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13279. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13280. }
  13281. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13282. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13283. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13284. }
  13285. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13286. foreach ( $aiList[$this->TRAIN] as $va ) {
  13287. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13288. }
  13289. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13290. foreach ( $aiList[$this->OTHER] as $va ) {
  13291. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13292. }
  13293. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13294. }
  13295. $monthStaffPrice = $receiptDetail->find ( array (
  13296. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13297. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13298. 'groupby' => 'Month(pastDate)',
  13299. 'asArray' => true
  13300. ) );
  13301. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13302. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13303. $m1 += $monthStaffPrice [0] ['price'];
  13304. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13305. } else
  13306. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13307. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13308. $list [$value ['username']] = $receiptL;
  13309. }
  13310. }
  13311. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13312. foreach ( $aiList[$this->AGENCY] as $va ) {
  13313. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13314. $subtotal[$this->AGENCY][$va['name']]=0;
  13315. }
  13316. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13317. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13318. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13319. $subtotal[$this->TRAVEL][$va['name']]=0;
  13320. }
  13321. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13322. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13323. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13324. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13325. }
  13326. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13327. foreach ( $aiList[$this->TRAIN] as $va ) {
  13328. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13329. $subtotal[$this->TRAIN][$va['name']]=0;
  13330. }
  13331. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13332. foreach ( $aiList[$this->OTHER] as $va ) {
  13333. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13334. $subtotal[$this->OTHER][$va['name']]=0;
  13335. }
  13336. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13337. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13338. $receiptL ['usernameEn'] =false;
  13339. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13340. }
  13341. $data ['list'] = $list;
  13342. // print_r($list);
  13343. $receiptCollectList = $receiptDetail->find ( array (
  13344. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13345. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13346. 'groupby' => 'item,Month(pastDate),itemCategory',
  13347. 'asArray' => true
  13348. ) );
  13349. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13350. // statistics html
  13351. $stList = $statistics->getOne ( array (
  13352. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13353. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13354. 'groupby' => 'Month(date)',
  13355. 'asArray' => true
  13356. ) );
  13357. if (empty ( $stList ))
  13358. $stList = array (
  13359. 'rePrice' => 0,
  13360. 'agPrice' => 0
  13361. );
  13362. $data ['stList'] = array (
  13363. 'rePrice' => $stList ['rePrice'],
  13364. 'agPrice' => $stList ['agPrice'],
  13365. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13366. );
  13367. $monthHtml = "";
  13368. for($i = 1; $i <= 12; $i ++) {
  13369. if ($i == $month)
  13370. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13371. else
  13372. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13373. }
  13374. $data ['monthHtml'] = $monthHtml;
  13375. $data ['year'] = $year;
  13376. $data ['month'] = $month;
  13377. $data ['nature'] = $nature;
  13378. $data ['aiList'] = $aiList;
  13379. $data ['memu'] = "receipt";
  13380. $data ['staff'] = $this->staff;
  13381. $data ['receiptMemu'] = 'companyCategoryCollect';
  13382. $data ['verifyId'] = $this->verifyId;
  13383. $data ['executeId'] = $this->executeId;
  13384. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13385. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13386. }
  13387. function staffCollectMonthDetail2() {
  13388. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13389. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13390. if (! $year)
  13391. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13392. if (! $month)
  13393. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13394. Doo::loadModel ( 'staff' );
  13395. $staff = new staff ();
  13396. Doo::loadModel ( "receiptDetail" );
  13397. $receiptDetail = new receiptDetail ();
  13398. Doo::loadModel ( 'accountItem' );
  13399. $accountItem = new accountItem ();
  13400. Doo::loadModel ( 'statistics' );
  13401. $statistics = new statistics ();
  13402. Doo::loadModel ( 'L_category' );
  13403. $lCategory = new L_category ();
  13404. $staffList = $staff->find ( array (
  13405. 'where' => 'username!="admin"',
  13406. 'asArray' => true
  13407. ) );
  13408. $categoryList = $staff->find ( array (
  13409. 'select' => 'COUNT(*) as count,cid,category',
  13410. 'where' => 'username !="admin"',
  13411. 'groupby' => 'cid',
  13412. 'asArray' => true
  13413. ) );
  13414. $list = array ();
  13415. foreach ( $categoryList as $vlu ) {
  13416. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13417. $r1 = 0;
  13418. $r2 = 0;
  13419. $r3 = 0;
  13420. $r4 = 0;
  13421. $r5 = 0;
  13422. $r6 = 0;
  13423. $r7 = 0;
  13424. $r8 = 0;
  13425. $r9 = 0;
  13426. $r10 = 0;
  13427. $r11 = 0;
  13428. $r12 = 0;
  13429. $r13 = 0;
  13430. $r14 = 0;
  13431. $r15 = 0;
  13432. $c1 = 0;
  13433. $c2 = 0;
  13434. $c3 = 0;
  13435. $c4 = 0;
  13436. $c5 = 0;
  13437. $c6 = 0;
  13438. $p1 = 0;
  13439. $p2 = 0;
  13440. $p3 = 0;
  13441. $p4 = 0;
  13442. $p5 = 0;
  13443. $p6 = 0;
  13444. $p7 = 0;
  13445. $p8 = 0;
  13446. $p9 = 0;
  13447. $t1 = 0;
  13448. $t2 = 0;
  13449. $t3 = 0;
  13450. $t4 = 0;
  13451. $t5 = 0;
  13452. $s1 = 0;
  13453. $m1 = 0;
  13454. foreach ( $staffList as $value ) {
  13455. if ($vlu ['cid'] == $value ['cid']) {
  13456. $receiptCollectList = $receiptDetail->find ( array (
  13457. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13458. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13459. 'groupby' => 'item,Month(date),itemCategory',
  13460. 'asArray' => true
  13461. ) );
  13462. if (! empty ( $receiptCollectList )) {
  13463. $receiptL = array (
  13464. '日常相关费用' => array (),
  13465. '差旅相关费用' => array (),
  13466. '培训班费用' => array (),
  13467. '其他' => array ()
  13468. );
  13469. $html = "";
  13470. $psum = 0;
  13471. $item = array (
  13472. '市内交通费',
  13473. '市内出租费',
  13474. '办事处房租',
  13475. '电话费',
  13476. '水费',
  13477. '电费',
  13478. '办公费用',
  13479. '邮寄费',
  13480. '其他费用',
  13481. '车辆费用',
  13482. '广告费',
  13483. '团队建设费',
  13484. '物业管理费',
  13485. '宽带费'
  13486. );
  13487. foreach ( $item as $va ) {
  13488. $falg = true;
  13489. foreach ( $receiptCollectList as $v ) {
  13490. if ($v ['itemCategory'] == '日常相关费用') {
  13491. if ($v ['item'] == $va) {
  13492. if ($va == '市内交通费')
  13493. $r1 += $v ['price'];
  13494. if ($va == '市内出租费')
  13495. $r2 += $v ['price'];
  13496. if ($va == '办事处房租')
  13497. $r3 += $v ['price'];
  13498. if ($va == '电话费')
  13499. $r4 += $v ['price'];
  13500. if ($va == '水费')
  13501. $r5 += $v ['price'];
  13502. if ($va == '电费')
  13503. $r6 += $v ['price'];
  13504. if ($va == '办公费用')
  13505. $r7 += $v ['price'];
  13506. if ($va == '邮寄费')
  13507. $r8 += $v ['price'];
  13508. if ($va == '其他费用')
  13509. $r9 += $v ['price'];
  13510. if ($va == '车辆费用')
  13511. $r10 += $v ['price'];
  13512. if ($va == '广告费')
  13513. $r11 += $v ['price'];
  13514. if ($va == '团队建设费')
  13515. $r13 += $v ['price'];
  13516. if ($va == '物业管理费')
  13517. $r14 += $v ['price'];
  13518. if ($va == '宽带费')
  13519. $r15 += $v ['price'];
  13520. $psum += $v ['price'];
  13521. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13522. $falg = false;
  13523. break;
  13524. }
  13525. }
  13526. }
  13527. if ($falg)
  13528. $html .= '<td class="taR">-</td>';
  13529. }
  13530. $r12 += $psum;
  13531. if (! empty ( $psum ))
  13532. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13533. else
  13534. $psum = '<td class="colGreen taR">-</td>';
  13535. $receiptL ['日常相关费用'] = $psum . $html;
  13536. /* ----------------------------------- */
  13537. $html = "";
  13538. $psum = 0;
  13539. $item = array (
  13540. '往来交通费',
  13541. '市内交通费',
  13542. '出差住宿费',
  13543. '出差补助',
  13544. '其他费用'
  13545. );
  13546. foreach ( $item as $va ) {
  13547. $falg = true;
  13548. foreach ( $receiptCollectList as $v ) {
  13549. if ($v ['itemCategory'] == '差旅相关费用') {
  13550. if ($v ['item'] == $va) {
  13551. if ($va == '往来交通费')
  13552. $c1 += $v ['price'];
  13553. if ($va == '市内交通费')
  13554. $c2 += $v ['price'];
  13555. if ($va == '出差住宿费')
  13556. $c3 += $v ['price'];
  13557. if ($va == '出差补助')
  13558. $c4 += $v ['price'];
  13559. if ($va == '其他费用')
  13560. $c5 += $v ['price'];
  13561. $psum += $v ['price'];
  13562. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13563. $falg = false;
  13564. break;
  13565. }
  13566. }
  13567. }
  13568. if ($falg)
  13569. $html .= '<td class="taR">-</td>';
  13570. }
  13571. $c6 += $psum;
  13572. if (! empty ( $psum ))
  13573. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13574. else
  13575. $psum = '<td class="colGreen taR">-</td>';
  13576. $receiptL ['差旅相关费用'] = $psum . $html;
  13577. /* ------------------------------------- */
  13578. $html = "";
  13579. $psum = 0;
  13580. $item = array (
  13581. '场租费',
  13582. '薪酬',
  13583. '住宿费',
  13584. '交通费',
  13585. '餐饮费',
  13586. '办公费',
  13587. '公关费',
  13588. '其他'
  13589. );
  13590. foreach ( $item as $va ) {
  13591. $falg = true;
  13592. foreach ( $receiptCollectList as $v ) {
  13593. if ($v ['itemCategory'] == '培训班费用') {
  13594. if ($v ['item'] == $va) {
  13595. if ($va == '场租费')
  13596. $p1 += $v ['price'];
  13597. if ($va == '薪酬')
  13598. $p2 += $v ['price'];
  13599. if ($va == '住宿费')
  13600. $p3 += $v ['price'];
  13601. if ($va == '交通费')
  13602. $p4 += $v ['price'];
  13603. if ($va == '餐饮费')
  13604. $p5 += $v ['price'];
  13605. if ($va == '办公费')
  13606. $p6 += $v ['price'];
  13607. if ($va == '公关费')
  13608. $p7 += $v ['price'];
  13609. if ($va == '其他')
  13610. $p8 += $v ['price'];
  13611. $psum += $v ['price'];
  13612. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13613. $falg = false;
  13614. break;
  13615. }
  13616. }
  13617. }
  13618. if ($falg)
  13619. $html .= '<td class="taR">-</td>';
  13620. }
  13621. $p9 += $psum;
  13622. if (! empty ( $psum ))
  13623. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13624. else
  13625. $psum = '<td class="colGreen taR">-</td>';
  13626. $receiptL ['培训班费用'] = $psum . $html;
  13627. /* ------------------------------------- */
  13628. $html = "";
  13629. $psum = 0;
  13630. $item = array (
  13631. '公关费',
  13632. '广告费',
  13633. '借款',
  13634. '可自加费用'
  13635. );
  13636. foreach ( $item as $va ) {
  13637. $falg = true;
  13638. foreach ( $receiptCollectList as $v ) {
  13639. if ($v ['itemCategory'] == '其他') {
  13640. if ($v ['item'] == $va) {
  13641. if ($va == '公关费')
  13642. $t1 += $v ['price'];
  13643. if ($va == '广告费')
  13644. $t2 += $v ['price'];
  13645. if ($va == '借款')
  13646. $t3 += $v ['price'];
  13647. if ($va == '可自加费用')
  13648. $t4 += $v ['price'];
  13649. $psum += $v ['price'];
  13650. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13651. $falg = false;
  13652. break;
  13653. }
  13654. }
  13655. }
  13656. if ($falg)
  13657. $html .= '<td class="taR">-</td>';
  13658. }
  13659. $t5 += $psum;
  13660. if (! empty ( $psum ))
  13661. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13662. else
  13663. $psum = '<td class="colGreen taR">-</td>';
  13664. $receiptL ['其他'] = $psum . $html;
  13665. /* ------------------------------------- */
  13666. $html = "";
  13667. $psum = 0;
  13668. foreach ( $receiptCollectList as $v ) {
  13669. if ($v ['itemCategory'] == '报销金额调整') {
  13670. if (! empty ( $v ['price'] )) {
  13671. $psum += $v ['price'];
  13672. }
  13673. }
  13674. }
  13675. $s1 += $psum;
  13676. if (! empty ( $psum ))
  13677. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13678. else
  13679. $psum = '<td class="taR colOrange">-</td>';
  13680. $receiptL ['报销金额调整'] = $psum . $html;
  13681. } else {
  13682. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13683. <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>';
  13684. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13685. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13686. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13687. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13688. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13689. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13690. }
  13691. $monthStaffPrice = $receiptDetail->find ( array (
  13692. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13693. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13694. 'asArray' => true
  13695. ) );
  13696. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13697. $m1 += $monthStaffPrice [0] ['price'];
  13698. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13699. } else
  13700. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13701. $list [$value ['username']] = $receiptL;
  13702. }
  13703. }
  13704. $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>
  13705. <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>
  13706. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13707. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13708. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13709. $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>
  13710. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13711. $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>';
  13712. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13713. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13714. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13715. }
  13716. $data ['list'] = $list;
  13717. $receiptCollectList = $receiptDetail->find ( array (
  13718. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13719. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13720. 'groupby' => 'item,Month(date),itemCategory',
  13721. 'asArray' => true
  13722. ) );
  13723. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13724. // statistics html
  13725. $stList = $statistics->getOne ( array (
  13726. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13727. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13728. 'groupby' => 'Month(date)',
  13729. 'asArray' => true
  13730. ) );
  13731. if (empty ( $stList ))
  13732. $stList = array (
  13733. 'rePrice' => 0,
  13734. 'agPrice' => 0
  13735. );
  13736. $data ['stList'] = array (
  13737. 'rePrice' => $stList ['rePrice'],
  13738. 'agPrice' => $stList ['agPrice'],
  13739. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13740. );
  13741. $monthHtml = "";
  13742. for($i = 1; $i <= 12; $i ++) {
  13743. if ($i == $month)
  13744. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13745. else
  13746. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13747. }
  13748. $data ['monthHtml'] = $monthHtml;
  13749. $data ['year'] = $year;
  13750. $data ['month'] = $month;
  13751. $data ['memu'] = "receipt";
  13752. $data ['staff'] = $this->staff;
  13753. $data ['receiptMemu'] = 'companyCategoryCollect';
  13754. $data ['verifyId'] = $this->verifyId;
  13755. $data ['executeId'] = $this->executeId;
  13756. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13757. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13758. }
  13759. /**
  13760. * 用户报销单列表
  13761. */
  13762. function receiptStatisticsStaffDetail() {
  13763. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13764. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13765. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13766. Doo::loadModel ( "receipt" );
  13767. $receipt = new receipt ();
  13768. Doo::loadModel ( "receiptDetail" );
  13769. $receiptDetail = new receiptDetail ();
  13770. Doo::loadModel ( 'staff' );
  13771. $staff = new staff ();
  13772. Doo::loadModel ( 'accountItem' );
  13773. $accountItem = new accountItem ();
  13774. Doo::loadModel ( 'statistics' );
  13775. $statistics = new statistics ();
  13776. if (! empty ( $username )) {
  13777. $username = addslashes ( urldecode ( $username ) );
  13778. $staffDetail = $staff->getStaffByName ( $username );
  13779. if (empty ( $staffDetail ))
  13780. die ( 'illegal request' );
  13781. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13782. $itemList = $accountItem->getAccountItem ();
  13783. $itemHtml = '';
  13784. $categoryHtml = '';
  13785. $itemKeyList = array_keys ( $itemList );
  13786. $revisePrice = 0;
  13787. // 报销单内容详情
  13788. foreach ( $list as $key => $value ) {
  13789. $accountItemList = json_decode ( $value ['accountItem'], true );
  13790. $list [$key] ['accountItemList'] = $accountItemList;
  13791. $receiptItemHtml = '';
  13792. foreach ( $itemKeyList as $v ) {
  13793. if ($v == '日常相关费用')
  13794. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13795. elseif ($v == '差旅相关费用')
  13796. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13797. elseif ($v == '培训班费用')
  13798. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13799. elseif ($v == '内部培训费用'){
  13800. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13801. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13802. }else{
  13803. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13804. }
  13805. }elseif ($v == '其他')
  13806. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13807. foreach ( $itemList [$v] as $ke => $va ) {
  13808. $falg = true;
  13809. if (! empty ( $accountItemList [$v] )) {
  13810. foreach ( $accountItemList [$v] as $ve ) {
  13811. if ($va ['name'] == $ve ['name']) {
  13812. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13813. $falg = false;
  13814. break;
  13815. }
  13816. }
  13817. }
  13818. if ($falg)
  13819. $receiptItemHtml .= '<td class="taR"></td>';
  13820. }
  13821. }
  13822. // 金额调整和费用查看
  13823. $revisePrice += $value ['revisePrice'];
  13824. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13825. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13826. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13827. }
  13828. // 报销单合计
  13829. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13830. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13831. $receiptTotalHtml = '';
  13832. // 报销单项目抬头
  13833. foreach ( $itemKeyList as $value ) {
  13834. $count = count ( $itemList [$value] ) + 1;
  13835. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13836. $categoryHtml .= '<th class="taC">合计</th>';
  13837. $sumfalg=true;
  13838. foreach ( $rtl as $rtlValue ) {
  13839. if ($rtlValue ['itemCategory'] == $value) {
  13840. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13841. $sumfalg=false;
  13842. break;
  13843. }
  13844. }
  13845. if ($sumfalg)
  13846. $receiptTotalHtml .= '<th></th>';
  13847. foreach ( $itemList [$value] as $k => $v ) {
  13848. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13849. // 合计
  13850. $falg = true;
  13851. foreach ( $receiptTotalList as $ve ) {
  13852. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13853. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13854. $falg = false;
  13855. break;
  13856. }
  13857. }
  13858. if ($falg)
  13859. $receiptTotalHtml .= '<th></th>';
  13860. }
  13861. }
  13862. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13863. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13864. if (empty ( $stList ))
  13865. $stList = array (
  13866. 'rePrice' => 0,
  13867. 'agPrice' => 0
  13868. );
  13869. $data ['stList'] = array (
  13870. 'rePrice' => $stList ['rePrice'],
  13871. 'agPrice' => $stList ['agPrice'],
  13872. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13873. );
  13874. $monthHtml = "";
  13875. for($i = 1; $i <= 12; $i ++) {
  13876. if ($i == $month)
  13877. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13878. else
  13879. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13880. }
  13881. $data ['username'] = urlencode ( $username );
  13882. $data ['usernameEN'] = $username;
  13883. $data ['monthHtml'] = $monthHtml;
  13884. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13885. $data ['list'] = $list;
  13886. $data ['categoryHtml'] = $categoryHtml;
  13887. $data ['itemHtml'] = $itemHtml;
  13888. $data ['itemList'] = $itemList;
  13889. $data ['year'] = $year;
  13890. $data ['month'] = $month;
  13891. $data ['memu'] = "receipt";
  13892. $data ['staff'] = $this->staff;
  13893. $data ['receiptMemu'] = 'companyCategoryCollect';
  13894. $data ['verifyId'] = $this->verifyId;
  13895. $data ['executeId'] = $this->executeId;
  13896. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13897. }
  13898. die ( 'illegal request' );
  13899. }
  13900. function companyMonthCollectDetail() {
  13901. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13902. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13903. if (! $year)
  13904. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13905. if (! $month)
  13906. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13907. Doo::loadModel ( 'staff' );
  13908. $staff = new staff ();
  13909. Doo::loadModel ( "receiptDetail" );
  13910. $receiptDetail = new receiptDetail ();
  13911. Doo::loadModel ( 'accountItem' );
  13912. $accountItem = new accountItem ();
  13913. Doo::loadModel ( 'statistics' );
  13914. $statistics = new statistics ();
  13915. Doo::loadModel ( 'L_category' );
  13916. $lCategory = new L_category ();
  13917. $staffList = $staff->find ( array (
  13918. 'where' => 'username!="admin"',
  13919. 'asArray' => true
  13920. ) );
  13921. $categoryList = $lCategory->find ( array (
  13922. 'asArray' => true
  13923. ) );
  13924. $aiList=$accountItem->getAccountItem();
  13925. $list = array ();
  13926. foreach ( $categoryList as $value ) {
  13927. $receiptCollectList = $receiptDetail->find ( array (
  13928. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13929. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13930. 'groupby' => 'item,Month(pastDate),itemCategory',
  13931. 'asArray' => true
  13932. ) );
  13933. if (! empty ( $receiptCollectList )) {
  13934. $receiptL = array (
  13935. '日常相关费用' => array (),
  13936. '差旅相关费用' => array (),
  13937. '内部培训费用' => array (),
  13938. '培训班费用' => array (),
  13939. '其他' => array ()
  13940. );
  13941. $html = "";
  13942. $psum = 0;
  13943. foreach ( $aiList[$this->AGENCY] as $va ) {
  13944. $falg = true;
  13945. foreach ( $receiptCollectList as $v ) {
  13946. if ($v ['itemCategory'] == $this->AGENCY) {
  13947. if ($v ['item'] == $va['name']) {
  13948. $psum += $v ['price'];
  13949. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13950. $falg = false;
  13951. break;
  13952. }
  13953. }
  13954. }
  13955. if ($falg)
  13956. $html .= '<td class="taR">-</td>';
  13957. }
  13958. if (! empty ( $psum ))
  13959. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13960. else
  13961. $psum = '<td class="colGreen taR">-</td>';
  13962. $receiptL [$this->AGENCY] = $psum . $html;
  13963. /* ----------------------------------- */
  13964. $html = "";
  13965. $psum = 0;
  13966. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13967. $falg = true;
  13968. foreach ( $receiptCollectList as $v ) {
  13969. if ($v ['itemCategory'] == $this->TRAVEL) {
  13970. if ($v ['item'] == $va['name']) {
  13971. $psum += $v ['price'];
  13972. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13973. $falg = false;
  13974. break;
  13975. }
  13976. }
  13977. }
  13978. if ($falg)
  13979. $html .= '<td class="taR">-</td>';
  13980. }
  13981. if (! empty ( $psum ))
  13982. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13983. else
  13984. $psum = '<td class="colGreen taR">-</td>';
  13985. $receiptL [$this->TRAVEL] = $psum . $html;
  13986. /* ------------------------------------- */
  13987. $html = "";
  13988. $psum = 0;
  13989. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13990. $falg = true;
  13991. foreach ( $receiptCollectList as $v ) {
  13992. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13993. if ($v ['item'] == $va['name']) {
  13994. $psum += $v ['price'];
  13995. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13996. $falg = false;
  13997. break;
  13998. }
  13999. }
  14000. }
  14001. if ($falg)
  14002. $html .= '<td class="taR">-</td>';
  14003. }
  14004. if (! empty ( $psum ))
  14005. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14006. else
  14007. $psum = '<td class="colGreen taR">-</td>';
  14008. $receiptL [$this->INTTRAIN] = $psum . $html;
  14009. /* ------------------------------------- */
  14010. $html = "";
  14011. $psum = 0;
  14012. foreach ( $aiList[$this->TRAIN] as $va ) {
  14013. $falg = true;
  14014. foreach ( $receiptCollectList as $v ) {
  14015. if ($v ['itemCategory'] == $this->TRAIN) {
  14016. if ($v ['item'] == $va['name']) {
  14017. $psum += $v ['price'];
  14018. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14019. $falg = false;
  14020. break;
  14021. }
  14022. }
  14023. }
  14024. if ($falg)
  14025. $html .= '<td class="taR">-</td>';
  14026. }
  14027. if (! empty ( $psum ))
  14028. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14029. else
  14030. $psum = '<td class="colGreen taR">-</td>';
  14031. $receiptL [$this->TRAIN] = $psum . $html;
  14032. /* ------------------------------------- */
  14033. $html = "";
  14034. $psum = 0;
  14035. foreach ( $aiList[$this->OTHER] as $va ) {
  14036. $falg = true;
  14037. foreach ( $receiptCollectList as $v ) {
  14038. if ($v ['itemCategory'] == $this->OTHER) {
  14039. if ($v ['item'] == $va['name']) {
  14040. $psum += $v ['price'];
  14041. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14042. $falg = false;
  14043. break;
  14044. }
  14045. }
  14046. }
  14047. if ($falg)
  14048. $html .= '<td class="taR">-</td>';
  14049. }
  14050. if (! empty ( $psum ))
  14051. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14052. else
  14053. $psum = '<td class="colGreen taR">-</td>';
  14054. $receiptL [$this->OTHER] = $psum . $html;
  14055. /* ------------------------------------- */
  14056. $html = "";
  14057. $psum = 0;
  14058. foreach ( $receiptCollectList as $v ) {
  14059. if ($v ['itemCategory'] == '报销金额调整') {
  14060. if (! empty ( $v ['price'] ))
  14061. $psum += $v ['price'];
  14062. }
  14063. }
  14064. if (! empty ( $psum ))
  14065. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14066. else
  14067. $psum = '<td class="taR colOrange">-</td>';
  14068. $receiptL ['报销金额调整'] = $psum . $html;
  14069. } else {
  14070. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14071. foreach ( $aiList[$this->AGENCY] as $va ) {
  14072. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14073. }
  14074. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14075. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14076. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14077. }
  14078. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14079. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14080. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14081. }
  14082. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14083. foreach ( $aiList[$this->TRAIN] as $va ) {
  14084. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14085. }
  14086. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14087. foreach ( $aiList[$this->OTHER] as $va ) {
  14088. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14089. }
  14090. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14091. }
  14092. $monthStaffPrice = $receiptDetail->find ( array (
  14093. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14094. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14095. 'asArray' => true
  14096. ) );
  14097. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14098. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14099. else
  14100. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14101. $list [$value ['title']] = $receiptL;
  14102. }
  14103. $data ['list'] = $list;
  14104. $receiptCollectList = $receiptDetail->find ( array (
  14105. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14106. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14107. 'groupby' => 'item,Month(pastDate),itemCategory',
  14108. 'asArray' => true
  14109. ) );
  14110. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14111. //print_r($data['monthPriceHtml']);
  14112. // foreach ($data['monthPriceHtml'] as $value){
  14113. // echo $value;
  14114. // }
  14115. // die;
  14116. // statistics html
  14117. $stList = $statistics->getOne ( array (
  14118. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14119. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14120. 'groupby' => 'Month(date)',
  14121. 'asArray' => true
  14122. ) );
  14123. if (empty ( $stList ))
  14124. $stList = array (
  14125. 'rePrice' => 0,
  14126. 'agPrice' => 0
  14127. );
  14128. $data ['stList'] = array (
  14129. 'rePrice' => $stList ['rePrice'],
  14130. 'agPrice' => $stList ['agPrice'],
  14131. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14132. );
  14133. $monthHtml = "";
  14134. for($i = 1; $i <= 12; $i ++) {
  14135. if ($i == $month)
  14136. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14137. else
  14138. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14139. }
  14140. $data ['aiList'] = $aiList;
  14141. $dateHtml = "";
  14142. $now = date ( "Y" );
  14143. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14144. if ($YEARD <= $now) {
  14145. $dateHtml .= '<option ';
  14146. if ($year == $YEARD) {
  14147. $dateHtml .= 'selected ';
  14148. }
  14149. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14150. }
  14151. }
  14152. $data ['dateHtml'] = $dateHtml;
  14153. $data ['monthHtml'] = $monthHtml;
  14154. $data ['year'] = $year;
  14155. $data ['month'] = $month;
  14156. $data ['memu'] = "receipt";
  14157. $data ['staff'] = $this->staff;
  14158. $data ['receiptMemu'] = 'companyCategoryCollect';
  14159. $data ['verifyId'] = $this->verifyId;
  14160. $data ['executeId'] = $this->executeId;
  14161. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14162. }
  14163. function staffCollectDetail() {
  14164. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14165. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14166. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14167. if (! $staffname) {
  14168. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14169. $staffname = urldecode ( $staffname );
  14170. }
  14171. Doo::loadModel ( 'staff' );
  14172. $staff = new staff ();
  14173. Doo::loadModel ( "receiptDetail" );
  14174. $receiptDetail = new receiptDetail ();
  14175. Doo::loadModel ( 'accountItem' );
  14176. $accountItem = new accountItem ();
  14177. Doo::loadModel ( 'statistics' );
  14178. $statistics = new statistics ();
  14179. Doo::loadModel ( 'L_category' );
  14180. $lCategory = new L_category ();
  14181. Doo::loadModel ( "receiptAuthorityManage" );
  14182. $receiptAuthorityManage = new receiptAuthorityManage ();
  14183. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14184. $cidList = array ();
  14185. foreach ( $imcStaff as $key => $value ) {
  14186. array_push ( $cidList, $value ['cid'] );
  14187. }
  14188. $cidString = implode ( ',', $cidList );
  14189. $staffList = $staff->find ( array (
  14190. 'where' => ' cid in (' . $cidString . ')',
  14191. 'asArray' => true
  14192. ) );
  14193. $stHtml = '';
  14194. $stTitle = "";
  14195. $staffId = 0;
  14196. $cid = 0;
  14197. $ocid = 0;
  14198. foreach ( $staffList as $value ) {
  14199. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14200. $stTitle = $value ['category'] . '-' . $value ['username'];
  14201. $staffId = $value ['sid'];
  14202. $cid = $value ['cid'];
  14203. $ocid = $value ['cid'];
  14204. if (! empty ( $value ['othercid'] ))
  14205. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14206. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14207. } elseif ($value ['username'] != 'admin')
  14208. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14209. }
  14210. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14211. 'where' => 'cid in(' . $cid . ')',
  14212. 'asArray' => true
  14213. ) );
  14214. if (empty ( $pcid ))
  14215. $pcid = $ocid;
  14216. $data ['ocid'] = $pcid;
  14217. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14218. $this->showCache ( $path );
  14219. //
  14220. $receiptCollectList = $receiptDetail->find ( array (
  14221. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14222. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14223. 'groupby' => 'item,Month(pastDate),itemCategory',
  14224. 'asArray' => true
  14225. ) );
  14226. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14227. // print_r($receiptCollectList);
  14228. $accountList = $accountItem->find ( array (
  14229. 'asArray' => true
  14230. ) );
  14231. // create CollectDetail HTML
  14232. $collectHtml = array ();
  14233. foreach ( $accountList as $key => $value ) {
  14234. $html = "";
  14235. $asum = 0;
  14236. for($i = 1; $i <= 12; $i ++) {
  14237. $falg = true;
  14238. foreach ( $receiptCollectList as $v ) {
  14239. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14240. if ($v ['item'] == '可自加费用') {
  14241. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14242. }
  14243. $asum += $v ['price'];
  14244. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14245. $falg = false;
  14246. break;
  14247. }
  14248. }
  14249. if ($falg)
  14250. $html .= '<td class="taR">-</td>';
  14251. }
  14252. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14253. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14254. }
  14255. $data ['collectHtml'] = $collectHtml;
  14256. // print_r($collectHtml);
  14257. // create Adjustment price html
  14258. $receiptCollectList = $receiptDetail->find ( array (
  14259. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14260. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14261. 'groupby' => 'itemCategory,Month(pastDate)',
  14262. 'asArray' => true
  14263. ) );
  14264. $adjustment = array ();
  14265. $collectArray = array (
  14266. '日常相关费用' => array (),
  14267. '差旅相关费用' => array (),
  14268. '培训班费用' => array (),
  14269. '内部培训费用'=>array(),
  14270. '其他' => array ()
  14271. );
  14272. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14273. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14274. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14275. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14276. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14277. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14278. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14279. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14280. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14281. array_push ( $collectArray ['其他'], $collectHtml );
  14282. $data ['collectArray'] = $collectArray;
  14283. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14284. array_push ( $adjustment, $collectHtml );
  14285. $data ['adjustment'] = $adjustment;
  14286. // total price html
  14287. $collectHtml = "";
  14288. $total = 0;
  14289. for($i = 1; $i <= 12; $i ++) {
  14290. $sumPrice = 0;
  14291. foreach ( $receiptCollectList as $key => $value ) {
  14292. if ($value ['month'] == $i) {
  14293. $sumPrice += $value ['price'];
  14294. }
  14295. }
  14296. if ($sumPrice == 0)
  14297. $collectHtml .= '<td class="taR">-</td>';
  14298. else
  14299. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14300. $total += $sumPrice;
  14301. }
  14302. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14303. // statistics html
  14304. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14305. if (empty ( $stList ))
  14306. $stList = array (
  14307. 'rePrice' => 0,
  14308. 'agPrice' => 0
  14309. );
  14310. $data ['stList'] = array (
  14311. 'rePrice' => $stList ['rePrice'],
  14312. 'agPrice' => $stList ['agPrice'],
  14313. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14314. );
  14315. $data ['totalPrice'] = $collectHtml;
  14316. $data ['totalYear'] = $total;
  14317. $data ['stHtml'] = $stHtml;
  14318. $data ['year'] = $year;
  14319. $data ['stTitle'] = $stTitle;
  14320. $data ['staffname'] = urlencode ( $staffname );
  14321. $data ['memu'] = "receipt";
  14322. $data ['staff'] = $this->staff;
  14323. $data ['receiptMemu'] = 'companyCategoryCollect';
  14324. $data ['verifyId'] = $this->verifyId;
  14325. $data ['executeId'] = $this->executeId;
  14326. if ($year < date ( "Y" )) {
  14327. Doo::loadModel ( 'receipt' );
  14328. $receipt = new receipt ();
  14329. $receiptList = $receipt->find ( array (
  14330. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14331. 'asArray' => true
  14332. ) );
  14333. if (empty ( $receiptList )) { // generated files
  14334. ob_start ();
  14335. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14336. $this->cacheFile ( $path );
  14337. die ();
  14338. }
  14339. }
  14340. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14341. }
  14342. function BUGFLAG() {
  14343. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14344. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14345. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14346. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14347. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14348. if (empty ( $status ))
  14349. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14350. $page_size = 12;
  14351. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14352. $vidList = array ();
  14353. $button = 0;
  14354. Doo::loadModel ( 'verify' );
  14355. $verify = new verify ();
  14356. Doo::loadModel ( 'receipt' );
  14357. $receipt = new receipt ();
  14358. Doo::loadModel ( 'staff' );
  14359. $staff = new staff ();
  14360. Doo::loadModel ( 'L_category' );
  14361. $Lcategory = new L_category ();
  14362. $dateCondition = " and Year(date) =" . $year;
  14363. if (! empty ( $month ))
  14364. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14365. $categoryList = $Lcategory->find ( array (
  14366. 'asArray' => true
  14367. ) );
  14368. $staffList = $staff->find ( array (
  14369. 'where' => 'cid=' . $cid,
  14370. 'asArray' => true
  14371. ) );
  14372. $cateCondition = "";
  14373. $staffCondition = "";
  14374. $approvalCondition = "";
  14375. if (! empty ( $cid ))
  14376. $cateCondition = ' and cid=' . $cid;
  14377. if (! empty ( $sid )) {
  14378. $staffCondition = ' and staff=' . $sid;
  14379. $cateCondition = "";
  14380. }
  14381. $approvalCondition = " and status=" . $status;
  14382. if ($status == 2) {
  14383. // 查找角色审批人
  14384. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14385. }
  14386. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14387. $approvalCondition = ' and status=2 ';
  14388. }
  14389. if ($status == 1) {
  14390. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14391. }
  14392. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14393. $pageinfo ['page'] = array (
  14394. 'previous' => ''
  14395. );
  14396. if ($status == 0) {
  14397. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14398. $receiptList = $receipt->find ( array (
  14399. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14400. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14401. 'desc' => 'rid',
  14402. 'asArray' => true
  14403. ) );
  14404. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14405. } else
  14406. $receiptList = $receipt->find ( array (
  14407. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14408. 'desc' => 'rid',
  14409. 'asArray' => true
  14410. ) );
  14411. $rLRes = $receipt->find ( array (
  14412. '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,
  14413. 'desc' => 'rid',
  14414. 'asArray' => true
  14415. ) );
  14416. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14417. // print_r($pageinfo);
  14418. $Locate = 0;
  14419. foreach ( $receiptList as $key => $value ) {
  14420. $receiptList [$key] ['Locate'] = $Locate;
  14421. $Locate ++;
  14422. $receiptList [$key] ['reviseDetail'] = array ();
  14423. if (! empty ( $value ['reviseDetail'] ))
  14424. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14425. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14426. $categoryDetil = $Lcategory->getOne ( array (
  14427. 'where' => 'cid=' . $value ['cid'],
  14428. 'asArray' => true
  14429. ) );
  14430. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14431. $verifyList = $verify->getOne ( array (
  14432. 'where' => 'vid=' . $value ['verify'],
  14433. 'asArray' => true
  14434. ) );
  14435. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14436. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14437. foreach ( $verifyList as $k => $v ) {
  14438. // init verifyStaff
  14439. $verifyList [$k] ['date'] = "";
  14440. $verifyList [$k] ['opinion'] = "";
  14441. $verifyList [$k] ['status'] = "";
  14442. if (empty ( $verifyStaff )) {
  14443. $verifyList [$k] ['date'] = "";
  14444. $verifyList [$k] ['opinion'] = "";
  14445. if ($v [0] == $this->staff [0] ['sid']) {
  14446. $verifyList [$k] ['status'] = 4;
  14447. $button = 4;
  14448. }
  14449. } else {
  14450. $flag = true;
  14451. foreach ( $verifyStaff as $m => $u ) {
  14452. if ($v [0] == $m) {
  14453. $verifyList [$k] ['date'] = $u ['date'];
  14454. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14455. $verifyList [$k] ['status'] = $u ['status'];
  14456. $flag = false;
  14457. break;
  14458. }
  14459. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14460. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14461. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14462. }
  14463. if ($flag) { // 检测可编辑
  14464. if ($v [0] == $this->staff [0] ['sid']) {
  14465. $verifyList [$k] ['status'] = 4;
  14466. $button = 4;
  14467. }
  14468. }
  14469. }
  14470. }
  14471. $receiptList [$key] ['verifyList'] = $verifyList;
  14472. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14473. 'where' => 'sid=' . $value ['staff'],
  14474. 'asArray' => true
  14475. ) );
  14476. $receiptList [$key] ['button'] = $button;
  14477. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14478. }
  14479. // print_r($receiptList);die;
  14480. // $data['verifyDetail']=$verifyDetail;
  14481. $mothHtml = "";
  14482. for($i = 1; $i <= 12; $i ++) {
  14483. if ($month == $i)
  14484. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14485. else
  14486. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14487. }
  14488. $data ['mothHtml'] = $mothHtml;
  14489. $data ['page'] = $pageinfo;
  14490. $data ['receiptList'] = $receiptList;
  14491. $data ['receiptApprovalCount'] = count ( $rLRes );
  14492. $data ['status'] = $status;
  14493. $data ['year'] = $year;
  14494. $data ['categoryList'] = $categoryList;
  14495. $data ['staffList'] = $staffList;
  14496. $data ['cid'] = $cid;
  14497. $data ['sid'] = $sid;
  14498. // print_r($receiptList);
  14499. $data ['memu'] = "receipt";
  14500. $data ['staff'] = $this->staff;
  14501. $data ['receiptMemu'] = 'approvalExpenses';
  14502. $data ['verifyId'] = $this->verifyId;
  14503. $data ['executeId'] = $this->executeId;
  14504. $this->render ( "/admin/FALG", $data );
  14505. }
  14506. function ajaxGetReceiptOrder() {
  14507. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14508. if (! empty ( $receiptOrder )) {
  14509. Doo::loadModel ( 'receipt' );
  14510. $receipt = new receipt ();
  14511. Doo::loadModel ( 'staff' );
  14512. $staff = new staff ();
  14513. $receiptInfo = $receipt->getOne ( array (
  14514. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14515. 'asArray' => true
  14516. ) );
  14517. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14518. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14519. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14520. </tbody></table><table class="table table table-bordered"><tbody>';
  14521. foreach ( $verifyStaff as $key => $value ) {
  14522. $staffInfo = $staff->getOne ( array (
  14523. 'select' => 'username',
  14524. 'where' => ' sid="' . $key . '"',
  14525. 'asArray' => true
  14526. ) );
  14527. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14528. }
  14529. $html .= '</tbody></table></div></div>';
  14530. echo json_encode ( array (
  14531. 'status' => 1,
  14532. 'receiptHtml' => $html
  14533. ) );
  14534. die ();
  14535. }
  14536. echo json_encode ( array (
  14537. 'status' => 2,
  14538. 'receiptHtml' => ''
  14539. ) );
  14540. die ();
  14541. }
  14542. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14543. if (! empty ( $receiptCollectList )) {
  14544. $receiptL = array (
  14545. '日常相关费用' => array (),
  14546. '差旅相关费用' => array (),
  14547. '内部培训费用'=>array(),
  14548. '培训班费用' => array (),
  14549. '其他' => array ()
  14550. );
  14551. $html = "";
  14552. $psum = 0;
  14553. foreach ( $aiList[$this->AGENCY] as $value ) {
  14554. $falg = true;
  14555. foreach ( $receiptCollectList as $v ) {
  14556. if ($v ['itemCategory'] == '日常相关费用') {
  14557. if ($v ['item'] == $value['name']) {
  14558. $psum += $v ['price'];
  14559. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14560. $falg = false;
  14561. break;
  14562. }
  14563. }
  14564. }
  14565. if ($falg)
  14566. $html .= '<td class="taR">-</td>';
  14567. }
  14568. if (! empty ( $psum ))
  14569. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14570. else
  14571. $psum = '<td class="colGreen taR">-</td>';
  14572. $receiptL ['日常相关费用'] = $psum . $html;
  14573. /* ----------------------------------- */
  14574. $html = "";
  14575. $psum = 0;
  14576. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14577. $falg = true;
  14578. foreach ( $receiptCollectList as $v ) {
  14579. if ($v ['itemCategory'] == '差旅相关费用') {
  14580. if ($v ['item'] == $value['name']) {
  14581. $psum += $v ['price'];
  14582. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14583. $falg = false;
  14584. break;
  14585. }
  14586. }
  14587. }
  14588. if ($falg)
  14589. $html .= '<td class="taR">-</td>';
  14590. }
  14591. if (! empty ( $psum ))
  14592. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14593. else
  14594. $psum = '<td class="colGreen taR">-</td>';
  14595. $receiptL ['差旅相关费用'] = $psum . $html;
  14596. /* ----------------------------------- */
  14597. $html = "";
  14598. $psum = 0;
  14599. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14600. $falg = true;
  14601. foreach ( $receiptCollectList as $v ) {
  14602. if ($v ['itemCategory'] == '内部培训费用') {
  14603. if ($v ['item'] == $value['name']) {
  14604. $psum += $v ['price'];
  14605. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14606. $falg = false;
  14607. break;
  14608. }
  14609. }
  14610. }
  14611. if ($falg)
  14612. $html .= '<td class="taR">-</td>';
  14613. }
  14614. if (! empty ( $psum ))
  14615. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14616. else
  14617. $psum = '<td class="colGreen taR">-</td>';
  14618. $receiptL ['内部培训费用'] = $psum . $html;
  14619. /* ------------------------------------- */
  14620. $html = "";
  14621. $psum = 0;
  14622. foreach ( $aiList[$this->TRAIN] as $value ) {
  14623. $falg = true;
  14624. foreach ( $receiptCollectList as $v ) {
  14625. if ($v ['itemCategory'] == '培训班费用') {
  14626. if ($v ['item'] == $value['name']) {
  14627. $psum += $v ['price'];
  14628. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14629. $falg = false;
  14630. break;
  14631. }
  14632. }
  14633. }
  14634. if ($falg)
  14635. $html .= '<td class="taR">-</td>';
  14636. }
  14637. if (! empty ( $psum ))
  14638. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14639. else
  14640. $psum = '<td class="colGreen taR">-</td>';
  14641. $receiptL ['培训班费用'] = $psum . $html;
  14642. /* ------------------------------------- */
  14643. $html = "";
  14644. $psum = 0;
  14645. foreach ( $aiList[$this->OTHER] as $value ) {
  14646. $falg = true;
  14647. foreach ( $receiptCollectList as $v ) {
  14648. if ($v ['itemCategory'] == '其他') {
  14649. if ($v ['item'] == $value['name']) {
  14650. $psum += $v ['price'];
  14651. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14652. $falg = false;
  14653. break;
  14654. }
  14655. }
  14656. }
  14657. if ($falg)
  14658. $html .= '<td class="taR">-</td>';
  14659. }
  14660. if (! empty ( $psum ))
  14661. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14662. else
  14663. $psum = '<td class="colGreen taR">-</td>';
  14664. $receiptL ['其他'] = $psum . $html;
  14665. /* ------------------------------------- */
  14666. $html = "";
  14667. $psum = 0;
  14668. foreach ( $receiptCollectList as $v ) {
  14669. if ($v ['itemCategory'] == '报销金额调整') {
  14670. if (! empty ( $v ['price'] ))
  14671. $psum += $v ['price'];
  14672. }
  14673. }
  14674. if (! empty ( $psum ))
  14675. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14676. else
  14677. $psum = '<td class="taR colOrange">-</td>';
  14678. $receiptL ['报销金额调整'] = $psum . $html;
  14679. } else {
  14680. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14681. foreach ( $aiList[$this->AGENCY] as $va ) {
  14682. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14683. }
  14684. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14685. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14686. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14687. }
  14688. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14689. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14690. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14691. }
  14692. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14693. foreach ( $aiList[$this->TRAIN] as $va ) {
  14694. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14695. }
  14696. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14697. foreach ( $aiList[$this->OTHER] as $va ) {
  14698. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14699. }
  14700. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14701. }
  14702. return $receiptL;
  14703. }
  14704. function eMail() {
  14705. Doo::loadModel ( 'staff' );
  14706. $staff = new staff ();
  14707. Doo::loadModel ( 'receipt' );
  14708. $receipt = new receipt ();
  14709. Doo::loadModel ( 'L_category' );
  14710. $Lcategory = new L_category ();
  14711. Doo::loadModel ( "verify" );
  14712. $verify = new verify ();
  14713. $staffList = $staff->find ( array (
  14714. 'asArray' => true
  14715. ) );
  14716. foreach ( $staffList as $key => $value ) {
  14717. if ($value ['username'] != 'admin') {
  14718. // 提交人
  14719. $receiptList = $receipt->find ( array (
  14720. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14721. 'asArray' => true
  14722. ) );
  14723. if (! empty ( $receiptList )) {
  14724. $html = '<br><div><style></style>
  14725. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14726. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14727. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14728. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14729. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14730. <tbody><tr>
  14731. <td style="padding: 0 40px;" align="left">
  14732. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14733. </td></tr><tr>
  14734. <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>
  14735. </tr>
  14736. </tbody> </table></td> </tr> <tr><td>
  14737. <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">
  14738. <tbody> <tr><td>
  14739. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14740. 以下报销单完成了审批,等着收款吧:</p>
  14741. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14742. foreach ( $receiptList as $k => $v ) {
  14743. $category = $Lcategory->getOne ( array (
  14744. 'where' => 'cid=' . $v ['cid'],
  14745. 'asArray' => true
  14746. ) );
  14747. $html .= '
  14748. <tr>
  14749. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14750. <td align="left">
  14751. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14752. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14753. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14754. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14755. </tr>';
  14756. }
  14757. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14758. <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>
  14759. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14760. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14761. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14762. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14763. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14764. $receipt = new receipt ();
  14765. $receipt->notice = 1;
  14766. $receipt->update ( array (
  14767. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14768. ) );
  14769. }
  14770. }
  14771. // 审批人
  14772. $verifyList = $verify->find ( array (
  14773. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14774. 'asArray' => true
  14775. ) );
  14776. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14777. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14778. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14779. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14780. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14781. <tbody><tr><td style="padding: 0 40px;" align="left">
  14782. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14783. </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>
  14784. </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">
  14785. <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>
  14786. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14787. foreach ( $verifyList as $k => $v ) {
  14788. $receiptList = $receipt->find ( array (
  14789. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14790. 'asArray' => true
  14791. ) );
  14792. foreach ( $receiptList as $r => $l ) {
  14793. $category = $Lcategory->getOne ( array (
  14794. 'where' => 'cid=' . $l ['cid'],
  14795. 'asArray' => true
  14796. ) );
  14797. $staffDetile = $staff->getOne ( array (
  14798. 'where' => 'sid=' . $l ['staff'],
  14799. 'asArray' => true
  14800. ) );
  14801. $html .= '
  14802. <tr>
  14803. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14804. <td align="left">
  14805. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14806. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14807. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14808. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14809. </tr>';
  14810. }
  14811. }
  14812. $html .= '
  14813. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14814. <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>
  14815. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14816. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14817. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14818. // $receipt=new receipt();
  14819. // $receipt->notice=1;
  14820. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14821. }
  14822. }
  14823. }
  14824. }
  14825. function setWXMsg($rid, $type) {
  14826. Doo::loadModel ( "receipt" );
  14827. $receipt = new receipt ();
  14828. $receiptDetail = $receipt->getOne ( array (
  14829. 'where' => 'rid=' . $rid,
  14830. 'asArray' => true
  14831. ) );
  14832. if (! empty ( $receiptDetail )) {
  14833. Doo::loadModel ( 'staff' );
  14834. $staff = new staff ();
  14835. $staffmsg = $staff->getOne ( array (
  14836. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14837. 'asArray' => TRUE
  14838. ) );
  14839. if (! empty ( $staffmsg ['wxid'] )) {
  14840. require_once (SITE_PATH . '/protected/class/client.php');
  14841. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14842. $user = $staffmsg ['wxid'];
  14843. $receiptName = '';
  14844. $msg = '';
  14845. switch ($receiptDetail ['Rtype']) {
  14846. case 0 :
  14847. $receiptName = '报销';
  14848. break;
  14849. case 1 :
  14850. $receiptName = '借款';
  14851. break;
  14852. case 2 :
  14853. $receiptName = '对公汇款';
  14854. break;
  14855. }
  14856. switch ($type) {
  14857. case 1 :
  14858. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14859. break;
  14860. case 2 :
  14861. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14862. break;
  14863. case 3 :
  14864. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14865. break;
  14866. }
  14867. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14868. }
  14869. }
  14870. }
  14871. // Email发送函数
  14872. function SMail($toemail, $subject, $contents) {
  14873. Doo::loadClass ( 'class.phpmailer' );
  14874. $mail = new PHPMailer ();
  14875. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14876. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14877. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14878. $mail->Password = "cDO1GjtY1seH"; // 密码
  14879. $mail->CharSet = "UTF8";
  14880. $mail->SMTPAuth = true;
  14881. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14882. $mail->Mailer = "smtp";
  14883. $mail->Port = 25;
  14884. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14885. $mail->MsgHTML ( $contents );
  14886. $mail->AddAddress ( $toemail );
  14887. $mail->CharSet = "UTF-8";
  14888. return $mail->Send ();
  14889. }
  14890. function h5Upload() {
  14891. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14892. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14893. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14894. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14895. header ( "HTTP/1.1 500 Internal Server Error" );
  14896. echo "POST exceeded maximum allowed size.";
  14897. exit ( 0 );
  14898. }
  14899. // Settings
  14900. $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)
  14901. $upload_name = "Filedata";
  14902. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14903. $extension_whitelist = array (
  14904. "doc",
  14905. "txt",
  14906. "jpg",
  14907. "gif",
  14908. "png"
  14909. ); // Allowed file extensions
  14910. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14911. // Other variables
  14912. $MAX_FILENAME_LENGTH = 260;
  14913. $file_name = "";
  14914. $file_extension = "";
  14915. $uploadErrors = array (
  14916. 0 => "文件上传成功",
  14917. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14918. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14919. 3 => "上传的文件仅为部分文件",
  14920. 4 => "没有文件上传",
  14921. 6 => "缺少临时文件夹"
  14922. );
  14923. $nk = time ();
  14924. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14925. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14926. echo "文件无法保存.";
  14927. exit ( 0 );
  14928. }
  14929. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14930. echo json_encode ( array (
  14931. 'filename' => $file_name,
  14932. 'id' => $nk
  14933. ) );
  14934. exit ( 0 );
  14935. }
  14936. function swfupload() {
  14937. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14938. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14939. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14940. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14941. header ( "HTTP/1.1 500 Internal Server Error" );
  14942. echo "POST exceeded maximum allowed size.";
  14943. exit ( 0 );
  14944. }
  14945. // Settings
  14946. $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)
  14947. $upload_name = "Filedata";
  14948. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14949. $extension_whitelist = array (
  14950. "doc",
  14951. "txt",
  14952. "jpg",
  14953. "gif",
  14954. "png"
  14955. ); // Allowed file extensions
  14956. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14957. // Other variables
  14958. $MAX_FILENAME_LENGTH = 260;
  14959. $file_name = "";
  14960. $file_extension = "";
  14961. $uploadErrors = array (
  14962. 0 => "文件上传成功",
  14963. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14964. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14965. 3 => "上传的文件仅为部分文件",
  14966. 4 => "没有文件上传",
  14967. 6 => "缺少临时文件夹"
  14968. );
  14969. $nk = time ();
  14970. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14971. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14972. echo "文件无法保存.";
  14973. exit ( 0 );
  14974. }
  14975. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14976. echo json_encode ( array (
  14977. 'filename' => $file_name,
  14978. 'id' => $nk
  14979. ) );
  14980. exit ( 0 );
  14981. }
  14982. function _GetFileEXT($filename) {
  14983. $pics = explode ( '.', $filename );
  14984. $num = count ( $pics );
  14985. return $pics [$num - 1];
  14986. }
  14987. /**
  14988. * 获取get或者POST值
  14989. * @param string $name 属性名称
  14990. * @return fixed 值
  14991. */
  14992. function get_args($name) {
  14993. if (isset ( $_GET [$name] )) {
  14994. if (is_array ( $_GET [$name] ))
  14995. return $_GET [$name];
  14996. else
  14997. return addslashes ( $_GET [$name] );
  14998. } elseif (isset ( $_POST [$name] )) {
  14999. if (is_array ( $_POST [$name] ))
  15000. return $_POST [$name];
  15001. else
  15002. return addslashes ( $_POST [$name] );
  15003. } else
  15004. return false;
  15005. }
  15006. function num_to_rmb($num) {
  15007. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15008. $c2 = "分角元拾佰仟万拾佰仟亿";
  15009. // 精确到分后面就不要了,所以只留两个小数位
  15010. $num = round ( $num, 2 );
  15011. // 将数字转化为整数
  15012. $num = $num * 100;
  15013. if (strlen ( $num ) > 10) {
  15014. return "金额太大,请检查";
  15015. }
  15016. $i = 0;
  15017. $c = "";
  15018. while ( 1 ) {
  15019. if ($i == 0) {
  15020. // 获取最后一位数字
  15021. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15022. } else {
  15023. $n = $num % 10;
  15024. }
  15025. // 每次将最后一位数字转化为中文
  15026. $p1 = substr ( $c1, 3 * $n, 3 );
  15027. $p2 = substr ( $c2, 3 * $i, 3 );
  15028. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15029. $c = $p1 . $p2 . $c;
  15030. } else {
  15031. $c = $p1 . $c;
  15032. }
  15033. $i = $i + 1;
  15034. // 去掉数字最后一位了
  15035. $num = $num / 10;
  15036. // echo $num.'</br>';
  15037. $num = ( int ) $num;
  15038. // $num =floor($num);
  15039. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15040. // echo $num.'</br>';
  15041. // 结束循环
  15042. if ($num == 0) {
  15043. break;
  15044. }
  15045. }
  15046. // echo $c.'</br>';
  15047. $j = 0;
  15048. $slen = strlen ( $c );
  15049. while ( $j < $slen ) {
  15050. // utf8一个汉字相当3个字符
  15051. $m = substr ( $c, $j, 6 );
  15052. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15053. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15054. $left = substr ( $c, 0, $j );
  15055. $right = substr ( $c, $j + 3 );
  15056. $c = $left . $right;
  15057. $j = $j - 3;
  15058. $slen = $slen - 3;
  15059. }
  15060. $j = $j + 3;
  15061. }
  15062. // 这个是为了去掉类似23.0中最后一个“零”字
  15063. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15064. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15065. }
  15066. // 将处理的汉字加上“整”
  15067. if (empty ( $c )) {
  15068. return "零元整";
  15069. } else {
  15070. return $c . "整";
  15071. }
  15072. }
  15073. /**
  15074. * 获得分页数据
  15075. * @param unknown_type $table
  15076. * @param unknown_type $condition
  15077. * @param unknown_type $on_page
  15078. * @param unknown_type $page_size
  15079. */
  15080. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15081. $page_c = "";
  15082. $page ['previous'] = $this->get_previous ( $on_page );
  15083. $page ['on_page'] = $on_page;
  15084. $total_count = $this->get_table_count ( $table, $condition );
  15085. $total = intval ( $total_count / $page_size );
  15086. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15087. $page ['total_data'] = $total_count;
  15088. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15089. $i = 1;
  15090. $page_max = 1;
  15091. $page_width = 3;
  15092. if ($on_page >= $page_width) {
  15093. $page_max = intval ( $on_page / $page_width ) + 1;
  15094. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15095. }
  15096. for(; $i <= $page ['total_page']; $i ++) {
  15097. if ($i == $on_page)
  15098. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15099. else
  15100. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15101. if ($i == ($page_width * $page_max))
  15102. break;
  15103. }
  15104. $page ['page'] = $page_c;
  15105. $page ['lower'] = (-- $on_page) * $page_size;
  15106. return $page;
  15107. }
  15108. /**
  15109. * 获取总页数
  15110. * @param unknown_type $table
  15111. * @param unknown_type $condition
  15112. */
  15113. public function get_table_count($table = "", $condition = "") {
  15114. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15115. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15116. // echo $sql;die;
  15117. $query = Doo::db ()->query ( $sql );
  15118. $result = $query->fetch ();
  15119. return $result ['count'];
  15120. }
  15121. /**
  15122. * 获取上一页
  15123. * @param unknown_type $on_page
  15124. */
  15125. function get_previous($on_page = 1) {
  15126. return $on_page != 0 ? $on_page - 1 : $on_page;
  15127. }
  15128. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15129. // 收入合计
  15130. Doo::loadModel ( 'invoiceTraining' );
  15131. $invoiceTraining = new invoiceTraining ();
  15132. Doo::loadModel ( 'receipt' );
  15133. $receipt = new receipt ();
  15134. $invoiceTrainingDetail = array (
  15135. 'invoiceArriveAmount' => '0.00',
  15136. 'RIAmount' => '0.00',
  15137. 'invoiceTotalAmount' => '0.00',
  15138. 'invoiceCompanyAmount' => '0.00',
  15139. 'invoiceArriveAmountM'=>'0.00',
  15140. 'invoiceCompanyAmountM'=>'0.00'
  15141. );
  15142. if ($invoiceTrainId != 0) {
  15143. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15144. }
  15145. $invoiceArriveAmount = $RIAmount = 0;
  15146. if (! empty ( $invoiceTrainingDetail )) {
  15147. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15148. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15149. }
  15150. // 备用金
  15151. $sum = 0;
  15152. if (! empty ( $trainLoanRid )) {
  15153. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15154. foreach ($receiptLoanList as $key=>$value){
  15155. $sum+=$value['sum'];
  15156. }
  15157. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15158. // $sum = $receiptLoanDetailBak ['sum'];
  15159. }
  15160. // 支出项金额详情
  15161. // 项目金额合计
  15162. Doo::loadModel ( 'RItem' );
  15163. $RItem = new RItem ();
  15164. Doo::loadModel ( 'accountItem' );
  15165. $accountItem = new accountItem ();
  15166. // 讲师获得
  15167. Doo::loadModel ( 'RILecturer' );
  15168. $RILecturer = new RILecturer ();
  15169. $RItemList = $RItem->getRItemByRid ($rid );
  15170. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15171. // 支出项金额详情
  15172. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15173. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15174. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15175. return $payment;
  15176. }
  15177. }
  15178. ?>