ReceiptController.php 574 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614
  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->new_summary = 1;
  2827. $receipt->executeCopy = $executeDetail ['staff'];
  2828. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2829. $receipt->remittanceName = $remittanceName;
  2830. $receipt->bankName = $bankName;
  2831. $receipt->bankNumber = $bankNumber;
  2832. $receipt->remittanceBankType = $remittanceBankType;
  2833. if ($remittanceBankType == 1)
  2834. $receipt->coupletNumber = $coupletNumber;
  2835. $rid = $receipt->insert ();
  2836. $XDeode = new XDeode ( 7 );
  2837. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2838. } else
  2839. die ( 'illegal request' );
  2840. }
  2841. /**
  2842. * 培训班编辑
  2843. */
  2844. function receiptTrainEdi() {
  2845. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2846. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2847. Doo::loadClass ( 'XDeode' );
  2848. $XDeode = new XDeode ( 7 );
  2849. $rid = $XDeode->decode ( $ridKey );
  2850. if (! is_numeric ( $rid ))
  2851. die ( 'illegal request' );
  2852. Doo::loadModel ( 'receipt' );
  2853. $receipt = new receipt ();
  2854. Doo::loadModel ( 'receiptTraining' );
  2855. $receiptTraining = new receiptTraining ();
  2856. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2857. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2858. die ('illegal request--status');
  2859. }
  2860. //如有已入账已收款的发票,自动取消办事处已收款
  2861. // Doo::loadModel ( 'RIExtend' );
  2862. // $RIExtend = new RIExtend ();
  2863. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2864. // if (!empty($RIExtendList)){
  2865. // foreach ($RIExtendList as $key=>$value){
  2866. // $RIExtend = new RIExtend ();
  2867. // $RIExtend->delete(array (
  2868. // 'where' => 'iid=' . $value['iid'],
  2869. // 'limit' => 1
  2870. // ));
  2871. // }
  2872. // }
  2873. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2874. // 汇总表合计
  2875. // 收入合计--加入开票合计
  2876. Doo::loadModel ( 'invoiceTraining' );
  2877. $invoiceTraining = new invoiceTraining ();
  2878. $invoiceTrainingDetail = array (
  2879. 'invoiceArriveAmount' => 0,
  2880. 'RIAmount' => 0,
  2881. 'invoiceTotalAmount' => 0,
  2882. 'invoiceCompanyAmount'=>0
  2883. );
  2884. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2885. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2886. }
  2887. // print_r($invoiceTrainingDetail);
  2888. $invoiceArriveAmount = $RIAmount = 0;
  2889. if (! empty ( $invoiceTrainingDetail )) {
  2890. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2891. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2892. }
  2893. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2894. //print_r($invoiceTrainingDetail);
  2895. // 支出项目
  2896. Doo::loadModel ( 'accountItem' );
  2897. $accountItem = new accountItem ();
  2898. // 项目金额合计
  2899. Doo::loadModel ( 'RItem' );
  2900. $RItem = new RItem ();
  2901. // 讲师获得
  2902. Doo::loadModel ( 'RILecturer' );
  2903. $RILecturer = new RILecturer ();
  2904. $RItemList = $RItem->getRItemByRid ( $rid );
  2905. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2906. // 支出项金额详情
  2907. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2908. // print_r($aiData);
  2909. // 利润
  2910. $profit=$invoiceArriveAmount - $aiData ['total'];
  2911. $companyProfit=$profit * 0.6;
  2912. $categoryProfit=$profit * 0.4;
  2913. $data ['profit'] = sprintf("%.2f",$profit);
  2914. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2915. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2916. //发票利润
  2917. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2918. //发票公司利润
  2919. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2920. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2921. //办事处利润
  2922. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2923. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2924. // print_r($aiData['dataList']);
  2925. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2926. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2927. // 备用金
  2928. $sum = 0;
  2929. $data ['receiptLoanDetail'] = array (
  2930. 'sum' => '0.00'
  2931. );
  2932. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2933. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2934. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2935. $sum=0;
  2936. foreach ($receiptLoanList as $key=>$value){
  2937. $sum+=$value['sum'];
  2938. }
  2939. $data ['receiptLoanDetail'] = array (
  2940. 'sum' => $sum
  2941. );
  2942. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2943. }
  2944. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2945. $data ['payment'] = sprintf("%.2f",$payment);
  2946. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2947. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2948. $data ['aiList'] = $aiData ['dataList'];
  2949. // 占比计算
  2950. if ($invoiceArriveAmount != 0) {
  2951. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2952. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2953. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2954. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2955. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2956. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2957. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2958. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2959. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2960. } else {
  2961. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2962. }
  2963. //发票金额占比计算
  2964. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2965. //支出
  2966. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2967. //利润
  2968. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2969. //公司利润
  2970. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2971. //办事处利润
  2972. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2973. //公司收款
  2974. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2975. //备用金
  2976. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2977. //办事处收款
  2978. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2979. //办事处实际支出
  2980. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2981. //付总部款
  2982. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2983. }else{
  2984. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2985. }
  2986. //讲师人数
  2987. Doo::loadModel ( 'RILecturer' );
  2988. $RILecturer = new RILecturer ();
  2989. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2990. $data['lectureCount']=count($RILecturerList);
  2991. // 审批组
  2992. Doo::loadModel ( 'verify' );
  2993. $verify = new verify ();
  2994. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2995. // 办事处
  2996. Doo::loadModel ( 'L_category' );
  2997. $lCategory = new L_category ();
  2998. $data ['category'] = $lCategory->getCategory ();
  2999. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3000. $data ['receiptDetail'] = $receiptDetail;
  3001. $data ['veList'] = $veList;
  3002. $data ['trainEdiType'] = $trainEdiType;
  3003. $data ['ridKey'] = $ridKey;
  3004. $data ['memu'] = "receipt";
  3005. $data ['staff'] = $this->staff;
  3006. $data ['receiptMemu'] = 'saeaBorad';
  3007. $data ['verifyId'] = $this->verifyId;
  3008. $data ['executeId'] = $this->executeId;
  3009. $this->render ( "/receipt/receiptTrainEdi", $data );
  3010. }
  3011. /**
  3012. * 培训班借款编辑
  3013. */
  3014. function receiptTrainLoanEdi() {
  3015. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3016. Doo::loadClass ( 'XDeode' );
  3017. $XDeode = new XDeode ( 7 );
  3018. $rid = $XDeode->decode ( $ridKey );
  3019. if (! is_numeric ( $rid ))
  3020. die ( 'illegal request' );
  3021. Doo::loadModel ( 'receipt' );
  3022. $receipt = new receipt ();
  3023. Doo::loadModel ( 'receiptTraining' );
  3024. $receiptTraining = new receiptTraining ();
  3025. Doo::loadModel ( 'verify' );
  3026. $verify = new verify ();
  3027. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3028. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3029. die ();
  3030. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3031. // 借款详情HTML
  3032. // 获得借款信息
  3033. $receiptLoanHtml = '';
  3034. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3035. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3036. foreach ($receiptLoanList as $key=>$value){
  3037. // 获得某费用单审批信息
  3038. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3039. Doo::loadClass ( 'receipt.func' );
  3040. $extendHtml = '<p><a class="button"
  3041. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3042. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3043. }
  3044. }
  3045. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3046. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3047. $data ['receiptDetail'] = $receiptDetail;
  3048. $data ['trainEdiType'] = "LOAN";
  3049. $data ['ridKey'] = $ridKey;
  3050. $data ['memu'] = "receipt";
  3051. $data ['staff'] = $this->staff;
  3052. $data ['receiptMemu'] = 'saeaBorad';
  3053. $data ['verifyId'] = $this->verifyId;
  3054. $data ['executeId'] = $this->executeId;
  3055. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3056. }
  3057. /**
  3058. * 更新培训班结算基本信息
  3059. */
  3060. function receiptTrainInfoEdiDo() {
  3061. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3062. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3063. // 培训班信息
  3064. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3065. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3066. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3067. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3068. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3069. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3070. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3071. // 发票信息
  3072. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3073. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3074. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3075. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3076. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3077. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3078. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3079. //&& ! empty ( $participants )
  3080. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3081. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3082. header ( 'Content-Type:text/html;charset=utf-8' );
  3083. die ( '请填写联行号' );
  3084. }
  3085. Doo::loadClass ( 'XDeode' );
  3086. $XDeode = new XDeode ( 5 );
  3087. $cid = $XDeode->decode ( $cid );
  3088. $rtid = $XDeode->decode ( $rtid );
  3089. $rid = $XDeode->decode ( $rid );
  3090. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3091. die ( 'illegal request-IdError' );
  3092. }
  3093. Doo::loadModel ( 'receipt' );
  3094. $receipt = new receipt ();
  3095. Doo::loadModel ( 'receiptTraining' );
  3096. $receiptTraining = new receiptTraining ();
  3097. // 更新费用培训班
  3098. $item = array (
  3099. 'rtid' => $rtid,
  3100. 'trainName' => $trainName,
  3101. 'trainStartDate' => $trainStartDate,
  3102. 'trainEndDate' => $trainEndDate,
  3103. 'participants' => $participants,
  3104. 'freeParticipants'=>$freeParticipants,
  3105. 'trainAddress' => $trainAddress,
  3106. 'trainRemarks' => $trainRemarks
  3107. );
  3108. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3109. // 报销单
  3110. $receipt->rid = $rid;
  3111. $receipt->cid = $cid;
  3112. $receipt->verify = $verify;
  3113. $receipt->remittanceName = $remittanceName;
  3114. $receipt->bankName = $bankName;
  3115. $receipt->bankNumber = $bankNumber;
  3116. $receipt->remittanceBankType = $remittanceBankType;
  3117. if ($remittanceBankType == 1)
  3118. $receipt->coupletNumber = $coupletNumber;
  3119. $receipt->update ();
  3120. $XDeode = new XDeode ( 7 );
  3121. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3122. } else
  3123. die ( 'illegal request' );
  3124. }
  3125. /**
  3126. * 编辑培训班结算---更新借款
  3127. */
  3128. function receiptTrainLoanEdiDo() {
  3129. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3130. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3131. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3132. Doo::loadModel ( 'receipt' );
  3133. $receipt = new receipt ();
  3134. Doo::loadClass ( 'XDeode' );
  3135. $XDeode = new XDeode ( 5 );
  3136. $rid = $XDeode->decode ( $ridKey );
  3137. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3138. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3139. die ( 'illegal request-ridError' );
  3140. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3141. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3142. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3143. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3144. die ( 'illegal request-receiptError' );
  3145. }
  3146. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3147. die ( 'illegal request-receipLoantError' );
  3148. }
  3149. // 培训班结算挂钩借款
  3150. $receipt = new receipt ();
  3151. $trainLoanRid=$ridLoan;
  3152. if (!empty($receiptDetail['trainLoanRid'])){
  3153. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3154. }
  3155. $item = array (
  3156. 'rid' => $rid,
  3157. 'trainLoanRid' => $trainLoanRid
  3158. );
  3159. $receipt->setReceiptByCondition ( $item );
  3160. // 更新借款状态变成已挂钩
  3161. $receipt = new receipt ();
  3162. $item = array (
  3163. 'rid' => $ridLoan,
  3164. 'status' => 10,
  3165. 'statusTrain' => 1
  3166. );
  3167. $receipt->setReceiptByCondition ( $item );
  3168. $XDeode = new XDeode ( 7 );
  3169. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3170. } else
  3171. die ( 'illegal request' );
  3172. }
  3173. /**
  3174. * 编辑培训班结算--移除借款
  3175. */
  3176. function receiptTrainLoanRemoveDo() {
  3177. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3178. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3179. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3180. Doo::loadModel ( 'receipt' );
  3181. $receipt = new receipt ();
  3182. Doo::loadClass ( 'XDeode' );
  3183. $XDeode = new XDeode ( 5 );
  3184. $rid = $XDeode->decode ( $ridKey );
  3185. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3186. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3187. die ( 'illegal request-ridError' );
  3188. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3189. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3190. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3191. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3192. die ( 'illegal request-receiptError' );
  3193. }
  3194. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3195. die ( 'illegal request-receipLoantError' );
  3196. }
  3197. // 培训班结算挂钩借款
  3198. $receipt = new receipt ();
  3199. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3200. foreach ($trainLoanRidArray as $key=>$value){
  3201. if($value==$ridLoan){
  3202. unset($trainLoanRidArray[$key]);
  3203. }
  3204. }
  3205. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3206. $item = array (
  3207. 'rid' => $rid,
  3208. 'trainLoanRid' => $trainLoanRidString
  3209. );
  3210. $receipt->setReceiptByCondition ( $item );
  3211. // 更新借款状态变成已挂钩
  3212. $receipt = new receipt ();
  3213. $item = array (
  3214. 'rid' => $ridLoan,
  3215. 'status' => 8,
  3216. 'statusTrain' => 0
  3217. );
  3218. $receipt->setReceiptByCondition ( $item );
  3219. $XDeode = new XDeode ( 7 );
  3220. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3221. } else
  3222. die ( 'illegal request' );
  3223. }
  3224. /**
  3225. * 编辑培训班结算 ---开票
  3226. */
  3227. function receiptTrainInvoiceEdi() {
  3228. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3229. Doo::loadClass ( 'XDeode' );
  3230. $XDeode = new XDeode ( 7 );
  3231. $rid = $XDeode->decode ( $ridKey );
  3232. if (! is_numeric ( $rid ))
  3233. die ( 'illegal request' );
  3234. Doo::loadModel ( 'receipt' );
  3235. $receipt = new receipt ();
  3236. Doo::loadModel ( 'receiptTraining' );
  3237. $receiptTraining = new receiptTraining ();
  3238. Doo::loadModel ( 'invoice' );
  3239. $invoice = new invoice ();
  3240. Doo::loadModel ( 'invoiceTraining' );
  3241. $invoiceTraining = new invoiceTraining ();
  3242. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3243. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3244. die ();
  3245. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3246. $invoiceList = $invoiceTrainingDetail = array ();
  3247. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3248. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3249. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3250. }
  3251. //print_r($invoiceList);
  3252. $data ['invoiceList'] = $invoiceList;
  3253. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3254. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3255. $data ['receiptDetail'] = $receiptDetail;
  3256. $data ['trainEdiType'] = "INVOICE";
  3257. $data ['ridKey'] = $ridKey;
  3258. $data ['memu'] = "receipt";
  3259. $data ['staff'] = $this->staff;
  3260. $data ['receiptMemu'] = 'saeaBorad';
  3261. $data ['verifyId'] = $this->verifyId;
  3262. $data ['executeId'] = $this->executeId;
  3263. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3264. }
  3265. /**
  3266. * 编辑培训班结算---更新开票
  3267. */
  3268. function receiptTrainInvoiceEdiDo() {
  3269. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3270. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3271. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3272. Doo::loadModel ( 'receipt' );
  3273. $receipt = new receipt ();
  3274. Doo::loadModel ( 'invoiceTraining' );
  3275. $invoiceTraining = new invoiceTraining ();
  3276. Doo::loadClass ( 'XDeode' );
  3277. $XDeode = new XDeode ( 5 );
  3278. $rid = $XDeode->decode ( $ridKey );
  3279. $itid = $XDeode->decode ( $itidKey );
  3280. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3281. die ( 'illegal request-idError' );
  3282. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3283. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3284. // 不合法的数据
  3285. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3286. die ( 'illegal request-receiptError' );
  3287. }
  3288. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3289. die ( 'illegal request-receipLoantError' );
  3290. }
  3291. // 培训班结算挂钩借款
  3292. $receipt = new receipt ();
  3293. $item = array (
  3294. 'rid' => $rid,
  3295. 'invoiceTrainId' => $itid
  3296. );
  3297. $receipt->setReceiptByCondition ( $item );
  3298. $invoiceTraining = new invoiceTraining ();
  3299. $item = array (
  3300. 'bindReceipt' => 1,
  3301. 'itid' => $itid
  3302. );
  3303. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3304. $XDeode = new XDeode ( 7 );
  3305. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3306. } else
  3307. die ( 'illegal request' );
  3308. }
  3309. /**
  3310. * 更新培训班结算 收款和取消收款
  3311. */
  3312. function receiptTrainReceivables() {
  3313. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3314. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3315. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3316. Doo::loadClass ( 'XDeode' );
  3317. $XDeode = new XDeode ( 5 );
  3318. $rid = $XDeode->decode ( $ridKey );
  3319. $iid = $XDeode->decode ( $iidKey );
  3320. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3321. die ( 'illegal request-iid' );
  3322. Doo::loadModel ( 'RIExtend' );
  3323. $RIExtend = new RIExtend ();
  3324. if ($doType == 'CONFIRM') {
  3325. $RIExtend->rid = $rid;
  3326. $RIExtend->iid = $iid;
  3327. $RIExtend->RIstatus = 1;
  3328. $RIExtend->insert ();
  3329. echo json_encode ( array (
  3330. 'status' => 1,
  3331. ) );
  3332. die ( );
  3333. } elseif ($doType == 'CANCEL') {
  3334. $RIExtend->delete ( array (
  3335. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3336. 'limit' => 1
  3337. ) );
  3338. echo json_encode ( array (
  3339. 'status' => 1,
  3340. ) );
  3341. die ( );
  3342. } else {
  3343. echo json_encode ( array (
  3344. 'status' => 2,
  3345. ) );
  3346. die ( );
  3347. }
  3348. }
  3349. /**
  3350. * 移除挂钩的培训班发票
  3351. */
  3352. function receiptTrainReceivablesDelDo() {
  3353. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3354. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3355. Doo::loadModel ( 'receipt' );
  3356. $receipt = new receipt ();
  3357. Doo::loadModel ( 'RIExtend' );
  3358. $RIExtend = new RIExtend ();
  3359. Doo::loadClass ( 'XDeode' );
  3360. $XDeode = new XDeode ( 5 );
  3361. $rid = $XDeode->decode ( $ridKey );
  3362. $itid = $XDeode->decode ( $itidKey );
  3363. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3364. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3365. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3366. die ( 'illegal request-status' );
  3367. }
  3368. $receipt = new receipt ();
  3369. $receipt->rid = $rid;
  3370. $receipt->invoiceTrainId = 0;
  3371. $receipt->update ();
  3372. Doo::loadModel ( 'invoiceTraining' );
  3373. $invoiceTraining = new invoiceTraining ();
  3374. $item = array (
  3375. 'bindReceipt' => 0,
  3376. 'itid' => $itid
  3377. );
  3378. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3379. $RIExtend->delete ( array (
  3380. 'where' => 'rid=' . $rid
  3381. ) );
  3382. $XDeode = new XDeode ( 7 );
  3383. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3384. } else
  3385. die ( 'illegal request-iid' );
  3386. }
  3387. /**
  3388. * 编辑培训班结算
  3389. */
  3390. function receiptTrainItemEdi() {
  3391. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3392. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3393. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3394. Doo::loadClass ( 'XDeode' );
  3395. $XDeode = new XDeode ( 7 );
  3396. $rid = $XDeode->decode ( $ridKey );
  3397. if (! is_numeric ( $rid ))
  3398. die ( 'illegal request' );
  3399. Doo::loadModel ( 'receipt' );
  3400. $receipt = new receipt ();
  3401. Doo::loadModel ( 'receiptTraining' );
  3402. $receiptTraining = new receiptTraining ();
  3403. Doo::loadModel ( 'RItem' );
  3404. $RItem = new RItem ();
  3405. Doo::loadModel ( 'accountItem' );
  3406. $accountItem = new accountItem ();
  3407. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3408. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3409. die ();
  3410. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3411. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3412. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3413. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3414. // if($value['name']=='税款'){
  3415. // unset($aiList[$key]);break;
  3416. // }
  3417. // }
  3418. //print_r($RItemList);
  3419. $data ['name'] = $name;
  3420. $data ['RItemList'] = $RItemList;
  3421. $data ['aiList'] = $aiList;
  3422. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3423. $data ['receiptDetail'] = $receiptDetail;
  3424. $data ['trainEdiType'] = "ITEM";
  3425. $data ['ridKey'] = $ridKey;
  3426. $data ['memu'] = "receipt";
  3427. $data ['staff'] = $this->staff;
  3428. $data ['receiptMemu'] = 'saeaBorad';
  3429. $data ['verifyId'] = $this->verifyId;
  3430. $data ['executeId'] = $this->executeId;
  3431. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3432. }
  3433. /**
  3434. * 添加支出项 需要修改 费用金额合计
  3435. */
  3436. function receiptTrainItemAddDo() {
  3437. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3438. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3439. // 支出项信息
  3440. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3441. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3442. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3443. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3444. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3445. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3446. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3447. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3448. Doo::loadClass ( 'XDeode' );
  3449. $XDeode = new XDeode ( 5 );
  3450. Doo::loadModel ( 'RItem' );
  3451. $RItem = new RItem ();
  3452. $rid = $XDeode->decode ( $ridKey );
  3453. $rtid= $XDeode->decode ( $rtidKey );
  3454. if (! is_numeric ( $rid )){
  3455. die ( 'illegal request' );
  3456. }
  3457. Doo::loadModel ( 'receiptDetail' );
  3458. $receiptDetail = new receiptDetail ();
  3459. Doo::loadModel ( 'receipt' );
  3460. $receipt = new receipt ();
  3461. Doo::loadModel ( 'receiptTraining' );
  3462. $receiptTraining = new receiptTraining ();
  3463. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3464. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3465. $order = array (
  3466. "\r\n",
  3467. "\n",
  3468. "\r"
  3469. );
  3470. $replace = '<br/>';
  3471. $describe = str_replace ( $order, $replace, $describe );
  3472. $itemData = array (
  3473. 'rid' => $rid,
  3474. 'item' => $item,
  3475. 'price' => $price,
  3476. 'date' => $date,
  3477. 'inputer' => $inputer,
  3478. 'describe' => $describe,
  3479. 'creater' => $this->staff['0']['username'],
  3480. 'createrId' => $this->staff['0']['sid'],
  3481. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3482. 'identifying'=>$identifyingTotal
  3483. );
  3484. if($payType=='company'){
  3485. $itemData += array (
  3486. 'payType' => 1
  3487. );
  3488. }
  3489. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3490. //更新支出项标识总数
  3491. $itemData = array (
  3492. 'rtid'=>$rtid,
  3493. 'identifyingTotal'=>$identifyingTotal
  3494. );
  3495. $receiptTraining->setReceiptTrainByCondition($itemData);
  3496. $XDeode = new XDeode ( 7 );
  3497. if($payType=='company'){
  3498. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3499. }else{
  3500. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3501. }
  3502. } else
  3503. die ( 'illegal request-dataError' );
  3504. }
  3505. /**
  3506. * 培训班结算-讲师
  3507. */
  3508. function receiptTrainLecturerEdi() {
  3509. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3510. Doo::loadClass ( 'XDeode' );
  3511. $XDeode = new XDeode ( 7 );
  3512. $rid = $XDeode->decode ( $ridKey );
  3513. if (! is_numeric ( $rid ))
  3514. die ( 'illegal request' );
  3515. Doo::loadModel ( 'receipt' );
  3516. $receipt = new receipt ();
  3517. Doo::loadModel ( 'receiptTraining' );
  3518. $receiptTraining = new receiptTraining ();
  3519. Doo::loadModel ( 'RILecturer' );
  3520. $RILecturer = new RILecturer ();
  3521. Doo::loadModel ( 'lecturer' );
  3522. $lecturer = new lecturer ();
  3523. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3524. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3525. die ();
  3526. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3527. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3528. $lecturerList = $lecturer->getLecturerAll ();
  3529. $INSIDEhtml = $OUTSIDEhtml = '';
  3530. foreach ( $lecturerList as $key => $value ) {
  3531. if ($value ['ltype'] == 'INSIDE') {
  3532. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3533. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3534. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3535. }
  3536. }
  3537. $data ['INSIDEhtml'] = $INSIDEhtml;
  3538. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3539. // print_r($RItemList);
  3540. $data ['RILecturerList'] = $RILecturerList;
  3541. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3542. $data ['receiptDetail'] = $receiptDetail;
  3543. $data ['trainEdiType'] = "LECTURER";
  3544. $data ['ridKey'] = $ridKey;
  3545. $data ['memu'] = "receipt";
  3546. $data ['staff'] = $this->staff;
  3547. $data ['receiptMemu'] = 'saeaBorad';
  3548. $data ['verifyId'] = $this->verifyId;
  3549. $data ['executeId'] = $this->executeId;
  3550. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3551. }
  3552. /**
  3553. * 添加讲师
  3554. */
  3555. function receiptTrainLecturerAddDo() {
  3556. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3557. // 支出项信息
  3558. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3559. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3560. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3561. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3562. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3563. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3564. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3565. Doo::loadClass ( 'XDeode' );
  3566. $XDeode = new XDeode ( 5 );
  3567. Doo::loadModel ( 'RILecturer' );
  3568. $RILecturer = new RILecturer ();
  3569. $rid = $XDeode->decode ( $ridKey );
  3570. if (! is_numeric ( $rid ))
  3571. die ( 'illegal request' );
  3572. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3573. die ( 'illegal request-taxationError' );
  3574. $RILecturer->rid = $rid;
  3575. $RILecturer->ltype = $ltype;
  3576. if ($ltype == 'OUTSIDE') {
  3577. if ($taxation == 'TAXATION') {
  3578. $RILecturer->taxation = 1;
  3579. } elseif ($taxation == 'NOTAXATION') {
  3580. $RILecturer->taxation = 0;
  3581. }
  3582. }
  3583. $RILecturer->lecturerName = $lecturerName;
  3584. $RILecturer->schoolDay = $schoolDay;
  3585. $RILecturer->price = $price;
  3586. $RILecturer->fees=$fees;
  3587. $RILecturer->insert ();
  3588. // 添加公司汇总
  3589. // 报销详情
  3590. Doo::loadModel ( 'receiptDetail' );
  3591. $receiptDetail = new receiptDetail ();
  3592. Doo::loadModel ( 'receipt' );
  3593. $receipt = new receipt ();
  3594. // 金额总计
  3595. $price = $price * $schoolDay;
  3596. $rInfo = $receipt->getReceiptByRid ( $rid );
  3597. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3598. if (empty ( $rdInfo )) {
  3599. $receiptDetail = new receiptDetail ();
  3600. $receiptDetail->staff = $rInfo ['staff'];
  3601. $receiptDetail->item = '讲课费';
  3602. $receiptDetail->itemCategory = '培训班费用';
  3603. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3604. $receiptDetail->date = date ( "Y-m-d" );
  3605. $receiptDetail->cid = $rInfo ['cid'];
  3606. $receiptDetail->rid = $rid;
  3607. $receiptDetail->status = 4;
  3608. $receiptDetail->insert ();
  3609. } else {
  3610. $receiptDetail = new receiptDetail ();
  3611. $rdInfo ['price'] += $fees;
  3612. $receiptDetail->price = $rdInfo ['price'];
  3613. $receiptDetail->update ( array (
  3614. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3615. ) );
  3616. }
  3617. $receipt = new receipt ();
  3618. $receipt->sum=$rInfo['sum']+$fees;
  3619. $receipt->update ( array (
  3620. 'where' => 'rid=' . $rid
  3621. ) );
  3622. $XDeode = new XDeode ( 7 );
  3623. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3624. } else
  3625. die ( 'illegal request' );
  3626. }
  3627. /**
  3628. * 移除讲师
  3629. */
  3630. function receiptTrainLecturerDelDo() {
  3631. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3632. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3633. Doo::loadModel ( 'receipt' );
  3634. $receipt = new receipt ();
  3635. Doo::loadModel ( 'RILecturer' );
  3636. $RILecturer = new RILecturer ();
  3637. Doo::loadClass ( 'XDeode' );
  3638. $XDeode = new XDeode ( 5 );
  3639. $rid = $XDeode->decode ( $ridKey );
  3640. $rlid = $XDeode->decode ( $rlidKey );
  3641. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3642. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3643. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3644. die ( 'illegal request-status' );
  3645. }
  3646. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3647. if (empty($detail)){
  3648. die ( 'illegal request-data' );
  3649. }
  3650. $RILecturer->delete ( array (
  3651. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3652. ) );
  3653. //更新费用合计金额
  3654. $rInfo = $receipt->getReceiptByRid ( $rid );
  3655. $receipt = new receipt ();
  3656. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3657. $receipt->update ( array (
  3658. 'where' => 'rid=' . $rid
  3659. ) );
  3660. Doo::loadModel ( 'receiptDetail' );
  3661. $receiptDetail = new receiptDetail ();
  3662. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3663. $receiptDetail = new receiptDetail ();
  3664. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3665. $receiptDetail->price = $rdInfo ['price'];
  3666. $receiptDetail->update ( array (
  3667. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3668. ) );
  3669. $XDeode = new XDeode ( 7 );
  3670. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3671. } else
  3672. die ( 'illegal request-iid' );
  3673. }
  3674. /**
  3675. * 培训班提交审批
  3676. */
  3677. function receiptTrainDo() {
  3678. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3679. Doo::loadClass ( 'XDeode' );
  3680. $XDeode = new XDeode ( 7 );
  3681. $rid = $XDeode->decode ( $ridKey );
  3682. Doo::loadModel ( 'receipt' );
  3683. $receipt = new receipt ();
  3684. Doo::loadModel ( 'receiptDetail' );
  3685. $receiptDetail = new receiptDetail ();
  3686. Doo::loadModel ( 'statistics' );
  3687. $statistics = new statistics ();
  3688. Doo::loadModel ( "verify" );
  3689. $verify = new verify ();
  3690. // 审批状态的判定
  3691. $receiptDetailList = $receipt->getOne ( array (
  3692. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3693. 'asArray' => true
  3694. ) );
  3695. if (empty ( $receiptDetailList ))
  3696. return "/saeaBorad";
  3697. $verifyDetail = $verify->getOne ( array (
  3698. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3699. 'asArray' => true
  3700. ) );
  3701. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3702. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3703. $nowStaff = "";
  3704. $nowStaffList = array ();
  3705. if ($verifyDetail [0] [1] == 'ROLE') {
  3706. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3707. foreach ( $vStaffString as $key => $value ) {
  3708. $staffK = explode ( "_", $value );
  3709. array_push ( $nowStaffList, $staffK [0] );
  3710. }
  3711. $nowStaff = implode ( ',', $nowStaffList );
  3712. } else {
  3713. $nowStaff = $verifyDetail [0] [0];
  3714. }
  3715. $receipt->nowStaff = $nowStaff;
  3716. }
  3717. // echo $nowStaff;
  3718. // print_r($verifyDetail);die;
  3719. $receipt->rid = $receiptDetailList ['rid'];
  3720. $receipt->date = date ( "Y-m-d" );
  3721. $receipt->status = 2;
  3722. $receipt->update ();
  3723. $receiptDetail->status = 2;
  3724. $receiptDetail->update ( array (
  3725. 'where' => 'rid=' . $receiptDetailList ['rid']
  3726. ) );
  3727. Doo::loadModel ( "receiptLog" );
  3728. $receiptLog = new receiptLog ();
  3729. Doo::loadModel ( "verify" );
  3730. $verify = new verify ();
  3731. $vr = $verify->getOne ( array (
  3732. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3733. 'asArray' => true
  3734. ) );
  3735. $jd = json_decode ( $vr ['staff'] );
  3736. $roleId = 0;
  3737. foreach ( $jd as $key => $value ) {
  3738. if ($value [1] == 'ROLE') {
  3739. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3740. if ($pos !== false) {
  3741. $roleId = $value [0];
  3742. }
  3743. }
  3744. }
  3745. // 审批日志
  3746. // echo $roleId;die;
  3747. if (! empty ( $roleId )) {
  3748. Doo::loadModel ( "role" );
  3749. $role = new role ();
  3750. $roleInfo = $role->getOne ( array (
  3751. 'where' => 'rid=' . $roleId,
  3752. 'asArray' => true
  3753. ) );
  3754. // $receiptLog->rolename = $roleInfo ['name'];
  3755. }
  3756. $receiptLog->username = $this->staff [0] ['username'];
  3757. $receiptLog->uid = $this->staff [0] ['sid'];
  3758. $receiptLog->date = date ( "Y-m-d" );
  3759. $receiptLog->opinion = '提交审批';
  3760. $receiptLog->img = $this->staff [0] ['avatar'];
  3761. $receiptLog->status = 2;
  3762. $receiptLog->rid = $rid;
  3763. $receiptLog->insert ();
  3764. // 写入列表项
  3765. Doo::loadModel ( 'accountItem' );
  3766. $accountItem = new accountItem ();
  3767. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3768. // 项目金额合计
  3769. Doo::loadModel ( 'RItem' );
  3770. $RItem = new RItem ();
  3771. // 讲师获得
  3772. Doo::loadModel ( 'RILecturer' );
  3773. $RILecturer = new RILecturer ();
  3774. $RItemList = $RItem->getRItemByRid ( $rid );
  3775. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3776. // 支出项金额详情
  3777. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3778. // print_r($aItem);
  3779. // print_r($aiData);
  3780. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3781. $ag = $tr = $ta = $ot = 0;
  3782. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3783. foreach ( $aItem as $key => $value ) {
  3784. if ($value ['category'] == $this->TRAIN) {
  3785. foreach ( $aiData ['dataList'] as $k => $v ) {
  3786. if ($value ['name'] == $v ['name']) {
  3787. array_push ( $accountJson [$this->TRAIN], array (
  3788. 'aid' => $value ['aid'],
  3789. 'name' => $value ['name'],
  3790. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3791. ) );
  3792. $sum += $v ['price'];
  3793. $trainSum += $v ['price'];
  3794. unset ( $aiData ['dataList'] [$k] );
  3795. break;
  3796. }
  3797. }
  3798. }
  3799. }
  3800. $accountJson ['cSum'] = array (
  3801. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3802. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3803. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3804. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3805. );
  3806. // 报销单
  3807. $receipt = new receipt ();
  3808. $receipt->accountItem = json_encode ( $accountJson );
  3809. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3810. $receipt->update ( array (
  3811. 'where' => 'rid=' . $rid
  3812. ) );
  3813. // print_r($accountJson);
  3814. // statistics item 统计写入
  3815. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3816. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3817. $accountItem = $accountJson;
  3818. $stat = $statistics->getOne ( array (
  3819. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3820. 'asArray' => true
  3821. ) );
  3822. if (empty ( $stat )) {
  3823. $statistics->date = date ( "Y-m-d" );
  3824. $statistics->cid = $this->staff [0] ['cid'];
  3825. $statistics->staff = $this->staff [0] ['sid'];
  3826. $statistics->agPrice = 0;
  3827. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3828. $statistics->insert ();
  3829. } else {
  3830. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3831. $statistics->update ( array (
  3832. 'where' => 'sid=' . $stat ['sid']
  3833. ) );
  3834. }
  3835. return "/saeaBorad";
  3836. }
  3837. function confirmation() {
  3838. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3839. Doo::loadModel ( 'receipt' );
  3840. Doo::loadModel ( 'receiptDetail' );
  3841. $receipt = new receipt ();
  3842. $receiptDetail = new receiptDetail ();
  3843. Doo::loadModel ( 'statistics' );
  3844. Doo::loadModel ( 'itemStatistics' );
  3845. $statistics = new statistics ();
  3846. $itemStatistics = new itemStatistics ();
  3847. Doo::loadModel ( "verify" );
  3848. $verify = new verify ();
  3849. $receiptDetailList = $receipt->getOne ( array (
  3850. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3851. 'asArray' => true
  3852. ) );
  3853. if (empty ( $receiptDetailList ))
  3854. return "/saeaBorad";
  3855. $verifyDetail = $verify->getOne ( array (
  3856. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3857. 'asArray' => true
  3858. ) );
  3859. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3860. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3861. $nowStaff = "";
  3862. $nowStaffList = array ();
  3863. if ($verifyDetail [0] [1] == 'ROLE') {
  3864. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3865. foreach ( $vStaffString as $key => $value ) {
  3866. $staffK = explode ( "_", $value );
  3867. array_push ( $nowStaffList, $staffK [0] );
  3868. }
  3869. $nowStaff = implode ( ',', $nowStaffList );
  3870. } else {
  3871. $nowStaff = $verifyDetail [0] [0];
  3872. }
  3873. $receipt->nowStaff = $nowStaff;
  3874. }
  3875. // echo $nowStaff;
  3876. // print_r($verifyDetail);die;
  3877. $receipt->rid = $receiptDetailList ['rid'];
  3878. $receipt->status = 2;
  3879. $receipt->update ();
  3880. // 操作日志
  3881. Doo::loadModel ( "receiptLog" );
  3882. $receiptLog = new receiptLog ();
  3883. $verify = new verify ();
  3884. $receiptInfo = $receipt->getOne ( array (
  3885. 'where' => 'rid=' . $rid,
  3886. 'asArray' => true
  3887. ) );
  3888. $vr = $verify->getOne ( array (
  3889. 'where' => 'vid=' . $receiptInfo ['verify'],
  3890. 'asArray' => true
  3891. ) );
  3892. $jd = json_decode ( $vr ['staff'] );
  3893. $roleId = 0;
  3894. foreach ( $jd as $key => $value ) {
  3895. if ($value [1] == 'ROLE') {
  3896. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3897. if ($pos !== false) {
  3898. $roleId = $value [0];
  3899. }
  3900. }
  3901. }
  3902. // 审批日志
  3903. // echo $roleId;die;
  3904. if (! empty ( $roleId )) {
  3905. Doo::loadModel ( "role" );
  3906. $role = new role ();
  3907. $roleInfo = $role->getOne ( array (
  3908. 'where' => 'rid=' . $roleId,
  3909. 'asArray' => true
  3910. ) );
  3911. // $receiptLog->rolename = $roleInfo ['name'];
  3912. }
  3913. $receiptLog->username = $this->staff [0] ['username'];
  3914. $receiptLog->uid = $this->staff [0] ['sid'];
  3915. $receiptLog->date = date ( "Y-m-d" );
  3916. $receiptLog->opinion = '提交审批';
  3917. $receiptLog->img = $this->staff [0] ['avatar'];
  3918. $receiptLog->status = 2;
  3919. $receiptLog->rid = $rid;
  3920. $receiptLog->insert ();
  3921. return "/expenses";
  3922. }
  3923. function expenses() {
  3924. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3925. if (empty ( $item ))
  3926. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3927. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3928. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3929. Doo::loadClass ( 'XDeode' );
  3930. $XDeode = new XDeode ( 7 );
  3931. Doo::loadModel ( 'receipt' );
  3932. $receipt = new receipt ();
  3933. Doo::loadModel ( 'L_category' );
  3934. $Lcategory = new L_category ();
  3935. Doo::loadModel ( 'verify' );
  3936. Doo::loadModel ( 'statistics' );
  3937. $statistics = new statistics ();
  3938. $verify = new verify ();
  3939. Doo::loadModel ( 'staff' );
  3940. $staff = new staff ();
  3941. $condition = "";
  3942. if ($item == "expenses")
  3943. $condition = " and Rtype=1 ";
  3944. elseif ($item == "receipts")
  3945. $condition = " and Rtype=0 ";
  3946. elseif ($item == "remits")
  3947. $condition = " and Rtype=2 ";
  3948. elseif ($item == "train")
  3949. $condition = " and Rtype=3 ";
  3950. $dateCondition = " and Year(date) =" . $year;
  3951. if (! empty ( $moth )) {
  3952. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3953. $stList = $statistics->getOne ( array (
  3954. 'select' => 'rePrice ,agPrice',
  3955. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3956. 'asArray' => true
  3957. ) );
  3958. } else
  3959. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3960. if (empty ( $stList ))
  3961. $stList = array (
  3962. 'rePrice' => 0,
  3963. 'agPrice' => 0
  3964. );
  3965. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3966. if (! isset ( $noPassSum ['sum'] ))
  3967. $noPassSum ['sum'] = 0;
  3968. $data ['stList'] = array (
  3969. 'rePrice' => $stList ['rePrice'],
  3970. 'agPrice' => $stList ['agPrice'],
  3971. 'skPrice' => ($noPassSum ['sum'])
  3972. );
  3973. $receiptList = $receipt->find ( array (
  3974. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3975. 'desc' => 'rid',
  3976. 'asArray' => true
  3977. ) );
  3978. $Locate = 0;
  3979. $roleId = 0;
  3980. $button = 0;
  3981. foreach ( $receiptList as $key => $value ) {
  3982. $receiptList[$key]['balance']='';
  3983. if($value['Rtype']==1){
  3984. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3985. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3986. }elseif($value['Rtype']==3){
  3987. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3988. $receiptList[$key]['payment']=$payment;
  3989. $receiptList[$key]['paymentABS']=abs($payment);
  3990. }
  3991. $receiptList [$key] ['Locate'] = $Locate;
  3992. $Locate ++;
  3993. $receiptList [$key] ['reviseDetail'] = array ();
  3994. if (! empty ( $value ['reviseDetail'] ))
  3995. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3996. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3997. $categoryDetil = $Lcategory->getOne ( array (
  3998. 'where' => 'cid=' . $value ['cid'],
  3999. 'asArray' => true
  4000. ) );
  4001. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4002. // 检测编辑状态
  4003. $verifyList = $verify->getOne ( array (
  4004. 'where' => 'vid=' . $value ['verify'],
  4005. 'asArray' => true
  4006. ) );
  4007. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4008. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4009. Doo::loadModel ( 'role' );
  4010. $role = new role ();
  4011. $flag = true;
  4012. $roleKey = 0;
  4013. $endStaffArray = array ();
  4014. $roleArrayCopy = array ();
  4015. foreach ( $verifyList as $k => $v ) {
  4016. // init verifyStaff
  4017. if ($v [1] == 'ROLE') {
  4018. if (! empty ( $verifyStaff )) {
  4019. $endStaffArray = end ( $verifyStaff );
  4020. // if ($v[0]==$endStaffArray['nextStaff']){
  4021. // $roleId=$v[0];
  4022. // }
  4023. }
  4024. $roleVerify = json_decode ( $v [3], true );
  4025. $roleKey = $k;
  4026. $roleArray = array ();
  4027. $rolename = $role->getOne ( array (
  4028. 'where' => 'rid=' . $v [0],
  4029. 'asArray' => true
  4030. ) );
  4031. foreach ( $roleVerify as $o => $p ) {
  4032. $staffID = explode ( '_', $p );
  4033. $staffInfo = $staff->getOne ( array (
  4034. 'where' => 'sid=' . $staffID [0],
  4035. 'asArray' => true
  4036. ) );
  4037. // print_r($staffID);
  4038. $exp = array (
  4039. 0 => $staffInfo ['sid'],
  4040. 1 => $staffID [1],
  4041. 2 => $staffInfo ['avatar'],
  4042. 'date' => '',
  4043. 'date' => '',
  4044. 'opinion' => '',
  4045. 'status' => '',
  4046. 'rolename' => $rolename ['name']
  4047. );
  4048. array_push ( $roleArray, $exp );
  4049. }
  4050. $roleArrayCopy [$v [0]] = $roleArray;
  4051. // $verifyList[$k]['roleArray']=$roleArray;
  4052. }
  4053. $verifyList [$k] ['date'] = "";
  4054. $verifyList [$k] ['opinion'] = "";
  4055. $verifyList [$k] ['status'] = "";
  4056. if (empty ( $verifyStaff )) {
  4057. $verifyList [$k] ['date'] = "";
  4058. $verifyList [$k] ['opinion'] = "";
  4059. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4060. $verifyList [$k] ['status'] = 4;
  4061. $flag = false;
  4062. }
  4063. } else {
  4064. foreach ( $verifyStaff as $m => $u ) {
  4065. if ($v [0] == $m) {
  4066. $verifyList [$k] ['date'] = $u ['date'];
  4067. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4068. $verifyList [$k] ['status'] = $u ['status'];
  4069. $flag = false;
  4070. break;
  4071. }
  4072. }
  4073. $endStaffArray = end ( $verifyStaff );
  4074. if (isset ( $endStaffArray ['ROLE'] )) {
  4075. } else {
  4076. // $endKey=key($verifyStaff);
  4077. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4078. // $button=4;
  4079. // $verifyList[$k]['status']=4;
  4080. // }
  4081. }
  4082. }
  4083. }
  4084. $rolename ['name'] = '';
  4085. if (! empty ( $roleId )) {
  4086. Doo::loadModel ( 'role' );
  4087. $role = new role ();
  4088. $rolename = $role->getOne ( array (
  4089. 'where' => 'rid=' . $roleId,
  4090. 'asArray' => true
  4091. ) );
  4092. }
  4093. if (! empty ( $verifyStaff ))
  4094. $endStaffArray = end ( $verifyStaff );
  4095. $KOP = false;
  4096. foreach ( $roleArrayCopy as $P => $A ) {
  4097. foreach ( $A as $MKI => $AVL ) {
  4098. if (! empty ( $verifyStaff )) {
  4099. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4100. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4101. $button = 4;
  4102. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4103. }
  4104. foreach ( $verifyStaff as $m => $u ) {
  4105. $AVLFK = $AVL [0] . '_R';
  4106. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4107. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4108. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4109. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4110. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4111. break;
  4112. }
  4113. }
  4114. } else {
  4115. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4116. $button = 4;
  4117. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4118. }
  4119. }
  4120. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4121. $KOP = true;
  4122. }
  4123. }
  4124. foreach ( $roleArrayCopy as $k => $v ) {
  4125. foreach ( $verifyList as $m => $n ) {
  4126. if ($n [0] == $k) {
  4127. array_splice ( $verifyList, $m, 1, $v );
  4128. }
  4129. }
  4130. }
  4131. $receiptList [$key] ['verifyList'] = $verifyList;
  4132. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4133. 'where' => 'sid=' . $value ['staff'],
  4134. 'asArray' => true
  4135. ) );
  4136. $receiptList [$key] ['button'] = $button;
  4137. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4138. if($value['version']==1){
  4139. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4140. }
  4141. }
  4142. // print_r($receiptList);die;
  4143. $mothHtml = "";
  4144. for($i = 1; $i <= 12; $i ++) {
  4145. if ($moth == $i)
  4146. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4147. else
  4148. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4149. }
  4150. $dateHtml = "";
  4151. $now = date ( "Y" );
  4152. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4153. if ($YEARD <= $now) {
  4154. $dateHtml .= '<option ';
  4155. if ($year == $YEARD) {
  4156. $dateHtml .= 'selected ';
  4157. }
  4158. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4159. }
  4160. }
  4161. $data ['dateHtml'] = $dateHtml;
  4162. $data ['mothHtml'] = $mothHtml;
  4163. $data ['receiptList'] = $receiptList;
  4164. $data ['memu'] = "receipt";
  4165. $data ['staff'] = $this->staff;
  4166. $data ['receiptMemu'] = 'expenses';
  4167. $data ['verifyId'] = $this->verifyId;
  4168. $data ['executeId'] = $this->executeId;
  4169. $data ['item'] = $item;
  4170. $data ['year'] = $year;
  4171. $this->render ( "/admin/expenses", $data );
  4172. }
  4173. function expensesCollect() {
  4174. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4175. Doo::loadModel ( 'receipt' );
  4176. $receipt = new receipt ();
  4177. Doo::loadModel ( 'L_category' );
  4178. $Lcategory = new L_category ();
  4179. Doo::loadModel ( 'verify' );
  4180. Doo::loadModel ( 'statistics' );
  4181. $statistics = new statistics ();
  4182. $verify = new verify ();
  4183. Doo::loadModel ( 'staff' );
  4184. $staff = new staff ();
  4185. Doo::loadModel ( 'loanReceipt' );
  4186. $loanReceipt = new loanReceipt ();
  4187. $receiptList = $receipt->find ( array (//去掉
  4188. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4189. 'desc' => 'rid',
  4190. 'asArray' => true
  4191. ) );
  4192. $loanList = $loanReceipt->find ( array (
  4193. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4194. 'desc' => 'rid',
  4195. 'asArray' => true
  4196. ) );
  4197. /*
  4198. * $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;
  4199. */
  4200. $data ['explanation'] = '';
  4201. if (! empty ( $loanList ))
  4202. $data ['explanation'] = $loanList [0] ['explanation'];
  4203. $Locate = 0;
  4204. $roleId = 0;
  4205. $button = 0;
  4206. foreach ( $receiptList as $key => $value ) {
  4207. $receiptList [$key] ['Locate'] = $Locate;
  4208. $Locate ++;
  4209. $receiptList [$key] ['reviseDetail'] = array ();
  4210. if (! empty ( $value ['reviseDetail'] ))
  4211. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4212. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4213. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4214. $categoryDetil = $Lcategory->getOne ( array (
  4215. 'where' => 'cid=' . $value ['cid'],
  4216. 'asArray' => true
  4217. ) );
  4218. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4219. // 检测编辑状态
  4220. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4221. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4222. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4223. else
  4224. $verifyList ['staff'] = $value ['verifyBreakup'];
  4225. } else
  4226. $verifyList = $verify->getOne ( array (
  4227. 'where' => 'vid=' . $value ['verify'],
  4228. 'asArray' => true
  4229. ) );
  4230. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4231. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4232. Doo::loadModel ( 'role' );
  4233. $role = new role ();
  4234. $flag = true;
  4235. $roleKey = 0;
  4236. $endStaffArray = array ();
  4237. $roleArrayCopy = array ();
  4238. foreach ( $verifyList as $k => $v ) {
  4239. // init verifyStaff
  4240. if ($v [1] == 'ROLE') {
  4241. if (! empty ( $verifyStaff )) {
  4242. $endStaffArray = end ( $verifyStaff );
  4243. // if ($v[0]==$endStaffArray['nextStaff']){
  4244. // $roleId=$v[0];
  4245. // }
  4246. }
  4247. $roleVerify = json_decode ( $v [3], true );
  4248. $roleKey = $k;
  4249. $roleArray = array ();
  4250. $rolename = $role->getOne ( array (
  4251. 'where' => 'rid=' . $v [0],
  4252. 'asArray' => true
  4253. ) );
  4254. foreach ( $roleVerify as $o => $p ) {
  4255. $staffID = explode ( '_', $p );
  4256. $staffInfo = $staff->getOne ( array (
  4257. 'where' => 'sid=' . $staffID [0],
  4258. 'asArray' => true
  4259. ) );
  4260. // print_r($staffID);
  4261. $exp = array (
  4262. 0 => $staffInfo ['sid'],
  4263. 1 => $staffID [1],
  4264. 2 => $staffInfo ['avatar'],
  4265. 'date' => '',
  4266. 'date' => '',
  4267. 'opinion' => '',
  4268. 'status' => '',
  4269. 'rolename' => $rolename ['name']
  4270. );
  4271. array_push ( $roleArray, $exp );
  4272. }
  4273. $roleArrayCopy [$v [0]] = $roleArray;
  4274. // $verifyList[$k]['roleArray']=$roleArray;
  4275. }
  4276. $verifyList [$k] ['date'] = "";
  4277. $verifyList [$k] ['opinion'] = "";
  4278. $verifyList [$k] ['status'] = "";
  4279. if (empty ( $verifyStaff )) {
  4280. $verifyList [$k] ['date'] = "";
  4281. $verifyList [$k] ['opinion'] = "";
  4282. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4283. $verifyList [$k] ['status'] = 4;
  4284. $flag = false;
  4285. }
  4286. } else {
  4287. foreach ( $verifyStaff as $m => $u ) {
  4288. if ($v [0] == $m) {
  4289. $verifyList [$k] ['date'] = $u ['date'];
  4290. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4291. $verifyList [$k] ['status'] = $u ['status'];
  4292. $flag = false;
  4293. break;
  4294. }
  4295. }
  4296. $endStaffArray = end ( $verifyStaff );
  4297. if (isset ( $endStaffArray ['ROLE'] )) {
  4298. } else {
  4299. // $endKey=key($verifyStaff);
  4300. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4301. // $button=4;
  4302. // $verifyList[$k]['status']=4;
  4303. // }
  4304. }
  4305. }
  4306. }
  4307. $rolename ['name'] = '';
  4308. if (! empty ( $roleId )) {
  4309. Doo::loadModel ( 'role' );
  4310. $role = new role ();
  4311. $rolename = $role->getOne ( array (
  4312. 'where' => 'rid=' . $roleId,
  4313. 'asArray' => true
  4314. ) );
  4315. }
  4316. if (! empty ( $verifyStaff ))
  4317. $endStaffArray = end ( $verifyStaff );
  4318. $KOP = false;
  4319. foreach ( $roleArrayCopy as $P => $A ) {
  4320. foreach ( $A as $MKI => $AVL ) {
  4321. if (! empty ( $verifyStaff )) {
  4322. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4323. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4324. $button = 4;
  4325. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4326. }
  4327. foreach ( $verifyStaff as $m => $u ) {
  4328. $AVLFK = $AVL [0] . '_R';
  4329. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4330. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4331. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4332. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4333. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4334. break;
  4335. }
  4336. }
  4337. } else {
  4338. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4339. $button = 4;
  4340. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4341. }
  4342. }
  4343. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4344. $KOP = true;
  4345. }
  4346. }
  4347. foreach ( $roleArrayCopy as $k => $v ) {
  4348. foreach ( $verifyList as $m => $n ) {
  4349. if ($n [0] == $k) {
  4350. array_splice ( $verifyList, $m, 1, $v );
  4351. }
  4352. }
  4353. }
  4354. // 费用执行人相关数据
  4355. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4356. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4357. foreach ( $executeCopy as $k => $v ) {
  4358. $executeCopy [$k] ['date'] = '';
  4359. $executeCopy [$k] ['opinion'] = '';
  4360. $executeCopy [$k] ['status'] = '';
  4361. if (! empty ( $executeStaff ))
  4362. foreach ( $executeStaff as $m => $u ) {
  4363. if ($v [0] == $m) {
  4364. $executeCopy [$k] ['date'] = $u ['date'];
  4365. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4366. $executeCopy [$k] ['status'] = $u ['status'];
  4367. break;
  4368. }
  4369. }
  4370. }
  4371. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4372. $receiptList [$key] ['verifyList'] = $verifyList;
  4373. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4374. 'where' => 'sid=' . $value ['staff'],
  4375. 'asArray' => true
  4376. ) );
  4377. $receiptList [$key] ['button'] = $button;
  4378. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4379. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4380. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4381. $receiptList [$key] ['relust'] = $relust;
  4382. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4383. }
  4384. Doo::loadModel ( 'enclosur' );
  4385. $enclosur = new enclosur ();
  4386. $enclosurList = $enclosur->find ( array (
  4387. 'where' => 'rid=' . $rid,
  4388. 'asArray' => true
  4389. ) );
  4390. $enclosurHtml = '';
  4391. foreach ( $enclosurList as $value ) {
  4392. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4393. }
  4394. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  4395. $data ['enclosurHtml'] = $enclosurHtml;
  4396. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4397. if($receiptList[0]['version']==1){
  4398. require "protected/class/comm_cld.php";
  4399. $receiptList=makeReceiptDataVersion1($receiptList);
  4400. }
  4401. $data ['receiptList'] = $receiptList;
  4402. $data ['memu'] = "receipt";
  4403. $data ['staff'] = $this->staff;
  4404. $data ['receiptMemu'] = 'expenses';
  4405. $data ['verifyId'] = $this->verifyId;
  4406. $data ['executeId'] = $this->executeId;
  4407. if($receiptList[0]['version']==1){
  4408. $this->render ( "/fee/detail/receipt_compatible", $data );
  4409. die;
  4410. }
  4411. if($receiptList[0]['receiptClass']==2){
  4412. if(!empty($receiptList[0]['itinerary2'])){
  4413. $this->render ( "/receipt/feeTraveDetail2", $data );
  4414. }else{
  4415. $this->render ( "/receipt/feeTraveDetail", $data );
  4416. }
  4417. }else{
  4418. $this->render ( "/admin/expensesCollect", $data );
  4419. }
  4420. }
  4421. function approvalExpenses() {
  4422. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4423. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4424. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4425. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4426. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4427. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4428. // echo $rdate;
  4429. if (empty ( $status ))
  4430. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4431. $page_size = 8;
  4432. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4433. $vidList = array ();
  4434. $button = 0;
  4435. Doo::loadModel ( 'verify' );
  4436. $verify = new verify ();
  4437. Doo::loadModel ( 'receipt' );
  4438. $receipt = new receipt ();
  4439. Doo::loadModel ( 'staff' );
  4440. $staff = new staff ();
  4441. Doo::loadModel ( 'L_category' );
  4442. $Lcategory = new L_category ();
  4443. // user verify ID
  4444. $verifyDetail = $verify->find ( array (
  4445. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4446. 'asArray' => true
  4447. ) );
  4448. foreach ( $verifyDetail as $key => $value ) {
  4449. array_push ( $vidList, $value ['vid'] );
  4450. }
  4451. $vid = implode ( ",", $vidList );
  4452. if (empty ( $verifyDetail )){
  4453. $vid = 0;
  4454. }
  4455. $dateCondition = " ";
  4456. // if (! empty ( $month ))
  4457. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4458. if ($status == 'done' || $status == 'termination') {
  4459. if (! empty ( $year )) {
  4460. $dateCondition = " and Year(pastDate) =" . $year;
  4461. if (! empty ( $month ))
  4462. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4463. }
  4464. } elseif ($status == 'finish') {
  4465. if (! empty ( $year )) {
  4466. $dateCondition = " and Year(pastDate) =" . $year;
  4467. if (! empty ( $month ))
  4468. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4469. }
  4470. }
  4471. // date ( 'Y-m' )
  4472. // if (! empty ( $rdate ) && $status == 'done')
  4473. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4474. // elseif (! empty ( $rdate ))
  4475. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4476. $categoryList = $Lcategory->find ( array (
  4477. 'asArray' => true
  4478. ) );
  4479. $staffList = $staff->find ( array (
  4480. 'where' => 'cid=' . $cid,
  4481. 'asArray' => true
  4482. ) );
  4483. $cateCondition = "";
  4484. $staffCondition = "";
  4485. $approvalCondition = "";
  4486. if (! empty ( $cid )) {
  4487. $cateCondition = ' and cid=' . $cid;
  4488. }
  4489. if (! empty ( $sid )) {
  4490. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4491. $cateCondition = "";
  4492. }
  4493. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4494. if ($status == 'pendApproval') {
  4495. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4496. }
  4497. if ($status == 'ongoing') {
  4498. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4499. }
  4500. if ($status == 'done') {
  4501. $approvalCondition = ' and (status=8 or status=9 ) ';
  4502. }
  4503. if ($status == 'termination') {
  4504. $approvalCondition = " and status=3";
  4505. }
  4506. if ($status == 'finish') {
  4507. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4508. }
  4509. if($status == 'loan'){
  4510. $approvalCondition = " and (status=8 or status=7) and Rtype=1";
  4511. }
  4512. $pageinfo ['page'] = array (
  4513. 'previous' => ''
  4514. );
  4515. if(!empty($receiptOrder)){
  4516. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4517. $receiptList = $receipt->find ( array ( // $dateCondition
  4518. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4519. 'desc' => 'rid',
  4520. 'asArray' => true
  4521. ) );
  4522. }else{
  4523. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4524. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4525. $receiptList = $receipt->find ( array ( // $dateCondition.
  4526. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4527. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4528. 'desc' => 'rid',
  4529. 'asArray' => true
  4530. ) );
  4531. } else {
  4532. $receiptList = $receipt->find ( array ( // $dateCondition
  4533. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4534. 'desc' => 'rid',
  4535. 'asArray' => true
  4536. ) );
  4537. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4538. }
  4539. }
  4540. $rLRes = $receipt->find ( array (
  4541. '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 . ')',
  4542. 'desc' => 'rid',
  4543. 'asArray' => true
  4544. ) );
  4545. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4546. // print_r($receiptList);
  4547. Doo::loadClass ( 'XDeode' );
  4548. $XDeode = new XDeode ( 7 );
  4549. $XDeode9 = new XDeode ( 9 );
  4550. $Locate = 0;
  4551. //
  4552. $reportList = $reportCateList = array ();
  4553. foreach ( $receiptList as $key => $value ) {
  4554. $receiptList [$key] ['rid_cld'] = $XDeode9->encode ( $value ['rid'] );
  4555. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4556. $receiptList [$key] ['Locate'] = $Locate;
  4557. $Locate ++;
  4558. $receiptList [$key] ['reviseDetail'] = array ();
  4559. if (! empty ( $value ['reviseDetail'] ))
  4560. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4561. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4562. $categoryDetil = $Lcategory->getOne ( array (
  4563. 'where' => 'cid=' . $value ['cid'],
  4564. 'asArray' => true
  4565. ) );
  4566. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4567. $verifyList = $verify->getOne ( array (
  4568. 'where' => 'vid=' . $value ['verify'],
  4569. 'asArray' => true
  4570. ) );
  4571. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4572. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4573. foreach ( $verifyList as $k => $v ) {
  4574. // init verifyStaff
  4575. $verifyList [$k] ['date'] = "";
  4576. $verifyList [$k] ['opinion'] = "";
  4577. $verifyList [$k] ['status'] = "";
  4578. if (empty ( $verifyStaff )) {
  4579. $verifyList [$k] ['date'] = "";
  4580. $verifyList [$k] ['opinion'] = "";
  4581. if ($v [0] == $this->staff [0] ['sid']) {
  4582. $verifyList [$k] ['status'] = 4;
  4583. $button = 4;
  4584. }
  4585. } else {
  4586. $flag = true;
  4587. foreach ( $verifyStaff as $m => $u ) {
  4588. if ($v [0] == $m) {
  4589. $verifyList [$k] ['date'] = $u ['date'];
  4590. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4591. $verifyList [$k] ['status'] = $u ['status'];
  4592. $flag = false;
  4593. break;
  4594. }
  4595. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4596. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4597. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4598. }
  4599. if ($flag) { // 检测可编辑
  4600. if ($v [0] == $this->staff [0] ['sid']) {
  4601. $verifyList [$k] ['status'] = 4;
  4602. $button = 4;
  4603. }
  4604. }
  4605. }
  4606. }
  4607. $receiptList [$key] ['verifyList'] = $verifyList;
  4608. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4609. 'where' => 'sid=' . $value ['staff'],
  4610. 'asArray' => true
  4611. ) );
  4612. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4613. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4614. $receiptList [$key] ['button'] = $button;
  4615. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4616. //获得培训班结算RID 借款费用--已经锁定
  4617. if($value['status']==10){
  4618. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4619. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4620. }
  4621. if($value['version']==1){
  4622. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4623. }
  4624. }
  4625. $reportList = array_unique ( $reportList );
  4626. $reportHtml = '';
  4627. foreach ( $reportList as $key => $value ) {
  4628. $v = explode ( "-", $value );
  4629. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4630. }
  4631. // print_r($reportList)
  4632. $data ['reportHtml'] = $reportHtml;
  4633. $reportCateList = array_unique ( $reportCateList );
  4634. $reportCateHtml = '';
  4635. foreach ( $reportCateList as $key => $value ) {
  4636. $v = explode ( "-", $value );
  4637. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4638. }
  4639. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4640. $data ['reportCateHtml'] = $reportCateHtml;
  4641. // print_r($receiptList);die;
  4642. // $data['verifyDetail']=$verifyDetail;
  4643. $mothHtml = "";
  4644. for($i = 1; $i <= 12; $i ++) {
  4645. if ($month == $i)
  4646. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4647. else
  4648. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4649. }
  4650. $data ['mothHtml'] = $mothHtml;
  4651. $dateHtml = "";
  4652. $now = date ( "Y" );
  4653. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4654. if ($YEARD <= $now) {
  4655. $dateHtml .= '<option ';
  4656. if ($year == $YEARD) {
  4657. $dateHtml .= 'selected ';
  4658. }
  4659. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4660. }
  4661. }
  4662. $data ['dateHtml'] = $dateHtml;
  4663. $data ['page'] = $pageinfo;
  4664. $data ['receiptList'] = $receiptList;
  4665. $data ['receiptApprovalCount'] = count ( $rLRes );
  4666. $data ['status'] = $status;
  4667. $data ['year'] = $year;
  4668. $data ['month'] = $month;
  4669. $data ['categoryList'] = $categoryList;
  4670. $data ['staffList'] = $staffList;
  4671. $data ['cid'] = $cid;
  4672. $data ['sid'] = $sid;
  4673. // print_r($receiptList);
  4674. $data['receiptOrder']=$receiptOrder;
  4675. $data ['memu'] = "receipt";
  4676. $data ['staff'] = $this->staff;
  4677. $data ['receiptMemu'] = 'approvalExpenses';
  4678. $data ['verifyId'] = $this->verifyId;
  4679. $data ['executeId'] = $this->executeId;
  4680. $this->render ( "/admin/approvalExpenses", $data );
  4681. }
  4682. private function _expensesDoc(){
  4683. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4684. Doo::loadClass ( 'XDeode' );
  4685. $XDeode = new XDeode ( 5 );
  4686. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4687. $rid = $XDeode->decode ( $rid );
  4688. if (! is_numeric ( $rid ))
  4689. die ( 'illegal request' );
  4690. Doo::loadModel ( 'receipt' );
  4691. $receipt = new receipt ();
  4692. Doo::loadModel ( 'L_category' );
  4693. $Lcategory = new L_category ();
  4694. Doo::loadModel ( 'verify' );
  4695. Doo::loadModel ( 'statistics' );
  4696. $statistics = new statistics ();
  4697. $verify = new verify ();
  4698. Doo::loadModel ( 'staff' );
  4699. $staff = new staff ();
  4700. Doo::loadModel ( 'loanReceipt' );
  4701. $loanReceipt = new loanReceipt ();
  4702. $receiptList = $receipt->find ( array (
  4703. 'where' => ' rid=' . $rid,
  4704. 'desc' => 'rid',
  4705. 'asArray' => true
  4706. ) );
  4707. $loanList = array ();
  4708. if (! empty ( $receiptList ))
  4709. $loanList = $loanReceipt->find ( array (
  4710. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4711. 'desc' => 'rid',
  4712. 'asArray' => true
  4713. ) );
  4714. $Locate = 0;
  4715. $roleId = 0;
  4716. $button = 0;
  4717. foreach ( $loanList as $key => $value ) {
  4718. $loanList [$key] ['Locate'] = $Locate;
  4719. $Locate ++;
  4720. $loanList [$key] ['reviseDetail'] = array ();
  4721. if (! empty ( $value ['reviseDetail'] ))
  4722. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4723. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4724. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4725. $categoryDetil = $Lcategory->getOne ( array (
  4726. 'where' => 'cid=' . $value ['cid'],
  4727. 'asArray' => true
  4728. ) );
  4729. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4730. // 检测编辑状态
  4731. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4732. $verifyList ['staff'] = $value ['verifyBreakup'];
  4733. else
  4734. $verifyList = $verify->getOne ( array (
  4735. 'where' => 'vid=' . $value ['verify'],
  4736. 'asArray' => true
  4737. ) );
  4738. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4739. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4740. Doo::loadModel ( 'role' );
  4741. $role = new role ();
  4742. $flag = true;
  4743. $roleKey = 0;
  4744. $endStaffArray = array ();
  4745. $roleArrayCopy = array ();
  4746. foreach ( $verifyList as $k => $v ) {
  4747. // init verifyStaff
  4748. if ($v [1] == 'ROLE') {
  4749. if (! empty ( $verifyStaff )) {
  4750. $endStaffArray = end ( $verifyStaff );
  4751. // if ($v[0]==$endStaffArray['nextStaff']){
  4752. // $roleId=$v[0];
  4753. // }
  4754. }
  4755. $roleVerify = json_decode ( $v [3], true );
  4756. $roleKey = $k;
  4757. $roleArray = array ();
  4758. $rolename = $role->getOne ( array (
  4759. 'where' => 'rid=' . $v [0],
  4760. 'asArray' => true
  4761. ) );
  4762. foreach ( $roleVerify as $o => $p ) {
  4763. $staffID = explode ( '_', $p );
  4764. $staffInfo = $staff->getOne ( array (
  4765. 'where' => 'sid=' . $staffID [0],
  4766. 'asArray' => true
  4767. ) );
  4768. // print_r($staffID);
  4769. $exp = array (
  4770. 0 => $staffInfo ['sid'],
  4771. 1 => $staffID [1],
  4772. 2 => $staffInfo ['avatar'],
  4773. 'date' => '',
  4774. 'date' => '',
  4775. 'opinion' => '',
  4776. 'status' => '',
  4777. 'rolename' => $rolename ['name']
  4778. );
  4779. array_push ( $roleArray, $exp );
  4780. }
  4781. $roleArrayCopy [$v [0]] = $roleArray;
  4782. // $verifyList[$k]['roleArray']=$roleArray;
  4783. }
  4784. $verifyList [$k] ['date'] = "";
  4785. $verifyList [$k] ['opinion'] = "";
  4786. $verifyList [$k] ['status'] = "";
  4787. if (empty ( $verifyStaff )) {
  4788. $verifyList [$k] ['date'] = "";
  4789. $verifyList [$k] ['opinion'] = "";
  4790. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4791. $verifyList [$k] ['status'] = 4;
  4792. $flag = false;
  4793. }
  4794. } else {
  4795. foreach ( $verifyStaff as $m => $u ) {
  4796. if ($v [0] == $m) {
  4797. $verifyList [$k] ['date'] = $u ['date'];
  4798. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4799. $verifyList [$k] ['status'] = $u ['status'];
  4800. $flag = false;
  4801. break;
  4802. }
  4803. }
  4804. $endStaffArray = end ( $verifyStaff );
  4805. if (isset ( $endStaffArray ['ROLE'] )) {
  4806. } else {
  4807. // $endKey=key($verifyStaff);
  4808. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4809. // $button=4;
  4810. // $verifyList[$k]['status']=4;
  4811. // }
  4812. }
  4813. }
  4814. }
  4815. $rolename ['name'] = '';
  4816. if (! empty ( $roleId )) {
  4817. Doo::loadModel ( 'role' );
  4818. $role = new role ();
  4819. $rolename = $role->getOne ( array (
  4820. 'where' => 'rid=' . $roleId,
  4821. 'asArray' => true
  4822. ) );
  4823. }
  4824. if (! empty ( $verifyStaff ))
  4825. $endStaffArray = end ( $verifyStaff );
  4826. $KOP = false;
  4827. foreach ( $roleArrayCopy as $P => $A ) {
  4828. foreach ( $A as $MKI => $AVL ) {
  4829. if (! empty ( $verifyStaff )) {
  4830. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4831. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4832. $button = 4;
  4833. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4834. }
  4835. foreach ( $verifyStaff as $m => $u ) {
  4836. $AVLFK = $AVL [0] . '_R';
  4837. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4838. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4839. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4840. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4841. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4842. break;
  4843. }
  4844. }
  4845. } else {
  4846. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4847. $button = 4;
  4848. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4849. }
  4850. }
  4851. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4852. $KOP = true;
  4853. }
  4854. }
  4855. foreach ( $roleArrayCopy as $k => $v ) {
  4856. foreach ( $verifyList as $m => $n ) {
  4857. if ($n [0] == $k) {
  4858. array_splice ( $verifyList, $m, 1, $v );
  4859. }
  4860. }
  4861. }
  4862. $loanList [$key] ['verifyList'] = $verifyList;
  4863. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4864. 'where' => 'sid=' . $value ['staff'],
  4865. 'asArray' => true
  4866. ) );
  4867. $loanList [$key] ['button'] = $button;
  4868. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4869. }
  4870. $data ['loanList'] = $loanList;
  4871. $data ['explanation'] = '';
  4872. if (! empty ( $loanList )){
  4873. $data ['explanation'] = $loanList [0] ['explanation'];
  4874. }
  4875. //print_r($loanList);
  4876. $Locate = 0;
  4877. $roleId = 0;
  4878. $button = 0;
  4879. foreach ( $receiptList as $key => $value ) {
  4880. $receiptList [$key] ['Locate'] = $Locate;
  4881. $Locate ++;
  4882. $receiptList [$key] ['reviseDetail'] = array ();
  4883. if (! empty ( $value ['reviseDetail'] ))
  4884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4886. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4887. $categoryDetil = $Lcategory->getOne ( array (
  4888. 'where' => 'cid=' . $value ['cid'],
  4889. 'asArray' => true
  4890. ) );
  4891. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4892. // 检测编辑状态
  4893. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4894. $verifyList ['staff'] = $value ['verifyBreakup'];
  4895. } else
  4896. $verifyList = $verify->getOne ( array (
  4897. 'where' => 'vid=' . $value ['verify'],
  4898. 'asArray' => true
  4899. ) );
  4900. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4901. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4902. Doo::loadModel ( 'role' );
  4903. $role = new role ();
  4904. if ($verifyList == NULL)
  4905. $verifyList = array ();
  4906. $flag = true;
  4907. $roleKey = 0;
  4908. $endStaffArray = array ();
  4909. $roleArrayCopy = array ();
  4910. foreach ( $verifyList as $k => $v ) {
  4911. // init verifyStaff
  4912. if ($v [1] == 'ROLE') {
  4913. if (! empty ( $verifyStaff )) {
  4914. $endStaffArray = end ( $verifyStaff );
  4915. // if ($v[0]==$endStaffArray['nextStaff']){
  4916. // $roleId=$v[0];
  4917. // }
  4918. }
  4919. $roleVerify = json_decode ( $v [3], true );
  4920. $roleKey = $k;
  4921. $roleArray = array ();
  4922. $rolename = $role->getOne ( array (
  4923. 'where' => 'rid=' . $v [0],
  4924. 'asArray' => true
  4925. ) );
  4926. foreach ( $roleVerify as $o => $p ) {
  4927. $staffID = explode ( '_', $p );
  4928. $staffInfo = $staff->getOne ( array (
  4929. 'where' => 'sid=' . $staffID [0],
  4930. 'asArray' => true
  4931. ) );
  4932. // print_r($staffID);
  4933. $exp = array (
  4934. 0 => $staffInfo ['sid'],
  4935. 1 => $staffID [1],
  4936. 2 => $staffInfo ['avatar'],
  4937. 'date' => '',
  4938. 'date' => '',
  4939. 'opinion' => '',
  4940. 'status' => '',
  4941. 'rolename' => $rolename ['name']
  4942. );
  4943. array_push ( $roleArray, $exp );
  4944. }
  4945. $roleArrayCopy [$v [0]] = $roleArray;
  4946. // $verifyList[$k]['roleArray']=$roleArray;
  4947. }
  4948. $verifyList [$k] ['date'] = "";
  4949. $verifyList [$k] ['opinion'] = "";
  4950. $verifyList [$k] ['status'] = "";
  4951. if (empty ( $verifyStaff )) {
  4952. $verifyList [$k] ['date'] = "";
  4953. $verifyList [$k] ['opinion'] = "";
  4954. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4955. $verifyList [$k] ['status'] = 4;
  4956. $flag = false;
  4957. }
  4958. } else {
  4959. foreach ( $verifyStaff as $m => $u ) {
  4960. if ($v [0] == $m) {
  4961. $verifyList [$k] ['date'] = $u ['date'];
  4962. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4963. $verifyList [$k] ['status'] = $u ['status'];
  4964. $flag = false;
  4965. break;
  4966. }
  4967. }
  4968. $endStaffArray = end ( $verifyStaff );
  4969. if (isset ( $endStaffArray ['ROLE'] )) {
  4970. } else {
  4971. // $endKey=key($verifyStaff);
  4972. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4973. // $button=4;
  4974. // $verifyList[$k]['status']=4;
  4975. // }
  4976. }
  4977. }
  4978. }
  4979. $FC = @$rolename ['name'];
  4980. $rolename ['name'] = '';
  4981. if (! empty ( $roleId )) {
  4982. Doo::loadModel ( 'role' );
  4983. $role = new role ();
  4984. $rolename = $role->getOne ( array (
  4985. 'where' => 'rid=' . $roleId,
  4986. 'asArray' => true
  4987. ) );
  4988. }
  4989. if (! empty ( $verifyStaff ))
  4990. $endStaffArray = end ( $verifyStaff );
  4991. $KOP = false;
  4992. foreach ( $roleArrayCopy as $P => $A ) {
  4993. foreach ( $A as $MKI => $AVL ) {
  4994. if (! empty ( $verifyStaff )) {
  4995. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4996. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4997. $button = 4;
  4998. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4999. }
  5000. foreach ( $verifyStaff as $m => $u ) {
  5001. $AVLFK = $AVL [0] . '_R';
  5002. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5003. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5004. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5005. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5006. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5007. break;
  5008. }
  5009. }
  5010. } else {
  5011. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5012. $button = 4;
  5013. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5014. }
  5015. }
  5016. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5017. $KOP = true;
  5018. }
  5019. }
  5020. foreach ( $roleArrayCopy as $k => $v ) {
  5021. foreach ( $verifyList as $m => $n ) {
  5022. if ($n [0] == $k) {
  5023. array_splice ( $verifyList, $m, 1, $v );
  5024. }
  5025. }
  5026. }
  5027. // 费用执行人相关数据
  5028. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5029. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5030. foreach ( $executeCopy as $k => $v ) {
  5031. $executeCopy [$k] ['date'] = '';
  5032. $executeCopy [$k] ['opinion'] = '';
  5033. $executeCopy [$k] ['status'] = '';
  5034. if (! empty ( $executeStaff ))
  5035. foreach ( $executeStaff as $m => $u ) {
  5036. if ($v [0] == $m) {
  5037. $executeCopy [$k] ['date'] = $u ['date'];
  5038. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5039. $executeCopy [$k] ['status'] = $u ['status'];
  5040. break;
  5041. }
  5042. }
  5043. }
  5044. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5045. // print_r($verifyList);
  5046. $receiptList [$key] ['verifyList'] = $verifyList;
  5047. // print_r($verifyList);
  5048. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5049. 'where' => 'sid=' . $value ['staff'],
  5050. 'asArray' => true
  5051. ) );
  5052. $receiptList [$key] ['button'] = $button;
  5053. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5054. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5055. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5056. $receiptList [$key] ['relust'] = $relust;
  5057. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5058. }
  5059. // print_r($receiptList);
  5060. // 获取审批日志
  5061. Doo::loadModel ( 'receiptLog' );
  5062. $receiptLog = new receiptLog ();
  5063. $rlList = array ();
  5064. $rlInfo = $receiptLog->getOne ( array (
  5065. 'where' => 'rid=' . $rid . ' and status=4',
  5066. 'asArray' => true
  5067. ) );
  5068. // $tijdate = $receiptLog->getOne ( array (
  5069. // 'where' => 'rid=' . $rid . ' and status=2',
  5070. // 'asc' => 'rlid',
  5071. // 'asArray' => true
  5072. // ) );
  5073. if (! empty ( $rlInfo )) {
  5074. $rlList = $receiptLog->find ( array (
  5075. 'where' => 'rid=' . $rid,
  5076. 'asc' => 'rlid',
  5077. 'asArray' => true
  5078. ) );
  5079. }
  5080. $RN=array();
  5081. if (!empty( $rolename ['staff'])){
  5082. $RN = @json_decode ( $rolename ['staff'] );
  5083. }
  5084. //
  5085. foreach ( $rlList as $key => $value ) {
  5086. $rlList [$key] ['rolename'] = '';
  5087. foreach ( $RN as $k => $v ) {
  5088. $id = explode ( "_", $v );
  5089. if ($id [0] == $value ['uid']) {
  5090. $rlList [$key] ['rolename'] = $FC;
  5091. break;
  5092. }
  5093. }
  5094. }
  5095. Doo::loadModel ( 'enclosur' );
  5096. $enclosur = new enclosur ();
  5097. $enclosurList = $enclosur->find ( array (
  5098. 'where' => 'rid=' . $rid,
  5099. 'asArray' => true
  5100. ) );
  5101. $enclosurHtml = '';
  5102. foreach ( $enclosurList as $value ) {
  5103. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5104. }
  5105. if($receiptList[0]['version']==1){
  5106. require "protected/class/comm_cld.php";
  5107. $receiptList=makeReceiptDataVersion1($receiptList);
  5108. }
  5109. $data ['enclosurHtml'] = $enclosurHtml;
  5110. $receiptList [0] ['rlList'] = $rlList;
  5111. // print_r($rlList);
  5112. $data ['receiptList'] = $receiptList;
  5113. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5114. // print_r($receiptList);
  5115. $data ['memu'] = "receipt";
  5116. $data ['staff'] = $this->staff;
  5117. $data ['receiptMemu'] = 'approvalExpenses';
  5118. $data ['verifyId'] = $this->verifyId;
  5119. $data ['executeId'] = $this->executeId;
  5120. return $data;
  5121. }
  5122. function expensesDoc() {
  5123. $data=$this->_expensesDoc();
  5124. if($data['receiptList'][0]['version']==1){
  5125. $this->render ( "/fee/detail/receipt_compatible", $data );
  5126. die;
  5127. }
  5128. if(!empty($data['receiptList'][0]['itinerary2'])){
  5129. $this->render ( "/receipt/feeTraveView", $data );
  5130. }else{
  5131. $this->render ( "/admin/expensesDoc", $data );
  5132. }
  5133. }
  5134. function expensesDocPrint(){
  5135. $data=$this->_expensesDoc();
  5136. if($data['receiptList'][0]['version']==1){
  5137. $this->render ( "/fee/detail/receiptPrint_compatible", $data );
  5138. die;
  5139. }
  5140. $this->render ( "/receipt/expensesDocPrint", $data );
  5141. }
  5142. function expensesEdi() {
  5143. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5144. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5145. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5146. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5147. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5148. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5149. if (empty ( $status ))
  5150. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5151. $vidList = array ();
  5152. $button = 0;
  5153. Doo::loadModel ( 'verify' );
  5154. Doo::loadModel ( 'receipt' );
  5155. Doo::loadModel ( 'staff' );
  5156. $staff = new staff ();
  5157. $receipt = new receipt ();
  5158. $verify = new verify ();
  5159. Doo::loadModel ( 'L_category' );
  5160. $Lcategory = new L_category ();
  5161. Doo::loadModel ( 'enclosur' );
  5162. $enclosur = new enclosur ();
  5163. // user verify ID
  5164. $verifyDetail = $verify->find ( array (
  5165. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5166. 'asArray' => true
  5167. ) );
  5168. foreach ( $verifyDetail as $key => $value ) {
  5169. array_push ( $vidList, $value ['vid'] );
  5170. }
  5171. $vid = implode ( ",", $vidList );
  5172. if (empty ( $verifyDetail ))
  5173. $vid = 0;
  5174. $categoryList = $Lcategory->find ( array (
  5175. 'asArray' => true
  5176. ) );
  5177. $staffList = $staff->find ( array (
  5178. 'where' => 'cid=' . $cid,
  5179. 'asArray' => true
  5180. ) );
  5181. $ap = "";
  5182. if ($status == 4) {
  5183. $ap = 4;
  5184. $status = 2;
  5185. }
  5186. // get Receipt By verifyID status 2
  5187. $receiptList = $receipt->find ( array (
  5188. 'where' => 'rid =' . $rid . ' and status=2',
  5189. 'desc' => 'rid',
  5190. 'asArray' => true
  5191. ) );
  5192. if (empty ( $receiptList )) {
  5193. die ( 'illegal request' );
  5194. }
  5195. $Locate = 0;
  5196. $roleId = 0;
  5197. if ($ap == 4)
  5198. $status = 4;
  5199. foreach ( $receiptList as $key => $value ) {
  5200. $receiptList [$key] ['Locate'] = $Locate;
  5201. $Locate ++;
  5202. $receiptList [$key] ['reviseDetail'] = array ();
  5203. if (! empty ( $value ['reviseDetail'] ))
  5204. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5205. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5206. $categoryDetil = $Lcategory->getOne ( array (
  5207. 'where' => 'cid=' . $value ['cid'],
  5208. 'asArray' => true
  5209. ) );
  5210. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5211. // 检测编辑状态
  5212. $verifyList = $verify->getOne ( array (
  5213. 'where' => 'vid=' . $value ['verify'],
  5214. 'asArray' => true
  5215. ) );
  5216. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5217. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5218. Doo::loadModel ( 'role' );
  5219. $role = new role ();
  5220. // print_r($verifyList);
  5221. $flag = true;
  5222. $roleKey = 0;
  5223. $endStaffArray = array ();
  5224. $roleArrayCopy = array ();
  5225. foreach ( $verifyList as $k => $v ) {
  5226. // init verifyStaff
  5227. if ($v [1] == 'ROLE') {
  5228. if (! empty ( $verifyStaff )) {
  5229. $endStaffArray = end ( $verifyStaff );
  5230. if ($v [0] == $endStaffArray ['nextStaff']) {
  5231. $roleId = $v [0];
  5232. }
  5233. }
  5234. $roleVerify = json_decode ( $v [3], true );
  5235. $roleKey = $k;
  5236. $roleArray = array ();
  5237. $rolename = $role->getOne ( array (
  5238. 'where' => 'rid=' . $v [0],
  5239. 'asArray' => true
  5240. ) );
  5241. foreach ( $roleVerify as $o => $p ) {
  5242. $staffID = explode ( '_', $p );
  5243. $staffInfo = $staff->getOne ( array (
  5244. 'where' => 'sid=' . $staffID [0],
  5245. 'asArray' => true
  5246. ) );
  5247. // print_r($staffID);
  5248. $exp = array (
  5249. 0 => $staffInfo ['sid'],
  5250. 1 => $staffID [1],
  5251. 2 => $staffInfo ['avatar'],
  5252. 'date' => '',
  5253. 'date' => '',
  5254. 'opinion' => '',
  5255. 'status' => '',
  5256. 'rolename' => $rolename ['name']
  5257. );
  5258. array_push ( $roleArray, $exp );
  5259. }
  5260. $roleArrayCopy [$v [0]] = $roleArray;
  5261. // $verifyList[$k]['roleArray']=$roleArray;
  5262. }
  5263. // print_r($roleArray);
  5264. $verifyList [$k] ['date'] = "";
  5265. $verifyList [$k] ['opinion'] = "";
  5266. $verifyList [$k] ['status'] = "";
  5267. if (empty ( $verifyStaff )) {
  5268. $verifyList [$k] ['date'] = "";
  5269. $verifyList [$k] ['opinion'] = "";
  5270. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5271. $verifyList [$k] ['status'] = 4;
  5272. $button = 4;
  5273. $flag = false;
  5274. }
  5275. } else {
  5276. foreach ( $verifyStaff as $m => $u ) {
  5277. if ($v [0] == $m) {
  5278. $verifyList [$k] ['date'] = $u ['date'];
  5279. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5280. $verifyList [$k] ['status'] = $u ['status'];
  5281. $flag = false;
  5282. break;
  5283. }
  5284. }
  5285. $endStaffArray = end ( $verifyStaff );
  5286. if (isset ( $endStaffArray ['ROLE'] )) {
  5287. } else {
  5288. $endKey = key ( $verifyStaff );
  5289. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5290. $button = 4;
  5291. $verifyList [$k] ['status'] = 4;
  5292. }
  5293. }
  5294. }
  5295. }
  5296. $rolename ['name'] = '';
  5297. if (! empty ( $roleId )) {
  5298. Doo::loadModel ( 'role' );
  5299. $role = new role ();
  5300. $rolename = $role->getOne ( array (
  5301. 'where' => 'rid=' . $roleId,
  5302. 'asArray' => true
  5303. ) );
  5304. }
  5305. if (! empty ( $verifyStaff ))
  5306. $endStaffArray = end ( $verifyStaff );
  5307. $KOP = false;
  5308. foreach ( $roleArrayCopy as $P => $A ) {
  5309. foreach ( $A as $MKI => $AVL ) {
  5310. if (! empty ( $verifyStaff )) {
  5311. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5312. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5313. $button = 4;
  5314. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5315. }
  5316. foreach ( $verifyStaff as $m => $u ) {
  5317. $AVLFK = $AVL [0] . '_R';
  5318. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5319. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5320. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5321. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5322. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5323. break;
  5324. }
  5325. }
  5326. } else {
  5327. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5328. $button = 4;
  5329. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5330. }
  5331. }
  5332. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5333. $KOP = true;
  5334. }
  5335. }
  5336. // print_r($roleArrayCopy);
  5337. // echo $roleKey;
  5338. foreach ( $roleArrayCopy as $k => $v ) {
  5339. foreach ( $verifyList as $m => $n ) {
  5340. if ($n [0] == $k) {
  5341. array_splice ( $verifyList, $m, 1, $v );
  5342. }
  5343. }
  5344. }
  5345. $receiptList [$key] ['verifyList'] = $verifyList;
  5346. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5347. 'where' => 'sid=' . $value ['staff'],
  5348. 'asArray' => true
  5349. ) );
  5350. $receiptList [$key] ['button'] = $button;
  5351. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5352. }
  5353. // $data['verifyDetail']=$verifyDetail;
  5354. $mothHtml = "";
  5355. for($i = 1; $i <= 12; $i ++) {
  5356. if ($month == $i)
  5357. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5358. else
  5359. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5360. }
  5361. // 获取审批日志
  5362. Doo::loadModel ( 'receiptLog' );
  5363. $receiptLog = new receiptLog ();
  5364. $rlList = array ();
  5365. $rlInfo = $receiptLog->getOne ( array (
  5366. 'where' => 'rid=' . $rid . ' and status=4',
  5367. 'asArray' => true
  5368. ) );
  5369. $tijdate = $receiptLog->getOne ( array (
  5370. 'where' => 'rid=' . $rid . ' and status=2',
  5371. 'asc' => 'rlid',
  5372. 'asArray' => true
  5373. ) );
  5374. if (! empty ( $rlInfo )) {
  5375. $rlList = $receiptLog->find ( array (
  5376. 'where' => 'rid=' . $rid,
  5377. 'asc' => 'rlid',
  5378. 'asArray' => true
  5379. ) );
  5380. }
  5381. $receiptList [0] ['rlList'] = $rlList;
  5382. $enclosurList = $enclosur->find ( array (
  5383. 'where' => 'rid=' . $rid,
  5384. 'asArray' => true
  5385. ) );
  5386. $enclosurHtml = '';
  5387. foreach ( $enclosurList as $value ) {
  5388. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5389. }
  5390. // print_r($receiptList);
  5391. $data ['rid'] = $rid;
  5392. $data ['enclosurHtml'] = $enclosurHtml;
  5393. $data ['rolename'] = $rolename ['name'];
  5394. $data ['datetij'] = $tijdate ['date'];
  5395. $data ['mothHtml'] = $mothHtml;
  5396. $data ['receiptList'] = $receiptList;
  5397. $data ['receiptApprovalCount'] = count ( $receiptList );
  5398. $data ['status'] = $status;
  5399. $data ['year'] = $year;
  5400. $data ['categoryList'] = $categoryList;
  5401. $data ['staffList'] = $staffList;
  5402. $data ['cid'] = $cid;
  5403. $data ['sid'] = $sid;
  5404. $data ['ap'] = $ap;
  5405. $data ['memu'] = "receipt";
  5406. $data ['staff'] = $this->staff;
  5407. $data ['receiptMemu'] = 'approvalExpenses';
  5408. $data ['verifyId'] = $this->verifyId;
  5409. $data ['executeId'] = $this->executeId;
  5410. $this->render ( "/admin/expensesEdi", $data );
  5411. }
  5412. function expensesDefray() {
  5413. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5414. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5415. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5416. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5417. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5418. if (! empty ( $rid )) {
  5419. Doo::loadModel ( "verify" );
  5420. $verify = new verify ();
  5421. Doo::loadModel ( "receiptDetail" );
  5422. $receiptDetailObj = new receiptDetail ();
  5423. Doo::loadModel ( "itemStatistics" );
  5424. Doo::loadModel ( "statistics" );
  5425. $statistics = new statistics ();
  5426. $itemStatistics = new itemStatistics ();
  5427. Doo::loadModel ( "receipt" );
  5428. $receipt = new receipt ();
  5429. Doo::loadModel ( "loanReceipt" );
  5430. $loanReceipt = new loanReceipt ();
  5431. $receiptDetail = $receipt->getOne ( array (
  5432. 'where' => 'rid=' . $rid . ' and status=2 ',
  5433. 'asArray' => true
  5434. ) );
  5435. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5436. $nsflag = true;
  5437. foreach ( $nslist as $value ) {
  5438. if ($value == $this->staff ['0'] ['sid']) {
  5439. $nsflag = false;
  5440. break;
  5441. }
  5442. }
  5443. // print_r($nslist);die;
  5444. if (empty ( $receiptDetail ) || $nsflag)
  5445. return "/approvalExpenses/pendApproval";
  5446. $verifyDetail = $verify->getOne ( array (
  5447. 'where' => ' vid =' . $receiptDetail ['verify'],
  5448. 'asArray' => true
  5449. ) );
  5450. $verifyString = $verifyDetail ['staff'];
  5451. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5452. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5453. if (empty ( $opinion )) {
  5454. if ($status == 3)
  5455. $opinion = "终止";
  5456. else
  5457. $opinion = "同意支付";
  5458. }
  5459. $nowStaff = 0;
  5460. $nowStaffList = array ();
  5461. if (empty ( $verifyStaff )) {
  5462. // 还需加入是否已经进入角色审批
  5463. if ($verifyDetail [0] [1] == 'ROLE') {
  5464. // print_r($verifyDetail);echo "ddd";
  5465. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5466. foreach ( $vStaffString as $key => $value ) {
  5467. $staffK = explode ( "_", $value );
  5468. if ($staffK [0] != $this->staff [0] ['sid'])
  5469. array_push ( $nowStaffList, $staffK [0] );
  5470. }
  5471. // print_r($verifyDetail);
  5472. // die;
  5473. if (! empty ( $nowStaffList )) {
  5474. $nowStaff = implode ( ',', $nowStaffList );
  5475. $verifyStaff = array (
  5476. $this->staff [0] ['sid'] . "_R" => array (
  5477. 'date' => date ( 'Y-m-d' ),
  5478. 'opinion' => $opinion,
  5479. 'status' => $status,
  5480. 'nextStaff' => $verifyDetail [0] [0],
  5481. 'ROLE' => 1
  5482. )
  5483. );
  5484. } else {
  5485. $nowStaff = $verifyDetail [1] [0];
  5486. $verifyStaff = array (
  5487. $this->staff [0] ['sid'] . "_R" => array (
  5488. 'date' => date ( 'Y-m-d' ),
  5489. 'opinion' => $opinion,
  5490. 'status' => $status,
  5491. 'nextStaff' => $verifyDetail [1] [0]
  5492. )
  5493. );
  5494. }
  5495. } else {
  5496. if ($verifyDetail [1] [1] == 'ROLE') {
  5497. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5498. // echo "dd";
  5499. foreach ( $vStaffString as $key => $value ) {
  5500. $staffK = explode ( "_", $value );
  5501. array_push ( $nowStaffList, $staffK [0] );
  5502. }
  5503. $nowStaff = implode ( ',', $nowStaffList );
  5504. $verifyStaff = array (
  5505. $this->staff [0] ['sid'] => array (
  5506. 'date' => date ( 'Y-m-d' ),
  5507. 'opinion' => $opinion,
  5508. 'status' => $status,
  5509. 'nextStaff' => $verifyDetail [1] [0],
  5510. 'ROLE' => 1
  5511. )
  5512. );
  5513. } else {
  5514. $nowStaff = $verifyDetail [1] [0];
  5515. $verifyStaff = array (
  5516. $this->staff [0] ['sid'] => array (
  5517. 'date' => date ( 'Y-m-d' ),
  5518. 'opinion' => $opinion,
  5519. 'status' => $status,
  5520. 'nextStaff' => $verifyDetail [1] [0]
  5521. )
  5522. );
  5523. }
  5524. }
  5525. if ($status == 3)
  5526. $verifyStaff = array (
  5527. 'final' => $status,
  5528. $this->staff [0] ['sid'] => array (
  5529. 'date' => date ( 'Y-m-d' ),
  5530. 'opinion' => $opinion,
  5531. 'status' => $status
  5532. )
  5533. );
  5534. $vStaffString = json_encode ( $verifyStaff );
  5535. $receipt->nowStaff = $nowStaff;
  5536. $receipt->verifyStaff = $vStaffString;
  5537. $loanReceipt->nowStaff = $nowStaff;
  5538. $loanReceipt->verifyStaff = $vStaffString;
  5539. } else {
  5540. $VS = end ( $verifyStaff );
  5541. // 非角色审批
  5542. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5543. $nextStaff = 0;
  5544. $roleSTF = false;
  5545. foreach ( $verifyDetail as $key => $value ) {
  5546. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5547. if (isset ( $verifyDetail [$key + 1] )) {
  5548. $nextStaff = $verifyDetail [$key + 1] [0];
  5549. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5550. $roleSTF = true;
  5551. }
  5552. break;
  5553. }
  5554. }
  5555. if (! $roleSTF) {
  5556. $nowStaff = $nextStaff;
  5557. $verifyStaff [$this->staff [0] ['sid']] = array (
  5558. 'date' => date ( 'Y-m-d' ),
  5559. 'opinion' => $opinion,
  5560. 'status' => $status,
  5561. 'nextStaff' => $nextStaff
  5562. );
  5563. } else {
  5564. // 获取角色下的所有用户ID
  5565. $nowStaffList = array ();
  5566. foreach ( $verifyDetail as $vfk ) {
  5567. if ($vfk [1] == 'ROLE') {
  5568. $vStaffString = json_decode ( $vfk [3] );
  5569. foreach ( $vStaffString as $key => $value ) {
  5570. $staffK = explode ( "_", $value );
  5571. array_push ( $nowStaffList, $staffK [0] );
  5572. }
  5573. }
  5574. }
  5575. $nowStaff = implode ( ',', $nowStaffList );
  5576. $verifyStaff [$this->staff [0] ['sid']] = array (
  5577. 'date' => date ( 'Y-m-d' ),
  5578. 'opinion' => $opinion,
  5579. 'status' => $status,
  5580. 'nextStaff' => $nextStaff,
  5581. 'ROLE' => 0
  5582. );
  5583. }
  5584. if ($status == 3) {
  5585. $verifyStaff ['final'] = $status;
  5586. $verifyStaff [$this->staff [0] ['sid']] = array (
  5587. 'date' => date ( 'Y-m-d' ),
  5588. 'opinion' => $opinion,
  5589. 'status' => $status
  5590. );
  5591. }
  5592. $vStaffString = json_encode ( $verifyStaff );
  5593. $receipt->nowStaff = $nowStaff;
  5594. $receipt->verifyStaff = $vStaffString;
  5595. $loanReceipt->nowStaff = $nowStaff;
  5596. $loanReceipt->verifyStaff = $vStaffString;
  5597. }
  5598. // 角色审批
  5599. if (isset ( $VS ['ROLE'] )) {
  5600. // 找出角色人 当前审批角色组
  5601. $verifyJSStaff = array ();
  5602. $nowStaffList2 = array ();
  5603. foreach ( $verifyDetail as $key => $value ) {
  5604. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5605. $verifyJSStaff = json_decode ( $value [3] );
  5606. foreach ( $verifyJSStaff as $m ) {
  5607. $staffK = explode ( "_", $m );
  5608. array_push ( $nowStaffList2, $staffK [0] );
  5609. }
  5610. // print_r($nowStaffList2);
  5611. }
  5612. }
  5613. $RoleVerifyStaff = array ();
  5614. foreach ( $verifyStaff as $key => $value ) {
  5615. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5616. foreach ( $nowStaffList2 as $m ) {
  5617. if ($key == $m . "_R")
  5618. $RoleVerifyStaff [$key] = $value;
  5619. }
  5620. }
  5621. }
  5622. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5623. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5624. // 下一个审批人ID
  5625. $nextStaff = 0;
  5626. $falg = false;
  5627. foreach ( $verifyDetail as $key => $value ) {
  5628. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5629. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5630. $falg = true;
  5631. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5632. $nowStaffList = array ();
  5633. foreach ( $vStaffString as $v ) {
  5634. $staffK = explode ( "_", $v );
  5635. array_push ( $nowStaffList, $staffK [0] );
  5636. }
  5637. $nowStaff = implode ( ',', $nowStaffList );
  5638. $nextStaff = $verifyDetail [$key + 1] [0];
  5639. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5640. $nextStaff = $verifyDetail [$key + 1] [0];
  5641. $nowStaff = $nextStaff;
  5642. } else
  5643. $nowStaff = '';
  5644. break;
  5645. }
  5646. }
  5647. if ($falg)
  5648. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5649. 'date' => date ( 'Y-m-d' ),
  5650. 'opinion' => $opinion,
  5651. 'status' => $status,
  5652. 'nextStaff' => $nextStaff,
  5653. 'ROLE' => 1
  5654. );
  5655. else
  5656. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5657. 'date' => date ( 'Y-m-d' ),
  5658. 'opinion' => $opinion,
  5659. 'status' => $status,
  5660. 'nextStaff' => $nextStaff
  5661. );
  5662. // print_r($verifyStaff);
  5663. // echo $nowStaff;die;
  5664. } else { // 进入下一个角色或者审批人
  5665. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5666. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5667. 'date' => date ( 'Y-m-d' ),
  5668. 'opinion' => $opinion,
  5669. 'status' => $status,
  5670. 'nextStaff' => $VS ['nextStaff'],
  5671. 'ROLE' => 1
  5672. );
  5673. }
  5674. if ($status == 3) {
  5675. $verifyStaff ['final'] = $status;
  5676. $verifyStaff [$this->staff [0] ['sid']] = array (
  5677. 'date' => date ( 'Y-m-d' ),
  5678. 'opinion' => $opinion,
  5679. 'status' => $status
  5680. );
  5681. }
  5682. $vStaffString = json_encode ( $verifyStaff );
  5683. $receipt->verifyStaff = $vStaffString;
  5684. $receipt->nowStaff = $nowStaff;
  5685. $loanReceipt->nowStaff = $nowStaff;
  5686. $loanReceipt->verifyStaff = $vStaffString;
  5687. }
  5688. // print_r($verifyStaff);die;
  5689. }
  5690. $roleKey = 0;
  5691. $roleId = 0;
  5692. $verifyDetailCopy = array ();
  5693. foreach ( $verifyDetail as $k => $v ) {
  5694. if ($v [1] == 'ROLE') {
  5695. $roleId = $v [0];
  5696. $roleVerify = json_decode ( $v [3], true );
  5697. $roleKey = $k;
  5698. $roleArray = array ();
  5699. foreach ( $roleVerify as $o => $p ) {
  5700. $staffID = explode ( '_', $p );
  5701. $exp = array (
  5702. 0 => $staffID [0],
  5703. 1 => $staffID [1]
  5704. );
  5705. array_push ( $roleArray, $exp );
  5706. }
  5707. $verifyDetailCopy [$v [0]] = $roleArray;
  5708. }
  5709. }
  5710. // print_r($verifyDetail);
  5711. foreach ( $verifyDetailCopy as $k => $v ) {
  5712. foreach ( $verifyDetail as $m => $n ) {
  5713. if ($n [0] == $k) {
  5714. array_splice ( $verifyDetail, $m, 1, $v );
  5715. }
  5716. }
  5717. }
  5718. // 审批日志
  5719. if (! isset ( $verifyStaff ['final'] )) {
  5720. Doo::loadModel ( "receiptLog" );
  5721. $receiptLog = new receiptLog ();
  5722. if (! empty ( $roleId )) {
  5723. Doo::loadModel ( "role" );
  5724. $role = new role ();
  5725. $roleInfo = $role->getOne ( array (
  5726. 'where' => 'rid=' . $roleId,
  5727. 'asArray' => true
  5728. ) );
  5729. $receiptLog->rolename = $roleInfo ['name'];
  5730. }
  5731. $receiptLog->username = $this->staff [0] ['username'];
  5732. $receiptLog->uid = $this->staff [0] ['sid'];
  5733. $receiptLog->date = date ( "Y-m-d" );
  5734. $receiptLog->opinion = $opinion;
  5735. $receiptLog->img = $this->staff [0] ['avatar'];
  5736. $receiptLog->status = 1;
  5737. $receiptLog->rid = $rid;
  5738. $receiptLog->insert ();
  5739. }
  5740. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5741. $receipt->status = 3;
  5742. $receipt->verifyBreakup = $verifyString;
  5743. $receiptDetailObj->status = 3;
  5744. $receiptDetailObj->update ( array (
  5745. 'where' => 'rid=' . $rid
  5746. ) );
  5747. // 微信企业号通知
  5748. $this->setWXMsg ( $rid, 3 );
  5749. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5750. $receipt->status = 6;
  5751. $receipt->pastDate = date ( "Y-m-d" );
  5752. $receipt->isBK = 1;
  5753. $loanReceipt->verifyBreakup = $verifyString;
  5754. $loanReceipt->status = 1;
  5755. $loanReceipt->pastDate = date ( "Y-m-d" );
  5756. //生成流水后 不更新汇款金额
  5757. Doo::loadModel ( 'wasteBook' );
  5758. $wasteBook = new wasteBook ();
  5759. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5760. if (empty($wbDetail)){
  5761. $loanReceipt->amount = $receiptDetail ['amount'];
  5762. }
  5763. $loanReceipt->update ( array (
  5764. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5765. ) );
  5766. // 微信企业号通知
  5767. $this->setWXMsg ( $rid, 1 );
  5768. }
  5769. $receipt->amount = $receiptDetail['sum'];
  5770. $receipt->update ( array (
  5771. 'where' => ' rid = ' . $rid
  5772. ) );
  5773. // 进入下一条审批费用新加需求
  5774. $vidList = array ();
  5775. $verifyDetail = $verify->find ( array (
  5776. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5777. 'asArray' => true
  5778. ) );
  5779. foreach ( $verifyDetail as $key => $value ) {
  5780. array_push ( $vidList, $value ['vid'] );
  5781. }
  5782. $vid = implode ( ",", $vidList );
  5783. if (empty ( $verifyDetail ))
  5784. $vid = 0;
  5785. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5786. $receipt = new receipt ();
  5787. $rd = $receipt->getOne ( array (
  5788. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5789. 'asc' => 'rid',
  5790. 'asArray' => true
  5791. ) );
  5792. if (empty ( $rd )) {
  5793. return '/approvalExpenses/pendApproval';
  5794. }
  5795. if ($rd ['Rtype'] == 1) {
  5796. if ($rd ['isBK'] == 1) {
  5797. return '/receiptburEdi/' . $rd ['rid'];
  5798. } else {
  5799. return '/expensesEdi/' . $rd ['rid'];
  5800. }
  5801. } elseif ($rd ['Rtype'] == 2) {
  5802. return '/remitApproval/' . $rd ['rid'];
  5803. } else {
  5804. return '/receiptburEdi/' . $rd ['rid'];
  5805. }
  5806. // return "/approvalExpenses/pendApproval";
  5807. }
  5808. }
  5809. function ajaxExamineExe() {
  5810. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5811. Doo::loadModel ( 'receipt' );
  5812. $receipt = new receipt ();
  5813. Doo::loadClass ( 'XDeode' );
  5814. $XDeode = new XDeode ( 5 );
  5815. if (! empty ( $rid )) {
  5816. $rLRes = $receipt->find ( array (
  5817. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5818. 'asArray' => true
  5819. ) );
  5820. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5821. echo json_encode ( array (
  5822. 'status' => 1,
  5823. 'receipt' => $rLRes [0]
  5824. ) );
  5825. die ();
  5826. }
  5827. echo json_encode ( array (
  5828. 'status' => 0,
  5829. 'receipt' => array ()
  5830. ) );
  5831. die ();
  5832. }
  5833. function implement() {
  5834. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5835. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5836. Doo::loadClass ( 'XDeode' );
  5837. $XDeode = new XDeode ( 5 );
  5838. Doo::loadModel ( 'receipt' );
  5839. $receipt = new receipt ();
  5840. Doo::loadModel ( 'L_category' );
  5841. $Lcategory = new L_category ();
  5842. Doo::loadModel ( 'verify' );
  5843. $verify = new verify ();
  5844. Doo::loadModel ( 'staff' );
  5845. $staff = new staff ();
  5846. Doo::loadModel ( "execute" );
  5847. $execute = new execute ();
  5848. $rid = $XDeode->decode ( $rid );
  5849. $receiptList = $receipt->find ( array (
  5850. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5851. 'desc' => 'rid',
  5852. 'asArray' => true
  5853. ) );
  5854. Doo::loadModel ( 'loanReceipt' );
  5855. $loanReceipt = new loanReceipt ();
  5856. // print_r($receiptList);
  5857. $loanList = array ();
  5858. if (! isset ( $receiptList ))
  5859. $loanList = $loanReceipt->find ( array (
  5860. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5861. 'desc' => 'rid',
  5862. 'asArray' => true
  5863. ) );
  5864. $Locate = 0;
  5865. $roleId = 0;
  5866. $button = 0;
  5867. foreach ( $loanList as $key => $value ) {
  5868. $loanList [$key] ['Locate'] = $Locate;
  5869. $Locate ++;
  5870. $loanList [$key] ['reviseDetail'] = array ();
  5871. if (! empty ( $value ['reviseDetail'] ))
  5872. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5873. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5874. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5875. $categoryDetil = $Lcategory->getOne ( array (
  5876. 'where' => 'cid=' . $value ['cid'],
  5877. 'asArray' => true
  5878. ) );
  5879. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5880. // 检测编辑状态
  5881. $verifyList = $verify->getOne ( array (
  5882. 'where' => 'vid=' . $value ['verify'],
  5883. 'asArray' => true
  5884. ) );
  5885. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5886. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5887. Doo::loadModel ( 'role' );
  5888. $role = new role ();
  5889. $flag = true;
  5890. $roleKey = 0;
  5891. $endStaffArray = array ();
  5892. $roleArrayCopy = array ();
  5893. foreach ( $verifyList as $k => $v ) {
  5894. // init verifyStaff
  5895. if ($v [1] == 'ROLE') {
  5896. if (! empty ( $verifyStaff )) {
  5897. $endStaffArray = end ( $verifyStaff );
  5898. // if ($v[0]==$endStaffArray['nextStaff']){
  5899. // $roleId=$v[0];
  5900. // }
  5901. }
  5902. $roleVerify = json_decode ( $v [3], true );
  5903. $roleKey = $k;
  5904. $roleArray = array ();
  5905. $rolename = $role->getOne ( array (
  5906. 'where' => 'rid=' . $v [0],
  5907. 'asArray' => true
  5908. ) );
  5909. foreach ( $roleVerify as $o => $p ) {
  5910. $staffID = explode ( '_', $p );
  5911. $staffInfo = $staff->getOne ( array (
  5912. 'where' => 'sid=' . $staffID [0],
  5913. 'asArray' => true
  5914. ) );
  5915. // print_r($staffID);
  5916. $exp = array (
  5917. 0 => $staffInfo ['sid'],
  5918. 1 => $staffID [1],
  5919. 2 => $staffInfo ['avatar'],
  5920. 'date' => '',
  5921. 'date' => '',
  5922. 'opinion' => '',
  5923. 'status' => '',
  5924. 'rolename' => $rolename ['name']
  5925. );
  5926. array_push ( $roleArray, $exp );
  5927. }
  5928. $roleArrayCopy [$v [0]] = $roleArray;
  5929. // $verifyList[$k]['roleArray']=$roleArray;
  5930. }
  5931. $verifyList [$k] ['date'] = "";
  5932. $verifyList [$k] ['opinion'] = "";
  5933. $verifyList [$k] ['status'] = "";
  5934. if (empty ( $verifyStaff )) {
  5935. $verifyList [$k] ['date'] = "";
  5936. $verifyList [$k] ['opinion'] = "";
  5937. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5938. $verifyList [$k] ['status'] = 4;
  5939. $flag = false;
  5940. }
  5941. } else {
  5942. foreach ( $verifyStaff as $m => $u ) {
  5943. if ($v [0] == $m) {
  5944. $verifyList [$k] ['date'] = $u ['date'];
  5945. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5946. $verifyList [$k] ['status'] = $u ['status'];
  5947. $flag = false;
  5948. break;
  5949. }
  5950. }
  5951. $endStaffArray = end ( $verifyStaff );
  5952. if (isset ( $endStaffArray ['ROLE'] )) {
  5953. } else {
  5954. // $endKey=key($verifyStaff);
  5955. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5956. // $button=4;
  5957. // $verifyList[$k]['status']=4;
  5958. // }
  5959. }
  5960. }
  5961. }
  5962. $rolename ['name'] = '';
  5963. if (! empty ( $roleId )) {
  5964. Doo::loadModel ( 'role' );
  5965. $role = new role ();
  5966. $rolename = $role->getOne ( array (
  5967. 'where' => 'rid=' . $roleId,
  5968. 'asArray' => true
  5969. ) );
  5970. }
  5971. if (! empty ( $verifyStaff ))
  5972. $endStaffArray = end ( $verifyStaff );
  5973. $KOP = false;
  5974. foreach ( $roleArrayCopy as $P => $A ) {
  5975. foreach ( $A as $MKI => $AVL ) {
  5976. if (! empty ( $verifyStaff )) {
  5977. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5978. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5979. $button = 4;
  5980. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5981. }
  5982. foreach ( $verifyStaff as $m => $u ) {
  5983. $AVLFK = $AVL [0] . '_R';
  5984. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5985. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5986. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5987. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5988. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5989. break;
  5990. }
  5991. }
  5992. } else {
  5993. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5994. $button = 4;
  5995. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5996. }
  5997. }
  5998. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5999. $KOP = true;
  6000. }
  6001. }
  6002. foreach ( $roleArrayCopy as $k => $v ) {
  6003. foreach ( $verifyList as $m => $n ) {
  6004. if ($n [0] == $k) {
  6005. array_splice ( $verifyList, $m, 1, $v );
  6006. }
  6007. }
  6008. }
  6009. $loanList [$key] ['verifyList'] = $verifyList;
  6010. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6011. 'where' => 'sid=' . $value ['staff'],
  6012. 'asArray' => true
  6013. ) );
  6014. }
  6015. $data ['loanList'] = $loanList;
  6016. $Locate = 0;
  6017. $roleId = 0;
  6018. $button = 0;
  6019. Doo::loadClass ( 'XDeode' );
  6020. $XDeode = new XDeode ( 5 );
  6021. foreach ( $receiptList as $key => $value ) {
  6022. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6023. $button2 = 0;
  6024. $receiptList [$key] ['Locate'] = $Locate;
  6025. $Locate ++;
  6026. $receiptList [$key] ['reviseDetail'] = array ();
  6027. if (! empty ( $value ['reviseDetail'] ))
  6028. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6029. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6030. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6031. $categoryDetil = $Lcategory->getOne ( array (
  6032. 'where' => 'cid=' . $value ['cid'],
  6033. 'asArray' => true
  6034. ) );
  6035. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6036. $executeList = json_decode ( $value ['executeCopy'], true );
  6037. $executeStaff = array ();
  6038. if (! empty ( $value ['executeStaff'] ))
  6039. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6040. if (isset ( $executeList )) {
  6041. foreach ( $executeList as $op => $lo ) {
  6042. $executeList [$op] ['date'] = "";
  6043. $executeList [$op] ['opinion'] = "";
  6044. $executeList [$op] ['status'] = "";
  6045. foreach ( $executeStaff as $m => $u ) {
  6046. if ($lo [0] == $m) {
  6047. $executeList [$op] ['date'] = $u ['date'];
  6048. $executeList [$op] ['opinion'] = $u ['opinion'];
  6049. $executeList [$op] ['status'] = $u ['status'];
  6050. break;
  6051. }
  6052. }
  6053. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6054. $button2 = 1;
  6055. $executeList [$op] ['status'] = 4;
  6056. }
  6057. }
  6058. }
  6059. // 检测编辑状态
  6060. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6061. $verifyList ['staff'] = $value ['verifyBreakup'];
  6062. } else
  6063. $verifyList = $verify->getOne ( array (
  6064. 'where' => 'vid=' . $value ['verify'],
  6065. 'asArray' => true
  6066. ) );
  6067. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6068. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6069. Doo::loadModel ( 'role' );
  6070. $role = new role ();
  6071. if ($verifyList == NULL)
  6072. $verifyList = array ();
  6073. $flag = true;
  6074. $roleKey = 0;
  6075. $endStaffArray = array ();
  6076. $roleArrayCopy = array ();
  6077. foreach ( $verifyList as $k => $v ) {
  6078. // init verifyStaff
  6079. if ($v [1] == 'ROLE') {
  6080. if (! empty ( $verifyStaff )) {
  6081. $endStaffArray = end ( $verifyStaff );
  6082. // if ($v[0]==$endStaffArray['nextStaff']){
  6083. // $roleId=$v[0];
  6084. // }
  6085. }
  6086. $roleVerify = json_decode ( $v [3], true );
  6087. $roleKey = $k;
  6088. $roleArray = array ();
  6089. $rolename = $role->getOne ( array (
  6090. 'where' => 'rid=' . $v [0],
  6091. 'asArray' => true
  6092. ) );
  6093. foreach ( $roleVerify as $o => $p ) {
  6094. $staffID = explode ( '_', $p );
  6095. $staffInfo = $staff->getOne ( array (
  6096. 'where' => 'sid=' . $staffID [0],
  6097. 'asArray' => true
  6098. ) );
  6099. // print_r($staffID);
  6100. $exp = array (
  6101. 0 => $staffInfo ['sid'],
  6102. 1 => $staffID [1],
  6103. 2 => $staffInfo ['avatar'],
  6104. 'date' => '',
  6105. 'date' => '',
  6106. 'opinion' => '',
  6107. 'status' => '',
  6108. 'rolename' => $rolename ['name']
  6109. );
  6110. array_push ( $roleArray, $exp );
  6111. }
  6112. $roleArrayCopy [$v [0]] = $roleArray;
  6113. // $verifyList[$k]['roleArray']=$roleArray;
  6114. }
  6115. $verifyList [$k] ['date'] = "";
  6116. $verifyList [$k] ['opinion'] = "";
  6117. $verifyList [$k] ['status'] = "";
  6118. if (empty ( $verifyStaff )) {
  6119. $verifyList [$k] ['date'] = "";
  6120. $verifyList [$k] ['opinion'] = "";
  6121. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6122. $verifyList [$k] ['status'] = 4;
  6123. $flag = false;
  6124. }
  6125. } else {
  6126. foreach ( $verifyStaff as $m => $u ) {
  6127. if ($v [0] == $m) {
  6128. $verifyList [$k] ['date'] = $u ['date'];
  6129. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6130. $verifyList [$k] ['status'] = $u ['status'];
  6131. $flag = false;
  6132. break;
  6133. }
  6134. }
  6135. $endStaffArray = end ( $verifyStaff );
  6136. if (isset ( $endStaffArray ['ROLE'] )) {
  6137. } else {
  6138. // $endKey=key($verifyStaff);
  6139. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6140. // $button=4;
  6141. // $verifyList[$k]['status']=4;
  6142. // }
  6143. }
  6144. }
  6145. }
  6146. $rolename ['name'] = '';
  6147. if (! empty ( $roleId )) {
  6148. Doo::loadModel ( 'role' );
  6149. $role = new role ();
  6150. $rolename = $role->getOne ( array (
  6151. 'where' => 'rid=' . $roleId,
  6152. 'asArray' => true
  6153. ) );
  6154. }
  6155. if (! empty ( $verifyStaff ))
  6156. $endStaffArray = end ( $verifyStaff );
  6157. $KOP = false;
  6158. foreach ( $roleArrayCopy as $P => $A ) {
  6159. foreach ( $A as $MKI => $AVL ) {
  6160. if (! empty ( $verifyStaff )) {
  6161. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6162. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6163. $button = 4;
  6164. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6165. }
  6166. foreach ( $verifyStaff as $m => $u ) {
  6167. $AVLFK = $AVL [0] . '_R';
  6168. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6169. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6170. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6171. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6172. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6173. break;
  6174. }
  6175. }
  6176. } else {
  6177. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6178. $button = 4;
  6179. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6180. }
  6181. }
  6182. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6183. $KOP = true;
  6184. }
  6185. }
  6186. foreach ( $roleArrayCopy as $k => $v ) {
  6187. foreach ( $verifyList as $m => $n ) {
  6188. if ($n [0] == $k) {
  6189. array_splice ( $verifyList, $m, 1, $v );
  6190. }
  6191. }
  6192. }
  6193. $receiptList [$key] ['verifyList'] = $verifyList;
  6194. $receiptList [$key] ['executeList'] = $executeList;
  6195. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6196. 'where' => 'sid=' . $value ['staff'],
  6197. 'asArray' => true
  6198. ) );
  6199. $receiptList [$key] ['button2'] = $button2;
  6200. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6201. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6202. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6203. $receiptList [$key] ['relust'] = $relust;
  6204. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6205. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6206. }
  6207. //执行人是否是最后一位
  6208. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6209. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6210. $executePrimary=count($executeCopy)-1;
  6211. $lastOne=true;
  6212. if($executePrimary!=count($executeStaff)){
  6213. $lastOne=false;
  6214. }
  6215. $data['lastOne']=$lastOne;
  6216. // 是否写入过流水
  6217. $accountType = 0;
  6218. if ($receiptList [0] ['Rtype'] == 0) {
  6219. $accountType = 3;
  6220. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6221. if($receiptList [0]['version']==1){
  6222. $accountType = 2;
  6223. }else{
  6224. if (!empty($receiptList [0]['accountItem']) ){
  6225. // if (!empty($receiptList [0]['loanRid']) ){
  6226. $accountType = 2;
  6227. }else{
  6228. $accountType = 1;
  6229. }
  6230. }
  6231. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6232. $accountType = 4;
  6233. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6234. $accountType = 12;
  6235. }
  6236. Doo::loadModel ( 'wasteBook' );
  6237. $wasteBook = new wasteBook ();
  6238. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6239. $data ['wbDetail'] = $wbDetail;
  6240. $wbDetailLoan=array();
  6241. if ($accountType==2){
  6242. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6243. }
  6244. $data ['wbDetailLoan'] = $wbDetailLoan;
  6245. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6246. //print_r($wbDetail);
  6247. if($receiptList[0]['version']==1){
  6248. require "protected/class/comm_cld.php";
  6249. $receiptList=makeReceiptDataVersion1($receiptList);
  6250. }
  6251. $data ['receiptList'] = $receiptList;
  6252. $data ['memu'] = "receipt";
  6253. $data ['staff'] = $this->staff;
  6254. $data ['receiptMemu'] = 'implement';
  6255. $data ['verifyId'] = $this->verifyId;
  6256. $data ['executeId'] = $this->executeId;
  6257. if($receiptList[0]['version']==1){
  6258. if ($Rtype=="loan"){
  6259. $this->render ( "/fee/implement/loan_compatible", $data );
  6260. }else{
  6261. $this->render ( "/fee/implement/receipt_compatible", $data );
  6262. }
  6263. die;
  6264. }
  6265. if ($Rtype=="loan"){
  6266. $this->render ( "/receipt/receiptImplementLoan", $data );
  6267. }elseif($Rtype=="receipt"){
  6268. if($receiptList[0]['receiptClass']==2){
  6269. //TODO 费用执行行程单2.0
  6270. if(!empty($receiptList[0]['itinerary2'])){
  6271. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6272. }else{
  6273. $this->render ( "/receipt/receiptImplementTrave", $data );
  6274. }
  6275. }else{
  6276. $this->render ( "/receipt/receiptImplement", $data );
  6277. }
  6278. }elseif($Rtype=="public"){
  6279. $this->render ( "/receipt/receiptImplementPublic", $data );
  6280. }else{
  6281. //$this->render ( "/admin/implement", $data );
  6282. }
  6283. }
  6284. function implementDo() {
  6285. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6286. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6287. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6288. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6289. // $ab = '';
  6290. // if ($accountBank == 'CGBDeposit')
  6291. // $ab = '纵横广发';
  6292. // elseif ($accountBank == 'ICBCDeposit')
  6293. // $ab = '纵横工行';
  6294. // elseif ($accountBank == 'HUADeposit')
  6295. // $ab = '华润银行';
  6296. // elseif ($accountBank == 'PersonalDeposit')
  6297. // $ab = '个人广发';
  6298. // if (empty ( $ab ))
  6299. // die ( 'illegal request--22' );
  6300. if (! empty ( $rid )) {
  6301. Doo::loadModel ( 'receipt' );
  6302. $receipt = new receipt ();
  6303. Doo::loadClass ( 'XDeode' );
  6304. $XDeode = new XDeode ( 5 );
  6305. $rid=$XDeode->decode($rid);
  6306. if (!is_numeric($rid)){
  6307. die;
  6308. }
  6309. // $rinfo = $receipt->getOne ( array (
  6310. // 'where' => 'rid=' . $rid,
  6311. // 'asArray' => true
  6312. // ) );
  6313. $rinfo = $receipt->getReceiptByRid ( $rid );
  6314. // $accountType = '';
  6315. // if ($rinfo ['Rtype'] == 1) {
  6316. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6317. // $accountType = 2;
  6318. // else
  6319. // $accountType = 1;
  6320. // } elseif ($rinfo ['Rtype'] == 2) {
  6321. // $accountType = 4;
  6322. // } elseif ($rinfo ['Rtype'] == 0)
  6323. // $accountType = 3;
  6324. // if (empty ( $accountType ))
  6325. // die ( 'illegal request' );
  6326. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6327. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6328. if (empty ( $executeStaff )) {
  6329. $executeStaff = array (
  6330. $this->staff [0] ['sid'] => array (
  6331. 'date' => date ( 'Y-m-d' ),
  6332. 'opinion' => $implementOpinions,
  6333. 'status' => 1
  6334. )
  6335. );
  6336. } else {
  6337. $executeStaff [$this->staff [0] ['sid']] = array (
  6338. 'date' => date ( 'Y-m-d' ),
  6339. 'opinion' => $implementOpinions,
  6340. 'status' => 1
  6341. );
  6342. }
  6343. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6344. $receipt->executeStaff = json_encode ( $executeStaff );
  6345. $receipt->status = 8;
  6346. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6347. $receipt->status = 9;
  6348. if ($rinfo ['status'] == 6) {
  6349. $receipt->loanDate = date ( "Y-m-d" );
  6350. }
  6351. $receipt->executeDate = date ( "Y-m-d" );
  6352. } else {
  6353. $receipt->executeStaff = json_encode ( $executeStaff );
  6354. }
  6355. //$receipt->amount = $amount;
  6356. $receipt->update ( array (
  6357. 'where' => 'rid=' . $rid
  6358. ) );
  6359. // 公司流水记录
  6360. // Doo::loadModel ( 'wasteBook' );
  6361. // $wasteBook = new wasteBook ();
  6362. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6363. // // 银行
  6364. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6365. // $item = array (
  6366. // 'dataID' => $rid,
  6367. // 'expensesType' => 2,
  6368. // 'accountType' => $accountType,
  6369. // 'accountPriceShow' => $amount,
  6370. // 'accountPrice' => - $amount,
  6371. // 'accountBank' => $accountBank,
  6372. // 'category' => $rinfo ['category'] [0] ['title'],
  6373. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6374. // 'name' => $rinfo ['staffDetail'] ['username'],
  6375. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6376. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6377. // );
  6378. // $wasteBook->setAccountBookStatistics ( $item );
  6379. // }
  6380. }
  6381. //$ridKey = $XDeode->encode ( $rid );
  6382. return "/hisImplement";
  6383. // return "/implement/" . $ridKey . ".html";
  6384. }
  6385. function receiptburEdi() {
  6386. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  6387. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6388. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6389. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6390. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6391. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6392. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6393. if (empty ( $status ))
  6394. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6395. $vidList = array ();
  6396. $button = 0;
  6397. Doo::loadModel ( 'verify' );
  6398. Doo::loadModel ( 'receipt' );
  6399. Doo::loadModel ( 'staff' );
  6400. $staff = new staff ();
  6401. $receipt = new receipt ();
  6402. $verify = new verify ();
  6403. Doo::loadModel ( 'L_category' );
  6404. $Lcategory = new L_category ();
  6405. Doo::loadModel ( 'enclosur' );
  6406. $enclosur = new enclosur ();
  6407. Doo::loadModel ( 'loanReceipt' );
  6408. $loanReceipt = new loanReceipt ();
  6409. // user verify ID
  6410. $verifyDetail = $verify->find ( array (
  6411. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6412. 'asArray' => true
  6413. ) );
  6414. foreach ( $verifyDetail as $key => $value ) {
  6415. array_push ( $vidList, $value ['vid'] );
  6416. }
  6417. $vid = implode ( ",", $vidList );
  6418. if (empty ( $verifyDetail ))
  6419. $vid = 0;
  6420. $categoryList = $Lcategory->find ( array (
  6421. 'asArray' => true
  6422. ) );
  6423. $staffList = $staff->find ( array (
  6424. 'where' => 'cid=' . $cid,
  6425. 'asArray' => true
  6426. ) );
  6427. $ap = "";
  6428. if ($status == 4) {
  6429. $ap = 4;
  6430. $status = 2;
  6431. }
  6432. // get Receipt By verifyID status 2
  6433. $receiptList = $receipt->find ( array (
  6434. 'where' => 'rid =' . $rid . ' and status=2',
  6435. 'desc' => 'rid',
  6436. 'asArray' => true
  6437. ) );
  6438. if (empty ( $receiptList )) {
  6439. die ( 'illegal request' );
  6440. }
  6441. $loanList = $loanReceipt->find ( array (
  6442. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6443. 'desc' => 'rid',
  6444. 'asArray' => true
  6445. ) );
  6446. $data ['explanation'] = '';
  6447. if (! empty ( $loanList ))
  6448. $data ['explanation'] = $loanList [0] ['explanation'];
  6449. $Locate = 0;
  6450. $roleId = 0;
  6451. $button = 0;
  6452. foreach ( $loanList as $key => $value ) {
  6453. $loanList [$key] ['Locate'] = $Locate;
  6454. $Locate ++;
  6455. $loanList [$key] ['reviseDetail'] = array ();
  6456. if (! empty ( $value ['reviseDetail'] ))
  6457. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6458. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6459. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6460. $categoryDetil = $Lcategory->getOne ( array (
  6461. 'where' => 'cid=' . $value ['cid'],
  6462. 'asArray' => true
  6463. ) );
  6464. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6465. // 检测编辑状态
  6466. $verifyList = $verify->getOne ( array (
  6467. 'where' => 'vid=' . $value ['verify'],
  6468. 'asArray' => true
  6469. ) );
  6470. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6471. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6472. Doo::loadModel ( 'role' );
  6473. $role = new role ();
  6474. $flag = true;
  6475. $roleKey = 0;
  6476. $endStaffArray = array ();
  6477. $roleArrayCopy = array ();
  6478. foreach ( $verifyList as $k => $v ) {
  6479. // init verifyStaff
  6480. if ($v [1] == 'ROLE') {
  6481. if (! empty ( $verifyStaff )) {
  6482. $endStaffArray = end ( $verifyStaff );
  6483. }
  6484. $roleVerify = json_decode ( $v [3], true );
  6485. $roleKey = $k;
  6486. $roleArray = array ();
  6487. $rolename = $role->getOne ( array (
  6488. 'where' => 'rid=' . $v [0],
  6489. 'asArray' => true
  6490. ) );
  6491. foreach ( $roleVerify as $o => $p ) {
  6492. $staffID = explode ( '_', $p );
  6493. $staffInfo = $staff->getOne ( array (
  6494. 'where' => 'sid=' . $staffID [0],
  6495. 'asArray' => true
  6496. ) );
  6497. // print_r($staffID);
  6498. $exp = array (
  6499. 0 => $staffInfo ['sid'],
  6500. 1 => $staffID [1],
  6501. 2 => $staffInfo ['avatar'],
  6502. 'date' => '',
  6503. 'date' => '',
  6504. 'opinion' => '',
  6505. 'status' => '',
  6506. 'rolename' => $rolename ['name']
  6507. );
  6508. array_push ( $roleArray, $exp );
  6509. }
  6510. $roleArrayCopy [$v [0]] = $roleArray;
  6511. // $verifyList[$k]['roleArray']=$roleArray;
  6512. }
  6513. $verifyList [$k] ['date'] = "";
  6514. $verifyList [$k] ['opinion'] = "";
  6515. $verifyList [$k] ['status'] = "";
  6516. if (empty ( $verifyStaff )) {
  6517. $verifyList [$k] ['date'] = "";
  6518. $verifyList [$k] ['opinion'] = "";
  6519. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6520. $verifyList [$k] ['status'] = 4;
  6521. $flag = false;
  6522. }
  6523. } else {
  6524. foreach ( $verifyStaff as $m => $u ) {
  6525. if ($v [0] == $m) {
  6526. $verifyList [$k] ['date'] = $u ['date'];
  6527. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6528. $verifyList [$k] ['status'] = $u ['status'];
  6529. $flag = false;
  6530. break;
  6531. }
  6532. }
  6533. $endStaffArray = end ( $verifyStaff );
  6534. if (isset ( $endStaffArray ['ROLE'] )) {
  6535. } else {
  6536. }
  6537. }
  6538. }
  6539. $rolename ['name'] = '';
  6540. if (! empty ( $roleId )) {
  6541. Doo::loadModel ( 'role' );
  6542. $role = new role ();
  6543. $rolename = $role->getOne ( array (
  6544. 'where' => 'rid=' . $roleId,
  6545. 'asArray' => true
  6546. ) );
  6547. }
  6548. if (! empty ( $verifyStaff ))
  6549. $endStaffArray = end ( $verifyStaff );
  6550. $KOP = false;
  6551. foreach ( $roleArrayCopy as $P => $A ) {
  6552. foreach ( $A as $MKI => $AVL ) {
  6553. if (! empty ( $verifyStaff )) {
  6554. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6555. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6556. $button = 4;
  6557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6558. }
  6559. foreach ( $verifyStaff as $m => $u ) {
  6560. $AVLFK = $AVL [0] . '_R';
  6561. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6562. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6563. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6564. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6565. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6566. break;
  6567. }
  6568. }
  6569. } else {
  6570. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6571. $button = 4;
  6572. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6573. }
  6574. }
  6575. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6576. $KOP = true;
  6577. }
  6578. }
  6579. foreach ( $roleArrayCopy as $k => $v ) {
  6580. foreach ( $verifyList as $m => $n ) {
  6581. if ($n [0] == $k) {
  6582. array_splice ( $verifyList, $m, 1, $v );
  6583. }
  6584. }
  6585. }
  6586. $loanList [$key] ['verifyList'] = $verifyList;
  6587. }
  6588. $htmlLoan = '';
  6589. $data ['loanReceiptDate'] = '';
  6590. if (isset ( $loanList [0] )) {
  6591. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6592. if ($value ['status'] == 1)
  6593. $htmlLoan .= '<li class="done" >';
  6594. elseif ($value ['status'] == 3)
  6595. $htmlLoan .= '<li class="undone" >';
  6596. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6597. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6598. if (isset ( $value ['rolename'] ))
  6599. $htmlLoan .= $value ['rolename'];
  6600. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6601. }
  6602. $data ['loanDate'] = $loanList [0] ['date'];
  6603. } else {
  6604. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6605. }
  6606. $data ['htmlLoan'] = $htmlLoan;
  6607. // $data ['LoanReceipt']=$loanList[0];
  6608. // print_r($loanList);
  6609. $Locate = 0;
  6610. $roleId = 0;
  6611. $button = 0;
  6612. if ($ap == 4)
  6613. $status = 4;
  6614. Doo::loadClass ( 'XDeode' );
  6615. $XDeode = new XDeode ( 5 );
  6616. foreach ( $receiptList as $key => $value ) {
  6617. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6618. $receiptList [$key] ['Locate'] = $Locate;
  6619. $Locate ++;
  6620. $receiptList [$key] ['reviseDetail'] = array ();
  6621. // 调整金额 代码调整
  6622. if (! empty ( $value ['reviseDetail'] )) {
  6623. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6624. foreach ( $reviseDetail as $ry => $re ) {
  6625. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6626. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6627. }
  6628. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6629. // print_r($reviseDetail);
  6630. }
  6631. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6632. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6633. $categoryDetil = $Lcategory->getOne ( array (
  6634. 'where' => 'cid=' . $value ['cid'],
  6635. 'asArray' => true
  6636. ) );
  6637. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6638. // 检测编辑状态
  6639. $verifyList = $verify->getOne ( array (
  6640. 'where' => 'vid=' . $value ['verify'],
  6641. 'asArray' => true
  6642. ) );
  6643. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6644. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6645. Doo::loadModel ( 'role' );
  6646. $role = new role ();
  6647. // print_r($verifyList);
  6648. $flag = true;
  6649. $roleKey = 0;
  6650. $endStaffArray = array ();
  6651. $roleArrayCopy = array ();
  6652. foreach ( $verifyList as $k => $v ) {
  6653. // init verifyStaff
  6654. if ($v [1] == 'ROLE') {
  6655. if (! empty ( $verifyStaff )) {
  6656. $endStaffArray = end ( $verifyStaff );
  6657. if ($v [0] == $endStaffArray ['nextStaff']) {
  6658. $roleId = $v [0];
  6659. }
  6660. }
  6661. $roleVerify = json_decode ( $v [3], true );
  6662. $roleKey = $k;
  6663. $roleArray = array ();
  6664. $rolename = $role->getOne ( array (
  6665. 'where' => 'rid=' . $v [0],
  6666. 'asArray' => true
  6667. ) );
  6668. foreach ( $roleVerify as $o => $p ) {
  6669. $staffID = explode ( '_', $p );
  6670. $staffInfo = $staff->getOne ( array (
  6671. 'where' => 'sid=' . $staffID [0],
  6672. 'asArray' => true
  6673. ) );
  6674. // print_r($staffID);
  6675. $exp = array (
  6676. 0 => $staffInfo ['sid'],
  6677. 1 => $staffID [1],
  6678. 2 => $staffInfo ['avatar'],
  6679. 'date' => '',
  6680. 'date' => '',
  6681. 'opinion' => '',
  6682. 'status' => '',
  6683. 'rolename' => $rolename ['name']
  6684. );
  6685. array_push ( $roleArray, $exp );
  6686. }
  6687. $roleArrayCopy [$v [0]] = $roleArray;
  6688. // $verifyList[$k]['roleArray']=$roleArray;
  6689. }
  6690. // print_r($roleArray);
  6691. $verifyList [$k] ['date'] = "";
  6692. $verifyList [$k] ['opinion'] = "";
  6693. $verifyList [$k] ['status'] = "";
  6694. if (empty ( $verifyStaff )) {
  6695. $verifyList [$k] ['date'] = "";
  6696. $verifyList [$k] ['opinion'] = "";
  6697. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6698. $verifyList [$k] ['status'] = 4;
  6699. $button = 4;
  6700. $flag = false;
  6701. }
  6702. } else {
  6703. foreach ( $verifyStaff as $m => $u ) {
  6704. if ($v [0] == $m) {
  6705. $verifyList [$k] ['date'] = $u ['date'];
  6706. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6707. $verifyList [$k] ['status'] = $u ['status'];
  6708. $flag = false;
  6709. break;
  6710. }
  6711. }
  6712. $endStaffArray = end ( $verifyStaff );
  6713. if (isset ( $endStaffArray ['ROLE'] )) {
  6714. } else {
  6715. $endKey = key ( $verifyStaff );
  6716. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6717. $button = 4;
  6718. $verifyList [$k] ['status'] = 4;
  6719. }
  6720. }
  6721. }
  6722. }
  6723. $rolename ['name'] = '';
  6724. if (! empty ( $roleId )) {
  6725. Doo::loadModel ( 'role' );
  6726. $role = new role ();
  6727. $rolename = $role->getOne ( array (
  6728. 'where' => 'rid=' . $roleId,
  6729. 'asArray' => true
  6730. ) );
  6731. }
  6732. if (! empty ( $verifyStaff ))
  6733. $endStaffArray = end ( $verifyStaff );
  6734. $KOP = false;
  6735. foreach ( $roleArrayCopy as $P => $A ) {
  6736. foreach ( $A as $MKI => $AVL ) {
  6737. if (! empty ( $verifyStaff )) {
  6738. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6739. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6740. $button = 4;
  6741. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6742. }
  6743. foreach ( $verifyStaff as $m => $u ) {
  6744. $AVLFK = $AVL [0] . '_R';
  6745. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6746. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6747. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6748. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6749. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6750. break;
  6751. }
  6752. }
  6753. } else {
  6754. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6755. $button = 4;
  6756. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6757. }
  6758. }
  6759. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6760. $KOP = true;
  6761. }
  6762. }
  6763. foreach ( $roleArrayCopy as $k => $v ) {
  6764. foreach ( $verifyList as $m => $n ) {
  6765. if ($n [0] == $k) {
  6766. array_splice ( $verifyList, $m, 1, $v );
  6767. }
  6768. }
  6769. }
  6770. // print_r($verifyList);
  6771. $receiptList [$key] ['verifyList'] = $verifyList;
  6772. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6773. 'where' => 'sid=' . $value ['staff'],
  6774. 'asArray' => true
  6775. ) );
  6776. $receiptList [$key] ['button'] = $button;
  6777. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6778. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6779. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6780. $receiptList [$key] ['relust'] = $relust;
  6781. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6782. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6783. }
  6784. //print_r($receiptList);die;
  6785. // $data['verifyDetail']=$verifyDetail;
  6786. $mothHtml = "";
  6787. for($i = 1; $i <= 12; $i ++) {
  6788. if ($month == $i)
  6789. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6790. else
  6791. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6792. }
  6793. // 获取审批日志
  6794. Doo::loadModel ( 'receiptLog' );
  6795. $receiptLog = new receiptLog ();
  6796. $rlList = array ();
  6797. $rlInfo = $receiptLog->getOne ( array (
  6798. 'where' => 'rid=' . $rid . ' and status=4',
  6799. 'asArray' => true
  6800. ) );
  6801. $tijdate = $receiptLog->getOne ( array (
  6802. 'where' => 'rid=' . $rid . ' and status=2',
  6803. 'asc' => 'rlid',
  6804. 'asArray' => true
  6805. ) );
  6806. if (! empty ( $rlInfo )) {
  6807. $rlList = $receiptLog->find ( array (
  6808. 'where' => 'rid=' . $rid,
  6809. 'asc' => 'rlid',
  6810. 'asArray' => true
  6811. ) );
  6812. }
  6813. // echo $rid;
  6814. // print_r($receiptList);
  6815. $receiptList [0] ['rlList'] = $rlList;
  6816. // print_r($receiptList);
  6817. $enclosurList = $enclosur->find ( array (
  6818. 'where' => 'rid=' . $rid,
  6819. 'asArray' => true
  6820. ) );
  6821. $enclosurHtml = '';
  6822. foreach ( $enclosurList as $value ) {
  6823. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6824. }
  6825. $data ['enclosurHtml'] = $enclosurHtml;
  6826. $data ['rolename'] = $rolename ['name'];
  6827. $data ['mothHtml'] = $mothHtml;
  6828. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6829. if($receiptList[0]['version']==1){
  6830. require "protected/class/comm_cld.php";
  6831. $receiptList=makeReceiptDataVersion1($receiptList);
  6832. }
  6833. $data ['rid'] = $rid;
  6834. $data ['tijdate'] = $tijdate ['date'];
  6835. $data ['receiptList'] = $receiptList;
  6836. $data ['receiptApprovalCount'] = count ( $receiptList );
  6837. $data ['status'] = $status;
  6838. $data ['year'] = $year;
  6839. $data ['categoryList'] = $categoryList;
  6840. $data ['staffList'] = $staffList;
  6841. $data ['cid'] = $cid;
  6842. $data ['sid'] = $sid;
  6843. $data ['ap'] = $ap;
  6844. $data ['memu'] = "receipt";
  6845. $data ['staff'] = $this->staff;
  6846. $data ['receiptMemu'] = 'approvalExpenses';
  6847. $data ['verifyId'] = $this->verifyId;
  6848. $data ['executeId'] = $this->executeId;
  6849. if($receiptList[0]['version']==1){
  6850. $this->render ( "/fee/approval/receipt_compatible", $data );
  6851. die;
  6852. }
  6853. if($receiptList[0]['receiptClass']==1){
  6854. $this->render ( "/receipt/feeAgencyApproval", $data );
  6855. }elseif($receiptList[0]['receiptClass']==2){
  6856. //TODO 行程单2.0
  6857. if(!empty($receiptList[0]['itinerary2'])){
  6858. $this->render ( "/receipt/feeTraveApproval2", $data );
  6859. }else{
  6860. $this->render ( "/receipt/feeTraveApproval", $data );
  6861. }
  6862. }elseif($receiptList[0]['receiptClass']==3){
  6863. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6864. }else{
  6865. $this->render ( "/admin/receiptburEdi", $data );
  6866. }
  6867. }
  6868. function hisImplement() {
  6869. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  6870. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6871. if (empty ( $item ))
  6872. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6873. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6874. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6875. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6876. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6877. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6878. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6879. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6880. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6881. Doo::loadClass ( 'XDeode' );
  6882. $XDeode = new XDeode ( 5 );
  6883. Doo::loadModel ( 'receipt' );
  6884. $receipt = new receipt ();
  6885. Doo::loadModel ( 'L_category' );
  6886. $Lcategory = new L_category ();
  6887. Doo::loadModel ( 'verify' );
  6888. Doo::loadModel ( 'statistics' );
  6889. $statistics = new statistics ();
  6890. $verify = new verify ();
  6891. Doo::loadModel ( 'staff' );
  6892. $staff = new staff ();
  6893. Doo::loadClass ( 'XDeode' );
  6894. $XDeode = new XDeode ( 5 );
  6895. $XDeode7 = new XDeode ( 7 );
  6896. $cid = $XDeode->decode ( $cidKey );
  6897. $condition = "";
  6898. if ($item == "expenses")
  6899. $condition = " and Rtype=1 ";
  6900. elseif ($item == "receipts")
  6901. $condition = " and Rtype=0 ";
  6902. elseif ($item == "remits")
  6903. $condition = " and Rtype=2 ";
  6904. elseif($item == "train")
  6905. $condition = " and Rtype=3 ";
  6906. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6907. $sopString = $cidString = "";
  6908. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6909. if (empty ( $rdate ))
  6910. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6911. else
  6912. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6913. if ($status == 'pendImplement') {
  6914. $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 ) ) ';
  6915. } elseif ($status == 'alerpts') {
  6916. $statusCon = '(status=8 or status=9 )';
  6917. if (empty ( $rdate )){
  6918. $dateCondition = " and Year(date) =" . $year;
  6919. }else{
  6920. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6921. }
  6922. }
  6923. if ($sop != 'SOP')
  6924. $sopString = " and staff=" . $sop;
  6925. if ($cidKey != 'ALL')
  6926. $cidString = " and cid=" . $cid;
  6927. //汇款信息需要提取出来
  6928. if(!empty($receiptOrder)){
  6929. $receiptList = $receipt->find ( array (
  6930. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6931. 'desc' => 'rid',
  6932. 'asArray' => true
  6933. ) );
  6934. // 员工筛选
  6935. $receiptList2 = $receipt->find ( array (
  6936. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6937. 'desc' => 'rid',
  6938. 'asArray' => true
  6939. ) );
  6940. }else{
  6941. $receiptList = $receipt->find ( array (
  6942. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6943. 'desc' => 'rid',
  6944. 'asArray' => true
  6945. ) );
  6946. // 员工筛选
  6947. $receiptList2 = $receipt->find ( array (
  6948. 'where' => $statusCon . $condition . $dateCondition,
  6949. 'desc' => 'rid',
  6950. 'asArray' => true
  6951. ) );
  6952. }
  6953. $sopStaff = array ();
  6954. foreach ( $receiptList2 as $key => $value ) {
  6955. $staffDetail = $staff->getOne ( array (
  6956. 'select' => 'username',
  6957. 'where' => 'sid=' . $value ['staff'],
  6958. 'asArray' => true
  6959. ) );
  6960. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6961. }
  6962. // 办事处筛选
  6963. $categoryScreen = array ();
  6964. $categorList = $Lcategory->getCategory ();
  6965. foreach ( $receiptList2 as $key => $value ) {
  6966. foreach ( $categorList as $k => $v ) {
  6967. if ($value ['cid'] == $v ['cid']) {
  6968. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6969. break;
  6970. }
  6971. }
  6972. }
  6973. $categoryScreenHtml = "";
  6974. foreach ( $categoryScreen as $key => $value ) {
  6975. if ($cidKey == $key)
  6976. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6977. else
  6978. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6979. }
  6980. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6981. $data ['cidKey'] = $cidKey;
  6982. $Locate = 0;
  6983. $roleId = 0;
  6984. $button = 0;
  6985. $staffBatchNumber = 100001;
  6986. $remittanceList = array ();
  6987. foreach ( $receiptList as $key => $value ) {
  6988. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6989. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6990. $receiptList [$key] ['Texe'] = 'false';
  6991. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6992. $receiptList [$key] ['Texe'] = 'true';
  6993. }
  6994. $receiptList [$key] ['TRexe'] = 'true';
  6995. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6996. $receiptList [$key] ['TRexe'] = 'false';
  6997. }
  6998. $receiptList [$key] ['Locate'] = $Locate;
  6999. $Locate ++;
  7000. $receiptList [$key] ['reviseDetail'] = array ();
  7001. if (! empty ( $value ['reviseDetail'] ))
  7002. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7003. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7004. $categoryDetil = $Lcategory->getOne ( array (
  7005. 'where' => 'cid=' . $value ['cid'],
  7006. 'asArray' => true
  7007. ) );
  7008. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7009. // 检测编辑状态
  7010. $verifyList = $verify->getOne ( array (
  7011. 'where' => 'vid=' . $value ['verify'],
  7012. 'asArray' => true
  7013. ) );
  7014. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7015. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7016. Doo::loadModel ( 'role' );
  7017. $role = new role ();
  7018. $flag = true;
  7019. $roleKey = 0;
  7020. $endStaffArray = array ();
  7021. $roleArrayCopy = array ();
  7022. foreach ( $verifyList as $k => $v ) {
  7023. // init verifyStaff
  7024. if ($v [1] == 'ROLE') {
  7025. if (! empty ( $verifyStaff )) {
  7026. $endStaffArray = end ( $verifyStaff );
  7027. }
  7028. $roleVerify = json_decode ( $v [3], true );
  7029. $roleKey = $k;
  7030. $roleArray = array ();
  7031. $rolename = $role->getOne ( array (
  7032. 'where' => 'rid=' . $v [0],
  7033. 'asArray' => true
  7034. ) );
  7035. foreach ( $roleVerify as $o => $p ) {
  7036. $staffID = explode ( '_', $p );
  7037. $staffInfo = $staff->getOne ( array (
  7038. 'where' => 'sid=' . $staffID [0],
  7039. 'asArray' => true
  7040. ) );
  7041. $exp = array (
  7042. 0 => $staffInfo ['sid'],
  7043. 1 => $staffID [1],
  7044. 2 => $staffInfo ['avatar'],
  7045. 'date' => '',
  7046. 'date' => '',
  7047. 'opinion' => '',
  7048. 'status' => '',
  7049. 'rolename' => $rolename ['name']
  7050. );
  7051. array_push ( $roleArray, $exp );
  7052. }
  7053. $roleArrayCopy [$v [0]] = $roleArray;
  7054. }
  7055. $verifyList [$k] ['date'] = "";
  7056. $verifyList [$k] ['opinion'] = "";
  7057. $verifyList [$k] ['status'] = "";
  7058. if (empty ( $verifyStaff )) {
  7059. $verifyList [$k] ['date'] = "";
  7060. $verifyList [$k] ['opinion'] = "";
  7061. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7062. $verifyList [$k] ['status'] = 4;
  7063. $flag = false;
  7064. }
  7065. } else {
  7066. foreach ( $verifyStaff as $m => $u ) {
  7067. if ($v [0] == $m) {
  7068. $verifyList [$k] ['date'] = $u ['date'];
  7069. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7070. $verifyList [$k] ['status'] = $u ['status'];
  7071. $flag = false;
  7072. break;
  7073. }
  7074. }
  7075. $endStaffArray = end ( $verifyStaff );
  7076. }
  7077. }
  7078. $rolename ['name'] = '';
  7079. if (! empty ( $roleId )) {
  7080. Doo::loadModel ( 'role' );
  7081. $role = new role ();
  7082. $rolename = $role->getOne ( array (
  7083. 'where' => 'rid=' . $roleId,
  7084. 'asArray' => true
  7085. ) );
  7086. }
  7087. if (! empty ( $verifyStaff ))
  7088. $endStaffArray = end ( $verifyStaff );
  7089. $KOP = false;
  7090. foreach ( $roleArrayCopy as $P => $A ) {
  7091. foreach ( $A as $MKI => $AVL ) {
  7092. if (! empty ( $verifyStaff )) {
  7093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7095. $button = 4;
  7096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7097. }
  7098. foreach ( $verifyStaff as $m => $u ) {
  7099. $AVLFK = $AVL [0] . '_R';
  7100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7105. break;
  7106. }
  7107. }
  7108. } else {
  7109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7110. $button = 4;
  7111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7112. }
  7113. }
  7114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7115. $KOP = true;
  7116. }
  7117. }
  7118. foreach ( $roleArrayCopy as $k => $v ) {
  7119. foreach ( $verifyList as $m => $n ) {
  7120. if ($n [0] == $k) {
  7121. array_splice ( $verifyList, $m, 1, $v );
  7122. }
  7123. }
  7124. }
  7125. $receiptList [$key] ['verifyList'] = $verifyList;
  7126. $staffDetail = $staff->getOne ( array (
  7127. 'where' => 'sid=' . $value ['staff'],
  7128. 'asArray' => true
  7129. ) );
  7130. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7131. $receiptList [$key] ['button'] = $button;
  7132. $receiptList [$key] ['paymentABS']="";
  7133. if ($value['Rtype']==1){
  7134. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7135. $receiptList [$key] ['relustABS'] = sprintf("%.2f",abs($receiptList [$key] ['relust']));
  7136. }elseif($value['Rtype']==3){
  7137. // 收入合计
  7138. Doo::loadModel ( 'invoiceTraining' );
  7139. $invoiceTraining = new invoiceTraining ();
  7140. $invoiceTrainingDetail = array (
  7141. 'invoiceArriveAmount' => '0.00',
  7142. 'RIAmount' => '0.00',
  7143. 'invoiceTotalAmount' => '0.00',
  7144. 'invoiceCompanyAmount' => '0.00',
  7145. 'invoiceArriveAmountM'=>'0.00',
  7146. 'invoiceCompanyAmountM'=>'0.00'
  7147. );
  7148. if ($value ['invoiceTrainId'] != 0) {
  7149. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7150. }
  7151. $invoiceArriveAmount = $RIAmount = 0;
  7152. if (! empty ( $invoiceTrainingDetail )) {
  7153. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7154. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7155. }
  7156. // 备用金
  7157. $sum = 0;
  7158. if (! empty ( $value ['trainLoanRid'] )) {
  7159. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7160. foreach ($receiptLoanList as $kll=>$vll){
  7161. $sum+=$vll['sum'];
  7162. }
  7163. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7164. // $sum = $receiptLoanDetailBak ['sum'];
  7165. }
  7166. // 支出项金额详情
  7167. // 项目金额合计
  7168. Doo::loadModel ( 'RItem' );
  7169. $RItem = new RItem ();
  7170. Doo::loadModel ( 'accountItem' );
  7171. $accountItem = new accountItem ();
  7172. // 讲师获得
  7173. Doo::loadModel ( 'RILecturer' );
  7174. $RILecturer = new RILecturer ();
  7175. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7176. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7177. // 支出项金额详情
  7178. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7179. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7180. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7181. $receiptList [$key] ['payment'] =$payment;
  7182. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7183. }
  7184. // 设置导出汇款execl
  7185. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7186. $remittanceDetail = array (
  7187. $staffBatchNumber,
  7188. $value ['remittanceName'],
  7189. $value ['bankNumber'],
  7190. $value ['bankName'],
  7191. $value ['remittanceBankType'],
  7192. $value ['coupletNumber'],
  7193. $value ['sum'] ,
  7194. $receiptList [$key] ['paymentABS']
  7195. );
  7196. array_push ( $remittanceList, $remittanceDetail );
  7197. $staffBatchNumber ++;
  7198. }
  7199. if($value['version']==1){
  7200. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  7201. }
  7202. }
  7203. $data ['remittanceList'] = json_encode ( $remittanceList );
  7204. // print_r($receiptList);
  7205. $mothHtml = "";
  7206. for($i = 1; $i <= 12; $i ++) {
  7207. if ($moth == $i)
  7208. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7209. else
  7210. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7211. }
  7212. $dayHtml = "";
  7213. if ($day != "DAY" || $moth != "MONTH") {
  7214. for($i = 1; $i <= 31; $i ++) {
  7215. if ($day == $i)
  7216. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7217. else
  7218. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7219. }
  7220. }
  7221. $sopHtml = "";
  7222. foreach ( $sopStaff as $key => $value ) {
  7223. if ($sop == $key)
  7224. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7225. else
  7226. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7227. }
  7228. $data ['status'] = $status;
  7229. $data ['rdate'] = $rdate;
  7230. $data ['sopHtml'] = $sopHtml;
  7231. $data ['dayHtml'] = $dayHtml;
  7232. $data ['mothHtml'] = $mothHtml;
  7233. $data ['receiptList'] = $receiptList;
  7234. $data ['memu'] = "receipt";
  7235. $data ['staff'] = $this->staff;
  7236. $data ['receiptMemu'] = 'implement';
  7237. $data ['verifyId'] = $this->verifyId;
  7238. $data ['executeId'] = $this->executeId;
  7239. $data ['item'] = $item;
  7240. $data ['year'] = $year;
  7241. $data ['moth'] = $moth;
  7242. $data['receiptOrder']=$receiptOrder;
  7243. $data ['day'] = $day;
  7244. $data ['sop'] = $sop;
  7245. $this->render ( "/admin/hisImplement", $data );
  7246. }
  7247. /**
  7248. * 导出汇款信息的exelc
  7249. */
  7250. function exportRemittance() {
  7251. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7252. if (empty ( $remittanceInfo ))
  7253. die ( 'illegal request' );
  7254. $title = array (
  7255. '员工编号',
  7256. '姓名',
  7257. '员工账号',
  7258. '员工账户开户行',
  7259. '转账类型',
  7260. '联行号',
  7261. '金额',
  7262. '结算(培训班)'
  7263. );
  7264. $data = json_decode ( $remittanceInfo, true );
  7265. if (empty ( $data ))
  7266. die ( 'illegal request' );
  7267. Doo::loadClass ( 'receipt.func' );
  7268. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7269. header ( 'Content-Type:text/html;charset=utf-8' );
  7270. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7271. }
  7272. function ajaxExamine() {
  7273. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7274. Doo::loadModel ( 'receipt' );
  7275. $receipt = new receipt ();
  7276. if (! empty ( $rid )) {
  7277. $rLRes = $receipt->find ( array (
  7278. '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,
  7279. 'asArray' => true
  7280. ) );
  7281. if(!empty($rLRes)){
  7282. Doo::loadClass ( 'XDeode' );
  7283. $XDeode = new XDeode ( 7 );
  7284. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7285. echo json_encode ( array (
  7286. 'status' => 1,
  7287. 'receipt' => $rLRes [0]
  7288. ) );
  7289. die ();
  7290. }else{
  7291. echo json_encode ( array (
  7292. 'status' => 1,
  7293. 'receipt' => array ()
  7294. ) );
  7295. die ();
  7296. }
  7297. }
  7298. echo json_encode ( array (
  7299. 'status' => 0,
  7300. 'receipt' => array ()
  7301. ) );
  7302. die ();
  7303. }
  7304. /*
  7305. * 废弃
  7306. */
  7307. function myReceipt() {
  7308. // all approval past withdraw
  7309. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7310. if (empty ( $item ))
  7311. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7312. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7313. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7314. Doo::loadModel ( 'receipt' );
  7315. $receipt = new receipt ();
  7316. // pre-loaded
  7317. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7318. // have cache
  7319. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7320. if (! empty ( $moth )) // yearPage
  7321. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7322. $this->showCache ( $path );
  7323. }
  7324. Doo::loadModel ( 'L_category' );
  7325. $Lcategory = new L_category ();
  7326. Doo::loadModel ( 'verify' );
  7327. Doo::loadModel ( 'statistics' );
  7328. $statistics = new statistics ();
  7329. $verify = new verify ();
  7330. Doo::loadModel ( 'staff' );
  7331. $staff = new staff ();
  7332. $condition = " and status!=0 ";
  7333. if ($item == "approval")
  7334. $condition = " and status=2 ";
  7335. elseif ($item == "withdraw")
  7336. $condition = " and status=3 ";
  7337. elseif ($item == "past")
  7338. $condition = " and status=1 ";
  7339. elseif ($item == "whdw")
  7340. $condition = " and status=4 ";
  7341. $dateCondition = " and Year(date) =" . $year;
  7342. if (! empty ( $moth )) {
  7343. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7344. $stList = $statistics->getOne ( array (
  7345. 'select' => 'rePrice ,agPrice',
  7346. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7347. 'asArray' => true
  7348. ) );
  7349. } else
  7350. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7351. if (empty ( $stList ))
  7352. $stList = array (
  7353. 'rePrice' => 0,
  7354. 'agPrice' => 0
  7355. );
  7356. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7357. $data ['stList'] = array (
  7358. 'rePrice' => $stList ['rePrice'],
  7359. 'agPrice' => $stList ['agPrice'],
  7360. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7361. );
  7362. $receiptList = $receipt->find ( array (
  7363. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7364. 'desc' => 'rid',
  7365. 'asArray' => true
  7366. ) );
  7367. $Locate = 0;
  7368. $roleId = 0;
  7369. $button = 0;
  7370. foreach ( $receiptList as $key => $value ) {
  7371. $receiptList [$key] ['Locate'] = $Locate;
  7372. $Locate ++;
  7373. $receiptList [$key] ['reviseDetail'] = array ();
  7374. if (! empty ( $value ['reviseDetail'] ))
  7375. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7376. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7377. $categoryDetil = $Lcategory->getOne ( array (
  7378. 'where' => 'cid=' . $value ['cid'],
  7379. 'asArray' => true
  7380. ) );
  7381. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7382. // 检测编辑状态
  7383. $verifyList = $verify->getOne ( array (
  7384. 'where' => 'vid=' . $value ['verify'],
  7385. 'asArray' => true
  7386. ) );
  7387. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7388. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7389. Doo::loadModel ( 'role' );
  7390. $role = new role ();
  7391. $flag = true;
  7392. $roleKey = 0;
  7393. $endStaffArray = array ();
  7394. $roleArrayCopy = array ();
  7395. foreach ( $verifyList as $k => $v ) {
  7396. // init verifyStaff
  7397. if ($v [1] == 'ROLE') {
  7398. if (! empty ( $verifyStaff )) {
  7399. $endStaffArray = end ( $verifyStaff );
  7400. // if ($v[0]==$endStaffArray['nextStaff']){
  7401. // $roleId=$v[0];
  7402. // }
  7403. }
  7404. $roleVerify = json_decode ( $v [3], true );
  7405. $roleKey = $k;
  7406. $roleArray = array ();
  7407. $rolename = $role->getOne ( array (
  7408. 'where' => 'rid=' . $v [0],
  7409. 'asArray' => true
  7410. ) );
  7411. foreach ( $roleVerify as $o => $p ) {
  7412. $staffID = explode ( '_', $p );
  7413. $staffInfo = $staff->getOne ( array (
  7414. 'where' => 'sid=' . $staffID [0],
  7415. 'asArray' => true
  7416. ) );
  7417. // print_r($staffID);
  7418. $exp = array (
  7419. 0 => $staffInfo ['sid'],
  7420. 1 => $staffID [1],
  7421. 2 => $staffInfo ['avatar'],
  7422. 'date' => '',
  7423. 'date' => '',
  7424. 'opinion' => '',
  7425. 'status' => '',
  7426. 'rolename' => $rolename ['name']
  7427. );
  7428. array_push ( $roleArray, $exp );
  7429. }
  7430. $roleArrayCopy [$v [0]] = $roleArray;
  7431. // $verifyList[$k]['roleArray']=$roleArray;
  7432. }
  7433. $verifyList [$k] ['date'] = "";
  7434. $verifyList [$k] ['opinion'] = "";
  7435. $verifyList [$k] ['status'] = "";
  7436. if (empty ( $verifyStaff )) {
  7437. $verifyList [$k] ['date'] = "";
  7438. $verifyList [$k] ['opinion'] = "";
  7439. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7440. $verifyList [$k] ['status'] = 4;
  7441. $flag = false;
  7442. }
  7443. } else {
  7444. foreach ( $verifyStaff as $m => $u ) {
  7445. if ($v [0] == $m) {
  7446. $verifyList [$k] ['date'] = $u ['date'];
  7447. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7448. $verifyList [$k] ['status'] = $u ['status'];
  7449. $flag = false;
  7450. break;
  7451. }
  7452. }
  7453. $endStaffArray = end ( $verifyStaff );
  7454. if (isset ( $endStaffArray ['ROLE'] )) {
  7455. } else {
  7456. // $endKey=key($verifyStaff);
  7457. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7458. // $button=4;
  7459. // $verifyList[$k]['status']=4;
  7460. // }
  7461. }
  7462. }
  7463. }
  7464. $rolename ['name'] = '';
  7465. if (! empty ( $roleId )) {
  7466. Doo::loadModel ( 'role' );
  7467. $role = new role ();
  7468. $rolename = $role->getOne ( array (
  7469. 'where' => 'rid=' . $roleId,
  7470. 'asArray' => true
  7471. ) );
  7472. }
  7473. if (! empty ( $verifyStaff ))
  7474. $endStaffArray = end ( $verifyStaff );
  7475. $KOP = false;
  7476. foreach ( $roleArrayCopy as $P => $A ) {
  7477. foreach ( $A as $MKI => $AVL ) {
  7478. if (! empty ( $verifyStaff )) {
  7479. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7480. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7481. $button = 4;
  7482. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7483. }
  7484. foreach ( $verifyStaff as $m => $u ) {
  7485. $AVLFK = $AVL [0] . '_R';
  7486. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7487. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7488. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7489. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7490. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7491. break;
  7492. }
  7493. }
  7494. } else {
  7495. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7496. $button = 4;
  7497. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7498. }
  7499. }
  7500. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7501. $KOP = true;
  7502. }
  7503. }
  7504. foreach ( $roleArrayCopy as $k => $v ) {
  7505. foreach ( $verifyList as $m => $n ) {
  7506. if ($n [0] == $k) {
  7507. array_splice ( $verifyList, $m, 1, $v );
  7508. }
  7509. }
  7510. }
  7511. $receiptList [$key] ['verifyList'] = $verifyList;
  7512. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7513. 'where' => 'sid=' . $value ['staff'],
  7514. 'asArray' => true
  7515. ) );
  7516. $receiptList [$key] ['button'] = $button;
  7517. }
  7518. // print_r($receiptList);die;
  7519. $mothHtml = "";
  7520. for($i = 1; $i <= 12; $i ++) {
  7521. if ($moth == $i)
  7522. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7523. else
  7524. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7525. }
  7526. $data ['mothHtml'] = $mothHtml;
  7527. $data ['receiptList'] = $receiptList;
  7528. $data ['memu'] = "receipt";
  7529. $data ['staff'] = $this->staff;
  7530. $data ['receiptMemu'] = 'receipt';
  7531. $data ['verifyId'] = $this->verifyId;
  7532. $data ['executeId'] = $this->executeId;
  7533. $data ['item'] = $item;
  7534. $data ['year'] = $year;
  7535. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7536. // sufficient condition to generate cache
  7537. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7538. $receiptList = $receipt->find ( array (
  7539. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7540. 'asArray' => true
  7541. ) );
  7542. if (empty ( $receiptList )) { // generated files
  7543. ob_start ();
  7544. $this->render ( "/admin/saea_myList", $data );
  7545. $this->cacheFile ( $path );
  7546. die ();
  7547. // $content = ob_get_contents();
  7548. // $fp = fopen($path, "w");
  7549. // fwrite($fp, $content);
  7550. // fclose($fp);
  7551. }
  7552. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7553. $receiptList = $receipt->find ( array (
  7554. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7555. 'asArray' => true
  7556. ) );
  7557. if (empty ( $receiptList )) { // generated files
  7558. ob_start ();
  7559. $this->render ( "/admin/saea_myList", $data );
  7560. $this->cacheFile ( $path );
  7561. die ();
  7562. }
  7563. }
  7564. }
  7565. $this->render ( "/admin/saea_myList", $data );
  7566. }
  7567. function approvedReceipt() {
  7568. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7569. Doo::loadModel ( 'receipt' );
  7570. Doo::loadModel ( 'receiptDetail' );
  7571. $receipt = new receipt ();
  7572. $receiptDetail = new receiptDetail ();
  7573. Doo::loadModel ( 'statistics' );
  7574. Doo::loadModel ( 'itemStatistics' );
  7575. $statistics = new statistics ();
  7576. $itemStatistics = new itemStatistics ();
  7577. Doo::loadModel ( "verify" );
  7578. $verify = new verify ();
  7579. // 审批状态的判定
  7580. $receiptDetailList = $receipt->getOne ( array (
  7581. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7582. 'asArray' => true
  7583. ) );
  7584. if (empty ( $receiptDetailList )){
  7585. return "/saeaBorad";
  7586. }
  7587. // 如果是新报销单,有差旅的情况下写入日期
  7588. if($receiptDetailList['version']==1){
  7589. if(!empty($receiptDetailList['traveJson'])){
  7590. $traveJson=json_decode($receiptDetailList['traveJson'],true)['traveList'];
  7591. foreach ($traveJson as $key=>$value){
  7592. Doo::loadModel ( 'cld/traveDate_cld' );
  7593. $traveDate = new traveDate_cld ();
  7594. $traveDate->sid=$this->staff [0] ['sid'];
  7595. $traveDate->rid=$receiptDetailList['rid'];
  7596. $tripTime = explode(" - ", $value['tripTime']);
  7597. $traveDate->start=$tripTime[0];
  7598. $traveDate->end=$tripTime[1];
  7599. $traveDate->insert ();
  7600. }
  7601. }
  7602. }
  7603. $verifyDetail = $verify->getOne ( array (
  7604. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7605. 'asArray' => true
  7606. ) );
  7607. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7608. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7609. $nowStaff = "";
  7610. $nowStaffList = array ();
  7611. if ($verifyDetail [0] [1] == 'ROLE') {
  7612. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7613. foreach ( $vStaffString as $key => $value ) {
  7614. $staffK = explode ( "_", $value );
  7615. array_push ( $nowStaffList, $staffK [0] );
  7616. }
  7617. $nowStaff = implode ( ',', $nowStaffList );
  7618. } else {
  7619. $nowStaff = $verifyDetail [0] [0];
  7620. }
  7621. $receipt->nowStaff = $nowStaff;
  7622. }
  7623. // echo $nowStaff;
  7624. // print_r($verifyDetail);die;
  7625. $receipt->rid = $receiptDetailList ['rid'];
  7626. $receipt->date = date ( "Y-m-d" );
  7627. $receipt->status = 2;
  7628. $receipt->update ();
  7629. $receiptDetail->status = 2;
  7630. $receiptDetail->update ( array (
  7631. 'where' => 'rid=' . $receiptDetailList ['rid']
  7632. ) );
  7633. Doo::loadModel ( "receiptLog" );
  7634. $receiptLog = new receiptLog ();
  7635. Doo::loadModel ( "verify" );
  7636. $verify = new verify ();
  7637. $receiptInfo = $receipt->getOne ( array (
  7638. 'where' => 'rid=' . $rid,
  7639. 'asArray' => true
  7640. ) );
  7641. $vr = $verify->getOne ( array (
  7642. 'where' => 'vid=' . $receiptInfo ['verify'],
  7643. 'asArray' => true
  7644. ) );
  7645. $jd = json_decode ( $vr ['staff'] );
  7646. $roleId = 0;
  7647. foreach ( $jd as $key => $value ) {
  7648. if ($value [1] == 'ROLE') {
  7649. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7650. if ($pos !== false) {
  7651. $roleId = $value [0];
  7652. }
  7653. }
  7654. }
  7655. // 审批日志
  7656. // echo $roleId;die;
  7657. if (! empty ( $roleId )) {
  7658. Doo::loadModel ( "role" );
  7659. $role = new role ();
  7660. $roleInfo = $role->getOne ( array (
  7661. 'where' => 'rid=' . $roleId,
  7662. 'asArray' => true
  7663. ) );
  7664. // $receiptLog->rolename = $roleInfo ['name'];
  7665. }
  7666. $receiptLog->username = $this->staff [0] ['username'];
  7667. $receiptLog->uid = $this->staff [0] ['sid'];
  7668. $receiptLog->date = date ( "Y-m-d" );
  7669. $receiptLog->opinion = '提交审批';
  7670. $receiptLog->img = $this->staff [0] ['avatar'];
  7671. $receiptLog->status = 2;
  7672. $receiptLog->rid = $rid;
  7673. $receiptLog->insert ();
  7674. // statistics item
  7675. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7676. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7677. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7678. $stat = $statistics->getOne ( array (
  7679. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7680. 'asArray' => true
  7681. ) );
  7682. if (empty ( $stat )) {
  7683. $statistics->date = date ( "Y-m-d" );
  7684. $statistics->cid = $this->staff [0] ['cid'];
  7685. $statistics->staff = $this->staff [0] ['sid'];
  7686. $statistics->agPrice = 0;
  7687. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7688. $statistics->insert ();
  7689. } else {
  7690. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7691. $statistics->update ( array (
  7692. 'where' => 'sid=' . $stat ['sid']
  7693. ) );
  7694. }
  7695. return "/expenses";
  7696. }
  7697. function approval() {
  7698. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7699. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7700. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7701. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7702. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7703. if (empty ( $status ))
  7704. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7705. $vidList = array ();
  7706. $button = 0;
  7707. Doo::loadModel ( 'verify' );
  7708. $verify = new verify ();
  7709. Doo::loadModel ( 'receipt' );
  7710. $receipt = new receipt ();
  7711. Doo::loadModel ( 'staff' );
  7712. $staff = new staff ();
  7713. Doo::loadModel ( 'L_category' );
  7714. $Lcategory = new L_category ();
  7715. // user verify ID
  7716. $verifyDetail = $verify->find ( array (
  7717. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7718. 'asArray' => true
  7719. ) );
  7720. foreach ( $verifyDetail as $key => $value ) {
  7721. array_push ( $vidList, $value ['vid'] );
  7722. }
  7723. $vid = implode ( ",", $vidList );
  7724. if (empty ( $verifyDetail ))
  7725. $vid = 0;
  7726. /*
  7727. */
  7728. $dateCondition = " and Year(date) =" . $year;
  7729. if (! empty ( $month ))
  7730. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7731. $categoryList = $Lcategory->find ( array (
  7732. 'asArray' => true
  7733. ) );
  7734. $staffList = $staff->find ( array (
  7735. 'where' => 'cid=' . $cid,
  7736. 'asArray' => true
  7737. ) );
  7738. $cateCondition = "";
  7739. $staffCondition = "";
  7740. $approvalCondition = "";
  7741. if (! empty ( $cid ))
  7742. $cateCondition = ' and cid=' . $cid;
  7743. if (! empty ( $sid )) {
  7744. $staffCondition = ' and staff=' . $sid;
  7745. $cateCondition = "";
  7746. }
  7747. // elseif($status==1){
  7748. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7749. // }
  7750. if ($status == 2) {
  7751. // 查找角色审批人
  7752. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7753. }
  7754. $ap = "";
  7755. if ($status == 4) {
  7756. $ap = 4;
  7757. $status = 2;
  7758. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7759. }
  7760. if ($status == 5) {
  7761. $status = 4;
  7762. $ap = 5;
  7763. }
  7764. // echo $vid;
  7765. // get Receipt By verifyID status 2 .$approvalCondition
  7766. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7767. $receiptList = $receipt->find ( array (
  7768. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7769. 'desc' => 'rid',
  7770. 'asArray' => true
  7771. ) );
  7772. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7773. $Locate = 0;
  7774. if ($ap == 4)
  7775. $status = 4;
  7776. elseif ($ap == 5)
  7777. $status = 5;
  7778. foreach ( $receiptList as $key => $value ) {
  7779. $receiptList [$key] ['Locate'] = $Locate;
  7780. $Locate ++;
  7781. $receiptList [$key] ['reviseDetail'] = array ();
  7782. if (! empty ( $value ['reviseDetail'] ))
  7783. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7784. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7785. $categoryDetil = $Lcategory->getOne ( array (
  7786. 'where' => 'cid=' . $value ['cid'],
  7787. 'asArray' => true
  7788. ) );
  7789. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7790. $verifyList = $verify->getOne ( array (
  7791. 'where' => 'vid=' . $value ['verify'],
  7792. 'asArray' => true
  7793. ) );
  7794. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7795. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7796. foreach ( $verifyList as $k => $v ) {
  7797. // init verifyStaff
  7798. $verifyList [$k] ['date'] = "";
  7799. $verifyList [$k] ['opinion'] = "";
  7800. $verifyList [$k] ['status'] = "";
  7801. if (empty ( $verifyStaff )) {
  7802. $verifyList [$k] ['date'] = "";
  7803. $verifyList [$k] ['opinion'] = "";
  7804. if ($v [0] == $this->staff [0] ['sid']) {
  7805. $verifyList [$k] ['status'] = 4;
  7806. $button = 4;
  7807. }
  7808. } else {
  7809. $flag = true;
  7810. foreach ( $verifyStaff as $m => $u ) {
  7811. if ($v [0] == $m) {
  7812. $verifyList [$k] ['date'] = $u ['date'];
  7813. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7814. $verifyList [$k] ['status'] = $u ['status'];
  7815. $flag = false;
  7816. break;
  7817. }
  7818. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7819. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7820. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7821. }
  7822. if ($flag) { // 检测可编辑
  7823. if ($v [0] == $this->staff [0] ['sid']) {
  7824. $verifyList [$k] ['status'] = 4;
  7825. $button = 4;
  7826. }
  7827. }
  7828. }
  7829. }
  7830. $receiptList [$key] ['verifyList'] = $verifyList;
  7831. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7832. 'where' => 'sid=' . $value ['staff'],
  7833. 'asArray' => true
  7834. ) );
  7835. $receiptList [$key] ['button'] = $button;
  7836. }
  7837. // print_r($receiptList);die;
  7838. // $data['verifyDetail']=$verifyDetail;
  7839. $mothHtml = "";
  7840. for($i = 1; $i <= 12; $i ++) {
  7841. if ($month == $i)
  7842. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7843. else
  7844. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7845. }
  7846. $data ['mothHtml'] = $mothHtml;
  7847. $data ['receiptList'] = $receiptList;
  7848. $data ['receiptApprovalCount'] = count ( $receiptList );
  7849. $data ['status'] = $status;
  7850. $data ['year'] = $year;
  7851. $data ['categoryList'] = $categoryList;
  7852. $data ['staffList'] = $staffList;
  7853. $data ['cid'] = $cid;
  7854. $data ['sid'] = $sid;
  7855. $data ['ap'] = $ap;
  7856. $data ['memu'] = "receipt";
  7857. $data ['staff'] = $this->staff;
  7858. $data ['receiptMemu'] = 'approval';
  7859. $data ['verifyId'] = $this->verifyId;
  7860. $data ['executeId'] = $this->executeId;
  7861. $this->render ( "/admin/saea_reportList", $data );
  7862. }
  7863. function approvalDetails() {
  7864. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7865. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7866. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7867. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7868. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7869. Doo::loadModel ( 'verify' );
  7870. $verify = new verify ();
  7871. Doo::loadModel ( 'receipt' );
  7872. $receipt = new receipt ();
  7873. Doo::loadModel ( 'staff' );
  7874. $staff = new staff ();
  7875. Doo::loadModel ( 'L_category' );
  7876. $Lcategory = new L_category ();
  7877. Doo::loadModel ( 'enclosur' );
  7878. $enclosur = new enclosur ();
  7879. $vidList = array ();
  7880. $verifyDetail = $verify->find ( array (
  7881. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7882. 'asArray' => true
  7883. ) );
  7884. foreach ( $verifyDetail as $key => $value ) {
  7885. array_push ( $vidList, $value ['vid'] );
  7886. }
  7887. $vid = implode ( ",", $vidList );
  7888. if (empty ( $verifyDetail ))
  7889. $vid = 0;
  7890. $categoryList = $Lcategory->find ( array (
  7891. 'asArray' => true
  7892. ) );
  7893. $staffList = $staff->find ( array (
  7894. 'where' => 'cid=' . $cid,
  7895. 'asArray' => true
  7896. ) );
  7897. $ap = 0;
  7898. $receiptList = $receipt->find ( array (
  7899. 'where' => 'rid =' . $rid,
  7900. 'desc' => 'rid',
  7901. 'asArray' => true
  7902. ) );
  7903. $Locate = 0;
  7904. $roleId = 0;
  7905. $button = 0;
  7906. foreach ( $receiptList as $key => $value ) {
  7907. $receiptList [$key] ['Locate'] = $Locate;
  7908. $Locate ++;
  7909. $receiptList [$key] ['reviseDetail'] = array ();
  7910. if (! empty ( $value ['reviseDetail'] ))
  7911. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7912. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7913. $categoryDetil = $Lcategory->getOne ( array (
  7914. 'where' => 'cid=' . $value ['cid'],
  7915. 'asArray' => true
  7916. ) );
  7917. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7918. // 检测编辑状态
  7919. $verifyList = $verify->getOne ( array (
  7920. 'where' => 'vid=' . $value ['verify'],
  7921. 'asArray' => true
  7922. ) );
  7923. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7924. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7925. Doo::loadModel ( 'role' );
  7926. $role = new role ();
  7927. // print_r($verifyList);
  7928. $flag = true;
  7929. $roleKey = 0;
  7930. $endStaffArray = array ();
  7931. $roleArrayCopy = array ();
  7932. foreach ( $verifyList as $k => $v ) {
  7933. // init verifyStaff
  7934. if ($v [1] == 'ROLE') {
  7935. if (! empty ( $verifyStaff )) {
  7936. $endStaffArray = end ( $verifyStaff );
  7937. if ($v [0] == $endStaffArray ['nextStaff']) {
  7938. $roleId = $v [0];
  7939. }
  7940. }
  7941. $roleVerify = json_decode ( $v [3], true );
  7942. $roleKey = $k;
  7943. $roleArray = array ();
  7944. $rolename = $role->getOne ( array (
  7945. 'where' => 'rid=' . $v [0],
  7946. 'asArray' => true
  7947. ) );
  7948. foreach ( $roleVerify as $o => $p ) {
  7949. $staffID = explode ( '_', $p );
  7950. $staffInfo = $staff->getOne ( array (
  7951. 'where' => 'sid=' . $staffID [0],
  7952. 'asArray' => true
  7953. ) );
  7954. // print_r($staffID);
  7955. $exp = array (
  7956. 0 => $staffInfo ['sid'],
  7957. 1 => $staffID [1],
  7958. 2 => $staffInfo ['avatar'],
  7959. 'date' => '',
  7960. 'date' => '',
  7961. 'opinion' => '',
  7962. 'status' => '',
  7963. 'rolename' => $rolename ['name']
  7964. );
  7965. array_push ( $roleArray, $exp );
  7966. }
  7967. $roleArrayCopy [$v [0]] = $roleArray;
  7968. // $verifyList[$k]['roleArray']=$roleArray;
  7969. }
  7970. // print_r($roleArray);
  7971. $verifyList [$k] ['date'] = "";
  7972. $verifyList [$k] ['opinion'] = "";
  7973. $verifyList [$k] ['status'] = "";
  7974. if (empty ( $verifyStaff )) {
  7975. $verifyList [$k] ['date'] = "";
  7976. $verifyList [$k] ['opinion'] = "";
  7977. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7978. $verifyList [$k] ['status'] = 4;
  7979. $button = 4;
  7980. $flag = false;
  7981. }
  7982. } else {
  7983. foreach ( $verifyStaff as $m => $u ) {
  7984. if ($v [0] == $m) {
  7985. $verifyList [$k] ['date'] = $u ['date'];
  7986. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7987. $verifyList [$k] ['status'] = $u ['status'];
  7988. $flag = false;
  7989. break;
  7990. }
  7991. }
  7992. $endStaffArray = end ( $verifyStaff );
  7993. if (isset ( $endStaffArray ['ROLE'] )) {
  7994. } else {
  7995. $endKey = key ( $verifyStaff );
  7996. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7997. $button = 4;
  7998. $verifyList [$k] ['status'] = 4;
  7999. }
  8000. }
  8001. }
  8002. }
  8003. $rolename ['name'] = '';
  8004. if (! empty ( $roleId )) {
  8005. Doo::loadModel ( 'role' );
  8006. $role = new role ();
  8007. $rolename = $role->getOne ( array (
  8008. 'where' => 'rid=' . $roleId,
  8009. 'asArray' => true
  8010. ) );
  8011. }
  8012. if (! empty ( $verifyStaff ))
  8013. $endStaffArray = end ( $verifyStaff );
  8014. $KOP = false;
  8015. foreach ( $roleArrayCopy as $P => $A ) {
  8016. foreach ( $A as $MKI => $AVL ) {
  8017. if (! empty ( $verifyStaff )) {
  8018. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8019. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8020. $button = 4;
  8021. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8022. }
  8023. foreach ( $verifyStaff as $m => $u ) {
  8024. $AVLFK = $AVL [0] . '_R';
  8025. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8026. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8027. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8028. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8029. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8030. break;
  8031. }
  8032. }
  8033. } else {
  8034. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8035. $button = 4;
  8036. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8037. }
  8038. }
  8039. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8040. $KOP = true;
  8041. }
  8042. }
  8043. foreach ( $roleArrayCopy as $k => $v ) {
  8044. foreach ( $verifyList as $m => $n ) {
  8045. if ($n [0] == $k) {
  8046. array_splice ( $verifyList, $m, 1, $v );
  8047. }
  8048. }
  8049. }
  8050. $receiptList [$key] ['verifyList'] = $verifyList;
  8051. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8052. 'where' => 'sid=' . $value ['staff'],
  8053. 'asArray' => true
  8054. ) );
  8055. $receiptList [$key] ['button'] = $button;
  8056. }
  8057. $mothHtml = "";
  8058. for($i = 1; $i <= 12; $i ++) {
  8059. if ($month == $i)
  8060. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8061. else
  8062. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8063. }
  8064. // 获取审批日志
  8065. Doo::loadModel ( 'receiptLog' );
  8066. $receiptLog = new receiptLog ();
  8067. $rlList = array ();
  8068. $rlInfo = $receiptLog->getOne ( array (
  8069. 'where' => 'rid=' . $rid . ' and status=4',
  8070. 'asArray' => true
  8071. ) );
  8072. $tijdate = $receiptLog->getOne ( array (
  8073. 'where' => 'rid=' . $rid . ' and status=2',
  8074. 'asc' => 'rlid',
  8075. 'asArray' => true
  8076. ) );
  8077. if (! empty ( $rlInfo )) {
  8078. $rlList = $receiptLog->find ( array (
  8079. 'where' => 'rid=' . $rid,
  8080. 'asc' => 'rlid',
  8081. 'asArray' => true
  8082. ) );
  8083. }
  8084. $receiptList [0] ['rlList'] = $rlList;
  8085. $enclosurList = $enclosur->find ( array (
  8086. 'where' => 'rid=' . $rid,
  8087. 'asArray' => true
  8088. ) );
  8089. $enclosurHtml = '';
  8090. foreach ( $enclosurList as $value ) {
  8091. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8092. }
  8093. $data ['enclosurHtml'] = $enclosurHtml;
  8094. $data ['rolename'] = $rolename ['name'];
  8095. $data ['datetij'] = $tijdate ['date'];
  8096. $data ['mothHtml'] = $mothHtml;
  8097. $data ['receiptList'] = $receiptList;
  8098. $data ['receiptApprovalCount'] = count ( $receiptList );
  8099. $data ['year'] = $year;
  8100. $data ['categoryList'] = $categoryList;
  8101. $data ['staffList'] = $staffList;
  8102. $data ['cid'] = $cid;
  8103. $data ['sid'] = $sid;
  8104. $data ['status'] = 0;
  8105. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8106. $ap = 4;
  8107. } else
  8108. $data ['status'] = $receiptList [0] ['status'];
  8109. if ($receiptList [0] ['status'] == 4) {
  8110. $data ['status'] = 5;
  8111. $ap = 0;
  8112. }
  8113. $data ['ap'] = $ap;
  8114. $data ['memu'] = "receipt";
  8115. $data ['staff'] = $this->staff;
  8116. $data ['receiptMemu'] = 'approval';
  8117. $data ['verifyId'] = $this->verifyId;
  8118. $data ['executeId'] = $this->executeId;
  8119. $this->render ( "/admin/saeaReportListReport", $data );
  8120. }
  8121. function approvalEdi() {
  8122. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8123. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8124. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8125. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8126. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8127. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8128. if (empty ( $status ))
  8129. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8130. $vidList = array ();
  8131. $button = 0;
  8132. Doo::loadModel ( 'verify' );
  8133. Doo::loadModel ( 'receipt' );
  8134. Doo::loadModel ( 'staff' );
  8135. $staff = new staff ();
  8136. $receipt = new receipt ();
  8137. $verify = new verify ();
  8138. Doo::loadModel ( 'L_category' );
  8139. $Lcategory = new L_category ();
  8140. Doo::loadModel ( 'enclosur' );
  8141. $enclosur = new enclosur ();
  8142. // user verify ID
  8143. $verifyDetail = $verify->find ( array (
  8144. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8145. 'asArray' => true
  8146. ) );
  8147. foreach ( $verifyDetail as $key => $value ) {
  8148. array_push ( $vidList, $value ['vid'] );
  8149. }
  8150. $vid = implode ( ",", $vidList );
  8151. if (empty ( $verifyDetail ))
  8152. $vid = 0;
  8153. $categoryList = $Lcategory->find ( array (
  8154. 'asArray' => true
  8155. ) );
  8156. $staffList = $staff->find ( array (
  8157. 'where' => 'cid=' . $cid,
  8158. 'asArray' => true
  8159. ) );
  8160. $ap = "";
  8161. if ($status == 4) {
  8162. $ap = 4;
  8163. $status = 2;
  8164. }
  8165. // get Receipt By verifyID status 2
  8166. $receiptList = $receipt->find ( array (
  8167. 'where' => 'rid =' . $rid,
  8168. 'desc' => 'rid',
  8169. 'asArray' => true
  8170. ) );
  8171. $Locate = 0;
  8172. $roleId = 0;
  8173. if ($ap == 4)
  8174. $status = 4;
  8175. foreach ( $receiptList as $key => $value ) {
  8176. $receiptList [$key] ['Locate'] = $Locate;
  8177. $Locate ++;
  8178. $receiptList [$key] ['reviseDetail'] = array ();
  8179. if (! empty ( $value ['reviseDetail'] ))
  8180. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8181. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8182. $categoryDetil = $Lcategory->getOne ( array (
  8183. 'where' => 'cid=' . $value ['cid'],
  8184. 'asArray' => true
  8185. ) );
  8186. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8187. // 检测编辑状态
  8188. $verifyList = $verify->getOne ( array (
  8189. 'where' => 'vid=' . $value ['verify'],
  8190. 'asArray' => true
  8191. ) );
  8192. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8193. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8194. // print_r($verifyList);
  8195. //
  8196. // if (empty($verifyStaff)){
  8197. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8198. // $verifyList[0]['status']=4;$button=4;
  8199. // }
  8200. //
  8201. // }else{
  8202. //
  8203. // }
  8204. // die;
  8205. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8206. // echo array_search("green",$a);
  8207. //
  8208. Doo::loadModel ( 'role' );
  8209. $role = new role ();
  8210. // print_r($verifyList);
  8211. $flag = true;
  8212. $roleKey = 0;
  8213. $endStaffArray = array ();
  8214. $roleArrayCopy = array ();
  8215. foreach ( $verifyList as $k => $v ) {
  8216. // init verifyStaff
  8217. if ($v [1] == 'ROLE') {
  8218. if (! empty ( $verifyStaff )) {
  8219. $endStaffArray = end ( $verifyStaff );
  8220. if ($v [0] == $endStaffArray ['nextStaff']) {
  8221. $roleId = $v [0];
  8222. }
  8223. }
  8224. $roleVerify = json_decode ( $v [3], true );
  8225. $roleKey = $k;
  8226. $roleArray = array ();
  8227. $rolename = $role->getOne ( array (
  8228. 'where' => 'rid=' . $v [0],
  8229. 'asArray' => true
  8230. ) );
  8231. foreach ( $roleVerify as $o => $p ) {
  8232. $staffID = explode ( '_', $p );
  8233. $staffInfo = $staff->getOne ( array (
  8234. 'where' => 'sid=' . $staffID [0],
  8235. 'asArray' => true
  8236. ) );
  8237. // print_r($staffID);
  8238. $exp = array (
  8239. 0 => $staffInfo ['sid'],
  8240. 1 => $staffID [1],
  8241. 2 => $staffInfo ['avatar'],
  8242. 'date' => '',
  8243. 'date' => '',
  8244. 'opinion' => '',
  8245. 'status' => '',
  8246. 'rolename' => $rolename ['name']
  8247. );
  8248. array_push ( $roleArray, $exp );
  8249. }
  8250. $roleArrayCopy [$v [0]] = $roleArray;
  8251. // $verifyList[$k]['roleArray']=$roleArray;
  8252. }
  8253. // print_r($roleArray);
  8254. $verifyList [$k] ['date'] = "";
  8255. $verifyList [$k] ['opinion'] = "";
  8256. $verifyList [$k] ['status'] = "";
  8257. if (empty ( $verifyStaff )) {
  8258. $verifyList [$k] ['date'] = "";
  8259. $verifyList [$k] ['opinion'] = "";
  8260. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8261. $verifyList [$k] ['status'] = 4;
  8262. $button = 4;
  8263. $flag = false;
  8264. }
  8265. } else {
  8266. foreach ( $verifyStaff as $m => $u ) {
  8267. if ($v [0] == $m) {
  8268. $verifyList [$k] ['date'] = $u ['date'];
  8269. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8270. $verifyList [$k] ['status'] = $u ['status'];
  8271. $flag = false;
  8272. break;
  8273. }
  8274. }
  8275. $endStaffArray = end ( $verifyStaff );
  8276. if (isset ( $endStaffArray ['ROLE'] )) {
  8277. } else {
  8278. $endKey = key ( $verifyStaff );
  8279. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8280. $button = 4;
  8281. $verifyList [$k] ['status'] = 4;
  8282. }
  8283. }
  8284. // print_r($endStaffArray);die;
  8285. // if (empty($verifyStaff)){
  8286. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8287. // $verifyList[$k]['status']=4;$button=4;
  8288. // }
  8289. //
  8290. // }else{
  8291. //
  8292. // }
  8293. // if($flag){//检测可编辑
  8294. // if($v[0]==$this->staff[0]['sid']){
  8295. // $verifyList[$k]['status']=4;$button=4;
  8296. // }
  8297. // }
  8298. }
  8299. }
  8300. $rolename ['name'] = '';
  8301. if (! empty ( $roleId )) {
  8302. Doo::loadModel ( 'role' );
  8303. $role = new role ();
  8304. $rolename = $role->getOne ( array (
  8305. 'where' => 'rid=' . $roleId,
  8306. 'asArray' => true
  8307. ) );
  8308. }
  8309. if (! empty ( $verifyStaff ))
  8310. $endStaffArray = end ( $verifyStaff );
  8311. $KOP = false;
  8312. foreach ( $roleArrayCopy as $P => $A ) {
  8313. foreach ( $A as $MKI => $AVL ) {
  8314. if (! empty ( $verifyStaff )) {
  8315. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8316. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8317. $button = 4;
  8318. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8319. }
  8320. foreach ( $verifyStaff as $m => $u ) {
  8321. $AVLFK = $AVL [0] . '_R';
  8322. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8323. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8324. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8325. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8326. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8327. break;
  8328. }
  8329. }
  8330. } else {
  8331. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8332. $button = 4;
  8333. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8334. }
  8335. }
  8336. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8337. $KOP = true;
  8338. }
  8339. }
  8340. // print_r($roleArrayCopy);
  8341. // echo $roleKey;
  8342. foreach ( $roleArrayCopy as $k => $v ) {
  8343. foreach ( $verifyList as $m => $n ) {
  8344. if ($n [0] == $k) {
  8345. array_splice ( $verifyList, $m, 1, $v );
  8346. }
  8347. }
  8348. }
  8349. // if ($KOP)
  8350. // array_splice($verifyList,$roleKey,1,$roleArray);
  8351. // print_r($verifyList);
  8352. $receiptList [$key] ['verifyList'] = $verifyList;
  8353. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8354. 'where' => 'sid=' . $value ['staff'],
  8355. 'asArray' => true
  8356. ) );
  8357. $receiptList [$key] ['button'] = $button;
  8358. }
  8359. // $data['verifyDetail']=$verifyDetail;
  8360. $mothHtml = "";
  8361. for($i = 1; $i <= 12; $i ++) {
  8362. if ($month == $i)
  8363. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8364. else
  8365. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8366. }
  8367. // 获取审批日志
  8368. Doo::loadModel ( 'receiptLog' );
  8369. $receiptLog = new receiptLog ();
  8370. $rlList = array ();
  8371. $rlInfo = $receiptLog->getOne ( array (
  8372. 'where' => 'rid=' . $rid . ' and status=4',
  8373. 'asArray' => true
  8374. ) );
  8375. $tijdate = $receiptLog->getOne ( array (
  8376. 'where' => 'rid=' . $rid . ' and status=2',
  8377. 'asc' => 'rlid',
  8378. 'asArray' => true
  8379. ) );
  8380. if (! empty ( $rlInfo )) {
  8381. $rlList = $receiptLog->find ( array (
  8382. 'where' => 'rid=' . $rid,
  8383. 'asc' => 'rlid',
  8384. 'asArray' => true
  8385. ) );
  8386. }
  8387. $receiptList [0] ['rlList'] = $rlList;
  8388. $enclosurList = $enclosur->find ( array (
  8389. 'where' => 'rid=' . $rid,
  8390. 'asArray' => true
  8391. ) );
  8392. $enclosurHtml = '';
  8393. foreach ( $enclosurList as $value ) {
  8394. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8395. }
  8396. $data ['enclosurHtml'] = $enclosurHtml;
  8397. $data ['rolename'] = $rolename ['name'];
  8398. $data ['datetij'] = $tijdate ['date'];
  8399. $data ['mothHtml'] = $mothHtml;
  8400. $data ['receiptList'] = $receiptList;
  8401. $data ['receiptApprovalCount'] = count ( $receiptList );
  8402. $data ['status'] = $status;
  8403. $data ['year'] = $year;
  8404. $data ['categoryList'] = $categoryList;
  8405. $data ['staffList'] = $staffList;
  8406. $data ['cid'] = $cid;
  8407. $data ['sid'] = $sid;
  8408. $data ['ap'] = $ap;
  8409. $data ['memu'] = "receipt";
  8410. $data ['staff'] = $this->staff;
  8411. $data ['receiptMemu'] = 'approval';
  8412. $data ['verifyId'] = $this->verifyId;
  8413. $data ['executeId'] = $this->executeId;
  8414. $this->render ( "/admin/saeaReportListReport", $data );
  8415. }
  8416. function remittanceHky() {
  8417. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8418. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8419. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8420. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8421. $page_size = 15;
  8422. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8423. Doo::loadModel ( 'receipt' );
  8424. $receipt = new receipt ();
  8425. Doo::loadModel ( 'staff' );
  8426. $staff = new staff ();
  8427. $dateCondition = " and Year(executeDate) =" . $year;
  8428. if ($moth != 'MONTH')
  8429. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8430. if ($day != 'DAY' && $moth != 'MONTH')
  8431. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8432. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8433. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8434. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8435. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8436. $dayList = $receipt->find ( array (
  8437. 'select' => 'executeDate,sum(amount) as amount',
  8438. 'where' => $sql,
  8439. 'desc' => 'executeDate',
  8440. 'groupby' => 'executeDate',
  8441. 'limit' => $limit,
  8442. 'asArray' => true
  8443. ) );
  8444. // print_r($dayList);
  8445. foreach ( $dayList as $key => $value ) {
  8446. $remitString = "";
  8447. $receiptList = $receipt->find ( array (
  8448. 'select' => 'rid,executeDate,amount,staff,cid',
  8449. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8450. 'desc' => 'executeDate',
  8451. 'asArray' => true
  8452. ) );
  8453. foreach ( $receiptList as $k => $v ) {
  8454. $sinfo = $staff->getOne ( array (
  8455. 'select' => 'username,category',
  8456. 'where' => ' sid=' . $v ['staff'],
  8457. 'asArray' => true
  8458. ) );
  8459. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8460. }
  8461. $dayList [$key] ['staff'] = $remitString;
  8462. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8463. }
  8464. // print_r($dayList);
  8465. $mothHtml = "";
  8466. for($i = 1; $i <= 12; $i ++) {
  8467. if ($moth == $i)
  8468. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8469. else
  8470. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8471. }
  8472. $dayHtml = "";
  8473. if ($day != "DAY" || $moth != "MONTH") {
  8474. for($i = 1; $i <= 31; $i ++) {
  8475. if ($day == $i)
  8476. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8477. else
  8478. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8479. }
  8480. }
  8481. $dateHtml = "";
  8482. $now = date ( "Y" );
  8483. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8484. if ($YEARD <= $now) {
  8485. $dateHtml .= '<option ';
  8486. if ($year == $YEARD) {
  8487. $dateHtml .= 'selected ';
  8488. }
  8489. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8490. }
  8491. }
  8492. $data ['dateHtml'] = $dateHtml;
  8493. $data ['page'] = $pageinfo;
  8494. $data ['year'] = $year;
  8495. $data ['moth'] = $moth;
  8496. $data ['day'] = $day;
  8497. $data ['get'] = $get;
  8498. $data ['dayHtml'] = $dayHtml;
  8499. $data ['mothHtml'] = $mothHtml;
  8500. $data ['receiptList'] = $dayList;
  8501. $data ['memu'] = "receipt";
  8502. $data ['staff'] = $this->staff;
  8503. $data ['receiptMemu'] = 'remittanceHky';
  8504. $data ['verifyId'] = $this->verifyId;
  8505. $data ['executeId'] = $this->executeId;
  8506. $this->render ( "/admin/remittanceHky", $data );
  8507. }
  8508. function remittancep() {
  8509. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8510. Doo::loadModel ( 'receipt' );
  8511. $receipt = new receipt ();
  8512. Doo::loadModel ( 'staff' );
  8513. $staff = new staff ();
  8514. Doo::loadClass ( 'XDeode' );
  8515. $XDeode = new XDeode ( 5 );
  8516. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8517. $rplist = $receipt->find ( array (
  8518. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8519. 'asArray' => true
  8520. ) );
  8521. $dayList = $receipt->find ( array (
  8522. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8523. 'desc' => 'executeDate',
  8524. 'groupby' => 'staff',
  8525. 'asArray' => true
  8526. ) );
  8527. $html = '';
  8528. foreach ( $dayList as $key => $value ) {
  8529. $sinfo = $staff->getOne ( array (
  8530. 'select' => 'username,category',
  8531. 'where' => ' sid=' . $value ['staff'],
  8532. 'asArray' => true
  8533. ) );
  8534. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8535. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8536. $au = 0;
  8537. foreach ( $rplist as $k => $v ) {
  8538. if ($value ['staff'] == $v ['staff']) {
  8539. $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>';
  8540. $au += $v ['amount'];
  8541. }
  8542. }
  8543. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8544. }
  8545. $data ['html'] = $html;
  8546. $data ['memu'] = "receipt";
  8547. $data ['staff'] = $this->staff;
  8548. $data ['receiptMemu'] = 'remittanceHky';
  8549. $data ['verifyId'] = $this->verifyId;
  8550. $data ['executeId'] = $this->executeId;
  8551. $this->render ( "/admin/remittancep", $data );
  8552. }
  8553. function ajaxGetReceiptDetails() {
  8554. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8555. Doo::loadClass ( 'XDeode' );
  8556. $XDeode = new XDeode ( 5 );
  8557. $rid = $XDeode->decode ( $rid );
  8558. if (empty ( $rid )) {
  8559. echo json_encode ( array (
  8560. 'status' => 2,
  8561. 'msg' => 'illegal request'
  8562. ) );
  8563. die ();
  8564. }
  8565. Doo::loadModel ( 'receipt' );
  8566. $receipt = new receipt ();
  8567. Doo::loadModel ( 'staff' );
  8568. $staff = new staff ();
  8569. $rinfo = $receipt->getOne ( array (
  8570. 'where' => 'rid= ' . $rid,
  8571. 'asArray' => true
  8572. ) );
  8573. $sinfo = $staff->getOne ( array (
  8574. 'select' => 'username,category',
  8575. 'where' => ' sid=' . $rinfo ['staff'],
  8576. 'asArray' => true
  8577. ) );
  8578. $rinfo ['reviseDetail'] = array ();
  8579. if (! empty ( $rinfo ['reviseDetail'] ))
  8580. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8581. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8582. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8583. $rinfo ['category'] = $sinfo ['category'];
  8584. $verifyStaff = array ();
  8585. if (! empty ( $rinfo ['verifyStaff'] ))
  8586. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8587. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8588. $rinfo ['relust'] = $relust;
  8589. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8590. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8591. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8592. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8593. // 费用执行人相关数据
  8594. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8595. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8596. foreach ( $executeCopy as $k => $v ) {
  8597. $executeCopy [$k] ['date'] = '';
  8598. $executeCopy [$k] ['opinion'] = '';
  8599. $executeCopy [$k] ['status'] = '';
  8600. if (! empty ( $executeStaff ))
  8601. foreach ( $executeStaff as $m => $u ) {
  8602. if ($v [0] == $m) {
  8603. $executeCopy [$k] ['date'] = $u ['date'];
  8604. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8605. $executeCopy [$k] ['status'] = $u ['status'];
  8606. break;
  8607. }
  8608. }
  8609. }
  8610. $rinfo ['executeCopy'] = $executeCopy;
  8611. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8612. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8613. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8614. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8615. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8616. $html .= '<tr><th>' . $value ['name'] . '</th>
  8617. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8618. }
  8619. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8620. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8621. <tr><th class="taC" colspan="2">费用说明</th>
  8622. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8623. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8624. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8625. </tbody></table>';
  8626. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8627. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8628. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8629. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8630. $html .= '<tr><th>' . $value ['name'] . '</th>
  8631. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8632. }
  8633. $html .= '<tr><th class="taR">合计</th>
  8634. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8635. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8636. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8637. $html .= '<tr><th>' . $value ['name'] . '</th>
  8638. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8639. }
  8640. $html .= '<tr><th class="taR">合计</th>
  8641. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8642. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8643. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8644. $html .= '<tr><th>' . $value ['name'] . '</th>
  8645. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8646. }
  8647. $html .= '<tr><th class="taR">合计</th>
  8648. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8649. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8650. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8651. $html .= '<tr><th>' . $value ['name'] . '</th>
  8652. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8653. }
  8654. $html .= '<tr><th class="taR">合计</th>
  8655. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8656. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8657. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8658. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8659. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8660. }
  8661. $html .= '<tr><th class="taR">合计</th>
  8662. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8663. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8664. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8665. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8666. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8667. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8668. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8669. <tr';
  8670. if ($rinfo ['relust'] >= 0) {
  8671. $html .= 'class="success"';
  8672. } else {
  8673. $html .= 'class="error"';
  8674. }
  8675. $html .= '><td class="taR"><b>借款结余</b></td>
  8676. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8677. </tbody></table>
  8678. ';
  8679. }
  8680. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8681. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8682. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8683. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8684. $html .= '<tr><th>' . $value ['name'] . '</th>
  8685. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8686. }
  8687. $html .= '<tr><th class="taR">合计</th>
  8688. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8689. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8690. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8691. <tr><th class="taC" colspan="2">费用说明</th>
  8692. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8693. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8694. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8695. </tbody></table>';
  8696. } else {
  8697. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8698. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8699. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8700. $html .= '<tr><th>' . $value ['name'] . '</th>
  8701. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8702. }
  8703. $html .= '<tr><th class="taR">合计</th>
  8704. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8705. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8706. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8707. $html .= '<tr><th>' . $value ['name'] . '</th>
  8708. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8709. }
  8710. $html .= '<tr><th class="taR">合计</th>
  8711. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8712. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8713. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8714. $html .= '<tr><th>' . $value ['name'] . '</th>
  8715. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8716. }
  8717. $html .= '<tr><th class="taR">合计</th>
  8718. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8719. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8720. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8721. $html .= '<tr><th>' . $value ['name'] . '</th>
  8722. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8723. }
  8724. $html .= '<tr><th class="taR">合计</th>
  8725. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8726. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8727. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8728. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8729. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8730. }
  8731. $html .= '<tr><th class="taR">合计</th>
  8732. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8733. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8734. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8735. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8736. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8737. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8738. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8739. $html .= '</tbody></table>';
  8740. /*
  8741. * <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>
  8742. */
  8743. }
  8744. // print_r($verifyStaff);die;
  8745. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8746. foreach ( $verifyStaff as $key => $value ) {
  8747. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8748. $sinfo = $staff->getOne ( array (
  8749. 'select' => 'username',
  8750. 'where' => ' sid=' . $key,
  8751. 'asArray' => true
  8752. ) );
  8753. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8754. }
  8755. $html .= '</tbody></table>';
  8756. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8757. foreach ( $rinfo ['executeCopy'] as $value ) {
  8758. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8759. }
  8760. $html .= '</tbody></table>';
  8761. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8762. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8763. </tr></table>';
  8764. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8765. echo json_encode ( array (
  8766. 'status' => 1,
  8767. 'html' => $html
  8768. ) );
  8769. die ();
  8770. }
  8771. /**
  8772. * 删除附件
  8773. */
  8774. function ajaxRemEnclousur() {
  8775. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8776. if (empty ( $key ))
  8777. echo json_encode ( array (
  8778. 'status' => 2
  8779. ) );
  8780. Doo::loadModel ( 'enclosur' );
  8781. $enclosur = new enclosur ();
  8782. $enclosur->delEnclosurByEid ( $key );
  8783. echo json_encode ( array (
  8784. 'status' => 1
  8785. ) );
  8786. }
  8787. function remittance() {
  8788. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8789. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8790. Doo::loadModel ( 'receipt' );
  8791. $receipt = new receipt ();
  8792. Doo::loadModel ( 'staff' );
  8793. $staff = new staff ();
  8794. $dateCondition = " and Year(pastDate) =" . $year;
  8795. if (! empty ( $month ))
  8796. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8797. // get Receipt By verifyID status 1
  8798. $receiptList = $receipt->find ( array (
  8799. 'select' => 'sum(sum) as sum,staff,pastDate',
  8800. 'where' => ' status=1' . $dateCondition,
  8801. 'desc' => 'pastDate',
  8802. 'groupby' => 'staff,pastDate',
  8803. 'asArray' => true
  8804. ) );
  8805. $dateList = $receipt->find ( array (
  8806. 'select' => 'pastDate,verifyStaff',
  8807. 'where' => ' status=1' . $dateCondition,
  8808. 'desc' => 'pastDate',
  8809. 'groupby' => 'pastDate',
  8810. 'asArray' => true
  8811. ) );
  8812. $dataList = array ();
  8813. foreach ( $dateList as $d => $a ) {
  8814. $dataList [$a ['pastDate']] = array ();
  8815. $daySum = 0;
  8816. foreach ( $receiptList as $key => $value ) {
  8817. if ($a ['pastDate'] == $value ['pastDate']) {
  8818. $oderList = $receipt->find ( array (
  8819. 'select' => 'receiptOrder',
  8820. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8821. 'asArray' => true
  8822. ) );
  8823. $list = array ();
  8824. $html = "";
  8825. foreach ( $oderList as $v ) {
  8826. array_push ( $list, $v ['receiptOrder'] );
  8827. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8828. }
  8829. $receiptList [$key] ['receiptOrder'] = $html;
  8830. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8831. $sinfo = $staff->getOne ( array (
  8832. 'select' => 'username ',
  8833. 'where' => ' sid=' . $value ['staff'],
  8834. 'asArray' => true
  8835. ) );
  8836. $receiptList [$key] ['username'] = $sinfo ['username'];
  8837. $daySum += $value ['sum'];
  8838. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8839. }
  8840. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8841. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8842. }
  8843. }
  8844. // print_r($dataList);
  8845. $data ['dataList'] = $dataList;
  8846. $mothHtml = "";
  8847. for($i = 1; $i <= 12; $i ++) {
  8848. if ($month == $i)
  8849. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8850. else
  8851. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8852. }
  8853. $data ['year'] = $year;
  8854. $data ['mothHtml'] = $mothHtml;
  8855. $data ['memu'] = "receipt";
  8856. $data ['staff'] = $this->staff;
  8857. $data ['receiptMemu'] = 'approval';
  8858. $data ['verifyId'] = $this->verifyId;
  8859. $data ['executeId'] = $this->executeId;
  8860. $this->render ( "/admin/saeaReportListPay", $data );
  8861. }
  8862. /**
  8863. * 金额调整,提高稳定性
  8864. * @return string
  8865. */
  8866. function revocationAdjustment() {
  8867. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8868. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8869. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8870. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8871. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8872. Doo::loadClass ( 'XDeode' );
  8873. $XDeode = new XDeode ( 5 );
  8874. Doo::loadModel ( 'receipt' );
  8875. $receipt = new receipt ();
  8876. $sid = $XDeode->decode ( $sidKey );
  8877. $rid = $XDeode->decode ( $ridKey );
  8878. $reviseKey = $XDeode->decode ( $reviseKey );
  8879. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8880. die ( 'illegal request' );
  8881. $receiptDetail = $receipt->getOne ( array (
  8882. 'where' => 'rid=' . $rid,
  8883. 'asArray' => true
  8884. ) );
  8885. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8886. die ( 'illegal request' );
  8887. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8888. if (! isset ( $reviseDetail [$reviseKey] ))
  8889. die ( 'illegal request' );
  8890. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8891. unset ( $reviseDetail [$reviseKey] );
  8892. $revisePrice = 0;
  8893. foreach ( $reviseDetail as $key => $value ) {
  8894. $revisePrice += $value ['price'];
  8895. }
  8896. $reviseDetailString = json_encode ( $reviseDetail );
  8897. $receipt->reviseDetail = $reviseDetailString;
  8898. $receipt->sum = $receiptDetail ['sum'] - $price;
  8899. $receipt->revisePrice = $revisePrice;
  8900. $receipt->update ( array (
  8901. 'where' => 'rid=' . $rid
  8902. ) );
  8903. return '/receiptburEdi/' . $rid;
  8904. } else
  8905. die ( 'illegal request2' );
  8906. }
  8907. function updateApprovalReceipt() {
  8908. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8909. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8910. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8911. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8912. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8913. if (! empty ( $rid )) {
  8914. Doo::loadModel ( "verify" );
  8915. $verify = new verify ();
  8916. Doo::loadModel ( "receiptDetail" );
  8917. $receiptDetailObj = new receiptDetail ();
  8918. Doo::loadModel ( "itemStatistics" );
  8919. Doo::loadModel ( "statistics" );
  8920. $statistics = new statistics ();
  8921. $itemStatistics = new itemStatistics ();
  8922. Doo::loadModel ( "receipt" );
  8923. $receipt = new receipt ();
  8924. $receiptDetail = $receipt->getOne ( array (
  8925. 'where' => 'rid=' . $rid . ' and status=2 ',
  8926. 'asArray' => true
  8927. ) );
  8928. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8929. $nsflag = true;
  8930. foreach ( $nslist as $value ) {
  8931. if ($value == $this->staff ['0'] ['sid']) {
  8932. $nsflag = false;
  8933. break;
  8934. }
  8935. }
  8936. if (empty ( $receiptDetail ) || $nsflag)
  8937. return "/approvalExpenses/pendApproval";
  8938. $verifyDetail = $verify->getOne ( array (
  8939. 'where' => ' vid =' . $receiptDetail ['verify'],
  8940. 'asArray' => true
  8941. ) );
  8942. $verifyString = $verifyDetail ['staff'];
  8943. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8944. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8945. if (empty ( $opinion )) {
  8946. if ($status == 3)
  8947. $opinion = "终止";
  8948. else
  8949. $opinion = "同意支付";
  8950. }
  8951. $nowStaff = 0;
  8952. $nowStaffList = array ();
  8953. if (empty ( $verifyStaff )) {
  8954. // 还需加入是否已经进入角色审批
  8955. if ($verifyDetail [0] [1] == 'ROLE') {
  8956. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8957. foreach ( $vStaffString as $key => $value ) {
  8958. $staffK = explode ( "_", $value );
  8959. if ($staffK [0] != $this->staff [0] ['sid'])
  8960. array_push ( $nowStaffList, $staffK [0] );
  8961. }
  8962. // print_r($verifyDetail);
  8963. // die;
  8964. if (! empty ( $nowStaffList )) {
  8965. $nowStaff = implode ( ',', $nowStaffList );
  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 [0] [0],
  8972. 'ROLE' => 1
  8973. )
  8974. );
  8975. } else {
  8976. $nowStaff = $verifyDetail [1] [0];
  8977. $verifyStaff = array (
  8978. $this->staff [0] ['sid'] . "_R" => array (
  8979. 'date' => date ( 'Y-m-d' ),
  8980. 'opinion' => $opinion,
  8981. 'status' => $status,
  8982. 'nextStaff' => $verifyDetail [1] [0]
  8983. )
  8984. );
  8985. }
  8986. } else {
  8987. if ($verifyDetail [1] [1] == 'ROLE') {
  8988. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8989. // echo "dd";
  8990. foreach ( $vStaffString as $key => $value ) {
  8991. $staffK = explode ( "_", $value );
  8992. array_push ( $nowStaffList, $staffK [0] );
  8993. }
  8994. $nowStaff = implode ( ',', $nowStaffList );
  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. 'ROLE' => 1
  9002. )
  9003. );
  9004. } else {
  9005. $nowStaff = $verifyDetail [1] [0];
  9006. $verifyStaff = array (
  9007. $this->staff [0] ['sid'] => array (
  9008. 'date' => date ( 'Y-m-d' ),
  9009. 'opinion' => $opinion,
  9010. 'status' => $status,
  9011. 'nextStaff' => $verifyDetail [1] [0]
  9012. )
  9013. );
  9014. }
  9015. }
  9016. if ($status == 3)
  9017. $verifyStaff = array (
  9018. 'final' => $status,
  9019. $this->staff [0] ['sid'] => array (
  9020. 'date' => date ( 'Y-m-d' ),
  9021. 'opinion' => $opinion,
  9022. 'status' => $status
  9023. )
  9024. );
  9025. $vStaffString = json_encode ( $verifyStaff );
  9026. $receipt->nowStaff = $nowStaff;
  9027. $receipt->verifyStaff = $vStaffString;
  9028. } else {
  9029. $VS = end ( $verifyStaff );
  9030. // 非角色审批
  9031. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9032. $nextStaff = 0;
  9033. $roleSTF = false;
  9034. foreach ( $verifyDetail as $key => $value ) {
  9035. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9036. if (isset ( $verifyDetail [$key + 1] )) {
  9037. $nextStaff = $verifyDetail [$key + 1] [0];
  9038. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9039. $roleSTF = true;
  9040. }
  9041. break;
  9042. }
  9043. }
  9044. if (! $roleSTF) {
  9045. $nowStaff = $nextStaff;
  9046. $verifyStaff [$this->staff [0] ['sid']] = array (
  9047. 'date' => date ( 'Y-m-d' ),
  9048. 'opinion' => $opinion,
  9049. 'status' => $status,
  9050. 'nextStaff' => $nextStaff
  9051. );
  9052. } else {
  9053. // 获取角色下的所有用户ID
  9054. $nowStaffList = array ();
  9055. foreach ( $verifyDetail as $vfk ) {
  9056. if ($vfk [1] == 'ROLE') {
  9057. $vStaffString = json_decode ( $vfk [3] );
  9058. foreach ( $vStaffString as $key => $value ) {
  9059. $staffK = explode ( "_", $value );
  9060. array_push ( $nowStaffList, $staffK [0] );
  9061. }
  9062. }
  9063. }
  9064. $nowStaff = implode ( ',', $nowStaffList );
  9065. $verifyStaff [$this->staff [0] ['sid']] = array (
  9066. 'date' => date ( 'Y-m-d' ),
  9067. 'opinion' => $opinion,
  9068. 'status' => $status,
  9069. 'nextStaff' => $nextStaff,
  9070. 'ROLE' => 0
  9071. );
  9072. }
  9073. if ($status == 3) {
  9074. $verifyStaff ['final'] = $status;
  9075. $verifyStaff [$this->staff [0] ['sid']] = array (
  9076. 'date' => date ( 'Y-m-d' ),
  9077. 'opinion' => $opinion,
  9078. 'status' => $status
  9079. );
  9080. }
  9081. $vStaffString = json_encode ( $verifyStaff );
  9082. $receipt->nowStaff = $nowStaff;
  9083. $receipt->verifyStaff = $vStaffString;
  9084. }
  9085. // 角色审批
  9086. if (isset ( $VS ['ROLE'] )) {
  9087. // 找出角色人 当前审批角色组
  9088. $verifyJSStaff = array ();
  9089. $nowStaffList2 = array ();
  9090. foreach ( $verifyDetail as $key => $value ) {
  9091. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9092. $verifyJSStaff = json_decode ( $value [3] );
  9093. foreach ( $verifyJSStaff as $m ) {
  9094. $staffK = explode ( "_", $m );
  9095. array_push ( $nowStaffList2, $staffK [0] );
  9096. }
  9097. // print_r($nowStaffList2);
  9098. }
  9099. }
  9100. $RoleVerifyStaff = array ();
  9101. foreach ( $verifyStaff as $key => $value ) {
  9102. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9103. foreach ( $nowStaffList2 as $m ) {
  9104. if ($key == $m . "_R")
  9105. $RoleVerifyStaff [$key] = $value;
  9106. }
  9107. }
  9108. }
  9109. // print_r($verifyStaff);
  9110. // print_r($nowStaffList2);
  9111. // print_r($RoleVerifyStaff);
  9112. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9113. // print_r($verifyJSStaff);
  9114. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9115. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9116. // 下一个审批人ID
  9117. $nextStaff = 0;
  9118. $falg = false;
  9119. foreach ( $verifyDetail as $key => $value ) {
  9120. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9121. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9122. $falg = true;
  9123. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9124. $nowStaffList = array ();
  9125. foreach ( $vStaffString as $v ) {
  9126. $staffK = explode ( "_", $v );
  9127. array_push ( $nowStaffList, $staffK [0] );
  9128. }
  9129. $nowStaff = implode ( ',', $nowStaffList );
  9130. $nextStaff = $verifyDetail [$key + 1] [0];
  9131. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9132. $nextStaff = $verifyDetail [$key + 1] [0];
  9133. $nowStaff = $nextStaff;
  9134. } else
  9135. $nowStaff = '';
  9136. break;
  9137. }
  9138. }
  9139. if ($falg)
  9140. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9141. 'date' => date ( 'Y-m-d' ),
  9142. 'opinion' => $opinion,
  9143. 'status' => $status,
  9144. 'nextStaff' => $nextStaff,
  9145. 'ROLE' => 1
  9146. );
  9147. else
  9148. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9149. 'date' => date ( 'Y-m-d' ),
  9150. 'opinion' => $opinion,
  9151. 'status' => $status,
  9152. 'nextStaff' => $nextStaff
  9153. );
  9154. // print_r($verifyStaff);
  9155. // echo $nowStaff;die;
  9156. } else { // 进入下一个角色或者审批人
  9157. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9158. //
  9159. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9160. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9161. 'date' => date ( 'Y-m-d' ),
  9162. 'opinion' => $opinion,
  9163. 'status' => $status,
  9164. 'nextStaff' => $VS ['nextStaff'],
  9165. 'ROLE' => 1
  9166. );
  9167. // print_r($verifyStaff);
  9168. // die;
  9169. }
  9170. if ($status == 3) {
  9171. $verifyStaff ['final'] = $status;
  9172. $verifyStaff [$this->staff [0] ['sid']] = array (
  9173. 'date' => date ( 'Y-m-d' ),
  9174. 'opinion' => $opinion,
  9175. 'status' => $status
  9176. );
  9177. }
  9178. $vStaffString = json_encode ( $verifyStaff );
  9179. $receipt->verifyStaff = $vStaffString;
  9180. $receipt->nowStaff = $nowStaff;
  9181. // die;
  9182. // }
  9183. // print_r($verifyStaff);
  9184. // die;
  9185. }
  9186. // print_r($verifyStaff);die;
  9187. }
  9188. // print_r($verifyDetail);
  9189. $roleKey = 0;
  9190. $roleId = 0;
  9191. $verifyDetailCopy = array ();
  9192. foreach ( $verifyDetail as $k => $v ) {
  9193. if ($v [1] == 'ROLE') {
  9194. $roleId = $v [0];
  9195. $roleVerify = json_decode ( $v [3], true );
  9196. $roleKey = $k;
  9197. $roleArray = array ();
  9198. foreach ( $roleVerify as $o => $p ) {
  9199. $staffID = explode ( '_', $p );
  9200. $exp = array (
  9201. 0 => $staffID [0],
  9202. 1 => $staffID [1]
  9203. );
  9204. array_push ( $roleArray, $exp );
  9205. }
  9206. $verifyDetailCopy [$v [0]] = $roleArray;
  9207. }
  9208. }
  9209. // print_r($verifyDetail);
  9210. foreach ( $verifyDetailCopy as $k => $v ) {
  9211. foreach ( $verifyDetail as $m => $n ) {
  9212. if ($n [0] == $k) {
  9213. array_splice ( $verifyDetail, $m, 1, $v );
  9214. }
  9215. }
  9216. }
  9217. // die;
  9218. // if (!empty($roleArray))
  9219. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9220. // echo $roleId;
  9221. // print_r($verifyStaff);
  9222. // print_r($verifyDetail);
  9223. // die;
  9224. Doo::loadModel ( "receiptLog" );
  9225. $receiptLog = new receiptLog ();
  9226. // 审批日志
  9227. if (! isset ( $verifyStaff ['final'] )) {
  9228. if (! empty ( $roleId )) {
  9229. Doo::loadModel ( "role" );
  9230. $role = new role ();
  9231. $roleInfo = $role->getOne ( array (
  9232. 'where' => 'rid=' . $roleId,
  9233. 'asArray' => true
  9234. ) );
  9235. $receiptLog->rolename = $roleInfo ['name'];
  9236. }
  9237. $receiptLog->username = $this->staff [0] ['username'];
  9238. $receiptLog->uid = $this->staff [0] ['sid'];
  9239. $receiptLog->date = date ( "Y-m-d" );
  9240. $receiptLog->opinion = $opinion;
  9241. $receiptLog->img = $this->staff [0] ['avatar'];
  9242. $receiptLog->status = 1;
  9243. $receiptLog->rid = $rid;
  9244. $receiptLog->insert ();
  9245. }
  9246. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9247. $receipt->verifyBreakup = $verifyString;
  9248. $receipt->status = 3;
  9249. $receiptDetailObj->status = 3;
  9250. $receiptDetailObj->update ( array (
  9251. 'where' => 'rid=' . $rid
  9252. ) );
  9253. if (! empty ( $roleId )) {
  9254. Doo::loadModel ( "role" );
  9255. $role = new role ();
  9256. $roleInfo = $role->getOne ( array (
  9257. 'where' => 'rid=' . $roleId,
  9258. 'asArray' => true
  9259. ) );
  9260. $receiptLog->rolename = $roleInfo ['name'];
  9261. }
  9262. $receiptLog->username = $this->staff [0] ['username'];
  9263. $receiptLog->uid = $this->staff [0] ['sid'];
  9264. $receiptLog->date = date ( "Y-m-d" );
  9265. $receiptLog->opinion = $opinion;
  9266. $receiptLog->img = $this->staff [0] ['avatar'];
  9267. $receiptLog->status = 3;
  9268. $receiptLog->rid = $rid;
  9269. $receiptLog->insert ();
  9270. //删除行程单
  9271. Doo::loadModel ( 'itinerary' );
  9272. $itinerary = new itinerary ();
  9273. $itinerary->delete ( array (
  9274. 'where' => 'rid="' . $rid . '"'
  9275. ) );
  9276. // 微信企业号通知
  9277. $this->setWXMsg ( $rid, 3 );
  9278. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9279. $receipt->status = 1;
  9280. $reviseSum = 0;
  9281. $receipt->verifyBreakup = $verifyString;
  9282. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9283. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9284. foreach ( $reviseDetail as $key => $value ) {
  9285. $receiptDetailObj = new receiptDetail ();
  9286. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9287. $receiptDetailObj->item = $value ['description'];
  9288. $receiptDetailObj->itemCategory = "报销金额调整";
  9289. $receiptDetailObj->price = $value ['price'];
  9290. $receiptDetailObj->date = $receiptDetail ['date'];
  9291. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9292. $receiptDetailObj->rid = $rid;
  9293. $receiptDetailObj->status = 1;
  9294. $receiptDetailObj->insert ();
  9295. $reviseSum += $value ['price'];
  9296. }
  9297. $itemStatistics = new itemStatistics ();
  9298. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9299. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9300. $itemStatistics->price = $reviseSum;
  9301. $itemStatistics->itemCategory = "报销金额调整";
  9302. $itemStatistics->date = $receiptDetail ['date'];
  9303. $itemStatistics->insert ();
  9304. }
  9305. $receiptDetailObj = new receiptDetail ();
  9306. $receiptDetailObj->status = 1;
  9307. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9308. $receiptDetailObj->update ( array (
  9309. 'where' => 'rid=' . $rid
  9310. ) );
  9311. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9312. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9313. $stat = $statistics->getOne ( array (
  9314. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9315. 'asArray' => true
  9316. ) );
  9317. if (empty ( $stat )) {
  9318. $statistics->date = $receiptDetail ['date'];
  9319. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9320. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9321. $statistics->agPrice = $receiptDetail ['sum'];
  9322. $statistics->rePrice = $reviseSum;
  9323. $statistics->insert ();
  9324. } else {
  9325. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9326. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9327. $statistics->update ( array (
  9328. 'where' => 'sid=' . $stat ['sid']
  9329. ) );
  9330. }
  9331. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9332. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9333. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9334. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9335. if ($key == "agencySum") {
  9336. $iStatistics = $itemStatistics->getOne ( array (
  9337. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9338. 'asArray' => true
  9339. ) );
  9340. if (empty ( $iStatistics )) {
  9341. $itemStatistics->cid = $receiptDetail ['cid'];
  9342. ;
  9343. $itemStatistics->staff = $receiptDetail ['staff'];
  9344. $itemStatistics->price = $value;
  9345. $itemStatistics->itemCategory = $this->AGENCY;
  9346. $itemStatistics->date = $receiptDetail ['date'];
  9347. $itemStatistics->insert ();
  9348. } else {
  9349. if (! empty ( $value )) {
  9350. $itemStatistics->price = $value + $iStatistics ['price'];
  9351. $itemStatistics->update ( array (
  9352. 'where' => 'sid=' . $iStatistics ['sid']
  9353. ) );
  9354. }
  9355. }
  9356. } elseif ($key == "travelSum") {
  9357. $iStatistics = $itemStatistics->getOne ( array (
  9358. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9359. 'asArray' => true
  9360. ) );
  9361. if (empty ( $iStatistics )) {
  9362. $itemStatistics->cid = $receiptDetail ['cid'];
  9363. $itemStatistics->staff = $receiptDetail ['staff'];
  9364. $itemStatistics->price = $value;
  9365. $itemStatistics->itemCategory = $this->TRAVEL;
  9366. $itemStatistics->date = $receiptDetail ['date'];
  9367. $itemStatistics->insert ();
  9368. } else {
  9369. if (! empty ( $value )) {
  9370. $itemStatistics->price = $value + $iStatistics ['price'];
  9371. $itemStatistics->update ( array (
  9372. 'where' => 'sid=' . $iStatistics ['sid']
  9373. ) );
  9374. }
  9375. }
  9376. } elseif ($key == "trainSum") {
  9377. $iStatistics = $itemStatistics->getOne ( array (
  9378. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9379. 'asArray' => true
  9380. ) );
  9381. if (empty ( $iStatistics )) {
  9382. $itemStatistics->cid = $receiptDetail ['cid'];
  9383. $itemStatistics->staff = $receiptDetail ['staff'];
  9384. $itemStatistics->price = $value;
  9385. $itemStatistics->itemCategory = $this->TRAIN;
  9386. $itemStatistics->date = $receiptDetail ['date'];
  9387. $itemStatistics->insert ();
  9388. } else {
  9389. if (! empty ( $value )) {
  9390. $itemStatistics->price = $value + $iStatistics ['price'];
  9391. $itemStatistics->update ( array (
  9392. 'where' => 'sid=' . $iStatistics ['sid']
  9393. ) );
  9394. }
  9395. }
  9396. } elseif ($key == "otherSum") {
  9397. $iStatistics = $itemStatistics->getOne ( array (
  9398. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9399. 'asArray' => true
  9400. ) );
  9401. if (empty ( $iStatistics )) {
  9402. $itemStatistics->cid = $receiptDetail ['cid'];
  9403. $itemStatistics->staff = $receiptDetail ['staff'];
  9404. $itemStatistics->price = $value;
  9405. $itemStatistics->itemCategory = $this->OTHER;
  9406. $itemStatistics->date = $receiptDetail ['date'];
  9407. $itemStatistics->insert ();
  9408. } else {
  9409. if (! empty ( $value )) {
  9410. $itemStatistics->price = $value + $iStatistics ['price'];
  9411. $itemStatistics->update ( array (
  9412. 'where' => 'sid=' . $iStatistics ['sid']
  9413. ) );
  9414. }
  9415. }
  9416. }
  9417. }
  9418. $receipt->pastDate = date ( "Y-m-d" );
  9419. // 微信企业号通知
  9420. $this->setWXMsg ( $rid, 1 );
  9421. }
  9422. //是否有流水
  9423. Doo::loadModel ( 'wasteBook' );
  9424. $wasteBook = new wasteBook ();
  9425. $accountType=3;
  9426. if ($receiptDetail['Rtype']==1){
  9427. $accountType=2;
  9428. }elseif($receiptDetail['Rtype']==2){
  9429. $accountType=4;
  9430. }
  9431. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9432. if (empty($wbDetail)){
  9433. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9434. $receipt->amount = $rsum;//$amount;
  9435. }
  9436. $receipt->update ( array (
  9437. 'where' => ' rid = ' . $rid
  9438. ) );
  9439. // 进入下一条审批费用新加需求
  9440. $vidList = array ();
  9441. $verifyDetail = $verify->find ( array (
  9442. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9443. 'asArray' => true
  9444. ) );
  9445. foreach ( $verifyDetail as $key => $value ) {
  9446. array_push ( $vidList, $value ['vid'] );
  9447. }
  9448. $vid = implode ( ",", $vidList );
  9449. if (empty ( $verifyDetail ))
  9450. $vid = 0;
  9451. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9452. $receipt = new receipt ();
  9453. $rd = $receipt->getOne ( array (
  9454. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9455. 'asc' => 'rid',
  9456. 'asArray' => true
  9457. ) );
  9458. if (empty ( $rd )) {
  9459. return '/approvalExpenses/pendApproval';
  9460. }
  9461. if ($rd ['Rtype'] == 1) {
  9462. if ($rd ['isBK'] == 1) {
  9463. return '/receiptburEdi/' . $rd ['rid'];
  9464. } else {
  9465. return '/expensesEdi/' . $rd ['rid'];
  9466. }
  9467. } elseif ($rd ['Rtype'] == 2) {
  9468. return '/remitApproval/' . $rd ['rid'];
  9469. } else {
  9470. return '/receiptburEdi/' . $rd ['rid'];
  9471. }
  9472. // return "/approvalExpenses/pendApproval";
  9473. }
  9474. }
  9475. function expensesRetreats() {
  9476. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9477. if (! empty ( $rid )) {
  9478. // 操作记录
  9479. Doo::loadModel ( "receipt" );
  9480. $receipt = new receipt ();
  9481. Doo::loadModel ( "receiptLog" );
  9482. $receiptLog = new receiptLog ();
  9483. Doo::loadModel ( "verify" );
  9484. $verify = new verify ();
  9485. $receiptInfo = $receipt->getOne ( array (
  9486. 'where' => 'rid=' . $rid,
  9487. 'asArray' => true
  9488. ) );
  9489. $vr = $verify->getOne ( array (
  9490. 'where' => 'vid=' . $receiptInfo ['verify'],
  9491. 'asArray' => true
  9492. ) );
  9493. $jd = json_decode ( $vr ['staff'] );
  9494. $roleId = 0;
  9495. foreach ( $jd as $key => $value ) {
  9496. if ($value [1] == 'ROLE') {
  9497. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9498. if ($pos !== false) {
  9499. $roleId = $value [0];
  9500. }
  9501. }
  9502. }
  9503. // 审批日志
  9504. // echo $roleId;die;
  9505. if (! empty ( $roleId )) {
  9506. Doo::loadModel ( "role" );
  9507. $role = new role ();
  9508. $roleInfo = $role->getOne ( array (
  9509. 'where' => 'rid=' . $roleId,
  9510. 'asArray' => true
  9511. ) );
  9512. $receiptLog->rolename = $roleInfo ['name'];
  9513. }
  9514. $receiptLog->username = $this->staff [0] ['username'];
  9515. $receiptLog->uid = $this->staff [0] ['sid'];
  9516. $receiptLog->date = date ( "Y-m-d" );
  9517. $receiptLog->opinion = '撤回';
  9518. $receiptLog->img = $this->staff [0] ['avatar'];
  9519. $receiptLog->status = 4;
  9520. $receiptLog->rid = $rid;
  9521. $receiptLog->insert ();
  9522. $receipt->status = 4;
  9523. $receipt->update ( array (
  9524. 'where' => 'rid=' . $rid
  9525. ) );
  9526. // 微信企业号通知
  9527. $this->setWXMsg ( $rid, 2 );
  9528. }
  9529. // echo "ddd";
  9530. return '/approvalExpenses/pendApproval';
  9531. }
  9532. function updateCheReceipt() {
  9533. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9534. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9535. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9536. if (! empty ( $rid )) {
  9537. // 操作记录
  9538. Doo::loadModel ( "receipt" );
  9539. $receipt = new receipt ();
  9540. Doo::loadModel ( "receiptLog" );
  9541. $receiptLog = new receiptLog ();
  9542. Doo::loadModel ( "verify" );
  9543. $verify = new verify ();
  9544. $receiptInfo = $receipt->getOne ( array (
  9545. 'where' => 'rid=' . $rid . ' and status=2',
  9546. 'asArray' => true
  9547. ) );
  9548. if (empty ( $receiptInfo )) {
  9549. echo json_encode ( array (
  9550. 'status' => 2
  9551. ) );
  9552. die ();
  9553. }
  9554. $vr = $verify->getOne ( array (
  9555. 'where' => 'vid=' . $receiptInfo ['verify'],
  9556. 'asArray' => true
  9557. ) );
  9558. $jd = json_decode ( $vr ['staff'] );
  9559. $roleId = 0;
  9560. foreach ( $jd as $key => $value ) {
  9561. if ($value [1] == 'ROLE') {
  9562. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9563. if ($pos !== false) {
  9564. $roleId = $value [0];
  9565. }
  9566. }
  9567. }
  9568. // 审批日志
  9569. // echo $roleId;die;
  9570. if (! empty ( $roleId )) {
  9571. Doo::loadModel ( "role" );
  9572. $role = new role ();
  9573. $roleInfo = $role->getOne ( array (
  9574. 'where' => 'rid=' . $roleId,
  9575. 'asArray' => true
  9576. ) );
  9577. $receiptLog->rolename = $roleInfo ['name'];
  9578. }
  9579. $receiptLog->username = $this->staff [0] ['username'];
  9580. $receiptLog->uid = $this->staff [0] ['sid'];
  9581. $receiptLog->date = date ( "Y-m-d" );
  9582. $receiptLog->opinion = $opinion;
  9583. $receiptLog->img = $this->staff [0] ['avatar'];
  9584. $receiptLog->status = 4;
  9585. $receiptLog->rid = $rid;
  9586. $receiptLog->insert ();
  9587. $receipt->status = 4;
  9588. $receipt->update ( array (
  9589. 'where' => 'rid=' . $rid
  9590. ) );
  9591. // 微信企业号通知
  9592. $this->setWXMsg ( $rid, 2 );
  9593. echo json_encode ( array (
  9594. 'status' => 1
  9595. ) );
  9596. // Header("HTTP/1.1 303 See Other");
  9597. // Header("Location: /approvalExpenses/pendApproval");
  9598. die ();
  9599. }
  9600. echo json_encode ( array (
  9601. 'status' => 2
  9602. ) );
  9603. die ();
  9604. // echo "ddd";
  9605. // return '/saeaBorad';
  9606. }
  9607. function revisePrice() {
  9608. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9609. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9610. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9611. // echo $price;die;
  9612. if (! empty ( $rid )) {
  9613. Doo::loadModel ( "receipt" );
  9614. $receipt = new receipt ();
  9615. $receiptDetail = $receipt->getOne ( array (
  9616. 'where' => 'rid=' . $rid . ' and status=2 ',
  9617. 'asArray' => true
  9618. ) );
  9619. if (empty ( $receiptDetail ))
  9620. die ( 'illegal request' );
  9621. $reviseDetail = array ();
  9622. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9623. array_push ( $reviseDetail, array (
  9624. 'sid' => $this->staff [0] ['sid'],
  9625. 'name' => $this->staff [0] ['username'],
  9626. 'description' => $description,
  9627. 'price' => $price
  9628. ) );
  9629. $reviseDetailString = json_encode ( $reviseDetail );
  9630. $receipt->reviseDetail = $reviseDetailString;
  9631. $receipt->revisePrice = $price;
  9632. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9633. } else {
  9634. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9635. array_push ( $reviseDetail, array (
  9636. 'sid' => $this->staff [0] ['sid'],
  9637. 'name' => $this->staff [0] ['username'],
  9638. 'description' => $description,
  9639. 'price' => $price
  9640. ) );
  9641. $reviseDetailString = json_encode ( $reviseDetail );
  9642. $receipt->reviseDetail = $reviseDetailString;
  9643. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9644. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9645. }
  9646. $receipt->update ( array (
  9647. 'where' => 'rid=' . $rid
  9648. ) );
  9649. if ($receiptDetail ['Rtype'] == 1) {
  9650. if ($receiptDetail ['isBK'] == 1) {
  9651. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9652. }
  9653. } elseif ($receiptDetail ['Rtype'] == 2) {
  9654. } else {
  9655. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9656. }
  9657. }
  9658. die ( 'illegal request' );
  9659. }
  9660. function personalCollect() {
  9661. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9662. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9663. $this->showCache ( $path );
  9664. Doo::loadModel ( "receiptDetail" );
  9665. Doo::loadModel ( "itemStatistics" );
  9666. Doo::loadModel ( 'statistics' );
  9667. $statistics = new statistics ();
  9668. $itemStatistics = new itemStatistics ();
  9669. $receiptDetail = new receiptDetail ();
  9670. $receiptCollectList = $receiptDetail->find ( array (
  9671. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9672. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9673. 'groupby' => 'itemCategory,Month(date)',
  9674. 'asArray' => true
  9675. ) );
  9676. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9677. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9678. 'asArray' => true
  9679. ) );
  9680. // create collect html
  9681. $collectArray = array (
  9682. '日常相关费用' => array (),
  9683. '差旅相关费用' => array (),
  9684. '培训班费用' => array (),
  9685. '其他' => array ()
  9686. );
  9687. $adjustment = array ();
  9688. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9689. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9690. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9691. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9692. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9693. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9694. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9695. array_push ( $collectArray ['其他'], $collectHtml );
  9696. $data ['collectArray'] = $collectArray;
  9697. // statistics html
  9698. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9699. if (empty ( $stList ))
  9700. $stList = array (
  9701. 'rePrice' => 0,
  9702. 'agPrice' => 0
  9703. );
  9704. $data ['stList'] = array (
  9705. 'rePrice' => $stList ['rePrice'],
  9706. 'agPrice' => $stList ['agPrice'],
  9707. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9708. );
  9709. // Adjustment price html
  9710. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9711. array_push ( $adjustment, $collectHtml );
  9712. $data ['adjustment'] = $adjustment;
  9713. // total price html
  9714. $collectHtml = "";
  9715. $total = 0;
  9716. for($i = 1; $i <= 12; $i ++) {
  9717. $sumPrice = 0;
  9718. foreach ( $receiptCollectList as $key => $value ) {
  9719. if ($value ['month'] == $i) {
  9720. $sumPrice += $value ['price'];
  9721. }
  9722. }
  9723. if ($sumPrice == 0)
  9724. $collectHtml .= '<td class="taR">-</td>';
  9725. else
  9726. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9727. $total += $sumPrice;
  9728. }
  9729. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9730. $data ['totalPrice'] = $collectHtml;
  9731. $dateHtml = "";
  9732. $now = date ( "Y" );
  9733. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9734. if ($YEARD <= $now) {
  9735. $dateHtml .= '<option ';
  9736. if ($year == $YEARD) {
  9737. $dateHtml .= 'selected ';
  9738. }
  9739. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9740. }
  9741. }
  9742. $data ['dateHtml'] = $dateHtml;
  9743. $data ['year'] = $year;
  9744. $data ['totalYear'] = $total;
  9745. $data ['memu'] = "receipt";
  9746. $data ['staff'] = $this->staff;
  9747. $data ['receiptMemu'] = 'personalCollect';
  9748. $data ['verifyId'] = $this->verifyId;
  9749. $data ['executeId'] = $this->executeId;
  9750. // year staff status 2,4
  9751. if ($year < date ( "Y" )) {
  9752. Doo::loadModel ( 'receipt' );
  9753. $receipt = new receipt ();
  9754. $receiptList = $receipt->find ( array (
  9755. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9756. 'asArray' => true
  9757. ) );
  9758. if (empty ( $receiptList )) {
  9759. ob_start ();
  9760. $this->render ( "/admin/saea_slist_collect", $data );
  9761. $this->cacheFile ( $path );
  9762. die ();
  9763. }
  9764. }
  9765. $this->render ( "/admin/saea_slist_collect", $data );
  9766. }
  9767. function personalCollectDetail() {
  9768. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9769. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9770. $this->showCache ( $path );
  9771. Doo::loadModel ( "receiptDetail" );
  9772. Doo::loadModel ( "itemStatistics" );
  9773. Doo::loadModel ( 'statistics' );
  9774. Doo::loadModel ( 'accountItem' );
  9775. $accountItem = new accountItem ();
  9776. $statistics = new statistics ();
  9777. $itemStatistics = new itemStatistics ();
  9778. $receiptDetail = new receiptDetail ();
  9779. $receiptCollectList = $receiptDetail->find ( array (
  9780. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9781. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9782. 'groupby' => 'item,Month(date)',
  9783. 'asArray' => true
  9784. ) );
  9785. $accountList = $accountItem->find ( array (
  9786. 'asArray' => true
  9787. ) );
  9788. // create CollectDetail HTML
  9789. $collectHtml = array ();
  9790. foreach ( $accountList as $key => $value ) {
  9791. $html = "";
  9792. $asum = 0;
  9793. for($i = 1; $i <= 12; $i ++) {
  9794. $falg = true;
  9795. foreach ( $receiptCollectList as $v ) {
  9796. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9797. $asum += $v ['price'];
  9798. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9799. $falg = false;
  9800. break;
  9801. }
  9802. }
  9803. if ($falg)
  9804. $html .= '<td class="taR">-</td>';
  9805. }
  9806. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9807. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9808. }
  9809. $data ['collectHtml'] = $collectHtml;
  9810. // create Adjustment price html
  9811. $receiptCollectList = $receiptDetail->find ( array (
  9812. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9813. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9814. 'groupby' => 'itemCategory,Month(date)',
  9815. 'asArray' => true
  9816. ) );
  9817. $adjustment = array ();
  9818. $collectArray = array (
  9819. '日常相关费用' => array (),
  9820. '差旅相关费用' => array (),
  9821. '培训班费用' => array (),
  9822. '其他' => array ()
  9823. );
  9824. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9825. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9826. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9827. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9828. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9829. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9830. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9831. array_push ( $collectArray ['其他'], $collectHtml );
  9832. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9833. array_push ( $adjustment, $collectHtml );
  9834. // total price html
  9835. $collectHtml = "";
  9836. $total = 0;
  9837. for($i = 1; $i <= 12; $i ++) {
  9838. $sumPrice = 0;
  9839. foreach ( $receiptCollectList as $key => $value ) {
  9840. if ($value ['month'] == $i) {
  9841. $sumPrice += $value ['price'];
  9842. }
  9843. }
  9844. if ($sumPrice == 0)
  9845. $collectHtml .= '<td class="taR">-</td>';
  9846. else
  9847. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9848. $total += $sumPrice;
  9849. }
  9850. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9851. // statistics html
  9852. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9853. if (empty ( $stList ))
  9854. $stList = array (
  9855. 'rePrice' => 0,
  9856. 'agPrice' => 0
  9857. );
  9858. $data ['stList'] = array (
  9859. 'rePrice' => $stList ['rePrice'],
  9860. 'agPrice' => $stList ['agPrice'],
  9861. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9862. );
  9863. $data ['collectArray'] = $collectArray;
  9864. $data ['adjustment'] = $adjustment;
  9865. $data ['totalPrice'] = $collectHtml;
  9866. $data ['totalYear'] = $total;
  9867. $data ['year'] = $year;
  9868. $dateHtml = "";
  9869. $now = date ( "Y" );
  9870. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9871. if ($YEARD <= $now) {
  9872. $dateHtml .= '<option ';
  9873. if ($year == $YEARD) {
  9874. $dateHtml .= 'selected ';
  9875. }
  9876. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9877. }
  9878. }
  9879. $data ['dateHtml'] = $dateHtml;
  9880. $data ['memu'] = "receipt";
  9881. $data ['staff'] = $this->staff;
  9882. $data ['receiptMemu'] = 'personalCollect';
  9883. $data ['verifyId'] = $this->verifyId;
  9884. $data ['executeId'] = $this->executeId;
  9885. // year staff status 2,4
  9886. if ($year < date ( "Y" )) {
  9887. Doo::loadModel ( 'receipt' );
  9888. $receipt = new receipt ();
  9889. $receiptList = $receipt->find ( array (
  9890. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9891. 'asArray' => true
  9892. ) );
  9893. if (empty ( $receiptList )) {
  9894. ob_start ();
  9895. $this->render ( "/admin/saeaCollectArticles", $data );
  9896. $this->cacheFile ( $path );
  9897. die ();
  9898. }
  9899. }
  9900. $this->render ( "/admin/saeaCollectArticles", $data );
  9901. }
  9902. function companyCategoryCollect() {
  9903. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9904. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9905. $this->showCache ( $path );
  9906. Doo::loadModel ( 'L_category' );
  9907. Doo::loadModel ( 'itemStatistics' );
  9908. Doo::loadModel ( 'statistics' );
  9909. $statistics = new statistics ();
  9910. $Lcategory = new L_category ();
  9911. $itemStatistics = new itemStatistics ();
  9912. Doo::loadModel ( "receiptAuthorityManage" );
  9913. $receiptAuthorityManage = new receiptAuthorityManage ();
  9914. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9915. $cidList = array ();
  9916. foreach ( $imcStaff as $key => $value ) {
  9917. array_push ( $cidList, $value ['cid'] );
  9918. }
  9919. $cidString = implode ( ',', $cidList );
  9920. $LcategoryList = $Lcategory->find ( array (
  9921. 'where' => ' cid in (' . $cidString . ')',
  9922. 'asArray' => true
  9923. ) ); // 'staff='.$this->staff[0]['sid']." and
  9924. $itemStatisticsList = $itemStatistics->find ( array (
  9925. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9926. 'where' => " Year(date)=" . $year,
  9927. 'groupby' => 'cid,Month(date)',
  9928. 'asArray' => true
  9929. ) );
  9930. // ceatre companyCollectHtml
  9931. foreach ( $LcategoryList as $value ) {
  9932. $html = "";
  9933. $asum = 0;
  9934. for($i = 1; $i <= 12; $i ++) {
  9935. $falg = true;
  9936. foreach ( $itemStatisticsList as $v ) {
  9937. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9938. $asum += $v ['price'];
  9939. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9940. $falg = false;
  9941. break;
  9942. }
  9943. }
  9944. if ($falg)
  9945. $html .= '<td class="taR">-</td>';
  9946. }
  9947. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9948. $collectHtml [$value ['title']] = array (
  9949. 'html' => $html,
  9950. 'cid' => $value ['cid']
  9951. );
  9952. }
  9953. $data ['companyHtml'] = $collectHtml;
  9954. // total price html
  9955. $collectHtml = "";
  9956. $total = 0;
  9957. for($i = 1; $i <= 12; $i ++) {
  9958. $sumPrice = 0;
  9959. foreach ( $itemStatisticsList as $key => $value ) {
  9960. if ($value ['month'] == $i) {
  9961. $sumPrice += $value ['price'];
  9962. }
  9963. }
  9964. if ($sumPrice == 0)
  9965. $collectHtml .= '<td class="taR">-</td>';
  9966. else
  9967. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9968. $total += $sumPrice;
  9969. }
  9970. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9971. $data ['companyTotalHtml'] = $collectHtml;
  9972. $data ['total'] = $total;
  9973. // statistics html
  9974. // echo $cidString;
  9975. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9976. if (empty ( $stList ))
  9977. $stList = array (
  9978. 'rePrice' => 0,
  9979. 'agPrice' => 0
  9980. );
  9981. $data ['stList'] = array (
  9982. 'rePrice' => $stList ['rePrice'],
  9983. 'agPrice' => $stList ['agPrice'],
  9984. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9985. );
  9986. $data ['year'] = $year;
  9987. $data ['memu'] = "receipt";
  9988. $data ['staff'] = $this->staff;
  9989. $data ['receiptMemu'] = 'companyCategoryCollect';
  9990. $data ['verifyId'] = $this->verifyId;
  9991. $data ['executeId'] = $this->executeId;
  9992. $dateHtml = "";
  9993. $now = date ( "Y" );
  9994. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9995. if ($YEARD <= $now) {
  9996. $dateHtml .= '<option ';
  9997. if ($year == $YEARD) {
  9998. $dateHtml .= 'selected ';
  9999. }
  10000. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10001. }
  10002. }
  10003. $data ['dateHtml'] = $dateHtml;
  10004. // year staff status 2,4
  10005. if ($year < date ( "Y" )) {
  10006. Doo::loadModel ( 'receipt' );
  10007. $receipt = new receipt ();
  10008. $receiptList = $receipt->find ( array (
  10009. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10010. 'asArray' => true
  10011. ) );
  10012. if (empty ( $receiptList )) {
  10013. ob_start ();
  10014. $this->render ( "/admin/saeaCompanyCollect", $data );
  10015. $this->cacheFile ( $path );
  10016. die ();
  10017. }
  10018. }
  10019. $this->render ( "/admin/saeaCompanyCollect", $data );
  10020. }
  10021. function categoryCollectDetail() {
  10022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10023. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10024. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10025. $this->showCache ( $path ); */
  10026. Doo::loadModel ( 'statistics' );
  10027. $statistics = new statistics ();
  10028. Doo::loadModel ( "receiptDetail" );
  10029. $receiptDetail = new receiptDetail ();
  10030. Doo::loadModel ( 'L_category' );
  10031. $Lcategory = new L_category ();
  10032. Doo::loadModel ( 'accountItem' );
  10033. $accountItem = new accountItem ();
  10034. Doo::loadModel ( "receiptAuthorityManage" );
  10035. $receiptAuthorityManage = new receiptAuthorityManage ();
  10036. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10037. $cidList = array ();
  10038. foreach ( $imcStaff as $key => $value ) {
  10039. array_push ( $cidList, $value ['cid'] );
  10040. }
  10041. $cidString = implode ( ',', $cidList );
  10042. $LcategoryList = $Lcategory->find ( array (
  10043. 'where' => 'cid in (' . $cidString . ')',
  10044. 'asArray' => true
  10045. ) );
  10046. if ($cid == 0) {
  10047. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10048. if ($cid == 0)
  10049. $cid = $LcategoryList [0] ['cid'];
  10050. }
  10051. $data ['LcategoryList'] = $LcategoryList;
  10052. $receiptCollectList = $receiptDetail->find ( array (
  10053. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10054. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10055. 'groupby' => 'item,Month(pastDate)',
  10056. 'asArray' => true
  10057. ) );
  10058. $accountList = $accountItem->find ( array (
  10059. 'asArray' => true
  10060. ) );
  10061. // create CollectDetail HTML
  10062. $collectHtml = array ();
  10063. foreach ( $accountList as $key => $value ) {
  10064. $html = "";
  10065. $asum = 0;
  10066. for($i = 1; $i <= 12; $i ++) {
  10067. $falg = true;
  10068. foreach ( $receiptCollectList as $v ) {
  10069. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10070. $asum += $v ['price'];
  10071. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10072. $falg = false;
  10073. break;
  10074. }
  10075. }
  10076. if ($falg)
  10077. $html .= '<td class="taR">-</td>';
  10078. }
  10079. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10080. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10081. }
  10082. $data ['collectHtml'] = $collectHtml;
  10083. // create Adjustment price html
  10084. $receiptCollectList = $receiptDetail->find ( array (
  10085. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10086. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10087. 'groupby' => 'itemCategory,Month(pastDate)',
  10088. 'asArray' => true
  10089. ) );
  10090. $adjustment = array ();
  10091. $collectArray = array (
  10092. '日常相关费用' => array (),
  10093. '差旅相关费用' => array (),
  10094. '培训班费用' => array (),
  10095. '内部培训费用'=>array(),
  10096. '其他' => array ()
  10097. );
  10098. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10099. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10100. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10101. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10102. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10103. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10104. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10105. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10106. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10107. array_push ( $collectArray ['其他'], $collectHtml );
  10108. $data ['collectArray'] = $collectArray;
  10109. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10110. array_push ( $adjustment, $collectHtml );
  10111. $data ['adjustment'] = $adjustment;
  10112. // total price html
  10113. $collectHtml = "";
  10114. $total = 0;
  10115. for($i = 1; $i <= 12; $i ++) {
  10116. $sumPrice = 0;
  10117. foreach ( $receiptCollectList as $key => $value ) {
  10118. if ($value ['month'] == $i) {
  10119. $sumPrice += $value ['price'];
  10120. }
  10121. }
  10122. if ($sumPrice == 0)
  10123. $collectHtml .= '<td class="taR">-</td>';
  10124. else
  10125. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10126. $total += $sumPrice;
  10127. }
  10128. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10129. // statistics html
  10130. $stList = $statistics->statisticsByCid ( $year, $cid );
  10131. if (empty ( $stList ))
  10132. $stList = array (
  10133. 'rePrice' => 0,
  10134. 'agPrice' => 0
  10135. );
  10136. $data ['stList'] = array (
  10137. 'rePrice' => $stList ['rePrice'],
  10138. 'agPrice' => $stList ['agPrice'],
  10139. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10140. );
  10141. $data ['totalYear'] = $total;
  10142. $data ['year'] = $year;
  10143. $data ['cid'] = $cid;
  10144. $data ['memu'] = "receipt";
  10145. $data ['staff'] = $this->staff;
  10146. $data ['receiptMemu'] = 'companyCategoryCollect';
  10147. $data ['verifyId'] = $this->verifyId;
  10148. $data ['executeId'] = $this->executeId;
  10149. // year staff status 2,4
  10150. /* if ($year < date ( "Y" )) {
  10151. Doo::loadModel ( 'receipt' );
  10152. $receipt = new receipt ();
  10153. $receiptList = $receipt->find ( array (
  10154. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10155. 'asArray' => true
  10156. ) );
  10157. if (empty ( $receiptList )) {
  10158. ob_start ();
  10159. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10160. $this->cacheFile ( $path );
  10161. die ();
  10162. }
  10163. } */
  10164. $dateHtml = "";
  10165. $now = date ( "Y" );
  10166. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10167. if ($YEARD <= $now) {
  10168. $dateHtml .= '<option ';
  10169. if ($year == $YEARD) {
  10170. $dateHtml .= 'selected ';
  10171. }
  10172. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10173. }
  10174. }
  10175. $data ['dateHtml'] = $dateHtml;
  10176. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10177. }
  10178. function staffCollect() {
  10179. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10180. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10181. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10182. // $this->showCache($path);
  10183. Doo::loadModel ( 'statistics' );
  10184. $statistics = new statistics ();
  10185. Doo::loadModel ( "receiptDetail" );
  10186. $receiptDetail = new receiptDetail ();
  10187. Doo::loadModel ( 'L_category' );
  10188. $Lcategory = new L_category ();
  10189. Doo::loadModel ( 'accountItem' );
  10190. $accountItem = new accountItem ();
  10191. Doo::loadModel ( 'staff' );
  10192. $staff = new staff ();
  10193. Doo::loadModel ( 'itemStatistics' );
  10194. $itemStatistics = new itemStatistics ();
  10195. Doo::loadModel ( "receiptAuthorityManage" );
  10196. $receiptAuthorityManage = new receiptAuthorityManage ();
  10197. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10198. $cidList = array ();
  10199. foreach ( $imcStaff as $key => $value ) {
  10200. array_push ( $cidList, $value ['cid'] );
  10201. }
  10202. $cidString = implode ( ',', $cidList );
  10203. $naturecon='';
  10204. if ($nature=='ONJOB'){
  10205. $naturecon=' and (nature!=4 )';
  10206. }elseif($nature=='LEAVEJOB'){
  10207. $naturecon=' and (nature=4 )';
  10208. }else{
  10209. die ( 'illegal request--nature' );
  10210. }
  10211. // statistics html
  10212. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10213. if (empty ( $stList ))
  10214. $stList = array (
  10215. 'rePrice' => 0,
  10216. 'agPrice' => 0
  10217. );
  10218. $data ['stList'] = array (
  10219. 'rePrice' => $stList ['rePrice'],
  10220. 'agPrice' => $stList ['agPrice'],
  10221. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10222. );
  10223. // ---
  10224. $staffList = $staff->find ( array (
  10225. 'where' => 'username !="admin" '.$naturecon,
  10226. 'asArray' => true
  10227. ) );
  10228. $LcategoryList = $Lcategory->find ( array (
  10229. 'asArray' => true
  10230. ) ); // 'staff='.$this->staff[0]['sid']." and
  10231. $itemStatisticsList = $itemStatistics->find ( array (
  10232. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10233. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10234. 'groupby' => 'staff,Month(date)',
  10235. 'asArray' => true
  10236. ) );
  10237. $categoryList = $staff->find ( array (
  10238. 'select' => 'COUNT(*) as count,cid,category',
  10239. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10240. 'groupby' => 'cid',
  10241. 'asArray' => true
  10242. ) );
  10243. // print_r($itemStatisticsList);die;
  10244. // ceatre companyCollectHtml
  10245. foreach ( $categoryList as $vlu ) {
  10246. $count = $vlu ['count'] + 1;
  10247. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10248. $m1 = 0;
  10249. $m2 = 0;
  10250. $m3 = 0;
  10251. $m4 = 0;
  10252. $m5 = 0;
  10253. $m6 = 0;
  10254. $m7 = 0;
  10255. $m8 = 0;
  10256. $m9 = 0;
  10257. $m10 = 0;
  10258. $m11 = 0;
  10259. $m12 = 0;
  10260. $m13 = 0;
  10261. foreach ( $staffList as $value ) {
  10262. if ($vlu ['cid'] == $value ['cid']) {
  10263. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10264. $asum = 0;
  10265. for($i = 1; $i <= 12; $i ++) {
  10266. $falg = true;
  10267. foreach ( $itemStatisticsList as $v ) {
  10268. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10269. if ($v ['month'] == 1)
  10270. $m1 += $v ['price'];
  10271. if ($v ['month'] == 2)
  10272. $m2 += $v ['price'];
  10273. if ($v ['month'] == 3)
  10274. $m3 += $v ['price'];
  10275. if ($v ['month'] == 4)
  10276. $m4 += $v ['price'];
  10277. if ($v ['month'] == 5)
  10278. $m5 += $v ['price'];
  10279. if ($v ['month'] == 6)
  10280. $m6 += $v ['price'];
  10281. if ($v ['month'] == 7)
  10282. $m7 += $v ['price'];
  10283. if ($v ['month'] == 8)
  10284. $m8 += $v ['price'];
  10285. if ($v ['month'] == 9)
  10286. $m9 += $v ['price'];
  10287. if ($v ['month'] == 10)
  10288. $m10 += $v ['price'];
  10289. if ($v ['month'] == 11)
  10290. $m11 += $v ['price'];
  10291. if ($v ['month'] == 12)
  10292. $m12 += $v ['price'];
  10293. $asum += $v ['price'];
  10294. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10295. $falg = false;
  10296. break;
  10297. }
  10298. }
  10299. if ($falg)
  10300. $html .= '<td class="taR">-</td>';
  10301. }
  10302. $m13 += $asum;
  10303. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10304. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10305. 'html' => $html,
  10306. 'sid' => $value ['sid']
  10307. );
  10308. $html = "";
  10309. }
  10310. }
  10311. $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>
  10312. <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>
  10313. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10314. $collectHtml [$vlu ['cid']] = array (
  10315. 'html' => $hl,
  10316. 'sid' => ''
  10317. );
  10318. }
  10319. $data ['companyHtml'] = $collectHtml;
  10320. // total price html
  10321. $collectHtml = "";
  10322. $total = 0;
  10323. for($i = 1; $i <= 12; $i ++) {
  10324. $sumPrice = 0;
  10325. foreach ( $itemStatisticsList as $key => $value ) {
  10326. if ($value ['month'] == $i) {
  10327. $sumPrice += $value ['price'];
  10328. }
  10329. }
  10330. if ($sumPrice == 0)
  10331. $collectHtml .= '<td class="taR">-</td>';
  10332. else
  10333. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10334. $total += $sumPrice;
  10335. }
  10336. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10337. $data ['companyTotalHtml'] = $collectHtml;
  10338. $data ['total'] = $total;
  10339. $data ['nature'] =$nature;
  10340. $data ['year'] = $year;
  10341. $data ['memu'] = "receipt";
  10342. $data ['staff'] = $this->staff;
  10343. $data ['receiptMemu'] = 'companyCategoryCollect';
  10344. $data ['verifyId'] = $this->verifyId;
  10345. $data ['executeId'] = $this->executeId;
  10346. if ($year <= date ( "Y" )) {
  10347. Doo::loadModel ( 'receipt' );
  10348. $receipt = new receipt ();
  10349. $receiptList = $receipt->find ( array (
  10350. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10351. 'asArray' => true
  10352. ) );
  10353. if (empty ( $receiptList )) { // generated files
  10354. ob_start ();
  10355. $this->render ( "/admin/saeaStaffCollectB", $data );
  10356. $this->cacheFile ( $path );
  10357. die ();
  10358. }
  10359. }
  10360. $this->render ( "/admin/saeaStaffCollectB", $data );
  10361. }
  10362. function staffCollectBak() {
  10363. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10364. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10365. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10366. $this->showCache ( $path );
  10367. Doo::loadModel ( 'statistics' );
  10368. $statistics = new statistics ();
  10369. Doo::loadModel ( "receiptDetail" );
  10370. $receiptDetail = new receiptDetail ();
  10371. Doo::loadModel ( 'L_category' );
  10372. $Lcategory = new L_category ();
  10373. Doo::loadModel ( 'accountItem' );
  10374. $accountItem = new accountItem ();
  10375. Doo::loadModel ( 'staff' );
  10376. $staff = new staff ();
  10377. Doo::loadModel ( 'itemStatistics' );
  10378. $itemStatistics = new itemStatistics ();
  10379. $itemStatisticsList = $itemStatistics->find ( array (
  10380. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10381. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10382. 'groupby' => 'staff,itemCategory,Month(date)',
  10383. 'asArray' => true
  10384. ) );
  10385. $itemCategoryList = $itemStatistics->find ( array (
  10386. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10387. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10388. 'groupby' => 'cid,itemCategory,Month(date)',
  10389. 'asArray' => true
  10390. ) );
  10391. $LcategoryList = $Lcategory->find ( array (
  10392. 'asArray' => true
  10393. ) );
  10394. $staffList = $staff->find ( array (
  10395. 'asArray' => true
  10396. ) );
  10397. $htmlArray = array ();
  10398. foreach ( $LcategoryList as $value ) {
  10399. $htmlArray [$value ['title']] = array ();
  10400. foreach ( $staffList as $v ) {
  10401. if ($value ['cid'] == $v ['cid']) {
  10402. $html = "";
  10403. $falg = true;
  10404. $staffSumPrice = 0;
  10405. foreach ( $itemStatisticsList as $a ) {
  10406. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10407. if (empty ( $a ['price'] )) {
  10408. $html .= '<td class="taR">-</td>';
  10409. $falg = false;
  10410. break;
  10411. } else {
  10412. $staffSumPrice += $a ['price'];
  10413. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10414. $falg = false;
  10415. break;
  10416. }
  10417. }
  10418. }
  10419. if ($falg) {
  10420. $html .= '<td class="taR">-</td>';
  10421. $falg = true;
  10422. }
  10423. $falg = true;
  10424. foreach ( $itemStatisticsList as $a ) {
  10425. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10426. if (empty ( $a ['price'] )) {
  10427. $html .= '<td class="taR">-</td>';
  10428. $falg = false;
  10429. break;
  10430. } else {
  10431. $staffSumPrice += $a ['price'];
  10432. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10433. $falg = false;
  10434. break;
  10435. }
  10436. }
  10437. }
  10438. if ($falg) {
  10439. $html .= '<td class="taR">-</td>';
  10440. $falg = true;
  10441. }
  10442. $falg = true;
  10443. foreach ( $itemStatisticsList as $a ) {
  10444. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10445. if (empty ( $a ['price'] )) {
  10446. $html .= '<td class="taR">-</td>';
  10447. $falg = false;
  10448. break;
  10449. } else {
  10450. $staffSumPrice += $a ['price'];
  10451. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10452. $falg = false;
  10453. break;
  10454. }
  10455. }
  10456. }
  10457. if ($falg) {
  10458. $html .= '<td class="taR">-</td>';
  10459. $falg = true;
  10460. }
  10461. $falg = true;
  10462. foreach ( $itemStatisticsList as $a ) {
  10463. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10464. if (! empty ( $a ['price'] )) {
  10465. $staffSumPrice += $a ['price'];
  10466. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10467. $falg = false;
  10468. break;
  10469. } else {
  10470. $html .= '<td class="taR">-</td>';
  10471. $falg = false;
  10472. break;
  10473. }
  10474. }
  10475. }
  10476. if ($falg) {
  10477. $html .= '<td class="taR">-</td>';
  10478. $falg = true;
  10479. }
  10480. $falg = true;
  10481. foreach ( $itemStatisticsList as $a ) {
  10482. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10483. if (! empty ( $a ['price'] )) {
  10484. $staffSumPrice += $a ['price'];
  10485. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10486. $falg = false;
  10487. break;
  10488. } else {
  10489. $html .= '<td class="taR">-</td>';
  10490. $falg = false;
  10491. break;
  10492. }
  10493. }
  10494. }
  10495. if ($falg) {
  10496. $html .= '<td class="taR">-</td>';
  10497. $falg = true;
  10498. }
  10499. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10500. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10501. }
  10502. }
  10503. /* -- --- */
  10504. // 合计费用
  10505. $cateHtml = "";
  10506. $catePrice = 0;
  10507. $cateFalg = true;
  10508. foreach ( $itemCategoryList as $l ) {
  10509. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10510. if (empty ( $l ['price'] )) {
  10511. $cateHtml .= '<td class="colGreen taR">-</td>';
  10512. $cateFalg = false;
  10513. break;
  10514. } else {
  10515. $catePrice += $l ['price'];
  10516. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10517. $cateFalg = false;
  10518. break;
  10519. }
  10520. }
  10521. }
  10522. if ($cateFalg) {
  10523. $cateHtml .= '<td class="colGreen taR">-</td>';
  10524. $cateFalg = true;
  10525. }
  10526. $cateFalg = true;
  10527. foreach ( $itemCategoryList as $l ) {
  10528. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10529. if (empty ( $l ['price'] )) {
  10530. $cateHtml .= '<td class="colGreen taR">-</td>';
  10531. $cateFalg = false;
  10532. break;
  10533. } else {
  10534. $catePrice += $l ['price'];
  10535. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10536. $cateFalg = false;
  10537. break;
  10538. }
  10539. }
  10540. }
  10541. if ($cateFalg) {
  10542. $cateHtml .= '<td class="colGreen taR">-</td>';
  10543. $cateFalg = true;
  10544. }
  10545. $cateFalg = true;
  10546. foreach ( $itemCategoryList as $l ) {
  10547. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10548. if (empty ( $l ['price'] )) {
  10549. $cateHtml .= '<td class="colGreen taR">-</td>';
  10550. $cateFalg = false;
  10551. break;
  10552. } else {
  10553. $catePrice += $l ['price'];
  10554. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10555. $cateFalg = false;
  10556. break;
  10557. }
  10558. }
  10559. }
  10560. if ($cateFalg) {
  10561. $cateHtml .= '<td class="colGreen taR">-</td>';
  10562. $cateFalg = true;
  10563. }
  10564. $cateFalg = true;
  10565. foreach ( $itemCategoryList as $l ) {
  10566. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10567. if (empty ( $l ['price'] )) {
  10568. $cateHtml .= '<td class="colGreen taR">-</td>';
  10569. $cateFalg = false;
  10570. break;
  10571. } else {
  10572. $catePrice += $l ['price'];
  10573. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10574. $cateFalg = false;
  10575. break;
  10576. }
  10577. }
  10578. }
  10579. if ($cateFalg) {
  10580. $cateHtml .= '<td class="colGreen taR">-</td>';
  10581. $cateFalg = true;
  10582. }
  10583. $cateFalg = true;
  10584. foreach ( $itemCategoryList as $l ) {
  10585. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10586. if (empty ( $l ['price'] )) {
  10587. $cateHtml .= '<td class="colGreen taR">-</td>';
  10588. $cateFalg = false;
  10589. break;
  10590. } else {
  10591. $catePrice += $l ['price'];
  10592. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10593. $cateFalg = false;
  10594. break;
  10595. }
  10596. }
  10597. }
  10598. if ($cateFalg) {
  10599. $cateHtml .= '<td class="colGreen taR">-</td>';
  10600. $cateFalg = true;
  10601. }
  10602. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10603. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10604. /* -- --- */
  10605. }
  10606. // print_r($htmlArray);die;
  10607. $data ['htmlArray'] = $htmlArray;
  10608. // statistics html
  10609. $stList = $statistics->getOne ( array (
  10610. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10611. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10612. 'groupby' => 'Month(date)',
  10613. 'asArray' => true
  10614. ) );
  10615. if (empty ( $stList ))
  10616. $stList = array (
  10617. 'rePrice' => 0,
  10618. 'agPrice' => 0
  10619. );
  10620. $data ['stList'] = array (
  10621. 'rePrice' => $stList ['rePrice'],
  10622. 'agPrice' => $stList ['agPrice'],
  10623. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10624. );
  10625. $monthHtml = "";
  10626. for($i = 1; $i <= 12; $i ++) {
  10627. if ($i == $month)
  10628. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10629. else
  10630. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10631. }
  10632. $data ['monthHtml'] = $monthHtml;
  10633. $data ['year'] = $year;
  10634. $data ['month'] = $month;
  10635. $data ['memu'] = "receipt";
  10636. $data ['staff'] = $this->staff;
  10637. $data ['receiptMemu'] = 'companyCategoryCollect';
  10638. $data ['verifyId'] = $this->verifyId;
  10639. $data ['executeId'] = $this->executeId;
  10640. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10641. Doo::loadModel ( 'receipt' );
  10642. $receipt = new receipt ();
  10643. $receiptList = $receipt->find ( array (
  10644. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10645. 'asArray' => true
  10646. ) );
  10647. if (empty ( $receiptList )) { // generated files
  10648. ob_start ();
  10649. $this->render ( "/admin/saeaStaffCollect", $data );
  10650. $this->cacheFile ( $path );
  10651. die ();
  10652. }
  10653. }
  10654. $this->render ( "/admin/saeaStaffCollect", $data );
  10655. }
  10656. /**
  10657. * 日常收支
  10658. */
  10659. function payments() {
  10660. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10661. Doo::loadModel ( "execute" );
  10662. $execute = new execute ();
  10663. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10664. die ( 'illegal request' );
  10665. }
  10666. Doo::loadModel ( "accountBook" );
  10667. $accountBook = new accountBook ();
  10668. Doo::loadModel ( "accountBookStatistics" );
  10669. $accountBookStatistics = new accountBookStatistics ();
  10670. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10671. $list = $accountBook->getAccountBookByLimit ( 10 );
  10672. $data ['date'] = date ( "Y-m-d" );
  10673. $data ['statisticsList'] = $statisticsList;
  10674. $data ['list'] = $list;
  10675. $data ['memu'] = "receipt";
  10676. $data ['staff'] = $this->staff;
  10677. $data ['receiptMemu'] = 'payments';
  10678. $data ['verifyId'] = $this->verifyId;
  10679. $data ['executeId'] = $this->executeId;
  10680. $this->render ( "/expenses/payments", $data );
  10681. }
  10682. function paymentsIncomeDo() {
  10683. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10684. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10685. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10686. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10687. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10688. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10689. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10690. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10691. Doo::loadClass ( 'XDeode' );
  10692. $XDeode = new XDeode ( 5 );
  10693. Doo::loadModel ( "accountBook" );
  10694. Doo::loadModel ( "accountBookStatistics" );
  10695. Doo::loadModel ( 'wasteBook' );
  10696. // 记录流水时银行的转换
  10697. $accountBank = '';
  10698. if ($receivedBank == '纵横广发') {
  10699. $accountBank = 'CGBDeposit';
  10700. } elseif ($receivedBank == '纵横工行') {
  10701. $accountBank = 'ICBCDeposit';
  10702. } elseif ($receivedBank == '华润银行') {
  10703. $accountBank = 'HUADeposit';
  10704. } elseif ($receivedBank == '个人广发') {
  10705. $accountBank = 'PersonalDeposit';
  10706. }
  10707. if (empty ( $accountBank ))
  10708. die ( 'illegal request-bank' );
  10709. //TODO -存款功能 提取
  10710. if($accountType == 11 || $accountType == 12){
  10711. if($accountType == 11){
  10712. $receivedBank = '纵横广发';
  10713. }elseif($accountType == 12){
  10714. $receivedBank = '纵横工行';
  10715. }
  10716. // 添加一条收入
  10717. $accountBook = new accountBook ();
  10718. $accountBook->accountType = $accountType;
  10719. $accountBook->accountMsg = $accountMsg;
  10720. $accountBook->receivedPrice = $receivedPrice;
  10721. $accountBook->receivedMsg = $receivedMsg;
  10722. $accountBook->receivedBank = $receivedBank;
  10723. $accountBook->receivedDate = $receivedDate;
  10724. $accountBook->remarks = $remarks;
  10725. $accountBook->expensesType = 1;
  10726. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10727. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10728. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10729. $inComeId = $accountBook->insert ();
  10730. // 收支汇总-添加一条收入日常汇总
  10731. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10732. $accountBookStatistics = new accountBookStatistics ();
  10733. $item = array (
  10734. 'date' => date ( "Y-m-d" ),
  10735. 'accountType' => $abDetail ['accountType'],
  10736. 'accountMsg' => $abDetail ['accountMsg'],
  10737. 'aid' => $abDetail ['aid'],
  10738. 'inComePrice' => $abDetail ['receivedPrice'],
  10739. 'expensesType' => $abDetail ['expensesType']
  10740. );
  10741. $accountBookStatistics->setAccountBookStatistics ( $item );
  10742. // 添加收入流水
  10743. if($accountType == 11){
  10744. $accountBank = 'CGBDeposit';
  10745. }elseif($accountType == 12){
  10746. $accountBank = 'ICBCDeposit';
  10747. }
  10748. $wasteBook = new wasteBook ();
  10749. $itemWaste = array (
  10750. 'accountPriceShow' => $receivedPrice,
  10751. 'accountPrice' => $receivedPrice,
  10752. 'expensesType' => 1,
  10753. 'accountType' => 6, // 流水类型
  10754. 'dataID' => $inComeId,
  10755. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10756. 'accountBank' => $accountBank,
  10757. 'category' => $this->staff [0] ['category'],
  10758. 'cid' => $this->staff [0] ['cid'],
  10759. 'name' => $this->staff [0] ['username'],
  10760. 'sid' => $this->staff [0] ['sid'],
  10761. 'inputDate' => $receivedDate,
  10762. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10763. 'synPaymentDate'=>1,
  10764. );
  10765. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10766. }
  10767. //TODO --移除理财相关
  10768. // elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10769. // // if ($receivedBank == '个人广发') {
  10770. // // die ( '个人广发 illegal request' );
  10771. // // }
  10772. // // echo $receivedBank;
  10773. // die;
  10774. // // 添加一条收入
  10775. // $accountBook = new accountBook ();
  10776. // $accountBook->accountType = 10;
  10777. // $accountBook->accountMsg = $accountMsg;
  10778. // $accountBook->receivedPrice = $receivedPrice;
  10779. // $accountBook->receivedMsg = $receivedMsg;
  10780. // $accountBook->receivedBank = $receivedBank;
  10781. // $accountBook->receivedDate = $receivedDate;
  10782. // $accountBook->remarks = $remarks;
  10783. // $accountBook->expensesType = 1;
  10784. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10785. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10786. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10787. // $inComeId = $accountBook->insert ();
  10788. // // 收支汇总-添加一条收入日常汇总
  10789. // $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10790. // $accountBookStatistics = new accountBookStatistics ();
  10791. // $item = array (
  10792. // 'date' => date ( "Y-m-d" ),
  10793. // 'accountType' => $abDetail ['accountType'],
  10794. // 'accountMsg' => $abDetail ['accountMsg'],
  10795. // 'aid' => $abDetail ['aid'],
  10796. // 'inComePrice' => $abDetail ['receivedPrice'],
  10797. // 'expensesType' => $abDetail ['expensesType']
  10798. // );
  10799. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10800. // // 添加收入流水
  10801. // $wasteBook = new wasteBook ();
  10802. // $itemWaste = array (
  10803. // 'accountPriceShow' => $receivedPrice,
  10804. // 'accountPrice' => $receivedPrice,
  10805. // 'expensesType' => 1,
  10806. // 'accountType' => 6, // 流水类型
  10807. // 'dataID' => $inComeId,
  10808. // 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10809. // 'accountBank' => $accountBank,
  10810. // 'category' => $this->staff [0] ['category'],
  10811. // 'cid' => $this->staff [0] ['cid'],
  10812. // 'name' => $this->staff [0] ['username'],
  10813. // 'sid' => $this->staff [0] ['sid'],
  10814. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10815. // );
  10816. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10817. // // 添加一条理财支出
  10818. // $accountBank = 'CGBDeposit';
  10819. // $expenditureBank = '纵横广发';
  10820. // if($accountMsg=='个人(GR)'){
  10821. // $expenditureBank = '个人广发';
  10822. // }
  10823. // $dailyExpenditureType = 4;
  10824. // if ($accountType == 9) {
  10825. // $accountBank = 'ICBCDeposit';
  10826. // $expenditureBank = '纵横工行';
  10827. // $dailyExpenditureType = 6;
  10828. // }
  10829. // $accountBook = new accountBook ();
  10830. // $accountBook->expensesType = 2;
  10831. // $accountBook->expenditureType = $dailyExpenditureType;
  10832. // $accountBook->expenditureMsg = $accountMsg;
  10833. // $accountBook->expenditurePrice = $receivedPrice;
  10834. // $accountBook->expenditureBank = $expenditureBank;
  10835. // $accountBook->expenditureDate = $receivedDate;
  10836. // $accountBook->remarks = $remarks;
  10837. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10838. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10839. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10840. // $id = $accountBook->insert ();
  10841. // // 收支汇总-添加一条理财支出汇总
  10842. // $abDetail = $accountBook->getAccountBookByAid ( $id );
  10843. // $accountBookStatistics = new accountBookStatistics ();
  10844. // $item = array (
  10845. // 'date' => date ( "Y-m-d" ),
  10846. // 'accountType' => $abDetail ['accountType'],
  10847. // 'accountMsg' => $abDetail ['accountMsg'],
  10848. // 'aid' => $abDetail ['aid'],
  10849. // 'financingPrice' => - $receivedPrice,
  10850. // 'expensesType' => 3
  10851. // );
  10852. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10853. // //TODO -新增理财为个人时的情况 添加一条支出理财流水
  10854. // $accountTypeWaste = 5;
  10855. // if ($accountMsg == '公司固定') {
  10856. // $accountTypeWaste = 9;
  10857. // } elseif ($accountMsg == '公司活期') {
  10858. // $accountTypeWaste = 10;
  10859. // } elseif ($receivedBank == '个人广发') {
  10860. // $accountTypeWaste = 9;
  10861. // $accountBank = 'ICBCDeposit';
  10862. // }
  10863. // $itemWaste = array (
  10864. // 'expensesType' => 2,
  10865. // 'accountType' => $accountTypeWaste,
  10866. // 'accountPriceShow' => $receivedPrice,
  10867. // 'accountPrice' => - $receivedPrice,
  10868. // 'dataID' => $id,
  10869. // 'dailyExpenditureType' => $dailyExpenditureType,
  10870. // 'accountBank' => $accountBank,
  10871. // 'category' => $this->staff [0] ['category'],
  10872. // 'cid' => $this->staff [0] ['cid'],
  10873. // 'name' => $this->staff [0] ['username'],
  10874. // 'sid' => $this->staff [0] ['sid'],
  10875. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10876. // );
  10877. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10878. // }
  10879. elseif ($accountType == 1) {
  10880. // if ($receivedBank == '个人广发')
  10881. // die ( 'illegal request--no man' );
  10882. // 添加一条收入
  10883. $accountBook = new accountBook ();
  10884. $accountBook->accountType = $accountType;
  10885. $accountBook->accountMsg = $accountMsg;
  10886. $accountBook->receivedPrice = $receivedPrice;
  10887. $accountBook->receivedMsg = $receivedMsg;
  10888. $accountBook->receivedBank = $receivedBank;
  10889. $accountBook->receivedDate = $receivedDate;
  10890. $accountBook->remarks = $remarks;
  10891. $accountBook->expensesType = 1;
  10892. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10893. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10894. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10895. $id = $accountBook->insert ();
  10896. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10897. // 收支汇总-添加一条收入日常汇总
  10898. $accountBookStatistics = new accountBookStatistics ();
  10899. $item = array (
  10900. 'date' => date ( "Y-m-d" ),
  10901. 'accountType' => $abDetail ['accountType'],
  10902. 'accountMsg' => $abDetail ['accountMsg'],
  10903. 'aid' => $abDetail ['aid'],
  10904. 'expensesType' => $abDetail ['expensesType']
  10905. );
  10906. if ($abDetail ['accountType'] == 8) {
  10907. $item += array (
  10908. 'inComePrice' => $abDetail ['receivedPrice']
  10909. );
  10910. } else {
  10911. $item += array (
  10912. 'inComePrice' => $abDetail ['receivedPrice']
  10913. );
  10914. }
  10915. $accountBookStatistics->setAccountBookStatistics ( $item );
  10916. // 流水存储方向
  10917. $itemWaste = array (
  10918. 'accountType' => 6
  10919. ); // 流水类型
  10920. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10921. // }else
  10922. if ($accountMsg == '活期理财收益') {
  10923. $itemWaste = array (
  10924. 'accountType' => 10
  10925. ); // 流水类型
  10926. }
  10927. // 添加收入流水
  10928. $wasteBook = new wasteBook ();
  10929. $itemWaste += array (
  10930. 'accountPrice' => $receivedPrice,
  10931. 'accountPriceShow' => $receivedPrice,
  10932. 'expensesType' => 1,
  10933. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10934. 'dataID' => $id,
  10935. 'accountBank' => $accountBank,
  10936. 'category' => $this->staff [0] ['category'],
  10937. 'cid' => $this->staff [0] ['cid'],
  10938. 'name' => $this->staff [0] ['username'],
  10939. 'sid' => $this->staff [0] ['sid'],
  10940. 'inputDate' => $receivedDate,
  10941. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10942. 'synPaymentDate'=>1,
  10943. );
  10944. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10945. } else { // 普通日常收入处理
  10946. // 添加一条收入
  10947. $accountBook = new accountBook ();
  10948. $accountBook->accountType = $accountType;
  10949. $accountBook->accountMsg = $accountMsg;
  10950. $accountBook->receivedPrice = $receivedPrice;
  10951. $accountBook->receivedMsg = $receivedMsg;
  10952. $accountBook->receivedBank = $receivedBank;
  10953. $accountBook->receivedDate = $receivedDate;
  10954. $accountBook->remarks = $remarks;
  10955. $accountBook->expensesType = 1;
  10956. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10957. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10958. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10959. $id = $accountBook->insert ();
  10960. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10961. // 收支汇总-添加一条收入日常汇总
  10962. $accountBookStatistics = new accountBookStatistics ();
  10963. $item = array (
  10964. 'date' => date ( "Y-m-d" ),
  10965. 'accountType' => $abDetail ['accountType'],
  10966. 'accountMsg' => $abDetail ['accountMsg'],
  10967. 'aid' => $abDetail ['aid'],
  10968. 'expensesType' => $abDetail ['expensesType']
  10969. );
  10970. if ($abDetail ['accountType'] == 8) {
  10971. $item += array (
  10972. 'inComePrice' => $abDetail ['receivedPrice']
  10973. );
  10974. } else {
  10975. $item += array (
  10976. 'inComePrice' => $abDetail ['receivedPrice']
  10977. );
  10978. }
  10979. $accountBookStatistics->setAccountBookStatistics ( $item );
  10980. // 添加收入流水
  10981. // $itemWaste = array (
  10982. // 'accountPrice' => $receivedPrice
  10983. // );
  10984. // if ($receivedBank == '个人广发') {
  10985. // $itemWaste = array (
  10986. // 'accountPrice' => - $receivedPrice
  10987. // );
  10988. // }
  10989. $wasteBook = new wasteBook ();
  10990. $itemWaste = array (
  10991. 'accountPriceShow' => $receivedPrice,
  10992. 'accountPrice' => $receivedPrice,
  10993. 'expensesType' => 1,
  10994. 'accountType' => 6, // 流水类型
  10995. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10996. 'dataID' => $id,
  10997. 'accountBank' => $accountBank,
  10998. 'category' => $this->staff [0] ['category'],
  10999. 'cid' => $this->staff [0] ['cid'],
  11000. 'name' => $this->staff [0] ['username'],
  11001. 'sid' => $this->staff [0] ['sid'],
  11002. 'inputDate' => $receivedDate,
  11003. 'createAt'=>date ( "Y-m-d H:i:s" ),
  11004. 'synPaymentDate'=>1,
  11005. );
  11006. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11007. }
  11008. }
  11009. return '/payments';
  11010. }
  11011. function paymentsExpenditureDo() {
  11012. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11013. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11014. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11015. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11016. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11017. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11018. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11019. // 理财支出特殊处理
  11020. Doo::loadModel ( "accountBook" );
  11021. Doo::loadModel ( "accountBookStatistics" );
  11022. Doo::loadModel ( 'wasteBook' );
  11023. $accountBank = '';
  11024. if ($expenditureBank == '纵横广发') {
  11025. $accountBank = 'CGBDeposit';
  11026. } elseif ($expenditureBank == '纵横工行') {
  11027. $accountBank = 'ICBCDeposit';
  11028. } elseif ($expenditureBank == '华润银行') {
  11029. $accountBank = 'HUADeposit';
  11030. } elseif ($expenditureBank == '个人广发') {
  11031. $accountBank = 'PersonalDeposit';
  11032. }
  11033. if (empty ( $accountBank ))
  11034. die ( 'illegal request' );
  11035. if($expenditureType == 8 || $expenditureType == 9){
  11036. // if($expenditureType == 8 ){
  11037. // $expenditureBank='纵横广发';
  11038. // }elseif($expenditureType == 9){
  11039. // $expenditureBank='纵横工行';
  11040. // }
  11041. // // 添加一笔日常支出
  11042. // $accountBook = new accountBook ();
  11043. // $accountBook->expensesType = 2;
  11044. // $accountBook->expenditureType = $expenditureType;
  11045. // $accountBook->expenditureMsg = $expenditureMsg;
  11046. // $accountBook->expenditurePrice = $expenditurePrice;
  11047. // $accountBook->expenditureBank = $expenditureBank;
  11048. // $accountBook->expenditureDate = $expenditureDate;
  11049. // $accountBook->remarks = $remarks;
  11050. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11051. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11052. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11053. // $expenditureId = $accountBook->insert ();
  11054. // // 添加日常支出汇总
  11055. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11056. // $accountBookStatistics = new accountBookStatistics ();
  11057. // $item = array (
  11058. // 'date' => date ( "Y-m-d" ),
  11059. // 'expenditureType' => $abDetail ['expenditureType'],
  11060. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11061. // 'aid' => $abDetail ['aid'],
  11062. // 'payPrice' => $abDetail ['expenditurePrice'],
  11063. // 'expensesType' => $abDetail ['expensesType']
  11064. // );
  11065. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11066. // // 公司日常支出流水
  11067. // if($expenditureType == 8 ){
  11068. // $accountBank = 'CGBDeposit';
  11069. // }elseif($expenditureType == 9){
  11070. // $accountBank = 'ICBCDeposit';
  11071. // }
  11072. // if($accountBank=='CGBDeposit'){
  11073. // $dailyExpenditureType='8';
  11074. // }elseif($accountBank=='ICBCDeposit'){
  11075. // $dailyExpenditureType='9';
  11076. // }elseif($accountBank=='PersonalDeposit'){
  11077. // $dailyExpenditureType='10';
  11078. // }elseif($accountBank=='HUADeposit'){
  11079. // $dailyExpenditureType='11';
  11080. // }
  11081. // $wasteBook = new wasteBook ();
  11082. // $itemWaste = array (
  11083. // 'expensesType' => 2,
  11084. // 'accountType' => 5,
  11085. // 'dailyExpenditureType' => $dailyExpenditureType,
  11086. // 'accountPriceShow' => $expenditurePrice,
  11087. // 'accountPrice' => - $expenditurePrice,
  11088. // 'dataID' => $expenditureId,
  11089. // 'accountBank' => $accountBank,
  11090. // 'category' => $this->staff [0] ['category'],
  11091. // 'cid' => $this->staff [0] ['cid'],
  11092. // 'name' => $this->staff [0] ['username'],
  11093. // 'sid' => $this->staff [0] ['sid'],
  11094. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11095. // );
  11096. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11097. //TODO 日常支出 个人理财情况的相关修改
  11098. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11099. // if ($expenditureBank == '个人广发') {
  11100. // die ( '个人广发 illegal request' );
  11101. // }
  11102. // echo $expenditureMsg;
  11103. die;
  11104. // // 添加一笔日常支出
  11105. // $accountBook = new accountBook ();
  11106. // $accountBook->expensesType = 2;
  11107. // $accountBook->expenditureType = 7;
  11108. // $accountBook->expenditureMsg = $expenditureMsg;
  11109. // $accountBook->expenditurePrice = $expenditurePrice;
  11110. // $accountBook->expenditureBank = $expenditureBank;
  11111. // $accountBook->expenditureDate = $expenditureDate;
  11112. // $accountBook->remarks = $remarks;
  11113. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11114. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11115. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11116. // $expenditureId = $accountBook->insert ();
  11117. // // 添加日常支出汇总
  11118. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11119. // $accountBookStatistics = new accountBookStatistics ();
  11120. // $item = array (
  11121. // 'date' => date ( "Y-m-d" ),
  11122. // 'expenditureType' => $abDetail ['expenditureType'],
  11123. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11124. // 'aid' => $abDetail ['aid'],
  11125. // 'payPrice' => $abDetail ['expenditurePrice'],
  11126. // 'expensesType' => $abDetail ['expensesType']
  11127. // );
  11128. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11129. // // 公司日常支出流水
  11130. // $wasteBook = new wasteBook ();
  11131. // $itemWaste = array (
  11132. // 'accountPrice' => - $expenditurePrice
  11133. // );
  11134. // if($expenditureMsg!='个人(GR)'){
  11135. // if ($expenditureBank == '个人广发') {
  11136. // $itemWaste = array (
  11137. // 'accountPrice' => $expenditurePrice
  11138. // );
  11139. // }
  11140. // }
  11141. // $itemWaste += array (
  11142. // 'expensesType' => 2,
  11143. // 'accountType' => 5,
  11144. // 'dailyExpenditureType' => $expenditureType,
  11145. // 'accountPriceShow' => $expenditurePrice,
  11146. // 'accountPrice' => - $expenditurePrice,
  11147. // 'dataID' => $expenditureId,
  11148. // 'accountBank' => $accountBank,
  11149. // 'category' => $this->staff [0] ['category'],
  11150. // 'cid' => $this->staff [0] ['cid'],
  11151. // 'name' => $this->staff [0] ['username'],
  11152. // 'sid' => $this->staff [0] ['sid'],
  11153. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11154. // );
  11155. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11156. // // 添加一笔理财收入
  11157. // $accountBank = 'CGBDeposit';
  11158. // $dailyIncomeType = 7;
  11159. // $receivedBank = '纵横广发';
  11160. // if ($expenditureType == 6) {
  11161. // $accountBank = 'ICBCDeposit';
  11162. // $receivedBank = '纵横工行';
  11163. // $dailyIncomeType = 9;
  11164. // }elseif($expenditureMsg=='个人(GR)'){
  11165. // $receivedBank = '个人广发';
  11166. // }
  11167. // $accountBook = new accountBook ();
  11168. // $accountBook->expensesType = 1;
  11169. // $accountBook->accountType = $dailyIncomeType;
  11170. // $accountBook->accountMsg = $expenditureMsg;
  11171. // $accountBook->receivedPrice = $expenditurePrice;
  11172. // $accountBook->receivedBank = $receivedBank;
  11173. // $accountBook->receivedDate = $expenditureDate;
  11174. // $accountBook->remarks = $remarks;
  11175. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11176. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11177. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11178. // $id = $accountBook->insert ();
  11179. // // 添加日常理财收入汇总
  11180. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11181. // $accountBookStatistics = new accountBookStatistics ();
  11182. // $item = array (
  11183. // 'date' => date ( "Y-m-d" ),
  11184. // 'expenditureType' => $abDetail ['expenditureType'],
  11185. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11186. // 'aid' => $abDetail ['aid'],
  11187. // 'financingPrice' => $expenditurePrice,
  11188. // 'expensesType' => 3
  11189. // );
  11190. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11191. // //TODO 修改理财收入 添加一笔收入流水
  11192. // if ($expenditureMsg == '公司固定') {
  11193. // $accountTypeWaste = 9;
  11194. // } elseif ($expenditureMsg == '公司活期') {
  11195. // $accountTypeWaste = 10;
  11196. // } elseif ($expenditureMsg == '个人(GR)') {
  11197. // $accountTypeWaste = 9;
  11198. // $accountBank = 'ICBCDeposit';
  11199. // }
  11200. // $itemWaste = array (
  11201. // 'expensesType' => 1,
  11202. // 'accountType' => $accountTypeWaste,
  11203. // 'accountPriceShow' => $expenditurePrice,
  11204. // 'accountPrice' => $expenditurePrice,
  11205. // 'dataID' => $id,
  11206. // 'dailyIncomeType' => $dailyIncomeType,
  11207. // 'accountBank' => $accountBank,
  11208. // 'category' => $this->staff [0] ['category'],
  11209. // 'cid' => $this->staff [0] ['cid'],
  11210. // 'name' => $this->staff [0] ['username'],
  11211. // 'sid' => $this->staff [0] ['sid'],
  11212. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11213. // );
  11214. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11215. } else {
  11216. // 添加一笔日常支出
  11217. $accountBook = new accountBook ();
  11218. $accountBook->expensesType = 2;
  11219. $accountBook->expenditureType = $expenditureType;
  11220. $accountBook->expenditureMsg = $expenditureMsg;
  11221. $accountBook->expenditurePrice = $expenditurePrice;
  11222. $accountBook->expenditureBank = $expenditureBank;
  11223. $accountBook->expenditureDate = $expenditureDate;
  11224. $accountBook->remarks = $remarks;
  11225. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11226. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11227. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11228. $id = $accountBook->insert ();
  11229. // 添加日常支出汇总
  11230. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11231. $accountBookStatistics = new accountBookStatistics ();
  11232. $item = array (
  11233. 'date' => date ( "Y-m-d" ),
  11234. 'expenditureType' => $abDetail ['expenditureType'],
  11235. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11236. 'aid' => $abDetail ['aid'],
  11237. 'expensesType' => $abDetail ['expensesType']
  11238. );
  11239. if ($expenditureType == 5) {
  11240. $item += array (
  11241. 'payPrice' => - $abDetail ['expenditurePrice']
  11242. );
  11243. } else {
  11244. $item += array (
  11245. 'payPrice' => $abDetail ['expenditurePrice']
  11246. );
  11247. }
  11248. $accountBookStatistics->setAccountBookStatistics ( $item );
  11249. // 公司日常支出流水
  11250. $wasteBook = new wasteBook ();
  11251. $itemWaste = array (
  11252. 'accountPrice' => - $expenditurePrice
  11253. );
  11254. if ($expenditureBank == '个人广发') {
  11255. $itemWaste = array (
  11256. 'accountPrice' => $expenditurePrice
  11257. );
  11258. }
  11259. $itemWaste += array (
  11260. 'expensesType' => 2,
  11261. 'accountType' => 5,
  11262. 'accountPriceShow' => $expenditurePrice,
  11263. 'dataID' => $id,
  11264. 'dailyExpenditureType' => $expenditureType,
  11265. 'accountBank' => $accountBank,
  11266. 'category' => $this->staff [0] ['category'],
  11267. 'cid' => $this->staff [0] ['cid'],
  11268. 'name' => $this->staff [0] ['username'],
  11269. 'sid' => $this->staff [0] ['sid'],
  11270. 'inputDate' => date ( "Y-m-d H:i:s" )
  11271. );
  11272. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11273. }
  11274. }
  11275. return '/payments';
  11276. }
  11277. /**
  11278. * 添加支出
  11279. */
  11280. function paymentsExpenditureDo_() {
  11281. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11282. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11283. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11284. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11285. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11286. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11287. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11288. $dailyExpenditureType = '';
  11289. $accountTypeWaste = 5;
  11290. $accountBank = '';
  11291. if ($expenditureBank == '纵横广发') {
  11292. $accountBank = 'CGBDeposit';
  11293. } elseif ($expenditureBank == '纵横工行') {
  11294. $accountBank = 'ICBCDeposit';
  11295. } elseif ($expenditureBank == '华润银行') {
  11296. $accountBank = 'HUADeposit';
  11297. } elseif ($expenditureBank == '个人广发') {
  11298. $accountBank = 'PersonalDeposit';
  11299. }
  11300. if (empty ( $accountBank ))
  11301. die ( 'illegal request' );
  11302. $itemWaste = array (
  11303. 'accountPrice' => - $expenditurePrice
  11304. );
  11305. if ($expenditureBank == '个人广发') {
  11306. $itemWaste = array (
  11307. 'accountPrice' => $expenditurePrice
  11308. );
  11309. }
  11310. if ($expenditureType == 4 || $expenditureType == 6) {
  11311. $dailyExpenditureType = 4;
  11312. if ($expenditureMsg == '公司固定') {
  11313. $accountTypeWaste = 9;
  11314. } elseif ($expenditureMsg == '公司活期') {
  11315. $accountTypeWaste = 10;
  11316. } elseif ($expenditureMsg == '个人(GR)') {
  11317. $accountBank = 'PersonalDeposit';
  11318. }
  11319. $itemWaste = array (
  11320. 'accountPrice' => $expenditurePrice
  11321. );
  11322. } elseif ($expenditureType == 1) {
  11323. $dailyExpenditureType = 1;
  11324. } elseif ($expenditureType == 2) {
  11325. $dailyExpenditureType = 2;
  11326. } elseif ($expenditureType == 3) {
  11327. $dailyExpenditureType = 3;
  11328. } elseif ($expenditureType == 5) {
  11329. $dailyExpenditureType = 5;
  11330. }
  11331. if (empty ( $dailyExpenditureType ))
  11332. die ( 'illegal request' );
  11333. Doo::loadModel ( "accountBook" );
  11334. $accountBook = new accountBook ();
  11335. $accountBook->expenditureType = $expenditureType;
  11336. $accountBook->expenditureMsg = $expenditureMsg;
  11337. $accountBook->expenditurePrice = $expenditurePrice;
  11338. $accountBook->expenditureBank = $expenditureBank;
  11339. $accountBook->expenditureDate = $expenditureDate;
  11340. $accountBook->remarks = $remarks;
  11341. $accountBook->expensesType = 2;
  11342. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11343. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11344. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11345. $id = $accountBook->insert ();
  11346. //
  11347. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11348. Doo::loadModel ( "accountBookStatistics" );
  11349. $accountBookStatistics = new accountBookStatistics ();
  11350. $item = array (
  11351. 'date' => date ( "Y-m-d" ),
  11352. 'expenditureType' => $abDetail ['expenditureType'],
  11353. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11354. 'aid' => $abDetail ['aid']
  11355. );
  11356. if ($abDetail ['expensesType'] == 2) {
  11357. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11358. $item += array (
  11359. 'financingPrice' => $expenditurePrice,
  11360. 'expensesType' => 3
  11361. );
  11362. } elseif ($abDetail ['expenditureType'] == 5) {
  11363. $item += array (
  11364. 'payPrice' => $abDetail ['expenditurePrice'],
  11365. 'expensesType' => $abDetail ['expensesType']
  11366. );
  11367. } else {
  11368. $item += array (
  11369. 'payPrice' => $abDetail ['expenditurePrice'],
  11370. 'expensesType' => $abDetail ['expensesType']
  11371. );
  11372. }
  11373. }
  11374. $accountBookStatistics->setAccountBookStatistics ( $item );
  11375. // 公司流水记录
  11376. Doo::loadModel ( 'wasteBook' );
  11377. $wasteBook = new wasteBook ();
  11378. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11379. // 银行
  11380. if (empty ( $abDetail )) {
  11381. $itemWaste += array (
  11382. 'accountPriceShow' => $expenditurePrice,
  11383. 'dataID' => $id,
  11384. 'expensesType' => 2,
  11385. 'accountType' => $accountTypeWaste,
  11386. 'dailyExpenditureType' => $expenditureType,
  11387. 'accountBank' => $accountBank,
  11388. 'category' => $this->staff [0] ['category'],
  11389. 'cid' => $this->staff [0] ['cid'],
  11390. 'name' => $this->staff [0] ['username'],
  11391. 'sid' => $this->staff [0] ['sid'],
  11392. 'inputDate' => date ( "Y-m-d H:i:s" )
  11393. );
  11394. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11395. }
  11396. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11397. if ($expenditureType == 4 || $expenditureType == 6) {
  11398. $accountBank = 'CGBDeposit';
  11399. $dailyIncomeType = 7;
  11400. $receivedBank = '纵横广发';
  11401. if ($expenditureType == 6) {
  11402. $accountBank = 'ICBCDeposit';
  11403. $receivedBank = '纵横工行';
  11404. $dailyIncomeType = 9;
  11405. }
  11406. // 添加一笔收入
  11407. $accountBook = new accountBook ();
  11408. $accountBook->accountType = $dailyIncomeType;
  11409. $accountBook->accountMsg = $expenditureMsg;
  11410. $accountBook->receivedPrice = $expenditurePrice;
  11411. $accountBook->receivedBank = $receivedBank;
  11412. $accountBook->receivedDate = $expenditureDate;
  11413. $accountBook->remarks = $remarks;
  11414. $accountBook->expensesType = 1;
  11415. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11416. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11417. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11418. $id = $accountBook->insert ();
  11419. // 添加一笔收入流水
  11420. $itemWaste = array (
  11421. 'accountPriceShow' => $expenditurePrice,
  11422. 'accountPrice' => - $expenditurePrice,
  11423. 'dataID' => $id,
  11424. 'expensesType' => 1,
  11425. 'accountType' => $accountTypeWaste,
  11426. 'dailyIncomeType' => $dailyIncomeType,
  11427. 'accountBank' => $accountBank,
  11428. 'category' => $this->staff [0] ['category'],
  11429. 'cid' => $this->staff [0] ['cid'],
  11430. 'name' => $this->staff [0] ['username'],
  11431. 'sid' => $this->staff [0] ['sid'],
  11432. 'inputDate' => date ( "Y-m-d H:i:s" )
  11433. );
  11434. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11435. }
  11436. }
  11437. return '/payments';
  11438. }
  11439. /**
  11440. * 所有收支
  11441. */
  11442. function paymentsAchieve() {
  11443. $page_size = 12;
  11444. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11445. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11446. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11447. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11448. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11449. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11450. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11451. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11452. Doo::loadModel ( "accountBookStatistics" );
  11453. $accountBookStatistics = new accountBookStatistics ();
  11454. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11455. $data ['statisticsList'] = $statisticsList;
  11456. Doo::loadModel ( "accountBook" );
  11457. $accountBook = new accountBook ();
  11458. $con = '';
  11459. if ($expensesType == 'INCOME')
  11460. $con = ' and expensesType=1 ';
  11461. elseif ($expensesType == 'PAY')
  11462. $con = ' and expensesType=2 ';
  11463. $dateArr = explode ( ':', $date );
  11464. $D1 = $dateString = '';
  11465. $D2 = '';
  11466. if (! empty ( $date )) {
  11467. $D1 = $dateArr [0];
  11468. if (isset ( $dateArr [1] ))
  11469. $D2 = $dateArr [1];
  11470. else
  11471. $D2 = '';
  11472. $dateString = $D1 . " : " . $D2;
  11473. }
  11474. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11475. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11476. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11477. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11478. if (! empty ( $price ))
  11479. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11480. if ($submitType == 1) {
  11481. if ($accountType != '') {
  11482. $expenditureType = '';
  11483. $con .= ' and accountType=' . $accountType;
  11484. if (! empty ( $accountMsg ))
  11485. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11486. }
  11487. } elseif ($submitType == 2) {
  11488. if ($expenditureType != '') {
  11489. $accountType = $accountMsg = '';
  11490. $con .= ' and expenditureType=' . $expenditureType;
  11491. }
  11492. } else {
  11493. $accountType = $accountMsg = $expenditureType = '';
  11494. }
  11495. $sql = "" . $con;
  11496. $action = "paymentsAchieve";
  11497. $get = '/' . $expensesType."?accountType=".$accountType."&expenditureType=".$expenditureType."&submitType=".$submitType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11498. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11499. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11500. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11501. $data ['expenditureType'] = $expenditureType;
  11502. $data ['accountMsg'] = $accountMsg;
  11503. $data ['accountType'] = $accountType;
  11504. $data ['inputDate'] = $date;
  11505. $data ['price'] = $price;
  11506. $data ['expensesType'] = $expensesType;
  11507. $data ['page'] = $pageinfo;
  11508. $data ['list'] = $list;
  11509. $data ['memu'] = "receipt";
  11510. $data ['staff'] = $this->staff;
  11511. $data ['receiptMemu'] = 'payments';
  11512. $data ['verifyId'] = $this->verifyId;
  11513. $data ['executeId'] = $this->executeId;
  11514. $this->render ( "/expenses/paymentsAchieve", $data );
  11515. }
  11516. function paymentsIncomeUpdateDo() {
  11517. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11518. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11519. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11520. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11521. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11522. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11523. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11524. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11525. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11526. Doo::loadClass ( 'XDeode' );
  11527. $XDeode = new XDeode ( 5 );
  11528. $aid = $XDeode->decode ( $aidKey );
  11529. Doo::loadModel ( "accountBook" );
  11530. $accountBook = new accountBook ();
  11531. //
  11532. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11533. $price = $receivedPrice - $abDetail [inComePrice];
  11534. Doo::loadModel ( "accountBookStatistics" );
  11535. $accountBookStatistics = new accountBookStatistics ();
  11536. if ($abDetail ['accountType'] == 7) {
  11537. $item += array (
  11538. 'date' => date ( "Y-m-d" ),
  11539. 'financingPrice' => - $price,
  11540. 'expensesType' => 3,
  11541. 'aid' => $abDetail ['aid']
  11542. );
  11543. } elseif ($abDetail ['accountType'] == 8) {
  11544. $item += array (
  11545. 'date' => date ( "Y-m-d" ),
  11546. 'expensesType' => $abDetail ['expensesType'],
  11547. 'inComePrice' => - $price,
  11548. 'aid' => $abDetail ['aid']
  11549. );
  11550. } else {
  11551. $item = array (
  11552. 'date' => date ( "Y-m-d" ),
  11553. 'expensesType' => $abDetail ['expensesType'],
  11554. 'inComePrice' => $price,
  11555. 'aid' => $abDetail ['aid']
  11556. );
  11557. }
  11558. $accountBookStatistics->setAccountBookStatistics ( $item );
  11559. $accountBook->accountType = $accountType;
  11560. $accountBook->accountMsg = $accountMsg;
  11561. $accountBook->receivedPrice = $receivedPrice;
  11562. $accountBook->receivedMsg = $receivedMsg;
  11563. $accountBook->receivedBank = $receivedBank;
  11564. $accountBook->receivedDate = $receivedDate;
  11565. $accountBook->remarks = $remarks;
  11566. $accountBook->aid = $aid;
  11567. $accountBook->update ();
  11568. }
  11569. return '/paymentsAchieve';
  11570. }
  11571. function paymentsExpenditureEdiDo() {
  11572. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11573. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11574. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11575. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11576. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11577. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11578. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11579. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11580. Doo::loadClass ( 'XDeode' );
  11581. $XDeode = new XDeode ( 5 );
  11582. $aid = $XDeode->decode ( $aidKey );
  11583. Doo::loadModel ( "accountBook" );
  11584. $accountBook = new accountBook ();
  11585. // 汇总信息
  11586. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11587. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11588. Doo::loadModel ( "accountBookStatistics" );
  11589. $accountBookStatistics = new accountBookStatistics ();
  11590. if ($abDetail ['expenditureType'] == 4) {
  11591. $item += array (
  11592. 'date' => date ( "Y-m-d" ),
  11593. 'financingPrice' => $price,
  11594. 'expensesType' => 3,
  11595. 'aid' => $abDetail ['aid']
  11596. );
  11597. } elseif ($abDetail ['expenditureType'] == 5) {
  11598. $item += array (
  11599. 'date' => date ( "Y-m-d" ),
  11600. 'expensesType' => $abDetail ['expensesType'],
  11601. 'payPrice' => $price,
  11602. 'aid' => $abDetail ['aid']
  11603. );
  11604. } else {
  11605. $item = array (
  11606. 'date' => date ( "Y-m-d" ),
  11607. 'expensesType' => $abDetail ['expensesType'],
  11608. 'payPrice' => $price,
  11609. 'aid' => $abDetail ['aid']
  11610. );
  11611. }
  11612. $accountBookStatistics->setAccountBookStatistics ( $item );
  11613. //
  11614. $accountBook->expenditureType = $expenditureType;
  11615. $accountBook->expenditureMsg = $expenditureMsg;
  11616. $accountBook->expenditurePrice = $expenditurePrice;
  11617. $accountBook->expenditureBank = $expenditureBank;
  11618. $accountBook->remarks = $remarks;
  11619. $accountBook->expenditureDate = $expenditureDate;
  11620. $accountBook->aid = $aid;
  11621. $id = $accountBook->update ();
  11622. }
  11623. return '/paymentsAchieve';
  11624. }
  11625. function paymentsDelDo() {
  11626. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11627. if (! empty ( $aidKey )) {
  11628. Doo::loadClass ( 'XDeode' );
  11629. $XDeode = new XDeode ( 5 );
  11630. $aid = $XDeode->decode ( $aidKey );
  11631. Doo::loadModel ( "accountBook" );
  11632. $accountBook = new accountBook ();
  11633. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11634. if (empty ( $abDetail ))
  11635. die ( 'illegal request' );
  11636. // 删除收支
  11637. Doo::loadModel ( "accountBookStatistics" );
  11638. $accountBookStatistics = new accountBookStatistics ();
  11639. $item = array (
  11640. 'date' => date ( "Y-m-d" ),
  11641. 'aid' => $abDetail ['aid']
  11642. );
  11643. $accountType = '';
  11644. if ($abDetail ['expensesType'] == 1) {
  11645. $accountType = 6;
  11646. if ($abDetail ['accountType'] != 7) {
  11647. $item += array (
  11648. 'expensesType' => $abDetail ['expensesType'],
  11649. 'inComePrice' => - $abDetail ['receivedPrice']
  11650. );
  11651. } else {
  11652. $item += array (
  11653. 'financingPrice' => $abDetail ['receivedPrice'],
  11654. 'expensesType' => 3
  11655. );
  11656. }
  11657. } elseif ($abDetail ['expensesType'] == 2) {
  11658. $accountType = 5;
  11659. if ($abDetail ['accountType'] != 7) {
  11660. $item += array (
  11661. 'expensesType' => $abDetail ['expensesType'],
  11662. 'payPrice' => - $abDetail ['expenditurePrice']
  11663. );
  11664. } else {
  11665. $item += array (
  11666. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11667. 'expensesType' => 3
  11668. );
  11669. }
  11670. }
  11671. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11672. if ($abDetail ['expenditureMsg'] == '公司固定')
  11673. $accountType = 9;
  11674. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11675. $accountType = 10;
  11676. }
  11677. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11678. if ($abDetail ['accountMsg'] == '公司固定')
  11679. $accountType = 9;
  11680. elseif ($abDetail ['accountMsg'] == '公司活期')
  11681. $accountType = 10;
  11682. }
  11683. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11684. $accountType = 10;
  11685. }
  11686. $accountBookStatistics->setAccountBookStatistics ( $item );
  11687. $accountBook->delete ( array (
  11688. 'where' => 'aid=' . $aid,
  11689. 'limit' => 1
  11690. ) );
  11691. // 删除收入流水
  11692. //TODO 2020-07-23 删除新增理财和银行存款流水
  11693. if (! empty ( $accountType )) {
  11694. Doo::loadModel ( 'wasteBook' );
  11695. $wasteBook = new wasteBook ();
  11696. $wasteBook->delete ( array (
  11697. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11698. 'limit' => 1
  11699. ) );
  11700. }
  11701. }
  11702. return '/paymentsAchieve';
  11703. }
  11704. function paymentsCollect() {
  11705. Doo::loadModel ( "execute" );
  11706. $execute = new execute ();
  11707. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11708. die ( 'illegal request' );
  11709. }
  11710. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11711. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11712. Doo::loadModel ( "accountBookStatistics" );
  11713. $accountBookStatistics = new accountBookStatistics ();
  11714. Doo::loadClass ( 'receipt.func' );
  11715. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11716. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11717. $data ['html'] = $html ['html'];
  11718. $data ['inSum'] = $html ['sum'];
  11719. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11720. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11721. $data ['payHtml'] = $html ['html'];
  11722. $data ['paySum'] = $html ['sum'];
  11723. // 余额统计
  11724. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11725. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11726. include './protected/config/wasteBook.conf.php';
  11727. Doo::loadModel ( 'wasteBook' );
  11728. $wasteBook = new wasteBook ();
  11729. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11730. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11731. // 获得年份之前所有金额
  11732. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11733. // print_r($detail);
  11734. // $waste['total'];
  11735. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11736. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11737. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11738. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11739. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11740. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11741. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11742. if (date ( 'Y' ) > $year) {
  11743. $limitMonth = 12;
  11744. }
  11745. for($i = 1; $i <= 12; $i ++) {
  11746. $inComeA = $payB = 0;
  11747. $falg = true;
  11748. foreach ( $inComePay as $key => $value ) {
  11749. if ($value ['month'] == $i) {
  11750. $falg = false;
  11751. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11752. $inSum += $value ['accountPrice'];
  11753. $showInSum += $value ['accountPriceShow'];
  11754. $inComeA = $value ['accountPrice'];
  11755. break;
  11756. }
  11757. }
  11758. if ($falg)
  11759. $inComeHtml .= '<td class="taR">-</td>';
  11760. $payFalg = true;
  11761. foreach ( $pay as $key => $value ) {
  11762. if ($value ['month'] == $i) {
  11763. $payFalg = false;
  11764. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11765. $paySum += $value ['accountPrice'];
  11766. $showPaySum += $value ['accountPriceShow'];
  11767. $payB = $value ['accountPrice'];
  11768. break;
  11769. }
  11770. }
  11771. if ($payFalg)
  11772. $payHtml .= '<td class="taR">-</td>';
  11773. if (empty ( $balanceC ) || $limitMonth < $i)
  11774. $lastBalanceHtml .= '<td class="taR">-</td>';
  11775. else
  11776. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11777. $balanceC = $balanceC + $inComeA + $payB;
  11778. $balanceSum += $balanceC;
  11779. if (empty ( $balanceC ) || $limitMonth < $i)
  11780. $BalanceHtml .= '<td class="taR">-</td>';
  11781. else
  11782. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11783. // 余额统计
  11784. }
  11785. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11786. $data ['inComeHtml'] = $inComeHtml;
  11787. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11788. $data ['payBalanceHtml'] = $payHtml;
  11789. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11790. $data ['BalanceHtml'] = $BalanceHtml;
  11791. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11792. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11793. $mothHtml = "";
  11794. for($i = 1; $i <= 12; $i ++) {
  11795. if ($moth == $i)
  11796. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11797. else
  11798. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11799. }
  11800. $data ['mothHtml'] = $mothHtml;
  11801. $dateHtml = "";
  11802. $now = date ( "Y" );
  11803. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11804. if ($YEARD <= $now) {
  11805. $dateHtml .= '<option ';
  11806. if ($year == $YEARD) {
  11807. $dateHtml .= 'selected ';
  11808. }
  11809. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11810. }
  11811. }
  11812. $data ['dateHtml'] = $dateHtml;
  11813. $data ['year'] = $year;
  11814. $data ['memu'] = "receipt";
  11815. $data ['staff'] = $this->staff;
  11816. $data ['receiptMemu'] = 'paymentsCollect';
  11817. $data ['verifyId'] = $this->verifyId;
  11818. $data ['executeId'] = $this->executeId;
  11819. $this->render ( "/expenses/paymentsCollect", $data );
  11820. }
  11821. function paymentsCollectDay() {
  11822. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11823. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11824. if (empty ( $moth ))
  11825. return 'paymentsCollect';
  11826. Doo::loadModel ( "accountBookStatistics" );
  11827. $accountBookStatistics = new accountBookStatistics ();
  11828. $i = 2;
  11829. $y = 2013;
  11830. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11831. Doo::loadClass ( 'receipt.func' );
  11832. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11833. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11834. $data ['html'] = $html ['html'];
  11835. $data ['inSum'] = $html ['sum'];
  11836. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11837. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11838. $data ['payHtml'] = $html ['html'];
  11839. $data ['paySum'] = $html ['sum'];
  11840. $mothHtml = "";
  11841. for($i = 1; $i <= 12; $i ++) {
  11842. if ($moth == $i)
  11843. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11844. else
  11845. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11846. }
  11847. $data ['mothHtml'] = $mothHtml;
  11848. $data ['year'] = $year;
  11849. // 余额
  11850. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11851. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11852. include './protected/config/wasteBook.conf.php';
  11853. Doo::loadModel ( 'wasteBook' );
  11854. $wasteBook = new wasteBook ();
  11855. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11856. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11857. // 获得年份之前所有金额
  11858. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11859. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11860. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11861. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11862. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11863. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11864. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11865. // $balanceC = 0;
  11866. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11867. $limitDay = date ( 'd' );
  11868. $monthLK = ( int ) date ( 'm' );
  11869. if (date ( 'Y' ) > $year) {
  11870. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11871. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11872. $limitDay = 0;
  11873. }
  11874. for($i = 1; $i <= $day; $i ++) {
  11875. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11876. $inComeA = $payB = 0;
  11877. $falg = true;
  11878. foreach ( $inComePay as $key => $value ) {
  11879. if ($value ['day'] == $i) {
  11880. $falg = false;
  11881. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11882. $inSum += $value ['accountPrice'];
  11883. $showInSum += $value ['accountPriceShow'];
  11884. $inComeA = $value ['accountPrice'];
  11885. break;
  11886. }
  11887. }
  11888. if ($falg)
  11889. $inComeHtml .= '<td class="taR">-</td>';
  11890. $payFalg = true;
  11891. foreach ( $pay as $key => $value ) {
  11892. if ($value ['day'] == $i) {
  11893. $payFalg = false;
  11894. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11895. $paySum += $value ['accountPrice'];
  11896. $showPaySum += $value ['accountPriceShow'];
  11897. $payB = $value ['accountPrice'];
  11898. break;
  11899. }
  11900. }
  11901. if ($payFalg)
  11902. $payHtml .= '<td class="taR">-</td>';
  11903. if (empty ( $balanceC ) || $limitDay < $i)
  11904. $lastBalanceHtml .= '<td class="taR">-</td>';
  11905. else
  11906. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11907. $balanceC = $balanceC + $inComeA + $payB;
  11908. $balanceSum += $balanceC;
  11909. if (empty ( $balanceC ) || $limitDay < $i)
  11910. $BalanceHtml .= '<td class="taR">-</td>';
  11911. else
  11912. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11913. }
  11914. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11915. $data ['inComeHtml'] = $inComeHtml;
  11916. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11917. $data ['payBalanceHtml'] = $payHtml;
  11918. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11919. $data ['BalanceHtml'] = $BalanceHtml;
  11920. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11921. $data ['dayHtml'] = $dayHtml;
  11922. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11923. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11924. $dateHtml = "";
  11925. $now = date ( "Y" );
  11926. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11927. if ($YEARD <= $now) {
  11928. $dateHtml .= '<option ';
  11929. if ($year == $YEARD) {
  11930. $dateHtml .= 'selected ';
  11931. }
  11932. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11933. }
  11934. }
  11935. $data ['dateHtml'] = $dateHtml;
  11936. $data ['memu'] = "receipt";
  11937. $data ['staff'] = $this->staff;
  11938. $data ['receiptMemu'] = 'paymentsCollect';
  11939. $data ['verifyId'] = $this->verifyId;
  11940. $data ['executeId'] = $this->executeId;
  11941. $this->render ( "/expenses/paymentsCollectDay", $data );
  11942. }
  11943. // 公司流水
  11944. function wasteBook() {
  11945. Doo::loadModel ( "execute" );
  11946. $execute = new execute ();
  11947. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11948. die ( 'illegal request' );
  11949. }
  11950. Doo::loadModel ( 'wasteBook' );
  11951. $wasteBook = new wasteBook ();
  11952. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11953. include './protected/config/wasteBook.conf.php';
  11954. $wasteBook = new wasteBook ();
  11955. $list=$wasteBook->GetAll();
  11956. $total=0;
  11957. $noInPrice=array(
  11958. "LC_HQ"=>0,
  11959. "LC_GD"=>0,
  11960. //工行理财固定
  11961. "GH_LC_GD"=>0,
  11962. "CK"=>0,
  11963. "HQ1"=>0,
  11964. );
  11965. //理财活期
  11966. $GD_LC_HQ=0;$GH_LC_HQ=0;
  11967. //理财固定
  11968. $GD_LC_GD=0;$GR_LC_GD=0;
  11969. //存款
  11970. $GF_CK=0;$GH_CK=0;$GR_CK=0;$ZH_CK=0;
  11971. foreach ($list as $key=>$value){
  11972. // 存款 旧理财部分 dailyType=0 accountType=9,10
  11973. if($value['dailyType']==0){
  11974. //旧理财部分 -活期
  11975. if($value['accountType']==10){
  11976. //广发理财
  11977. if($value['accountBank']=="CGBDeposit"){
  11978. $GD_LC_HQ+=$value["accountPrice"];
  11979. //工行理财
  11980. }elseif($value['accountBank']=="ICBCDeposit"){
  11981. $GH_LC_HQ+=$value["accountPrice"];
  11982. }else{
  11983. //未统计到金额
  11984. $noInPrice['LC_HQ']+=$value["accountPrice"];
  11985. }
  11986. //旧理财部分 -固定
  11987. }elseif($value['accountType']==9){
  11988. //广发理财
  11989. if($value['accountBank']=="CGBDeposit"){
  11990. $GD_LC_HQ+=$value["accountPrice"];
  11991. //个人理财--- 原是工行理财固定-不统计入内
  11992. }elseif($value['accountBank']=="ICBCDeposit"){
  11993. // $GR_LC_GD+=$value["accountPrice"];
  11994. $noInPrice['GH_LC_GD']+=$value["accountPrice"];
  11995. }else{
  11996. //未统计到金额
  11997. $noInPrice['LC_GD']+=$value["accountPrice"];
  11998. }
  11999. //存款
  12000. }else{
  12001. //广发存款
  12002. if($value['accountBank']=="CGBDeposit"){
  12003. $GF_CK+=$value["accountPrice"];
  12004. //工行存款
  12005. }elseif($value['accountBank']=="ICBCDeposit"){
  12006. $GH_CK+=$value["accountPrice"];
  12007. //个人存款
  12008. }elseif($value['accountBank']=="PersonalDeposit"){
  12009. $GR_CK+=$value["accountPrice"];
  12010. //(广发)纵横知道--原华润银行
  12011. }elseif($value['accountBank']=="HUADeposit"){
  12012. $ZH_CK+=$value["accountPrice"];
  12013. }else{
  12014. $noInPrice['CK']+=$value["accountPrice"];
  12015. }
  12016. }
  12017. }else{
  12018. // 理财部分 其中 公司账户为存款部分
  12019. //理财账号
  12020. if($value['operatingBankType']==1){
  12021. //广发理财活期
  12022. if ($value['depositMethod'] == '活期' && $value['accountBank'] == 'CGBDeposit') {
  12023. $GD_LC_HQ += $value['accountPrice'];
  12024. //工行理财活期
  12025. }elseif ($value['depositMethod'] == '活期' && $value['accountBank'] == 'ICBCDeposit') {
  12026. $GH_LC_HQ += $value['accountPrice'];
  12027. //个人理财固定(广发)
  12028. }elseif ($value['depositMethod'] == '固定' && $value['accountBank'] == 'CGBPersonalDeposit') {
  12029. $GR_LC_GD += $value['accountPrice'];
  12030. //广发理财-固定
  12031. }elseif ($value['depositMethod'] == '固定' && $value['accountBank'] == 'CGBDeposit') {
  12032. $GD_LC_GD += $value['accountPrice'];
  12033. }else{
  12034. $noInPrice['HQ1']+=$value["accountPrice"];
  12035. }
  12036. //公司账号
  12037. }elseif($value['operatingBankType']==2){
  12038. //(纵横广发)广发存款
  12039. if ( $value['accountBank'] == 'CGBDeposit') {
  12040. $GF_CK += $value['accountPrice'];
  12041. }elseif ( $value['accountBank'] == 'ICBCDeposit') {
  12042. //工行存款
  12043. $GH_CK += $value['accountPrice'];
  12044. }elseif ( $value['accountBank'] == 'PersonalDeposit') {
  12045. //个人存款
  12046. $GR_CK += $value['accountPrice'];
  12047. }else{
  12048. $noInPrice['HQ2']+=$value["accountPrice"];
  12049. }
  12050. }else{
  12051. $noInPrice['HQ3']+=$value["accountPrice"];
  12052. }
  12053. }
  12054. }
  12055. $data['GF_CK']=bcadd($GF_CK,$waste['bank']['CGBDeposit'],2);
  12056. $data['ZH_CK']=bcadd($ZH_CK,$waste['bank']['HUADeposit'],2);
  12057. $data['CK_TO']=bcadd($data['GF_CK'],$data['ZH_CK'],2);
  12058. $data['GD_LC_HQ']=bcadd($GD_LC_HQ,$waste['financial']['current']['CGBDeposit'],2);
  12059. $data['GH_LC_HQ']=bcadd($GH_LC_HQ,$waste['financial']['current']['ICBCDeposit'],2);
  12060. $data['GH_CK']=bcadd($GH_CK,$waste['bank']['ICBCDeposit'],2);
  12061. $data['GR_CK']=bcadd($GR_CK,$waste['bank']['PersonalDeposit'],2);
  12062. $data['HQ_TO']=bcadd($data['GD_LC_HQ']+$data['GH_LC_HQ'],$data['GH_CK']+$data['GR_CK'],2);
  12063. $data['GD_LC_GD']=bcadd($GD_LC_GD,$waste['financial']['fixed']['CGBDeposit'],2);
  12064. $data['GR_LC_GD']=bcadd($GR_LC_GD,$waste['financial']['fixed']['ICBCDeposit'],2);
  12065. $data['total']=bcadd($data['CK_TO']+$data['HQ_TO'],$data['GD_LC_GD']+$data['GR_LC_GD'],2);
  12066. // echo $waste;
  12067. // $data['total']=bcadd($total,$waste,2);
  12068. // include './protected/config/wasteBook.conf.php';
  12069. // Doo::loadModel ( 'wasteBook' );
  12070. // $wasteBook = new wasteBook ();
  12071. // $data ['store']=$waste;
  12072. // $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  12073. // //print_r($waste);
  12074. // //1-收入支出流水金额合计
  12075. // $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  12076. // //echo $waste['bank']['CGBDeposit'].'</br>';
  12077. // //2020-07-20 -理财相关-面板数据
  12078. // Doo::loadClass ( 'wasteBook.finances.func' );
  12079. // $financesStatistics=$wasteBook->getFinancesStatistics();
  12080. // //print_r($waste);
  12081. // // 展示使用
  12082. // // 收入
  12083. // //print_r($inComeStatistics);
  12084. // $wasteStatistics['CGBDeposit']=0;
  12085. // $wasteStatistics['ICBCDeposit']=0;
  12086. // $wasteStatistics['HUADeposit']=0;
  12087. // $wasteStatistics['PersonalDeposit']=0;
  12088. // foreach ($inComeStatistics['incomeStatistics'] as $value ){
  12089. // if($value['accountBank']=='CGBDeposit'){
  12090. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12091. // }
  12092. // if($value['accountBank']=='ICBCDeposit'){
  12093. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12094. // }
  12095. // if($value['accountBank']=='HUADeposit'){
  12096. // $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  12097. // }
  12098. // if($value['accountBank']=='PersonalDeposit'){
  12099. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12100. // }
  12101. // }
  12102. // $data ['wasteStatistics']=$wasteStatistics;
  12103. // //支出
  12104. // $wasteStatistics['CGBDeposit']=0;
  12105. // $wasteStatistics['ICBCDeposit']=0;
  12106. // $wasteStatistics['HUADeposit']=0;
  12107. // $wasteStatistics['PersonalDeposit']=0;
  12108. // foreach ($inComeStatistics['expenditureStatistics'] as $value ){
  12109. // if($value['accountBank']=='CGBDeposit'){
  12110. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12111. // }
  12112. // if($value['accountBank']=='ICBCDeposit'){
  12113. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12114. // }
  12115. // if($value['accountBank']=='HUADeposit'){
  12116. // $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  12117. // }
  12118. // if($value['accountBank']=='PersonalDeposit'){
  12119. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12120. // }
  12121. // }
  12122. // $data ['wastePay']=$wasteStatistics;
  12123. // //理财公司账号部分
  12124. // $wasteStatistics['CGBDeposit']=0;
  12125. // $wasteStatistics['ICBCDeposit']=0;
  12126. // $wasteStatistics['HUADeposit']=0;
  12127. // $wasteStatistics['PersonalDeposit']=0;
  12128. // foreach ($financesStatistics['companyAccount'] as $value ){
  12129. // //(纵横广发)广发存款
  12130. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12131. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12132. // }
  12133. // //工行存款
  12134. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12135. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12136. // }
  12137. // //个人存款
  12138. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12139. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12140. // }
  12141. // }
  12142. // $data ['wasteCompanyAccount']=$wasteStatistics;
  12143. // //理财部分的金额计算
  12144. // $waste =_getFinancesWBS ( $waste, $financesStatistics );
  12145. // //echo $waste['bank']['CGBDeposit'].'</br>';;
  12146. // //存款面板数据--日常收支改变后的金额汇总
  12147. // $bankSavingsStatistics=$wasteBook->getBankSavingsStatistics();
  12148. // $waste =_getBankSavingsWBS ( $waste, $bankSavingsStatistics );
  12149. // //展示调试BUG-使用
  12150. // //print_r($bankSavingsStatistics);
  12151. // $wasteStatistics['CGBDeposit']=0;
  12152. // $wasteStatistics['ICBCDeposit']=0;
  12153. // $wasteStatistics['PersonalDeposit']=0;
  12154. // foreach ($bankSavingsStatistics as $value ){
  12155. // //(纵横广发)广发存款
  12156. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12157. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12158. // }
  12159. // //工行存款
  12160. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12161. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12162. // }
  12163. // //个人存款
  12164. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12165. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12166. // }
  12167. // }
  12168. // $data ['wasteNewPay']=$wasteStatistics;
  12169. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12170. //
  12171. // $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'];
  12172. // $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12173. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12174. // print_r($waste);
  12175. // $data ['total'] = number_format($total,2);
  12176. // $data ['CGBDeposit_total'] = number_format($CGBDeposit_total,2);
  12177. // $cashBalance=$CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12178. // $data['cashBalance']= number_format($cashBalance,2);
  12179. // $waste ['bank'] ['CGBDeposit']=sprintf("%.2f", round($waste ['bank'] ['CGBDeposit'], 2));
  12180. // $data ['waste'] = $waste;
  12181. // 月流水数据结构
  12182. $monthStatistics = array ();
  12183. $incomeMothStatistics = array ();
  12184. $expenditureMothStatistics = array ();
  12185. for($i = 1; $i <= 12; $i ++) {
  12186. $month = date ( 'Y' ) . '-' . $i;
  12187. if ($i < 10)
  12188. $month = date ( 'Y' ) . '-0' . $i;
  12189. array_push ( $monthStatistics, $month );
  12190. }
  12191. foreach ( $monthStatistics as $value ) {
  12192. $falg = true;
  12193. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12194. if ($value == $v ['inputDate']) {
  12195. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12196. $falg = false;
  12197. }
  12198. }
  12199. if ($falg) {
  12200. array_push ( $incomeMothStatistics, '' );
  12201. }
  12202. $falgEx = true;
  12203. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12204. if ($value == $v ['inputDate']) {
  12205. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12206. $falg = false;
  12207. }
  12208. }
  12209. if ($falgEx) {
  12210. array_push ( $expenditureMothStatistics, '' );
  12211. }
  12212. }
  12213. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12214. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12215. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12216. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12217. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12218. // print_r($incomeList);
  12219. $data ['expenditureList'] = $expenditureList;
  12220. $data ['incomeList'] = $incomeList;
  12221. $data ['memu'] = "receipt";
  12222. $data ['staff'] = $this->staff;
  12223. $data ['receiptMemu'] = 'wasteBook';
  12224. $data ['verifyId'] = $this->verifyId;
  12225. $data ['executeId'] = $this->executeId;
  12226. $this->render ( "/expenses/wasteBook", $data );
  12227. }
  12228. function wasteBookIncome() {
  12229. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12230. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12231. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12232. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12233. $data ['dailyIncomeType'] = $dailyIncomeType;
  12234. Doo::loadModel ( 'wasteBook' );
  12235. $wasteBook = new wasteBook ();
  12236. Doo::loadModel ( 'L_category' );
  12237. $L_category = new L_category ();
  12238. Doo::loadClass ( 'XDeode' );
  12239. $XDeode = new XDeode ( 5 );
  12240. $year=date("Y");
  12241. $theDay=date("Y-m-d");
  12242. $dateArr = explode ( ':', $date );
  12243. $D1 = '';
  12244. $D2 = '';
  12245. $con = '';
  12246. if (! empty ( $date )) {
  12247. $D1 = $dateArr [0];
  12248. $D2 = $dateArr [1];
  12249. }
  12250. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12251. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12252. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12253. $con = ' and inputDate = "' . $D1 . '"';
  12254. else{
  12255. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12256. }
  12257. if ($cid != 'ALL') {
  12258. $cid = $XDeode->decode ( $cid );
  12259. $con .= ' and cid = "' . $cid . '"';
  12260. }
  12261. if ($accountType != 'ALL') {
  12262. if ($accountType == 'INVOICE') {
  12263. $con .= ' and (accountType = 7 or accountType = 8)';
  12264. } elseif ($accountType == 'PAYMENTS') {
  12265. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12266. if ($dailyIncomeType != 'ALL') {
  12267. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12268. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12269. }
  12270. }
  12271. }
  12272. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12273. foreach ($incomeList as $key=>$value){
  12274. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12275. $wasteBook = new wasteBook ();
  12276. $wasteBook->wid = $value['wid'];
  12277. $wasteBook->synPaymentDate = 1;
  12278. $wasteBook->inputDate = $value['data']['receivedDate'];
  12279. $wasteBook->update();
  12280. }
  12281. }
  12282. $sum = 0;$thsDaySum=0;
  12283. foreach ( $incomeList as $key => $value ) {
  12284. $sum += $value ['accountPrice'];
  12285. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12286. $thsDaySum+=$value ['accountPrice'];
  12287. }
  12288. }
  12289. // print_r($incomeList);
  12290. // 获得办事和部门
  12291. $categoryList = $L_category->getCategory ();
  12292. $data ['accountType'] = $accountType;
  12293. $data ['cid'] = $cid;
  12294. $data ['categoryList'] = $categoryList;
  12295. $data ['sum'] = $sum;
  12296. $data ['incomeList'] = $incomeList;
  12297. $data ['inputDate'] = $date;
  12298. $data['year']=$year;
  12299. $data ['thsDay'] =$theDay;
  12300. $data ['thsDaySum'] =$thsDaySum;
  12301. $data ['memu'] = "receipt";
  12302. $data ['staff'] = $this->staff;
  12303. $data ['receiptMemu'] = 'wasteBook';
  12304. $data ['verifyId'] = $this->verifyId;
  12305. $data ['executeId'] = $this->executeId;
  12306. $this->render ( "/expenses/wasteBookIncome", $data );
  12307. }
  12308. /**
  12309. * 所有支出
  12310. */
  12311. function wasteBookExpenditure() {
  12312. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12313. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12314. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12315. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12316. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12317. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12318. $data ['receiptType'] = $receiptType;
  12319. Doo::loadModel ( 'wasteBook' );
  12320. $wasteBook = new wasteBook ();
  12321. Doo::loadModel ( 'L_category' );
  12322. $L_category = new L_category ();
  12323. Doo::loadClass ( 'XDeode' );
  12324. $XDeode = new XDeode ( 5 );
  12325. $year=date("Y");
  12326. $theDay=date("Y-m-d");
  12327. $dateArr = explode ( ':', $date );
  12328. $D1 = '';
  12329. $D2 = '';
  12330. $con = '';
  12331. if (! empty ( $date )) {
  12332. $D1 = $dateArr [0];
  12333. $D2 = $dateArr [1];
  12334. }
  12335. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12336. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12337. elseif (! empty ( $D1 ) && empty ( $D2 )){
  12338. $startYear=$D1.":00.00.00";
  12339. $endYear=$D1.":23.59.59";
  12340. $con = ' and inputDate >= "'.$startYear.'" and inputDate <= "'.$endYear.'"';
  12341. }else{
  12342. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12343. }
  12344. if ($cid != 'ALL') {
  12345. $cid = $XDeode->decode ( $cid );
  12346. $con .= ' and cid = "' . $cid . '"';
  12347. }
  12348. if ($accountType != 'ALL') {
  12349. if ($accountType == 'INVOICE') {
  12350. $con .= ' and accountType = 11';
  12351. } elseif ($accountType == 'PAYMENTS') {
  12352. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12353. if ($dailyExpenditureType != 'ALL') {
  12354. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12355. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12356. }
  12357. } elseif ($accountType == 'RECEIPT') {
  12358. if ($receiptType == 'ALL') {
  12359. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12360. } else {
  12361. $receiptType = $XDeode->decode ( $receiptType );
  12362. echo $receiptType;
  12363. if ($receiptType == 1) {
  12364. $con .= ' and (accountType = 1 or accountType=2)';
  12365. } else {
  12366. $con .= ' and accountType = ' . $receiptType;
  12367. }
  12368. }
  12369. }
  12370. }
  12371. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12372. foreach ($incomeList as $key=>$value){
  12373. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12374. $wasteBook = new wasteBook ();
  12375. $wasteBook->wid = $value['wid'];
  12376. $wasteBook->synPaymentDate = 1;
  12377. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12378. $wasteBook->update();
  12379. }
  12380. }
  12381. $sum = 0;$thsDaySum=0;
  12382. foreach ( $incomeList as $key => $value ) {
  12383. $sum += $value ['accountPriceShow'];
  12384. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12385. $thsDaySum+=$value ['accountPriceShow'];
  12386. }
  12387. }
  12388. // print_r($incomeList);
  12389. // 获得办事和部门
  12390. $categoryList = $L_category->getCategory ();
  12391. $data ['accountType'] = $accountType;
  12392. $data ['cid'] = $cid;
  12393. $data ['categoryList'] = $categoryList;
  12394. $data ['sum'] = $sum;
  12395. $data ['incomeList'] = $incomeList;
  12396. $data ['inputDate'] = $date;
  12397. $data['year']=$year;
  12398. $data ['thsDay'] =$theDay;
  12399. $data ['thsDaySum'] =$thsDaySum;
  12400. $data ['memu'] = "receipt";
  12401. $data ['staff'] = $this->staff;
  12402. $data ['receiptMemu'] = 'wasteBook';
  12403. $data ['verifyId'] = $this->verifyId;
  12404. $data ['executeId'] = $this->executeId;
  12405. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12406. }
  12407. function ajaxGetWasteinvoiceReceivables() {
  12408. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12409. Doo::loadClass ( 'XDeode' );
  12410. $XDeode = new XDeode ( 5 );
  12411. $irid = $XDeode->decode ( $serial );
  12412. Doo::loadModel ( 'invoiceReceivables' );
  12413. $invoiceReceivables = new invoiceReceivables ();
  12414. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12415. echo json_encode ( array (
  12416. 'status' => 1,
  12417. 'detail' => $detail
  12418. ) );
  12419. }
  12420. function ajaxGetPaymentsByAid() {
  12421. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12422. Doo::loadModel ( "accountBook" );
  12423. $accountBook = new accountBook ();
  12424. $detail = $accountBook->getAccountBookByAid ( $serial );
  12425. echo json_encode ( array (
  12426. 'status' => 1,
  12427. 'detail' => $detail
  12428. ) );
  12429. }
  12430. function ajaxGetWasteInvoice() {
  12431. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12432. Doo::loadModel ( 'invoice' );
  12433. $invoice = new invoice ();
  12434. Doo::loadModel ( 'invoiceReceivables' );
  12435. $invoiceReceivables = new invoiceReceivables ();
  12436. $detail = $invoice->getInvoiceByIid ( $serial );
  12437. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12438. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12439. echo json_encode ( array (
  12440. 'status' => 1,
  12441. 'detail' => $detail
  12442. ) );
  12443. }
  12444. /**
  12445. */
  12446. function ajaxGetWasteReceipt() {
  12447. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12448. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12449. Doo::loadModel ( 'receipt' );
  12450. $receipt = new receipt ();
  12451. Doo::loadClass ( 'XDeode' );
  12452. $XDeode = new XDeode ( 5 );
  12453. $rid = $XDeode->decode ( $serial );
  12454. $accountType= $XDeode->decode ( $accountTypeKey );
  12455. // 获得个数据
  12456. $detail = $receipt->getReceiptByRid ( $rid );
  12457. // 初始化
  12458. $detail ['reviseDetail'] = array ();
  12459. if (! empty ( $value ['reviseDetail'] ))
  12460. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12461. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12462. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12463. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12464. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12465. // 获得费用html
  12466. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12467. // 获得费用审批人数据
  12468. $detail = $this->getReceiptApproverHtml ( $detail );
  12469. // 审批执行
  12470. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12471. <th class="taC" width="90">审批人</th>
  12472. <th class="taC">审批意见</th></tr>';
  12473. foreach ( $detail ['verifyList'] as $key => $value ) {
  12474. $html .= '<tr>
  12475. <td>' . $value [1] . '</td>
  12476. <td>' . $value ['opinion'] . '</td>
  12477. </tr>
  12478. ';
  12479. }
  12480. $html .= ' </tbody></table>';
  12481. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12482. <th class="taC" width="90">执行人</th>
  12483. <th class="taC">执行意见</th></tr>';
  12484. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12485. $html .= '<tr>
  12486. <td>' . $value [1] . '</td>
  12487. <td>' . $value ['opinion'] . '</td>
  12488. </tr>
  12489. ';
  12490. }
  12491. $html .= ' </tbody></table>';
  12492. if($accountType==1){
  12493. Doo::loadModel ( 'loanReceipt' );
  12494. $loanReceipt = new loanReceipt ();
  12495. $loanList = $loanReceipt->getOne ( array (
  12496. 'where' => 'rid=' . $detail ['loanRid'],
  12497. 'desc' => 'rid',
  12498. 'asArray' => true
  12499. ) );
  12500. $html .= '<table class="table table-bordered table-condensed">
  12501. <tr class="warning">
  12502. <td class="taR"><b>汇款金额</b></td>
  12503. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12504. </tr>
  12505. </table>';
  12506. }else{
  12507. $html .= '<table class="table table-bordered table-condensed">
  12508. <tr class="warning">
  12509. <td class="taR"><b>汇款金额</b></td>
  12510. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12511. </tr>
  12512. </table>';
  12513. }
  12514. // print_r($detail['verifyList']);
  12515. // header ( 'Content-Type:text/html;charset=utf-8' );
  12516. // echo $html;
  12517. echo json_encode ( array (
  12518. 'status' => 1,
  12519. 'html' => $html,
  12520. 'detail' => $detail
  12521. ) );
  12522. }
  12523. function getReceiptApproverHtml($detail = array()) {
  12524. Doo::loadModel ( 'loanReceipt' );
  12525. $loanReceipt = new loanReceipt ();
  12526. Doo::loadModel ( 'verify' );
  12527. $verify = new verify ();
  12528. Doo::loadModel ( 'staff' );
  12529. $staff = new staff ();
  12530. if (empty ( $detail ))
  12531. return array ();
  12532. $loanList = $loanReceipt->getOne ( array (
  12533. 'where' => 'rid=' . $detail ['loanRid'],
  12534. 'desc' => 'rid',
  12535. 'asArray' => true
  12536. ) );
  12537. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12538. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12539. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12540. else
  12541. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12542. } else
  12543. $verifyList = $verify->getOne ( array (
  12544. 'where' => 'vid=' . $detail ['verify'],
  12545. 'asArray' => true
  12546. ) );
  12547. $verifyList = json_decode ( $verifyList ['staff'], true );
  12548. Doo::loadModel ( 'role' );
  12549. $role = new role ();
  12550. $roleId = 0;
  12551. $flag = true;
  12552. $roleKey = 0;
  12553. $endStaffArray = array ();
  12554. $roleArrayCopy = array ();
  12555. foreach ( $verifyList as $k => $v ) {
  12556. // init verifyStaff
  12557. if ($v [1] == 'ROLE') {
  12558. if (! empty ( $verifyStaff )) {
  12559. $endStaffArray = end ( $verifyStaff );
  12560. }
  12561. $roleVerify = json_decode ( $v [3], true );
  12562. $roleKey = $k;
  12563. $roleArray = array ();
  12564. $rolename = $role->getOne ( array (
  12565. 'where' => 'rid=' . $v [0],
  12566. 'asArray' => true
  12567. ) );
  12568. foreach ( $roleVerify as $o => $p ) {
  12569. $staffID = explode ( '_', $p );
  12570. $staffInfo = $staff->getOne ( array (
  12571. 'where' => 'sid=' . $staffID [0],
  12572. 'asArray' => true
  12573. ) );
  12574. // print_r($staffID);
  12575. $exp = array (
  12576. 0 => $staffInfo ['sid'],
  12577. 1 => $staffID [1],
  12578. 2 => $staffInfo ['avatar'],
  12579. 'date' => '',
  12580. 'date' => '',
  12581. 'opinion' => '',
  12582. 'status' => '',
  12583. 'rolename' => $rolename ['name']
  12584. );
  12585. array_push ( $roleArray, $exp );
  12586. }
  12587. $roleArrayCopy [$v [0]] = $roleArray;
  12588. // $verifyList[$k]['roleArray']=$roleArray;
  12589. }
  12590. $verifyList [$k] ['date'] = "";
  12591. $verifyList [$k] ['opinion'] = "";
  12592. $verifyList [$k] ['status'] = "";
  12593. if (empty ( $verifyStaff )) {
  12594. $verifyList [$k] ['date'] = "";
  12595. $verifyList [$k] ['opinion'] = "";
  12596. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12597. $verifyList [$k] ['status'] = 4;
  12598. $flag = false;
  12599. }
  12600. } else {
  12601. foreach ( $verifyStaff as $m => $u ) {
  12602. if ($v [0] == $m) {
  12603. $verifyList [$k] ['date'] = $u ['date'];
  12604. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12605. $verifyList [$k] ['status'] = $u ['status'];
  12606. $flag = false;
  12607. break;
  12608. }
  12609. }
  12610. $endStaffArray = end ( $verifyStaff );
  12611. }
  12612. }
  12613. $rolename ['name'] = '';
  12614. if (! empty ( $roleId )) {
  12615. Doo::loadModel ( 'role' );
  12616. $role = new role ();
  12617. $rolename = $role->getOne ( array (
  12618. 'where' => 'rid=' . $roleId,
  12619. 'asArray' => true
  12620. ) );
  12621. }
  12622. if (! empty ( $verifyStaff ))
  12623. $endStaffArray = end ( $verifyStaff );
  12624. $KOP = false;
  12625. foreach ( $roleArrayCopy as $P => $A ) {
  12626. foreach ( $A as $MKI => $AVL ) {
  12627. if (! empty ( $verifyStaff )) {
  12628. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12629. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12630. $button = 4;
  12631. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12632. }
  12633. foreach ( $verifyStaff as $m => $u ) {
  12634. $AVLFK = $AVL [0] . '_R';
  12635. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12636. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12637. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12638. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12639. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12640. break;
  12641. }
  12642. }
  12643. } else {
  12644. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12645. $button = 4;
  12646. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12647. }
  12648. }
  12649. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12650. $KOP = true;
  12651. }
  12652. }
  12653. foreach ( $roleArrayCopy as $k => $v ) {
  12654. foreach ( $verifyList as $m => $n ) {
  12655. if ($n [0] == $k) {
  12656. array_splice ( $verifyList, $m, 1, $v );
  12657. }
  12658. }
  12659. }
  12660. // 费用执行人相关数据
  12661. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12662. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12663. foreach ( $executeCopy as $k => $v ) {
  12664. $executeCopy [$k] ['date'] = '';
  12665. $executeCopy [$k] ['opinion'] = '';
  12666. $executeCopy [$k] ['status'] = '';
  12667. if (! empty ( $executeStaff ))
  12668. foreach ( $executeStaff as $m => $u ) {
  12669. if ($v [0] == $m) {
  12670. $executeCopy [$k] ['date'] = $u ['date'];
  12671. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12672. $executeCopy [$k] ['status'] = $u ['status'];
  12673. break;
  12674. }
  12675. }
  12676. }
  12677. $detail ['executeCopy'] = $executeCopy;
  12678. $detail ['verifyList'] = $verifyList;
  12679. return $detail;
  12680. }
  12681. //获得新版报销单费用说明
  12682. private function getReceiptVerson1Explanation($value){
  12683. $version_1_explanation="";
  12684. if($value['version']==1){
  12685. if(!empty($value['officeJson'])){
  12686. $officeJson=json_decode($value['officeJson'],true);
  12687. $version_1_explanation.=$officeJson['officeExplain'][0]['officeExplain']."\n";
  12688. }
  12689. if(!empty($value['traveJson'])){
  12690. $traveJson=json_decode($value['traveJson'],true);
  12691. $version_1_explanation.=$traveJson['traveExplain'][0]['traveExplain']."\n";
  12692. }
  12693. if(!empty($value['trainJson'])){
  12694. $trainJson=json_decode($value['trainJson'],true);
  12695. $version_1_explanation.=$trainJson['trainExplain'][0]['trainExplain']."\n";
  12696. }
  12697. }
  12698. return $version_1_explanation;
  12699. }
  12700. //获得新版报销单 详情HTML
  12701. private function getReceiptVerson1Html($detail){
  12702. $html='<table class="table table-bordered table-condensed">
  12703. <tbody>';
  12704. if($detail['version']==1){
  12705. if(!empty($detail['officeJson'])){
  12706. $officeJson=json_decode($detail['officeJson'],true);
  12707. $html .= '
  12708. <tr>
  12709. <th colspan="2" class="taC">日常相关费用</th>
  12710. </tr>';
  12711. // 日常相关费用
  12712. $total=0;
  12713. foreach ( $officeJson['daily'] as $key => $value ) {
  12714. if(!empty($value['price'])){
  12715. $html .= '
  12716. <tr>
  12717. <th>' . $value ['name'] . '</th>
  12718. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12719. </tr>';
  12720. $total=bcadd($total,$value ['price'],2);
  12721. }
  12722. }
  12723. $html .= '
  12724. <tr>
  12725. <th class="taR">合计</th>
  12726. <td class="colGreen taR">¥' .$total . '</td>
  12727. </tr>';
  12728. // 其他
  12729. $html .= '<tr>
  12730. <th colspan="2" class="taC">其他</th>
  12731. </tr>';
  12732. $total=0;
  12733. foreach ( $officeJson['other'] as $key => $value ) {
  12734. if(!empty($value['price'])){
  12735. $html .= '
  12736. <tr>
  12737. <th>' . $value ['name'] . '</th>
  12738. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12739. </tr>';
  12740. $total=bcadd($total,$value ['price'],2);
  12741. }
  12742. }
  12743. $html .= '
  12744. <tr>
  12745. <th class="taR">合计</th>
  12746. <td class="colGreen taR">¥' . $total . '</td>
  12747. </tr>';
  12748. }
  12749. if(!empty($detail['traveJson'])){
  12750. $traveJson=json_decode($detail['traveJson'],true);
  12751. // 差旅
  12752. $html .= '<tr>
  12753. <th colspan="2" class="taC">差旅相关费用</th>
  12754. </tr>';
  12755. $total=0;
  12756. foreach ( $traveJson['trave'] as $key => $value ) {
  12757. if(!empty($value['price'])){
  12758. $html .= '
  12759. <tr>
  12760. <th>' . $value ['name'] . '</th>
  12761. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12762. </tr>';
  12763. $total=bcadd($total,$value ['price'],2);
  12764. }
  12765. }
  12766. $html .= '
  12767. <tr>
  12768. <th class="taR">合计</th>
  12769. <td class="colGreen taR">¥' . $total . '</td>
  12770. </tr>';
  12771. }
  12772. if(!empty($detail['trainJson'])){
  12773. $trainJson=json_decode($detail['trainJson'],true);
  12774. // 内部培训费用
  12775. $html .= '<tr>
  12776. <th colspan="2" class="taC">内部培训费用</th>
  12777. </tr>';
  12778. $total=0;
  12779. foreach ( $trainJson['train'] as $key => $value ) {
  12780. if(!empty($value['price'])){
  12781. $html .= '
  12782. <tr>
  12783. <th>' . $value ['name'] . '</th>
  12784. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12785. </tr>';
  12786. $total=bcadd($total,$value ['price'],2);
  12787. }
  12788. }
  12789. $html .= '
  12790. <tr>
  12791. <th class="taR">合计</th>
  12792. <td class="colGreen taR">¥' . $total . '</td>
  12793. </tr>';
  12794. }
  12795. }
  12796. return $html;
  12797. }
  12798. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12799. if (empty ( $detail ))
  12800. return '';
  12801. $html = '';
  12802. // die;
  12803. if ($detail ['Rtype'] == 0) { // 报销单
  12804. if($detail ['version']==1){
  12805. $html .= $this->getReceiptVerson1Html($detail);
  12806. }else{
  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 ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12813. $html .= '
  12814. <tr>
  12815. <th>' . $value ['name'] . '</th>
  12816. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12817. </tr>';
  12818. }
  12819. $html .= '
  12820. <tr>
  12821. <th class="taR">合计</th>
  12822. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12823. </tr>';
  12824. $html .= '<tr>
  12825. <th colspan="2" class="taC">差旅相关费用</th>
  12826. </tr>';
  12827. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12828. $html .= '
  12829. <tr>
  12830. <th>' . $value ['name'] . '</th>
  12831. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12832. </tr>';
  12833. }
  12834. $html .= '
  12835. <tr>
  12836. <th class="taR">合计</th>
  12837. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12838. </tr>';
  12839. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12840. $html .= '<tr>
  12841. <th colspan="2" class="taC">内部培训费用</th>
  12842. </tr>';
  12843. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12844. $html .= '
  12845. <tr>
  12846. <th>' . $value ['name'] . '</th>
  12847. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12848. </tr>';
  12849. }
  12850. $html .= '
  12851. <tr>
  12852. <th class="taR">合计</th>
  12853. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12854. </tr>';
  12855. }
  12856. $html .= '<tr>
  12857. <th colspan="2" class="taC">其他</th>
  12858. </tr>';
  12859. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12860. $html .= '
  12861. <tr>
  12862. <th>' . $value ['name'] . '</th>
  12863. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12864. </tr>';
  12865. }
  12866. $html .= '
  12867. <tr>
  12868. <th class="taR">合计</th>
  12869. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12870. </tr>';
  12871. }
  12872. $html .= '<tr>
  12873. <th colspan="2" class="taC">报销金额调整</th>
  12874. </tr>';
  12875. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12876. $html .= '
  12877. <tr>
  12878. <th>' . $value ['name'] . '</th>
  12879. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12880. </tr>';
  12881. }
  12882. $html .= '
  12883. <tr>
  12884. <th class="taR">合计</th>
  12885. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12886. </tr>';
  12887. $html .= '
  12888. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12889. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12890. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12891. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12892. <tr class="warning">
  12893. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12894. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12895. </tr>
  12896. </tbody>
  12897. </table>';
  12898. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12899. $html .= '
  12900. <table class="table table-bordered table-condensed">
  12901. <tbody>
  12902. <tr>
  12903. <th colspan="2" class="taC">办事处相关费用</th>
  12904. </tr>';
  12905. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12906. $html .= '
  12907. <tr>
  12908. <th>' . $value ['name'] . '</th>
  12909. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12910. </tr>';
  12911. }
  12912. $html .= '
  12913. <tr>
  12914. <th class="taR">合计</th>
  12915. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12916. </tr>';
  12917. $html .= '
  12918. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12919. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12920. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12921. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12922. <tr class="warning">
  12923. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12924. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12925. </tr>
  12926. </tbody>
  12927. </table>';
  12928. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12929. Doo::loadModel ( 'loanReceipt' );
  12930. $loanReceipt = new loanReceipt ();
  12931. $loanList = $loanReceipt->getOne ( array (
  12932. 'where' => 'rid=' . $detail ['loanRid'],
  12933. 'desc' => 'rid',
  12934. 'asArray' => true
  12935. ) );
  12936. // print_r($loanList);
  12937. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12938. $html .= '<table class="table table-bordered table-condensed">
  12939. <tbody>
  12940. <tr>
  12941. <th colspan="2" class="taC">借款费用</th>
  12942. </tr>';
  12943. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12944. $html .= '<tr>
  12945. <th>' . $value ['name'] . '</th>
  12946. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12947. </tr>';
  12948. }
  12949. $html .= '<tr>
  12950. <th class="taC" colspan="2">产生费用所在办事处</th>
  12951. </tr>
  12952. <tr>
  12953. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12954. </tr>
  12955. <tr>
  12956. <th class="taC" colspan="2">费用说明</th>
  12957. </tr>
  12958. <tr>
  12959. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12960. </tr>
  12961. <tr class="warning">
  12962. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12963. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12964. </tr>
  12965. </tbody>
  12966. </table>
  12967. ';
  12968. if ( $accountType==2) {
  12969. $balance=$detail ['sum']-$loanList ['sum'];
  12970. $balanceCN=$this->num_to_rmb($balance);
  12971. if($detail ['version']==1){
  12972. $html .= $this->getReceiptVerson1Html($detail);
  12973. }else{
  12974. $html .= '<table class="table table-bordered table-condensed">
  12975. <tbody>
  12976. <tr>
  12977. <th colspan="2" class="taC">日常相关费用</th>
  12978. </tr>';
  12979. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12980. $html .= '
  12981. <tr>
  12982. <th>' . $value ['name'] . '</th>
  12983. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12984. </tr>';
  12985. }
  12986. $html .= '
  12987. <tr>
  12988. <th class="taR">合计</th>
  12989. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12990. </tr>';
  12991. $html .= '<tr>
  12992. <th colspan="2" class="taC">差旅相关费用</th>
  12993. </tr>';
  12994. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12995. $html .= '
  12996. <tr>
  12997. <th>' . $value ['name'] . '</th>
  12998. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12999. </tr>';
  13000. }
  13001. $html .= '
  13002. <tr>
  13003. <th class="taR">合计</th>
  13004. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  13005. </tr>';
  13006. if(isset($detail ['accountItem'] ['内部培训费用'])){
  13007. $html .= '<tr>
  13008. <th colspan="2" class="taC">内部培训费用</th>
  13009. </tr>';
  13010. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  13011. $html .= '
  13012. <tr>
  13013. <th>' . $value ['name'] . '</th>
  13014. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13015. </tr>';
  13016. }
  13017. $html .= '
  13018. <tr>
  13019. <th class="taR">合计</th>
  13020. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  13021. </tr>';
  13022. }
  13023. $html .= '<tr>
  13024. <th colspan="2" class="taC">其他</th>
  13025. </tr>';
  13026. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  13027. $html .= '
  13028. <tr>
  13029. <th>' . $value ['name'] . '</th>
  13030. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13031. </tr>';
  13032. }
  13033. $html .= '
  13034. <tr>
  13035. <th class="taR">合计</th>
  13036. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  13037. </tr>';
  13038. }
  13039. $html .= '<tr>
  13040. <th colspan="2" class="taC">报销金额调整</th>
  13041. </tr>';
  13042. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  13043. $html .= '
  13044. <tr>
  13045. <th>' . $value ['name'] . '</th>
  13046. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13047. </tr>';
  13048. }
  13049. $html .= '
  13050. <tr>
  13051. <th class="taR">合计</th>
  13052. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  13053. </tr>';
  13054. $html .= '
  13055. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  13056. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  13057. <tr><th class="taC" colspan="2">报销说明</th></tr>
  13058. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  13059. <tr class="warning">
  13060. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  13061. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  13062. </tr>
  13063. <tr class="success">
  13064. <td class="taR"><b>借款结余</b></td>
  13065. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  13066. </tr>
  13067. </tbody>
  13068. </table>';
  13069. }
  13070. }
  13071. return $html;
  13072. }
  13073. /**
  13074. * 计算流水
  13075. */
  13076. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  13077. $bakWaste ['bank'] = array (
  13078. 'CGBDeposit' => 0,
  13079. 'ICBCDeposit' => 0,
  13080. 'HUADeposit' => 0,
  13081. 'PersonalDeposit' => 0
  13082. );
  13083. $bakWaste ['financial'] = array (
  13084. 'current' => array (
  13085. 'CGBDeposit' => 0,
  13086. 'ICBCDeposit' => 0
  13087. ),
  13088. 'fixed' => array (
  13089. 'CGBDeposit' => 0,
  13090. 'ICBCDeposit' => 0
  13091. )
  13092. );
  13093. // 存款
  13094. foreach ( $waste ['bank'] as $key => $value ) {
  13095. // 收入
  13096. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  13097. // 广发
  13098. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13099. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13100. }
  13101. // 工商
  13102. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13103. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13104. }
  13105. // 华润
  13106. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13107. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13108. }
  13109. // 个人
  13110. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13111. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13112. }
  13113. }
  13114. }
  13115. foreach ( $waste ['bank'] as $key => $value ) {
  13116. // 支出
  13117. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  13118. // 广发
  13119. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13120. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13121. }
  13122. // 工商
  13123. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13124. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13125. }
  13126. // 华润
  13127. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13128. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13129. }
  13130. // 个人
  13131. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13132. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13133. }
  13134. }
  13135. }
  13136. // 活期
  13137. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13138. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13139. // 广发
  13140. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13141. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13142. }
  13143. // 工商
  13144. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13145. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13146. }
  13147. // 个人
  13148. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13149. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13150. }
  13151. }
  13152. }
  13153. // print_r($inComeStatistics ['fixedStatistics']);
  13154. // 固期
  13155. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13156. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13157. // 广发
  13158. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13159. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13160. }
  13161. // 工商---已经转变成个人理财固定代表含义
  13162. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13163. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13164. }
  13165. // 个人
  13166. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13167. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13168. }
  13169. }
  13170. }
  13171. $waste ['bank'] ['ICBCDeposit'] = sprintf("%.2f", $waste ['bank'] ['ICBCDeposit']);
  13172. return $waste;
  13173. }
  13174. function lyt() {
  13175. Doo::loadModel ( "receiptDetail" );
  13176. $receiptDetail = new receiptDetail ();
  13177. $receiptCollectList = $receiptDetail->find ( array (
  13178. 'where' => 'status=1 ',
  13179. 'asArray' => true
  13180. ) );
  13181. foreach ( $receiptCollectList as $key => $value ) {
  13182. $receiptDetail = new receiptDetail ();
  13183. $receiptDetail->pastDate = $value ['date'];
  13184. $receiptDetail->update ( array (
  13185. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13186. ) );
  13187. }
  13188. }
  13189. function staffCollectMonthDetail() {
  13190. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13191. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13192. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13193. if (! $year)
  13194. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13195. if (! $month)
  13196. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13197. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13198. if (! $nature){
  13199. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13200. }
  13201. Doo::loadModel ( 'staff' );
  13202. $staff = new staff ();
  13203. Doo::loadModel ( "receiptDetail" );
  13204. $receiptDetail = new receiptDetail ();
  13205. Doo::loadModel ( 'accountItem' );
  13206. $accountItem = new accountItem ();
  13207. Doo::loadModel ( 'statistics' );
  13208. $statistics = new statistics ();
  13209. Doo::loadModel ( "receiptAuthorityManage" );
  13210. $receiptAuthorityManage = new receiptAuthorityManage ();
  13211. $aiList=$accountItem->getAccountItem();
  13212. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13213. $cidList = array ();
  13214. foreach ( $imcStaff as $key => $value ) {
  13215. array_push ( $cidList, $value ['cid'] );
  13216. }
  13217. $cidString = implode ( ',', $cidList );
  13218. $naturecon='';
  13219. if ($nature=='ONJOB'){
  13220. $naturecon=' and (nature!=4 )';
  13221. }elseif($nature=='LEAVEJOB'){
  13222. $naturecon=' and (nature=4 )';
  13223. }else{
  13224. die ( 'illegal request--nature' );
  13225. }
  13226. $staffList = $staff->find ( array (
  13227. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13228. 'asArray' => true
  13229. ) );
  13230. $categoryList = $staff->find ( array (
  13231. 'select' => 'COUNT(*) as count,cid,category',
  13232. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13233. 'groupby' => 'cid',
  13234. 'asArray' => true
  13235. ) );
  13236. $list = array ();
  13237. foreach($aiList as $key=>$value){
  13238. foreach ($value as $v){
  13239. $subtotal[$key][$v['name']]=0;
  13240. }
  13241. }
  13242. foreach ( $categoryList as $vlu ) {
  13243. $s1 = 0;
  13244. $m1 = 0;
  13245. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13246. foreach ( $staffList as $value ) {
  13247. if ($vlu ['cid'] == $value ['cid']) {
  13248. // pastDate
  13249. $receiptCollectList = $receiptDetail->find ( array (
  13250. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13251. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13252. 'groupby' => 'item,Month(pastDate),itemCategory',
  13253. 'asArray' => true
  13254. ) );
  13255. if (! empty ( $receiptCollectList )) {
  13256. $receiptL = array (
  13257. '日常相关费用' => array (),
  13258. '差旅相关费用' => array (),
  13259. '内部培训费用' => array (),
  13260. '培训班费用' => array (),
  13261. '其他' => array ()
  13262. );
  13263. $html = "";
  13264. $psum = 0;
  13265. foreach ( $aiList[$this->AGENCY] as $va ) {
  13266. $falg = true;
  13267. foreach ( $receiptCollectList as $v ) {
  13268. if ($v ['itemCategory'] == '日常相关费用') {
  13269. if ($v ['item'] == $va['name']) {
  13270. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13271. $psum += $v ['price'];
  13272. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13273. $falg = false;
  13274. break;
  13275. }
  13276. }
  13277. }
  13278. if ($falg)
  13279. $html .= '<td class="taR">-</td>';
  13280. }
  13281. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13282. if (! empty ( $psum ))
  13283. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13284. else
  13285. $psum = '<td class="colGreen taR">-</td>';
  13286. $receiptL ['日常相关费用'] = $psum . $html;
  13287. /* ----------------------------------- */
  13288. $html = "";
  13289. $psum = 0;
  13290. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13291. $falg = true;
  13292. foreach ( $receiptCollectList as $v ) {
  13293. if ($v ['itemCategory'] == '差旅相关费用') {
  13294. if ($v ['item'] == $va['name']) {
  13295. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13296. $psum += $v ['price'];
  13297. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13298. $falg = false;
  13299. break;
  13300. }
  13301. }
  13302. }
  13303. if ($falg)
  13304. $html .= '<td class="taR">-</td>';
  13305. }
  13306. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13307. if (! empty ( $psum ))
  13308. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13309. else
  13310. $psum = '<td class="colGreen taR">-</td>';
  13311. $receiptL ['差旅相关费用'] = $psum . $html;
  13312. /* ------------------------------------- */
  13313. $html = "";
  13314. $psum = 0;
  13315. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13316. $falg = true;
  13317. foreach ( $receiptCollectList as $v ) {
  13318. if ($v ['itemCategory'] == '内部培训费用') {
  13319. if ($v ['item'] == $va['name']) {
  13320. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13321. $psum += $v ['price'];
  13322. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13323. $falg = false;
  13324. break;
  13325. }
  13326. }
  13327. }
  13328. if ($falg)
  13329. $html .= '<td class="taR">-</td>';
  13330. }
  13331. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13332. if (! empty ( $psum ))
  13333. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13334. else
  13335. $psum = '<td class="colGreen taR">-</td>';
  13336. $receiptL ['内部培训费用'] = $psum . $html;
  13337. /* ----------------------------------- */
  13338. $html = "";
  13339. $psum = 0;
  13340. foreach ( $aiList[$this->TRAIN] as $va ) {
  13341. $falg = true;
  13342. foreach ( $receiptCollectList as $v ) {
  13343. if ($v ['itemCategory'] == '培训班费用') {
  13344. if ($v ['item'] == $va['name']) {
  13345. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13346. $psum += $v ['price'];
  13347. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13348. $falg = false;
  13349. break;
  13350. }
  13351. }
  13352. }
  13353. if ($falg)
  13354. $html .= '<td class="taR">-</td>';
  13355. }
  13356. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13357. if (! empty ( $psum ))
  13358. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13359. else
  13360. $psum = '<td class="colGreen taR">-</td>';
  13361. $receiptL ['培训班费用'] = $psum . $html;
  13362. /* ------------------------------------- */
  13363. $html = "";
  13364. $psum = 0;
  13365. foreach ( $aiList[$this->OTHER] as $va ) {
  13366. $falg = true;
  13367. foreach ( $receiptCollectList as $v ) {
  13368. if ($v ['itemCategory'] == '其他') {
  13369. if (trim ( $v ['item'] ) == $va['name']) {
  13370. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13371. $psum += $v ['price'];
  13372. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13373. $falg = false;
  13374. break;
  13375. }
  13376. }
  13377. }
  13378. if ($falg)
  13379. $html .= '<td class="taR">-</td>';
  13380. }
  13381. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13382. if (! empty ( $psum ))
  13383. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13384. else
  13385. $psum = '<td class="colGreen taR">-</td>';
  13386. $receiptL ['其他'] = $psum . $html;
  13387. /* ------------------------------------- */
  13388. $html = "";
  13389. $psum = 0;
  13390. foreach ( $receiptCollectList as $v ) {
  13391. if ($v ['itemCategory'] == '报销金额调整') {
  13392. if (! empty ( $v ['price'] )) {
  13393. $psum += $v ['price'];
  13394. }
  13395. }
  13396. }
  13397. $s1 += $psum;
  13398. if (! empty ( $psum ))
  13399. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13400. else
  13401. $psum = '<td class="taR colOrange">-</td>';
  13402. $receiptL ['报销金额调整'] = $psum . $html;
  13403. } else {
  13404. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13405. foreach ( $aiList[$this->AGENCY] as $va ) {
  13406. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13407. }
  13408. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13409. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13410. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13411. }
  13412. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13413. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13414. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13415. }
  13416. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13417. foreach ( $aiList[$this->TRAIN] as $va ) {
  13418. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13419. }
  13420. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13421. foreach ( $aiList[$this->OTHER] as $va ) {
  13422. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13423. }
  13424. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13425. }
  13426. $monthStaffPrice = $receiptDetail->find ( array (
  13427. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13428. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13429. 'groupby' => 'Month(pastDate)',
  13430. 'asArray' => true
  13431. ) );
  13432. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13433. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13434. $m1 += $monthStaffPrice [0] ['price'];
  13435. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13436. } else
  13437. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13438. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13439. $list [$value ['username']] = $receiptL;
  13440. }
  13441. }
  13442. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13443. foreach ( $aiList[$this->AGENCY] as $va ) {
  13444. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13445. $subtotal[$this->AGENCY][$va['name']]=0;
  13446. }
  13447. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13448. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13449. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13450. $subtotal[$this->TRAVEL][$va['name']]=0;
  13451. }
  13452. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13453. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13454. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13455. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13456. }
  13457. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13458. foreach ( $aiList[$this->TRAIN] as $va ) {
  13459. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13460. $subtotal[$this->TRAIN][$va['name']]=0;
  13461. }
  13462. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13463. foreach ( $aiList[$this->OTHER] as $va ) {
  13464. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13465. $subtotal[$this->OTHER][$va['name']]=0;
  13466. }
  13467. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13468. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13469. $receiptL ['usernameEn'] =false;
  13470. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13471. }
  13472. $data ['list'] = $list;
  13473. // print_r($list);
  13474. $receiptCollectList = $receiptDetail->find ( array (
  13475. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13476. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13477. 'groupby' => 'item,Month(pastDate),itemCategory',
  13478. 'asArray' => true
  13479. ) );
  13480. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13481. // statistics html
  13482. $stList = $statistics->getOne ( array (
  13483. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13484. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13485. 'groupby' => 'Month(date)',
  13486. 'asArray' => true
  13487. ) );
  13488. if (empty ( $stList ))
  13489. $stList = array (
  13490. 'rePrice' => 0,
  13491. 'agPrice' => 0
  13492. );
  13493. $data ['stList'] = array (
  13494. 'rePrice' => $stList ['rePrice'],
  13495. 'agPrice' => $stList ['agPrice'],
  13496. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13497. );
  13498. $monthHtml = "";
  13499. for($i = 1; $i <= 12; $i ++) {
  13500. if ($i == $month)
  13501. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13502. else
  13503. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13504. }
  13505. $data ['monthHtml'] = $monthHtml;
  13506. $data ['year'] = $year;
  13507. $data ['month'] = $month;
  13508. $data ['nature'] = $nature;
  13509. $data ['aiList'] = $aiList;
  13510. $data ['memu'] = "receipt";
  13511. $data ['staff'] = $this->staff;
  13512. $data ['receiptMemu'] = 'companyCategoryCollect';
  13513. $data ['verifyId'] = $this->verifyId;
  13514. $data ['executeId'] = $this->executeId;
  13515. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13516. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13517. }
  13518. function staffCollectMonthDetail2() {
  13519. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13520. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13521. if (! $year)
  13522. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13523. if (! $month)
  13524. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13525. Doo::loadModel ( 'staff' );
  13526. $staff = new staff ();
  13527. Doo::loadModel ( "receiptDetail" );
  13528. $receiptDetail = new receiptDetail ();
  13529. Doo::loadModel ( 'accountItem' );
  13530. $accountItem = new accountItem ();
  13531. Doo::loadModel ( 'statistics' );
  13532. $statistics = new statistics ();
  13533. Doo::loadModel ( 'L_category' );
  13534. $lCategory = new L_category ();
  13535. $staffList = $staff->find ( array (
  13536. 'where' => 'username!="admin"',
  13537. 'asArray' => true
  13538. ) );
  13539. $categoryList = $staff->find ( array (
  13540. 'select' => 'COUNT(*) as count,cid,category',
  13541. 'where' => 'username !="admin"',
  13542. 'groupby' => 'cid',
  13543. 'asArray' => true
  13544. ) );
  13545. $list = array ();
  13546. foreach ( $categoryList as $vlu ) {
  13547. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13548. $r1 = 0;
  13549. $r2 = 0;
  13550. $r3 = 0;
  13551. $r4 = 0;
  13552. $r5 = 0;
  13553. $r6 = 0;
  13554. $r7 = 0;
  13555. $r8 = 0;
  13556. $r9 = 0;
  13557. $r10 = 0;
  13558. $r11 = 0;
  13559. $r12 = 0;
  13560. $r13 = 0;
  13561. $r14 = 0;
  13562. $r15 = 0;
  13563. $c1 = 0;
  13564. $c2 = 0;
  13565. $c3 = 0;
  13566. $c4 = 0;
  13567. $c5 = 0;
  13568. $c6 = 0;
  13569. $p1 = 0;
  13570. $p2 = 0;
  13571. $p3 = 0;
  13572. $p4 = 0;
  13573. $p5 = 0;
  13574. $p6 = 0;
  13575. $p7 = 0;
  13576. $p8 = 0;
  13577. $p9 = 0;
  13578. $t1 = 0;
  13579. $t2 = 0;
  13580. $t3 = 0;
  13581. $t4 = 0;
  13582. $t5 = 0;
  13583. $s1 = 0;
  13584. $m1 = 0;
  13585. foreach ( $staffList as $value ) {
  13586. if ($vlu ['cid'] == $value ['cid']) {
  13587. $receiptCollectList = $receiptDetail->find ( array (
  13588. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13589. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13590. 'groupby' => 'item,Month(date),itemCategory',
  13591. 'asArray' => true
  13592. ) );
  13593. if (! empty ( $receiptCollectList )) {
  13594. $receiptL = array (
  13595. '日常相关费用' => array (),
  13596. '差旅相关费用' => array (),
  13597. '培训班费用' => array (),
  13598. '其他' => array ()
  13599. );
  13600. $html = "";
  13601. $psum = 0;
  13602. $item = array (
  13603. '市内交通费',
  13604. '市内出租费',
  13605. '办事处房租',
  13606. '电话费',
  13607. '水费',
  13608. '电费',
  13609. '办公费用',
  13610. '邮寄费',
  13611. '其他费用',
  13612. '车辆费用',
  13613. '广告费',
  13614. '团队建设费',
  13615. '物业管理费',
  13616. '宽带费'
  13617. );
  13618. foreach ( $item as $va ) {
  13619. $falg = true;
  13620. foreach ( $receiptCollectList as $v ) {
  13621. if ($v ['itemCategory'] == '日常相关费用') {
  13622. if ($v ['item'] == $va) {
  13623. if ($va == '市内交通费')
  13624. $r1 += $v ['price'];
  13625. if ($va == '市内出租费')
  13626. $r2 += $v ['price'];
  13627. if ($va == '办事处房租')
  13628. $r3 += $v ['price'];
  13629. if ($va == '电话费')
  13630. $r4 += $v ['price'];
  13631. if ($va == '水费')
  13632. $r5 += $v ['price'];
  13633. if ($va == '电费')
  13634. $r6 += $v ['price'];
  13635. if ($va == '办公费用')
  13636. $r7 += $v ['price'];
  13637. if ($va == '邮寄费')
  13638. $r8 += $v ['price'];
  13639. if ($va == '其他费用')
  13640. $r9 += $v ['price'];
  13641. if ($va == '车辆费用')
  13642. $r10 += $v ['price'];
  13643. if ($va == '广告费')
  13644. $r11 += $v ['price'];
  13645. if ($va == '团队建设费')
  13646. $r13 += $v ['price'];
  13647. if ($va == '物业管理费')
  13648. $r14 += $v ['price'];
  13649. if ($va == '宽带费')
  13650. $r15 += $v ['price'];
  13651. $psum += $v ['price'];
  13652. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13653. $falg = false;
  13654. break;
  13655. }
  13656. }
  13657. }
  13658. if ($falg)
  13659. $html .= '<td class="taR">-</td>';
  13660. }
  13661. $r12 += $psum;
  13662. if (! empty ( $psum ))
  13663. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13664. else
  13665. $psum = '<td class="colGreen taR">-</td>';
  13666. $receiptL ['日常相关费用'] = $psum . $html;
  13667. /* ----------------------------------- */
  13668. $html = "";
  13669. $psum = 0;
  13670. $item = array (
  13671. '往来交通费',
  13672. '市内交通费',
  13673. '出差住宿费',
  13674. '出差补助',
  13675. '其他费用'
  13676. );
  13677. foreach ( $item as $va ) {
  13678. $falg = true;
  13679. foreach ( $receiptCollectList as $v ) {
  13680. if ($v ['itemCategory'] == '差旅相关费用') {
  13681. if ($v ['item'] == $va) {
  13682. if ($va == '往来交通费')
  13683. $c1 += $v ['price'];
  13684. if ($va == '市内交通费')
  13685. $c2 += $v ['price'];
  13686. if ($va == '出差住宿费')
  13687. $c3 += $v ['price'];
  13688. if ($va == '出差补助')
  13689. $c4 += $v ['price'];
  13690. if ($va == '其他费用')
  13691. $c5 += $v ['price'];
  13692. $psum += $v ['price'];
  13693. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13694. $falg = false;
  13695. break;
  13696. }
  13697. }
  13698. }
  13699. if ($falg)
  13700. $html .= '<td class="taR">-</td>';
  13701. }
  13702. $c6 += $psum;
  13703. if (! empty ( $psum ))
  13704. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13705. else
  13706. $psum = '<td class="colGreen taR">-</td>';
  13707. $receiptL ['差旅相关费用'] = $psum . $html;
  13708. /* ------------------------------------- */
  13709. $html = "";
  13710. $psum = 0;
  13711. $item = array (
  13712. '场租费',
  13713. '薪酬',
  13714. '住宿费',
  13715. '交通费',
  13716. '餐饮费',
  13717. '办公费',
  13718. '公关费',
  13719. '其他'
  13720. );
  13721. foreach ( $item as $va ) {
  13722. $falg = true;
  13723. foreach ( $receiptCollectList as $v ) {
  13724. if ($v ['itemCategory'] == '培训班费用') {
  13725. if ($v ['item'] == $va) {
  13726. if ($va == '场租费')
  13727. $p1 += $v ['price'];
  13728. if ($va == '薪酬')
  13729. $p2 += $v ['price'];
  13730. if ($va == '住宿费')
  13731. $p3 += $v ['price'];
  13732. if ($va == '交通费')
  13733. $p4 += $v ['price'];
  13734. if ($va == '餐饮费')
  13735. $p5 += $v ['price'];
  13736. if ($va == '办公费')
  13737. $p6 += $v ['price'];
  13738. if ($va == '公关费')
  13739. $p7 += $v ['price'];
  13740. if ($va == '其他')
  13741. $p8 += $v ['price'];
  13742. $psum += $v ['price'];
  13743. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13744. $falg = false;
  13745. break;
  13746. }
  13747. }
  13748. }
  13749. if ($falg)
  13750. $html .= '<td class="taR">-</td>';
  13751. }
  13752. $p9 += $psum;
  13753. if (! empty ( $psum ))
  13754. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13755. else
  13756. $psum = '<td class="colGreen taR">-</td>';
  13757. $receiptL ['培训班费用'] = $psum . $html;
  13758. /* ------------------------------------- */
  13759. $html = "";
  13760. $psum = 0;
  13761. $item = array (
  13762. '公关费',
  13763. '广告费',
  13764. '借款',
  13765. '可自加费用'
  13766. );
  13767. foreach ( $item as $va ) {
  13768. $falg = true;
  13769. foreach ( $receiptCollectList as $v ) {
  13770. if ($v ['itemCategory'] == '其他') {
  13771. if ($v ['item'] == $va) {
  13772. if ($va == '公关费')
  13773. $t1 += $v ['price'];
  13774. if ($va == '广告费')
  13775. $t2 += $v ['price'];
  13776. if ($va == '借款')
  13777. $t3 += $v ['price'];
  13778. if ($va == '可自加费用')
  13779. $t4 += $v ['price'];
  13780. $psum += $v ['price'];
  13781. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13782. $falg = false;
  13783. break;
  13784. }
  13785. }
  13786. }
  13787. if ($falg)
  13788. $html .= '<td class="taR">-</td>';
  13789. }
  13790. $t5 += $psum;
  13791. if (! empty ( $psum ))
  13792. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13793. else
  13794. $psum = '<td class="colGreen taR">-</td>';
  13795. $receiptL ['其他'] = $psum . $html;
  13796. /* ------------------------------------- */
  13797. $html = "";
  13798. $psum = 0;
  13799. foreach ( $receiptCollectList as $v ) {
  13800. if ($v ['itemCategory'] == '报销金额调整') {
  13801. if (! empty ( $v ['price'] )) {
  13802. $psum += $v ['price'];
  13803. }
  13804. }
  13805. }
  13806. $s1 += $psum;
  13807. if (! empty ( $psum ))
  13808. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13809. else
  13810. $psum = '<td class="taR colOrange">-</td>';
  13811. $receiptL ['报销金额调整'] = $psum . $html;
  13812. } else {
  13813. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13814. <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>';
  13815. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13816. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13817. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13818. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13819. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13820. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13821. }
  13822. $monthStaffPrice = $receiptDetail->find ( array (
  13823. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13824. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13825. 'asArray' => true
  13826. ) );
  13827. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13828. $m1 += $monthStaffPrice [0] ['price'];
  13829. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13830. } else
  13831. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13832. $list [$value ['username']] = $receiptL;
  13833. }
  13834. }
  13835. $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>
  13836. <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>
  13837. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13838. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13839. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13840. $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>
  13841. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13842. $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>';
  13843. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13844. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13845. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13846. }
  13847. $data ['list'] = $list;
  13848. $receiptCollectList = $receiptDetail->find ( array (
  13849. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13850. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13851. 'groupby' => 'item,Month(date),itemCategory',
  13852. 'asArray' => true
  13853. ) );
  13854. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13855. // statistics html
  13856. $stList = $statistics->getOne ( array (
  13857. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13858. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13859. 'groupby' => 'Month(date)',
  13860. 'asArray' => true
  13861. ) );
  13862. if (empty ( $stList ))
  13863. $stList = array (
  13864. 'rePrice' => 0,
  13865. 'agPrice' => 0
  13866. );
  13867. $data ['stList'] = array (
  13868. 'rePrice' => $stList ['rePrice'],
  13869. 'agPrice' => $stList ['agPrice'],
  13870. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13871. );
  13872. $monthHtml = "";
  13873. for($i = 1; $i <= 12; $i ++) {
  13874. if ($i == $month)
  13875. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13876. else
  13877. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13878. }
  13879. $data ['monthHtml'] = $monthHtml;
  13880. $data ['year'] = $year;
  13881. $data ['month'] = $month;
  13882. $data ['memu'] = "receipt";
  13883. $data ['staff'] = $this->staff;
  13884. $data ['receiptMemu'] = 'companyCategoryCollect';
  13885. $data ['verifyId'] = $this->verifyId;
  13886. $data ['executeId'] = $this->executeId;
  13887. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13888. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13889. }
  13890. /**
  13891. * 用户报销单列表
  13892. */
  13893. function receiptStatisticsStaffDetail() {
  13894. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13895. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13896. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13897. Doo::loadModel ( "receipt" );
  13898. $receipt = new receipt ();
  13899. Doo::loadModel ( "receiptDetail" );
  13900. $receiptDetail = new receiptDetail ();
  13901. Doo::loadModel ( 'staff' );
  13902. $staff = new staff ();
  13903. Doo::loadModel ( 'accountItem' );
  13904. $accountItem = new accountItem ();
  13905. Doo::loadModel ( 'statistics' );
  13906. $statistics = new statistics ();
  13907. if (! empty ( $username )) {
  13908. $username = addslashes ( urldecode ( $username ) );
  13909. $staffDetail = $staff->getStaffByName ( $username );
  13910. if (empty ( $staffDetail ))
  13911. die ( 'illegal request' );
  13912. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13913. $itemList = $accountItem->getAccountItem ();
  13914. $itemHtml = '';
  13915. $categoryHtml = '';
  13916. $itemKeyList = array_keys ( $itemList );
  13917. $revisePrice = 0;
  13918. // 报销单内容详情
  13919. foreach ( $list as $key => $value ) {
  13920. $accountItemList = json_decode ( $value ['accountItem'], true );
  13921. $list [$key] ['accountItemList'] = $accountItemList;
  13922. $receiptItemHtml = '';
  13923. foreach ( $itemKeyList as $v ) {
  13924. if ($v == '日常相关费用')
  13925. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13926. elseif ($v == '差旅相关费用')
  13927. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13928. elseif ($v == '培训班费用')
  13929. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13930. elseif ($v == '内部培训费用'){
  13931. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13932. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13933. }else{
  13934. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13935. }
  13936. }elseif ($v == '其他')
  13937. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13938. foreach ( $itemList [$v] as $ke => $va ) {
  13939. $falg = true;
  13940. if (! empty ( $accountItemList [$v] )) {
  13941. foreach ( $accountItemList [$v] as $ve ) {
  13942. if ($va ['name'] == $ve ['name']) {
  13943. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13944. $falg = false;
  13945. break;
  13946. }
  13947. }
  13948. }
  13949. if ($falg)
  13950. $receiptItemHtml .= '<td class="taR"></td>';
  13951. }
  13952. }
  13953. // 金额调整和费用查看
  13954. $revisePrice += $value ['revisePrice'];
  13955. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13956. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13957. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13958. }
  13959. // 报销单合计
  13960. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13961. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13962. $receiptTotalHtml = '';
  13963. // 报销单项目抬头
  13964. foreach ( $itemKeyList as $value ) {
  13965. $count = count ( $itemList [$value] ) + 1;
  13966. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13967. $categoryHtml .= '<th class="taC">合计</th>';
  13968. $sumfalg=true;
  13969. foreach ( $rtl as $rtlValue ) {
  13970. if ($rtlValue ['itemCategory'] == $value) {
  13971. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13972. $sumfalg=false;
  13973. break;
  13974. }
  13975. }
  13976. if ($sumfalg)
  13977. $receiptTotalHtml .= '<th></th>';
  13978. foreach ( $itemList [$value] as $k => $v ) {
  13979. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13980. // 合计
  13981. $falg = true;
  13982. foreach ( $receiptTotalList as $ve ) {
  13983. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13984. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13985. $falg = false;
  13986. break;
  13987. }
  13988. }
  13989. if ($falg)
  13990. $receiptTotalHtml .= '<th></th>';
  13991. }
  13992. }
  13993. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13994. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13995. if (empty ( $stList ))
  13996. $stList = array (
  13997. 'rePrice' => 0,
  13998. 'agPrice' => 0
  13999. );
  14000. $data ['stList'] = array (
  14001. 'rePrice' => $stList ['rePrice'],
  14002. 'agPrice' => $stList ['agPrice'],
  14003. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14004. );
  14005. $monthHtml = "";
  14006. for($i = 1; $i <= 12; $i ++) {
  14007. if ($i == $month)
  14008. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14009. else
  14010. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14011. }
  14012. $data ['username'] = urlencode ( $username );
  14013. $data ['usernameEN'] = $username;
  14014. $data ['monthHtml'] = $monthHtml;
  14015. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  14016. $data ['list'] = $list;
  14017. $data ['categoryHtml'] = $categoryHtml;
  14018. $data ['itemHtml'] = $itemHtml;
  14019. $data ['itemList'] = $itemList;
  14020. $data ['year'] = $year;
  14021. $data ['month'] = $month;
  14022. $data ['memu'] = "receipt";
  14023. $data ['staff'] = $this->staff;
  14024. $data ['receiptMemu'] = 'companyCategoryCollect';
  14025. $data ['verifyId'] = $this->verifyId;
  14026. $data ['executeId'] = $this->executeId;
  14027. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  14028. }
  14029. die ( 'illegal request' );
  14030. }
  14031. function companyMonthCollectDetail() {
  14032. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  14033. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14034. if (! $year)
  14035. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  14036. if (! $month)
  14037. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  14038. Doo::loadModel ( 'staff' );
  14039. $staff = new staff ();
  14040. Doo::loadModel ( "receiptDetail" );
  14041. $receiptDetail = new receiptDetail ();
  14042. Doo::loadModel ( 'accountItem' );
  14043. $accountItem = new accountItem ();
  14044. Doo::loadModel ( 'statistics' );
  14045. $statistics = new statistics ();
  14046. Doo::loadModel ( 'L_category' );
  14047. $lCategory = new L_category ();
  14048. $staffList = $staff->find ( array (
  14049. 'where' => 'username!="admin"',
  14050. 'asArray' => true
  14051. ) );
  14052. $categoryList = $lCategory->find ( array (
  14053. 'asArray' => true
  14054. ) );
  14055. $aiList=$accountItem->getAccountItem();
  14056. $list = array ();
  14057. foreach ( $categoryList as $value ) {
  14058. $receiptCollectList = $receiptDetail->find ( array (
  14059. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14060. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14061. 'groupby' => 'item,Month(pastDate),itemCategory',
  14062. 'asArray' => true
  14063. ) );
  14064. if (! empty ( $receiptCollectList )) {
  14065. $receiptL = array (
  14066. '日常相关费用' => array (),
  14067. '差旅相关费用' => array (),
  14068. '内部培训费用' => array (),
  14069. '培训班费用' => array (),
  14070. '其他' => array ()
  14071. );
  14072. $html = "";
  14073. $psum = 0;
  14074. foreach ( $aiList[$this->AGENCY] as $va ) {
  14075. $falg = true;
  14076. foreach ( $receiptCollectList as $v ) {
  14077. if ($v ['itemCategory'] == $this->AGENCY) {
  14078. if ($v ['item'] == $va['name']) {
  14079. $psum += $v ['price'];
  14080. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14081. $falg = false;
  14082. break;
  14083. }
  14084. }
  14085. }
  14086. if ($falg)
  14087. $html .= '<td class="taR">-</td>';
  14088. }
  14089. if (! empty ( $psum ))
  14090. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14091. else
  14092. $psum = '<td class="colGreen taR">-</td>';
  14093. $receiptL [$this->AGENCY] = $psum . $html;
  14094. /* ----------------------------------- */
  14095. $html = "";
  14096. $psum = 0;
  14097. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14098. $falg = true;
  14099. foreach ( $receiptCollectList as $v ) {
  14100. if ($v ['itemCategory'] == $this->TRAVEL) {
  14101. if ($v ['item'] == $va['name']) {
  14102. $psum += $v ['price'];
  14103. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14104. $falg = false;
  14105. break;
  14106. }
  14107. }
  14108. }
  14109. if ($falg)
  14110. $html .= '<td class="taR">-</td>';
  14111. }
  14112. if (! empty ( $psum ))
  14113. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14114. else
  14115. $psum = '<td class="colGreen taR">-</td>';
  14116. $receiptL [$this->TRAVEL] = $psum . $html;
  14117. /* ------------------------------------- */
  14118. $html = "";
  14119. $psum = 0;
  14120. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14121. $falg = true;
  14122. foreach ( $receiptCollectList as $v ) {
  14123. if ($v ['itemCategory'] == $this->INTTRAIN) {
  14124. if ($v ['item'] == $va['name']) {
  14125. $psum += $v ['price'];
  14126. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14127. $falg = false;
  14128. break;
  14129. }
  14130. }
  14131. }
  14132. if ($falg)
  14133. $html .= '<td class="taR">-</td>';
  14134. }
  14135. if (! empty ( $psum ))
  14136. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14137. else
  14138. $psum = '<td class="colGreen taR">-</td>';
  14139. $receiptL [$this->INTTRAIN] = $psum . $html;
  14140. /* ------------------------------------- */
  14141. $html = "";
  14142. $psum = 0;
  14143. foreach ( $aiList[$this->TRAIN] as $va ) {
  14144. $falg = true;
  14145. foreach ( $receiptCollectList as $v ) {
  14146. if ($v ['itemCategory'] == $this->TRAIN) {
  14147. if ($v ['item'] == $va['name']) {
  14148. $psum += $v ['price'];
  14149. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14150. $falg = false;
  14151. break;
  14152. }
  14153. }
  14154. }
  14155. if ($falg)
  14156. $html .= '<td class="taR">-</td>';
  14157. }
  14158. if (! empty ( $psum ))
  14159. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14160. else
  14161. $psum = '<td class="colGreen taR">-</td>';
  14162. $receiptL [$this->TRAIN] = $psum . $html;
  14163. /* ------------------------------------- */
  14164. $html = "";
  14165. $psum = 0;
  14166. foreach ( $aiList[$this->OTHER] as $va ) {
  14167. $falg = true;
  14168. foreach ( $receiptCollectList as $v ) {
  14169. if ($v ['itemCategory'] == $this->OTHER) {
  14170. if ($v ['item'] == $va['name']) {
  14171. $psum += $v ['price'];
  14172. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14173. $falg = false;
  14174. break;
  14175. }
  14176. }
  14177. }
  14178. if ($falg)
  14179. $html .= '<td class="taR">-</td>';
  14180. }
  14181. if (! empty ( $psum ))
  14182. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14183. else
  14184. $psum = '<td class="colGreen taR">-</td>';
  14185. $receiptL [$this->OTHER] = $psum . $html;
  14186. /* ------------------------------------- */
  14187. $html = "";
  14188. $psum = 0;
  14189. foreach ( $receiptCollectList as $v ) {
  14190. if ($v ['itemCategory'] == '报销金额调整') {
  14191. if (! empty ( $v ['price'] ))
  14192. $psum += $v ['price'];
  14193. }
  14194. }
  14195. if (! empty ( $psum ))
  14196. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14197. else
  14198. $psum = '<td class="taR colOrange">-</td>';
  14199. $receiptL ['报销金额调整'] = $psum . $html;
  14200. } else {
  14201. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14202. foreach ( $aiList[$this->AGENCY] as $va ) {
  14203. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14204. }
  14205. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14206. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14207. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14208. }
  14209. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14210. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14211. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14212. }
  14213. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14214. foreach ( $aiList[$this->TRAIN] as $va ) {
  14215. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14216. }
  14217. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14218. foreach ( $aiList[$this->OTHER] as $va ) {
  14219. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14220. }
  14221. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14222. }
  14223. $monthStaffPrice = $receiptDetail->find ( array (
  14224. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14225. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14226. 'asArray' => true
  14227. ) );
  14228. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14229. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14230. else
  14231. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14232. $list [$value ['title']] = $receiptL;
  14233. }
  14234. $data ['list'] = $list;
  14235. $receiptCollectList = $receiptDetail->find ( array (
  14236. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14237. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14238. 'groupby' => 'item,Month(pastDate),itemCategory',
  14239. 'asArray' => true
  14240. ) );
  14241. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14242. //print_r($data['monthPriceHtml']);
  14243. // foreach ($data['monthPriceHtml'] as $value){
  14244. // echo $value;
  14245. // }
  14246. // die;
  14247. // statistics html
  14248. $stList = $statistics->getOne ( array (
  14249. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14250. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14251. 'groupby' => 'Month(date)',
  14252. 'asArray' => true
  14253. ) );
  14254. if (empty ( $stList ))
  14255. $stList = array (
  14256. 'rePrice' => 0,
  14257. 'agPrice' => 0
  14258. );
  14259. $data ['stList'] = array (
  14260. 'rePrice' => $stList ['rePrice'],
  14261. 'agPrice' => $stList ['agPrice'],
  14262. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14263. );
  14264. $monthHtml = "";
  14265. for($i = 1; $i <= 12; $i ++) {
  14266. if ($i == $month)
  14267. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14268. else
  14269. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14270. }
  14271. $data ['aiList'] = $aiList;
  14272. $dateHtml = "";
  14273. $now = date ( "Y" );
  14274. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14275. if ($YEARD <= $now) {
  14276. $dateHtml .= '<option ';
  14277. if ($year == $YEARD) {
  14278. $dateHtml .= 'selected ';
  14279. }
  14280. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14281. }
  14282. }
  14283. $data ['dateHtml'] = $dateHtml;
  14284. $data ['monthHtml'] = $monthHtml;
  14285. $data ['year'] = $year;
  14286. $data ['month'] = $month;
  14287. $data ['memu'] = "receipt";
  14288. $data ['staff'] = $this->staff;
  14289. $data ['receiptMemu'] = 'companyCategoryCollect';
  14290. $data ['verifyId'] = $this->verifyId;
  14291. $data ['executeId'] = $this->executeId;
  14292. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14293. }
  14294. function staffCollectDetail() {
  14295. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14296. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14297. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14298. if (! $staffname) {
  14299. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14300. $staffname = urldecode ( $staffname );
  14301. }
  14302. Doo::loadModel ( 'staff' );
  14303. $staff = new staff ();
  14304. Doo::loadModel ( "receiptDetail" );
  14305. $receiptDetail = new receiptDetail ();
  14306. Doo::loadModel ( 'accountItem' );
  14307. $accountItem = new accountItem ();
  14308. Doo::loadModel ( 'statistics' );
  14309. $statistics = new statistics ();
  14310. Doo::loadModel ( 'L_category' );
  14311. $lCategory = new L_category ();
  14312. Doo::loadModel ( "receiptAuthorityManage" );
  14313. $receiptAuthorityManage = new receiptAuthorityManage ();
  14314. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14315. $cidList = array ();
  14316. foreach ( $imcStaff as $key => $value ) {
  14317. array_push ( $cidList, $value ['cid'] );
  14318. }
  14319. $cidString = implode ( ',', $cidList );
  14320. $staffList = $staff->find ( array (
  14321. 'where' => ' cid in (' . $cidString . ')',
  14322. 'asArray' => true
  14323. ) );
  14324. $stHtml = '';
  14325. $stTitle = "";
  14326. $staffId = 0;
  14327. $cid = 0;
  14328. $ocid = 0;
  14329. foreach ( $staffList as $value ) {
  14330. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14331. $stTitle = $value ['category'] . '-' . $value ['username'];
  14332. $staffId = $value ['sid'];
  14333. $cid = $value ['cid'];
  14334. $ocid = $value ['cid'];
  14335. if (! empty ( $value ['othercid'] ))
  14336. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14337. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14338. } elseif ($value ['username'] != 'admin')
  14339. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14340. }
  14341. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14342. 'where' => 'cid in(' . $cid . ')',
  14343. 'asArray' => true
  14344. ) );
  14345. if (empty ( $pcid ))
  14346. $pcid = $ocid;
  14347. $data ['ocid'] = $pcid;
  14348. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14349. $this->showCache ( $path );
  14350. //
  14351. $receiptCollectList = $receiptDetail->find ( array (
  14352. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14353. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14354. 'groupby' => 'item,Month(pastDate),itemCategory',
  14355. 'asArray' => true
  14356. ) );
  14357. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14358. // print_r($receiptCollectList);
  14359. $accountList = $accountItem->find ( array (
  14360. 'asArray' => true
  14361. ) );
  14362. // create CollectDetail HTML
  14363. $collectHtml = array ();
  14364. foreach ( $accountList as $key => $value ) {
  14365. $html = "";
  14366. $asum = 0;
  14367. for($i = 1; $i <= 12; $i ++) {
  14368. $falg = true;
  14369. foreach ( $receiptCollectList as $v ) {
  14370. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14371. if ($v ['item'] == '可自加费用') {
  14372. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14373. }
  14374. $asum += $v ['price'];
  14375. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14376. $falg = false;
  14377. break;
  14378. }
  14379. }
  14380. if ($falg)
  14381. $html .= '<td class="taR">-</td>';
  14382. }
  14383. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14384. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14385. }
  14386. $data ['collectHtml'] = $collectHtml;
  14387. // print_r($collectHtml);
  14388. // create Adjustment price html
  14389. $receiptCollectList = $receiptDetail->find ( array (
  14390. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14391. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14392. 'groupby' => 'itemCategory,Month(pastDate)',
  14393. 'asArray' => true
  14394. ) );
  14395. $adjustment = array ();
  14396. $collectArray = array (
  14397. '日常相关费用' => array (),
  14398. '差旅相关费用' => array (),
  14399. '培训班费用' => array (),
  14400. '内部培训费用'=>array(),
  14401. '其他' => array ()
  14402. );
  14403. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14404. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14405. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14406. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14407. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14408. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14409. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14410. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14411. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14412. array_push ( $collectArray ['其他'], $collectHtml );
  14413. $data ['collectArray'] = $collectArray;
  14414. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14415. array_push ( $adjustment, $collectHtml );
  14416. $data ['adjustment'] = $adjustment;
  14417. // total price html
  14418. $collectHtml = "";
  14419. $total = 0;
  14420. for($i = 1; $i <= 12; $i ++) {
  14421. $sumPrice = 0;
  14422. foreach ( $receiptCollectList as $key => $value ) {
  14423. if ($value ['month'] == $i) {
  14424. $sumPrice += $value ['price'];
  14425. }
  14426. }
  14427. if ($sumPrice == 0)
  14428. $collectHtml .= '<td class="taR">-</td>';
  14429. else
  14430. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14431. $total += $sumPrice;
  14432. }
  14433. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14434. // statistics html
  14435. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14436. if (empty ( $stList ))
  14437. $stList = array (
  14438. 'rePrice' => 0,
  14439. 'agPrice' => 0
  14440. );
  14441. $data ['stList'] = array (
  14442. 'rePrice' => $stList ['rePrice'],
  14443. 'agPrice' => $stList ['agPrice'],
  14444. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14445. );
  14446. $data ['totalPrice'] = $collectHtml;
  14447. $data ['totalYear'] = $total;
  14448. $data ['stHtml'] = $stHtml;
  14449. $data ['year'] = $year;
  14450. $data ['stTitle'] = $stTitle;
  14451. $data ['staffname'] = urlencode ( $staffname );
  14452. $data ['memu'] = "receipt";
  14453. $data ['staff'] = $this->staff;
  14454. $data ['receiptMemu'] = 'companyCategoryCollect';
  14455. $data ['verifyId'] = $this->verifyId;
  14456. $data ['executeId'] = $this->executeId;
  14457. if ($year < date ( "Y" )) {
  14458. Doo::loadModel ( 'receipt' );
  14459. $receipt = new receipt ();
  14460. $receiptList = $receipt->find ( array (
  14461. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14462. 'asArray' => true
  14463. ) );
  14464. if (empty ( $receiptList )) { // generated files
  14465. ob_start ();
  14466. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14467. $this->cacheFile ( $path );
  14468. die ();
  14469. }
  14470. }
  14471. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14472. }
  14473. function BUGFLAG() {
  14474. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14475. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14476. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14477. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14478. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14479. if (empty ( $status ))
  14480. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14481. $page_size = 12;
  14482. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14483. $vidList = array ();
  14484. $button = 0;
  14485. Doo::loadModel ( 'verify' );
  14486. $verify = new verify ();
  14487. Doo::loadModel ( 'receipt' );
  14488. $receipt = new receipt ();
  14489. Doo::loadModel ( 'staff' );
  14490. $staff = new staff ();
  14491. Doo::loadModel ( 'L_category' );
  14492. $Lcategory = new L_category ();
  14493. $dateCondition = " and Year(date) =" . $year;
  14494. if (! empty ( $month ))
  14495. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14496. $categoryList = $Lcategory->find ( array (
  14497. 'asArray' => true
  14498. ) );
  14499. $staffList = $staff->find ( array (
  14500. 'where' => 'cid=' . $cid,
  14501. 'asArray' => true
  14502. ) );
  14503. $cateCondition = "";
  14504. $staffCondition = "";
  14505. $approvalCondition = "";
  14506. if (! empty ( $cid ))
  14507. $cateCondition = ' and cid=' . $cid;
  14508. if (! empty ( $sid )) {
  14509. $staffCondition = ' and staff=' . $sid;
  14510. $cateCondition = "";
  14511. }
  14512. $approvalCondition = " and status=" . $status;
  14513. if ($status == 2) {
  14514. // 查找角色审批人
  14515. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14516. }
  14517. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14518. $approvalCondition = ' and status=2 ';
  14519. }
  14520. if ($status == 1) {
  14521. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14522. }
  14523. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14524. $pageinfo ['page'] = array (
  14525. 'previous' => ''
  14526. );
  14527. if ($status == 0) {
  14528. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14529. $receiptList = $receipt->find ( array (
  14530. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14531. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14532. 'desc' => 'rid',
  14533. 'asArray' => true
  14534. ) );
  14535. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14536. } else
  14537. $receiptList = $receipt->find ( array (
  14538. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14539. 'desc' => 'rid',
  14540. 'asArray' => true
  14541. ) );
  14542. $rLRes = $receipt->find ( array (
  14543. '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,
  14544. 'desc' => 'rid',
  14545. 'asArray' => true
  14546. ) );
  14547. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14548. // print_r($pageinfo);
  14549. $Locate = 0;
  14550. foreach ( $receiptList as $key => $value ) {
  14551. $receiptList [$key] ['Locate'] = $Locate;
  14552. $Locate ++;
  14553. $receiptList [$key] ['reviseDetail'] = array ();
  14554. if (! empty ( $value ['reviseDetail'] ))
  14555. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14556. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14557. $categoryDetil = $Lcategory->getOne ( array (
  14558. 'where' => 'cid=' . $value ['cid'],
  14559. 'asArray' => true
  14560. ) );
  14561. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14562. $verifyList = $verify->getOne ( array (
  14563. 'where' => 'vid=' . $value ['verify'],
  14564. 'asArray' => true
  14565. ) );
  14566. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14567. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14568. foreach ( $verifyList as $k => $v ) {
  14569. // init verifyStaff
  14570. $verifyList [$k] ['date'] = "";
  14571. $verifyList [$k] ['opinion'] = "";
  14572. $verifyList [$k] ['status'] = "";
  14573. if (empty ( $verifyStaff )) {
  14574. $verifyList [$k] ['date'] = "";
  14575. $verifyList [$k] ['opinion'] = "";
  14576. if ($v [0] == $this->staff [0] ['sid']) {
  14577. $verifyList [$k] ['status'] = 4;
  14578. $button = 4;
  14579. }
  14580. } else {
  14581. $flag = true;
  14582. foreach ( $verifyStaff as $m => $u ) {
  14583. if ($v [0] == $m) {
  14584. $verifyList [$k] ['date'] = $u ['date'];
  14585. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14586. $verifyList [$k] ['status'] = $u ['status'];
  14587. $flag = false;
  14588. break;
  14589. }
  14590. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14591. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14592. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14593. }
  14594. if ($flag) { // 检测可编辑
  14595. if ($v [0] == $this->staff [0] ['sid']) {
  14596. $verifyList [$k] ['status'] = 4;
  14597. $button = 4;
  14598. }
  14599. }
  14600. }
  14601. }
  14602. $receiptList [$key] ['verifyList'] = $verifyList;
  14603. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14604. 'where' => 'sid=' . $value ['staff'],
  14605. 'asArray' => true
  14606. ) );
  14607. $receiptList [$key] ['button'] = $button;
  14608. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14609. }
  14610. // print_r($receiptList);die;
  14611. // $data['verifyDetail']=$verifyDetail;
  14612. $mothHtml = "";
  14613. for($i = 1; $i <= 12; $i ++) {
  14614. if ($month == $i)
  14615. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14616. else
  14617. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14618. }
  14619. $data ['mothHtml'] = $mothHtml;
  14620. $data ['page'] = $pageinfo;
  14621. $data ['receiptList'] = $receiptList;
  14622. $data ['receiptApprovalCount'] = count ( $rLRes );
  14623. $data ['status'] = $status;
  14624. $data ['year'] = $year;
  14625. $data ['categoryList'] = $categoryList;
  14626. $data ['staffList'] = $staffList;
  14627. $data ['cid'] = $cid;
  14628. $data ['sid'] = $sid;
  14629. // print_r($receiptList);
  14630. $data ['memu'] = "receipt";
  14631. $data ['staff'] = $this->staff;
  14632. $data ['receiptMemu'] = 'approvalExpenses';
  14633. $data ['verifyId'] = $this->verifyId;
  14634. $data ['executeId'] = $this->executeId;
  14635. $this->render ( "/admin/FALG", $data );
  14636. }
  14637. function ajaxGetReceiptOrder() {
  14638. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14639. if (! empty ( $receiptOrder )) {
  14640. Doo::loadModel ( 'receipt' );
  14641. $receipt = new receipt ();
  14642. Doo::loadModel ( 'staff' );
  14643. $staff = new staff ();
  14644. $receiptInfo = $receipt->getOne ( array (
  14645. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14646. 'asArray' => true
  14647. ) );
  14648. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14649. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14650. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14651. </tbody></table><table class="table table table-bordered"><tbody>';
  14652. foreach ( $verifyStaff as $key => $value ) {
  14653. $staffInfo = $staff->getOne ( array (
  14654. 'select' => 'username',
  14655. 'where' => ' sid="' . $key . '"',
  14656. 'asArray' => true
  14657. ) );
  14658. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14659. }
  14660. $html .= '</tbody></table></div></div>';
  14661. echo json_encode ( array (
  14662. 'status' => 1,
  14663. 'receiptHtml' => $html
  14664. ) );
  14665. die ();
  14666. }
  14667. echo json_encode ( array (
  14668. 'status' => 2,
  14669. 'receiptHtml' => ''
  14670. ) );
  14671. die ();
  14672. }
  14673. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14674. if (! empty ( $receiptCollectList )) {
  14675. $receiptL = array (
  14676. '日常相关费用' => array (),
  14677. '差旅相关费用' => array (),
  14678. '内部培训费用'=>array(),
  14679. '培训班费用' => array (),
  14680. '其他' => array ()
  14681. );
  14682. $html = "";
  14683. $psum = 0;
  14684. foreach ( $aiList[$this->AGENCY] as $value ) {
  14685. $falg = true;
  14686. foreach ( $receiptCollectList as $v ) {
  14687. if ($v ['itemCategory'] == '日常相关费用') {
  14688. if ($v ['item'] == $value['name']) {
  14689. $psum += $v ['price'];
  14690. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14691. $falg = false;
  14692. break;
  14693. }
  14694. }
  14695. }
  14696. if ($falg)
  14697. $html .= '<td class="taR">-</td>';
  14698. }
  14699. if (! empty ( $psum ))
  14700. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14701. else
  14702. $psum = '<td class="colGreen taR">-</td>';
  14703. $receiptL ['日常相关费用'] = $psum . $html;
  14704. /* ----------------------------------- */
  14705. $html = "";
  14706. $psum = 0;
  14707. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14708. $falg = true;
  14709. foreach ( $receiptCollectList as $v ) {
  14710. if ($v ['itemCategory'] == '差旅相关费用') {
  14711. if ($v ['item'] == $value['name']) {
  14712. $psum += $v ['price'];
  14713. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14714. $falg = false;
  14715. break;
  14716. }
  14717. }
  14718. }
  14719. if ($falg)
  14720. $html .= '<td class="taR">-</td>';
  14721. }
  14722. if (! empty ( $psum ))
  14723. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14724. else
  14725. $psum = '<td class="colGreen taR">-</td>';
  14726. $receiptL ['差旅相关费用'] = $psum . $html;
  14727. /* ----------------------------------- */
  14728. $html = "";
  14729. $psum = 0;
  14730. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14731. $falg = true;
  14732. foreach ( $receiptCollectList as $v ) {
  14733. if ($v ['itemCategory'] == '内部培训费用') {
  14734. if ($v ['item'] == $value['name']) {
  14735. $psum += $v ['price'];
  14736. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14737. $falg = false;
  14738. break;
  14739. }
  14740. }
  14741. }
  14742. if ($falg)
  14743. $html .= '<td class="taR">-</td>';
  14744. }
  14745. if (! empty ( $psum ))
  14746. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14747. else
  14748. $psum = '<td class="colGreen taR">-</td>';
  14749. $receiptL ['内部培训费用'] = $psum . $html;
  14750. /* ------------------------------------- */
  14751. $html = "";
  14752. $psum = 0;
  14753. foreach ( $aiList[$this->TRAIN] as $value ) {
  14754. $falg = true;
  14755. foreach ( $receiptCollectList as $v ) {
  14756. if ($v ['itemCategory'] == '培训班费用') {
  14757. if ($v ['item'] == $value['name']) {
  14758. $psum += $v ['price'];
  14759. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14760. $falg = false;
  14761. break;
  14762. }
  14763. }
  14764. }
  14765. if ($falg)
  14766. $html .= '<td class="taR">-</td>';
  14767. }
  14768. if (! empty ( $psum ))
  14769. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14770. else
  14771. $psum = '<td class="colGreen taR">-</td>';
  14772. $receiptL ['培训班费用'] = $psum . $html;
  14773. /* ------------------------------------- */
  14774. $html = "";
  14775. $psum = 0;
  14776. foreach ( $aiList[$this->OTHER] as $value ) {
  14777. $falg = true;
  14778. foreach ( $receiptCollectList as $v ) {
  14779. if ($v ['itemCategory'] == '其他') {
  14780. if ($v ['item'] == $value['name']) {
  14781. $psum += $v ['price'];
  14782. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14783. $falg = false;
  14784. break;
  14785. }
  14786. }
  14787. }
  14788. if ($falg)
  14789. $html .= '<td class="taR">-</td>';
  14790. }
  14791. if (! empty ( $psum ))
  14792. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14793. else
  14794. $psum = '<td class="colGreen taR">-</td>';
  14795. $receiptL ['其他'] = $psum . $html;
  14796. /* ------------------------------------- */
  14797. $html = "";
  14798. $psum = 0;
  14799. foreach ( $receiptCollectList as $v ) {
  14800. if ($v ['itemCategory'] == '报销金额调整') {
  14801. if (! empty ( $v ['price'] ))
  14802. $psum += $v ['price'];
  14803. }
  14804. }
  14805. if (! empty ( $psum ))
  14806. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14807. else
  14808. $psum = '<td class="taR colOrange">-</td>';
  14809. $receiptL ['报销金额调整'] = $psum . $html;
  14810. } else {
  14811. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14812. foreach ( $aiList[$this->AGENCY] as $va ) {
  14813. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14814. }
  14815. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14816. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14817. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14818. }
  14819. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14820. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14821. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14822. }
  14823. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14824. foreach ( $aiList[$this->TRAIN] as $va ) {
  14825. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14826. }
  14827. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14828. foreach ( $aiList[$this->OTHER] as $va ) {
  14829. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14830. }
  14831. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14832. }
  14833. return $receiptL;
  14834. }
  14835. function eMail() {
  14836. Doo::loadModel ( 'staff' );
  14837. $staff = new staff ();
  14838. Doo::loadModel ( 'receipt' );
  14839. $receipt = new receipt ();
  14840. Doo::loadModel ( 'L_category' );
  14841. $Lcategory = new L_category ();
  14842. Doo::loadModel ( "verify" );
  14843. $verify = new verify ();
  14844. $staffList = $staff->find ( array (
  14845. 'asArray' => true
  14846. ) );
  14847. foreach ( $staffList as $key => $value ) {
  14848. if ($value ['username'] != 'admin') {
  14849. // 提交人
  14850. $receiptList = $receipt->find ( array (
  14851. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14852. 'asArray' => true
  14853. ) );
  14854. if (! empty ( $receiptList )) {
  14855. $html = '<br><div><style></style>
  14856. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14857. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14858. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14859. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14860. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14861. <tbody><tr>
  14862. <td style="padding: 0 40px;" align="left">
  14863. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14864. </td></tr><tr>
  14865. <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>
  14866. </tr>
  14867. </tbody> </table></td> </tr> <tr><td>
  14868. <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">
  14869. <tbody> <tr><td>
  14870. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14871. 以下报销单完成了审批,等着收款吧:</p>
  14872. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14873. foreach ( $receiptList as $k => $v ) {
  14874. $category = $Lcategory->getOne ( array (
  14875. 'where' => 'cid=' . $v ['cid'],
  14876. 'asArray' => true
  14877. ) );
  14878. $html .= '
  14879. <tr>
  14880. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14881. <td align="left">
  14882. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14883. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14884. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14885. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14886. </tr>';
  14887. }
  14888. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14889. <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>
  14890. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14891. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14892. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14893. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14894. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14895. $receipt = new receipt ();
  14896. $receipt->notice = 1;
  14897. $receipt->update ( array (
  14898. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14899. ) );
  14900. }
  14901. }
  14902. // 审批人
  14903. $verifyList = $verify->find ( array (
  14904. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14905. 'asArray' => true
  14906. ) );
  14907. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14908. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14909. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14910. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14911. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14912. <tbody><tr><td style="padding: 0 40px;" align="left">
  14913. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14914. </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>
  14915. </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">
  14916. <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>
  14917. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14918. foreach ( $verifyList as $k => $v ) {
  14919. $receiptList = $receipt->find ( array (
  14920. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14921. 'asArray' => true
  14922. ) );
  14923. foreach ( $receiptList as $r => $l ) {
  14924. $category = $Lcategory->getOne ( array (
  14925. 'where' => 'cid=' . $l ['cid'],
  14926. 'asArray' => true
  14927. ) );
  14928. $staffDetile = $staff->getOne ( array (
  14929. 'where' => 'sid=' . $l ['staff'],
  14930. 'asArray' => true
  14931. ) );
  14932. $html .= '
  14933. <tr>
  14934. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14935. <td align="left">
  14936. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14937. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14938. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14939. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14940. </tr>';
  14941. }
  14942. }
  14943. $html .= '
  14944. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14945. <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>
  14946. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14947. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14948. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14949. // $receipt=new receipt();
  14950. // $receipt->notice=1;
  14951. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14952. }
  14953. }
  14954. }
  14955. }
  14956. function setWXMsg($rid, $type) {
  14957. Doo::loadModel ( "receipt" );
  14958. $receipt = new receipt ();
  14959. $receiptDetail = $receipt->getOne ( array (
  14960. 'where' => 'rid=' . $rid,
  14961. 'asArray' => true
  14962. ) );
  14963. if (! empty ( $receiptDetail )) {
  14964. Doo::loadModel ( 'staff' );
  14965. $staff = new staff ();
  14966. $staffmsg = $staff->getOne ( array (
  14967. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14968. 'asArray' => TRUE
  14969. ) );
  14970. if (! empty ( $staffmsg ['wxid'] )) {
  14971. require_once (SITE_PATH . '/protected/class/client.php');
  14972. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14973. $user = $staffmsg ['wxid'];
  14974. $receiptName = '';
  14975. $msg = '';
  14976. switch ($receiptDetail ['Rtype']) {
  14977. case 0 :
  14978. $receiptName = '报销';
  14979. break;
  14980. case 1 :
  14981. $receiptName = '借款';
  14982. break;
  14983. case 2 :
  14984. $receiptName = '对公汇款';
  14985. break;
  14986. }
  14987. switch ($type) {
  14988. case 1 :
  14989. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14990. break;
  14991. case 2 :
  14992. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14993. break;
  14994. case 3 :
  14995. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14996. break;
  14997. }
  14998. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14999. }
  15000. }
  15001. }
  15002. // Email发送函数
  15003. function SMail($toemail, $subject, $contents) {
  15004. Doo::loadClass ( 'class.phpmailer' );
  15005. $mail = new PHPMailer ();
  15006. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  15007. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  15008. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  15009. $mail->Password = "cDO1GjtY1seH"; // 密码
  15010. $mail->CharSet = "UTF8";
  15011. $mail->SMTPAuth = true;
  15012. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  15013. $mail->Mailer = "smtp";
  15014. $mail->Port = 25;
  15015. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  15016. $mail->MsgHTML ( $contents );
  15017. $mail->AddAddress ( $toemail );
  15018. $mail->CharSet = "UTF-8";
  15019. return $mail->Send ();
  15020. }
  15021. function h5Upload() {
  15022. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  15023. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  15024. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  15025. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  15026. header ( "HTTP/1.1 500 Internal Server Error" );
  15027. echo "POST exceeded maximum allowed size.";
  15028. exit ( 0 );
  15029. }
  15030. // Settings
  15031. $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)
  15032. $upload_name = "Filedata";
  15033. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  15034. $extension_whitelist = array (
  15035. "doc",
  15036. "txt",
  15037. "jpg",
  15038. "gif",
  15039. "png"
  15040. ); // Allowed file extensions
  15041. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  15042. // Other variables
  15043. $MAX_FILENAME_LENGTH = 260;
  15044. $file_name = "";
  15045. $file_extension = "";
  15046. $uploadErrors = array (
  15047. 0 => "文件上传成功",
  15048. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  15049. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  15050. 3 => "上传的文件仅为部分文件",
  15051. 4 => "没有文件上传",
  15052. 6 => "缺少临时文件夹"
  15053. );
  15054. $nk = time ();
  15055. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  15056. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  15057. echo "文件无法保存.";
  15058. exit ( 0 );
  15059. }
  15060. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  15061. echo json_encode ( array (
  15062. 'filename' => $file_name,
  15063. 'id' => $nk
  15064. ) );
  15065. exit ( 0 );
  15066. }
  15067. function swfupload() {
  15068. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  15069. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  15070. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  15071. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  15072. header ( "HTTP/1.1 500 Internal Server Error" );
  15073. echo "POST exceeded maximum allowed size.";
  15074. exit ( 0 );
  15075. }
  15076. // Settings
  15077. $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)
  15078. $upload_name = "Filedata";
  15079. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  15080. $extension_whitelist = array (
  15081. "doc",
  15082. "txt",
  15083. "jpg",
  15084. "gif",
  15085. "png"
  15086. ); // Allowed file extensions
  15087. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  15088. // Other variables
  15089. $MAX_FILENAME_LENGTH = 260;
  15090. $file_name = "";
  15091. $file_extension = "";
  15092. $uploadErrors = array (
  15093. 0 => "文件上传成功",
  15094. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  15095. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  15096. 3 => "上传的文件仅为部分文件",
  15097. 4 => "没有文件上传",
  15098. 6 => "缺少临时文件夹"
  15099. );
  15100. $nk = time ();
  15101. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  15102. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  15103. echo "文件无法保存.";
  15104. exit ( 0 );
  15105. }
  15106. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  15107. echo json_encode ( array (
  15108. 'filename' => $file_name,
  15109. 'id' => $nk
  15110. ) );
  15111. exit ( 0 );
  15112. }
  15113. function _GetFileEXT($filename) {
  15114. $pics = explode ( '.', $filename );
  15115. $num = count ( $pics );
  15116. return $pics [$num - 1];
  15117. }
  15118. /**
  15119. * 获取get或者POST值
  15120. * @param string $name 属性名称
  15121. * @return fixed 值
  15122. */
  15123. function get_args($name) {
  15124. if (isset ( $_GET [$name] )) {
  15125. if (is_array ( $_GET [$name] ))
  15126. return $_GET [$name];
  15127. else
  15128. return addslashes ( $_GET [$name] );
  15129. } elseif (isset ( $_POST [$name] )) {
  15130. if (is_array ( $_POST [$name] ))
  15131. return $_POST [$name];
  15132. else
  15133. return addslashes ( $_POST [$name] );
  15134. } else
  15135. return false;
  15136. }
  15137. function num_to_rmb($num) {
  15138. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15139. $c2 = "分角元拾佰仟万拾佰仟亿";
  15140. // 精确到分后面就不要了,所以只留两个小数位
  15141. $num = round ( $num, 2 );
  15142. // 将数字转化为整数
  15143. $num = $num * 100;
  15144. if (strlen ( $num ) > 10) {
  15145. return "金额太大,请检查";
  15146. }
  15147. $i = 0;
  15148. $c = "";
  15149. while ( 1 ) {
  15150. if ($i == 0) {
  15151. // 获取最后一位数字
  15152. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15153. } else {
  15154. $n = $num % 10;
  15155. }
  15156. // 每次将最后一位数字转化为中文
  15157. $p1 = substr ( $c1, 3 * $n, 3 );
  15158. $p2 = substr ( $c2, 3 * $i, 3 );
  15159. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15160. $c = $p1 . $p2 . $c;
  15161. } else {
  15162. $c = $p1 . $c;
  15163. }
  15164. $i = $i + 1;
  15165. // 去掉数字最后一位了
  15166. $num = $num / 10;
  15167. // echo $num.'</br>';
  15168. $num = ( int ) $num;
  15169. // $num =floor($num);
  15170. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15171. // echo $num.'</br>';
  15172. // 结束循环
  15173. if ($num == 0) {
  15174. break;
  15175. }
  15176. }
  15177. // echo $c.'</br>';
  15178. $j = 0;
  15179. $slen = strlen ( $c );
  15180. while ( $j < $slen ) {
  15181. // utf8一个汉字相当3个字符
  15182. $m = substr ( $c, $j, 6 );
  15183. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15184. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15185. $left = substr ( $c, 0, $j );
  15186. $right = substr ( $c, $j + 3 );
  15187. $c = $left . $right;
  15188. $j = $j - 3;
  15189. $slen = $slen - 3;
  15190. }
  15191. $j = $j + 3;
  15192. }
  15193. // 这个是为了去掉类似23.0中最后一个“零”字
  15194. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15195. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15196. }
  15197. // 将处理的汉字加上“整”
  15198. if (empty ( $c )) {
  15199. return "零元整";
  15200. } else {
  15201. return $c . "整";
  15202. }
  15203. }
  15204. /**
  15205. * 获得分页数据
  15206. * @param unknown_type $table
  15207. * @param unknown_type $condition
  15208. * @param unknown_type $on_page
  15209. * @param unknown_type $page_size
  15210. */
  15211. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15212. $page_c = "";
  15213. $page ['previous'] = $this->get_previous ( $on_page );
  15214. $page ['on_page'] = $on_page;
  15215. $total_count = $this->get_table_count ( $table, $condition );
  15216. $total = intval ( $total_count / $page_size );
  15217. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15218. $page ['total_data'] = $total_count;
  15219. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15220. $i = 1;
  15221. $page_max = 1;
  15222. $page_width = 3;
  15223. if ($on_page >= $page_width) {
  15224. $page_max = intval ( $on_page / $page_width ) + 1;
  15225. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15226. }
  15227. for(; $i <= $page ['total_page']; $i ++) {
  15228. if ($i == $on_page)
  15229. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15230. else
  15231. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15232. if ($i == ($page_width * $page_max))
  15233. break;
  15234. }
  15235. $page ['page'] = $page_c;
  15236. $page ['lower'] = (-- $on_page) * $page_size;
  15237. return $page;
  15238. }
  15239. /**
  15240. * 获取总页数
  15241. * @param unknown_type $table
  15242. * @param unknown_type $condition
  15243. */
  15244. public function get_table_count($table = "", $condition = "") {
  15245. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15246. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15247. // echo $sql;die;
  15248. $query = Doo::db ()->query ( $sql );
  15249. $result = $query->fetch ();
  15250. return $result ['count'];
  15251. }
  15252. /**
  15253. * 获取上一页
  15254. * @param unknown_type $on_page
  15255. */
  15256. function get_previous($on_page = 1) {
  15257. return $on_page != 0 ? $on_page - 1 : $on_page;
  15258. }
  15259. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15260. // 收入合计
  15261. Doo::loadModel ( 'invoiceTraining' );
  15262. $invoiceTraining = new invoiceTraining ();
  15263. Doo::loadModel ( 'receipt' );
  15264. $receipt = new receipt ();
  15265. $invoiceTrainingDetail = array (
  15266. 'invoiceArriveAmount' => '0.00',
  15267. 'RIAmount' => '0.00',
  15268. 'invoiceTotalAmount' => '0.00',
  15269. 'invoiceCompanyAmount' => '0.00',
  15270. 'invoiceArriveAmountM'=>'0.00',
  15271. 'invoiceCompanyAmountM'=>'0.00'
  15272. );
  15273. if ($invoiceTrainId != 0) {
  15274. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15275. }
  15276. $invoiceArriveAmount = $RIAmount = 0;
  15277. if (! empty ( $invoiceTrainingDetail )) {
  15278. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15279. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15280. }
  15281. // 备用金
  15282. $sum = 0;
  15283. if (! empty ( $trainLoanRid )) {
  15284. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15285. foreach ($receiptLoanList as $key=>$value){
  15286. $sum+=$value['sum'];
  15287. }
  15288. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15289. // $sum = $receiptLoanDetailBak ['sum'];
  15290. }
  15291. // 支出项金额详情
  15292. // 项目金额合计
  15293. Doo::loadModel ( 'RItem' );
  15294. $RItem = new RItem ();
  15295. Doo::loadModel ( 'accountItem' );
  15296. $accountItem = new accountItem ();
  15297. // 讲师获得
  15298. Doo::loadModel ( 'RILecturer' );
  15299. $RILecturer = new RILecturer ();
  15300. $RItemList = $RItem->getRItemByRid ($rid );
  15301. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15302. // 支出项金额详情
  15303. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15304. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15305. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15306. return $payment;
  15307. }
  15308. }
  15309. ?>