ReceiptController.php 569 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. private function _itineraryDateMin(){
  58. Doo::loadModel ( "itinerary" );
  59. $itinerary = new itinerary ();
  60. $itineraryDetail=$itinerary->getOne(array (
  61. 'where'=>'sid ='.$this->staff [0] ['sid'],
  62. 'desc'=>'itineraryDate',
  63. 'asArray' => true
  64. ));
  65. return date("Y-m-d",strtotime("+1 day",strtotime($itineraryDetail['itineraryDate'])));
  66. }
  67. public function beforeRun($resource, $action) {
  68. Doo::loadClass ( 'XDeode' );
  69. $XDeode = new XDeode ( 5 );
  70. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  71. // 单独判断公司汇总的访问权限
  72. if ($action == 'companyCategoryCollect') {
  73. Doo::loadModel ( "receiptAuthorityManage" );
  74. $invoiceCompanyManage = new receiptAuthorityManage ();
  75. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  76. if (empty ( $icm ))
  77. die ( 'illegal request-statistics' );
  78. }
  79. Doo::loadModel ( 'staff' );
  80. $staff = new staff ();
  81. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  82. $accessModular = 'RECEIPTS';
  83. if (empty ( $detail ['cldAccessArray'] ))
  84. die ( 'illegal request' );
  85. else {
  86. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  87. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  88. $flag = true;
  89. } else {
  90. $flag = false;
  91. }
  92. } else {
  93. die ( 'illegal request' );
  94. }
  95. }
  96. if (! $flag)
  97. die ( 'illegal request' );
  98. }
  99. function __construct() {
  100. if (isset ( $_COOKIE ["staff"] )) {
  101. if (! empty ( $_COOKIE ["staff"] )) {
  102. Doo::loadModel ( 'staff' );
  103. Doo::loadModel ( 'verify' );
  104. $verify = new verify ();
  105. $staff = new staff ();
  106. Doo::loadModel ( "execute" );
  107. $execute = new execute ();
  108. $verifyList = $verify->find ( array (
  109. 'select' => 'staff',
  110. 'asArray' => true
  111. ) );
  112. $list = array ();
  113. // 判断角色的审批权限
  114. foreach ( $verifyList as $key => $value ) {
  115. $ver = json_decode ( $value ['staff'] );
  116. foreach ( $ver as $k => $v ) {
  117. if ($v [1] == 'ROLE') {
  118. $roleList = json_decode ( $v [3] );
  119. foreach ( $roleList as $t => $g ) {
  120. $gList = explode ( "_", $g );
  121. array_push ( $list, $gList [0] );
  122. // print_r($list);
  123. }
  124. } else
  125. array_push ( $list, $v [0] );
  126. }
  127. }
  128. // 判断执行人的审批权限
  129. $executeList = $execute->find ( array (
  130. 'where'=>'mold !="日常收支"',
  131. 'select' => 'staff',
  132. 'asArray' => true
  133. ) );
  134. $list2 = array ();
  135. foreach ( $executeList as $key => $value ) {
  136. $ver = json_decode ( $value ['staff'] );
  137. foreach ( $ver as $k => $v ) {
  138. array_push ( $list2, $v [0] );
  139. }
  140. }
  141. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  142. $eidList = array_filter ( explode ( ",", $eidList ) );
  143. $this->executeId = array_merge ( $list2, $eidList );
  144. $this->verifyId = $list;
  145. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  146. // 检测用户信息完成
  147. $this->data ['isStaffCompleteMsg'] = false;
  148. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  149. if (! empty ( $detail ))
  150. $this->data ['isStaffCompleteMsg'] = true;
  151. return "/";
  152. }
  153. }
  154. Doo::loadCore ( 'uri/DooUriRouter' );
  155. $router = new DooUriRouter ();
  156. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  157. if ($routeRs ['1'] != "login") {
  158. header ( 'Content-Type:text/html;charset=utf-8' );
  159. @header ( "Location: /login" );
  160. }
  161. }
  162. /**
  163. * 费用首页
  164. */
  165. function saeaBorad() {
  166. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  167. Doo::loadModel ( 'receipt' );
  168. $receipt = new receipt ();
  169. Doo::loadModel ( 'verify' );
  170. $verify = new verify ();
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. Doo::loadModel ( "receiptLog" );
  176. $receiptLog = new receiptLog ();
  177. Doo::loadModel ( 'accountItem' );
  178. $accountItem = new accountItem ();
  179. Doo::loadClass ( 'XDeode' );
  180. $XDeode = new XDeode ( 7 );
  181. $XDeode9 = new XDeode ( 9 );
  182. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  183. $receiptDetail = $receipt->find ( array (
  184. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  185. 'desc' => 'rid',
  186. 'asArray' => true
  187. ) );
  188. foreach ( $receiptDetail as $key => $value ) {
  189. $receiptDetail [$key] ['receiptId'] = $XDeode9->encode ( $value ['rid'] );
  190. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  191. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  192. $veList = $verify->getOne ( array (
  193. 'where' => 'vid=' . $value ['verify'],
  194. 'asArray' => true
  195. ) );
  196. $v = json_decode ( $veList ['staff'] );
  197. array_push ( $v [0], $veList ['description'] );
  198. foreach ( $v as $n => $m ) {
  199. if ($m ['1'] == 'ROLE') {
  200. $roleInfo = $role->getOne ( array (
  201. 'where' => 'rid=' . $m [0],
  202. 'asArray' => true
  203. ) );
  204. $v [$n] [1] = $roleInfo ['name'];
  205. }
  206. }
  207. $receiptDetail [$key] ['staff'] = $v;
  208. $category = $lCategory->getOne ( array (
  209. 'where' => 'cid=' . $value ['cid'],
  210. 'asArray' => true
  211. ) );
  212. $receiptDetail [$key] ['category'] = $category ['title'];
  213. }
  214. // print_r($receiptLogList);
  215. // 协助修改TODO,只显示未完成的
  216. Doo::loadModel ( 'RAssist' );
  217. $RAssist = new RAssist ();
  218. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  219. //费用项目
  220. $acItem = $accountItem->find ( array ('asArray' => true) );
  221. if ($travel=='success'){
  222. $data ['travel'] =true;
  223. }else{
  224. $data ['travel'] =false;
  225. }
  226. $data ['acItem'] = $acItem;
  227. $data ['receiptExtendList'] = $receiptExtendList;
  228. $data ['receiptLogList'] = $receiptLogList;
  229. $data ['receiptDetail'] = $receiptDetail;
  230. $data ['memu'] = "receipt";
  231. $data ['staff'] = $this->staff;
  232. $data ['receiptMemu'] = 'saeaBorad';
  233. $data ['verifyId'] = $this->verifyId;
  234. $data ['executeId'] = $this->executeId;
  235. $this->render ( "/receipt/receiptFee", $data );
  236. }
  237. /**
  238. * 费用报销单-导流入哪个细分类
  239. */
  240. function receiptFeeDiversion(){
  241. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  242. if($feeType==2){
  243. return '/receipt/feeTravel';
  244. }elseif($feeType==3){
  245. return '/receipt/feeInternalTrain';
  246. }else{
  247. return '/receipt/feeAgency';
  248. }
  249. }
  250. private function _feeData(){
  251. Doo::loadModel ( 'L_category' );
  252. $lCategory = new L_category ();
  253. Doo::loadModel ( 'verify' );
  254. $verify = new verify ();
  255. Doo::loadModel ( 'accountItem' );
  256. $accountItem = new accountItem ();
  257. Doo::loadModel ( "role" );
  258. $role = new role ();
  259. $acItem = $accountItem->find ( array (
  260. 'asArray' => true
  261. ) );
  262. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  263. $data ['category'] = $lCategory->find ( array (
  264. 'asArray' => true
  265. ) );
  266. $data ['itineraryDate'] = $this->_itineraryDateMin();
  267. $data ['veList'] = $veList;
  268. $data ['acItem'] = $acItem;
  269. $data ['memu'] = "receipt";
  270. $data ['staff'] = $this->staff;
  271. $data ['receiptMemu'] = 'saeaBorad';
  272. $data ['verifyId'] = $this->verifyId;
  273. $data ['executeId'] = $this->executeId;
  274. return $data;
  275. }
  276. /**
  277. * 办事处相关费用
  278. */
  279. function feeAgency(){
  280. $data=$this->_feeData();
  281. $this->render ( "/receipt/feeAgency", $data );
  282. }
  283. /**
  284. * 办事处
  285. */
  286. function feeTravel(){
  287. $data=$this->_feeData();
  288. $this->render ( "/receipt/feeTravel", $data );
  289. }
  290. function feeInternalTrain(){
  291. $data=$this->_feeData();
  292. $this->render ( "/receipt/feeInternalTrain", $data );
  293. }
  294. /**
  295. * 添加费用报销单页面
  296. */
  297. function saeaCreate() {
  298. Doo::loadModel ( 'accountItem' );
  299. Doo::loadModel ( 'verify' );
  300. Doo::loadModel ( 'receipt' );
  301. Doo::loadModel ( 'L_category' );
  302. $lCategory = new L_category ();
  303. $receipt = new receipt ();
  304. $verify = new verify ();
  305. $accountItem = new accountItem ();
  306. Doo::loadModel ( "role" );
  307. $role = new role ();
  308. $acItem = $accountItem->find ( array (
  309. 'asArray' => true
  310. ) );
  311. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  312. $data ['category'] = $lCategory->find ( array (
  313. 'asArray' => true
  314. ) );
  315. $data ['veList'] = $veList;
  316. $data ['acItem'] = $acItem;
  317. $data ['memu'] = "receipt";
  318. $data ['staff'] = $this->staff;
  319. $data ['receiptMemu'] = 'saeaBorad';
  320. $data ['verifyId'] = $this->verifyId;
  321. $data ['executeId'] = $this->executeId;
  322. $this->render ( "/admin/saea_create", $data );
  323. }
  324. private function _storageItinerary($itinerary,$rid,$version=2){
  325. $itineraryJson=json_decode($itinerary,true);
  326. Doo::loadModel ( 'itinerary' );
  327. $itinerary = new itinerary ();
  328. $itinerary->delete(array('where' => 'rid=' . $rid ));
  329. if($version==2){
  330. foreach ($itineraryJson as $k=>$v){
  331. foreach ($v as $kk=>$vv){
  332. foreach ($vv as $key=>$value){
  333. if($key==0){
  334. $feeTraveItem=json_encode($value['feeTraveItem']);
  335. $itinerary = new itinerary ();
  336. $itinerary->rid=$rid;
  337. $itinerary->sid=$this->staff [0] ['sid'];
  338. $itinerary->itineraryDate=$value['departuredate'];
  339. $itinerary->itineraryCity=$value['departurecity'];
  340. $itinerary->feeTraveItem='';
  341. $itinerary->itineraryIndex=0;
  342. $itinerary->insert ();
  343. $itinerary = new itinerary ();
  344. $itinerary->rid=$rid;
  345. $itinerary->sid=$this->staff [0] ['sid'];
  346. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  347. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  348. $itinerary->feeTraveItem=$feeTraveItem;
  349. $itinerary->itineraryIndex=1;
  350. $itinerary->insert ();
  351. }else{
  352. $feeTraveItem=json_encode($value['feeTraveItem']);
  353. $itinerary = new itinerary ();
  354. $itinerary->rid=$rid;
  355. $itinerary->sid=$this->staff [0] ['sid'];
  356. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  357. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  358. $itinerary->feeTraveItem=$feeTraveItem;
  359. $itinerary->itineraryIndex=$key+1;
  360. $itinerary->insert ();
  361. }
  362. }
  363. }
  364. }
  365. }elseif($version==1){
  366. foreach ($itineraryJson as $key=>$value){
  367. if($key==0){
  368. $feeTraveItem=json_encode($value['feeTraveItem']);
  369. $itinerary = new itinerary ();
  370. $itinerary->rid=$rid;
  371. $itinerary->sid=$this->staff [0] ['sid'];
  372. $itinerary->itineraryDate=$value['departuredate'];
  373. $itinerary->itineraryCity=$value['departurecity'];
  374. $itinerary->feeTraveItem='';
  375. $itinerary->itineraryIndex=0;
  376. $itinerary->insert ();
  377. $itinerary = new itinerary ();
  378. $itinerary->rid=$rid;
  379. $itinerary->sid=$this->staff [0] ['sid'];
  380. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  381. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  382. $itinerary->feeTraveItem=$feeTraveItem;
  383. $itinerary->itineraryIndex=1;
  384. $itinerary->insert ();
  385. }else{
  386. $feeTraveItem=json_encode($value['feeTraveItem']);
  387. $itinerary = new itinerary ();
  388. $itinerary->rid=$rid;
  389. $itinerary->sid=$this->staff [0] ['sid'];
  390. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  391. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  392. $itinerary->feeTraveItem=$feeTraveItem;
  393. $itinerary->itineraryIndex=$key+1;
  394. $itinerary->insert ();
  395. }
  396. }
  397. }else{
  398. die ( '行程单版本不正确' );
  399. }
  400. }
  401. private function _verificationItinerary($itinerary){
  402. Doo::loadModel ( 'itinerary' );
  403. $itineraryObj = new itinerary ();
  404. if(empty($itinerary)){
  405. header ( 'Content-Type:text/html;charset=utf-8' );
  406. die ( '请填写行程单' );
  407. }
  408. $itineraryJson=json_decode($itinerary,true);
  409. foreach ($itineraryJson as $k=>$v){
  410. foreach ($v as $kk=>$vv){
  411. foreach ($vv as $key=>$value){
  412. if(empty($value['departuredate'])||empty($value['arrivalsdate'])){
  413. header ( 'Content-Type:text/html;charset=utf-8' );
  414. die ( '有行程的日期未设置' );
  415. }
  416. }
  417. }
  418. }
  419. $itineraryDate=array();$sql=array();
  420. foreach ($itineraryJson as $k=>$v){
  421. foreach ($v as $kk=>$vv){
  422. foreach ($vv as $key=>$value){
  423. if($key==0){
  424. array_push($itineraryDate, $value['departuredate']);
  425. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  426. array_push($sql,'?');array_push($sql,'?');
  427. }else{
  428. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  429. array_push($sql,'?');
  430. }
  431. }
  432. }
  433. }
  434. array_push($itineraryDate, $this->staff [0] ['sid']);
  435. $sql=implode(',',$sql);
  436. // $itineraryDate=array();$sql=array();
  437. // foreach ($itineraryJson as $key=>$value){
  438. // if($key==0){
  439. // array_push($itineraryDate, $value['departuredate']);
  440. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  441. // array_push($sql,'?');array_push($sql,'?');
  442. // }else{
  443. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  444. // array_push($sql,'?');
  445. // }
  446. // }
  447. // array_push($itineraryDate, $this->staff [0] ['sid']);
  448. // $sql=implode(',',$sql);
  449. if(empty($sql)){
  450. header ( 'Content-Type:text/html;charset=utf-8' );
  451. die ( '请填写行程单-2' );
  452. }
  453. $qualification=array(
  454. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  455. 'param' => $itineraryDate,
  456. 'asArray' => TRUE);
  457. $itDateList=$itineraryObj->find($qualification);
  458. if(empty($itDateList)){
  459. return false;
  460. }else{
  461. return true;
  462. }
  463. }
  464. private function _buildFeeData($receiptClass=1,$itinerary=''){
  465. $agency = $this->get_args ( 'agency' );
  466. $travel = $this->get_args ( 'travel' );
  467. $train = $this->get_args ( 'train' );
  468. $other = $this->get_args ( 'other' );
  469. $inttrain = $this->get_args ( 'inttrain' );
  470. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  471. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  472. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  473. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  474. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  475. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  476. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  477. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  478. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  479. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  480. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  481. header ( 'Content-Type:text/html;charset=utf-8' );
  482. die ( '请填写联行号' );
  483. }
  484. if($receiptClass==2){
  485. //TODO 日期检测
  486. if($this->_verificationItinerary($itinerary)){
  487. header ( 'Content-Type:text/html;charset=utf-8' );
  488. die ( '已申请过类此日期的行程' );
  489. }
  490. }
  491. $itinerary=str_replace('\n','<br/>',$itinerary);
  492. Doo::loadModel ( 'receipt' );
  493. Doo::loadModel ( 'receiptDetail' );
  494. Doo::loadModel ( 'accountItem' );
  495. $accountItem = new accountItem ();
  496. $receipt = new receipt ();
  497. Doo::loadModel ( 'enclosur' );
  498. Doo::loadModel ( 'execute' );
  499. $execute = new execute ();
  500. $executeDetail = $execute->getOne ( array (
  501. 'where' => 'mold="报销单执行人"',
  502. 'asArray' => true
  503. ) );
  504. $aItem = $accountItem->find ( array (
  505. 'asArray' => true
  506. ) );
  507. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  508. $ag = $tr = $ta = $ot= $it = 0;
  509. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  510. foreach ( $aItem as $key => $value ) {
  511. if ($value ['category'] == $this->AGENCY) {
  512. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  513. array_push ( $accountJson [$this->AGENCY], array (
  514. 'aid' => $value ['aid'],
  515. 'name' => $value ['name'],
  516. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  517. ) );
  518. $sum += $agency [$ag];
  519. $agencySum += $agency [$ag];
  520. }
  521. $ag ++;
  522. }
  523. if ($value ['category'] == $this->TRAVEL) {
  524. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  525. array_push ( $accountJson [$this->TRAVEL], array (
  526. 'aid' => $value ['aid'],
  527. 'name' => $value ['name'],
  528. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  529. ) );
  530. $sum += $travel [$tr];
  531. $travelSum += $travel [$tr];
  532. }
  533. $tr ++;
  534. }
  535. if ($value ['category'] == $this->TRAIN) {
  536. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  537. array_push ( $accountJson [$this->TRAIN], array (
  538. 'aid' => $value ['aid'],
  539. 'name' => $value ['name'],
  540. 'price' => number_format ( $train [$ta], 2, '.', '' )
  541. ) );
  542. $sum += $train [$ta];
  543. $trainSum += $train [$ta];
  544. }
  545. $ta ++;
  546. }
  547. if ($value ['category'] == $this->INTTRAIN) {
  548. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  549. array_push ( $accountJson [$this->INTTRAIN], array (
  550. 'aid' => $value ['aid'],
  551. 'name' => $value ['name'],
  552. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  553. ) );
  554. $sum += $inttrain [$it];
  555. $inttrainSum += $inttrain [$it];
  556. }
  557. $it ++;
  558. }
  559. if ($value ['category'] == $this->OTHER) {
  560. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  561. array_push ( $accountJson [$this->OTHER], array (
  562. 'aid' => $value ['aid'],
  563. 'name' => $value ['name'],
  564. 'price' => number_format ( $other [$ot], 2, '.', '' )
  565. ) );
  566. $sum += $other [$ot];
  567. $otherSum += $other [$ot];
  568. }
  569. $ot ++;
  570. }
  571. }
  572. $accountJson ['cSum'] = array (
  573. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  574. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  575. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  576. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  577. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  578. );
  579. // 报销单
  580. $receipt->accountItem = json_encode ( $accountJson );
  581. $receipt->staff = $this->staff [0] ['sid'];
  582. $receipt->sum = number_format ( $sum, 2, '.', '' );
  583. $receipt->date = date ( "Y-m-d" );
  584. $receipt->cid = $cid;
  585. $receipt->status = 5;
  586. // 修改审批流程加入角色
  587. $receipt->verify = $verify;
  588. $receipt->executeCopy = $executeDetail ['staff'];
  589. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  590. $order = array (
  591. "\r\n",
  592. "\n",
  593. "\r"
  594. );
  595. $replace = '<br/>';
  596. $explanation = str_replace ( $order, $replace, $explanation );
  597. $receipt->explanation = $explanation;
  598. $receipt->receiptClass = $receiptClass;
  599. $receipt->itinerary2=$itinerary;
  600. $receipt->remittanceName = $remittanceName;
  601. $receipt->bankName = $bankName;
  602. $receipt->bankNumber = $bankNumber;
  603. $receipt->remittanceBankType = $remittanceBankType;
  604. if ($remittanceBankType == 1) {
  605. $receipt->coupletNumber = $coupletNumber;
  606. }
  607. $rid = $receipt->insert ();
  608. //记录行程单
  609. $this->_storageItinerary($itinerary,$rid);
  610. // 附件
  611. if (! empty ( $enclosurName )) {
  612. $enclosurArray = explode ( '-', $enclosurName );
  613. foreach ( $enclosurArray as $value ) {
  614. $enclosur = new enclosur ();
  615. $enclosur->name = $value;
  616. $enclosur->rid = $rid;
  617. $enclosur->insert ();
  618. }
  619. }
  620. // 报销详情
  621. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  622. $receiptDetail = new receiptDetail ();
  623. $receiptDetail->staff = $this->staff [0] ['sid'];
  624. $receiptDetail->item = $value ['name'];
  625. $receiptDetail->itemCategory = $this->AGENCY;
  626. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  627. $receiptDetail->date = date ( "Y-m-d" );
  628. $receiptDetail->cid = $cid;
  629. $receiptDetail->rid = $rid;
  630. $receiptDetail->status = 4;
  631. $receiptDetail->insert ();
  632. }
  633. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  634. $receiptDetail = new receiptDetail ();
  635. $receiptDetail->staff = $this->staff [0] ['sid'];
  636. $receiptDetail->item = $value ['name'];
  637. $receiptDetail->itemCategory = $this->TRAVEL;
  638. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  639. $receiptDetail->date = date ( "Y-m-d" );
  640. $receiptDetail->cid = $cid;
  641. $receiptDetail->rid = $rid;
  642. $receiptDetail->status = 4;
  643. $receiptDetail->insert ();
  644. }
  645. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  646. $receiptDetail = new receiptDetail ();
  647. $receiptDetail->staff = $this->staff [0] ['sid'];
  648. $receiptDetail->item = $value ['name'];
  649. $receiptDetail->itemCategory = $this->TRAIN;
  650. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  651. $receiptDetail->date = date ( "Y-m-d" );
  652. $receiptDetail->cid = $cid;
  653. $receiptDetail->rid = $rid;
  654. $receiptDetail->status = 4;
  655. $receiptDetail->insert ();
  656. }
  657. // 内训
  658. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  659. $receiptDetail = new receiptDetail ();
  660. $receiptDetail->staff = $this->staff [0] ['sid'];
  661. $receiptDetail->item = $value ['name'];
  662. $receiptDetail->itemCategory = $this->INTTRAIN;
  663. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  664. $receiptDetail->date = date ( "Y-m-d" );
  665. $receiptDetail->cid = $cid;
  666. $receiptDetail->rid = $rid;
  667. $receiptDetail->status = 4;
  668. $receiptDetail->insert ();
  669. }
  670. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  671. $receiptDetail = new receiptDetail ();
  672. $receiptDetail->staff = $this->staff [0] ['sid'];
  673. $receiptDetail->item = $value ['name'];
  674. $receiptDetail->itemCategory = $this->OTHER;
  675. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  676. $receiptDetail->date = date ( "Y-m-d" );
  677. $receiptDetail->cid = $cid;
  678. $receiptDetail->rid = $rid;
  679. $receiptDetail->status = 4;
  680. $receiptDetail->insert ();
  681. }
  682. return true;
  683. } else
  684. return false;
  685. }
  686. function addReceipt() {
  687. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  688. if ($this->_buildFeeData(1)) {
  689. return "/saeaBorad";
  690. } else{
  691. die ( 'illegal request' );
  692. }
  693. }
  694. function addFeeTravel(){
  695. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  696. $itineraryList=json_decode($itinerary,true);
  697. // foreach ($itineraryList as $key=>$value){
  698. // if(empty($value['departuredate'])||empty($value['departurecity'])){
  699. // header ( 'Content-Type:text/html;charset=utf-8' );
  700. // die ( '请设置出发地和出发日期' );
  701. // }
  702. // }
  703. if ($this->_buildFeeData(2,$itinerary)) {
  704. return "/saeaBorad?travel=success";
  705. } else{
  706. die ( 'illegal request' );
  707. }
  708. }
  709. function addFeeInternalTrain(){
  710. if ($this->_buildFeeData(3)) {
  711. return "/saeaBorad";
  712. } else{
  713. die ( 'illegal request' );
  714. }
  715. }
  716. function referReceipt() {
  717. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  718. Doo::loadModel ( 'receipt' );
  719. Doo::loadModel ( 'verify' );
  720. $verify = new verify ();
  721. $receipt = new receipt ();
  722. Doo::loadModel ( 'L_category' );
  723. $lCategory = new L_category ();
  724. Doo::loadModel ( "role" );
  725. $role = new role ();
  726. $receiptDetail = $receipt->find ( array (
  727. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  728. 'asArray' => true
  729. ) );
  730. if (empty ( $receiptDetail ))
  731. return "/addReceipt";
  732. foreach ( $receiptDetail as $key => $value ) {
  733. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  734. $veList = $verify->getOne ( array (
  735. 'where' => 'vid=' . $value ['verify'],
  736. 'asArray' => true
  737. ) );
  738. $v = json_decode ( $veList ['staff'] );
  739. array_push ( $v [0], $veList ['description'] );
  740. foreach ( $v as $n => $m ) {
  741. if ($m ['1'] == 'ROLE') {
  742. $roleInfo = $role->getOne ( array (
  743. 'where' => 'rid=' . $m [0],
  744. 'asArray' => true
  745. ) );
  746. $v [$n] [1] = $roleInfo ['name'];
  747. }
  748. }
  749. $receiptDetail [$key] ['staff'] = $v;
  750. $category = $lCategory->getOne ( array (
  751. 'where' => 'cid=' . $value ['cid'],
  752. 'asArray' => true
  753. ) );
  754. $receiptDetail [$key] ['category'] = $category ['title'];
  755. }
  756. // print_r($receiptDetail);
  757. $data ['receiptDetail'] = $receiptDetail;
  758. $data ['memu'] = "receipt";
  759. $data ['staff'] = $this->staff;
  760. $data ['receiptMemu'] = 'saeaCreate';
  761. $data ['verifyId'] = $this->verifyId;
  762. $data ['executeId'] = $this->executeId;
  763. $this->render ( "/admin/saea_confirm", $data );
  764. }
  765. function editReceipt() {
  766. // edit status 4
  767. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  768. Doo::loadClass ( 'XDeode' );
  769. $XDeode = new XDeode ( 7 );
  770. $rid = $XDeode->decode ( $ridKey );
  771. if (empty ( $rid )) {
  772. die ( 'illegal request-id' );
  773. }
  774. // echo $rid.'sd';
  775. Doo::loadModel ( 'accountItem' );
  776. Doo::loadModel ( 'verify' );
  777. Doo::loadModel ( 'receipt' );
  778. $receipt = new receipt ();
  779. $verify = new verify ();
  780. $accountItem = new accountItem ();
  781. Doo::loadModel ( 'L_category' );
  782. $lCategory = new L_category ();
  783. Doo::loadModel ( "role" );
  784. $role = new role ();
  785. Doo::loadModel ( 'enclosur' );
  786. $enclosur = new enclosur ();
  787. $receiptDetail = $receipt->getOne ( array (
  788. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  789. 'asArray' => true
  790. ) );
  791. if (empty ( $receiptDetail )) {
  792. die ( 'illegal request-emptyData' );
  793. }
  794. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  795. $acItem = $accountItem->find ( array (
  796. 'asArray' => true
  797. ) );
  798. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  799. // 配置编辑信息
  800. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  801. foreach ( $acItem as $key => $value ) {
  802. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  803. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  804. $acItem [$key] ['price'] = $v ['price'];
  805. }
  806. }
  807. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  808. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  809. $acItem [$key] ['price'] = $v ['price'];
  810. }
  811. }
  812. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  813. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  814. $acItem [$key] ['price'] = $v ['price'];
  815. }
  816. }
  817. // 内训
  818. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  819. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  820. $acItem [$key] ['price'] = $v ['price'];
  821. }
  822. }
  823. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  824. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  825. $acItem [$key] ['price'] = $v ['price'];
  826. }
  827. }
  828. }
  829. //$receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  830. //nl2br($receiptDetail['explanation']);
  831. Doo::loadModel ( 'itinerary' );
  832. $itinerary = new itinerary ();
  833. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  834. $receiptDetail['explanation']= str_replace('<br/>',"\n",$receiptDetail['explanation']);
  835. $receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  836. $data ['category'] = $lCategory->find ( array (
  837. 'asArray' => true
  838. ) );
  839. $data ['cSum'] = $accountItemList ['cSum'];
  840. $data ['sum'] = $receiptDetail ['sum'];
  841. $data ['enclosurList'] = $enclosurList;
  842. $data ['receiptDetail'] = $receiptDetail;
  843. $data ['veList'] = $veList;
  844. $data ['acItem'] = $acItem;
  845. $data ['memu'] = "receipt";
  846. $data ['staff'] = $this->staff;
  847. $data ['receiptMemu'] = 'saeaBorad';
  848. $data ['verify'] = $receiptDetail ['verify'];
  849. $data ['verifyId'] = $this->verifyId;
  850. $data ['executeId'] = $this->executeId;
  851. $data ['rid'] = $ridKey;
  852. if($receiptDetail['receiptClass']==1){
  853. $this->render ( "/receipt/feeAgencyEdi", $data );
  854. }elseif($receiptDetail['receiptClass']==2){
  855. if(!empty($receiptDetail['itinerary2'])){
  856. //TODO 报销说明
  857. $this->render ( "/receipt/feeTravelEdi2", $data );
  858. }else{
  859. $this->render ( "/receipt/feeTravelEdi", $data );
  860. }
  861. }elseif($receiptDetail['receiptClass']==3){
  862. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  863. }else{
  864. $this->render ( "/admin/saea_edit", $data );
  865. //die ( 'illegal request-renderHtml' );
  866. }
  867. }
  868. function updateReceipt() {
  869. $agency = $this->get_args ( 'agency' );
  870. $travel = $this->get_args ( 'travel' );
  871. $train = $this->get_args ( 'train' );
  872. $other = $this->get_args ( 'other' );
  873. $inttrain = $this->get_args ( 'inttrain' );
  874. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  875. $traveVer = $this->get_args ( 'traveVer' ) ? $this->get_args ( 'traveVer' ) : "trave2";
  876. $itinerary = $_POST['itinerary'];
  877. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  878. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  879. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  880. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  881. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  882. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  883. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  884. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  885. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  886. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  887. Doo::loadClass ( 'XDeode' );
  888. $XDeode = new XDeode ( 7 );
  889. $rid = $XDeode->decode ( $ridKey );
  890. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  891. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  892. header ( 'Content-Type:text/html;charset=utf-8' );
  893. die ( '请填写联行号' );
  894. }
  895. if($traveVer!='trave1'){
  896. if($receiptClass=='trave'){
  897. //TODO 日期检测
  898. if($this->_verificationItinerary($itinerary)){
  899. header ( 'Content-Type:text/html;charset=utf-8' );
  900. die ( '已申请过类此日期的行程' );
  901. }
  902. }
  903. }
  904. Doo::loadModel ( 'receipt' );
  905. Doo::loadModel ( 'receiptDetail' );
  906. Doo::loadModel ( 'accountItem' );
  907. $accountItem = new accountItem ();
  908. $receipt = new receipt ();
  909. Doo::loadModel ( 'enclosur' );
  910. Doo::loadModel ( 'execute' );
  911. $execute = new execute ();
  912. $receiptDetail = $receipt->getOne ( array (
  913. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  914. 'asArray' => true
  915. ) );
  916. if (empty ( $receiptDetail )) {
  917. return "/saeaBorad";
  918. }
  919. //TODO 存储行程单-兼容旧版本的行程单
  920. $itinerary=str_replace('\n','<br/>',$itinerary);
  921. if(!empty($receiptDetail['itinerary2'])){
  922. $this->_storageItinerary($itinerary,$rid);
  923. }else{
  924. $this->_storageItinerary($itinerary,$rid,1);
  925. }
  926. if ($receiptDetail ['Rtype'] == 1) {
  927. $executeDetail = $execute->getOne ( array (
  928. 'where' => 'mold="借款费用执行人"',
  929. 'asArray' => true
  930. ) );
  931. } else {
  932. $executeDetail = $execute->getOne ( array (
  933. 'where' => 'mold="报销单执行人"',
  934. 'asArray' => true
  935. ) );
  936. }
  937. $aItem = $accountItem->find ( array (
  938. 'asArray' => true
  939. ) );
  940. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  941. $ag = $tr = $ta = $ot = $it = 0;
  942. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  943. foreach ( $aItem as $key => $value ) {
  944. if ($value ['category'] == $this->AGENCY) {
  945. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  946. array_push ( $accountJson [$this->AGENCY], array (
  947. 'aid' => $value ['aid'],
  948. 'name' => $value ['name'],
  949. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  950. ) );
  951. $sum += $agency [$ag];
  952. $agencySum += $agency [$ag];
  953. }
  954. $ag ++;
  955. }
  956. if ($value ['category'] == $this->TRAVEL) {
  957. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  958. array_push ( $accountJson [$this->TRAVEL], array (
  959. 'aid' => $value ['aid'],
  960. 'name' => $value ['name'],
  961. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  962. ) );
  963. $sum += $travel [$tr];
  964. $travelSum += $travel [$tr];
  965. }
  966. $tr ++;
  967. }
  968. if ($value ['category'] == $this->TRAIN) {
  969. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  970. array_push ( $accountJson [$this->TRAIN], array (
  971. 'aid' => $value ['aid'],
  972. 'name' => $value ['name'],
  973. 'price' => number_format ( $train [$ta], 2, '.', '' )
  974. ) );
  975. $sum += $train [$ta];
  976. $trainSum += $train [$ta];
  977. }
  978. $ta ++;
  979. }
  980. if ($value ['category'] == $this->INTTRAIN) {
  981. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  982. array_push ( $accountJson [$this->INTTRAIN], array (
  983. 'aid' => $value ['aid'],
  984. 'name' => $value ['name'],
  985. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  986. ) );
  987. $sum += $inttrain [$it];
  988. $inttrainSum += $inttrain [$it];
  989. }
  990. $it ++;
  991. }
  992. if ($value ['category'] == $this->OTHER) {
  993. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  994. array_push ( $accountJson [$this->OTHER], array (
  995. 'aid' => $value ['aid'],
  996. 'name' => $value ['name'],
  997. 'price' => number_format ( $other [$ot], 2, '.', '' )
  998. ) );
  999. $sum += $other [$ot];
  1000. $otherSum += $other [$ot];
  1001. }
  1002. $ot ++;
  1003. }
  1004. }
  1005. $accountJson ['cSum'] = array (
  1006. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1007. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1008. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1009. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  1010. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1011. );
  1012. // 报销单
  1013. $rid = $receipt->rid = $receiptDetail ['rid'];
  1014. $receipt->accountItem = json_encode ( $accountJson );
  1015. $receipt->staff = $this->staff [0] ['sid'];
  1016. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1017. $receipt->date = date ( "Y-m-d" );
  1018. $receipt->cid = $cid;
  1019. if (($receiptDetail ['status'] != 4)) {
  1020. if ($receiptDetail ['Rtype'] == 1) {
  1021. $receipt->status = 7;
  1022. } else {
  1023. $receipt->status = 5;
  1024. }
  1025. }
  1026. if ($receiptDetail != 4 && ! empty ( $verify ))
  1027. $receipt->verify = $verify;
  1028. $receipt->executeCopy = $executeDetail ['staff'];
  1029. $order = array (
  1030. "\r\n",
  1031. "\n",
  1032. "\r"
  1033. );
  1034. $replace = '<br/>';
  1035. $explanation = str_replace ( $order, $replace, $explanation );
  1036. $receipt->explanation = $explanation;
  1037. if($receiptClass=='trave'){
  1038. if(!empty($receiptDetail['itinerary2'])){//行程单版本
  1039. $receipt->itinerary2=$itinerary;
  1040. }else{
  1041. $receipt->itinerary=$itinerary;
  1042. }
  1043. }
  1044. $receipt->remittanceName = $remittanceName;
  1045. $receipt->bankName = $bankName;
  1046. $receipt->bankNumber = $bankNumber;
  1047. $receipt->remittanceBankType = $remittanceBankType;
  1048. if ($remittanceBankType == 1)
  1049. $receipt->coupletNumber = $coupletNumber;
  1050. $receipt->update ();
  1051. $receiptDetail = new receiptDetail ();
  1052. $receiptDetail->delete ( array (
  1053. 'where' => 'rid=' . $rid
  1054. ) );
  1055. // 报销详情
  1056. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1057. $receiptDetail = new receiptDetail ();
  1058. $receiptDetail->staff = $this->staff [0] ['sid'];
  1059. $receiptDetail->item = $value ['name'];
  1060. $receiptDetail->itemCategory = $this->AGENCY;
  1061. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1062. $receiptDetail->date = date ( "Y-m-d" );
  1063. $receiptDetail->cid = $cid;
  1064. $receiptDetail->rid = $rid;
  1065. $receiptDetail->status = 4;
  1066. $receiptDetail->insert ();
  1067. }
  1068. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1069. $receiptDetail = new receiptDetail ();
  1070. $receiptDetail->staff = $this->staff [0] ['sid'];
  1071. $receiptDetail->item = $value ['name'];
  1072. $receiptDetail->itemCategory = $this->TRAVEL;
  1073. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1074. $receiptDetail->date = date ( "Y-m-d" );
  1075. $receiptDetail->cid = $cid;
  1076. $receiptDetail->rid = $rid;
  1077. $receiptDetail->status = 4;
  1078. $receiptDetail->insert ();
  1079. }
  1080. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1081. $receiptDetail = new receiptDetail ();
  1082. $receiptDetail->staff = $this->staff [0] ['sid'];
  1083. $receiptDetail->item = $value ['name'];
  1084. $receiptDetail->itemCategory = $this->TRAIN;
  1085. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1086. $receiptDetail->date = date ( "Y-m-d" );
  1087. $receiptDetail->cid = $cid;
  1088. $receiptDetail->rid = $rid;
  1089. $receiptDetail->status = 4;
  1090. $receiptDetail->insert ();
  1091. }
  1092. // 内训
  1093. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1094. $receiptDetail = new receiptDetail ();
  1095. $receiptDetail->staff = $this->staff [0] ['sid'];
  1096. $receiptDetail->item = $value ['name'];
  1097. $receiptDetail->itemCategory = $this->INTTRAIN;
  1098. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1099. $receiptDetail->date = date ( "Y-m-d" );
  1100. $receiptDetail->cid = $cid;
  1101. $receiptDetail->rid = $rid;
  1102. $receiptDetail->status = 4;
  1103. $receiptDetail->insert ();
  1104. }
  1105. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1106. $receiptDetail = new receiptDetail ();
  1107. $receiptDetail->staff = $this->staff [0] ['sid'];
  1108. $receiptDetail->item = $value ['name'];
  1109. $receiptDetail->itemCategory = $this->OTHER;
  1110. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1111. $receiptDetail->date = date ( "Y-m-d" );
  1112. $receiptDetail->cid = $cid;
  1113. $receiptDetail->rid = $rid;
  1114. $receiptDetail->status = 4;
  1115. $receiptDetail->insert ();
  1116. }
  1117. // 附件
  1118. if (! empty ( $enclosurName )) {
  1119. $enclosurArray = explode ( '-', $enclosurName );
  1120. foreach ( $enclosurArray as $value ) {
  1121. $enclosur = new enclosur ();
  1122. $enclosur->name = $value;
  1123. $enclosur->rid = $rid;
  1124. $enclosur->insert ();
  1125. }
  1126. }
  1127. // return "/referReceipt/".$rid;
  1128. }
  1129. return "/saeaBorad";
  1130. }
  1131. function remitAdd() {
  1132. Doo::loadModel ( 'accountItem' );
  1133. Doo::loadModel ( 'verify' );
  1134. Doo::loadModel ( 'receipt' );
  1135. Doo::loadModel ( 'L_category' );
  1136. $lCategory = new L_category ();
  1137. $receipt = new receipt ();
  1138. $verify = new verify ();
  1139. $accountItem = new accountItem ();
  1140. Doo::loadModel ( "role" );
  1141. $role = new role ();
  1142. $acItem = $accountItem->find ( array (
  1143. 'asArray' => true
  1144. ) );
  1145. $veList = $verify->getVerifyBySubordinate('REMIT');
  1146. $data ['category'] = $lCategory->find ( array (
  1147. 'asArray' => true
  1148. ) );
  1149. $data ['veList'] = $veList;
  1150. $data ['acItem'] = $acItem;
  1151. $data ['memu'] = "receipt";
  1152. $data ['staff'] = $this->staff;
  1153. $data ['receiptMemu'] = 'saeaBorad';
  1154. $data ['verifyId'] = $this->verifyId;
  1155. $data ['executeId'] = $this->executeId;
  1156. $this->render ( "/admin/remitAdd", $data );
  1157. }
  1158. function remitAddDo() {
  1159. $agency = $this->get_args ( 'agency' );
  1160. $travel = $this->get_args ( 'travel' );
  1161. $train = $this->get_args ( 'train' );
  1162. $other = $this->get_args ( 'other' );
  1163. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1164. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1165. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1166. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1167. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1168. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1169. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1170. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1171. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1172. // print_r($agency);die;
  1173. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1174. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1175. header ( 'Content-Type:text/html;charset=utf-8' );
  1176. die ( '请填写联行号' );
  1177. }
  1178. Doo::loadModel ( 'receipt' );
  1179. Doo::loadModel ( 'receiptDetail' );
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $receipt = new receipt ();
  1183. Doo::loadModel ( 'enclosur' );
  1184. Doo::loadModel ( 'execute' );
  1185. $execute = new execute ();
  1186. $executeDetail = $execute->getOne ( array (
  1187. 'where' => 'mold="对公汇款执行人"',
  1188. 'asArray' => true
  1189. ) );
  1190. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1191. $aItem = $accountItem->find ( array (
  1192. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1193. 'asArray' => true
  1194. ) );
  1195. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1196. $ag = $tr = $ta = $ot = 0;
  1197. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1198. print_r($aItem);
  1199. foreach ( $aItem as $key => $value ) {
  1200. if ($value ['category'] == $this->AGENCY) {
  1201. if (isset ( $agency [$ag] )) {
  1202. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1203. array_push ( $accountJson [$this->AGENCY], array (
  1204. 'aid' => $value ['aid'],
  1205. 'name' => $value ['name'],
  1206. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1207. ) );
  1208. $sum += $agency [$ag];
  1209. $agencySum += $agency [$ag];
  1210. }
  1211. }
  1212. $ag ++;
  1213. }
  1214. }
  1215. $accountJson ['cSum'] = array (
  1216. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1217. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1218. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1219. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1220. );
  1221. //die;
  1222. // 报销单
  1223. $receipt->accountItem = json_encode ( $accountJson );
  1224. $receipt->staff = $this->staff [0] ['sid'];
  1225. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1226. $receipt->date = date ( "Y-m-d" );
  1227. $receipt->cid = $cid;
  1228. $receipt->status = 5;
  1229. $receipt->Rtype = 2;
  1230. // 修改审批流程加入角色
  1231. $receipt->verify = $verify;
  1232. $receipt->executeCopy = $executeDetail ['staff'];
  1233. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1234. $order = array (
  1235. "\r\n",
  1236. "\n",
  1237. "\r"
  1238. );
  1239. $replace = '<br/>';
  1240. $explanation = str_replace ( $order, $replace, $explanation );
  1241. $receipt->explanation = $explanation;
  1242. $receipt->remittanceName = $remittanceName;
  1243. $receipt->bankName = $bankName;
  1244. $receipt->bankNumber = $bankNumber;
  1245. $receipt->remittanceBankType = $remittanceBankType;
  1246. if ($remittanceBankType == 1)
  1247. $receipt->coupletNumber = $coupletNumber;
  1248. $rid = $receipt->insert ();
  1249. // 附件
  1250. if (! empty ( $enclosurName )) {
  1251. $enclosurArray = explode ( '-', $enclosurName );
  1252. foreach ( $enclosurArray as $value ) {
  1253. $enclosur = new enclosur ();
  1254. $enclosur->name = $value;
  1255. $enclosur->rid = $rid;
  1256. $enclosur->insert ();
  1257. }
  1258. // print_r($enclosurArray);die;
  1259. }
  1260. // 报销详情
  1261. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1262. $receiptDetail = new receiptDetail ();
  1263. $receiptDetail->staff = $this->staff [0] ['sid'];
  1264. $receiptDetail->item = $value ['name'];
  1265. $receiptDetail->itemCategory = $this->AGENCY;
  1266. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1267. $receiptDetail->date = date ( "Y-m-d" );
  1268. $receiptDetail->cid = $cid;
  1269. $receiptDetail->rid = $rid;
  1270. $receiptDetail->status = 4;
  1271. $receiptDetail->insert ();
  1272. }
  1273. return "/saeaBorad";
  1274. } else
  1275. die ( 'illegal request' );
  1276. }
  1277. function remitEdit() {
  1278. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1279. Doo::loadClass ( 'XDeode' );
  1280. $XDeode = new XDeode ( 7 );
  1281. $rid = $XDeode->decode ( $ridKey );
  1282. if (! is_numeric ( $rid ))
  1283. die ( 'illegal request' );
  1284. Doo::loadModel ( 'accountItem' );
  1285. Doo::loadModel ( 'verify' );
  1286. Doo::loadModel ( 'receipt' );
  1287. $receipt = new receipt ();
  1288. $verify = new verify ();
  1289. $accountItem = new accountItem ();
  1290. Doo::loadModel ( 'L_category' );
  1291. $lCategory = new L_category ();
  1292. Doo::loadModel ( "role" );
  1293. $role = new role ();
  1294. Doo::loadModel ( 'enclosur' );
  1295. $enclosur = new enclosur ();
  1296. $receiptDetail = $receipt->getOne ( array (
  1297. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1298. 'asArray' => true
  1299. ) );
  1300. if (empty ( $receiptDetail ))
  1301. return "/saeaCreate";
  1302. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1303. $acItem = $accountItem->find ( array (
  1304. 'asArray' => true
  1305. ) );
  1306. $veList = $verify->getVerifyBySubordinate('REMIT');
  1307. // 配置编辑信息
  1308. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1309. foreach ( $acItem as $key => $value ) {
  1310. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1311. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1312. $acItem [$key] ['price'] = $v ['price'];
  1313. }
  1314. }
  1315. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1316. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1317. $acItem [$key] ['price'] = $v ['price'];
  1318. }
  1319. }
  1320. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1321. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1322. $acItem [$key] ['price'] = $v ['price'];
  1323. }
  1324. }
  1325. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1326. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1327. $acItem [$key] ['price'] = $v ['price'];
  1328. }
  1329. }
  1330. }
  1331. $data ['category'] = $lCategory->find ( array (
  1332. 'asArray' => true
  1333. ) );
  1334. $data ['enclosurList'] = $enclosurList;
  1335. $data ['cSum'] = $accountItemList ['cSum'];
  1336. $data ['sum'] = $receiptDetail ['sum'];
  1337. $data ['receiptDetail'] = $receiptDetail;
  1338. $data ['veList'] = $veList;
  1339. $data ['acItem'] = $acItem;
  1340. $data ['memu'] = "receipt";
  1341. $data ['staff'] = $this->staff;
  1342. $data ['receiptMemu'] = 'saeaBorad';
  1343. $data ['verify'] = $receiptDetail ['verify'];
  1344. $data ['verifyId'] = $this->verifyId;
  1345. $data ['executeId'] = $this->executeId;
  1346. $data ['rid'] = $rid;
  1347. $data ['ridKey'] = $ridKey;
  1348. $this->render ( "/admin/remitEdit", $data );
  1349. }
  1350. function remitEdiDo() {
  1351. $agency = $this->get_args ( 'agency' );
  1352. $travel = $this->get_args ( 'travel' );
  1353. $train = $this->get_args ( 'train' );
  1354. $other = $this->get_args ( 'other' );
  1355. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1356. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1357. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1358. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1359. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1360. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1361. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1362. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1363. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1364. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1365. Doo::loadClass ( 'XDeode' );
  1366. $XDeode = new XDeode ( 7 );
  1367. $rid = $XDeode->decode ( $ridKey );
  1368. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1369. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1370. header ( 'Content-Type:text/html;charset=utf-8' );
  1371. die ( '请填写联行号' );
  1372. }
  1373. Doo::loadModel ( 'receipt' );
  1374. Doo::loadModel ( 'receiptDetail' );
  1375. Doo::loadModel ( 'accountItem' );
  1376. $accountItem = new accountItem ();
  1377. $receipt = new receipt ();
  1378. Doo::loadModel ( 'enclosur' );
  1379. $enclosur = new enclosur ();
  1380. Doo::loadModel ( 'execute' );
  1381. $execute = new execute ();
  1382. $executeDetail = $execute->getOne ( array (
  1383. 'where' => 'mold="对公汇款执行人"',
  1384. 'asArray' => true
  1385. ) );
  1386. $receiptDetail = $receipt->getOne ( array (
  1387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1388. 'asArray' => true
  1389. ) );
  1390. if (empty ( $receiptDetail ))
  1391. return "/saeaBorad";
  1392. $aItem = $accountItem->find ( array (
  1393. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1394. 'asArray' => true
  1395. ) );
  1396. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1397. $ag = $tr = $ta = $ot = 0;
  1398. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1399. foreach ( $aItem as $key => $value ) {
  1400. if ($value ['category'] == $this->AGENCY) {
  1401. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1402. array_push ( $accountJson [$this->AGENCY], array (
  1403. 'aid' => $value ['aid'],
  1404. 'name' => $value ['name'],
  1405. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1406. ) );
  1407. $sum += $agency [$ag];
  1408. $agencySum += $agency [$ag];
  1409. }
  1410. $ag ++;
  1411. }
  1412. }
  1413. $accountJson ['cSum'] = array (
  1414. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1415. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1416. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1417. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1418. );
  1419. // 报销单
  1420. $rid = $receipt->rid = $receiptDetail ['rid'];
  1421. $receipt->accountItem = json_encode ( $accountJson );
  1422. $receipt->staff = $this->staff [0] ['sid'];
  1423. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1424. $receipt->date = date ( "Y-m-d" );
  1425. $receipt->cid = $cid;
  1426. if ($receiptDetail ['Rtype'] == 1)
  1427. $receipt->status = 7;
  1428. else
  1429. $receipt->status = 5;
  1430. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1431. $receipt->verify = $verify;
  1432. $receipt->executeCopy = $executeDetail ['staff'];
  1433. $order = array (
  1434. "\r\n",
  1435. "\n",
  1436. "\r"
  1437. );
  1438. $replace = '<br/>';
  1439. $explanation = str_replace ( $order, $replace, $explanation );
  1440. $receipt->explanation = $explanation;
  1441. $receipt->remittanceName = $remittanceName;
  1442. $receipt->bankName = $bankName;
  1443. $receipt->bankNumber = $bankNumber;
  1444. $receipt->remittanceBankType = $remittanceBankType;
  1445. if ($remittanceBankType == 1)
  1446. $receipt->coupletNumber = $coupletNumber;
  1447. $receipt->update ();
  1448. $receiptDetail = new receiptDetail ();
  1449. $receiptDetail->delete ( array (
  1450. 'where' => 'rid=' . $rid
  1451. ) );
  1452. // 报销详情
  1453. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1454. $receiptDetail = new receiptDetail ();
  1455. $receiptDetail->staff = $this->staff [0] ['sid'];
  1456. $receiptDetail->item = $value ['name'];
  1457. $receiptDetail->itemCategory = $this->AGENCY;
  1458. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1459. $receiptDetail->date = date ( "Y-m-d" );
  1460. $receiptDetail->cid = $cid;
  1461. $receiptDetail->rid = $rid;
  1462. $receiptDetail->status = 4;
  1463. $receiptDetail->insert ();
  1464. }
  1465. // 附件
  1466. if (! empty ( $enclosurName )) {
  1467. $enclosurArray = explode ( '-', $enclosurName );
  1468. foreach ( $enclosurArray as $value ) {
  1469. $enclosur = new enclosur ();
  1470. $enclosur->name = $value;
  1471. $enclosur->rid = $rid;
  1472. $enclosur->insert ();
  1473. }
  1474. }
  1475. }
  1476. return "/saeaBorad";
  1477. }
  1478. function remitApproval() {
  1479. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1480. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1482. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1483. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1484. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1485. if (empty ( $status ))
  1486. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1487. $vidList = array ();
  1488. $button = 0;
  1489. Doo::loadModel ( 'verify' );
  1490. Doo::loadModel ( 'receipt' );
  1491. Doo::loadModel ( 'staff' );
  1492. $staff = new staff ();
  1493. $receipt = new receipt ();
  1494. $verify = new verify ();
  1495. Doo::loadModel ( 'L_category' );
  1496. $Lcategory = new L_category ();
  1497. Doo::loadModel ( 'enclosur' );
  1498. $enclosur = new enclosur ();
  1499. // user verify ID
  1500. $verifyDetail = $verify->find ( array (
  1501. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1502. 'asArray' => true
  1503. ) );
  1504. foreach ( $verifyDetail as $key => $value ) {
  1505. array_push ( $vidList, $value ['vid'] );
  1506. }
  1507. $vid = implode ( ",", $vidList );
  1508. if (empty ( $verifyDetail ))
  1509. $vid = 0;
  1510. $categoryList = $Lcategory->find ( array (
  1511. 'asArray' => true
  1512. ) );
  1513. $staffList = $staff->find ( array (
  1514. 'where' => 'cid=' . $cid,
  1515. 'asArray' => true
  1516. ) );
  1517. $ap = "";
  1518. if ($status == 4) {
  1519. $ap = 4;
  1520. $status = 2;
  1521. }
  1522. // get Receipt By verifyID status 2
  1523. $receiptList = $receipt->find ( array (
  1524. 'where' => 'rid =' . $rid . ' and status=2',
  1525. 'desc' => 'rid',
  1526. 'asArray' => true
  1527. ) );
  1528. if (empty ( $receiptList )) {
  1529. die ( 'illegal request' );
  1530. }
  1531. $Locate = 0;
  1532. $roleId = 0;
  1533. if ($ap == 4)
  1534. $status = 4;
  1535. foreach ( $receiptList as $key => $value ) {
  1536. $receiptList [$key] ['Locate'] = $Locate;
  1537. $Locate ++;
  1538. $receiptList [$key] ['reviseDetail'] = array ();
  1539. if (! empty ( $value ['reviseDetail'] ))
  1540. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1541. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1542. $categoryDetil = $Lcategory->getOne ( array (
  1543. 'where' => 'cid=' . $value ['cid'],
  1544. 'asArray' => true
  1545. ) );
  1546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1547. // 检测编辑状态
  1548. $verifyList = $verify->getOne ( array (
  1549. 'where' => 'vid=' . $value ['verify'],
  1550. 'asArray' => true
  1551. ) );
  1552. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1553. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1554. Doo::loadModel ( 'role' );
  1555. $role = new role ();
  1556. // print_r($verifyList);
  1557. $flag = true;
  1558. $roleKey = 0;
  1559. $endStaffArray = array ();
  1560. $roleArrayCopy = array ();
  1561. foreach ( $verifyList as $k => $v ) {
  1562. // init verifyStaff
  1563. if ($v [1] == 'ROLE') {
  1564. if (! empty ( $verifyStaff )) {
  1565. $endStaffArray = end ( $verifyStaff );
  1566. if ($v [0] == $endStaffArray ['nextStaff']) {
  1567. $roleId = $v [0];
  1568. }
  1569. }
  1570. $roleVerify = json_decode ( $v [3], true );
  1571. $roleKey = $k;
  1572. $roleArray = array ();
  1573. $rolename = $role->getOne ( array (
  1574. 'where' => 'rid=' . $v [0],
  1575. 'asArray' => true
  1576. ) );
  1577. foreach ( $roleVerify as $o => $p ) {
  1578. $staffID = explode ( '_', $p );
  1579. $staffInfo = $staff->getOne ( array (
  1580. 'where' => 'sid=' . $staffID [0],
  1581. 'asArray' => true
  1582. ) );
  1583. // print_r($staffID);
  1584. $exp = array (
  1585. 0 => $staffInfo ['sid'],
  1586. 1 => $staffID [1],
  1587. 2 => $staffInfo ['avatar'],
  1588. 'date' => '',
  1589. 'date' => '',
  1590. 'opinion' => '',
  1591. 'status' => '',
  1592. 'rolename' => $rolename ['name']
  1593. );
  1594. array_push ( $roleArray, $exp );
  1595. }
  1596. $roleArrayCopy [$v [0]] = $roleArray;
  1597. // $verifyList[$k]['roleArray']=$roleArray;
  1598. }
  1599. // print_r($roleArray);
  1600. $verifyList [$k] ['date'] = "";
  1601. $verifyList [$k] ['opinion'] = "";
  1602. $verifyList [$k] ['status'] = "";
  1603. if (empty ( $verifyStaff )) {
  1604. $verifyList [$k] ['date'] = "";
  1605. $verifyList [$k] ['opinion'] = "";
  1606. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1607. $verifyList [$k] ['status'] = 4;
  1608. $button = 4;
  1609. $flag = false;
  1610. }
  1611. } else {
  1612. foreach ( $verifyStaff as $m => $u ) {
  1613. if ($v [0] == $m) {
  1614. $verifyList [$k] ['date'] = $u ['date'];
  1615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1616. $verifyList [$k] ['status'] = $u ['status'];
  1617. $flag = false;
  1618. break;
  1619. }
  1620. }
  1621. $endStaffArray = end ( $verifyStaff );
  1622. if (isset ( $endStaffArray ['ROLE'] )) {
  1623. } else {
  1624. $endKey = key ( $verifyStaff );
  1625. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1626. $button = 4;
  1627. $verifyList [$k] ['status'] = 4;
  1628. }
  1629. }
  1630. }
  1631. }
  1632. $rolename ['name'] = '';
  1633. if (! empty ( $roleId )) {
  1634. Doo::loadModel ( 'role' );
  1635. $role = new role ();
  1636. $rolename = $role->getOne ( array (
  1637. 'where' => 'rid=' . $roleId,
  1638. 'asArray' => true
  1639. ) );
  1640. }
  1641. if (! empty ( $verifyStaff ))
  1642. $endStaffArray = end ( $verifyStaff );
  1643. $KOP = false;
  1644. foreach ( $roleArrayCopy as $P => $A ) {
  1645. foreach ( $A as $MKI => $AVL ) {
  1646. if (! empty ( $verifyStaff )) {
  1647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1649. $button = 4;
  1650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1651. }
  1652. foreach ( $verifyStaff as $m => $u ) {
  1653. $AVLFK = $AVL [0] . '_R';
  1654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1659. break;
  1660. }
  1661. }
  1662. } else {
  1663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1664. $button = 4;
  1665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1666. }
  1667. }
  1668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1669. $KOP = true;
  1670. }
  1671. }
  1672. foreach ( $roleArrayCopy as $k => $v ) {
  1673. foreach ( $verifyList as $m => $n ) {
  1674. if ($n [0] == $k) {
  1675. array_splice ( $verifyList, $m, 1, $v );
  1676. }
  1677. }
  1678. }
  1679. $receiptList [$key] ['verifyList'] = $verifyList;
  1680. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1681. 'where' => 'sid=' . $value ['staff'],
  1682. 'asArray' => true
  1683. ) );
  1684. $receiptList [$key] ['button'] = $button;
  1685. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1686. }
  1687. $mothHtml = "";
  1688. for($i = 1; $i <= 12; $i ++) {
  1689. if ($month == $i)
  1690. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1691. else
  1692. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1693. }
  1694. // 获取审批日志
  1695. Doo::loadModel ( 'receiptLog' );
  1696. $receiptLog = new receiptLog ();
  1697. $rlList = array ();
  1698. $rlInfo = $receiptLog->getOne ( array (
  1699. 'where' => 'rid=' . $rid . ' and status=4',
  1700. 'asArray' => true
  1701. ) );
  1702. $tijdate = $receiptLog->getOne ( array (
  1703. 'where' => 'rid=' . $rid . ' and status=2',
  1704. 'asc' => 'rlid',
  1705. 'asArray' => true
  1706. ) );
  1707. if (! empty ( $rlInfo )) {
  1708. $rlList = $receiptLog->find ( array (
  1709. 'where' => 'rid=' . $rid,
  1710. 'asc' => 'rlid',
  1711. 'asArray' => true
  1712. ) );
  1713. }
  1714. $receiptList [0] ['rlList'] = $rlList;
  1715. $enclosurList = $enclosur->find ( array (
  1716. 'where' => 'rid=' . $rid,
  1717. 'asArray' => true
  1718. ) );
  1719. $enclosurHtml = '';
  1720. foreach ( $enclosurList as $value ) {
  1721. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1722. }
  1723. // print_r($receiptList);
  1724. $data ['enclosurHtml'] = $enclosurHtml;
  1725. $data ['rolename'] = $rolename ['name'];
  1726. $data ['datetij'] = $tijdate ['date'];
  1727. $data ['mothHtml'] = $mothHtml;
  1728. $data ['rid'] = $rid;
  1729. $data ['receiptList'] = $receiptList;
  1730. $data ['receiptApprovalCount'] = count ( $receiptList );
  1731. $data ['status'] = $status;
  1732. $data ['year'] = $year;
  1733. $data ['categoryList'] = $categoryList;
  1734. $data ['staffList'] = $staffList;
  1735. $data ['cid'] = $cid;
  1736. $data ['sid'] = $sid;
  1737. $data ['ap'] = $ap;
  1738. $data ['memu'] = "receipt";
  1739. $data ['staff'] = $this->staff;
  1740. $data ['receiptMemu'] = 'approvalExpenses';
  1741. $data ['verifyId'] = $this->verifyId;
  1742. $data ['executeId'] = $this->executeId;
  1743. $this->render ( "/admin/remitApproval", $data );
  1744. }
  1745. function saeaLoanAdd() {
  1746. Doo::loadModel ( 'verify' );
  1747. $verify = new verify ();
  1748. Doo::loadModel ( "role" );
  1749. $role = new role ();
  1750. Doo::loadModel ( 'L_category' );
  1751. $lCategory = new L_category ();
  1752. $veList = $verify->getVerifyBySubordinate('LOAN');
  1753. $data ['category'] = $lCategory->find ( array (
  1754. 'asArray' => true
  1755. ) );
  1756. $data ['veList'] = $veList;
  1757. $data ['memu'] = "receipt";
  1758. $data ['staff'] = $this->staff;
  1759. $data ['receiptMemu'] = 'saeaBorad';
  1760. $data ['verifyId'] = $this->verifyId;
  1761. $data ['executeId'] = $this->executeId;
  1762. $this->render ( "/admin/saeaLoanAdd", $data );
  1763. }
  1764. function saeaLoanAddDo() {
  1765. $agency = $this->get_args ( 'agency' );
  1766. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1767. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1768. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1769. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1770. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1771. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1772. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1773. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1774. // die;
  1775. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1776. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1777. header ( 'Content-Type:text/html;charset=utf-8' );
  1778. die ( '请填写联行号' );
  1779. }
  1780. Doo::loadModel ( 'receipt' );
  1781. Doo::loadModel ( 'receiptDetail' );
  1782. Doo::loadModel ( 'accountItem' );
  1783. $accountItem = new accountItem ();
  1784. $receipt = new receipt ();
  1785. Doo::loadModel ( 'loanReceipt' );
  1786. $loanReceipt = new loanReceipt ();
  1787. Doo::loadModel ( 'execute' );
  1788. $execute = new execute ();
  1789. Doo::loadModel ( 'enclosur' );
  1790. $executeDetail = $execute->getOne ( array (
  1791. 'where' => 'mold="借款执行人"',
  1792. 'asArray' => true
  1793. ) );
  1794. $aItem = $accountItem->find ( array (
  1795. 'asArray' => true
  1796. ) );
  1797. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1798. $ag = $tr = $ta = $ot = 0;
  1799. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1800. array_push ( $accountJson ['借款费用'], array (
  1801. 'aid' => 0,
  1802. 'name' => '申请金额',
  1803. 'price' => number_format ( $agency, 2, '.', '' )
  1804. ) );
  1805. $sum += $agency;
  1806. $agencySum += $agency;
  1807. $accountJson ['cSum'] = array (
  1808. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1809. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1810. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1811. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1812. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1813. );
  1814. // 借款数据备份
  1815. $loanReceipt->loanItem = json_encode ( $accountJson );
  1816. $loanReceipt->staff = $this->staff [0] ['sid'];
  1817. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1818. $loanReceipt->date = date ( "Y-m-d" );
  1819. $loanReceipt->cid = $cid;
  1820. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1821. $loanReceipt->status = 5;
  1822. $loanReceipt->Rtype = 1;
  1823. $loanReceipt->verify = $verify;
  1824. $receipt->receiptOrder = $receipt->receiptOrder;
  1825. // 添加HTML换行符
  1826. // var_dump($explanation);
  1827. $order = array (
  1828. "\r\n",
  1829. "\n",
  1830. "\r"
  1831. );
  1832. $replace = '<br/>';
  1833. $explanation = str_replace ( $order, $replace, $explanation );
  1834. // $explanation=str_replace('\r',"<br/>",$explanation);
  1835. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1836. $loanReceipt->explanation = $explanation;
  1837. $loanRid = $loanReceipt->insert ();
  1838. // 报销单
  1839. $receipt->loanItem = json_encode ( $accountJson );
  1840. $receipt->staff = $this->staff [0] ['sid'];
  1841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1842. $receipt->date = date ( "Y-m-d" );
  1843. $receipt->cid = $cid;
  1844. // 特殊状态
  1845. $receipt->status = 5;
  1846. $receipt->Rtype = 1;
  1847. $receipt->loanRid = $loanRid;
  1848. // 修改审批流程加入角色
  1849. $receipt->verify = $verify;
  1850. $receipt->executeCopy = $executeDetail ['staff'];
  1851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1852. $receipt->explanation = $explanation;
  1853. $receipt->remittanceName = $remittanceName;
  1854. $receipt->bankName = $bankName;
  1855. $receipt->bankNumber = $bankNumber;
  1856. $receipt->remittanceBankType = $remittanceBankType;
  1857. if ($remittanceBankType == 1)
  1858. $receipt->coupletNumber = $coupletNumber;
  1859. $rid = $receipt->insert ();
  1860. return "/saeaBorad";
  1861. } else
  1862. die ( 'illegal request' );
  1863. }
  1864. function saeaLoanEdi() {
  1865. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1866. Doo::loadClass ( 'XDeode' );
  1867. $XDeode = new XDeode ( 7 );
  1868. $rid = $XDeode->decode ( $ridKey );
  1869. if (! is_numeric ( $rid ))
  1870. die ( 'illegal request' );
  1871. Doo::loadModel ( 'verify' );
  1872. $verify = new verify ();
  1873. Doo::loadModel ( "role" );
  1874. $role = new role ();
  1875. Doo::loadModel ( 'L_category' );
  1876. $lCategory = new L_category ();
  1877. Doo::loadModel ( 'receipt' );
  1878. $receipt = new receipt ();
  1879. $receiptInfo = $receipt->getOne ( array (
  1880. 'where' => 'rid=' . $rid,
  1881. 'asArray' => true
  1882. ) );
  1883. $veList = $verify->find ( array (
  1884. 'where'=>'subordinate like "%LOAN%"',
  1885. 'asArray' => true
  1886. ) );
  1887. foreach ( $veList as $key => $value ) {
  1888. $v = json_decode ( $value ['staff'] );
  1889. $list = array ();
  1890. foreach ( $v as $n => $m ) {
  1891. if ($m ['1'] == 'ROLE') {
  1892. $roleInfo = $role->getOne ( array (
  1893. 'where' => 'rid=' . $m [0],
  1894. 'asArray' => true
  1895. ) );
  1896. $v [$n] [1] = $roleInfo ['name'];
  1897. array_push ( $list, $roleInfo ['name'] );
  1898. } else {
  1899. array_push ( $list, $v [$n] [1] );
  1900. }
  1901. }
  1902. $veList [$key] ['staff'] = implode ( '>', $list );
  1903. }
  1904. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1905. // print_r($receiptInfo);
  1906. $data ['receiptInfo'] = $receiptInfo;
  1907. $data ['category'] = $lCategory->find ( array (
  1908. 'asArray' => true
  1909. ) );
  1910. $data ['veList'] = $veList;
  1911. $data ['ridKey'] = $ridKey;
  1912. $data ['memu'] = "receipt";
  1913. $data ['staff'] = $this->staff;
  1914. $data ['receiptMemu'] = 'saeaBorad';
  1915. $data ['verifyId'] = $this->verifyId;
  1916. $data ['executeId'] = $this->executeId;
  1917. $this->render ( "/admin/saeaLoanEdi", $data );
  1918. }
  1919. function saeaLoanEdiDo() {
  1920. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1921. $agency = $this->get_args ( 'agency' );
  1922. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1923. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1924. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1925. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1926. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1927. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1928. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1929. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1930. // die;
  1931. Doo::loadClass ( 'XDeode' );
  1932. $XDeode = new XDeode ( 7 );
  1933. $rid = $XDeode->decode ( $ridKey );
  1934. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1935. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1936. header ( 'Content-Type:text/html;charset=utf-8' );
  1937. die ( '请填写联行号' );
  1938. }
  1939. Doo::loadModel ( 'receipt' );
  1940. Doo::loadModel ( 'receiptDetail' );
  1941. Doo::loadModel ( 'accountItem' );
  1942. $accountItem = new accountItem ();
  1943. $receipt = new receipt ();
  1944. Doo::loadModel ( 'loanReceipt' );
  1945. $loanReceipt = new loanReceipt ();
  1946. Doo::loadModel ( 'enclosur' );
  1947. Doo::loadModel ( 'execute' );
  1948. $execute = new execute ();
  1949. $executeDetail = $execute->getOne ( array (
  1950. 'where' => 'mold="借款执行人"',
  1951. 'asArray' => true
  1952. ) );
  1953. $receiptDetail = $receipt->getOne ( array (
  1954. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1955. 'asArray' => true
  1956. ) );
  1957. if (empty ( $receiptDetail ))
  1958. die ( '参数错误' );
  1959. $aItem = $accountItem->find ( array (
  1960. 'asArray' => true
  1961. ) );
  1962. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1963. $ag = $tr = $ta = $ot = 0;
  1964. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1965. array_push ( $accountJson ['借款费用'], array (
  1966. 'aid' => 0,
  1967. 'name' => '申请金额',
  1968. 'price' => number_format ( $agency, 2, '.', '' )
  1969. ) );
  1970. $sum += $agency;
  1971. $agencySum += $agency;
  1972. $accountJson ['cSum'] = array (
  1973. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1974. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1975. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1976. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1977. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1978. );
  1979. // 报销单
  1980. $receipt->loanItem = json_encode ( $accountJson );
  1981. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1982. $receipt->cid = $cid;
  1983. // 特殊状态
  1984. // 修改审批流程加入角色
  1985. if ($receiptDetail ['status'] != 4)
  1986. $receipt->verify = $verify;
  1987. $order = array (
  1988. "\r\n",
  1989. "\n",
  1990. "\r"
  1991. );
  1992. $replace = '<br/>';
  1993. $explanation = str_replace ( $order, $replace, $explanation );
  1994. $receipt->explanation = $explanation;
  1995. $receipt->remittanceName = $remittanceName;
  1996. $receipt->bankName = $bankName;
  1997. $receipt->bankNumber = $bankNumber;
  1998. $receipt->remittanceBankType = $remittanceBankType;
  1999. if ($remittanceBankType == 1)
  2000. $receipt->coupletNumber = $coupletNumber;
  2001. $receipt->update ( array (
  2002. 'where' => 'rid=' . $rid
  2003. ) );
  2004. // 借款数据更新
  2005. $loanReceipt->loanItem = json_encode ( $accountJson );
  2006. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  2007. $loanReceipt->cid = $cid;
  2008. if ($receiptDetail ['status'] != 4)
  2009. $loanReceipt->verify = $verify;
  2010. $loanReceipt->explanation = $explanation;
  2011. $receipt->executeCopy = $executeDetail ['staff'];
  2012. $loanReceipt->update ( array (
  2013. 'where' => 'rid=' . $receiptDetail ['loanRid']
  2014. ) );
  2015. }
  2016. return "/saeaBorad";
  2017. }
  2018. function saeaLoanReceiptAdd() {
  2019. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2020. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2021. Doo::loadModel ( 'receipt' );
  2022. $receipt = new receipt ();
  2023. Doo::loadModel ( 'loanReceipt' );
  2024. $loanReceipt = new loanReceipt ();
  2025. Doo::loadModel ( 'L_category' );
  2026. $Lcategory = new L_category ();
  2027. Doo::loadModel ( 'verify' );
  2028. Doo::loadModel ( 'statistics' );
  2029. $statistics = new statistics ();
  2030. $verify = new verify ();
  2031. Doo::loadModel ( 'staff' );
  2032. $staff = new staff ();
  2033. $receiptDetail = $receipt->getOne ( array (
  2034. 'where' => 'rid=' . $rid,
  2035. 'desc' => 'rid',
  2036. 'asArray' => true
  2037. ) );
  2038. $receiptList = $loanReceipt->find ( array (
  2039. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2040. 'desc' => 'rid',
  2041. 'asArray' => true
  2042. ) );
  2043. $Locate = 0;
  2044. $roleId = 0;
  2045. $button = 0;
  2046. foreach ( $receiptList as $key => $value ) {
  2047. $receiptList [$key] ['Locate'] = $Locate;
  2048. $Locate ++;
  2049. $receiptList [$key] ['reviseDetail'] = array ();
  2050. if (! empty ( $value ['reviseDetail'] ))
  2051. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2052. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2053. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2054. $categoryDetil = $Lcategory->getOne ( array (
  2055. 'where' => 'cid=' . $value ['cid'],
  2056. 'asArray' => true
  2057. ) );
  2058. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2059. // 检测编辑状态
  2060. $verifyList = $verify->getOne ( array (
  2061. 'where' => 'vid=' . $value ['verify'],
  2062. 'asArray' => true
  2063. ) );
  2064. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2065. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2066. Doo::loadModel ( 'role' );
  2067. $role = new role ();
  2068. $flag = true;
  2069. $roleKey = 0;
  2070. $endStaffArray = array ();
  2071. $roleArrayCopy = array ();
  2072. foreach ( $verifyList as $k => $v ) {
  2073. // init verifyStaff
  2074. if ($v [1] == 'ROLE') {
  2075. if (! empty ( $verifyStaff )) {
  2076. $endStaffArray = end ( $verifyStaff );
  2077. // if ($v[0]==$endStaffArray['nextStaff']){
  2078. // $roleId=$v[0];
  2079. // }
  2080. }
  2081. $roleVerify = json_decode ( $v [3], true );
  2082. $roleKey = $k;
  2083. $roleArray = array ();
  2084. $rolename = $role->getOne ( array (
  2085. 'where' => 'rid=' . $v [0],
  2086. 'asArray' => true
  2087. ) );
  2088. foreach ( $roleVerify as $o => $p ) {
  2089. $staffID = explode ( '_', $p );
  2090. $staffInfo = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $staffID [0],
  2092. 'asArray' => true
  2093. ) );
  2094. // print_r($staffID);
  2095. $exp = array (
  2096. 0 => $staffInfo ['sid'],
  2097. 1 => $staffID [1],
  2098. 2 => $staffInfo ['avatar'],
  2099. 'date' => '',
  2100. 'date' => '',
  2101. 'opinion' => '',
  2102. 'status' => '',
  2103. 'rolename' => $rolename ['name']
  2104. );
  2105. array_push ( $roleArray, $exp );
  2106. }
  2107. $roleArrayCopy [$v [0]] = $roleArray;
  2108. // $verifyList[$k]['roleArray']=$roleArray;
  2109. }
  2110. $verifyList [$k] ['date'] = "";
  2111. $verifyList [$k] ['opinion'] = "";
  2112. $verifyList [$k] ['status'] = "";
  2113. if (empty ( $verifyStaff )) {
  2114. $verifyList [$k] ['date'] = "";
  2115. $verifyList [$k] ['opinion'] = "";
  2116. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2117. $verifyList [$k] ['status'] = 4;
  2118. $flag = false;
  2119. }
  2120. } else {
  2121. foreach ( $verifyStaff as $m => $u ) {
  2122. if ($v [0] == $m) {
  2123. $verifyList [$k] ['date'] = $u ['date'];
  2124. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2125. $verifyList [$k] ['status'] = $u ['status'];
  2126. $flag = false;
  2127. break;
  2128. }
  2129. }
  2130. $endStaffArray = end ( $verifyStaff );
  2131. if (isset ( $endStaffArray ['ROLE'] )) {
  2132. } else {
  2133. // $endKey=key($verifyStaff);
  2134. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2135. // $button=4;
  2136. // $verifyList[$k]['status']=4;
  2137. // }
  2138. }
  2139. }
  2140. }
  2141. $rolename ['name'] = '';
  2142. if (! empty ( $roleId )) {
  2143. Doo::loadModel ( 'role' );
  2144. $role = new role ();
  2145. $rolename = $role->getOne ( array (
  2146. 'where' => 'rid=' . $roleId,
  2147. 'asArray' => true
  2148. ) );
  2149. }
  2150. if (! empty ( $verifyStaff ))
  2151. $endStaffArray = end ( $verifyStaff );
  2152. $KOP = false;
  2153. foreach ( $roleArrayCopy as $P => $A ) {
  2154. foreach ( $A as $MKI => $AVL ) {
  2155. if (! empty ( $verifyStaff )) {
  2156. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2157. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2158. $button = 4;
  2159. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2160. }
  2161. foreach ( $verifyStaff as $m => $u ) {
  2162. $AVLFK = $AVL [0] . '_R';
  2163. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2164. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2165. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2166. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2167. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2168. break;
  2169. }
  2170. }
  2171. } else {
  2172. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2173. $button = 4;
  2174. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2175. }
  2176. }
  2177. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2178. $KOP = true;
  2179. }
  2180. }
  2181. foreach ( $roleArrayCopy as $k => $v ) {
  2182. foreach ( $verifyList as $m => $n ) {
  2183. if ($n [0] == $k) {
  2184. array_splice ( $verifyList, $m, 1, $v );
  2185. }
  2186. }
  2187. }
  2188. $receiptList [$key] ['verifyList'] = $verifyList;
  2189. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2190. 'where' => 'sid=' . $value ['staff'],
  2191. 'asArray' => true
  2192. ) );
  2193. $receiptList [$key] ['button'] = $button;
  2194. //
  2195. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2196. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2197. }
  2198. $data ['receiptList'] = $receiptList;
  2199. $data ['receiptDetail'] = $receiptDetail;
  2200. Doo::loadModel ( 'L_category' );
  2201. $lCategory = new L_category ();
  2202. Doo::loadModel ( 'accountItem' );
  2203. $accountItem = new accountItem ();
  2204. $acItem = $accountItem->find ( array (
  2205. 'asArray' => true
  2206. ) );
  2207. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2208. $data ['rid'] = $rid;
  2209. $data ['category'] = $lCategory->find ( array (
  2210. 'asArray' => true
  2211. ) );
  2212. $data ['veList'] = $veList;
  2213. $data ['acItem'] = $acItem;
  2214. $data['itineraryDate']=$this->_itineraryDateMin();
  2215. $data ['memu'] = "receipt";
  2216. $data ['staff'] = $this->staff;
  2217. $data ['receiptMemu'] = 'saeaBorad';
  2218. $data ['verifyId'] = $this->verifyId;
  2219. $data ['executeId'] = $this->executeId;
  2220. $data['receiptClass']=$receiptClass;
  2221. if($receiptClass=='trave'){
  2222. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2223. }else{
  2224. $this->render ( "/receipt/feeLoanReceipt", $data );
  2225. }
  2226. }
  2227. function saeaLoanReceiptAddDo() {
  2228. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2229. $agency = $this->get_args ( 'agency' );
  2230. $travel = $this->get_args ( 'travel' );
  2231. $train = $this->get_args ( 'train' );
  2232. $other = $this->get_args ( 'other' );
  2233. $inttrain = $this->get_args ( 'inttrain' );
  2234. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2235. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2236. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2237. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2238. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2239. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2240. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2241. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2242. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2243. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2244. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2245. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2246. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2247. header ( 'Content-Type:text/html;charset=utf-8' );
  2248. die ( '请填写联行号' );
  2249. }
  2250. if($receiptClass=='agency'){
  2251. $receiptClass=1;
  2252. }elseif($receiptClass=='trave'){
  2253. $receiptClass=2;
  2254. if($this->_verificationItinerary($itinerary)){
  2255. header ( 'Content-Type:text/html;charset=utf-8' );
  2256. die ( '已申请过类此日期的行程' );
  2257. }
  2258. }elseif($receiptClass=='internalTrain'){
  2259. $receiptClass=3;
  2260. }else{
  2261. header ( 'Content-Type:text/html;charset=utf-8' );
  2262. die ( '借款报销单分类不正确' );
  2263. }
  2264. Doo::loadModel ( 'receipt' );
  2265. Doo::loadModel ( 'receiptDetail' );
  2266. Doo::loadModel ( 'accountItem' );
  2267. $accountItem = new accountItem ();
  2268. $receipt = new receipt ();
  2269. Doo::loadModel ( 'enclosur' );
  2270. Doo::loadModel ( 'execute' );
  2271. $execute = new execute ();
  2272. $executeDetail = $execute->getOne ( array (
  2273. 'where' => 'mold="借款费用执行人"',
  2274. 'asArray' => true
  2275. ) );
  2276. $receiptDet = $receipt->getOne ( array (
  2277. 'where' => 'rid=' . $rid,
  2278. 'asArray' => true
  2279. ) );
  2280. // if(!empty($receiptDetail))
  2281. // return "/referReceipt/".$receiptDetail['rid'];
  2282. $aItem = $accountItem->find ( array (
  2283. 'asArray' => true
  2284. ) );
  2285. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2286. $ag = $tr = $ta = $ot =$it = 0;
  2287. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2288. foreach ( $aItem as $key => $value ) {
  2289. if ($value ['category'] == $this->AGENCY) {
  2290. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2291. array_push ( $accountJson [$this->AGENCY], array (
  2292. 'aid' => $value ['aid'],
  2293. 'name' => $value ['name'],
  2294. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2295. ) );
  2296. $sum += $agency [$ag];
  2297. $agencySum += $agency [$ag];
  2298. }
  2299. $ag ++;
  2300. }
  2301. if ($value ['category'] == $this->TRAVEL) {
  2302. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2303. array_push ( $accountJson [$this->TRAVEL], array (
  2304. 'aid' => $value ['aid'],
  2305. 'name' => $value ['name'],
  2306. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2307. ) );
  2308. $sum += $travel [$tr];
  2309. $travelSum += $travel [$tr];
  2310. }
  2311. $tr ++;
  2312. }
  2313. if ($value ['category'] == $this->INTTRAIN) {
  2314. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2315. array_push ( $accountJson [$this->INTTRAIN], array (
  2316. 'aid' => $value ['aid'],
  2317. 'name' => $value ['name'],
  2318. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2319. ) );
  2320. $sum += $inttrain [$it];
  2321. $inttrainSum += $inttrain [$it];
  2322. }
  2323. $it ++;
  2324. }
  2325. if ($value ['category'] == $this->TRAIN) {
  2326. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2327. array_push ( $accountJson [$this->TRAIN], array (
  2328. 'aid' => $value ['aid'],
  2329. 'name' => $value ['name'],
  2330. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2331. ) );
  2332. $sum += $train [$ta];
  2333. $trainSum += $train [$ta];
  2334. }
  2335. $ta ++;
  2336. }
  2337. if ($value ['category'] == $this->OTHER) {
  2338. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2339. array_push ( $accountJson [$this->OTHER], array (
  2340. 'aid' => $value ['aid'],
  2341. 'name' => $value ['name'],
  2342. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2343. ) );
  2344. $sum += $other [$ot];
  2345. $otherSum += $other [$ot];
  2346. }
  2347. $ot ++;
  2348. }
  2349. }
  2350. $accountJson ['cSum'] = array (
  2351. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2352. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2353. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2354. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2355. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2356. );
  2357. // 报销单
  2358. $receipt->accountItem = json_encode ( $accountJson );
  2359. $receipt->staff = $this->staff [0] ['sid'];
  2360. $receipt->loanSum = $receiptDet ['sum'];
  2361. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2362. $receipt->date = date ( "Y-m-d" );
  2363. $receipt->pastDate = '0000-00-00';
  2364. $receipt->cid = $cid;
  2365. $receipt->status = 7;
  2366. $receipt->receiptClass=$receiptClass;
  2367. if($receiptClass==2){
  2368. $receipt->itinerary2=$itinerary;
  2369. $this->_storageItinerary($itinerary, $rid);
  2370. }
  2371. // 修改审批流程加入角色
  2372. $receipt->verify = $verify;
  2373. $receipt->verifyStaff = '';
  2374. $receipt->executeStaff = '';
  2375. $receipt->executeCopy = $executeDetail ['staff'];
  2376. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2377. $receipt->explanation = $explanation;
  2378. $receipt->remittanceName = $remittanceName;
  2379. $receipt->bankName = $bankName;
  2380. $receipt->bankNumber = $bankNumber;
  2381. $receipt->remittanceBankType = $remittanceBankType;
  2382. if ($remittanceBankType == 1)
  2383. $receipt->coupletNumber = $coupletNumber;
  2384. $receipt->update ( array (
  2385. 'where' => 'rid=' . $rid
  2386. ) );
  2387. // 附件
  2388. if (! empty ( $enclosurName )) {
  2389. $enclosurArray = explode ( '-', $enclosurName );
  2390. foreach ( $enclosurArray as $value ) {
  2391. $enclosur = new enclosur ();
  2392. $enclosur->name = $value;
  2393. $enclosur->rid = $rid;
  2394. $enclosur->insert ();
  2395. }
  2396. // print_r($enclosurArray);die;
  2397. }
  2398. // 报销详情
  2399. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2400. $receiptDetail = new receiptDetail ();
  2401. $receiptDetail->staff = $this->staff [0] ['sid'];
  2402. $receiptDetail->item = $value ['name'];
  2403. $receiptDetail->itemCategory = $this->AGENCY;
  2404. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2405. $receiptDetail->date = date ( "Y-m-d" );
  2406. $receiptDetail->cid = $cid;
  2407. $receiptDetail->rid = $rid;
  2408. $receiptDetail->status = 4;
  2409. $receiptDetail->insert ();
  2410. }
  2411. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2412. $receiptDetail = new receiptDetail ();
  2413. $receiptDetail->staff = $this->staff [0] ['sid'];
  2414. $receiptDetail->item = $value ['name'];
  2415. $receiptDetail->itemCategory = $this->TRAVEL;
  2416. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2417. $receiptDetail->date = date ( "Y-m-d" );
  2418. $receiptDetail->cid = $cid;
  2419. $receiptDetail->rid = $rid;
  2420. $receiptDetail->status = 4;
  2421. $receiptDetail->insert ();
  2422. }
  2423. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2424. $receiptDetail = new receiptDetail ();
  2425. $receiptDetail->staff = $this->staff [0] ['sid'];
  2426. $receiptDetail->item = $value ['name'];
  2427. $receiptDetail->itemCategory = $this->TRAIN;
  2428. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2429. $receiptDetail->date = date ( "Y-m-d" );
  2430. $receiptDetail->cid = $cid;
  2431. $receiptDetail->rid = $rid;
  2432. $receiptDetail->status = 4;
  2433. $receiptDetail->insert ();
  2434. }
  2435. //内训
  2436. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2437. $receiptDetail = new receiptDetail ();
  2438. $receiptDetail->staff = $this->staff [0] ['sid'];
  2439. $receiptDetail->item = $value ['name'];
  2440. $receiptDetail->itemCategory = $this->INTTRAIN;
  2441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2442. $receiptDetail->date = date ( "Y-m-d" );
  2443. $receiptDetail->cid = $cid;
  2444. $receiptDetail->rid = $rid;
  2445. $receiptDetail->status = 4;
  2446. $receiptDetail->insert ();
  2447. }
  2448. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2449. $receiptDetail = new receiptDetail ();
  2450. $receiptDetail->staff = $this->staff [0] ['sid'];
  2451. $receiptDetail->item = $value ['name'];
  2452. $receiptDetail->itemCategory = $this->OTHER;
  2453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2454. $receiptDetail->date = date ( "Y-m-d" );
  2455. $receiptDetail->cid = $cid;
  2456. $receiptDetail->rid = $rid;
  2457. $receiptDetail->status = 4;
  2458. $receiptDetail->insert ();
  2459. }
  2460. return "/saeaBorad";
  2461. }
  2462. return "/saeaLoanReceiptAdd/" . $rid;
  2463. }
  2464. function saeaLoanReceiptEdi() {
  2465. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2466. Doo::loadClass ( 'XDeode' );
  2467. $XDeode = new XDeode ( 7 );
  2468. $rid = $XDeode->decode ( $ridKey );
  2469. if (! is_numeric ( $rid ))
  2470. die ( 'illegal request' );
  2471. Doo::loadModel ( 'accountItem' );
  2472. Doo::loadModel ( 'verify' );
  2473. Doo::loadModel ( 'receipt' );
  2474. $receipt = new receipt ();
  2475. $verify = new verify ();
  2476. $accountItem = new accountItem ();
  2477. Doo::loadModel ( 'L_category' );
  2478. $Lcategory = new L_category ();
  2479. Doo::loadModel ( "role" );
  2480. $role = new role ();
  2481. Doo::loadModel ( 'loanReceipt' );
  2482. $loanReceipt = new loanReceipt ();
  2483. Doo::loadModel ( 'staff' );
  2484. $staff = new staff ();
  2485. $receiptDetail = $receipt->getOne ( array (
  2486. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2487. 'asArray' => true
  2488. ) );
  2489. if (empty ( $receiptDetail ))
  2490. return "/saeaBorad";
  2491. $receiptList = $loanReceipt->find ( array (
  2492. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2493. 'desc' => 'rid',
  2494. 'asArray' => true
  2495. ) );
  2496. $Locate = 0;
  2497. $roleId = 0;
  2498. $button = 0;
  2499. foreach ( $receiptList as $key => $value ) {
  2500. $receiptList [$key] ['Locate'] = $Locate;
  2501. $Locate ++;
  2502. $receiptList [$key] ['reviseDetail'] = array ();
  2503. if (! empty ( $value ['reviseDetail'] ))
  2504. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2505. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2506. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2507. $categoryDetil = $Lcategory->getOne ( array (
  2508. 'where' => 'cid=' . $value ['cid'],
  2509. 'asArray' => true
  2510. ) );
  2511. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2512. // 检测编辑状态
  2513. $verifyList = $verify->getOne ( array (
  2514. 'where' => 'vid=' . $value ['verify'],
  2515. 'asArray' => true
  2516. ) );
  2517. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2518. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2519. Doo::loadModel ( 'role' );
  2520. $role = new role ();
  2521. $flag = true;
  2522. $roleKey = 0;
  2523. $endStaffArray = array ();
  2524. $roleArrayCopy = array ();
  2525. foreach ( $verifyList as $k => $v ) {
  2526. // init verifyStaff
  2527. if ($v [1] == 'ROLE') {
  2528. if (! empty ( $verifyStaff )) {
  2529. $endStaffArray = end ( $verifyStaff );
  2530. // if ($v[0]==$endStaffArray['nextStaff']){
  2531. // $roleId=$v[0];
  2532. // }
  2533. }
  2534. $roleVerify = json_decode ( $v [3], true );
  2535. $roleKey = $k;
  2536. $roleArray = array ();
  2537. $rolename = $role->getOne ( array (
  2538. 'where' => 'rid=' . $v [0],
  2539. 'asArray' => true
  2540. ) );
  2541. foreach ( $roleVerify as $o => $p ) {
  2542. $staffID = explode ( '_', $p );
  2543. $staffInfo = $staff->getOne ( array (
  2544. 'where' => 'sid=' . $staffID [0],
  2545. 'asArray' => true
  2546. ) );
  2547. // print_r($staffID);
  2548. $exp = array (
  2549. 0 => $staffInfo ['sid'],
  2550. 1 => $staffID [1],
  2551. 2 => $staffInfo ['avatar'],
  2552. 'date' => '',
  2553. 'date' => '',
  2554. 'opinion' => '',
  2555. 'status' => '',
  2556. 'rolename' => $rolename ['name']
  2557. );
  2558. array_push ( $roleArray, $exp );
  2559. }
  2560. $roleArrayCopy [$v [0]] = $roleArray;
  2561. // $verifyList[$k]['roleArray']=$roleArray;
  2562. }
  2563. $verifyList [$k] ['date'] = "";
  2564. $verifyList [$k] ['opinion'] = "";
  2565. $verifyList [$k] ['status'] = "";
  2566. if (empty ( $verifyStaff )) {
  2567. $verifyList [$k] ['date'] = "";
  2568. $verifyList [$k] ['opinion'] = "";
  2569. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2570. $verifyList [$k] ['status'] = 4;
  2571. $flag = false;
  2572. }
  2573. } else {
  2574. foreach ( $verifyStaff as $m => $u ) {
  2575. if ($v [0] == $m) {
  2576. $verifyList [$k] ['date'] = $u ['date'];
  2577. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2578. $verifyList [$k] ['status'] = $u ['status'];
  2579. $flag = false;
  2580. break;
  2581. }
  2582. }
  2583. $endStaffArray = end ( $verifyStaff );
  2584. if (isset ( $endStaffArray ['ROLE'] )) {
  2585. } else {
  2586. // $endKey=key($verifyStaff);
  2587. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2588. // $button=4;
  2589. // $verifyList[$k]['status']=4;
  2590. // }
  2591. }
  2592. }
  2593. }
  2594. $rolename ['name'] = '';
  2595. if (! empty ( $roleId )) {
  2596. Doo::loadModel ( 'role' );
  2597. $role = new role ();
  2598. $rolename = $role->getOne ( array (
  2599. 'where' => 'rid=' . $roleId,
  2600. 'asArray' => true
  2601. ) );
  2602. }
  2603. if (! empty ( $verifyStaff ))
  2604. $endStaffArray = end ( $verifyStaff );
  2605. $KOP = false;
  2606. foreach ( $roleArrayCopy as $P => $A ) {
  2607. foreach ( $A as $MKI => $AVL ) {
  2608. if (! empty ( $verifyStaff )) {
  2609. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2610. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2611. $button = 4;
  2612. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2613. }
  2614. foreach ( $verifyStaff as $m => $u ) {
  2615. $AVLFK = $AVL [0] . '_R';
  2616. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2617. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2618. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2619. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2620. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2621. break;
  2622. }
  2623. }
  2624. } else {
  2625. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2626. $button = 4;
  2627. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2628. }
  2629. }
  2630. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2631. $KOP = true;
  2632. }
  2633. }
  2634. foreach ( $roleArrayCopy as $k => $v ) {
  2635. foreach ( $verifyList as $m => $n ) {
  2636. if ($n [0] == $k) {
  2637. array_splice ( $verifyList, $m, 1, $v );
  2638. }
  2639. }
  2640. }
  2641. $receiptList [$key] ['verifyList'] = $verifyList;
  2642. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2643. 'where' => 'sid=' . $value ['staff'],
  2644. 'asArray' => true
  2645. ) );
  2646. $receiptList [$key] ['button'] = $button;
  2647. //
  2648. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2649. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2650. }
  2651. $data ['receiptList'] = $receiptList;
  2652. $acItem = $accountItem->find ( array (
  2653. 'asArray' => true
  2654. ) );
  2655. $veList = $verify->find ( array (
  2656. 'asArray' => true
  2657. ) );
  2658. foreach ( $veList as $key => $value ) {
  2659. $v = json_decode ( $value ['staff'] );
  2660. $list = array ();
  2661. foreach ( $v as $n => $m ) {
  2662. if ($m ['1'] == 'ROLE') {
  2663. $roleInfo = $role->getOne ( array (
  2664. 'where' => 'rid=' . $m [0],
  2665. 'asArray' => true
  2666. ) );
  2667. $v [$n] [1] = $roleInfo ['name'];
  2668. array_push ( $list, $roleInfo ['name'] );
  2669. } else {
  2670. array_push ( $list, $v [$n] [1] );
  2671. }
  2672. }
  2673. $veList [$key] ['staff'] = implode ( '>', $list );
  2674. }
  2675. // 配置编辑信息
  2676. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2677. foreach ( $acItem as $key => $value ) {
  2678. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2679. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2680. $acItem [$key] ['price'] = $v ['price'];
  2681. }
  2682. }
  2683. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2684. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2685. $acItem [$key] ['price'] = $v ['price'];
  2686. }
  2687. }
  2688. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2689. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2690. $acItem [$key] ['price'] = $v ['price'];
  2691. }
  2692. }
  2693. //内训
  2694. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2695. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2696. $acItem [$key] ['price'] = $v ['price'];
  2697. }
  2698. }
  2699. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2700. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2701. $acItem [$key] ['price'] = $v ['price'];
  2702. }
  2703. }
  2704. }
  2705. $data ['category'] = $Lcategory->find ( array (
  2706. 'asArray' => true
  2707. ) );
  2708. $data ['ridKey'] = $ridKey;
  2709. $data ['cSum'] = $accountItemList ['cSum'];
  2710. $data ['sum'] = $receiptDetail ['sum'];
  2711. $data ['receiptDetail'] = $receiptDetail;
  2712. $data ['veList'] = $veList;
  2713. $data ['acItem'] = $acItem;
  2714. $data ['memu'] = "receipt";
  2715. $data ['staff'] = $this->staff;
  2716. $data ['receiptMemu'] = 'saeaBorad';
  2717. $data ['verify'] = $receiptDetail ['verify'];
  2718. $data ['verifyId'] = $this->verifyId;
  2719. $data ['executeId'] = $this->executeId;
  2720. $data ['rid'] = $rid;
  2721. if($receiptDetail['receiptClass']==1){
  2722. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2723. }elseif($receiptDetail['receiptClass']==2){
  2724. Doo::loadModel ( 'itinerary' );
  2725. $itinerary = new itinerary ();
  2726. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  2727. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2728. }elseif($receiptDetail['receiptClass']==3){
  2729. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2730. }else{
  2731. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2732. }
  2733. }
  2734. /**
  2735. * 培训班结算
  2736. */
  2737. function receiptTrainAdd() {
  2738. Doo::loadModel ( 'accountItem' );
  2739. $accountItem = new accountItem ();
  2740. $acItem = $accountItem->find ( array (
  2741. 'asArray' => true
  2742. ) );
  2743. // 审批组
  2744. Doo::loadModel ( 'verify' );
  2745. $verify = new verify ();
  2746. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2747. // 办事处
  2748. Doo::loadModel ( 'L_category' );
  2749. $lCategory = new L_category ();
  2750. $data ['category'] = $lCategory->getCategory ();
  2751. $data ['veList'] = $veList;
  2752. $data ['memu'] = "receipt";
  2753. $data ['staff'] = $this->staff;
  2754. $data ['acItem'] = $acItem;
  2755. $data ['receiptMemu'] = 'saeaBorad';
  2756. $data ['verifyId'] = $this->verifyId;
  2757. $data ['executeId'] = $this->executeId;
  2758. $this->render ( "/receipt/receiptTrainAdd", $data );
  2759. }
  2760. /**
  2761. * 添加培训班结算
  2762. */
  2763. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2764. // 培训班信息
  2765. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2766. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2767. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2768. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2769. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2770. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2771. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2772. // 发票信息
  2773. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2774. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2775. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2776. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2777. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2778. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2779. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2780. //&&! empty ( $participants )
  2781. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2782. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2783. header ( 'Content-Type:text/html;charset=utf-8' );
  2784. die ( '请填写联行号' );
  2785. }
  2786. Doo::loadModel ( 'execute' );
  2787. $execute = new execute ();
  2788. $executeDetail = $execute->getOne ( array (
  2789. 'where' => 'mold="培训班结算"',
  2790. 'asArray' => true
  2791. ) );
  2792. if (empty ( $executeDetail )) {
  2793. header ( 'Content-Type:text/html;charset=utf-8' );
  2794. die ( '未设置执行人' );
  2795. }
  2796. Doo::loadClass ( 'XDeode' );
  2797. $XDeode = new XDeode ( 5 );
  2798. $cid = $XDeode->decode ( $cid );
  2799. Doo::loadModel ( 'receipt' );
  2800. $receipt = new receipt ();
  2801. Doo::loadModel ( 'receiptTraining' );
  2802. $receiptTraining = new receiptTraining ();
  2803. // 创建费用培训班
  2804. $item = array (
  2805. 'cid' => $this->staff [0] ['cid'],
  2806. 'categoryName' => $this->staff [0] ['category'],
  2807. 'trainName' => $trainName,
  2808. 'trainStartDate' => $trainStartDate,
  2809. 'trainEndDate' => $trainEndDate,
  2810. 'participants' => $participants,
  2811. 'freeParticipants'=>$freeParticipants,
  2812. 'trainAddress' => $trainAddress,
  2813. 'trainRemarks' => $trainRemarks,
  2814. 'creator' => $this->staff [0] ['sid'],
  2815. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2816. );
  2817. $irid = $receiptTraining->addReceiptTraining ( $item );
  2818. // 报销单
  2819. $receipt->status = 5;
  2820. $receipt->trainId = $irid;
  2821. $receipt->Rtype = 3;
  2822. $receipt->staff = $this->staff [0] ['sid'];
  2823. $receipt->cid = $cid;
  2824. $receipt->verify = $verify;
  2825. $receipt->date = date ( "Y-m-d" );
  2826. $receipt->executeCopy = $executeDetail ['staff'];
  2827. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2828. $receipt->remittanceName = $remittanceName;
  2829. $receipt->bankName = $bankName;
  2830. $receipt->bankNumber = $bankNumber;
  2831. $receipt->remittanceBankType = $remittanceBankType;
  2832. if ($remittanceBankType == 1)
  2833. $receipt->coupletNumber = $coupletNumber;
  2834. $rid = $receipt->insert ();
  2835. $XDeode = new XDeode ( 7 );
  2836. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2837. } else
  2838. die ( 'illegal request' );
  2839. }
  2840. /**
  2841. * 培训班编辑
  2842. */
  2843. function receiptTrainEdi() {
  2844. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2845. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2846. Doo::loadClass ( 'XDeode' );
  2847. $XDeode = new XDeode ( 7 );
  2848. $rid = $XDeode->decode ( $ridKey );
  2849. if (! is_numeric ( $rid ))
  2850. die ( 'illegal request' );
  2851. Doo::loadModel ( 'receipt' );
  2852. $receipt = new receipt ();
  2853. Doo::loadModel ( 'receiptTraining' );
  2854. $receiptTraining = new receiptTraining ();
  2855. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2856. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2857. die ('illegal request--status');
  2858. }
  2859. //如有已入账已收款的发票,自动取消办事处已收款
  2860. // Doo::loadModel ( 'RIExtend' );
  2861. // $RIExtend = new RIExtend ();
  2862. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2863. // if (!empty($RIExtendList)){
  2864. // foreach ($RIExtendList as $key=>$value){
  2865. // $RIExtend = new RIExtend ();
  2866. // $RIExtend->delete(array (
  2867. // 'where' => 'iid=' . $value['iid'],
  2868. // 'limit' => 1
  2869. // ));
  2870. // }
  2871. // }
  2872. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2873. // 汇总表合计
  2874. // 收入合计--加入开票合计
  2875. Doo::loadModel ( 'invoiceTraining' );
  2876. $invoiceTraining = new invoiceTraining ();
  2877. $invoiceTrainingDetail = array (
  2878. 'invoiceArriveAmount' => 0,
  2879. 'RIAmount' => 0,
  2880. 'invoiceTotalAmount' => 0,
  2881. 'invoiceCompanyAmount'=>0
  2882. );
  2883. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2884. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2885. }
  2886. // print_r($invoiceTrainingDetail);
  2887. $invoiceArriveAmount = $RIAmount = 0;
  2888. if (! empty ( $invoiceTrainingDetail )) {
  2889. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2890. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2891. }
  2892. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2893. //print_r($invoiceTrainingDetail);
  2894. // 支出项目
  2895. Doo::loadModel ( 'accountItem' );
  2896. $accountItem = new accountItem ();
  2897. // 项目金额合计
  2898. Doo::loadModel ( 'RItem' );
  2899. $RItem = new RItem ();
  2900. // 讲师获得
  2901. Doo::loadModel ( 'RILecturer' );
  2902. $RILecturer = new RILecturer ();
  2903. $RItemList = $RItem->getRItemByRid ( $rid );
  2904. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2905. // 支出项金额详情
  2906. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2907. // print_r($aiData);
  2908. // 利润
  2909. $profit=$invoiceArriveAmount - $aiData ['total'];
  2910. $companyProfit=$profit * 0.6;
  2911. $categoryProfit=$profit * 0.4;
  2912. $data ['profit'] = sprintf("%.2f",$profit);
  2913. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2914. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2915. //发票利润
  2916. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2917. //发票公司利润
  2918. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2919. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2920. //办事处利润
  2921. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2922. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2923. // print_r($aiData['dataList']);
  2924. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2925. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2926. // 备用金
  2927. $sum = 0;
  2928. $data ['receiptLoanDetail'] = array (
  2929. 'sum' => '0.00'
  2930. );
  2931. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2932. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2933. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2934. $sum=0;
  2935. foreach ($receiptLoanList as $key=>$value){
  2936. $sum+=$value['sum'];
  2937. }
  2938. $data ['receiptLoanDetail'] = array (
  2939. 'sum' => $sum
  2940. );
  2941. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2942. }
  2943. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2944. $data ['payment'] = sprintf("%.2f",$payment);
  2945. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2946. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2947. $data ['aiList'] = $aiData ['dataList'];
  2948. // 占比计算
  2949. if ($invoiceArriveAmount != 0) {
  2950. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2951. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2952. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2953. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2954. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2955. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2956. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2957. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2958. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2959. } else {
  2960. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2961. }
  2962. //发票金额占比计算
  2963. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2964. //支出
  2965. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2966. //利润
  2967. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2968. //公司利润
  2969. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2970. //办事处利润
  2971. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2972. //公司收款
  2973. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2974. //备用金
  2975. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2976. //办事处收款
  2977. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2978. //办事处实际支出
  2979. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2980. //付总部款
  2981. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2982. }else{
  2983. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2984. }
  2985. //讲师人数
  2986. Doo::loadModel ( 'RILecturer' );
  2987. $RILecturer = new RILecturer ();
  2988. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2989. $data['lectureCount']=count($RILecturerList);
  2990. // 审批组
  2991. Doo::loadModel ( 'verify' );
  2992. $verify = new verify ();
  2993. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2994. // 办事处
  2995. Doo::loadModel ( 'L_category' );
  2996. $lCategory = new L_category ();
  2997. $data ['category'] = $lCategory->getCategory ();
  2998. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2999. $data ['receiptDetail'] = $receiptDetail;
  3000. $data ['veList'] = $veList;
  3001. $data ['trainEdiType'] = $trainEdiType;
  3002. $data ['ridKey'] = $ridKey;
  3003. $data ['memu'] = "receipt";
  3004. $data ['staff'] = $this->staff;
  3005. $data ['receiptMemu'] = 'saeaBorad';
  3006. $data ['verifyId'] = $this->verifyId;
  3007. $data ['executeId'] = $this->executeId;
  3008. $this->render ( "/receipt/receiptTrainEdi", $data );
  3009. }
  3010. /**
  3011. * 培训班借款编辑
  3012. */
  3013. function receiptTrainLoanEdi() {
  3014. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3015. Doo::loadClass ( 'XDeode' );
  3016. $XDeode = new XDeode ( 7 );
  3017. $rid = $XDeode->decode ( $ridKey );
  3018. if (! is_numeric ( $rid ))
  3019. die ( 'illegal request' );
  3020. Doo::loadModel ( 'receipt' );
  3021. $receipt = new receipt ();
  3022. Doo::loadModel ( 'receiptTraining' );
  3023. $receiptTraining = new receiptTraining ();
  3024. Doo::loadModel ( 'verify' );
  3025. $verify = new verify ();
  3026. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3027. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3028. die ();
  3029. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3030. // 借款详情HTML
  3031. // 获得借款信息
  3032. $receiptLoanHtml = '';
  3033. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3034. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3035. foreach ($receiptLoanList as $key=>$value){
  3036. // 获得某费用单审批信息
  3037. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3038. Doo::loadClass ( 'receipt.func' );
  3039. $extendHtml = '<p><a class="button"
  3040. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3041. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3042. }
  3043. }
  3044. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3045. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3046. $data ['receiptDetail'] = $receiptDetail;
  3047. $data ['trainEdiType'] = "LOAN";
  3048. $data ['ridKey'] = $ridKey;
  3049. $data ['memu'] = "receipt";
  3050. $data ['staff'] = $this->staff;
  3051. $data ['receiptMemu'] = 'saeaBorad';
  3052. $data ['verifyId'] = $this->verifyId;
  3053. $data ['executeId'] = $this->executeId;
  3054. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3055. }
  3056. /**
  3057. * 更新培训班结算基本信息
  3058. */
  3059. function receiptTrainInfoEdiDo() {
  3060. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3061. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3062. // 培训班信息
  3063. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3064. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3065. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3066. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3067. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3068. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3069. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3070. // 发票信息
  3071. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3072. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3073. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3074. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3075. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3076. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3077. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3078. //&& ! empty ( $participants )
  3079. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3080. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3081. header ( 'Content-Type:text/html;charset=utf-8' );
  3082. die ( '请填写联行号' );
  3083. }
  3084. Doo::loadClass ( 'XDeode' );
  3085. $XDeode = new XDeode ( 5 );
  3086. $cid = $XDeode->decode ( $cid );
  3087. $rtid = $XDeode->decode ( $rtid );
  3088. $rid = $XDeode->decode ( $rid );
  3089. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3090. die ( 'illegal request-IdError' );
  3091. }
  3092. Doo::loadModel ( 'receipt' );
  3093. $receipt = new receipt ();
  3094. Doo::loadModel ( 'receiptTraining' );
  3095. $receiptTraining = new receiptTraining ();
  3096. // 更新费用培训班
  3097. $item = array (
  3098. 'rtid' => $rtid,
  3099. 'trainName' => $trainName,
  3100. 'trainStartDate' => $trainStartDate,
  3101. 'trainEndDate' => $trainEndDate,
  3102. 'participants' => $participants,
  3103. 'freeParticipants'=>$freeParticipants,
  3104. 'trainAddress' => $trainAddress,
  3105. 'trainRemarks' => $trainRemarks
  3106. );
  3107. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3108. // 报销单
  3109. $receipt->rid = $rid;
  3110. $receipt->cid = $cid;
  3111. $receipt->verify = $verify;
  3112. $receipt->remittanceName = $remittanceName;
  3113. $receipt->bankName = $bankName;
  3114. $receipt->bankNumber = $bankNumber;
  3115. $receipt->remittanceBankType = $remittanceBankType;
  3116. if ($remittanceBankType == 1)
  3117. $receipt->coupletNumber = $coupletNumber;
  3118. $receipt->update ();
  3119. $XDeode = new XDeode ( 7 );
  3120. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3121. } else
  3122. die ( 'illegal request' );
  3123. }
  3124. /**
  3125. * 编辑培训班结算---更新借款
  3126. */
  3127. function receiptTrainLoanEdiDo() {
  3128. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3129. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3130. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3131. Doo::loadModel ( 'receipt' );
  3132. $receipt = new receipt ();
  3133. Doo::loadClass ( 'XDeode' );
  3134. $XDeode = new XDeode ( 5 );
  3135. $rid = $XDeode->decode ( $ridKey );
  3136. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3137. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3138. die ( 'illegal request-ridError' );
  3139. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3140. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3141. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3142. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3143. die ( 'illegal request-receiptError' );
  3144. }
  3145. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3146. die ( 'illegal request-receipLoantError' );
  3147. }
  3148. // 培训班结算挂钩借款
  3149. $receipt = new receipt ();
  3150. $trainLoanRid=$ridLoan;
  3151. if (!empty($receiptDetail['trainLoanRid'])){
  3152. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3153. }
  3154. $item = array (
  3155. 'rid' => $rid,
  3156. 'trainLoanRid' => $trainLoanRid
  3157. );
  3158. $receipt->setReceiptByCondition ( $item );
  3159. // 更新借款状态变成已挂钩
  3160. $receipt = new receipt ();
  3161. $item = array (
  3162. 'rid' => $ridLoan,
  3163. 'status' => 10,
  3164. 'statusTrain' => 1
  3165. );
  3166. $receipt->setReceiptByCondition ( $item );
  3167. $XDeode = new XDeode ( 7 );
  3168. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3169. } else
  3170. die ( 'illegal request' );
  3171. }
  3172. /**
  3173. * 编辑培训班结算--移除借款
  3174. */
  3175. function receiptTrainLoanRemoveDo() {
  3176. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3177. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3178. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3179. Doo::loadModel ( 'receipt' );
  3180. $receipt = new receipt ();
  3181. Doo::loadClass ( 'XDeode' );
  3182. $XDeode = new XDeode ( 5 );
  3183. $rid = $XDeode->decode ( $ridKey );
  3184. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3185. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3186. die ( 'illegal request-ridError' );
  3187. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3188. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3189. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3190. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3191. die ( 'illegal request-receiptError' );
  3192. }
  3193. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3194. die ( 'illegal request-receipLoantError' );
  3195. }
  3196. // 培训班结算挂钩借款
  3197. $receipt = new receipt ();
  3198. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3199. foreach ($trainLoanRidArray as $key=>$value){
  3200. if($value==$ridLoan){
  3201. unset($trainLoanRidArray[$key]);
  3202. }
  3203. }
  3204. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3205. $item = array (
  3206. 'rid' => $rid,
  3207. 'trainLoanRid' => $trainLoanRidString
  3208. );
  3209. $receipt->setReceiptByCondition ( $item );
  3210. // 更新借款状态变成已挂钩
  3211. $receipt = new receipt ();
  3212. $item = array (
  3213. 'rid' => $ridLoan,
  3214. 'status' => 8,
  3215. 'statusTrain' => 0
  3216. );
  3217. $receipt->setReceiptByCondition ( $item );
  3218. $XDeode = new XDeode ( 7 );
  3219. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3220. } else
  3221. die ( 'illegal request' );
  3222. }
  3223. /**
  3224. * 编辑培训班结算 ---开票
  3225. */
  3226. function receiptTrainInvoiceEdi() {
  3227. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3228. Doo::loadClass ( 'XDeode' );
  3229. $XDeode = new XDeode ( 7 );
  3230. $rid = $XDeode->decode ( $ridKey );
  3231. if (! is_numeric ( $rid ))
  3232. die ( 'illegal request' );
  3233. Doo::loadModel ( 'receipt' );
  3234. $receipt = new receipt ();
  3235. Doo::loadModel ( 'receiptTraining' );
  3236. $receiptTraining = new receiptTraining ();
  3237. Doo::loadModel ( 'invoice' );
  3238. $invoice = new invoice ();
  3239. Doo::loadModel ( 'invoiceTraining' );
  3240. $invoiceTraining = new invoiceTraining ();
  3241. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3242. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3243. die ();
  3244. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3245. $invoiceList = $invoiceTrainingDetail = array ();
  3246. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3247. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3248. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3249. }
  3250. //print_r($invoiceList);
  3251. $data ['invoiceList'] = $invoiceList;
  3252. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3253. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3254. $data ['receiptDetail'] = $receiptDetail;
  3255. $data ['trainEdiType'] = "INVOICE";
  3256. $data ['ridKey'] = $ridKey;
  3257. $data ['memu'] = "receipt";
  3258. $data ['staff'] = $this->staff;
  3259. $data ['receiptMemu'] = 'saeaBorad';
  3260. $data ['verifyId'] = $this->verifyId;
  3261. $data ['executeId'] = $this->executeId;
  3262. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3263. }
  3264. /**
  3265. * 编辑培训班结算---更新开票
  3266. */
  3267. function receiptTrainInvoiceEdiDo() {
  3268. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3269. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3270. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3271. Doo::loadModel ( 'receipt' );
  3272. $receipt = new receipt ();
  3273. Doo::loadModel ( 'invoiceTraining' );
  3274. $invoiceTraining = new invoiceTraining ();
  3275. Doo::loadClass ( 'XDeode' );
  3276. $XDeode = new XDeode ( 5 );
  3277. $rid = $XDeode->decode ( $ridKey );
  3278. $itid = $XDeode->decode ( $itidKey );
  3279. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3280. die ( 'illegal request-idError' );
  3281. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3282. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3283. // 不合法的数据
  3284. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3285. die ( 'illegal request-receiptError' );
  3286. }
  3287. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3288. die ( 'illegal request-receipLoantError' );
  3289. }
  3290. // 培训班结算挂钩借款
  3291. $receipt = new receipt ();
  3292. $item = array (
  3293. 'rid' => $rid,
  3294. 'invoiceTrainId' => $itid
  3295. );
  3296. $receipt->setReceiptByCondition ( $item );
  3297. $invoiceTraining = new invoiceTraining ();
  3298. $item = array (
  3299. 'bindReceipt' => 1,
  3300. 'itid' => $itid
  3301. );
  3302. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3303. $XDeode = new XDeode ( 7 );
  3304. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3305. } else
  3306. die ( 'illegal request' );
  3307. }
  3308. /**
  3309. * 更新培训班结算 收款和取消收款
  3310. */
  3311. function receiptTrainReceivables() {
  3312. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3313. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3314. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3315. Doo::loadClass ( 'XDeode' );
  3316. $XDeode = new XDeode ( 5 );
  3317. $rid = $XDeode->decode ( $ridKey );
  3318. $iid = $XDeode->decode ( $iidKey );
  3319. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3320. die ( 'illegal request-iid' );
  3321. Doo::loadModel ( 'RIExtend' );
  3322. $RIExtend = new RIExtend ();
  3323. if ($doType == 'CONFIRM') {
  3324. $RIExtend->rid = $rid;
  3325. $RIExtend->iid = $iid;
  3326. $RIExtend->RIstatus = 1;
  3327. $RIExtend->insert ();
  3328. echo json_encode ( array (
  3329. 'status' => 1,
  3330. ) );
  3331. die ( );
  3332. } elseif ($doType == 'CANCEL') {
  3333. $RIExtend->delete ( array (
  3334. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3335. 'limit' => 1
  3336. ) );
  3337. echo json_encode ( array (
  3338. 'status' => 1,
  3339. ) );
  3340. die ( );
  3341. } else {
  3342. echo json_encode ( array (
  3343. 'status' => 2,
  3344. ) );
  3345. die ( );
  3346. }
  3347. }
  3348. /**
  3349. * 移除挂钩的培训班发票
  3350. */
  3351. function receiptTrainReceivablesDelDo() {
  3352. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3353. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3354. Doo::loadModel ( 'receipt' );
  3355. $receipt = new receipt ();
  3356. Doo::loadModel ( 'RIExtend' );
  3357. $RIExtend = new RIExtend ();
  3358. Doo::loadClass ( 'XDeode' );
  3359. $XDeode = new XDeode ( 5 );
  3360. $rid = $XDeode->decode ( $ridKey );
  3361. $itid = $XDeode->decode ( $itidKey );
  3362. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3363. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3364. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3365. die ( 'illegal request-status' );
  3366. }
  3367. $receipt = new receipt ();
  3368. $receipt->rid = $rid;
  3369. $receipt->invoiceTrainId = 0;
  3370. $receipt->update ();
  3371. Doo::loadModel ( 'invoiceTraining' );
  3372. $invoiceTraining = new invoiceTraining ();
  3373. $item = array (
  3374. 'bindReceipt' => 0,
  3375. 'itid' => $itid
  3376. );
  3377. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3378. $RIExtend->delete ( array (
  3379. 'where' => 'rid=' . $rid
  3380. ) );
  3381. $XDeode = new XDeode ( 7 );
  3382. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3383. } else
  3384. die ( 'illegal request-iid' );
  3385. }
  3386. /**
  3387. * 编辑培训班结算
  3388. */
  3389. function receiptTrainItemEdi() {
  3390. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3391. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3392. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3393. Doo::loadClass ( 'XDeode' );
  3394. $XDeode = new XDeode ( 7 );
  3395. $rid = $XDeode->decode ( $ridKey );
  3396. if (! is_numeric ( $rid ))
  3397. die ( 'illegal request' );
  3398. Doo::loadModel ( 'receipt' );
  3399. $receipt = new receipt ();
  3400. Doo::loadModel ( 'receiptTraining' );
  3401. $receiptTraining = new receiptTraining ();
  3402. Doo::loadModel ( 'RItem' );
  3403. $RItem = new RItem ();
  3404. Doo::loadModel ( 'accountItem' );
  3405. $accountItem = new accountItem ();
  3406. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3407. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3408. die ();
  3409. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3410. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3411. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3412. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3413. // if($value['name']=='税款'){
  3414. // unset($aiList[$key]);break;
  3415. // }
  3416. // }
  3417. //print_r($RItemList);
  3418. $data ['name'] = $name;
  3419. $data ['RItemList'] = $RItemList;
  3420. $data ['aiList'] = $aiList;
  3421. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3422. $data ['receiptDetail'] = $receiptDetail;
  3423. $data ['trainEdiType'] = "ITEM";
  3424. $data ['ridKey'] = $ridKey;
  3425. $data ['memu'] = "receipt";
  3426. $data ['staff'] = $this->staff;
  3427. $data ['receiptMemu'] = 'saeaBorad';
  3428. $data ['verifyId'] = $this->verifyId;
  3429. $data ['executeId'] = $this->executeId;
  3430. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3431. }
  3432. /**
  3433. * 添加支出项 需要修改 费用金额合计
  3434. */
  3435. function receiptTrainItemAddDo() {
  3436. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3437. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3438. // 支出项信息
  3439. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3440. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3441. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3442. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3443. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3444. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3445. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3446. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3447. Doo::loadClass ( 'XDeode' );
  3448. $XDeode = new XDeode ( 5 );
  3449. Doo::loadModel ( 'RItem' );
  3450. $RItem = new RItem ();
  3451. $rid = $XDeode->decode ( $ridKey );
  3452. $rtid= $XDeode->decode ( $rtidKey );
  3453. if (! is_numeric ( $rid )){
  3454. die ( 'illegal request' );
  3455. }
  3456. Doo::loadModel ( 'receiptDetail' );
  3457. $receiptDetail = new receiptDetail ();
  3458. Doo::loadModel ( 'receipt' );
  3459. $receipt = new receipt ();
  3460. Doo::loadModel ( 'receiptTraining' );
  3461. $receiptTraining = new receiptTraining ();
  3462. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3463. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3464. $order = array (
  3465. "\r\n",
  3466. "\n",
  3467. "\r"
  3468. );
  3469. $replace = '<br/>';
  3470. $describe = str_replace ( $order, $replace, $describe );
  3471. $itemData = array (
  3472. 'rid' => $rid,
  3473. 'item' => $item,
  3474. 'price' => $price,
  3475. 'date' => $date,
  3476. 'inputer' => $inputer,
  3477. 'describe' => $describe,
  3478. 'creater' => $this->staff['0']['username'],
  3479. 'createrId' => $this->staff['0']['sid'],
  3480. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3481. 'identifying'=>$identifyingTotal
  3482. );
  3483. if($payType=='company'){
  3484. $itemData += array (
  3485. 'payType' => 1
  3486. );
  3487. }
  3488. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3489. //更新支出项标识总数
  3490. $itemData = array (
  3491. 'rtid'=>$rtid,
  3492. 'identifyingTotal'=>$identifyingTotal
  3493. );
  3494. $receiptTraining->setReceiptTrainByCondition($itemData);
  3495. $XDeode = new XDeode ( 7 );
  3496. if($payType=='company'){
  3497. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3498. }else{
  3499. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3500. }
  3501. } else
  3502. die ( 'illegal request-dataError' );
  3503. }
  3504. /**
  3505. * 培训班结算-讲师
  3506. */
  3507. function receiptTrainLecturerEdi() {
  3508. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3509. Doo::loadClass ( 'XDeode' );
  3510. $XDeode = new XDeode ( 7 );
  3511. $rid = $XDeode->decode ( $ridKey );
  3512. if (! is_numeric ( $rid ))
  3513. die ( 'illegal request' );
  3514. Doo::loadModel ( 'receipt' );
  3515. $receipt = new receipt ();
  3516. Doo::loadModel ( 'receiptTraining' );
  3517. $receiptTraining = new receiptTraining ();
  3518. Doo::loadModel ( 'RILecturer' );
  3519. $RILecturer = new RILecturer ();
  3520. Doo::loadModel ( 'lecturer' );
  3521. $lecturer = new lecturer ();
  3522. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3523. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3524. die ();
  3525. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3526. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3527. $lecturerList = $lecturer->getLecturerAll ();
  3528. $INSIDEhtml = $OUTSIDEhtml = '';
  3529. foreach ( $lecturerList as $key => $value ) {
  3530. if ($value ['ltype'] == 'INSIDE') {
  3531. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3532. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3533. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3534. }
  3535. }
  3536. $data ['INSIDEhtml'] = $INSIDEhtml;
  3537. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3538. // print_r($RItemList);
  3539. $data ['RILecturerList'] = $RILecturerList;
  3540. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3541. $data ['receiptDetail'] = $receiptDetail;
  3542. $data ['trainEdiType'] = "LECTURER";
  3543. $data ['ridKey'] = $ridKey;
  3544. $data ['memu'] = "receipt";
  3545. $data ['staff'] = $this->staff;
  3546. $data ['receiptMemu'] = 'saeaBorad';
  3547. $data ['verifyId'] = $this->verifyId;
  3548. $data ['executeId'] = $this->executeId;
  3549. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3550. }
  3551. /**
  3552. * 添加讲师
  3553. */
  3554. function receiptTrainLecturerAddDo() {
  3555. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3556. // 支出项信息
  3557. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3558. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3559. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3560. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3561. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3562. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3563. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3564. Doo::loadClass ( 'XDeode' );
  3565. $XDeode = new XDeode ( 5 );
  3566. Doo::loadModel ( 'RILecturer' );
  3567. $RILecturer = new RILecturer ();
  3568. $rid = $XDeode->decode ( $ridKey );
  3569. if (! is_numeric ( $rid ))
  3570. die ( 'illegal request' );
  3571. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3572. die ( 'illegal request-taxationError' );
  3573. $RILecturer->rid = $rid;
  3574. $RILecturer->ltype = $ltype;
  3575. if ($ltype == 'OUTSIDE') {
  3576. if ($taxation == 'TAXATION') {
  3577. $RILecturer->taxation = 1;
  3578. } elseif ($taxation == 'NOTAXATION') {
  3579. $RILecturer->taxation = 0;
  3580. }
  3581. }
  3582. $RILecturer->lecturerName = $lecturerName;
  3583. $RILecturer->schoolDay = $schoolDay;
  3584. $RILecturer->price = $price;
  3585. $RILecturer->fees=$fees;
  3586. $RILecturer->insert ();
  3587. // 添加公司汇总
  3588. // 报销详情
  3589. Doo::loadModel ( 'receiptDetail' );
  3590. $receiptDetail = new receiptDetail ();
  3591. Doo::loadModel ( 'receipt' );
  3592. $receipt = new receipt ();
  3593. // 金额总计
  3594. $price = $price * $schoolDay;
  3595. $rInfo = $receipt->getReceiptByRid ( $rid );
  3596. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3597. if (empty ( $rdInfo )) {
  3598. $receiptDetail = new receiptDetail ();
  3599. $receiptDetail->staff = $rInfo ['staff'];
  3600. $receiptDetail->item = '讲课费';
  3601. $receiptDetail->itemCategory = '培训班费用';
  3602. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3603. $receiptDetail->date = date ( "Y-m-d" );
  3604. $receiptDetail->cid = $rInfo ['cid'];
  3605. $receiptDetail->rid = $rid;
  3606. $receiptDetail->status = 4;
  3607. $receiptDetail->insert ();
  3608. } else {
  3609. $receiptDetail = new receiptDetail ();
  3610. $rdInfo ['price'] += $fees;
  3611. $receiptDetail->price = $rdInfo ['price'];
  3612. $receiptDetail->update ( array (
  3613. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3614. ) );
  3615. }
  3616. $receipt = new receipt ();
  3617. $receipt->sum=$rInfo['sum']+$fees;
  3618. $receipt->update ( array (
  3619. 'where' => 'rid=' . $rid
  3620. ) );
  3621. $XDeode = new XDeode ( 7 );
  3622. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3623. } else
  3624. die ( 'illegal request' );
  3625. }
  3626. /**
  3627. * 移除讲师
  3628. */
  3629. function receiptTrainLecturerDelDo() {
  3630. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3631. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3632. Doo::loadModel ( 'receipt' );
  3633. $receipt = new receipt ();
  3634. Doo::loadModel ( 'RILecturer' );
  3635. $RILecturer = new RILecturer ();
  3636. Doo::loadClass ( 'XDeode' );
  3637. $XDeode = new XDeode ( 5 );
  3638. $rid = $XDeode->decode ( $ridKey );
  3639. $rlid = $XDeode->decode ( $rlidKey );
  3640. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3641. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3642. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3643. die ( 'illegal request-status' );
  3644. }
  3645. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3646. if (empty($detail)){
  3647. die ( 'illegal request-data' );
  3648. }
  3649. $RILecturer->delete ( array (
  3650. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3651. ) );
  3652. //更新费用合计金额
  3653. $rInfo = $receipt->getReceiptByRid ( $rid );
  3654. $receipt = new receipt ();
  3655. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3656. $receipt->update ( array (
  3657. 'where' => 'rid=' . $rid
  3658. ) );
  3659. Doo::loadModel ( 'receiptDetail' );
  3660. $receiptDetail = new receiptDetail ();
  3661. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3662. $receiptDetail = new receiptDetail ();
  3663. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3664. $receiptDetail->price = $rdInfo ['price'];
  3665. $receiptDetail->update ( array (
  3666. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3667. ) );
  3668. $XDeode = new XDeode ( 7 );
  3669. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3670. } else
  3671. die ( 'illegal request-iid' );
  3672. }
  3673. /**
  3674. * 培训班提交审批
  3675. */
  3676. function receiptTrainDo() {
  3677. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3678. Doo::loadClass ( 'XDeode' );
  3679. $XDeode = new XDeode ( 7 );
  3680. $rid = $XDeode->decode ( $ridKey );
  3681. Doo::loadModel ( 'receipt' );
  3682. $receipt = new receipt ();
  3683. Doo::loadModel ( 'receiptDetail' );
  3684. $receiptDetail = new receiptDetail ();
  3685. Doo::loadModel ( 'statistics' );
  3686. $statistics = new statistics ();
  3687. Doo::loadModel ( "verify" );
  3688. $verify = new verify ();
  3689. // 审批状态的判定
  3690. $receiptDetailList = $receipt->getOne ( array (
  3691. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3692. 'asArray' => true
  3693. ) );
  3694. if (empty ( $receiptDetailList ))
  3695. return "/saeaBorad";
  3696. $verifyDetail = $verify->getOne ( array (
  3697. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3698. 'asArray' => true
  3699. ) );
  3700. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3701. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3702. $nowStaff = "";
  3703. $nowStaffList = array ();
  3704. if ($verifyDetail [0] [1] == 'ROLE') {
  3705. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3706. foreach ( $vStaffString as $key => $value ) {
  3707. $staffK = explode ( "_", $value );
  3708. array_push ( $nowStaffList, $staffK [0] );
  3709. }
  3710. $nowStaff = implode ( ',', $nowStaffList );
  3711. } else {
  3712. $nowStaff = $verifyDetail [0] [0];
  3713. }
  3714. $receipt->nowStaff = $nowStaff;
  3715. }
  3716. // echo $nowStaff;
  3717. // print_r($verifyDetail);die;
  3718. $receipt->rid = $receiptDetailList ['rid'];
  3719. $receipt->date = date ( "Y-m-d" );
  3720. $receipt->status = 2;
  3721. $receipt->update ();
  3722. $receiptDetail->status = 2;
  3723. $receiptDetail->update ( array (
  3724. 'where' => 'rid=' . $receiptDetailList ['rid']
  3725. ) );
  3726. Doo::loadModel ( "receiptLog" );
  3727. $receiptLog = new receiptLog ();
  3728. Doo::loadModel ( "verify" );
  3729. $verify = new verify ();
  3730. $vr = $verify->getOne ( array (
  3731. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3732. 'asArray' => true
  3733. ) );
  3734. $jd = json_decode ( $vr ['staff'] );
  3735. $roleId = 0;
  3736. foreach ( $jd as $key => $value ) {
  3737. if ($value [1] == 'ROLE') {
  3738. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3739. if ($pos !== false) {
  3740. $roleId = $value [0];
  3741. }
  3742. }
  3743. }
  3744. // 审批日志
  3745. // echo $roleId;die;
  3746. if (! empty ( $roleId )) {
  3747. Doo::loadModel ( "role" );
  3748. $role = new role ();
  3749. $roleInfo = $role->getOne ( array (
  3750. 'where' => 'rid=' . $roleId,
  3751. 'asArray' => true
  3752. ) );
  3753. // $receiptLog->rolename = $roleInfo ['name'];
  3754. }
  3755. $receiptLog->username = $this->staff [0] ['username'];
  3756. $receiptLog->uid = $this->staff [0] ['sid'];
  3757. $receiptLog->date = date ( "Y-m-d" );
  3758. $receiptLog->opinion = '提交审批';
  3759. $receiptLog->img = $this->staff [0] ['avatar'];
  3760. $receiptLog->status = 2;
  3761. $receiptLog->rid = $rid;
  3762. $receiptLog->insert ();
  3763. // 写入列表项
  3764. Doo::loadModel ( 'accountItem' );
  3765. $accountItem = new accountItem ();
  3766. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3767. // 项目金额合计
  3768. Doo::loadModel ( 'RItem' );
  3769. $RItem = new RItem ();
  3770. // 讲师获得
  3771. Doo::loadModel ( 'RILecturer' );
  3772. $RILecturer = new RILecturer ();
  3773. $RItemList = $RItem->getRItemByRid ( $rid );
  3774. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3775. // 支出项金额详情
  3776. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3777. // print_r($aItem);
  3778. // print_r($aiData);
  3779. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3780. $ag = $tr = $ta = $ot = 0;
  3781. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3782. foreach ( $aItem as $key => $value ) {
  3783. if ($value ['category'] == $this->TRAIN) {
  3784. foreach ( $aiData ['dataList'] as $k => $v ) {
  3785. if ($value ['name'] == $v ['name']) {
  3786. array_push ( $accountJson [$this->TRAIN], array (
  3787. 'aid' => $value ['aid'],
  3788. 'name' => $value ['name'],
  3789. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3790. ) );
  3791. $sum += $v ['price'];
  3792. $trainSum += $v ['price'];
  3793. unset ( $aiData ['dataList'] [$k] );
  3794. break;
  3795. }
  3796. }
  3797. }
  3798. }
  3799. $accountJson ['cSum'] = array (
  3800. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3801. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3802. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3803. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3804. );
  3805. // 报销单
  3806. $receipt = new receipt ();
  3807. $receipt->accountItem = json_encode ( $accountJson );
  3808. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3809. $receipt->update ( array (
  3810. 'where' => 'rid=' . $rid
  3811. ) );
  3812. // print_r($accountJson);
  3813. // statistics item 统计写入
  3814. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3815. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3816. $accountItem = $accountJson;
  3817. $stat = $statistics->getOne ( array (
  3818. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3819. 'asArray' => true
  3820. ) );
  3821. if (empty ( $stat )) {
  3822. $statistics->date = date ( "Y-m-d" );
  3823. $statistics->cid = $this->staff [0] ['cid'];
  3824. $statistics->staff = $this->staff [0] ['sid'];
  3825. $statistics->agPrice = 0;
  3826. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3827. $statistics->insert ();
  3828. } else {
  3829. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3830. $statistics->update ( array (
  3831. 'where' => 'sid=' . $stat ['sid']
  3832. ) );
  3833. }
  3834. return "/saeaBorad";
  3835. }
  3836. function confirmation() {
  3837. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3838. Doo::loadModel ( 'receipt' );
  3839. Doo::loadModel ( 'receiptDetail' );
  3840. $receipt = new receipt ();
  3841. $receiptDetail = new receiptDetail ();
  3842. Doo::loadModel ( 'statistics' );
  3843. Doo::loadModel ( 'itemStatistics' );
  3844. $statistics = new statistics ();
  3845. $itemStatistics = new itemStatistics ();
  3846. Doo::loadModel ( "verify" );
  3847. $verify = new verify ();
  3848. $receiptDetailList = $receipt->getOne ( array (
  3849. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3850. 'asArray' => true
  3851. ) );
  3852. if (empty ( $receiptDetailList ))
  3853. return "/saeaBorad";
  3854. $verifyDetail = $verify->getOne ( array (
  3855. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3856. 'asArray' => true
  3857. ) );
  3858. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3859. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3860. $nowStaff = "";
  3861. $nowStaffList = array ();
  3862. if ($verifyDetail [0] [1] == 'ROLE') {
  3863. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3864. foreach ( $vStaffString as $key => $value ) {
  3865. $staffK = explode ( "_", $value );
  3866. array_push ( $nowStaffList, $staffK [0] );
  3867. }
  3868. $nowStaff = implode ( ',', $nowStaffList );
  3869. } else {
  3870. $nowStaff = $verifyDetail [0] [0];
  3871. }
  3872. $receipt->nowStaff = $nowStaff;
  3873. }
  3874. // echo $nowStaff;
  3875. // print_r($verifyDetail);die;
  3876. $receipt->rid = $receiptDetailList ['rid'];
  3877. $receipt->status = 2;
  3878. $receipt->update ();
  3879. // 操作日志
  3880. Doo::loadModel ( "receiptLog" );
  3881. $receiptLog = new receiptLog ();
  3882. $verify = new verify ();
  3883. $receiptInfo = $receipt->getOne ( array (
  3884. 'where' => 'rid=' . $rid,
  3885. 'asArray' => true
  3886. ) );
  3887. $vr = $verify->getOne ( array (
  3888. 'where' => 'vid=' . $receiptInfo ['verify'],
  3889. 'asArray' => true
  3890. ) );
  3891. $jd = json_decode ( $vr ['staff'] );
  3892. $roleId = 0;
  3893. foreach ( $jd as $key => $value ) {
  3894. if ($value [1] == 'ROLE') {
  3895. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3896. if ($pos !== false) {
  3897. $roleId = $value [0];
  3898. }
  3899. }
  3900. }
  3901. // 审批日志
  3902. // echo $roleId;die;
  3903. if (! empty ( $roleId )) {
  3904. Doo::loadModel ( "role" );
  3905. $role = new role ();
  3906. $roleInfo = $role->getOne ( array (
  3907. 'where' => 'rid=' . $roleId,
  3908. 'asArray' => true
  3909. ) );
  3910. // $receiptLog->rolename = $roleInfo ['name'];
  3911. }
  3912. $receiptLog->username = $this->staff [0] ['username'];
  3913. $receiptLog->uid = $this->staff [0] ['sid'];
  3914. $receiptLog->date = date ( "Y-m-d" );
  3915. $receiptLog->opinion = '提交审批';
  3916. $receiptLog->img = $this->staff [0] ['avatar'];
  3917. $receiptLog->status = 2;
  3918. $receiptLog->rid = $rid;
  3919. $receiptLog->insert ();
  3920. return "/expenses";
  3921. }
  3922. function expenses() {
  3923. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3924. if (empty ( $item ))
  3925. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3926. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3927. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3928. Doo::loadClass ( 'XDeode' );
  3929. $XDeode = new XDeode ( 7 );
  3930. Doo::loadModel ( 'receipt' );
  3931. $receipt = new receipt ();
  3932. Doo::loadModel ( 'L_category' );
  3933. $Lcategory = new L_category ();
  3934. Doo::loadModel ( 'verify' );
  3935. Doo::loadModel ( 'statistics' );
  3936. $statistics = new statistics ();
  3937. $verify = new verify ();
  3938. Doo::loadModel ( 'staff' );
  3939. $staff = new staff ();
  3940. $condition = "";
  3941. if ($item == "expenses")
  3942. $condition = " and Rtype=1 ";
  3943. elseif ($item == "receipts")
  3944. $condition = " and Rtype=0 ";
  3945. elseif ($item == "remits")
  3946. $condition = " and Rtype=2 ";
  3947. elseif ($item == "train")
  3948. $condition = " and Rtype=3 ";
  3949. $dateCondition = " and Year(date) =" . $year;
  3950. if (! empty ( $moth )) {
  3951. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3952. $stList = $statistics->getOne ( array (
  3953. 'select' => 'rePrice ,agPrice',
  3954. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3955. 'asArray' => true
  3956. ) );
  3957. } else
  3958. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3959. if (empty ( $stList ))
  3960. $stList = array (
  3961. 'rePrice' => 0,
  3962. 'agPrice' => 0
  3963. );
  3964. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3965. if (! isset ( $noPassSum ['sum'] ))
  3966. $noPassSum ['sum'] = 0;
  3967. $data ['stList'] = array (
  3968. 'rePrice' => $stList ['rePrice'],
  3969. 'agPrice' => $stList ['agPrice'],
  3970. 'skPrice' => ($noPassSum ['sum'])
  3971. );
  3972. $receiptList = $receipt->find ( array (
  3973. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3974. 'desc' => 'rid',
  3975. 'asArray' => true
  3976. ) );
  3977. $Locate = 0;
  3978. $roleId = 0;
  3979. $button = 0;
  3980. foreach ( $receiptList as $key => $value ) {
  3981. $receiptList[$key]['balance']='';
  3982. if($value['Rtype']==1){
  3983. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3984. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3985. }elseif($value['Rtype']==3){
  3986. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3987. $receiptList[$key]['payment']=$payment;
  3988. $receiptList[$key]['paymentABS']=abs($payment);
  3989. }
  3990. $receiptList [$key] ['Locate'] = $Locate;
  3991. $Locate ++;
  3992. $receiptList [$key] ['reviseDetail'] = array ();
  3993. if (! empty ( $value ['reviseDetail'] ))
  3994. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3995. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3996. $categoryDetil = $Lcategory->getOne ( array (
  3997. 'where' => 'cid=' . $value ['cid'],
  3998. 'asArray' => true
  3999. ) );
  4000. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4001. // 检测编辑状态
  4002. $verifyList = $verify->getOne ( array (
  4003. 'where' => 'vid=' . $value ['verify'],
  4004. 'asArray' => true
  4005. ) );
  4006. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4007. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4008. Doo::loadModel ( 'role' );
  4009. $role = new role ();
  4010. $flag = true;
  4011. $roleKey = 0;
  4012. $endStaffArray = array ();
  4013. $roleArrayCopy = array ();
  4014. foreach ( $verifyList as $k => $v ) {
  4015. // init verifyStaff
  4016. if ($v [1] == 'ROLE') {
  4017. if (! empty ( $verifyStaff )) {
  4018. $endStaffArray = end ( $verifyStaff );
  4019. // if ($v[0]==$endStaffArray['nextStaff']){
  4020. // $roleId=$v[0];
  4021. // }
  4022. }
  4023. $roleVerify = json_decode ( $v [3], true );
  4024. $roleKey = $k;
  4025. $roleArray = array ();
  4026. $rolename = $role->getOne ( array (
  4027. 'where' => 'rid=' . $v [0],
  4028. 'asArray' => true
  4029. ) );
  4030. foreach ( $roleVerify as $o => $p ) {
  4031. $staffID = explode ( '_', $p );
  4032. $staffInfo = $staff->getOne ( array (
  4033. 'where' => 'sid=' . $staffID [0],
  4034. 'asArray' => true
  4035. ) );
  4036. // print_r($staffID);
  4037. $exp = array (
  4038. 0 => $staffInfo ['sid'],
  4039. 1 => $staffID [1],
  4040. 2 => $staffInfo ['avatar'],
  4041. 'date' => '',
  4042. 'date' => '',
  4043. 'opinion' => '',
  4044. 'status' => '',
  4045. 'rolename' => $rolename ['name']
  4046. );
  4047. array_push ( $roleArray, $exp );
  4048. }
  4049. $roleArrayCopy [$v [0]] = $roleArray;
  4050. // $verifyList[$k]['roleArray']=$roleArray;
  4051. }
  4052. $verifyList [$k] ['date'] = "";
  4053. $verifyList [$k] ['opinion'] = "";
  4054. $verifyList [$k] ['status'] = "";
  4055. if (empty ( $verifyStaff )) {
  4056. $verifyList [$k] ['date'] = "";
  4057. $verifyList [$k] ['opinion'] = "";
  4058. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4059. $verifyList [$k] ['status'] = 4;
  4060. $flag = false;
  4061. }
  4062. } else {
  4063. foreach ( $verifyStaff as $m => $u ) {
  4064. if ($v [0] == $m) {
  4065. $verifyList [$k] ['date'] = $u ['date'];
  4066. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4067. $verifyList [$k] ['status'] = $u ['status'];
  4068. $flag = false;
  4069. break;
  4070. }
  4071. }
  4072. $endStaffArray = end ( $verifyStaff );
  4073. if (isset ( $endStaffArray ['ROLE'] )) {
  4074. } else {
  4075. // $endKey=key($verifyStaff);
  4076. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4077. // $button=4;
  4078. // $verifyList[$k]['status']=4;
  4079. // }
  4080. }
  4081. }
  4082. }
  4083. $rolename ['name'] = '';
  4084. if (! empty ( $roleId )) {
  4085. Doo::loadModel ( 'role' );
  4086. $role = new role ();
  4087. $rolename = $role->getOne ( array (
  4088. 'where' => 'rid=' . $roleId,
  4089. 'asArray' => true
  4090. ) );
  4091. }
  4092. if (! empty ( $verifyStaff ))
  4093. $endStaffArray = end ( $verifyStaff );
  4094. $KOP = false;
  4095. foreach ( $roleArrayCopy as $P => $A ) {
  4096. foreach ( $A as $MKI => $AVL ) {
  4097. if (! empty ( $verifyStaff )) {
  4098. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4099. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4100. $button = 4;
  4101. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4102. }
  4103. foreach ( $verifyStaff as $m => $u ) {
  4104. $AVLFK = $AVL [0] . '_R';
  4105. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4106. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4107. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4108. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4109. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4110. break;
  4111. }
  4112. }
  4113. } else {
  4114. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4115. $button = 4;
  4116. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4117. }
  4118. }
  4119. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4120. $KOP = true;
  4121. }
  4122. }
  4123. foreach ( $roleArrayCopy as $k => $v ) {
  4124. foreach ( $verifyList as $m => $n ) {
  4125. if ($n [0] == $k) {
  4126. array_splice ( $verifyList, $m, 1, $v );
  4127. }
  4128. }
  4129. }
  4130. $receiptList [$key] ['verifyList'] = $verifyList;
  4131. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4132. 'where' => 'sid=' . $value ['staff'],
  4133. 'asArray' => true
  4134. ) );
  4135. $receiptList [$key] ['button'] = $button;
  4136. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4137. if($value['version']==1){
  4138. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4139. }
  4140. }
  4141. // print_r($receiptList);die;
  4142. $mothHtml = "";
  4143. for($i = 1; $i <= 12; $i ++) {
  4144. if ($moth == $i)
  4145. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4146. else
  4147. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4148. }
  4149. $dateHtml = "";
  4150. $now = date ( "Y" );
  4151. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4152. if ($YEARD <= $now) {
  4153. $dateHtml .= '<option ';
  4154. if ($year == $YEARD) {
  4155. $dateHtml .= 'selected ';
  4156. }
  4157. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4158. }
  4159. }
  4160. $data ['dateHtml'] = $dateHtml;
  4161. $data ['mothHtml'] = $mothHtml;
  4162. $data ['receiptList'] = $receiptList;
  4163. $data ['memu'] = "receipt";
  4164. $data ['staff'] = $this->staff;
  4165. $data ['receiptMemu'] = 'expenses';
  4166. $data ['verifyId'] = $this->verifyId;
  4167. $data ['executeId'] = $this->executeId;
  4168. $data ['item'] = $item;
  4169. $data ['year'] = $year;
  4170. $this->render ( "/admin/expenses", $data );
  4171. }
  4172. function expensesCollect() {
  4173. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4174. Doo::loadModel ( 'receipt' );
  4175. $receipt = new receipt ();
  4176. Doo::loadModel ( 'L_category' );
  4177. $Lcategory = new L_category ();
  4178. Doo::loadModel ( 'verify' );
  4179. Doo::loadModel ( 'statistics' );
  4180. $statistics = new statistics ();
  4181. $verify = new verify ();
  4182. Doo::loadModel ( 'staff' );
  4183. $staff = new staff ();
  4184. Doo::loadModel ( 'loanReceipt' );
  4185. $loanReceipt = new loanReceipt ();
  4186. $receiptList = $receipt->find ( array (//去掉
  4187. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4188. 'desc' => 'rid',
  4189. 'asArray' => true
  4190. ) );
  4191. $loanList = $loanReceipt->find ( array (
  4192. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4193. 'desc' => 'rid',
  4194. 'asArray' => true
  4195. ) );
  4196. /*
  4197. * $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;
  4198. */
  4199. $data ['explanation'] = '';
  4200. if (! empty ( $loanList ))
  4201. $data ['explanation'] = $loanList [0] ['explanation'];
  4202. $Locate = 0;
  4203. $roleId = 0;
  4204. $button = 0;
  4205. foreach ( $receiptList as $key => $value ) {
  4206. $receiptList [$key] ['Locate'] = $Locate;
  4207. $Locate ++;
  4208. $receiptList [$key] ['reviseDetail'] = array ();
  4209. if (! empty ( $value ['reviseDetail'] ))
  4210. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4211. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4212. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4213. $categoryDetil = $Lcategory->getOne ( array (
  4214. 'where' => 'cid=' . $value ['cid'],
  4215. 'asArray' => true
  4216. ) );
  4217. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4218. // 检测编辑状态
  4219. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4220. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4221. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4222. else
  4223. $verifyList ['staff'] = $value ['verifyBreakup'];
  4224. } else
  4225. $verifyList = $verify->getOne ( array (
  4226. 'where' => 'vid=' . $value ['verify'],
  4227. 'asArray' => true
  4228. ) );
  4229. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4230. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4231. Doo::loadModel ( 'role' );
  4232. $role = new role ();
  4233. $flag = true;
  4234. $roleKey = 0;
  4235. $endStaffArray = array ();
  4236. $roleArrayCopy = array ();
  4237. foreach ( $verifyList as $k => $v ) {
  4238. // init verifyStaff
  4239. if ($v [1] == 'ROLE') {
  4240. if (! empty ( $verifyStaff )) {
  4241. $endStaffArray = end ( $verifyStaff );
  4242. // if ($v[0]==$endStaffArray['nextStaff']){
  4243. // $roleId=$v[0];
  4244. // }
  4245. }
  4246. $roleVerify = json_decode ( $v [3], true );
  4247. $roleKey = $k;
  4248. $roleArray = array ();
  4249. $rolename = $role->getOne ( array (
  4250. 'where' => 'rid=' . $v [0],
  4251. 'asArray' => true
  4252. ) );
  4253. foreach ( $roleVerify as $o => $p ) {
  4254. $staffID = explode ( '_', $p );
  4255. $staffInfo = $staff->getOne ( array (
  4256. 'where' => 'sid=' . $staffID [0],
  4257. 'asArray' => true
  4258. ) );
  4259. // print_r($staffID);
  4260. $exp = array (
  4261. 0 => $staffInfo ['sid'],
  4262. 1 => $staffID [1],
  4263. 2 => $staffInfo ['avatar'],
  4264. 'date' => '',
  4265. 'date' => '',
  4266. 'opinion' => '',
  4267. 'status' => '',
  4268. 'rolename' => $rolename ['name']
  4269. );
  4270. array_push ( $roleArray, $exp );
  4271. }
  4272. $roleArrayCopy [$v [0]] = $roleArray;
  4273. // $verifyList[$k]['roleArray']=$roleArray;
  4274. }
  4275. $verifyList [$k] ['date'] = "";
  4276. $verifyList [$k] ['opinion'] = "";
  4277. $verifyList [$k] ['status'] = "";
  4278. if (empty ( $verifyStaff )) {
  4279. $verifyList [$k] ['date'] = "";
  4280. $verifyList [$k] ['opinion'] = "";
  4281. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4282. $verifyList [$k] ['status'] = 4;
  4283. $flag = false;
  4284. }
  4285. } else {
  4286. foreach ( $verifyStaff as $m => $u ) {
  4287. if ($v [0] == $m) {
  4288. $verifyList [$k] ['date'] = $u ['date'];
  4289. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4290. $verifyList [$k] ['status'] = $u ['status'];
  4291. $flag = false;
  4292. break;
  4293. }
  4294. }
  4295. $endStaffArray = end ( $verifyStaff );
  4296. if (isset ( $endStaffArray ['ROLE'] )) {
  4297. } else {
  4298. // $endKey=key($verifyStaff);
  4299. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4300. // $button=4;
  4301. // $verifyList[$k]['status']=4;
  4302. // }
  4303. }
  4304. }
  4305. }
  4306. $rolename ['name'] = '';
  4307. if (! empty ( $roleId )) {
  4308. Doo::loadModel ( 'role' );
  4309. $role = new role ();
  4310. $rolename = $role->getOne ( array (
  4311. 'where' => 'rid=' . $roleId,
  4312. 'asArray' => true
  4313. ) );
  4314. }
  4315. if (! empty ( $verifyStaff ))
  4316. $endStaffArray = end ( $verifyStaff );
  4317. $KOP = false;
  4318. foreach ( $roleArrayCopy as $P => $A ) {
  4319. foreach ( $A as $MKI => $AVL ) {
  4320. if (! empty ( $verifyStaff )) {
  4321. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4322. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4323. $button = 4;
  4324. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4325. }
  4326. foreach ( $verifyStaff as $m => $u ) {
  4327. $AVLFK = $AVL [0] . '_R';
  4328. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4329. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4330. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4331. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4332. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4333. break;
  4334. }
  4335. }
  4336. } else {
  4337. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4338. $button = 4;
  4339. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4340. }
  4341. }
  4342. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4343. $KOP = true;
  4344. }
  4345. }
  4346. foreach ( $roleArrayCopy as $k => $v ) {
  4347. foreach ( $verifyList as $m => $n ) {
  4348. if ($n [0] == $k) {
  4349. array_splice ( $verifyList, $m, 1, $v );
  4350. }
  4351. }
  4352. }
  4353. // 费用执行人相关数据
  4354. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4355. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4356. foreach ( $executeCopy as $k => $v ) {
  4357. $executeCopy [$k] ['date'] = '';
  4358. $executeCopy [$k] ['opinion'] = '';
  4359. $executeCopy [$k] ['status'] = '';
  4360. if (! empty ( $executeStaff ))
  4361. foreach ( $executeStaff as $m => $u ) {
  4362. if ($v [0] == $m) {
  4363. $executeCopy [$k] ['date'] = $u ['date'];
  4364. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4365. $executeCopy [$k] ['status'] = $u ['status'];
  4366. break;
  4367. }
  4368. }
  4369. }
  4370. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4371. $receiptList [$key] ['verifyList'] = $verifyList;
  4372. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4373. 'where' => 'sid=' . $value ['staff'],
  4374. 'asArray' => true
  4375. ) );
  4376. $receiptList [$key] ['button'] = $button;
  4377. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4378. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4379. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4380. $receiptList [$key] ['relust'] = $relust;
  4381. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4382. }
  4383. Doo::loadModel ( 'enclosur' );
  4384. $enclosur = new enclosur ();
  4385. $enclosurList = $enclosur->find ( array (
  4386. 'where' => 'rid=' . $rid,
  4387. 'asArray' => true
  4388. ) );
  4389. $enclosurHtml = '';
  4390. foreach ( $enclosurList as $value ) {
  4391. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4392. }
  4393. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  4394. $data ['enclosurHtml'] = $enclosurHtml;
  4395. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4396. if($receiptList[0]['version']==1){
  4397. require "protected/class/comm_cld.php";
  4398. $receiptList=makeReceiptDataVersion1($receiptList);
  4399. }
  4400. $data ['receiptList'] = $receiptList;
  4401. $data ['memu'] = "receipt";
  4402. $data ['staff'] = $this->staff;
  4403. $data ['receiptMemu'] = 'expenses';
  4404. $data ['verifyId'] = $this->verifyId;
  4405. $data ['executeId'] = $this->executeId;
  4406. if($receiptList[0]['version']==1){
  4407. $this->render ( "/fee/detail/receipt_compatible", $data );
  4408. die;
  4409. }
  4410. if($receiptList[0]['receiptClass']==2){
  4411. if(!empty($receiptList[0]['itinerary2'])){
  4412. $this->render ( "/receipt/feeTraveDetail2", $data );
  4413. }else{
  4414. $this->render ( "/receipt/feeTraveDetail", $data );
  4415. }
  4416. }else{
  4417. $this->render ( "/admin/expensesCollect", $data );
  4418. }
  4419. }
  4420. function approvalExpenses() {
  4421. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4422. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4423. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4424. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4425. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4426. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4427. // echo $rdate;
  4428. if (empty ( $status ))
  4429. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4430. $page_size = 8;
  4431. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4432. $vidList = array ();
  4433. $button = 0;
  4434. Doo::loadModel ( 'verify' );
  4435. $verify = new verify ();
  4436. Doo::loadModel ( 'receipt' );
  4437. $receipt = new receipt ();
  4438. Doo::loadModel ( 'staff' );
  4439. $staff = new staff ();
  4440. Doo::loadModel ( 'L_category' );
  4441. $Lcategory = new L_category ();
  4442. // user verify ID
  4443. $verifyDetail = $verify->find ( array (
  4444. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4445. 'asArray' => true
  4446. ) );
  4447. foreach ( $verifyDetail as $key => $value ) {
  4448. array_push ( $vidList, $value ['vid'] );
  4449. }
  4450. $vid = implode ( ",", $vidList );
  4451. if (empty ( $verifyDetail )){
  4452. $vid = 0;
  4453. }
  4454. $dateCondition = " ";
  4455. // if (! empty ( $month ))
  4456. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4457. if ($status == 'done' || $status == 'termination') {
  4458. if (! empty ( $year )) {
  4459. $dateCondition = " and Year(pastDate) =" . $year;
  4460. if (! empty ( $month ))
  4461. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4462. }
  4463. } elseif ($status == 'finish') {
  4464. if (! empty ( $year )) {
  4465. $dateCondition = " and Year(pastDate) =" . $year;
  4466. if (! empty ( $month ))
  4467. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4468. }
  4469. }
  4470. // date ( 'Y-m' )
  4471. // if (! empty ( $rdate ) && $status == 'done')
  4472. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4473. // elseif (! empty ( $rdate ))
  4474. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4475. $categoryList = $Lcategory->find ( array (
  4476. 'asArray' => true
  4477. ) );
  4478. $staffList = $staff->find ( array (
  4479. 'where' => 'cid=' . $cid,
  4480. 'asArray' => true
  4481. ) );
  4482. $cateCondition = "";
  4483. $staffCondition = "";
  4484. $approvalCondition = "";
  4485. if (! empty ( $cid )) {
  4486. $cateCondition = ' and cid=' . $cid;
  4487. }
  4488. if (! empty ( $sid )) {
  4489. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4490. $cateCondition = "";
  4491. }
  4492. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4493. if ($status == 'pendApproval') {
  4494. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4495. }
  4496. if ($status == 'ongoing') {
  4497. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4498. }
  4499. if ($status == 'done') {
  4500. $approvalCondition = ' and (status=8 or status=9 ) ';
  4501. }
  4502. if ($status == 'termination') {
  4503. $approvalCondition = " and status=3";
  4504. }
  4505. if ($status == 'finish') {
  4506. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4507. }
  4508. if($status == 'loan'){
  4509. $approvalCondition = " and (status=8 or status=7) and Rtype=1";
  4510. }
  4511. $pageinfo ['page'] = array (
  4512. 'previous' => ''
  4513. );
  4514. if(!empty($receiptOrder)){
  4515. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4516. $receiptList = $receipt->find ( array ( // $dateCondition
  4517. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4518. 'desc' => 'rid',
  4519. 'asArray' => true
  4520. ) );
  4521. }else{
  4522. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4523. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4524. $receiptList = $receipt->find ( array ( // $dateCondition.
  4525. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4526. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4527. 'desc' => 'rid',
  4528. 'asArray' => true
  4529. ) );
  4530. } else {
  4531. $receiptList = $receipt->find ( array ( // $dateCondition
  4532. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4533. 'desc' => 'rid',
  4534. 'asArray' => true
  4535. ) );
  4536. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4537. }
  4538. }
  4539. $rLRes = $receipt->find ( array (
  4540. '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 . ')',
  4541. 'desc' => 'rid',
  4542. 'asArray' => true
  4543. ) );
  4544. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4545. // print_r($receiptList);
  4546. Doo::loadClass ( 'XDeode' );
  4547. $XDeode = new XDeode ( 7 );
  4548. $XDeode9 = new XDeode ( 9 );
  4549. $Locate = 0;
  4550. //
  4551. $reportList = $reportCateList = array ();
  4552. foreach ( $receiptList as $key => $value ) {
  4553. $receiptList [$key] ['rid_cld'] = $XDeode9->encode ( $value ['rid'] );
  4554. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4555. $receiptList [$key] ['Locate'] = $Locate;
  4556. $Locate ++;
  4557. $receiptList [$key] ['reviseDetail'] = array ();
  4558. if (! empty ( $value ['reviseDetail'] ))
  4559. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4560. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4561. $categoryDetil = $Lcategory->getOne ( array (
  4562. 'where' => 'cid=' . $value ['cid'],
  4563. 'asArray' => true
  4564. ) );
  4565. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4566. $verifyList = $verify->getOne ( array (
  4567. 'where' => 'vid=' . $value ['verify'],
  4568. 'asArray' => true
  4569. ) );
  4570. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4571. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4572. foreach ( $verifyList as $k => $v ) {
  4573. // init verifyStaff
  4574. $verifyList [$k] ['date'] = "";
  4575. $verifyList [$k] ['opinion'] = "";
  4576. $verifyList [$k] ['status'] = "";
  4577. if (empty ( $verifyStaff )) {
  4578. $verifyList [$k] ['date'] = "";
  4579. $verifyList [$k] ['opinion'] = "";
  4580. if ($v [0] == $this->staff [0] ['sid']) {
  4581. $verifyList [$k] ['status'] = 4;
  4582. $button = 4;
  4583. }
  4584. } else {
  4585. $flag = true;
  4586. foreach ( $verifyStaff as $m => $u ) {
  4587. if ($v [0] == $m) {
  4588. $verifyList [$k] ['date'] = $u ['date'];
  4589. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4590. $verifyList [$k] ['status'] = $u ['status'];
  4591. $flag = false;
  4592. break;
  4593. }
  4594. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4595. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4596. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4597. }
  4598. if ($flag) { // 检测可编辑
  4599. if ($v [0] == $this->staff [0] ['sid']) {
  4600. $verifyList [$k] ['status'] = 4;
  4601. $button = 4;
  4602. }
  4603. }
  4604. }
  4605. }
  4606. $receiptList [$key] ['verifyList'] = $verifyList;
  4607. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4608. 'where' => 'sid=' . $value ['staff'],
  4609. 'asArray' => true
  4610. ) );
  4611. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4612. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4613. $receiptList [$key] ['button'] = $button;
  4614. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4615. //获得培训班结算RID 借款费用--已经锁定
  4616. if($value['status']==10){
  4617. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4618. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4619. }
  4620. if($value['version']==1){
  4621. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4622. }
  4623. }
  4624. $reportList = array_unique ( $reportList );
  4625. $reportHtml = '';
  4626. foreach ( $reportList as $key => $value ) {
  4627. $v = explode ( "-", $value );
  4628. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4629. }
  4630. // print_r($reportList)
  4631. $data ['reportHtml'] = $reportHtml;
  4632. $reportCateList = array_unique ( $reportCateList );
  4633. $reportCateHtml = '';
  4634. foreach ( $reportCateList as $key => $value ) {
  4635. $v = explode ( "-", $value );
  4636. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4637. }
  4638. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4639. $data ['reportCateHtml'] = $reportCateHtml;
  4640. // print_r($receiptList);die;
  4641. // $data['verifyDetail']=$verifyDetail;
  4642. $mothHtml = "";
  4643. for($i = 1; $i <= 12; $i ++) {
  4644. if ($month == $i)
  4645. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4646. else
  4647. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4648. }
  4649. $data ['mothHtml'] = $mothHtml;
  4650. $dateHtml = "";
  4651. $now = date ( "Y" );
  4652. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4653. if ($YEARD <= $now) {
  4654. $dateHtml .= '<option ';
  4655. if ($year == $YEARD) {
  4656. $dateHtml .= 'selected ';
  4657. }
  4658. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4659. }
  4660. }
  4661. $data ['dateHtml'] = $dateHtml;
  4662. $data ['page'] = $pageinfo;
  4663. $data ['receiptList'] = $receiptList;
  4664. $data ['receiptApprovalCount'] = count ( $rLRes );
  4665. $data ['status'] = $status;
  4666. $data ['year'] = $year;
  4667. $data ['month'] = $month;
  4668. $data ['categoryList'] = $categoryList;
  4669. $data ['staffList'] = $staffList;
  4670. $data ['cid'] = $cid;
  4671. $data ['sid'] = $sid;
  4672. // print_r($receiptList);
  4673. $data['receiptOrder']=$receiptOrder;
  4674. $data ['memu'] = "receipt";
  4675. $data ['staff'] = $this->staff;
  4676. $data ['receiptMemu'] = 'approvalExpenses';
  4677. $data ['verifyId'] = $this->verifyId;
  4678. $data ['executeId'] = $this->executeId;
  4679. $this->render ( "/admin/approvalExpenses", $data );
  4680. }
  4681. private function _expensesDoc(){
  4682. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4683. Doo::loadClass ( 'XDeode' );
  4684. $XDeode = new XDeode ( 5 );
  4685. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4686. $rid = $XDeode->decode ( $rid );
  4687. if (! is_numeric ( $rid ))
  4688. die ( 'illegal request' );
  4689. Doo::loadModel ( 'receipt' );
  4690. $receipt = new receipt ();
  4691. Doo::loadModel ( 'L_category' );
  4692. $Lcategory = new L_category ();
  4693. Doo::loadModel ( 'verify' );
  4694. Doo::loadModel ( 'statistics' );
  4695. $statistics = new statistics ();
  4696. $verify = new verify ();
  4697. Doo::loadModel ( 'staff' );
  4698. $staff = new staff ();
  4699. Doo::loadModel ( 'loanReceipt' );
  4700. $loanReceipt = new loanReceipt ();
  4701. $receiptList = $receipt->find ( array (
  4702. 'where' => ' rid=' . $rid,
  4703. 'desc' => 'rid',
  4704. 'asArray' => true
  4705. ) );
  4706. $loanList = array ();
  4707. if (! empty ( $receiptList ))
  4708. $loanList = $loanReceipt->find ( array (
  4709. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4710. 'desc' => 'rid',
  4711. 'asArray' => true
  4712. ) );
  4713. $Locate = 0;
  4714. $roleId = 0;
  4715. $button = 0;
  4716. foreach ( $loanList as $key => $value ) {
  4717. $loanList [$key] ['Locate'] = $Locate;
  4718. $Locate ++;
  4719. $loanList [$key] ['reviseDetail'] = array ();
  4720. if (! empty ( $value ['reviseDetail'] ))
  4721. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4722. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4723. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4724. $categoryDetil = $Lcategory->getOne ( array (
  4725. 'where' => 'cid=' . $value ['cid'],
  4726. 'asArray' => true
  4727. ) );
  4728. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4729. // 检测编辑状态
  4730. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4731. $verifyList ['staff'] = $value ['verifyBreakup'];
  4732. else
  4733. $verifyList = $verify->getOne ( array (
  4734. 'where' => 'vid=' . $value ['verify'],
  4735. 'asArray' => true
  4736. ) );
  4737. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4738. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4739. Doo::loadModel ( 'role' );
  4740. $role = new role ();
  4741. $flag = true;
  4742. $roleKey = 0;
  4743. $endStaffArray = array ();
  4744. $roleArrayCopy = array ();
  4745. foreach ( $verifyList as $k => $v ) {
  4746. // init verifyStaff
  4747. if ($v [1] == 'ROLE') {
  4748. if (! empty ( $verifyStaff )) {
  4749. $endStaffArray = end ( $verifyStaff );
  4750. // if ($v[0]==$endStaffArray['nextStaff']){
  4751. // $roleId=$v[0];
  4752. // }
  4753. }
  4754. $roleVerify = json_decode ( $v [3], true );
  4755. $roleKey = $k;
  4756. $roleArray = array ();
  4757. $rolename = $role->getOne ( array (
  4758. 'where' => 'rid=' . $v [0],
  4759. 'asArray' => true
  4760. ) );
  4761. foreach ( $roleVerify as $o => $p ) {
  4762. $staffID = explode ( '_', $p );
  4763. $staffInfo = $staff->getOne ( array (
  4764. 'where' => 'sid=' . $staffID [0],
  4765. 'asArray' => true
  4766. ) );
  4767. // print_r($staffID);
  4768. $exp = array (
  4769. 0 => $staffInfo ['sid'],
  4770. 1 => $staffID [1],
  4771. 2 => $staffInfo ['avatar'],
  4772. 'date' => '',
  4773. 'date' => '',
  4774. 'opinion' => '',
  4775. 'status' => '',
  4776. 'rolename' => $rolename ['name']
  4777. );
  4778. array_push ( $roleArray, $exp );
  4779. }
  4780. $roleArrayCopy [$v [0]] = $roleArray;
  4781. // $verifyList[$k]['roleArray']=$roleArray;
  4782. }
  4783. $verifyList [$k] ['date'] = "";
  4784. $verifyList [$k] ['opinion'] = "";
  4785. $verifyList [$k] ['status'] = "";
  4786. if (empty ( $verifyStaff )) {
  4787. $verifyList [$k] ['date'] = "";
  4788. $verifyList [$k] ['opinion'] = "";
  4789. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4790. $verifyList [$k] ['status'] = 4;
  4791. $flag = false;
  4792. }
  4793. } else {
  4794. foreach ( $verifyStaff as $m => $u ) {
  4795. if ($v [0] == $m) {
  4796. $verifyList [$k] ['date'] = $u ['date'];
  4797. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4798. $verifyList [$k] ['status'] = $u ['status'];
  4799. $flag = false;
  4800. break;
  4801. }
  4802. }
  4803. $endStaffArray = end ( $verifyStaff );
  4804. if (isset ( $endStaffArray ['ROLE'] )) {
  4805. } else {
  4806. // $endKey=key($verifyStaff);
  4807. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4808. // $button=4;
  4809. // $verifyList[$k]['status']=4;
  4810. // }
  4811. }
  4812. }
  4813. }
  4814. $rolename ['name'] = '';
  4815. if (! empty ( $roleId )) {
  4816. Doo::loadModel ( 'role' );
  4817. $role = new role ();
  4818. $rolename = $role->getOne ( array (
  4819. 'where' => 'rid=' . $roleId,
  4820. 'asArray' => true
  4821. ) );
  4822. }
  4823. if (! empty ( $verifyStaff ))
  4824. $endStaffArray = end ( $verifyStaff );
  4825. $KOP = false;
  4826. foreach ( $roleArrayCopy as $P => $A ) {
  4827. foreach ( $A as $MKI => $AVL ) {
  4828. if (! empty ( $verifyStaff )) {
  4829. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4830. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4831. $button = 4;
  4832. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4833. }
  4834. foreach ( $verifyStaff as $m => $u ) {
  4835. $AVLFK = $AVL [0] . '_R';
  4836. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4837. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4838. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4839. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4840. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4841. break;
  4842. }
  4843. }
  4844. } else {
  4845. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4846. $button = 4;
  4847. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4848. }
  4849. }
  4850. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4851. $KOP = true;
  4852. }
  4853. }
  4854. foreach ( $roleArrayCopy as $k => $v ) {
  4855. foreach ( $verifyList as $m => $n ) {
  4856. if ($n [0] == $k) {
  4857. array_splice ( $verifyList, $m, 1, $v );
  4858. }
  4859. }
  4860. }
  4861. $loanList [$key] ['verifyList'] = $verifyList;
  4862. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4863. 'where' => 'sid=' . $value ['staff'],
  4864. 'asArray' => true
  4865. ) );
  4866. $loanList [$key] ['button'] = $button;
  4867. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4868. }
  4869. $data ['loanList'] = $loanList;
  4870. $data ['explanation'] = '';
  4871. if (! empty ( $loanList )){
  4872. $data ['explanation'] = $loanList [0] ['explanation'];
  4873. }
  4874. //print_r($loanList);
  4875. $Locate = 0;
  4876. $roleId = 0;
  4877. $button = 0;
  4878. foreach ( $receiptList as $key => $value ) {
  4879. $receiptList [$key] ['Locate'] = $Locate;
  4880. $Locate ++;
  4881. $receiptList [$key] ['reviseDetail'] = array ();
  4882. if (! empty ( $value ['reviseDetail'] ))
  4883. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4884. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4885. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4886. $categoryDetil = $Lcategory->getOne ( array (
  4887. 'where' => 'cid=' . $value ['cid'],
  4888. 'asArray' => true
  4889. ) );
  4890. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4891. // 检测编辑状态
  4892. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4893. $verifyList ['staff'] = $value ['verifyBreakup'];
  4894. } else
  4895. $verifyList = $verify->getOne ( array (
  4896. 'where' => 'vid=' . $value ['verify'],
  4897. 'asArray' => true
  4898. ) );
  4899. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4900. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4901. Doo::loadModel ( 'role' );
  4902. $role = new role ();
  4903. if ($verifyList == NULL)
  4904. $verifyList = array ();
  4905. $flag = true;
  4906. $roleKey = 0;
  4907. $endStaffArray = array ();
  4908. $roleArrayCopy = array ();
  4909. foreach ( $verifyList as $k => $v ) {
  4910. // init verifyStaff
  4911. if ($v [1] == 'ROLE') {
  4912. if (! empty ( $verifyStaff )) {
  4913. $endStaffArray = end ( $verifyStaff );
  4914. // if ($v[0]==$endStaffArray['nextStaff']){
  4915. // $roleId=$v[0];
  4916. // }
  4917. }
  4918. $roleVerify = json_decode ( $v [3], true );
  4919. $roleKey = $k;
  4920. $roleArray = array ();
  4921. $rolename = $role->getOne ( array (
  4922. 'where' => 'rid=' . $v [0],
  4923. 'asArray' => true
  4924. ) );
  4925. foreach ( $roleVerify as $o => $p ) {
  4926. $staffID = explode ( '_', $p );
  4927. $staffInfo = $staff->getOne ( array (
  4928. 'where' => 'sid=' . $staffID [0],
  4929. 'asArray' => true
  4930. ) );
  4931. // print_r($staffID);
  4932. $exp = array (
  4933. 0 => $staffInfo ['sid'],
  4934. 1 => $staffID [1],
  4935. 2 => $staffInfo ['avatar'],
  4936. 'date' => '',
  4937. 'date' => '',
  4938. 'opinion' => '',
  4939. 'status' => '',
  4940. 'rolename' => $rolename ['name']
  4941. );
  4942. array_push ( $roleArray, $exp );
  4943. }
  4944. $roleArrayCopy [$v [0]] = $roleArray;
  4945. // $verifyList[$k]['roleArray']=$roleArray;
  4946. }
  4947. $verifyList [$k] ['date'] = "";
  4948. $verifyList [$k] ['opinion'] = "";
  4949. $verifyList [$k] ['status'] = "";
  4950. if (empty ( $verifyStaff )) {
  4951. $verifyList [$k] ['date'] = "";
  4952. $verifyList [$k] ['opinion'] = "";
  4953. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4954. $verifyList [$k] ['status'] = 4;
  4955. $flag = false;
  4956. }
  4957. } else {
  4958. foreach ( $verifyStaff as $m => $u ) {
  4959. if ($v [0] == $m) {
  4960. $verifyList [$k] ['date'] = $u ['date'];
  4961. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4962. $verifyList [$k] ['status'] = $u ['status'];
  4963. $flag = false;
  4964. break;
  4965. }
  4966. }
  4967. $endStaffArray = end ( $verifyStaff );
  4968. if (isset ( $endStaffArray ['ROLE'] )) {
  4969. } else {
  4970. // $endKey=key($verifyStaff);
  4971. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4972. // $button=4;
  4973. // $verifyList[$k]['status']=4;
  4974. // }
  4975. }
  4976. }
  4977. }
  4978. $FC = @$rolename ['name'];
  4979. $rolename ['name'] = '';
  4980. if (! empty ( $roleId )) {
  4981. Doo::loadModel ( 'role' );
  4982. $role = new role ();
  4983. $rolename = $role->getOne ( array (
  4984. 'where' => 'rid=' . $roleId,
  4985. 'asArray' => true
  4986. ) );
  4987. }
  4988. if (! empty ( $verifyStaff ))
  4989. $endStaffArray = end ( $verifyStaff );
  4990. $KOP = false;
  4991. foreach ( $roleArrayCopy as $P => $A ) {
  4992. foreach ( $A as $MKI => $AVL ) {
  4993. if (! empty ( $verifyStaff )) {
  4994. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4995. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4996. $button = 4;
  4997. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4998. }
  4999. foreach ( $verifyStaff as $m => $u ) {
  5000. $AVLFK = $AVL [0] . '_R';
  5001. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5002. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5003. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5004. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5005. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5006. break;
  5007. }
  5008. }
  5009. } else {
  5010. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5011. $button = 4;
  5012. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5013. }
  5014. }
  5015. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5016. $KOP = true;
  5017. }
  5018. }
  5019. foreach ( $roleArrayCopy as $k => $v ) {
  5020. foreach ( $verifyList as $m => $n ) {
  5021. if ($n [0] == $k) {
  5022. array_splice ( $verifyList, $m, 1, $v );
  5023. }
  5024. }
  5025. }
  5026. // 费用执行人相关数据
  5027. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5028. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5029. foreach ( $executeCopy as $k => $v ) {
  5030. $executeCopy [$k] ['date'] = '';
  5031. $executeCopy [$k] ['opinion'] = '';
  5032. $executeCopy [$k] ['status'] = '';
  5033. if (! empty ( $executeStaff ))
  5034. foreach ( $executeStaff as $m => $u ) {
  5035. if ($v [0] == $m) {
  5036. $executeCopy [$k] ['date'] = $u ['date'];
  5037. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5038. $executeCopy [$k] ['status'] = $u ['status'];
  5039. break;
  5040. }
  5041. }
  5042. }
  5043. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5044. // print_r($verifyList);
  5045. $receiptList [$key] ['verifyList'] = $verifyList;
  5046. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5047. 'where' => 'sid=' . $value ['staff'],
  5048. 'asArray' => true
  5049. ) );
  5050. $receiptList [$key] ['button'] = $button;
  5051. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5052. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5053. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5054. $receiptList [$key] ['relust'] = $relust;
  5055. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5056. }
  5057. // print_r($receiptList);
  5058. // 获取审批日志
  5059. Doo::loadModel ( 'receiptLog' );
  5060. $receiptLog = new receiptLog ();
  5061. $rlList = array ();
  5062. $rlInfo = $receiptLog->getOne ( array (
  5063. 'where' => 'rid=' . $rid . ' and status=4',
  5064. 'asArray' => true
  5065. ) );
  5066. // $tijdate = $receiptLog->getOne ( array (
  5067. // 'where' => 'rid=' . $rid . ' and status=2',
  5068. // 'asc' => 'rlid',
  5069. // 'asArray' => true
  5070. // ) );
  5071. if (! empty ( $rlInfo )) {
  5072. $rlList = $receiptLog->find ( array (
  5073. 'where' => 'rid=' . $rid,
  5074. 'asc' => 'rlid',
  5075. 'asArray' => true
  5076. ) );
  5077. }
  5078. $RN=array();
  5079. if (!empty( $rolename ['staff'])){
  5080. $RN = @json_decode ( $rolename ['staff'] );
  5081. }
  5082. //
  5083. foreach ( $rlList as $key => $value ) {
  5084. $rlList [$key] ['rolename'] = '';
  5085. foreach ( $RN as $k => $v ) {
  5086. $id = explode ( "_", $v );
  5087. if ($id [0] == $value ['uid']) {
  5088. $rlList [$key] ['rolename'] = $FC;
  5089. break;
  5090. }
  5091. }
  5092. }
  5093. Doo::loadModel ( 'enclosur' );
  5094. $enclosur = new enclosur ();
  5095. $enclosurList = $enclosur->find ( array (
  5096. 'where' => 'rid=' . $rid,
  5097. 'asArray' => true
  5098. ) );
  5099. $enclosurHtml = '';
  5100. foreach ( $enclosurList as $value ) {
  5101. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5102. }
  5103. if($receiptList[0]['version']==1){
  5104. require "protected/class/comm_cld.php";
  5105. $receiptList=makeReceiptDataVersion1($receiptList);
  5106. }
  5107. $data ['enclosurHtml'] = $enclosurHtml;
  5108. $receiptList [0] ['rlList'] = $rlList;
  5109. $data ['receiptList'] = $receiptList;
  5110. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5111. // print_r($receiptList);
  5112. $data ['memu'] = "receipt";
  5113. $data ['staff'] = $this->staff;
  5114. $data ['receiptMemu'] = 'approvalExpenses';
  5115. $data ['verifyId'] = $this->verifyId;
  5116. $data ['executeId'] = $this->executeId;
  5117. return $data;
  5118. }
  5119. function expensesDoc() {
  5120. $data=$this->_expensesDoc();
  5121. if($data['receiptList'][0]['version']==1){
  5122. $this->render ( "/fee/detail/receipt_compatible", $data );
  5123. die;
  5124. }
  5125. if(!empty($data['receiptList'][0]['itinerary2'])){
  5126. $this->render ( "/receipt/feeTraveView", $data );
  5127. }else{
  5128. $this->render ( "/admin/expensesDoc", $data );
  5129. }
  5130. }
  5131. function expensesDocPrint(){
  5132. $data=$this->_expensesDoc();
  5133. if($data['receiptList'][0]['version']==1){
  5134. $this->render ( "/fee/detail/receiptPrint_compatible", $data );
  5135. die;
  5136. }
  5137. $this->render ( "/receipt/expensesDocPrint", $data );
  5138. }
  5139. function expensesEdi() {
  5140. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5141. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5142. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5143. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5144. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5145. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5146. if (empty ( $status ))
  5147. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5148. $vidList = array ();
  5149. $button = 0;
  5150. Doo::loadModel ( 'verify' );
  5151. Doo::loadModel ( 'receipt' );
  5152. Doo::loadModel ( 'staff' );
  5153. $staff = new staff ();
  5154. $receipt = new receipt ();
  5155. $verify = new verify ();
  5156. Doo::loadModel ( 'L_category' );
  5157. $Lcategory = new L_category ();
  5158. Doo::loadModel ( 'enclosur' );
  5159. $enclosur = new enclosur ();
  5160. // user verify ID
  5161. $verifyDetail = $verify->find ( array (
  5162. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5163. 'asArray' => true
  5164. ) );
  5165. foreach ( $verifyDetail as $key => $value ) {
  5166. array_push ( $vidList, $value ['vid'] );
  5167. }
  5168. $vid = implode ( ",", $vidList );
  5169. if (empty ( $verifyDetail ))
  5170. $vid = 0;
  5171. $categoryList = $Lcategory->find ( array (
  5172. 'asArray' => true
  5173. ) );
  5174. $staffList = $staff->find ( array (
  5175. 'where' => 'cid=' . $cid,
  5176. 'asArray' => true
  5177. ) );
  5178. $ap = "";
  5179. if ($status == 4) {
  5180. $ap = 4;
  5181. $status = 2;
  5182. }
  5183. // get Receipt By verifyID status 2
  5184. $receiptList = $receipt->find ( array (
  5185. 'where' => 'rid =' . $rid . ' and status=2',
  5186. 'desc' => 'rid',
  5187. 'asArray' => true
  5188. ) );
  5189. if (empty ( $receiptList )) {
  5190. die ( 'illegal request' );
  5191. }
  5192. $Locate = 0;
  5193. $roleId = 0;
  5194. if ($ap == 4)
  5195. $status = 4;
  5196. foreach ( $receiptList as $key => $value ) {
  5197. $receiptList [$key] ['Locate'] = $Locate;
  5198. $Locate ++;
  5199. $receiptList [$key] ['reviseDetail'] = array ();
  5200. if (! empty ( $value ['reviseDetail'] ))
  5201. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5202. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5203. $categoryDetil = $Lcategory->getOne ( array (
  5204. 'where' => 'cid=' . $value ['cid'],
  5205. 'asArray' => true
  5206. ) );
  5207. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5208. // 检测编辑状态
  5209. $verifyList = $verify->getOne ( array (
  5210. 'where' => 'vid=' . $value ['verify'],
  5211. 'asArray' => true
  5212. ) );
  5213. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5214. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5215. Doo::loadModel ( 'role' );
  5216. $role = new role ();
  5217. // print_r($verifyList);
  5218. $flag = true;
  5219. $roleKey = 0;
  5220. $endStaffArray = array ();
  5221. $roleArrayCopy = array ();
  5222. foreach ( $verifyList as $k => $v ) {
  5223. // init verifyStaff
  5224. if ($v [1] == 'ROLE') {
  5225. if (! empty ( $verifyStaff )) {
  5226. $endStaffArray = end ( $verifyStaff );
  5227. if ($v [0] == $endStaffArray ['nextStaff']) {
  5228. $roleId = $v [0];
  5229. }
  5230. }
  5231. $roleVerify = json_decode ( $v [3], true );
  5232. $roleKey = $k;
  5233. $roleArray = array ();
  5234. $rolename = $role->getOne ( array (
  5235. 'where' => 'rid=' . $v [0],
  5236. 'asArray' => true
  5237. ) );
  5238. foreach ( $roleVerify as $o => $p ) {
  5239. $staffID = explode ( '_', $p );
  5240. $staffInfo = $staff->getOne ( array (
  5241. 'where' => 'sid=' . $staffID [0],
  5242. 'asArray' => true
  5243. ) );
  5244. // print_r($staffID);
  5245. $exp = array (
  5246. 0 => $staffInfo ['sid'],
  5247. 1 => $staffID [1],
  5248. 2 => $staffInfo ['avatar'],
  5249. 'date' => '',
  5250. 'date' => '',
  5251. 'opinion' => '',
  5252. 'status' => '',
  5253. 'rolename' => $rolename ['name']
  5254. );
  5255. array_push ( $roleArray, $exp );
  5256. }
  5257. $roleArrayCopy [$v [0]] = $roleArray;
  5258. // $verifyList[$k]['roleArray']=$roleArray;
  5259. }
  5260. // print_r($roleArray);
  5261. $verifyList [$k] ['date'] = "";
  5262. $verifyList [$k] ['opinion'] = "";
  5263. $verifyList [$k] ['status'] = "";
  5264. if (empty ( $verifyStaff )) {
  5265. $verifyList [$k] ['date'] = "";
  5266. $verifyList [$k] ['opinion'] = "";
  5267. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5268. $verifyList [$k] ['status'] = 4;
  5269. $button = 4;
  5270. $flag = false;
  5271. }
  5272. } else {
  5273. foreach ( $verifyStaff as $m => $u ) {
  5274. if ($v [0] == $m) {
  5275. $verifyList [$k] ['date'] = $u ['date'];
  5276. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5277. $verifyList [$k] ['status'] = $u ['status'];
  5278. $flag = false;
  5279. break;
  5280. }
  5281. }
  5282. $endStaffArray = end ( $verifyStaff );
  5283. if (isset ( $endStaffArray ['ROLE'] )) {
  5284. } else {
  5285. $endKey = key ( $verifyStaff );
  5286. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5287. $button = 4;
  5288. $verifyList [$k] ['status'] = 4;
  5289. }
  5290. }
  5291. }
  5292. }
  5293. $rolename ['name'] = '';
  5294. if (! empty ( $roleId )) {
  5295. Doo::loadModel ( 'role' );
  5296. $role = new role ();
  5297. $rolename = $role->getOne ( array (
  5298. 'where' => 'rid=' . $roleId,
  5299. 'asArray' => true
  5300. ) );
  5301. }
  5302. if (! empty ( $verifyStaff ))
  5303. $endStaffArray = end ( $verifyStaff );
  5304. $KOP = false;
  5305. foreach ( $roleArrayCopy as $P => $A ) {
  5306. foreach ( $A as $MKI => $AVL ) {
  5307. if (! empty ( $verifyStaff )) {
  5308. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5309. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5310. $button = 4;
  5311. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5312. }
  5313. foreach ( $verifyStaff as $m => $u ) {
  5314. $AVLFK = $AVL [0] . '_R';
  5315. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5316. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5317. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5318. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5319. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5320. break;
  5321. }
  5322. }
  5323. } else {
  5324. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5325. $button = 4;
  5326. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5327. }
  5328. }
  5329. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5330. $KOP = true;
  5331. }
  5332. }
  5333. // print_r($roleArrayCopy);
  5334. // echo $roleKey;
  5335. foreach ( $roleArrayCopy as $k => $v ) {
  5336. foreach ( $verifyList as $m => $n ) {
  5337. if ($n [0] == $k) {
  5338. array_splice ( $verifyList, $m, 1, $v );
  5339. }
  5340. }
  5341. }
  5342. $receiptList [$key] ['verifyList'] = $verifyList;
  5343. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5344. 'where' => 'sid=' . $value ['staff'],
  5345. 'asArray' => true
  5346. ) );
  5347. $receiptList [$key] ['button'] = $button;
  5348. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5349. }
  5350. // $data['verifyDetail']=$verifyDetail;
  5351. $mothHtml = "";
  5352. for($i = 1; $i <= 12; $i ++) {
  5353. if ($month == $i)
  5354. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5355. else
  5356. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5357. }
  5358. // 获取审批日志
  5359. Doo::loadModel ( 'receiptLog' );
  5360. $receiptLog = new receiptLog ();
  5361. $rlList = array ();
  5362. $rlInfo = $receiptLog->getOne ( array (
  5363. 'where' => 'rid=' . $rid . ' and status=4',
  5364. 'asArray' => true
  5365. ) );
  5366. $tijdate = $receiptLog->getOne ( array (
  5367. 'where' => 'rid=' . $rid . ' and status=2',
  5368. 'asc' => 'rlid',
  5369. 'asArray' => true
  5370. ) );
  5371. if (! empty ( $rlInfo )) {
  5372. $rlList = $receiptLog->find ( array (
  5373. 'where' => 'rid=' . $rid,
  5374. 'asc' => 'rlid',
  5375. 'asArray' => true
  5376. ) );
  5377. }
  5378. $receiptList [0] ['rlList'] = $rlList;
  5379. $enclosurList = $enclosur->find ( array (
  5380. 'where' => 'rid=' . $rid,
  5381. 'asArray' => true
  5382. ) );
  5383. $enclosurHtml = '';
  5384. foreach ( $enclosurList as $value ) {
  5385. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5386. }
  5387. // print_r($receiptList);
  5388. $data ['rid'] = $rid;
  5389. $data ['enclosurHtml'] = $enclosurHtml;
  5390. $data ['rolename'] = $rolename ['name'];
  5391. $data ['datetij'] = $tijdate ['date'];
  5392. $data ['mothHtml'] = $mothHtml;
  5393. $data ['receiptList'] = $receiptList;
  5394. $data ['receiptApprovalCount'] = count ( $receiptList );
  5395. $data ['status'] = $status;
  5396. $data ['year'] = $year;
  5397. $data ['categoryList'] = $categoryList;
  5398. $data ['staffList'] = $staffList;
  5399. $data ['cid'] = $cid;
  5400. $data ['sid'] = $sid;
  5401. $data ['ap'] = $ap;
  5402. $data ['memu'] = "receipt";
  5403. $data ['staff'] = $this->staff;
  5404. $data ['receiptMemu'] = 'approvalExpenses';
  5405. $data ['verifyId'] = $this->verifyId;
  5406. $data ['executeId'] = $this->executeId;
  5407. $this->render ( "/admin/expensesEdi", $data );
  5408. }
  5409. function expensesDefray() {
  5410. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5411. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5412. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5413. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5414. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5415. if (! empty ( $rid )) {
  5416. Doo::loadModel ( "verify" );
  5417. $verify = new verify ();
  5418. Doo::loadModel ( "receiptDetail" );
  5419. $receiptDetailObj = new receiptDetail ();
  5420. Doo::loadModel ( "itemStatistics" );
  5421. Doo::loadModel ( "statistics" );
  5422. $statistics = new statistics ();
  5423. $itemStatistics = new itemStatistics ();
  5424. Doo::loadModel ( "receipt" );
  5425. $receipt = new receipt ();
  5426. Doo::loadModel ( "loanReceipt" );
  5427. $loanReceipt = new loanReceipt ();
  5428. $receiptDetail = $receipt->getOne ( array (
  5429. 'where' => 'rid=' . $rid . ' and status=2 ',
  5430. 'asArray' => true
  5431. ) );
  5432. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5433. $nsflag = true;
  5434. foreach ( $nslist as $value ) {
  5435. if ($value == $this->staff ['0'] ['sid']) {
  5436. $nsflag = false;
  5437. break;
  5438. }
  5439. }
  5440. // print_r($nslist);die;
  5441. if (empty ( $receiptDetail ) || $nsflag)
  5442. return "/approvalExpenses/pendApproval";
  5443. $verifyDetail = $verify->getOne ( array (
  5444. 'where' => ' vid =' . $receiptDetail ['verify'],
  5445. 'asArray' => true
  5446. ) );
  5447. $verifyString = $verifyDetail ['staff'];
  5448. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5449. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5450. if (empty ( $opinion )) {
  5451. if ($status == 3)
  5452. $opinion = "终止";
  5453. else
  5454. $opinion = "同意支付";
  5455. }
  5456. $nowStaff = 0;
  5457. $nowStaffList = array ();
  5458. if (empty ( $verifyStaff )) {
  5459. // 还需加入是否已经进入角色审批
  5460. if ($verifyDetail [0] [1] == 'ROLE') {
  5461. // print_r($verifyDetail);echo "ddd";
  5462. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5463. foreach ( $vStaffString as $key => $value ) {
  5464. $staffK = explode ( "_", $value );
  5465. if ($staffK [0] != $this->staff [0] ['sid'])
  5466. array_push ( $nowStaffList, $staffK [0] );
  5467. }
  5468. // print_r($verifyDetail);
  5469. // die;
  5470. if (! empty ( $nowStaffList )) {
  5471. $nowStaff = implode ( ',', $nowStaffList );
  5472. $verifyStaff = array (
  5473. $this->staff [0] ['sid'] . "_R" => array (
  5474. 'date' => date ( 'Y-m-d' ),
  5475. 'opinion' => $opinion,
  5476. 'status' => $status,
  5477. 'nextStaff' => $verifyDetail [0] [0],
  5478. 'ROLE' => 1
  5479. )
  5480. );
  5481. } else {
  5482. $nowStaff = $verifyDetail [1] [0];
  5483. $verifyStaff = array (
  5484. $this->staff [0] ['sid'] . "_R" => array (
  5485. 'date' => date ( 'Y-m-d' ),
  5486. 'opinion' => $opinion,
  5487. 'status' => $status,
  5488. 'nextStaff' => $verifyDetail [1] [0]
  5489. )
  5490. );
  5491. }
  5492. } else {
  5493. if ($verifyDetail [1] [1] == 'ROLE') {
  5494. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5495. // echo "dd";
  5496. foreach ( $vStaffString as $key => $value ) {
  5497. $staffK = explode ( "_", $value );
  5498. array_push ( $nowStaffList, $staffK [0] );
  5499. }
  5500. $nowStaff = implode ( ',', $nowStaffList );
  5501. $verifyStaff = array (
  5502. $this->staff [0] ['sid'] => array (
  5503. 'date' => date ( 'Y-m-d' ),
  5504. 'opinion' => $opinion,
  5505. 'status' => $status,
  5506. 'nextStaff' => $verifyDetail [1] [0],
  5507. 'ROLE' => 1
  5508. )
  5509. );
  5510. } else {
  5511. $nowStaff = $verifyDetail [1] [0];
  5512. $verifyStaff = array (
  5513. $this->staff [0] ['sid'] => array (
  5514. 'date' => date ( 'Y-m-d' ),
  5515. 'opinion' => $opinion,
  5516. 'status' => $status,
  5517. 'nextStaff' => $verifyDetail [1] [0]
  5518. )
  5519. );
  5520. }
  5521. }
  5522. if ($status == 3)
  5523. $verifyStaff = array (
  5524. 'final' => $status,
  5525. $this->staff [0] ['sid'] => array (
  5526. 'date' => date ( 'Y-m-d' ),
  5527. 'opinion' => $opinion,
  5528. 'status' => $status
  5529. )
  5530. );
  5531. $vStaffString = json_encode ( $verifyStaff );
  5532. $receipt->nowStaff = $nowStaff;
  5533. $receipt->verifyStaff = $vStaffString;
  5534. $loanReceipt->nowStaff = $nowStaff;
  5535. $loanReceipt->verifyStaff = $vStaffString;
  5536. } else {
  5537. $VS = end ( $verifyStaff );
  5538. // 非角色审批
  5539. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5540. $nextStaff = 0;
  5541. $roleSTF = false;
  5542. foreach ( $verifyDetail as $key => $value ) {
  5543. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5544. if (isset ( $verifyDetail [$key + 1] )) {
  5545. $nextStaff = $verifyDetail [$key + 1] [0];
  5546. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5547. $roleSTF = true;
  5548. }
  5549. break;
  5550. }
  5551. }
  5552. if (! $roleSTF) {
  5553. $nowStaff = $nextStaff;
  5554. $verifyStaff [$this->staff [0] ['sid']] = array (
  5555. 'date' => date ( 'Y-m-d' ),
  5556. 'opinion' => $opinion,
  5557. 'status' => $status,
  5558. 'nextStaff' => $nextStaff
  5559. );
  5560. } else {
  5561. // 获取角色下的所有用户ID
  5562. $nowStaffList = array ();
  5563. foreach ( $verifyDetail as $vfk ) {
  5564. if ($vfk [1] == 'ROLE') {
  5565. $vStaffString = json_decode ( $vfk [3] );
  5566. foreach ( $vStaffString as $key => $value ) {
  5567. $staffK = explode ( "_", $value );
  5568. array_push ( $nowStaffList, $staffK [0] );
  5569. }
  5570. }
  5571. }
  5572. $nowStaff = implode ( ',', $nowStaffList );
  5573. $verifyStaff [$this->staff [0] ['sid']] = array (
  5574. 'date' => date ( 'Y-m-d' ),
  5575. 'opinion' => $opinion,
  5576. 'status' => $status,
  5577. 'nextStaff' => $nextStaff,
  5578. 'ROLE' => 0
  5579. );
  5580. }
  5581. if ($status == 3) {
  5582. $verifyStaff ['final'] = $status;
  5583. $verifyStaff [$this->staff [0] ['sid']] = array (
  5584. 'date' => date ( 'Y-m-d' ),
  5585. 'opinion' => $opinion,
  5586. 'status' => $status
  5587. );
  5588. }
  5589. $vStaffString = json_encode ( $verifyStaff );
  5590. $receipt->nowStaff = $nowStaff;
  5591. $receipt->verifyStaff = $vStaffString;
  5592. $loanReceipt->nowStaff = $nowStaff;
  5593. $loanReceipt->verifyStaff = $vStaffString;
  5594. }
  5595. // 角色审批
  5596. if (isset ( $VS ['ROLE'] )) {
  5597. // 找出角色人 当前审批角色组
  5598. $verifyJSStaff = array ();
  5599. $nowStaffList2 = array ();
  5600. foreach ( $verifyDetail as $key => $value ) {
  5601. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5602. $verifyJSStaff = json_decode ( $value [3] );
  5603. foreach ( $verifyJSStaff as $m ) {
  5604. $staffK = explode ( "_", $m );
  5605. array_push ( $nowStaffList2, $staffK [0] );
  5606. }
  5607. // print_r($nowStaffList2);
  5608. }
  5609. }
  5610. $RoleVerifyStaff = array ();
  5611. foreach ( $verifyStaff as $key => $value ) {
  5612. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5613. foreach ( $nowStaffList2 as $m ) {
  5614. if ($key == $m . "_R")
  5615. $RoleVerifyStaff [$key] = $value;
  5616. }
  5617. }
  5618. }
  5619. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5620. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5621. // 下一个审批人ID
  5622. $nextStaff = 0;
  5623. $falg = false;
  5624. foreach ( $verifyDetail as $key => $value ) {
  5625. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5626. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5627. $falg = true;
  5628. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5629. $nowStaffList = array ();
  5630. foreach ( $vStaffString as $v ) {
  5631. $staffK = explode ( "_", $v );
  5632. array_push ( $nowStaffList, $staffK [0] );
  5633. }
  5634. $nowStaff = implode ( ',', $nowStaffList );
  5635. $nextStaff = $verifyDetail [$key + 1] [0];
  5636. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5637. $nextStaff = $verifyDetail [$key + 1] [0];
  5638. $nowStaff = $nextStaff;
  5639. } else
  5640. $nowStaff = '';
  5641. break;
  5642. }
  5643. }
  5644. if ($falg)
  5645. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5646. 'date' => date ( 'Y-m-d' ),
  5647. 'opinion' => $opinion,
  5648. 'status' => $status,
  5649. 'nextStaff' => $nextStaff,
  5650. 'ROLE' => 1
  5651. );
  5652. else
  5653. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5654. 'date' => date ( 'Y-m-d' ),
  5655. 'opinion' => $opinion,
  5656. 'status' => $status,
  5657. 'nextStaff' => $nextStaff
  5658. );
  5659. // print_r($verifyStaff);
  5660. // echo $nowStaff;die;
  5661. } else { // 进入下一个角色或者审批人
  5662. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5663. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5664. 'date' => date ( 'Y-m-d' ),
  5665. 'opinion' => $opinion,
  5666. 'status' => $status,
  5667. 'nextStaff' => $VS ['nextStaff'],
  5668. 'ROLE' => 1
  5669. );
  5670. }
  5671. if ($status == 3) {
  5672. $verifyStaff ['final'] = $status;
  5673. $verifyStaff [$this->staff [0] ['sid']] = array (
  5674. 'date' => date ( 'Y-m-d' ),
  5675. 'opinion' => $opinion,
  5676. 'status' => $status
  5677. );
  5678. }
  5679. $vStaffString = json_encode ( $verifyStaff );
  5680. $receipt->verifyStaff = $vStaffString;
  5681. $receipt->nowStaff = $nowStaff;
  5682. $loanReceipt->nowStaff = $nowStaff;
  5683. $loanReceipt->verifyStaff = $vStaffString;
  5684. }
  5685. // print_r($verifyStaff);die;
  5686. }
  5687. $roleKey = 0;
  5688. $roleId = 0;
  5689. $verifyDetailCopy = array ();
  5690. foreach ( $verifyDetail as $k => $v ) {
  5691. if ($v [1] == 'ROLE') {
  5692. $roleId = $v [0];
  5693. $roleVerify = json_decode ( $v [3], true );
  5694. $roleKey = $k;
  5695. $roleArray = array ();
  5696. foreach ( $roleVerify as $o => $p ) {
  5697. $staffID = explode ( '_', $p );
  5698. $exp = array (
  5699. 0 => $staffID [0],
  5700. 1 => $staffID [1]
  5701. );
  5702. array_push ( $roleArray, $exp );
  5703. }
  5704. $verifyDetailCopy [$v [0]] = $roleArray;
  5705. }
  5706. }
  5707. // print_r($verifyDetail);
  5708. foreach ( $verifyDetailCopy as $k => $v ) {
  5709. foreach ( $verifyDetail as $m => $n ) {
  5710. if ($n [0] == $k) {
  5711. array_splice ( $verifyDetail, $m, 1, $v );
  5712. }
  5713. }
  5714. }
  5715. // 审批日志
  5716. if (! isset ( $verifyStaff ['final'] )) {
  5717. Doo::loadModel ( "receiptLog" );
  5718. $receiptLog = new receiptLog ();
  5719. if (! empty ( $roleId )) {
  5720. Doo::loadModel ( "role" );
  5721. $role = new role ();
  5722. $roleInfo = $role->getOne ( array (
  5723. 'where' => 'rid=' . $roleId,
  5724. 'asArray' => true
  5725. ) );
  5726. $receiptLog->rolename = $roleInfo ['name'];
  5727. }
  5728. $receiptLog->username = $this->staff [0] ['username'];
  5729. $receiptLog->uid = $this->staff [0] ['sid'];
  5730. $receiptLog->date = date ( "Y-m-d" );
  5731. $receiptLog->opinion = $opinion;
  5732. $receiptLog->img = $this->staff [0] ['avatar'];
  5733. $receiptLog->status = 1;
  5734. $receiptLog->rid = $rid;
  5735. $receiptLog->insert ();
  5736. }
  5737. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5738. $receipt->status = 3;
  5739. $receipt->verifyBreakup = $verifyString;
  5740. $receiptDetailObj->status = 3;
  5741. $receiptDetailObj->update ( array (
  5742. 'where' => 'rid=' . $rid
  5743. ) );
  5744. // 微信企业号通知
  5745. $this->setWXMsg ( $rid, 3 );
  5746. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5747. $receipt->status = 6;
  5748. $receipt->pastDate = date ( "Y-m-d" );
  5749. $receipt->isBK = 1;
  5750. $loanReceipt->verifyBreakup = $verifyString;
  5751. $loanReceipt->status = 1;
  5752. $loanReceipt->pastDate = date ( "Y-m-d" );
  5753. //生成流水后 不更新汇款金额
  5754. Doo::loadModel ( 'wasteBook' );
  5755. $wasteBook = new wasteBook ();
  5756. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5757. if (empty($wbDetail)){
  5758. $loanReceipt->amount = $receiptDetail ['amount'];
  5759. }
  5760. $loanReceipt->update ( array (
  5761. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5762. ) );
  5763. // 微信企业号通知
  5764. $this->setWXMsg ( $rid, 1 );
  5765. }
  5766. $receipt->amount = $receiptDetail['sum'];
  5767. $receipt->update ( array (
  5768. 'where' => ' rid = ' . $rid
  5769. ) );
  5770. // 进入下一条审批费用新加需求
  5771. $vidList = array ();
  5772. $verifyDetail = $verify->find ( array (
  5773. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5774. 'asArray' => true
  5775. ) );
  5776. foreach ( $verifyDetail as $key => $value ) {
  5777. array_push ( $vidList, $value ['vid'] );
  5778. }
  5779. $vid = implode ( ",", $vidList );
  5780. if (empty ( $verifyDetail ))
  5781. $vid = 0;
  5782. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5783. $receipt = new receipt ();
  5784. $rd = $receipt->getOne ( array (
  5785. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5786. 'asc' => 'rid',
  5787. 'asArray' => true
  5788. ) );
  5789. if (empty ( $rd )) {
  5790. return '/approvalExpenses/pendApproval';
  5791. }
  5792. if ($rd ['Rtype'] == 1) {
  5793. if ($rd ['isBK'] == 1) {
  5794. return '/receiptburEdi/' . $rd ['rid'];
  5795. } else {
  5796. return '/expensesEdi/' . $rd ['rid'];
  5797. }
  5798. } elseif ($rd ['Rtype'] == 2) {
  5799. return '/remitApproval/' . $rd ['rid'];
  5800. } else {
  5801. return '/receiptburEdi/' . $rd ['rid'];
  5802. }
  5803. // return "/approvalExpenses/pendApproval";
  5804. }
  5805. }
  5806. function ajaxExamineExe() {
  5807. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5808. Doo::loadModel ( 'receipt' );
  5809. $receipt = new receipt ();
  5810. Doo::loadClass ( 'XDeode' );
  5811. $XDeode = new XDeode ( 5 );
  5812. if (! empty ( $rid )) {
  5813. $rLRes = $receipt->find ( array (
  5814. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5815. 'asArray' => true
  5816. ) );
  5817. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5818. echo json_encode ( array (
  5819. 'status' => 1,
  5820. 'receipt' => $rLRes [0]
  5821. ) );
  5822. die ();
  5823. }
  5824. echo json_encode ( array (
  5825. 'status' => 0,
  5826. 'receipt' => array ()
  5827. ) );
  5828. die ();
  5829. }
  5830. function implement() {
  5831. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5832. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5833. Doo::loadClass ( 'XDeode' );
  5834. $XDeode = new XDeode ( 5 );
  5835. Doo::loadModel ( 'receipt' );
  5836. $receipt = new receipt ();
  5837. Doo::loadModel ( 'L_category' );
  5838. $Lcategory = new L_category ();
  5839. Doo::loadModel ( 'verify' );
  5840. $verify = new verify ();
  5841. Doo::loadModel ( 'staff' );
  5842. $staff = new staff ();
  5843. Doo::loadModel ( "execute" );
  5844. $execute = new execute ();
  5845. $rid = $XDeode->decode ( $rid );
  5846. $receiptList = $receipt->find ( array (
  5847. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5848. 'desc' => 'rid',
  5849. 'asArray' => true
  5850. ) );
  5851. Doo::loadModel ( 'loanReceipt' );
  5852. $loanReceipt = new loanReceipt ();
  5853. // print_r($receiptList);
  5854. $loanList = array ();
  5855. if (! isset ( $receiptList ))
  5856. $loanList = $loanReceipt->find ( array (
  5857. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5858. 'desc' => 'rid',
  5859. 'asArray' => true
  5860. ) );
  5861. $Locate = 0;
  5862. $roleId = 0;
  5863. $button = 0;
  5864. foreach ( $loanList as $key => $value ) {
  5865. $loanList [$key] ['Locate'] = $Locate;
  5866. $Locate ++;
  5867. $loanList [$key] ['reviseDetail'] = array ();
  5868. if (! empty ( $value ['reviseDetail'] ))
  5869. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5870. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5871. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5872. $categoryDetil = $Lcategory->getOne ( array (
  5873. 'where' => 'cid=' . $value ['cid'],
  5874. 'asArray' => true
  5875. ) );
  5876. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5877. // 检测编辑状态
  5878. $verifyList = $verify->getOne ( array (
  5879. 'where' => 'vid=' . $value ['verify'],
  5880. 'asArray' => true
  5881. ) );
  5882. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5883. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5884. Doo::loadModel ( 'role' );
  5885. $role = new role ();
  5886. $flag = true;
  5887. $roleKey = 0;
  5888. $endStaffArray = array ();
  5889. $roleArrayCopy = array ();
  5890. foreach ( $verifyList as $k => $v ) {
  5891. // init verifyStaff
  5892. if ($v [1] == 'ROLE') {
  5893. if (! empty ( $verifyStaff )) {
  5894. $endStaffArray = end ( $verifyStaff );
  5895. // if ($v[0]==$endStaffArray['nextStaff']){
  5896. // $roleId=$v[0];
  5897. // }
  5898. }
  5899. $roleVerify = json_decode ( $v [3], true );
  5900. $roleKey = $k;
  5901. $roleArray = array ();
  5902. $rolename = $role->getOne ( array (
  5903. 'where' => 'rid=' . $v [0],
  5904. 'asArray' => true
  5905. ) );
  5906. foreach ( $roleVerify as $o => $p ) {
  5907. $staffID = explode ( '_', $p );
  5908. $staffInfo = $staff->getOne ( array (
  5909. 'where' => 'sid=' . $staffID [0],
  5910. 'asArray' => true
  5911. ) );
  5912. // print_r($staffID);
  5913. $exp = array (
  5914. 0 => $staffInfo ['sid'],
  5915. 1 => $staffID [1],
  5916. 2 => $staffInfo ['avatar'],
  5917. 'date' => '',
  5918. 'date' => '',
  5919. 'opinion' => '',
  5920. 'status' => '',
  5921. 'rolename' => $rolename ['name']
  5922. );
  5923. array_push ( $roleArray, $exp );
  5924. }
  5925. $roleArrayCopy [$v [0]] = $roleArray;
  5926. // $verifyList[$k]['roleArray']=$roleArray;
  5927. }
  5928. $verifyList [$k] ['date'] = "";
  5929. $verifyList [$k] ['opinion'] = "";
  5930. $verifyList [$k] ['status'] = "";
  5931. if (empty ( $verifyStaff )) {
  5932. $verifyList [$k] ['date'] = "";
  5933. $verifyList [$k] ['opinion'] = "";
  5934. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5935. $verifyList [$k] ['status'] = 4;
  5936. $flag = false;
  5937. }
  5938. } else {
  5939. foreach ( $verifyStaff as $m => $u ) {
  5940. if ($v [0] == $m) {
  5941. $verifyList [$k] ['date'] = $u ['date'];
  5942. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5943. $verifyList [$k] ['status'] = $u ['status'];
  5944. $flag = false;
  5945. break;
  5946. }
  5947. }
  5948. $endStaffArray = end ( $verifyStaff );
  5949. if (isset ( $endStaffArray ['ROLE'] )) {
  5950. } else {
  5951. // $endKey=key($verifyStaff);
  5952. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5953. // $button=4;
  5954. // $verifyList[$k]['status']=4;
  5955. // }
  5956. }
  5957. }
  5958. }
  5959. $rolename ['name'] = '';
  5960. if (! empty ( $roleId )) {
  5961. Doo::loadModel ( 'role' );
  5962. $role = new role ();
  5963. $rolename = $role->getOne ( array (
  5964. 'where' => 'rid=' . $roleId,
  5965. 'asArray' => true
  5966. ) );
  5967. }
  5968. if (! empty ( $verifyStaff ))
  5969. $endStaffArray = end ( $verifyStaff );
  5970. $KOP = false;
  5971. foreach ( $roleArrayCopy as $P => $A ) {
  5972. foreach ( $A as $MKI => $AVL ) {
  5973. if (! empty ( $verifyStaff )) {
  5974. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5975. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5976. $button = 4;
  5977. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5978. }
  5979. foreach ( $verifyStaff as $m => $u ) {
  5980. $AVLFK = $AVL [0] . '_R';
  5981. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5982. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5983. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5984. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5985. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5986. break;
  5987. }
  5988. }
  5989. } else {
  5990. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5991. $button = 4;
  5992. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5993. }
  5994. }
  5995. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5996. $KOP = true;
  5997. }
  5998. }
  5999. foreach ( $roleArrayCopy as $k => $v ) {
  6000. foreach ( $verifyList as $m => $n ) {
  6001. if ($n [0] == $k) {
  6002. array_splice ( $verifyList, $m, 1, $v );
  6003. }
  6004. }
  6005. }
  6006. $loanList [$key] ['verifyList'] = $verifyList;
  6007. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6008. 'where' => 'sid=' . $value ['staff'],
  6009. 'asArray' => true
  6010. ) );
  6011. }
  6012. $data ['loanList'] = $loanList;
  6013. $Locate = 0;
  6014. $roleId = 0;
  6015. $button = 0;
  6016. Doo::loadClass ( 'XDeode' );
  6017. $XDeode = new XDeode ( 5 );
  6018. foreach ( $receiptList as $key => $value ) {
  6019. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6020. $button2 = 0;
  6021. $receiptList [$key] ['Locate'] = $Locate;
  6022. $Locate ++;
  6023. $receiptList [$key] ['reviseDetail'] = array ();
  6024. if (! empty ( $value ['reviseDetail'] ))
  6025. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6026. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6027. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6028. $categoryDetil = $Lcategory->getOne ( array (
  6029. 'where' => 'cid=' . $value ['cid'],
  6030. 'asArray' => true
  6031. ) );
  6032. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6033. $executeList = json_decode ( $value ['executeCopy'], true );
  6034. $executeStaff = array ();
  6035. if (! empty ( $value ['executeStaff'] ))
  6036. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6037. if (isset ( $executeList )) {
  6038. foreach ( $executeList as $op => $lo ) {
  6039. $executeList [$op] ['date'] = "";
  6040. $executeList [$op] ['opinion'] = "";
  6041. $executeList [$op] ['status'] = "";
  6042. foreach ( $executeStaff as $m => $u ) {
  6043. if ($lo [0] == $m) {
  6044. $executeList [$op] ['date'] = $u ['date'];
  6045. $executeList [$op] ['opinion'] = $u ['opinion'];
  6046. $executeList [$op] ['status'] = $u ['status'];
  6047. break;
  6048. }
  6049. }
  6050. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6051. $button2 = 1;
  6052. $executeList [$op] ['status'] = 4;
  6053. }
  6054. }
  6055. }
  6056. // 检测编辑状态
  6057. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6058. $verifyList ['staff'] = $value ['verifyBreakup'];
  6059. } else
  6060. $verifyList = $verify->getOne ( array (
  6061. 'where' => 'vid=' . $value ['verify'],
  6062. 'asArray' => true
  6063. ) );
  6064. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6065. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6066. Doo::loadModel ( 'role' );
  6067. $role = new role ();
  6068. if ($verifyList == NULL)
  6069. $verifyList = array ();
  6070. $flag = true;
  6071. $roleKey = 0;
  6072. $endStaffArray = array ();
  6073. $roleArrayCopy = array ();
  6074. foreach ( $verifyList as $k => $v ) {
  6075. // init verifyStaff
  6076. if ($v [1] == 'ROLE') {
  6077. if (! empty ( $verifyStaff )) {
  6078. $endStaffArray = end ( $verifyStaff );
  6079. // if ($v[0]==$endStaffArray['nextStaff']){
  6080. // $roleId=$v[0];
  6081. // }
  6082. }
  6083. $roleVerify = json_decode ( $v [3], true );
  6084. $roleKey = $k;
  6085. $roleArray = array ();
  6086. $rolename = $role->getOne ( array (
  6087. 'where' => 'rid=' . $v [0],
  6088. 'asArray' => true
  6089. ) );
  6090. foreach ( $roleVerify as $o => $p ) {
  6091. $staffID = explode ( '_', $p );
  6092. $staffInfo = $staff->getOne ( array (
  6093. 'where' => 'sid=' . $staffID [0],
  6094. 'asArray' => true
  6095. ) );
  6096. // print_r($staffID);
  6097. $exp = array (
  6098. 0 => $staffInfo ['sid'],
  6099. 1 => $staffID [1],
  6100. 2 => $staffInfo ['avatar'],
  6101. 'date' => '',
  6102. 'date' => '',
  6103. 'opinion' => '',
  6104. 'status' => '',
  6105. 'rolename' => $rolename ['name']
  6106. );
  6107. array_push ( $roleArray, $exp );
  6108. }
  6109. $roleArrayCopy [$v [0]] = $roleArray;
  6110. // $verifyList[$k]['roleArray']=$roleArray;
  6111. }
  6112. $verifyList [$k] ['date'] = "";
  6113. $verifyList [$k] ['opinion'] = "";
  6114. $verifyList [$k] ['status'] = "";
  6115. if (empty ( $verifyStaff )) {
  6116. $verifyList [$k] ['date'] = "";
  6117. $verifyList [$k] ['opinion'] = "";
  6118. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6119. $verifyList [$k] ['status'] = 4;
  6120. $flag = false;
  6121. }
  6122. } else {
  6123. foreach ( $verifyStaff as $m => $u ) {
  6124. if ($v [0] == $m) {
  6125. $verifyList [$k] ['date'] = $u ['date'];
  6126. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6127. $verifyList [$k] ['status'] = $u ['status'];
  6128. $flag = false;
  6129. break;
  6130. }
  6131. }
  6132. $endStaffArray = end ( $verifyStaff );
  6133. if (isset ( $endStaffArray ['ROLE'] )) {
  6134. } else {
  6135. // $endKey=key($verifyStaff);
  6136. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6137. // $button=4;
  6138. // $verifyList[$k]['status']=4;
  6139. // }
  6140. }
  6141. }
  6142. }
  6143. $rolename ['name'] = '';
  6144. if (! empty ( $roleId )) {
  6145. Doo::loadModel ( 'role' );
  6146. $role = new role ();
  6147. $rolename = $role->getOne ( array (
  6148. 'where' => 'rid=' . $roleId,
  6149. 'asArray' => true
  6150. ) );
  6151. }
  6152. if (! empty ( $verifyStaff ))
  6153. $endStaffArray = end ( $verifyStaff );
  6154. $KOP = false;
  6155. foreach ( $roleArrayCopy as $P => $A ) {
  6156. foreach ( $A as $MKI => $AVL ) {
  6157. if (! empty ( $verifyStaff )) {
  6158. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6159. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6160. $button = 4;
  6161. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6162. }
  6163. foreach ( $verifyStaff as $m => $u ) {
  6164. $AVLFK = $AVL [0] . '_R';
  6165. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6166. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6167. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6168. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6169. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6170. break;
  6171. }
  6172. }
  6173. } else {
  6174. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6175. $button = 4;
  6176. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6177. }
  6178. }
  6179. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6180. $KOP = true;
  6181. }
  6182. }
  6183. foreach ( $roleArrayCopy as $k => $v ) {
  6184. foreach ( $verifyList as $m => $n ) {
  6185. if ($n [0] == $k) {
  6186. array_splice ( $verifyList, $m, 1, $v );
  6187. }
  6188. }
  6189. }
  6190. $receiptList [$key] ['verifyList'] = $verifyList;
  6191. $receiptList [$key] ['executeList'] = $executeList;
  6192. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6193. 'where' => 'sid=' . $value ['staff'],
  6194. 'asArray' => true
  6195. ) );
  6196. $receiptList [$key] ['button2'] = $button2;
  6197. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6198. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6199. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6200. $receiptList [$key] ['relust'] = $relust;
  6201. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6202. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6203. }
  6204. //执行人是否是最后一位
  6205. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6206. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6207. $executePrimary=count($executeCopy)-1;
  6208. $lastOne=true;
  6209. if($executePrimary!=count($executeStaff)){
  6210. $lastOne=false;
  6211. }
  6212. $data['lastOne']=$lastOne;
  6213. // 是否写入过流水
  6214. $accountType = 0;
  6215. if ($receiptList [0] ['Rtype'] == 0) {
  6216. $accountType = 3;
  6217. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6218. if($receiptList [0]['version']==1){
  6219. $accountType = 2;
  6220. }else{
  6221. if (!empty($receiptList [0]['accountItem']) ){
  6222. // if (!empty($receiptList [0]['loanRid']) ){
  6223. $accountType = 2;
  6224. }else{
  6225. $accountType = 1;
  6226. }
  6227. }
  6228. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6229. $accountType = 4;
  6230. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6231. $accountType = 12;
  6232. }
  6233. Doo::loadModel ( 'wasteBook' );
  6234. $wasteBook = new wasteBook ();
  6235. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6236. $data ['wbDetail'] = $wbDetail;
  6237. $wbDetailLoan=array();
  6238. if ($accountType==2){
  6239. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6240. }
  6241. $data ['wbDetailLoan'] = $wbDetailLoan;
  6242. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6243. //print_r($wbDetail);
  6244. if($receiptList[0]['version']==1){
  6245. require "protected/class/comm_cld.php";
  6246. $receiptList=makeReceiptDataVersion1($receiptList);
  6247. }
  6248. $data ['receiptList'] = $receiptList;
  6249. $data ['memu'] = "receipt";
  6250. $data ['staff'] = $this->staff;
  6251. $data ['receiptMemu'] = 'implement';
  6252. $data ['verifyId'] = $this->verifyId;
  6253. $data ['executeId'] = $this->executeId;
  6254. if($receiptList[0]['version']==1){
  6255. if ($Rtype=="loan"){
  6256. $this->render ( "/fee/implement/loan_compatible", $data );
  6257. }else{
  6258. $this->render ( "/fee/implement/receipt_compatible", $data );
  6259. }
  6260. die;
  6261. }
  6262. if ($Rtype=="loan"){
  6263. $this->render ( "/receipt/receiptImplementLoan", $data );
  6264. }elseif($Rtype=="receipt"){
  6265. if($receiptList[0]['receiptClass']==2){
  6266. //TODO 费用执行行程单2.0
  6267. if(!empty($receiptList[0]['itinerary2'])){
  6268. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6269. }else{
  6270. $this->render ( "/receipt/receiptImplementTrave", $data );
  6271. }
  6272. }else{
  6273. $this->render ( "/receipt/receiptImplement", $data );
  6274. }
  6275. }elseif($Rtype=="public"){
  6276. $this->render ( "/receipt/receiptImplementPublic", $data );
  6277. }else{
  6278. //$this->render ( "/admin/implement", $data );
  6279. }
  6280. }
  6281. function implementDo() {
  6282. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6283. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6284. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6285. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6286. // $ab = '';
  6287. // if ($accountBank == 'CGBDeposit')
  6288. // $ab = '纵横广发';
  6289. // elseif ($accountBank == 'ICBCDeposit')
  6290. // $ab = '纵横工行';
  6291. // elseif ($accountBank == 'HUADeposit')
  6292. // $ab = '华润银行';
  6293. // elseif ($accountBank == 'PersonalDeposit')
  6294. // $ab = '个人广发';
  6295. // if (empty ( $ab ))
  6296. // die ( 'illegal request--22' );
  6297. if (! empty ( $rid )) {
  6298. Doo::loadModel ( 'receipt' );
  6299. $receipt = new receipt ();
  6300. Doo::loadClass ( 'XDeode' );
  6301. $XDeode = new XDeode ( 5 );
  6302. $rid=$XDeode->decode($rid);
  6303. if (!is_numeric($rid)){
  6304. die;
  6305. }
  6306. // $rinfo = $receipt->getOne ( array (
  6307. // 'where' => 'rid=' . $rid,
  6308. // 'asArray' => true
  6309. // ) );
  6310. $rinfo = $receipt->getReceiptByRid ( $rid );
  6311. // $accountType = '';
  6312. // if ($rinfo ['Rtype'] == 1) {
  6313. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6314. // $accountType = 2;
  6315. // else
  6316. // $accountType = 1;
  6317. // } elseif ($rinfo ['Rtype'] == 2) {
  6318. // $accountType = 4;
  6319. // } elseif ($rinfo ['Rtype'] == 0)
  6320. // $accountType = 3;
  6321. // if (empty ( $accountType ))
  6322. // die ( 'illegal request' );
  6323. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6324. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6325. if (empty ( $executeStaff )) {
  6326. $executeStaff = array (
  6327. $this->staff [0] ['sid'] => array (
  6328. 'date' => date ( 'Y-m-d' ),
  6329. 'opinion' => $implementOpinions,
  6330. 'status' => 1
  6331. )
  6332. );
  6333. } else {
  6334. $executeStaff [$this->staff [0] ['sid']] = array (
  6335. 'date' => date ( 'Y-m-d' ),
  6336. 'opinion' => $implementOpinions,
  6337. 'status' => 1
  6338. );
  6339. }
  6340. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6341. $receipt->executeStaff = json_encode ( $executeStaff );
  6342. $receipt->status = 8;
  6343. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6344. $receipt->status = 9;
  6345. if ($rinfo ['status'] == 6) {
  6346. $receipt->loanDate = date ( "Y-m-d" );
  6347. }
  6348. $receipt->executeDate = date ( "Y-m-d" );
  6349. } else {
  6350. $receipt->executeStaff = json_encode ( $executeStaff );
  6351. }
  6352. //$receipt->amount = $amount;
  6353. $receipt->update ( array (
  6354. 'where' => 'rid=' . $rid
  6355. ) );
  6356. // 公司流水记录
  6357. // Doo::loadModel ( 'wasteBook' );
  6358. // $wasteBook = new wasteBook ();
  6359. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6360. // // 银行
  6361. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6362. // $item = array (
  6363. // 'dataID' => $rid,
  6364. // 'expensesType' => 2,
  6365. // 'accountType' => $accountType,
  6366. // 'accountPriceShow' => $amount,
  6367. // 'accountPrice' => - $amount,
  6368. // 'accountBank' => $accountBank,
  6369. // 'category' => $rinfo ['category'] [0] ['title'],
  6370. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6371. // 'name' => $rinfo ['staffDetail'] ['username'],
  6372. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6373. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6374. // );
  6375. // $wasteBook->setAccountBookStatistics ( $item );
  6376. // }
  6377. }
  6378. //$ridKey = $XDeode->encode ( $rid );
  6379. return "/hisImplement";
  6380. // return "/implement/" . $ridKey . ".html";
  6381. }
  6382. function receiptburEdi() {
  6383. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  6384. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6385. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6386. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6387. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6388. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6389. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6390. if (empty ( $status ))
  6391. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6392. $vidList = array ();
  6393. $button = 0;
  6394. Doo::loadModel ( 'verify' );
  6395. Doo::loadModel ( 'receipt' );
  6396. Doo::loadModel ( 'staff' );
  6397. $staff = new staff ();
  6398. $receipt = new receipt ();
  6399. $verify = new verify ();
  6400. Doo::loadModel ( 'L_category' );
  6401. $Lcategory = new L_category ();
  6402. Doo::loadModel ( 'enclosur' );
  6403. $enclosur = new enclosur ();
  6404. Doo::loadModel ( 'loanReceipt' );
  6405. $loanReceipt = new loanReceipt ();
  6406. // user verify ID
  6407. $verifyDetail = $verify->find ( array (
  6408. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6409. 'asArray' => true
  6410. ) );
  6411. foreach ( $verifyDetail as $key => $value ) {
  6412. array_push ( $vidList, $value ['vid'] );
  6413. }
  6414. $vid = implode ( ",", $vidList );
  6415. if (empty ( $verifyDetail ))
  6416. $vid = 0;
  6417. $categoryList = $Lcategory->find ( array (
  6418. 'asArray' => true
  6419. ) );
  6420. $staffList = $staff->find ( array (
  6421. 'where' => 'cid=' . $cid,
  6422. 'asArray' => true
  6423. ) );
  6424. $ap = "";
  6425. if ($status == 4) {
  6426. $ap = 4;
  6427. $status = 2;
  6428. }
  6429. // get Receipt By verifyID status 2
  6430. $receiptList = $receipt->find ( array (
  6431. 'where' => 'rid =' . $rid . ' and status=2',
  6432. 'desc' => 'rid',
  6433. 'asArray' => true
  6434. ) );
  6435. if (empty ( $receiptList )) {
  6436. die ( 'illegal request' );
  6437. }
  6438. $loanList = $loanReceipt->find ( array (
  6439. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6440. 'desc' => 'rid',
  6441. 'asArray' => true
  6442. ) );
  6443. $data ['explanation'] = '';
  6444. if (! empty ( $loanList ))
  6445. $data ['explanation'] = $loanList [0] ['explanation'];
  6446. $Locate = 0;
  6447. $roleId = 0;
  6448. $button = 0;
  6449. foreach ( $loanList as $key => $value ) {
  6450. $loanList [$key] ['Locate'] = $Locate;
  6451. $Locate ++;
  6452. $loanList [$key] ['reviseDetail'] = array ();
  6453. if (! empty ( $value ['reviseDetail'] ))
  6454. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6455. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6456. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6457. $categoryDetil = $Lcategory->getOne ( array (
  6458. 'where' => 'cid=' . $value ['cid'],
  6459. 'asArray' => true
  6460. ) );
  6461. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6462. // 检测编辑状态
  6463. $verifyList = $verify->getOne ( array (
  6464. 'where' => 'vid=' . $value ['verify'],
  6465. 'asArray' => true
  6466. ) );
  6467. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6468. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6469. Doo::loadModel ( 'role' );
  6470. $role = new role ();
  6471. $flag = true;
  6472. $roleKey = 0;
  6473. $endStaffArray = array ();
  6474. $roleArrayCopy = array ();
  6475. foreach ( $verifyList as $k => $v ) {
  6476. // init verifyStaff
  6477. if ($v [1] == 'ROLE') {
  6478. if (! empty ( $verifyStaff )) {
  6479. $endStaffArray = end ( $verifyStaff );
  6480. }
  6481. $roleVerify = json_decode ( $v [3], true );
  6482. $roleKey = $k;
  6483. $roleArray = array ();
  6484. $rolename = $role->getOne ( array (
  6485. 'where' => 'rid=' . $v [0],
  6486. 'asArray' => true
  6487. ) );
  6488. foreach ( $roleVerify as $o => $p ) {
  6489. $staffID = explode ( '_', $p );
  6490. $staffInfo = $staff->getOne ( array (
  6491. 'where' => 'sid=' . $staffID [0],
  6492. 'asArray' => true
  6493. ) );
  6494. // print_r($staffID);
  6495. $exp = array (
  6496. 0 => $staffInfo ['sid'],
  6497. 1 => $staffID [1],
  6498. 2 => $staffInfo ['avatar'],
  6499. 'date' => '',
  6500. 'date' => '',
  6501. 'opinion' => '',
  6502. 'status' => '',
  6503. 'rolename' => $rolename ['name']
  6504. );
  6505. array_push ( $roleArray, $exp );
  6506. }
  6507. $roleArrayCopy [$v [0]] = $roleArray;
  6508. // $verifyList[$k]['roleArray']=$roleArray;
  6509. }
  6510. $verifyList [$k] ['date'] = "";
  6511. $verifyList [$k] ['opinion'] = "";
  6512. $verifyList [$k] ['status'] = "";
  6513. if (empty ( $verifyStaff )) {
  6514. $verifyList [$k] ['date'] = "";
  6515. $verifyList [$k] ['opinion'] = "";
  6516. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6517. $verifyList [$k] ['status'] = 4;
  6518. $flag = false;
  6519. }
  6520. } else {
  6521. foreach ( $verifyStaff as $m => $u ) {
  6522. if ($v [0] == $m) {
  6523. $verifyList [$k] ['date'] = $u ['date'];
  6524. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6525. $verifyList [$k] ['status'] = $u ['status'];
  6526. $flag = false;
  6527. break;
  6528. }
  6529. }
  6530. $endStaffArray = end ( $verifyStaff );
  6531. if (isset ( $endStaffArray ['ROLE'] )) {
  6532. } else {
  6533. }
  6534. }
  6535. }
  6536. $rolename ['name'] = '';
  6537. if (! empty ( $roleId )) {
  6538. Doo::loadModel ( 'role' );
  6539. $role = new role ();
  6540. $rolename = $role->getOne ( array (
  6541. 'where' => 'rid=' . $roleId,
  6542. 'asArray' => true
  6543. ) );
  6544. }
  6545. if (! empty ( $verifyStaff ))
  6546. $endStaffArray = end ( $verifyStaff );
  6547. $KOP = false;
  6548. foreach ( $roleArrayCopy as $P => $A ) {
  6549. foreach ( $A as $MKI => $AVL ) {
  6550. if (! empty ( $verifyStaff )) {
  6551. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6552. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6553. $button = 4;
  6554. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6555. }
  6556. foreach ( $verifyStaff as $m => $u ) {
  6557. $AVLFK = $AVL [0] . '_R';
  6558. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6559. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6560. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6561. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6562. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6563. break;
  6564. }
  6565. }
  6566. } else {
  6567. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6568. $button = 4;
  6569. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6570. }
  6571. }
  6572. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6573. $KOP = true;
  6574. }
  6575. }
  6576. foreach ( $roleArrayCopy as $k => $v ) {
  6577. foreach ( $verifyList as $m => $n ) {
  6578. if ($n [0] == $k) {
  6579. array_splice ( $verifyList, $m, 1, $v );
  6580. }
  6581. }
  6582. }
  6583. $loanList [$key] ['verifyList'] = $verifyList;
  6584. }
  6585. $htmlLoan = '';
  6586. $data ['loanReceiptDate'] = '';
  6587. if (isset ( $loanList [0] )) {
  6588. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6589. if ($value ['status'] == 1)
  6590. $htmlLoan .= '<li class="done" >';
  6591. elseif ($value ['status'] == 3)
  6592. $htmlLoan .= '<li class="undone" >';
  6593. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6594. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6595. if (isset ( $value ['rolename'] ))
  6596. $htmlLoan .= $value ['rolename'];
  6597. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6598. }
  6599. $data ['loanDate'] = $loanList [0] ['date'];
  6600. } else {
  6601. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6602. }
  6603. $data ['htmlLoan'] = $htmlLoan;
  6604. // $data ['LoanReceipt']=$loanList[0];
  6605. // print_r($loanList);
  6606. $Locate = 0;
  6607. $roleId = 0;
  6608. $button = 0;
  6609. if ($ap == 4)
  6610. $status = 4;
  6611. Doo::loadClass ( 'XDeode' );
  6612. $XDeode = new XDeode ( 5 );
  6613. foreach ( $receiptList as $key => $value ) {
  6614. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6615. $receiptList [$key] ['Locate'] = $Locate;
  6616. $Locate ++;
  6617. $receiptList [$key] ['reviseDetail'] = array ();
  6618. // 调整金额 代码调整
  6619. if (! empty ( $value ['reviseDetail'] )) {
  6620. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6621. foreach ( $reviseDetail as $ry => $re ) {
  6622. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6623. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6624. }
  6625. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6626. // print_r($reviseDetail);
  6627. }
  6628. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6629. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6630. $categoryDetil = $Lcategory->getOne ( array (
  6631. 'where' => 'cid=' . $value ['cid'],
  6632. 'asArray' => true
  6633. ) );
  6634. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6635. // 检测编辑状态
  6636. $verifyList = $verify->getOne ( array (
  6637. 'where' => 'vid=' . $value ['verify'],
  6638. 'asArray' => true
  6639. ) );
  6640. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6641. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6642. Doo::loadModel ( 'role' );
  6643. $role = new role ();
  6644. // print_r($verifyList);
  6645. $flag = true;
  6646. $roleKey = 0;
  6647. $endStaffArray = array ();
  6648. $roleArrayCopy = array ();
  6649. foreach ( $verifyList as $k => $v ) {
  6650. // init verifyStaff
  6651. if ($v [1] == 'ROLE') {
  6652. if (! empty ( $verifyStaff )) {
  6653. $endStaffArray = end ( $verifyStaff );
  6654. if ($v [0] == $endStaffArray ['nextStaff']) {
  6655. $roleId = $v [0];
  6656. }
  6657. }
  6658. $roleVerify = json_decode ( $v [3], true );
  6659. $roleKey = $k;
  6660. $roleArray = array ();
  6661. $rolename = $role->getOne ( array (
  6662. 'where' => 'rid=' . $v [0],
  6663. 'asArray' => true
  6664. ) );
  6665. foreach ( $roleVerify as $o => $p ) {
  6666. $staffID = explode ( '_', $p );
  6667. $staffInfo = $staff->getOne ( array (
  6668. 'where' => 'sid=' . $staffID [0],
  6669. 'asArray' => true
  6670. ) );
  6671. // print_r($staffID);
  6672. $exp = array (
  6673. 0 => $staffInfo ['sid'],
  6674. 1 => $staffID [1],
  6675. 2 => $staffInfo ['avatar'],
  6676. 'date' => '',
  6677. 'date' => '',
  6678. 'opinion' => '',
  6679. 'status' => '',
  6680. 'rolename' => $rolename ['name']
  6681. );
  6682. array_push ( $roleArray, $exp );
  6683. }
  6684. $roleArrayCopy [$v [0]] = $roleArray;
  6685. // $verifyList[$k]['roleArray']=$roleArray;
  6686. }
  6687. // print_r($roleArray);
  6688. $verifyList [$k] ['date'] = "";
  6689. $verifyList [$k] ['opinion'] = "";
  6690. $verifyList [$k] ['status'] = "";
  6691. if (empty ( $verifyStaff )) {
  6692. $verifyList [$k] ['date'] = "";
  6693. $verifyList [$k] ['opinion'] = "";
  6694. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6695. $verifyList [$k] ['status'] = 4;
  6696. $button = 4;
  6697. $flag = false;
  6698. }
  6699. } else {
  6700. foreach ( $verifyStaff as $m => $u ) {
  6701. if ($v [0] == $m) {
  6702. $verifyList [$k] ['date'] = $u ['date'];
  6703. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6704. $verifyList [$k] ['status'] = $u ['status'];
  6705. $flag = false;
  6706. break;
  6707. }
  6708. }
  6709. $endStaffArray = end ( $verifyStaff );
  6710. if (isset ( $endStaffArray ['ROLE'] )) {
  6711. } else {
  6712. $endKey = key ( $verifyStaff );
  6713. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6714. $button = 4;
  6715. $verifyList [$k] ['status'] = 4;
  6716. }
  6717. }
  6718. }
  6719. }
  6720. $rolename ['name'] = '';
  6721. if (! empty ( $roleId )) {
  6722. Doo::loadModel ( 'role' );
  6723. $role = new role ();
  6724. $rolename = $role->getOne ( array (
  6725. 'where' => 'rid=' . $roleId,
  6726. 'asArray' => true
  6727. ) );
  6728. }
  6729. if (! empty ( $verifyStaff ))
  6730. $endStaffArray = end ( $verifyStaff );
  6731. $KOP = false;
  6732. foreach ( $roleArrayCopy as $P => $A ) {
  6733. foreach ( $A as $MKI => $AVL ) {
  6734. if (! empty ( $verifyStaff )) {
  6735. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6736. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6737. $button = 4;
  6738. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6739. }
  6740. foreach ( $verifyStaff as $m => $u ) {
  6741. $AVLFK = $AVL [0] . '_R';
  6742. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6743. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6744. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6745. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6746. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6747. break;
  6748. }
  6749. }
  6750. } else {
  6751. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6752. $button = 4;
  6753. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6754. }
  6755. }
  6756. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6757. $KOP = true;
  6758. }
  6759. }
  6760. foreach ( $roleArrayCopy as $k => $v ) {
  6761. foreach ( $verifyList as $m => $n ) {
  6762. if ($n [0] == $k) {
  6763. array_splice ( $verifyList, $m, 1, $v );
  6764. }
  6765. }
  6766. }
  6767. // print_r($verifyList);
  6768. $receiptList [$key] ['verifyList'] = $verifyList;
  6769. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6770. 'where' => 'sid=' . $value ['staff'],
  6771. 'asArray' => true
  6772. ) );
  6773. $receiptList [$key] ['button'] = $button;
  6774. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6775. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6776. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6777. $receiptList [$key] ['relust'] = $relust;
  6778. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6779. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6780. }
  6781. //print_r($receiptList);die;
  6782. // $data['verifyDetail']=$verifyDetail;
  6783. $mothHtml = "";
  6784. for($i = 1; $i <= 12; $i ++) {
  6785. if ($month == $i)
  6786. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6787. else
  6788. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6789. }
  6790. // 获取审批日志
  6791. Doo::loadModel ( 'receiptLog' );
  6792. $receiptLog = new receiptLog ();
  6793. $rlList = array ();
  6794. $rlInfo = $receiptLog->getOne ( array (
  6795. 'where' => 'rid=' . $rid . ' and status=4',
  6796. 'asArray' => true
  6797. ) );
  6798. $tijdate = $receiptLog->getOne ( array (
  6799. 'where' => 'rid=' . $rid . ' and status=2',
  6800. 'asc' => 'rlid',
  6801. 'asArray' => true
  6802. ) );
  6803. if (! empty ( $rlInfo )) {
  6804. $rlList = $receiptLog->find ( array (
  6805. 'where' => 'rid=' . $rid,
  6806. 'asc' => 'rlid',
  6807. 'asArray' => true
  6808. ) );
  6809. }
  6810. // echo $rid;
  6811. // print_r($receiptList);
  6812. $receiptList [0] ['rlList'] = $rlList;
  6813. // print_r($receiptList);
  6814. $enclosurList = $enclosur->find ( array (
  6815. 'where' => 'rid=' . $rid,
  6816. 'asArray' => true
  6817. ) );
  6818. $enclosurHtml = '';
  6819. foreach ( $enclosurList as $value ) {
  6820. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6821. }
  6822. $data ['enclosurHtml'] = $enclosurHtml;
  6823. $data ['rolename'] = $rolename ['name'];
  6824. $data ['mothHtml'] = $mothHtml;
  6825. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6826. if($receiptList[0]['version']==1){
  6827. require "protected/class/comm_cld.php";
  6828. $receiptList=makeReceiptDataVersion1($receiptList);
  6829. }
  6830. $data ['rid'] = $rid;
  6831. $data ['tijdate'] = $tijdate ['date'];
  6832. $data ['receiptList'] = $receiptList;
  6833. $data ['receiptApprovalCount'] = count ( $receiptList );
  6834. $data ['status'] = $status;
  6835. $data ['year'] = $year;
  6836. $data ['categoryList'] = $categoryList;
  6837. $data ['staffList'] = $staffList;
  6838. $data ['cid'] = $cid;
  6839. $data ['sid'] = $sid;
  6840. $data ['ap'] = $ap;
  6841. $data ['memu'] = "receipt";
  6842. $data ['staff'] = $this->staff;
  6843. $data ['receiptMemu'] = 'approvalExpenses';
  6844. $data ['verifyId'] = $this->verifyId;
  6845. $data ['executeId'] = $this->executeId;
  6846. if($receiptList[0]['version']==1){
  6847. $this->render ( "/fee/approval/receipt_compatible", $data );
  6848. die;
  6849. }
  6850. if($receiptList[0]['receiptClass']==1){
  6851. $this->render ( "/receipt/feeAgencyApproval", $data );
  6852. }elseif($receiptList[0]['receiptClass']==2){
  6853. //TODO 行程单2.0
  6854. if(!empty($receiptList[0]['itinerary2'])){
  6855. $this->render ( "/receipt/feeTraveApproval2", $data );
  6856. }else{
  6857. $this->render ( "/receipt/feeTraveApproval", $data );
  6858. }
  6859. }elseif($receiptList[0]['receiptClass']==3){
  6860. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6861. }else{
  6862. $this->render ( "/admin/receiptburEdi", $data );
  6863. }
  6864. }
  6865. function hisImplement() {
  6866. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6867. if (empty ( $item ))
  6868. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6869. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6870. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6871. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6872. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6873. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6874. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6875. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6876. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6877. Doo::loadClass ( 'XDeode' );
  6878. $XDeode = new XDeode ( 5 );
  6879. Doo::loadModel ( 'receipt' );
  6880. $receipt = new receipt ();
  6881. Doo::loadModel ( 'L_category' );
  6882. $Lcategory = new L_category ();
  6883. Doo::loadModel ( 'verify' );
  6884. Doo::loadModel ( 'statistics' );
  6885. $statistics = new statistics ();
  6886. $verify = new verify ();
  6887. Doo::loadModel ( 'staff' );
  6888. $staff = new staff ();
  6889. Doo::loadClass ( 'XDeode' );
  6890. $XDeode = new XDeode ( 5 );
  6891. $XDeode7 = new XDeode ( 7 );
  6892. $cid = $XDeode->decode ( $cidKey );
  6893. $condition = "";
  6894. if ($item == "expenses")
  6895. $condition = " and Rtype=1 ";
  6896. elseif ($item == "receipts")
  6897. $condition = " and Rtype=0 ";
  6898. elseif ($item == "remits")
  6899. $condition = " and Rtype=2 ";
  6900. elseif($item == "train")
  6901. $condition = " and Rtype=3 ";
  6902. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6903. $sopString = $cidString = "";
  6904. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6905. if (empty ( $rdate ))
  6906. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6907. else
  6908. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6909. if ($status == 'pendImplement') {
  6910. $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 ) ) ';
  6911. } elseif ($status == 'alerpts') {
  6912. $statusCon = '(status=8 or status=9 )';
  6913. if (empty ( $rdate )){
  6914. $dateCondition = " and Year(date) =" . $year;
  6915. }else{
  6916. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6917. }
  6918. }
  6919. if ($sop != 'SOP')
  6920. $sopString = " and staff=" . $sop;
  6921. if ($cidKey != 'ALL')
  6922. $cidString = " and cid=" . $cid;
  6923. //汇款信息需要提取出来
  6924. if(!empty($receiptOrder)){
  6925. $receiptList = $receipt->find ( array (
  6926. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6927. 'desc' => 'rid',
  6928. 'asArray' => true
  6929. ) );
  6930. // 员工筛选
  6931. $receiptList2 = $receipt->find ( array (
  6932. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6933. 'desc' => 'rid',
  6934. 'asArray' => true
  6935. ) );
  6936. }else{
  6937. $receiptList = $receipt->find ( array (
  6938. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6939. 'desc' => 'rid',
  6940. 'asArray' => true
  6941. ) );
  6942. // 员工筛选
  6943. $receiptList2 = $receipt->find ( array (
  6944. 'where' => $statusCon . $condition . $dateCondition,
  6945. 'desc' => 'rid',
  6946. 'asArray' => true
  6947. ) );
  6948. }
  6949. $sopStaff = array ();
  6950. foreach ( $receiptList2 as $key => $value ) {
  6951. $staffDetail = $staff->getOne ( array (
  6952. 'select' => 'username',
  6953. 'where' => 'sid=' . $value ['staff'],
  6954. 'asArray' => true
  6955. ) );
  6956. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6957. }
  6958. // 办事处筛选
  6959. $categoryScreen = array ();
  6960. $categorList = $Lcategory->getCategory ();
  6961. foreach ( $receiptList2 as $key => $value ) {
  6962. foreach ( $categorList as $k => $v ) {
  6963. if ($value ['cid'] == $v ['cid']) {
  6964. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6965. break;
  6966. }
  6967. }
  6968. }
  6969. $categoryScreenHtml = "";
  6970. foreach ( $categoryScreen as $key => $value ) {
  6971. if ($cidKey == $key)
  6972. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6973. else
  6974. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6975. }
  6976. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6977. $data ['cidKey'] = $cidKey;
  6978. $Locate = 0;
  6979. $roleId = 0;
  6980. $button = 0;
  6981. $staffBatchNumber = 100001;
  6982. $remittanceList = array ();
  6983. foreach ( $receiptList as $key => $value ) {
  6984. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6985. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6986. $receiptList [$key] ['Texe'] = 'false';
  6987. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6988. $receiptList [$key] ['Texe'] = 'true';
  6989. }
  6990. $receiptList [$key] ['TRexe'] = 'true';
  6991. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6992. $receiptList [$key] ['TRexe'] = 'false';
  6993. }
  6994. $receiptList [$key] ['Locate'] = $Locate;
  6995. $Locate ++;
  6996. $receiptList [$key] ['reviseDetail'] = array ();
  6997. if (! empty ( $value ['reviseDetail'] ))
  6998. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6999. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7000. $categoryDetil = $Lcategory->getOne ( array (
  7001. 'where' => 'cid=' . $value ['cid'],
  7002. 'asArray' => true
  7003. ) );
  7004. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7005. // 检测编辑状态
  7006. $verifyList = $verify->getOne ( array (
  7007. 'where' => 'vid=' . $value ['verify'],
  7008. 'asArray' => true
  7009. ) );
  7010. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7011. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7012. Doo::loadModel ( 'role' );
  7013. $role = new role ();
  7014. $flag = true;
  7015. $roleKey = 0;
  7016. $endStaffArray = array ();
  7017. $roleArrayCopy = array ();
  7018. foreach ( $verifyList as $k => $v ) {
  7019. // init verifyStaff
  7020. if ($v [1] == 'ROLE') {
  7021. if (! empty ( $verifyStaff )) {
  7022. $endStaffArray = end ( $verifyStaff );
  7023. }
  7024. $roleVerify = json_decode ( $v [3], true );
  7025. $roleKey = $k;
  7026. $roleArray = array ();
  7027. $rolename = $role->getOne ( array (
  7028. 'where' => 'rid=' . $v [0],
  7029. 'asArray' => true
  7030. ) );
  7031. foreach ( $roleVerify as $o => $p ) {
  7032. $staffID = explode ( '_', $p );
  7033. $staffInfo = $staff->getOne ( array (
  7034. 'where' => 'sid=' . $staffID [0],
  7035. 'asArray' => true
  7036. ) );
  7037. $exp = array (
  7038. 0 => $staffInfo ['sid'],
  7039. 1 => $staffID [1],
  7040. 2 => $staffInfo ['avatar'],
  7041. 'date' => '',
  7042. 'date' => '',
  7043. 'opinion' => '',
  7044. 'status' => '',
  7045. 'rolename' => $rolename ['name']
  7046. );
  7047. array_push ( $roleArray, $exp );
  7048. }
  7049. $roleArrayCopy [$v [0]] = $roleArray;
  7050. }
  7051. $verifyList [$k] ['date'] = "";
  7052. $verifyList [$k] ['opinion'] = "";
  7053. $verifyList [$k] ['status'] = "";
  7054. if (empty ( $verifyStaff )) {
  7055. $verifyList [$k] ['date'] = "";
  7056. $verifyList [$k] ['opinion'] = "";
  7057. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7058. $verifyList [$k] ['status'] = 4;
  7059. $flag = false;
  7060. }
  7061. } else {
  7062. foreach ( $verifyStaff as $m => $u ) {
  7063. if ($v [0] == $m) {
  7064. $verifyList [$k] ['date'] = $u ['date'];
  7065. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7066. $verifyList [$k] ['status'] = $u ['status'];
  7067. $flag = false;
  7068. break;
  7069. }
  7070. }
  7071. $endStaffArray = end ( $verifyStaff );
  7072. }
  7073. }
  7074. $rolename ['name'] = '';
  7075. if (! empty ( $roleId )) {
  7076. Doo::loadModel ( 'role' );
  7077. $role = new role ();
  7078. $rolename = $role->getOne ( array (
  7079. 'where' => 'rid=' . $roleId,
  7080. 'asArray' => true
  7081. ) );
  7082. }
  7083. if (! empty ( $verifyStaff ))
  7084. $endStaffArray = end ( $verifyStaff );
  7085. $KOP = false;
  7086. foreach ( $roleArrayCopy as $P => $A ) {
  7087. foreach ( $A as $MKI => $AVL ) {
  7088. if (! empty ( $verifyStaff )) {
  7089. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7090. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7091. $button = 4;
  7092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7093. }
  7094. foreach ( $verifyStaff as $m => $u ) {
  7095. $AVLFK = $AVL [0] . '_R';
  7096. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7097. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7098. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7099. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7100. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7101. break;
  7102. }
  7103. }
  7104. } else {
  7105. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7106. $button = 4;
  7107. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7108. }
  7109. }
  7110. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7111. $KOP = true;
  7112. }
  7113. }
  7114. foreach ( $roleArrayCopy as $k => $v ) {
  7115. foreach ( $verifyList as $m => $n ) {
  7116. if ($n [0] == $k) {
  7117. array_splice ( $verifyList, $m, 1, $v );
  7118. }
  7119. }
  7120. }
  7121. $receiptList [$key] ['verifyList'] = $verifyList;
  7122. $staffDetail = $staff->getOne ( array (
  7123. 'where' => 'sid=' . $value ['staff'],
  7124. 'asArray' => true
  7125. ) );
  7126. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7127. $receiptList [$key] ['button'] = $button;
  7128. if ($value['Rtype']==1){
  7129. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7130. $receiptList [$key] ['relustABS'] = sprintf("%.2f",abs($receiptList [$key] ['relust']));
  7131. }elseif($value['Rtype']==3){
  7132. // 收入合计
  7133. Doo::loadModel ( 'invoiceTraining' );
  7134. $invoiceTraining = new invoiceTraining ();
  7135. $invoiceTrainingDetail = array (
  7136. 'invoiceArriveAmount' => '0.00',
  7137. 'RIAmount' => '0.00',
  7138. 'invoiceTotalAmount' => '0.00',
  7139. 'invoiceCompanyAmount' => '0.00',
  7140. 'invoiceArriveAmountM'=>'0.00',
  7141. 'invoiceCompanyAmountM'=>'0.00'
  7142. );
  7143. if ($value ['invoiceTrainId'] != 0) {
  7144. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7145. }
  7146. $invoiceArriveAmount = $RIAmount = 0;
  7147. if (! empty ( $invoiceTrainingDetail )) {
  7148. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7149. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7150. }
  7151. // 备用金
  7152. $sum = 0;
  7153. if (! empty ( $value ['trainLoanRid'] )) {
  7154. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7155. foreach ($receiptLoanList as $kll=>$vll){
  7156. $sum+=$vll['sum'];
  7157. }
  7158. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7159. // $sum = $receiptLoanDetailBak ['sum'];
  7160. }
  7161. // 支出项金额详情
  7162. // 项目金额合计
  7163. Doo::loadModel ( 'RItem' );
  7164. $RItem = new RItem ();
  7165. Doo::loadModel ( 'accountItem' );
  7166. $accountItem = new accountItem ();
  7167. // 讲师获得
  7168. Doo::loadModel ( 'RILecturer' );
  7169. $RILecturer = new RILecturer ();
  7170. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7171. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7172. // 支出项金额详情
  7173. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7174. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7175. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7176. $receiptList [$key] ['payment'] =$payment;
  7177. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7178. }
  7179. // 设置导出汇款execl
  7180. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7181. $remittanceDetail = array (
  7182. $staffBatchNumber,
  7183. $value ['remittanceName'],
  7184. $value ['bankNumber'],
  7185. $value ['bankName'],
  7186. $value ['remittanceBankType'],
  7187. $value ['coupletNumber'],
  7188. $value ['sum']
  7189. );
  7190. array_push ( $remittanceList, $remittanceDetail );
  7191. $staffBatchNumber ++;
  7192. }
  7193. if($value['version']==1){
  7194. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  7195. }
  7196. }
  7197. $data ['remittanceList'] = json_encode ( $remittanceList );
  7198. // print_r($receiptList);
  7199. $mothHtml = "";
  7200. for($i = 1; $i <= 12; $i ++) {
  7201. if ($moth == $i)
  7202. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7203. else
  7204. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7205. }
  7206. $dayHtml = "";
  7207. if ($day != "DAY" || $moth != "MONTH") {
  7208. for($i = 1; $i <= 31; $i ++) {
  7209. if ($day == $i)
  7210. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7211. else
  7212. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7213. }
  7214. }
  7215. $sopHtml = "";
  7216. foreach ( $sopStaff as $key => $value ) {
  7217. if ($sop == $key)
  7218. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7219. else
  7220. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7221. }
  7222. $data ['status'] = $status;
  7223. $data ['rdate'] = $rdate;
  7224. $data ['sopHtml'] = $sopHtml;
  7225. $data ['dayHtml'] = $dayHtml;
  7226. $data ['mothHtml'] = $mothHtml;
  7227. $data ['receiptList'] = $receiptList;
  7228. $data ['memu'] = "receipt";
  7229. $data ['staff'] = $this->staff;
  7230. $data ['receiptMemu'] = 'implement';
  7231. $data ['verifyId'] = $this->verifyId;
  7232. $data ['executeId'] = $this->executeId;
  7233. $data ['item'] = $item;
  7234. $data ['year'] = $year;
  7235. $data ['moth'] = $moth;
  7236. $data['receiptOrder']=$receiptOrder;
  7237. $data ['day'] = $day;
  7238. $data ['sop'] = $sop;
  7239. $this->render ( "/admin/hisImplement", $data );
  7240. }
  7241. /**
  7242. * 导出汇款信息的exelc
  7243. */
  7244. function exportRemittance() {
  7245. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7246. if (empty ( $remittanceInfo ))
  7247. die ( 'illegal request' );
  7248. $title = array (
  7249. '员工编号',
  7250. '姓名',
  7251. '员工账号',
  7252. '员工账户开户行',
  7253. '转账类型',
  7254. '联行号',
  7255. '金额'
  7256. );
  7257. $data = json_decode ( $remittanceInfo, true );
  7258. if (empty ( $data ))
  7259. die ( 'illegal request' );
  7260. Doo::loadClass ( 'receipt.func' );
  7261. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7262. header ( 'Content-Type:text/html;charset=utf-8' );
  7263. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7264. }
  7265. function ajaxExamine() {
  7266. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7267. Doo::loadModel ( 'receipt' );
  7268. $receipt = new receipt ();
  7269. if (! empty ( $rid )) {
  7270. $rLRes = $receipt->find ( array (
  7271. '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,
  7272. 'asArray' => true
  7273. ) );
  7274. if(!empty($rLRes)){
  7275. Doo::loadClass ( 'XDeode' );
  7276. $XDeode = new XDeode ( 7 );
  7277. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7278. echo json_encode ( array (
  7279. 'status' => 1,
  7280. 'receipt' => $rLRes [0]
  7281. ) );
  7282. die ();
  7283. }else{
  7284. echo json_encode ( array (
  7285. 'status' => 1,
  7286. 'receipt' => array ()
  7287. ) );
  7288. die ();
  7289. }
  7290. }
  7291. echo json_encode ( array (
  7292. 'status' => 0,
  7293. 'receipt' => array ()
  7294. ) );
  7295. die ();
  7296. }
  7297. /*
  7298. * 废弃
  7299. */
  7300. function myReceipt() {
  7301. // all approval past withdraw
  7302. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7303. if (empty ( $item ))
  7304. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7305. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7306. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7307. Doo::loadModel ( 'receipt' );
  7308. $receipt = new receipt ();
  7309. // pre-loaded
  7310. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7311. // have cache
  7312. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7313. if (! empty ( $moth )) // yearPage
  7314. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7315. $this->showCache ( $path );
  7316. }
  7317. Doo::loadModel ( 'L_category' );
  7318. $Lcategory = new L_category ();
  7319. Doo::loadModel ( 'verify' );
  7320. Doo::loadModel ( 'statistics' );
  7321. $statistics = new statistics ();
  7322. $verify = new verify ();
  7323. Doo::loadModel ( 'staff' );
  7324. $staff = new staff ();
  7325. $condition = " and status!=0 ";
  7326. if ($item == "approval")
  7327. $condition = " and status=2 ";
  7328. elseif ($item == "withdraw")
  7329. $condition = " and status=3 ";
  7330. elseif ($item == "past")
  7331. $condition = " and status=1 ";
  7332. elseif ($item == "whdw")
  7333. $condition = " and status=4 ";
  7334. $dateCondition = " and Year(date) =" . $year;
  7335. if (! empty ( $moth )) {
  7336. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7337. $stList = $statistics->getOne ( array (
  7338. 'select' => 'rePrice ,agPrice',
  7339. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7340. 'asArray' => true
  7341. ) );
  7342. } else
  7343. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7344. if (empty ( $stList ))
  7345. $stList = array (
  7346. 'rePrice' => 0,
  7347. 'agPrice' => 0
  7348. );
  7349. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7350. $data ['stList'] = array (
  7351. 'rePrice' => $stList ['rePrice'],
  7352. 'agPrice' => $stList ['agPrice'],
  7353. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7354. );
  7355. $receiptList = $receipt->find ( array (
  7356. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7357. 'desc' => 'rid',
  7358. 'asArray' => true
  7359. ) );
  7360. $Locate = 0;
  7361. $roleId = 0;
  7362. $button = 0;
  7363. foreach ( $receiptList as $key => $value ) {
  7364. $receiptList [$key] ['Locate'] = $Locate;
  7365. $Locate ++;
  7366. $receiptList [$key] ['reviseDetail'] = array ();
  7367. if (! empty ( $value ['reviseDetail'] ))
  7368. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7369. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7370. $categoryDetil = $Lcategory->getOne ( array (
  7371. 'where' => 'cid=' . $value ['cid'],
  7372. 'asArray' => true
  7373. ) );
  7374. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7375. // 检测编辑状态
  7376. $verifyList = $verify->getOne ( array (
  7377. 'where' => 'vid=' . $value ['verify'],
  7378. 'asArray' => true
  7379. ) );
  7380. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7381. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7382. Doo::loadModel ( 'role' );
  7383. $role = new role ();
  7384. $flag = true;
  7385. $roleKey = 0;
  7386. $endStaffArray = array ();
  7387. $roleArrayCopy = array ();
  7388. foreach ( $verifyList as $k => $v ) {
  7389. // init verifyStaff
  7390. if ($v [1] == 'ROLE') {
  7391. if (! empty ( $verifyStaff )) {
  7392. $endStaffArray = end ( $verifyStaff );
  7393. // if ($v[0]==$endStaffArray['nextStaff']){
  7394. // $roleId=$v[0];
  7395. // }
  7396. }
  7397. $roleVerify = json_decode ( $v [3], true );
  7398. $roleKey = $k;
  7399. $roleArray = array ();
  7400. $rolename = $role->getOne ( array (
  7401. 'where' => 'rid=' . $v [0],
  7402. 'asArray' => true
  7403. ) );
  7404. foreach ( $roleVerify as $o => $p ) {
  7405. $staffID = explode ( '_', $p );
  7406. $staffInfo = $staff->getOne ( array (
  7407. 'where' => 'sid=' . $staffID [0],
  7408. 'asArray' => true
  7409. ) );
  7410. // print_r($staffID);
  7411. $exp = array (
  7412. 0 => $staffInfo ['sid'],
  7413. 1 => $staffID [1],
  7414. 2 => $staffInfo ['avatar'],
  7415. 'date' => '',
  7416. 'date' => '',
  7417. 'opinion' => '',
  7418. 'status' => '',
  7419. 'rolename' => $rolename ['name']
  7420. );
  7421. array_push ( $roleArray, $exp );
  7422. }
  7423. $roleArrayCopy [$v [0]] = $roleArray;
  7424. // $verifyList[$k]['roleArray']=$roleArray;
  7425. }
  7426. $verifyList [$k] ['date'] = "";
  7427. $verifyList [$k] ['opinion'] = "";
  7428. $verifyList [$k] ['status'] = "";
  7429. if (empty ( $verifyStaff )) {
  7430. $verifyList [$k] ['date'] = "";
  7431. $verifyList [$k] ['opinion'] = "";
  7432. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7433. $verifyList [$k] ['status'] = 4;
  7434. $flag = false;
  7435. }
  7436. } else {
  7437. foreach ( $verifyStaff as $m => $u ) {
  7438. if ($v [0] == $m) {
  7439. $verifyList [$k] ['date'] = $u ['date'];
  7440. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7441. $verifyList [$k] ['status'] = $u ['status'];
  7442. $flag = false;
  7443. break;
  7444. }
  7445. }
  7446. $endStaffArray = end ( $verifyStaff );
  7447. if (isset ( $endStaffArray ['ROLE'] )) {
  7448. } else {
  7449. // $endKey=key($verifyStaff);
  7450. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7451. // $button=4;
  7452. // $verifyList[$k]['status']=4;
  7453. // }
  7454. }
  7455. }
  7456. }
  7457. $rolename ['name'] = '';
  7458. if (! empty ( $roleId )) {
  7459. Doo::loadModel ( 'role' );
  7460. $role = new role ();
  7461. $rolename = $role->getOne ( array (
  7462. 'where' => 'rid=' . $roleId,
  7463. 'asArray' => true
  7464. ) );
  7465. }
  7466. if (! empty ( $verifyStaff ))
  7467. $endStaffArray = end ( $verifyStaff );
  7468. $KOP = false;
  7469. foreach ( $roleArrayCopy as $P => $A ) {
  7470. foreach ( $A as $MKI => $AVL ) {
  7471. if (! empty ( $verifyStaff )) {
  7472. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7473. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7474. $button = 4;
  7475. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7476. }
  7477. foreach ( $verifyStaff as $m => $u ) {
  7478. $AVLFK = $AVL [0] . '_R';
  7479. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7480. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7481. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7482. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7483. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7484. break;
  7485. }
  7486. }
  7487. } else {
  7488. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7489. $button = 4;
  7490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7491. }
  7492. }
  7493. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7494. $KOP = true;
  7495. }
  7496. }
  7497. foreach ( $roleArrayCopy as $k => $v ) {
  7498. foreach ( $verifyList as $m => $n ) {
  7499. if ($n [0] == $k) {
  7500. array_splice ( $verifyList, $m, 1, $v );
  7501. }
  7502. }
  7503. }
  7504. $receiptList [$key] ['verifyList'] = $verifyList;
  7505. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7506. 'where' => 'sid=' . $value ['staff'],
  7507. 'asArray' => true
  7508. ) );
  7509. $receiptList [$key] ['button'] = $button;
  7510. }
  7511. // print_r($receiptList);die;
  7512. $mothHtml = "";
  7513. for($i = 1; $i <= 12; $i ++) {
  7514. if ($moth == $i)
  7515. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7516. else
  7517. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7518. }
  7519. $data ['mothHtml'] = $mothHtml;
  7520. $data ['receiptList'] = $receiptList;
  7521. $data ['memu'] = "receipt";
  7522. $data ['staff'] = $this->staff;
  7523. $data ['receiptMemu'] = 'receipt';
  7524. $data ['verifyId'] = $this->verifyId;
  7525. $data ['executeId'] = $this->executeId;
  7526. $data ['item'] = $item;
  7527. $data ['year'] = $year;
  7528. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7529. // sufficient condition to generate cache
  7530. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7531. $receiptList = $receipt->find ( array (
  7532. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7533. 'asArray' => true
  7534. ) );
  7535. if (empty ( $receiptList )) { // generated files
  7536. ob_start ();
  7537. $this->render ( "/admin/saea_myList", $data );
  7538. $this->cacheFile ( $path );
  7539. die ();
  7540. // $content = ob_get_contents();
  7541. // $fp = fopen($path, "w");
  7542. // fwrite($fp, $content);
  7543. // fclose($fp);
  7544. }
  7545. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7546. $receiptList = $receipt->find ( array (
  7547. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7548. 'asArray' => true
  7549. ) );
  7550. if (empty ( $receiptList )) { // generated files
  7551. ob_start ();
  7552. $this->render ( "/admin/saea_myList", $data );
  7553. $this->cacheFile ( $path );
  7554. die ();
  7555. }
  7556. }
  7557. }
  7558. $this->render ( "/admin/saea_myList", $data );
  7559. }
  7560. function approvedReceipt() {
  7561. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7562. Doo::loadModel ( 'receipt' );
  7563. Doo::loadModel ( 'receiptDetail' );
  7564. $receipt = new receipt ();
  7565. $receiptDetail = new receiptDetail ();
  7566. Doo::loadModel ( 'statistics' );
  7567. Doo::loadModel ( 'itemStatistics' );
  7568. $statistics = new statistics ();
  7569. $itemStatistics = new itemStatistics ();
  7570. Doo::loadModel ( "verify" );
  7571. $verify = new verify ();
  7572. // 审批状态的判定
  7573. $receiptDetailList = $receipt->getOne ( array (
  7574. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7575. 'asArray' => true
  7576. ) );
  7577. if (empty ( $receiptDetailList )){
  7578. return "/saeaBorad";
  7579. }
  7580. // 如果是新报销单,有差旅的情况下写入日期
  7581. if($receiptDetailList['version']==1){
  7582. if(!empty($receiptDetailList['traveJson'])){
  7583. $traveJson=json_decode($receiptDetailList['traveJson'],true)['traveList'];
  7584. foreach ($traveJson as $key=>$value){
  7585. Doo::loadModel ( 'cld/traveDate_cld' );
  7586. $traveDate = new traveDate_cld ();
  7587. $traveDate->sid=$this->staff [0] ['sid'];
  7588. $traveDate->rid=$receiptDetailList['rid'];
  7589. $tripTime = explode(" - ", $value['tripTime']);
  7590. $traveDate->start=$tripTime[0];
  7591. $traveDate->end=$tripTime[1];
  7592. $traveDate->insert ();
  7593. }
  7594. }
  7595. }
  7596. $verifyDetail = $verify->getOne ( array (
  7597. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7598. 'asArray' => true
  7599. ) );
  7600. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7601. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7602. $nowStaff = "";
  7603. $nowStaffList = array ();
  7604. if ($verifyDetail [0] [1] == 'ROLE') {
  7605. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7606. foreach ( $vStaffString as $key => $value ) {
  7607. $staffK = explode ( "_", $value );
  7608. array_push ( $nowStaffList, $staffK [0] );
  7609. }
  7610. $nowStaff = implode ( ',', $nowStaffList );
  7611. } else {
  7612. $nowStaff = $verifyDetail [0] [0];
  7613. }
  7614. $receipt->nowStaff = $nowStaff;
  7615. }
  7616. // echo $nowStaff;
  7617. // print_r($verifyDetail);die;
  7618. $receipt->rid = $receiptDetailList ['rid'];
  7619. $receipt->date = date ( "Y-m-d" );
  7620. $receipt->status = 2;
  7621. $receipt->update ();
  7622. $receiptDetail->status = 2;
  7623. $receiptDetail->update ( array (
  7624. 'where' => 'rid=' . $receiptDetailList ['rid']
  7625. ) );
  7626. Doo::loadModel ( "receiptLog" );
  7627. $receiptLog = new receiptLog ();
  7628. Doo::loadModel ( "verify" );
  7629. $verify = new verify ();
  7630. $receiptInfo = $receipt->getOne ( array (
  7631. 'where' => 'rid=' . $rid,
  7632. 'asArray' => true
  7633. ) );
  7634. $vr = $verify->getOne ( array (
  7635. 'where' => 'vid=' . $receiptInfo ['verify'],
  7636. 'asArray' => true
  7637. ) );
  7638. $jd = json_decode ( $vr ['staff'] );
  7639. $roleId = 0;
  7640. foreach ( $jd as $key => $value ) {
  7641. if ($value [1] == 'ROLE') {
  7642. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7643. if ($pos !== false) {
  7644. $roleId = $value [0];
  7645. }
  7646. }
  7647. }
  7648. // 审批日志
  7649. // echo $roleId;die;
  7650. if (! empty ( $roleId )) {
  7651. Doo::loadModel ( "role" );
  7652. $role = new role ();
  7653. $roleInfo = $role->getOne ( array (
  7654. 'where' => 'rid=' . $roleId,
  7655. 'asArray' => true
  7656. ) );
  7657. // $receiptLog->rolename = $roleInfo ['name'];
  7658. }
  7659. $receiptLog->username = $this->staff [0] ['username'];
  7660. $receiptLog->uid = $this->staff [0] ['sid'];
  7661. $receiptLog->date = date ( "Y-m-d" );
  7662. $receiptLog->opinion = '提交审批';
  7663. $receiptLog->img = $this->staff [0] ['avatar'];
  7664. $receiptLog->status = 2;
  7665. $receiptLog->rid = $rid;
  7666. $receiptLog->insert ();
  7667. // statistics item
  7668. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7669. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7670. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7671. $stat = $statistics->getOne ( array (
  7672. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7673. 'asArray' => true
  7674. ) );
  7675. if (empty ( $stat )) {
  7676. $statistics->date = date ( "Y-m-d" );
  7677. $statistics->cid = $this->staff [0] ['cid'];
  7678. $statistics->staff = $this->staff [0] ['sid'];
  7679. $statistics->agPrice = 0;
  7680. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7681. $statistics->insert ();
  7682. } else {
  7683. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7684. $statistics->update ( array (
  7685. 'where' => 'sid=' . $stat ['sid']
  7686. ) );
  7687. }
  7688. return "/expenses";
  7689. }
  7690. function approval() {
  7691. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7692. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7693. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7694. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7695. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7696. if (empty ( $status ))
  7697. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7698. $vidList = array ();
  7699. $button = 0;
  7700. Doo::loadModel ( 'verify' );
  7701. $verify = new verify ();
  7702. Doo::loadModel ( 'receipt' );
  7703. $receipt = new receipt ();
  7704. Doo::loadModel ( 'staff' );
  7705. $staff = new staff ();
  7706. Doo::loadModel ( 'L_category' );
  7707. $Lcategory = new L_category ();
  7708. // user verify ID
  7709. $verifyDetail = $verify->find ( array (
  7710. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7711. 'asArray' => true
  7712. ) );
  7713. foreach ( $verifyDetail as $key => $value ) {
  7714. array_push ( $vidList, $value ['vid'] );
  7715. }
  7716. $vid = implode ( ",", $vidList );
  7717. if (empty ( $verifyDetail ))
  7718. $vid = 0;
  7719. /*
  7720. */
  7721. $dateCondition = " and Year(date) =" . $year;
  7722. if (! empty ( $month ))
  7723. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7724. $categoryList = $Lcategory->find ( array (
  7725. 'asArray' => true
  7726. ) );
  7727. $staffList = $staff->find ( array (
  7728. 'where' => 'cid=' . $cid,
  7729. 'asArray' => true
  7730. ) );
  7731. $cateCondition = "";
  7732. $staffCondition = "";
  7733. $approvalCondition = "";
  7734. if (! empty ( $cid ))
  7735. $cateCondition = ' and cid=' . $cid;
  7736. if (! empty ( $sid )) {
  7737. $staffCondition = ' and staff=' . $sid;
  7738. $cateCondition = "";
  7739. }
  7740. // elseif($status==1){
  7741. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7742. // }
  7743. if ($status == 2) {
  7744. // 查找角色审批人
  7745. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7746. }
  7747. $ap = "";
  7748. if ($status == 4) {
  7749. $ap = 4;
  7750. $status = 2;
  7751. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7752. }
  7753. if ($status == 5) {
  7754. $status = 4;
  7755. $ap = 5;
  7756. }
  7757. // echo $vid;
  7758. // get Receipt By verifyID status 2 .$approvalCondition
  7759. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7760. $receiptList = $receipt->find ( array (
  7761. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7762. 'desc' => 'rid',
  7763. 'asArray' => true
  7764. ) );
  7765. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7766. $Locate = 0;
  7767. if ($ap == 4)
  7768. $status = 4;
  7769. elseif ($ap == 5)
  7770. $status = 5;
  7771. foreach ( $receiptList as $key => $value ) {
  7772. $receiptList [$key] ['Locate'] = $Locate;
  7773. $Locate ++;
  7774. $receiptList [$key] ['reviseDetail'] = array ();
  7775. if (! empty ( $value ['reviseDetail'] ))
  7776. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7777. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7778. $categoryDetil = $Lcategory->getOne ( array (
  7779. 'where' => 'cid=' . $value ['cid'],
  7780. 'asArray' => true
  7781. ) );
  7782. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7783. $verifyList = $verify->getOne ( array (
  7784. 'where' => 'vid=' . $value ['verify'],
  7785. 'asArray' => true
  7786. ) );
  7787. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7788. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7789. foreach ( $verifyList as $k => $v ) {
  7790. // init verifyStaff
  7791. $verifyList [$k] ['date'] = "";
  7792. $verifyList [$k] ['opinion'] = "";
  7793. $verifyList [$k] ['status'] = "";
  7794. if (empty ( $verifyStaff )) {
  7795. $verifyList [$k] ['date'] = "";
  7796. $verifyList [$k] ['opinion'] = "";
  7797. if ($v [0] == $this->staff [0] ['sid']) {
  7798. $verifyList [$k] ['status'] = 4;
  7799. $button = 4;
  7800. }
  7801. } else {
  7802. $flag = true;
  7803. foreach ( $verifyStaff as $m => $u ) {
  7804. if ($v [0] == $m) {
  7805. $verifyList [$k] ['date'] = $u ['date'];
  7806. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7807. $verifyList [$k] ['status'] = $u ['status'];
  7808. $flag = false;
  7809. break;
  7810. }
  7811. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7812. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7813. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7814. }
  7815. if ($flag) { // 检测可编辑
  7816. if ($v [0] == $this->staff [0] ['sid']) {
  7817. $verifyList [$k] ['status'] = 4;
  7818. $button = 4;
  7819. }
  7820. }
  7821. }
  7822. }
  7823. $receiptList [$key] ['verifyList'] = $verifyList;
  7824. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7825. 'where' => 'sid=' . $value ['staff'],
  7826. 'asArray' => true
  7827. ) );
  7828. $receiptList [$key] ['button'] = $button;
  7829. }
  7830. // print_r($receiptList);die;
  7831. // $data['verifyDetail']=$verifyDetail;
  7832. $mothHtml = "";
  7833. for($i = 1; $i <= 12; $i ++) {
  7834. if ($month == $i)
  7835. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7836. else
  7837. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7838. }
  7839. $data ['mothHtml'] = $mothHtml;
  7840. $data ['receiptList'] = $receiptList;
  7841. $data ['receiptApprovalCount'] = count ( $receiptList );
  7842. $data ['status'] = $status;
  7843. $data ['year'] = $year;
  7844. $data ['categoryList'] = $categoryList;
  7845. $data ['staffList'] = $staffList;
  7846. $data ['cid'] = $cid;
  7847. $data ['sid'] = $sid;
  7848. $data ['ap'] = $ap;
  7849. $data ['memu'] = "receipt";
  7850. $data ['staff'] = $this->staff;
  7851. $data ['receiptMemu'] = 'approval';
  7852. $data ['verifyId'] = $this->verifyId;
  7853. $data ['executeId'] = $this->executeId;
  7854. $this->render ( "/admin/saea_reportList", $data );
  7855. }
  7856. function approvalDetails() {
  7857. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7858. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7859. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7860. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7861. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7862. Doo::loadModel ( 'verify' );
  7863. $verify = new verify ();
  7864. Doo::loadModel ( 'receipt' );
  7865. $receipt = new receipt ();
  7866. Doo::loadModel ( 'staff' );
  7867. $staff = new staff ();
  7868. Doo::loadModel ( 'L_category' );
  7869. $Lcategory = new L_category ();
  7870. Doo::loadModel ( 'enclosur' );
  7871. $enclosur = new enclosur ();
  7872. $vidList = array ();
  7873. $verifyDetail = $verify->find ( array (
  7874. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7875. 'asArray' => true
  7876. ) );
  7877. foreach ( $verifyDetail as $key => $value ) {
  7878. array_push ( $vidList, $value ['vid'] );
  7879. }
  7880. $vid = implode ( ",", $vidList );
  7881. if (empty ( $verifyDetail ))
  7882. $vid = 0;
  7883. $categoryList = $Lcategory->find ( array (
  7884. 'asArray' => true
  7885. ) );
  7886. $staffList = $staff->find ( array (
  7887. 'where' => 'cid=' . $cid,
  7888. 'asArray' => true
  7889. ) );
  7890. $ap = 0;
  7891. $receiptList = $receipt->find ( array (
  7892. 'where' => 'rid =' . $rid,
  7893. 'desc' => 'rid',
  7894. 'asArray' => true
  7895. ) );
  7896. $Locate = 0;
  7897. $roleId = 0;
  7898. $button = 0;
  7899. foreach ( $receiptList as $key => $value ) {
  7900. $receiptList [$key] ['Locate'] = $Locate;
  7901. $Locate ++;
  7902. $receiptList [$key] ['reviseDetail'] = array ();
  7903. if (! empty ( $value ['reviseDetail'] ))
  7904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7906. $categoryDetil = $Lcategory->getOne ( array (
  7907. 'where' => 'cid=' . $value ['cid'],
  7908. 'asArray' => true
  7909. ) );
  7910. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7911. // 检测编辑状态
  7912. $verifyList = $verify->getOne ( array (
  7913. 'where' => 'vid=' . $value ['verify'],
  7914. 'asArray' => true
  7915. ) );
  7916. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7917. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7918. Doo::loadModel ( 'role' );
  7919. $role = new role ();
  7920. // print_r($verifyList);
  7921. $flag = true;
  7922. $roleKey = 0;
  7923. $endStaffArray = array ();
  7924. $roleArrayCopy = array ();
  7925. foreach ( $verifyList as $k => $v ) {
  7926. // init verifyStaff
  7927. if ($v [1] == 'ROLE') {
  7928. if (! empty ( $verifyStaff )) {
  7929. $endStaffArray = end ( $verifyStaff );
  7930. if ($v [0] == $endStaffArray ['nextStaff']) {
  7931. $roleId = $v [0];
  7932. }
  7933. }
  7934. $roleVerify = json_decode ( $v [3], true );
  7935. $roleKey = $k;
  7936. $roleArray = array ();
  7937. $rolename = $role->getOne ( array (
  7938. 'where' => 'rid=' . $v [0],
  7939. 'asArray' => true
  7940. ) );
  7941. foreach ( $roleVerify as $o => $p ) {
  7942. $staffID = explode ( '_', $p );
  7943. $staffInfo = $staff->getOne ( array (
  7944. 'where' => 'sid=' . $staffID [0],
  7945. 'asArray' => true
  7946. ) );
  7947. // print_r($staffID);
  7948. $exp = array (
  7949. 0 => $staffInfo ['sid'],
  7950. 1 => $staffID [1],
  7951. 2 => $staffInfo ['avatar'],
  7952. 'date' => '',
  7953. 'date' => '',
  7954. 'opinion' => '',
  7955. 'status' => '',
  7956. 'rolename' => $rolename ['name']
  7957. );
  7958. array_push ( $roleArray, $exp );
  7959. }
  7960. $roleArrayCopy [$v [0]] = $roleArray;
  7961. // $verifyList[$k]['roleArray']=$roleArray;
  7962. }
  7963. // print_r($roleArray);
  7964. $verifyList [$k] ['date'] = "";
  7965. $verifyList [$k] ['opinion'] = "";
  7966. $verifyList [$k] ['status'] = "";
  7967. if (empty ( $verifyStaff )) {
  7968. $verifyList [$k] ['date'] = "";
  7969. $verifyList [$k] ['opinion'] = "";
  7970. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7971. $verifyList [$k] ['status'] = 4;
  7972. $button = 4;
  7973. $flag = false;
  7974. }
  7975. } else {
  7976. foreach ( $verifyStaff as $m => $u ) {
  7977. if ($v [0] == $m) {
  7978. $verifyList [$k] ['date'] = $u ['date'];
  7979. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7980. $verifyList [$k] ['status'] = $u ['status'];
  7981. $flag = false;
  7982. break;
  7983. }
  7984. }
  7985. $endStaffArray = end ( $verifyStaff );
  7986. if (isset ( $endStaffArray ['ROLE'] )) {
  7987. } else {
  7988. $endKey = key ( $verifyStaff );
  7989. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7990. $button = 4;
  7991. $verifyList [$k] ['status'] = 4;
  7992. }
  7993. }
  7994. }
  7995. }
  7996. $rolename ['name'] = '';
  7997. if (! empty ( $roleId )) {
  7998. Doo::loadModel ( 'role' );
  7999. $role = new role ();
  8000. $rolename = $role->getOne ( array (
  8001. 'where' => 'rid=' . $roleId,
  8002. 'asArray' => true
  8003. ) );
  8004. }
  8005. if (! empty ( $verifyStaff ))
  8006. $endStaffArray = end ( $verifyStaff );
  8007. $KOP = false;
  8008. foreach ( $roleArrayCopy as $P => $A ) {
  8009. foreach ( $A as $MKI => $AVL ) {
  8010. if (! empty ( $verifyStaff )) {
  8011. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8012. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8013. $button = 4;
  8014. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8015. }
  8016. foreach ( $verifyStaff as $m => $u ) {
  8017. $AVLFK = $AVL [0] . '_R';
  8018. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8019. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8020. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8021. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8022. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8023. break;
  8024. }
  8025. }
  8026. } else {
  8027. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8028. $button = 4;
  8029. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8030. }
  8031. }
  8032. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8033. $KOP = true;
  8034. }
  8035. }
  8036. foreach ( $roleArrayCopy as $k => $v ) {
  8037. foreach ( $verifyList as $m => $n ) {
  8038. if ($n [0] == $k) {
  8039. array_splice ( $verifyList, $m, 1, $v );
  8040. }
  8041. }
  8042. }
  8043. $receiptList [$key] ['verifyList'] = $verifyList;
  8044. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8045. 'where' => 'sid=' . $value ['staff'],
  8046. 'asArray' => true
  8047. ) );
  8048. $receiptList [$key] ['button'] = $button;
  8049. }
  8050. $mothHtml = "";
  8051. for($i = 1; $i <= 12; $i ++) {
  8052. if ($month == $i)
  8053. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8054. else
  8055. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8056. }
  8057. // 获取审批日志
  8058. Doo::loadModel ( 'receiptLog' );
  8059. $receiptLog = new receiptLog ();
  8060. $rlList = array ();
  8061. $rlInfo = $receiptLog->getOne ( array (
  8062. 'where' => 'rid=' . $rid . ' and status=4',
  8063. 'asArray' => true
  8064. ) );
  8065. $tijdate = $receiptLog->getOne ( array (
  8066. 'where' => 'rid=' . $rid . ' and status=2',
  8067. 'asc' => 'rlid',
  8068. 'asArray' => true
  8069. ) );
  8070. if (! empty ( $rlInfo )) {
  8071. $rlList = $receiptLog->find ( array (
  8072. 'where' => 'rid=' . $rid,
  8073. 'asc' => 'rlid',
  8074. 'asArray' => true
  8075. ) );
  8076. }
  8077. $receiptList [0] ['rlList'] = $rlList;
  8078. $enclosurList = $enclosur->find ( array (
  8079. 'where' => 'rid=' . $rid,
  8080. 'asArray' => true
  8081. ) );
  8082. $enclosurHtml = '';
  8083. foreach ( $enclosurList as $value ) {
  8084. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8085. }
  8086. $data ['enclosurHtml'] = $enclosurHtml;
  8087. $data ['rolename'] = $rolename ['name'];
  8088. $data ['datetij'] = $tijdate ['date'];
  8089. $data ['mothHtml'] = $mothHtml;
  8090. $data ['receiptList'] = $receiptList;
  8091. $data ['receiptApprovalCount'] = count ( $receiptList );
  8092. $data ['year'] = $year;
  8093. $data ['categoryList'] = $categoryList;
  8094. $data ['staffList'] = $staffList;
  8095. $data ['cid'] = $cid;
  8096. $data ['sid'] = $sid;
  8097. $data ['status'] = 0;
  8098. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8099. $ap = 4;
  8100. } else
  8101. $data ['status'] = $receiptList [0] ['status'];
  8102. if ($receiptList [0] ['status'] == 4) {
  8103. $data ['status'] = 5;
  8104. $ap = 0;
  8105. }
  8106. $data ['ap'] = $ap;
  8107. $data ['memu'] = "receipt";
  8108. $data ['staff'] = $this->staff;
  8109. $data ['receiptMemu'] = 'approval';
  8110. $data ['verifyId'] = $this->verifyId;
  8111. $data ['executeId'] = $this->executeId;
  8112. $this->render ( "/admin/saeaReportListReport", $data );
  8113. }
  8114. function approvalEdi() {
  8115. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8116. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8117. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8118. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8119. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8120. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8121. if (empty ( $status ))
  8122. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8123. $vidList = array ();
  8124. $button = 0;
  8125. Doo::loadModel ( 'verify' );
  8126. Doo::loadModel ( 'receipt' );
  8127. Doo::loadModel ( 'staff' );
  8128. $staff = new staff ();
  8129. $receipt = new receipt ();
  8130. $verify = new verify ();
  8131. Doo::loadModel ( 'L_category' );
  8132. $Lcategory = new L_category ();
  8133. Doo::loadModel ( 'enclosur' );
  8134. $enclosur = new enclosur ();
  8135. // user verify ID
  8136. $verifyDetail = $verify->find ( array (
  8137. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8138. 'asArray' => true
  8139. ) );
  8140. foreach ( $verifyDetail as $key => $value ) {
  8141. array_push ( $vidList, $value ['vid'] );
  8142. }
  8143. $vid = implode ( ",", $vidList );
  8144. if (empty ( $verifyDetail ))
  8145. $vid = 0;
  8146. $categoryList = $Lcategory->find ( array (
  8147. 'asArray' => true
  8148. ) );
  8149. $staffList = $staff->find ( array (
  8150. 'where' => 'cid=' . $cid,
  8151. 'asArray' => true
  8152. ) );
  8153. $ap = "";
  8154. if ($status == 4) {
  8155. $ap = 4;
  8156. $status = 2;
  8157. }
  8158. // get Receipt By verifyID status 2
  8159. $receiptList = $receipt->find ( array (
  8160. 'where' => 'rid =' . $rid,
  8161. 'desc' => 'rid',
  8162. 'asArray' => true
  8163. ) );
  8164. $Locate = 0;
  8165. $roleId = 0;
  8166. if ($ap == 4)
  8167. $status = 4;
  8168. foreach ( $receiptList as $key => $value ) {
  8169. $receiptList [$key] ['Locate'] = $Locate;
  8170. $Locate ++;
  8171. $receiptList [$key] ['reviseDetail'] = array ();
  8172. if (! empty ( $value ['reviseDetail'] ))
  8173. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8174. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8175. $categoryDetil = $Lcategory->getOne ( array (
  8176. 'where' => 'cid=' . $value ['cid'],
  8177. 'asArray' => true
  8178. ) );
  8179. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8180. // 检测编辑状态
  8181. $verifyList = $verify->getOne ( array (
  8182. 'where' => 'vid=' . $value ['verify'],
  8183. 'asArray' => true
  8184. ) );
  8185. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8186. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8187. // print_r($verifyList);
  8188. //
  8189. // if (empty($verifyStaff)){
  8190. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8191. // $verifyList[0]['status']=4;$button=4;
  8192. // }
  8193. //
  8194. // }else{
  8195. //
  8196. // }
  8197. // die;
  8198. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8199. // echo array_search("green",$a);
  8200. //
  8201. Doo::loadModel ( 'role' );
  8202. $role = new role ();
  8203. // print_r($verifyList);
  8204. $flag = true;
  8205. $roleKey = 0;
  8206. $endStaffArray = array ();
  8207. $roleArrayCopy = array ();
  8208. foreach ( $verifyList as $k => $v ) {
  8209. // init verifyStaff
  8210. if ($v [1] == 'ROLE') {
  8211. if (! empty ( $verifyStaff )) {
  8212. $endStaffArray = end ( $verifyStaff );
  8213. if ($v [0] == $endStaffArray ['nextStaff']) {
  8214. $roleId = $v [0];
  8215. }
  8216. }
  8217. $roleVerify = json_decode ( $v [3], true );
  8218. $roleKey = $k;
  8219. $roleArray = array ();
  8220. $rolename = $role->getOne ( array (
  8221. 'where' => 'rid=' . $v [0],
  8222. 'asArray' => true
  8223. ) );
  8224. foreach ( $roleVerify as $o => $p ) {
  8225. $staffID = explode ( '_', $p );
  8226. $staffInfo = $staff->getOne ( array (
  8227. 'where' => 'sid=' . $staffID [0],
  8228. 'asArray' => true
  8229. ) );
  8230. // print_r($staffID);
  8231. $exp = array (
  8232. 0 => $staffInfo ['sid'],
  8233. 1 => $staffID [1],
  8234. 2 => $staffInfo ['avatar'],
  8235. 'date' => '',
  8236. 'date' => '',
  8237. 'opinion' => '',
  8238. 'status' => '',
  8239. 'rolename' => $rolename ['name']
  8240. );
  8241. array_push ( $roleArray, $exp );
  8242. }
  8243. $roleArrayCopy [$v [0]] = $roleArray;
  8244. // $verifyList[$k]['roleArray']=$roleArray;
  8245. }
  8246. // print_r($roleArray);
  8247. $verifyList [$k] ['date'] = "";
  8248. $verifyList [$k] ['opinion'] = "";
  8249. $verifyList [$k] ['status'] = "";
  8250. if (empty ( $verifyStaff )) {
  8251. $verifyList [$k] ['date'] = "";
  8252. $verifyList [$k] ['opinion'] = "";
  8253. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8254. $verifyList [$k] ['status'] = 4;
  8255. $button = 4;
  8256. $flag = false;
  8257. }
  8258. } else {
  8259. foreach ( $verifyStaff as $m => $u ) {
  8260. if ($v [0] == $m) {
  8261. $verifyList [$k] ['date'] = $u ['date'];
  8262. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8263. $verifyList [$k] ['status'] = $u ['status'];
  8264. $flag = false;
  8265. break;
  8266. }
  8267. }
  8268. $endStaffArray = end ( $verifyStaff );
  8269. if (isset ( $endStaffArray ['ROLE'] )) {
  8270. } else {
  8271. $endKey = key ( $verifyStaff );
  8272. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8273. $button = 4;
  8274. $verifyList [$k] ['status'] = 4;
  8275. }
  8276. }
  8277. // print_r($endStaffArray);die;
  8278. // if (empty($verifyStaff)){
  8279. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8280. // $verifyList[$k]['status']=4;$button=4;
  8281. // }
  8282. //
  8283. // }else{
  8284. //
  8285. // }
  8286. // if($flag){//检测可编辑
  8287. // if($v[0]==$this->staff[0]['sid']){
  8288. // $verifyList[$k]['status']=4;$button=4;
  8289. // }
  8290. // }
  8291. }
  8292. }
  8293. $rolename ['name'] = '';
  8294. if (! empty ( $roleId )) {
  8295. Doo::loadModel ( 'role' );
  8296. $role = new role ();
  8297. $rolename = $role->getOne ( array (
  8298. 'where' => 'rid=' . $roleId,
  8299. 'asArray' => true
  8300. ) );
  8301. }
  8302. if (! empty ( $verifyStaff ))
  8303. $endStaffArray = end ( $verifyStaff );
  8304. $KOP = false;
  8305. foreach ( $roleArrayCopy as $P => $A ) {
  8306. foreach ( $A as $MKI => $AVL ) {
  8307. if (! empty ( $verifyStaff )) {
  8308. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8309. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8310. $button = 4;
  8311. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8312. }
  8313. foreach ( $verifyStaff as $m => $u ) {
  8314. $AVLFK = $AVL [0] . '_R';
  8315. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8316. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8317. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8318. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8319. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8320. break;
  8321. }
  8322. }
  8323. } else {
  8324. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8325. $button = 4;
  8326. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8327. }
  8328. }
  8329. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8330. $KOP = true;
  8331. }
  8332. }
  8333. // print_r($roleArrayCopy);
  8334. // echo $roleKey;
  8335. foreach ( $roleArrayCopy as $k => $v ) {
  8336. foreach ( $verifyList as $m => $n ) {
  8337. if ($n [0] == $k) {
  8338. array_splice ( $verifyList, $m, 1, $v );
  8339. }
  8340. }
  8341. }
  8342. // if ($KOP)
  8343. // array_splice($verifyList,$roleKey,1,$roleArray);
  8344. // print_r($verifyList);
  8345. $receiptList [$key] ['verifyList'] = $verifyList;
  8346. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8347. 'where' => 'sid=' . $value ['staff'],
  8348. 'asArray' => true
  8349. ) );
  8350. $receiptList [$key] ['button'] = $button;
  8351. }
  8352. // $data['verifyDetail']=$verifyDetail;
  8353. $mothHtml = "";
  8354. for($i = 1; $i <= 12; $i ++) {
  8355. if ($month == $i)
  8356. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8357. else
  8358. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8359. }
  8360. // 获取审批日志
  8361. Doo::loadModel ( 'receiptLog' );
  8362. $receiptLog = new receiptLog ();
  8363. $rlList = array ();
  8364. $rlInfo = $receiptLog->getOne ( array (
  8365. 'where' => 'rid=' . $rid . ' and status=4',
  8366. 'asArray' => true
  8367. ) );
  8368. $tijdate = $receiptLog->getOne ( array (
  8369. 'where' => 'rid=' . $rid . ' and status=2',
  8370. 'asc' => 'rlid',
  8371. 'asArray' => true
  8372. ) );
  8373. if (! empty ( $rlInfo )) {
  8374. $rlList = $receiptLog->find ( array (
  8375. 'where' => 'rid=' . $rid,
  8376. 'asc' => 'rlid',
  8377. 'asArray' => true
  8378. ) );
  8379. }
  8380. $receiptList [0] ['rlList'] = $rlList;
  8381. $enclosurList = $enclosur->find ( array (
  8382. 'where' => 'rid=' . $rid,
  8383. 'asArray' => true
  8384. ) );
  8385. $enclosurHtml = '';
  8386. foreach ( $enclosurList as $value ) {
  8387. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8388. }
  8389. $data ['enclosurHtml'] = $enclosurHtml;
  8390. $data ['rolename'] = $rolename ['name'];
  8391. $data ['datetij'] = $tijdate ['date'];
  8392. $data ['mothHtml'] = $mothHtml;
  8393. $data ['receiptList'] = $receiptList;
  8394. $data ['receiptApprovalCount'] = count ( $receiptList );
  8395. $data ['status'] = $status;
  8396. $data ['year'] = $year;
  8397. $data ['categoryList'] = $categoryList;
  8398. $data ['staffList'] = $staffList;
  8399. $data ['cid'] = $cid;
  8400. $data ['sid'] = $sid;
  8401. $data ['ap'] = $ap;
  8402. $data ['memu'] = "receipt";
  8403. $data ['staff'] = $this->staff;
  8404. $data ['receiptMemu'] = 'approval';
  8405. $data ['verifyId'] = $this->verifyId;
  8406. $data ['executeId'] = $this->executeId;
  8407. $this->render ( "/admin/saeaReportListReport", $data );
  8408. }
  8409. function remittanceHky() {
  8410. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8411. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8412. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8413. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8414. $page_size = 15;
  8415. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8416. Doo::loadModel ( 'receipt' );
  8417. $receipt = new receipt ();
  8418. Doo::loadModel ( 'staff' );
  8419. $staff = new staff ();
  8420. $dateCondition = " and Year(executeDate) =" . $year;
  8421. if ($moth != 'MONTH')
  8422. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8423. if ($day != 'DAY' && $moth != 'MONTH')
  8424. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8425. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8426. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8427. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8428. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8429. $dayList = $receipt->find ( array (
  8430. 'select' => 'executeDate,sum(amount) as amount',
  8431. 'where' => $sql,
  8432. 'desc' => 'executeDate',
  8433. 'groupby' => 'executeDate',
  8434. 'limit' => $limit,
  8435. 'asArray' => true
  8436. ) );
  8437. // print_r($dayList);
  8438. foreach ( $dayList as $key => $value ) {
  8439. $remitString = "";
  8440. $receiptList = $receipt->find ( array (
  8441. 'select' => 'rid,executeDate,amount,staff,cid',
  8442. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8443. 'desc' => 'executeDate',
  8444. 'asArray' => true
  8445. ) );
  8446. foreach ( $receiptList as $k => $v ) {
  8447. $sinfo = $staff->getOne ( array (
  8448. 'select' => 'username,category',
  8449. 'where' => ' sid=' . $v ['staff'],
  8450. 'asArray' => true
  8451. ) );
  8452. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8453. }
  8454. $dayList [$key] ['staff'] = $remitString;
  8455. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8456. }
  8457. // print_r($dayList);
  8458. $mothHtml = "";
  8459. for($i = 1; $i <= 12; $i ++) {
  8460. if ($moth == $i)
  8461. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8462. else
  8463. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8464. }
  8465. $dayHtml = "";
  8466. if ($day != "DAY" || $moth != "MONTH") {
  8467. for($i = 1; $i <= 31; $i ++) {
  8468. if ($day == $i)
  8469. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8470. else
  8471. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8472. }
  8473. }
  8474. $dateHtml = "";
  8475. $now = date ( "Y" );
  8476. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8477. if ($YEARD <= $now) {
  8478. $dateHtml .= '<option ';
  8479. if ($year == $YEARD) {
  8480. $dateHtml .= 'selected ';
  8481. }
  8482. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8483. }
  8484. }
  8485. $data ['dateHtml'] = $dateHtml;
  8486. $data ['page'] = $pageinfo;
  8487. $data ['year'] = $year;
  8488. $data ['moth'] = $moth;
  8489. $data ['day'] = $day;
  8490. $data ['get'] = $get;
  8491. $data ['dayHtml'] = $dayHtml;
  8492. $data ['mothHtml'] = $mothHtml;
  8493. $data ['receiptList'] = $dayList;
  8494. $data ['memu'] = "receipt";
  8495. $data ['staff'] = $this->staff;
  8496. $data ['receiptMemu'] = 'remittanceHky';
  8497. $data ['verifyId'] = $this->verifyId;
  8498. $data ['executeId'] = $this->executeId;
  8499. $this->render ( "/admin/remittanceHky", $data );
  8500. }
  8501. function remittancep() {
  8502. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8503. Doo::loadModel ( 'receipt' );
  8504. $receipt = new receipt ();
  8505. Doo::loadModel ( 'staff' );
  8506. $staff = new staff ();
  8507. Doo::loadClass ( 'XDeode' );
  8508. $XDeode = new XDeode ( 5 );
  8509. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8510. $rplist = $receipt->find ( array (
  8511. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8512. 'asArray' => true
  8513. ) );
  8514. $dayList = $receipt->find ( array (
  8515. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8516. 'desc' => 'executeDate',
  8517. 'groupby' => 'staff',
  8518. 'asArray' => true
  8519. ) );
  8520. $html = '';
  8521. foreach ( $dayList as $key => $value ) {
  8522. $sinfo = $staff->getOne ( array (
  8523. 'select' => 'username,category',
  8524. 'where' => ' sid=' . $value ['staff'],
  8525. 'asArray' => true
  8526. ) );
  8527. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8528. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8529. $au = 0;
  8530. foreach ( $rplist as $k => $v ) {
  8531. if ($value ['staff'] == $v ['staff']) {
  8532. $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>';
  8533. $au += $v ['amount'];
  8534. }
  8535. }
  8536. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8537. }
  8538. $data ['html'] = $html;
  8539. $data ['memu'] = "receipt";
  8540. $data ['staff'] = $this->staff;
  8541. $data ['receiptMemu'] = 'remittanceHky';
  8542. $data ['verifyId'] = $this->verifyId;
  8543. $data ['executeId'] = $this->executeId;
  8544. $this->render ( "/admin/remittancep", $data );
  8545. }
  8546. function ajaxGetReceiptDetails() {
  8547. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8548. Doo::loadClass ( 'XDeode' );
  8549. $XDeode = new XDeode ( 5 );
  8550. $rid = $XDeode->decode ( $rid );
  8551. if (empty ( $rid )) {
  8552. echo json_encode ( array (
  8553. 'status' => 2,
  8554. 'msg' => 'illegal request'
  8555. ) );
  8556. die ();
  8557. }
  8558. Doo::loadModel ( 'receipt' );
  8559. $receipt = new receipt ();
  8560. Doo::loadModel ( 'staff' );
  8561. $staff = new staff ();
  8562. $rinfo = $receipt->getOne ( array (
  8563. 'where' => 'rid= ' . $rid,
  8564. 'asArray' => true
  8565. ) );
  8566. $sinfo = $staff->getOne ( array (
  8567. 'select' => 'username,category',
  8568. 'where' => ' sid=' . $rinfo ['staff'],
  8569. 'asArray' => true
  8570. ) );
  8571. $rinfo ['reviseDetail'] = array ();
  8572. if (! empty ( $rinfo ['reviseDetail'] ))
  8573. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8574. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8575. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8576. $rinfo ['category'] = $sinfo ['category'];
  8577. $verifyStaff = array ();
  8578. if (! empty ( $rinfo ['verifyStaff'] ))
  8579. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8580. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8581. $rinfo ['relust'] = $relust;
  8582. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8583. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8584. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8585. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8586. // 费用执行人相关数据
  8587. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8588. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8589. foreach ( $executeCopy as $k => $v ) {
  8590. $executeCopy [$k] ['date'] = '';
  8591. $executeCopy [$k] ['opinion'] = '';
  8592. $executeCopy [$k] ['status'] = '';
  8593. if (! empty ( $executeStaff ))
  8594. foreach ( $executeStaff as $m => $u ) {
  8595. if ($v [0] == $m) {
  8596. $executeCopy [$k] ['date'] = $u ['date'];
  8597. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8598. $executeCopy [$k] ['status'] = $u ['status'];
  8599. break;
  8600. }
  8601. }
  8602. }
  8603. $rinfo ['executeCopy'] = $executeCopy;
  8604. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8605. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8606. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8607. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8608. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8609. $html .= '<tr><th>' . $value ['name'] . '</th>
  8610. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8611. }
  8612. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8613. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8614. <tr><th class="taC" colspan="2">费用说明</th>
  8615. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8616. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8617. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8618. </tbody></table>';
  8619. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8620. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8621. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8622. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8623. $html .= '<tr><th>' . $value ['name'] . '</th>
  8624. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8625. }
  8626. $html .= '<tr><th class="taR">合计</th>
  8627. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  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'] ['travelSum'] . '</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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  8649. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8650. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8651. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8652. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8653. }
  8654. $html .= '<tr><th class="taR">合计</th>
  8655. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8656. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8657. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8658. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8659. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8660. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8661. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8662. <tr';
  8663. if ($rinfo ['relust'] >= 0) {
  8664. $html .= 'class="success"';
  8665. } else {
  8666. $html .= 'class="error"';
  8667. }
  8668. $html .= '><td class="taR"><b>借款结余</b></td>
  8669. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8670. </tbody></table>
  8671. ';
  8672. }
  8673. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8674. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8675. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8676. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8677. $html .= '<tr><th>' . $value ['name'] . '</th>
  8678. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8679. }
  8680. $html .= '<tr><th class="taR">合计</th>
  8681. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8682. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8683. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8684. <tr><th class="taC" colspan="2">费用说明</th>
  8685. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8686. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8687. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8688. </tbody></table>';
  8689. } else {
  8690. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8691. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8692. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8693. $html .= '<tr><th>' . $value ['name'] . '</th>
  8694. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8695. }
  8696. $html .= '<tr><th class="taR">合计</th>
  8697. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  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'] ['travelSum'] . '</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'] ['trainSum'] . '</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'] ['otherSum'] . '</td></tr>';
  8719. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8720. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8721. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8722. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8723. }
  8724. $html .= '<tr><th class="taR">合计</th>
  8725. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8726. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8727. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8728. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8729. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8730. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8731. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8732. $html .= '</tbody></table>';
  8733. /*
  8734. * <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>
  8735. */
  8736. }
  8737. // print_r($verifyStaff);die;
  8738. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8739. foreach ( $verifyStaff as $key => $value ) {
  8740. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8741. $sinfo = $staff->getOne ( array (
  8742. 'select' => 'username',
  8743. 'where' => ' sid=' . $key,
  8744. 'asArray' => true
  8745. ) );
  8746. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8747. }
  8748. $html .= '</tbody></table>';
  8749. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8750. foreach ( $rinfo ['executeCopy'] as $value ) {
  8751. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8752. }
  8753. $html .= '</tbody></table>';
  8754. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8755. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8756. </tr></table>';
  8757. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8758. echo json_encode ( array (
  8759. 'status' => 1,
  8760. 'html' => $html
  8761. ) );
  8762. die ();
  8763. }
  8764. /**
  8765. * 删除附件
  8766. */
  8767. function ajaxRemEnclousur() {
  8768. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8769. if (empty ( $key ))
  8770. echo json_encode ( array (
  8771. 'status' => 2
  8772. ) );
  8773. Doo::loadModel ( 'enclosur' );
  8774. $enclosur = new enclosur ();
  8775. $enclosur->delEnclosurByEid ( $key );
  8776. echo json_encode ( array (
  8777. 'status' => 1
  8778. ) );
  8779. }
  8780. function remittance() {
  8781. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8782. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8783. Doo::loadModel ( 'receipt' );
  8784. $receipt = new receipt ();
  8785. Doo::loadModel ( 'staff' );
  8786. $staff = new staff ();
  8787. $dateCondition = " and Year(pastDate) =" . $year;
  8788. if (! empty ( $month ))
  8789. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8790. // get Receipt By verifyID status 1
  8791. $receiptList = $receipt->find ( array (
  8792. 'select' => 'sum(sum) as sum,staff,pastDate',
  8793. 'where' => ' status=1' . $dateCondition,
  8794. 'desc' => 'pastDate',
  8795. 'groupby' => 'staff,pastDate',
  8796. 'asArray' => true
  8797. ) );
  8798. $dateList = $receipt->find ( array (
  8799. 'select' => 'pastDate,verifyStaff',
  8800. 'where' => ' status=1' . $dateCondition,
  8801. 'desc' => 'pastDate',
  8802. 'groupby' => 'pastDate',
  8803. 'asArray' => true
  8804. ) );
  8805. $dataList = array ();
  8806. foreach ( $dateList as $d => $a ) {
  8807. $dataList [$a ['pastDate']] = array ();
  8808. $daySum = 0;
  8809. foreach ( $receiptList as $key => $value ) {
  8810. if ($a ['pastDate'] == $value ['pastDate']) {
  8811. $oderList = $receipt->find ( array (
  8812. 'select' => 'receiptOrder',
  8813. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8814. 'asArray' => true
  8815. ) );
  8816. $list = array ();
  8817. $html = "";
  8818. foreach ( $oderList as $v ) {
  8819. array_push ( $list, $v ['receiptOrder'] );
  8820. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8821. }
  8822. $receiptList [$key] ['receiptOrder'] = $html;
  8823. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8824. $sinfo = $staff->getOne ( array (
  8825. 'select' => 'username ',
  8826. 'where' => ' sid=' . $value ['staff'],
  8827. 'asArray' => true
  8828. ) );
  8829. $receiptList [$key] ['username'] = $sinfo ['username'];
  8830. $daySum += $value ['sum'];
  8831. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8832. }
  8833. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8834. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8835. }
  8836. }
  8837. // print_r($dataList);
  8838. $data ['dataList'] = $dataList;
  8839. $mothHtml = "";
  8840. for($i = 1; $i <= 12; $i ++) {
  8841. if ($month == $i)
  8842. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8843. else
  8844. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8845. }
  8846. $data ['year'] = $year;
  8847. $data ['mothHtml'] = $mothHtml;
  8848. $data ['memu'] = "receipt";
  8849. $data ['staff'] = $this->staff;
  8850. $data ['receiptMemu'] = 'approval';
  8851. $data ['verifyId'] = $this->verifyId;
  8852. $data ['executeId'] = $this->executeId;
  8853. $this->render ( "/admin/saeaReportListPay", $data );
  8854. }
  8855. /**
  8856. * 金额调整,提高稳定性
  8857. * @return string
  8858. */
  8859. function revocationAdjustment() {
  8860. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8861. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8862. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8863. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8864. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8865. Doo::loadClass ( 'XDeode' );
  8866. $XDeode = new XDeode ( 5 );
  8867. Doo::loadModel ( 'receipt' );
  8868. $receipt = new receipt ();
  8869. $sid = $XDeode->decode ( $sidKey );
  8870. $rid = $XDeode->decode ( $ridKey );
  8871. $reviseKey = $XDeode->decode ( $reviseKey );
  8872. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8873. die ( 'illegal request' );
  8874. $receiptDetail = $receipt->getOne ( array (
  8875. 'where' => 'rid=' . $rid,
  8876. 'asArray' => true
  8877. ) );
  8878. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8879. die ( 'illegal request' );
  8880. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8881. if (! isset ( $reviseDetail [$reviseKey] ))
  8882. die ( 'illegal request' );
  8883. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8884. unset ( $reviseDetail [$reviseKey] );
  8885. $revisePrice = 0;
  8886. foreach ( $reviseDetail as $key => $value ) {
  8887. $revisePrice += $value ['price'];
  8888. }
  8889. $reviseDetailString = json_encode ( $reviseDetail );
  8890. $receipt->reviseDetail = $reviseDetailString;
  8891. $receipt->sum = $receiptDetail ['sum'] - $price;
  8892. $receipt->revisePrice = $revisePrice;
  8893. $receipt->update ( array (
  8894. 'where' => 'rid=' . $rid
  8895. ) );
  8896. return '/receiptburEdi/' . $rid;
  8897. } else
  8898. die ( 'illegal request2' );
  8899. }
  8900. function updateApprovalReceipt() {
  8901. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8902. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8903. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8904. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8905. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8906. if (! empty ( $rid )) {
  8907. Doo::loadModel ( "verify" );
  8908. $verify = new verify ();
  8909. Doo::loadModel ( "receiptDetail" );
  8910. $receiptDetailObj = new receiptDetail ();
  8911. Doo::loadModel ( "itemStatistics" );
  8912. Doo::loadModel ( "statistics" );
  8913. $statistics = new statistics ();
  8914. $itemStatistics = new itemStatistics ();
  8915. Doo::loadModel ( "receipt" );
  8916. $receipt = new receipt ();
  8917. $receiptDetail = $receipt->getOne ( array (
  8918. 'where' => 'rid=' . $rid . ' and status=2 ',
  8919. 'asArray' => true
  8920. ) );
  8921. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8922. $nsflag = true;
  8923. foreach ( $nslist as $value ) {
  8924. if ($value == $this->staff ['0'] ['sid']) {
  8925. $nsflag = false;
  8926. break;
  8927. }
  8928. }
  8929. if (empty ( $receiptDetail ) || $nsflag)
  8930. return "/approvalExpenses/pendApproval";
  8931. $verifyDetail = $verify->getOne ( array (
  8932. 'where' => ' vid =' . $receiptDetail ['verify'],
  8933. 'asArray' => true
  8934. ) );
  8935. $verifyString = $verifyDetail ['staff'];
  8936. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8937. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8938. if (empty ( $opinion )) {
  8939. if ($status == 3)
  8940. $opinion = "终止";
  8941. else
  8942. $opinion = "同意支付";
  8943. }
  8944. $nowStaff = 0;
  8945. $nowStaffList = array ();
  8946. if (empty ( $verifyStaff )) {
  8947. // 还需加入是否已经进入角色审批
  8948. if ($verifyDetail [0] [1] == 'ROLE') {
  8949. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8950. foreach ( $vStaffString as $key => $value ) {
  8951. $staffK = explode ( "_", $value );
  8952. if ($staffK [0] != $this->staff [0] ['sid'])
  8953. array_push ( $nowStaffList, $staffK [0] );
  8954. }
  8955. // print_r($verifyDetail);
  8956. // die;
  8957. if (! empty ( $nowStaffList )) {
  8958. $nowStaff = implode ( ',', $nowStaffList );
  8959. $verifyStaff = array (
  8960. $this->staff [0] ['sid'] . "_R" => array (
  8961. 'date' => date ( 'Y-m-d' ),
  8962. 'opinion' => $opinion,
  8963. 'status' => $status,
  8964. 'nextStaff' => $verifyDetail [0] [0],
  8965. 'ROLE' => 1
  8966. )
  8967. );
  8968. } else {
  8969. $nowStaff = $verifyDetail [1] [0];
  8970. $verifyStaff = array (
  8971. $this->staff [0] ['sid'] . "_R" => array (
  8972. 'date' => date ( 'Y-m-d' ),
  8973. 'opinion' => $opinion,
  8974. 'status' => $status,
  8975. 'nextStaff' => $verifyDetail [1] [0]
  8976. )
  8977. );
  8978. }
  8979. } else {
  8980. if ($verifyDetail [1] [1] == 'ROLE') {
  8981. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8982. // echo "dd";
  8983. foreach ( $vStaffString as $key => $value ) {
  8984. $staffK = explode ( "_", $value );
  8985. array_push ( $nowStaffList, $staffK [0] );
  8986. }
  8987. $nowStaff = implode ( ',', $nowStaffList );
  8988. $verifyStaff = array (
  8989. $this->staff [0] ['sid'] => array (
  8990. 'date' => date ( 'Y-m-d' ),
  8991. 'opinion' => $opinion,
  8992. 'status' => $status,
  8993. 'nextStaff' => $verifyDetail [1] [0],
  8994. 'ROLE' => 1
  8995. )
  8996. );
  8997. } else {
  8998. $nowStaff = $verifyDetail [1] [0];
  8999. $verifyStaff = array (
  9000. $this->staff [0] ['sid'] => array (
  9001. 'date' => date ( 'Y-m-d' ),
  9002. 'opinion' => $opinion,
  9003. 'status' => $status,
  9004. 'nextStaff' => $verifyDetail [1] [0]
  9005. )
  9006. );
  9007. }
  9008. }
  9009. if ($status == 3)
  9010. $verifyStaff = array (
  9011. 'final' => $status,
  9012. $this->staff [0] ['sid'] => array (
  9013. 'date' => date ( 'Y-m-d' ),
  9014. 'opinion' => $opinion,
  9015. 'status' => $status
  9016. )
  9017. );
  9018. $vStaffString = json_encode ( $verifyStaff );
  9019. $receipt->nowStaff = $nowStaff;
  9020. $receipt->verifyStaff = $vStaffString;
  9021. } else {
  9022. $VS = end ( $verifyStaff );
  9023. // 非角色审批
  9024. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9025. $nextStaff = 0;
  9026. $roleSTF = false;
  9027. foreach ( $verifyDetail as $key => $value ) {
  9028. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9029. if (isset ( $verifyDetail [$key + 1] )) {
  9030. $nextStaff = $verifyDetail [$key + 1] [0];
  9031. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9032. $roleSTF = true;
  9033. }
  9034. break;
  9035. }
  9036. }
  9037. if (! $roleSTF) {
  9038. $nowStaff = $nextStaff;
  9039. $verifyStaff [$this->staff [0] ['sid']] = array (
  9040. 'date' => date ( 'Y-m-d' ),
  9041. 'opinion' => $opinion,
  9042. 'status' => $status,
  9043. 'nextStaff' => $nextStaff
  9044. );
  9045. } else {
  9046. // 获取角色下的所有用户ID
  9047. $nowStaffList = array ();
  9048. foreach ( $verifyDetail as $vfk ) {
  9049. if ($vfk [1] == 'ROLE') {
  9050. $vStaffString = json_decode ( $vfk [3] );
  9051. foreach ( $vStaffString as $key => $value ) {
  9052. $staffK = explode ( "_", $value );
  9053. array_push ( $nowStaffList, $staffK [0] );
  9054. }
  9055. }
  9056. }
  9057. $nowStaff = implode ( ',', $nowStaffList );
  9058. $verifyStaff [$this->staff [0] ['sid']] = array (
  9059. 'date' => date ( 'Y-m-d' ),
  9060. 'opinion' => $opinion,
  9061. 'status' => $status,
  9062. 'nextStaff' => $nextStaff,
  9063. 'ROLE' => 0
  9064. );
  9065. }
  9066. if ($status == 3) {
  9067. $verifyStaff ['final'] = $status;
  9068. $verifyStaff [$this->staff [0] ['sid']] = array (
  9069. 'date' => date ( 'Y-m-d' ),
  9070. 'opinion' => $opinion,
  9071. 'status' => $status
  9072. );
  9073. }
  9074. $vStaffString = json_encode ( $verifyStaff );
  9075. $receipt->nowStaff = $nowStaff;
  9076. $receipt->verifyStaff = $vStaffString;
  9077. }
  9078. // 角色审批
  9079. if (isset ( $VS ['ROLE'] )) {
  9080. // 找出角色人 当前审批角色组
  9081. $verifyJSStaff = array ();
  9082. $nowStaffList2 = array ();
  9083. foreach ( $verifyDetail as $key => $value ) {
  9084. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9085. $verifyJSStaff = json_decode ( $value [3] );
  9086. foreach ( $verifyJSStaff as $m ) {
  9087. $staffK = explode ( "_", $m );
  9088. array_push ( $nowStaffList2, $staffK [0] );
  9089. }
  9090. // print_r($nowStaffList2);
  9091. }
  9092. }
  9093. $RoleVerifyStaff = array ();
  9094. foreach ( $verifyStaff as $key => $value ) {
  9095. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9096. foreach ( $nowStaffList2 as $m ) {
  9097. if ($key == $m . "_R")
  9098. $RoleVerifyStaff [$key] = $value;
  9099. }
  9100. }
  9101. }
  9102. // print_r($verifyStaff);
  9103. // print_r($nowStaffList2);
  9104. // print_r($RoleVerifyStaff);
  9105. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9106. // print_r($verifyJSStaff);
  9107. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9108. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9109. // 下一个审批人ID
  9110. $nextStaff = 0;
  9111. $falg = false;
  9112. foreach ( $verifyDetail as $key => $value ) {
  9113. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9114. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9115. $falg = true;
  9116. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9117. $nowStaffList = array ();
  9118. foreach ( $vStaffString as $v ) {
  9119. $staffK = explode ( "_", $v );
  9120. array_push ( $nowStaffList, $staffK [0] );
  9121. }
  9122. $nowStaff = implode ( ',', $nowStaffList );
  9123. $nextStaff = $verifyDetail [$key + 1] [0];
  9124. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9125. $nextStaff = $verifyDetail [$key + 1] [0];
  9126. $nowStaff = $nextStaff;
  9127. } else
  9128. $nowStaff = '';
  9129. break;
  9130. }
  9131. }
  9132. if ($falg)
  9133. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9134. 'date' => date ( 'Y-m-d' ),
  9135. 'opinion' => $opinion,
  9136. 'status' => $status,
  9137. 'nextStaff' => $nextStaff,
  9138. 'ROLE' => 1
  9139. );
  9140. else
  9141. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9142. 'date' => date ( 'Y-m-d' ),
  9143. 'opinion' => $opinion,
  9144. 'status' => $status,
  9145. 'nextStaff' => $nextStaff
  9146. );
  9147. // print_r($verifyStaff);
  9148. // echo $nowStaff;die;
  9149. } else { // 进入下一个角色或者审批人
  9150. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9151. //
  9152. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9153. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9154. 'date' => date ( 'Y-m-d' ),
  9155. 'opinion' => $opinion,
  9156. 'status' => $status,
  9157. 'nextStaff' => $VS ['nextStaff'],
  9158. 'ROLE' => 1
  9159. );
  9160. // print_r($verifyStaff);
  9161. // die;
  9162. }
  9163. if ($status == 3) {
  9164. $verifyStaff ['final'] = $status;
  9165. $verifyStaff [$this->staff [0] ['sid']] = array (
  9166. 'date' => date ( 'Y-m-d' ),
  9167. 'opinion' => $opinion,
  9168. 'status' => $status
  9169. );
  9170. }
  9171. $vStaffString = json_encode ( $verifyStaff );
  9172. $receipt->verifyStaff = $vStaffString;
  9173. $receipt->nowStaff = $nowStaff;
  9174. // die;
  9175. // }
  9176. // print_r($verifyStaff);
  9177. // die;
  9178. }
  9179. // print_r($verifyStaff);die;
  9180. }
  9181. // print_r($verifyDetail);
  9182. $roleKey = 0;
  9183. $roleId = 0;
  9184. $verifyDetailCopy = array ();
  9185. foreach ( $verifyDetail as $k => $v ) {
  9186. if ($v [1] == 'ROLE') {
  9187. $roleId = $v [0];
  9188. $roleVerify = json_decode ( $v [3], true );
  9189. $roleKey = $k;
  9190. $roleArray = array ();
  9191. foreach ( $roleVerify as $o => $p ) {
  9192. $staffID = explode ( '_', $p );
  9193. $exp = array (
  9194. 0 => $staffID [0],
  9195. 1 => $staffID [1]
  9196. );
  9197. array_push ( $roleArray, $exp );
  9198. }
  9199. $verifyDetailCopy [$v [0]] = $roleArray;
  9200. }
  9201. }
  9202. // print_r($verifyDetail);
  9203. foreach ( $verifyDetailCopy as $k => $v ) {
  9204. foreach ( $verifyDetail as $m => $n ) {
  9205. if ($n [0] == $k) {
  9206. array_splice ( $verifyDetail, $m, 1, $v );
  9207. }
  9208. }
  9209. }
  9210. // die;
  9211. // if (!empty($roleArray))
  9212. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9213. // echo $roleId;
  9214. // print_r($verifyStaff);
  9215. // print_r($verifyDetail);
  9216. // die;
  9217. Doo::loadModel ( "receiptLog" );
  9218. $receiptLog = new receiptLog ();
  9219. // 审批日志
  9220. if (! isset ( $verifyStaff ['final'] )) {
  9221. if (! empty ( $roleId )) {
  9222. Doo::loadModel ( "role" );
  9223. $role = new role ();
  9224. $roleInfo = $role->getOne ( array (
  9225. 'where' => 'rid=' . $roleId,
  9226. 'asArray' => true
  9227. ) );
  9228. $receiptLog->rolename = $roleInfo ['name'];
  9229. }
  9230. $receiptLog->username = $this->staff [0] ['username'];
  9231. $receiptLog->uid = $this->staff [0] ['sid'];
  9232. $receiptLog->date = date ( "Y-m-d" );
  9233. $receiptLog->opinion = $opinion;
  9234. $receiptLog->img = $this->staff [0] ['avatar'];
  9235. $receiptLog->status = 1;
  9236. $receiptLog->rid = $rid;
  9237. $receiptLog->insert ();
  9238. }
  9239. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9240. $receipt->verifyBreakup = $verifyString;
  9241. $receipt->status = 3;
  9242. $receiptDetailObj->status = 3;
  9243. $receiptDetailObj->update ( array (
  9244. 'where' => 'rid=' . $rid
  9245. ) );
  9246. if (! empty ( $roleId )) {
  9247. Doo::loadModel ( "role" );
  9248. $role = new role ();
  9249. $roleInfo = $role->getOne ( array (
  9250. 'where' => 'rid=' . $roleId,
  9251. 'asArray' => true
  9252. ) );
  9253. $receiptLog->rolename = $roleInfo ['name'];
  9254. }
  9255. $receiptLog->username = $this->staff [0] ['username'];
  9256. $receiptLog->uid = $this->staff [0] ['sid'];
  9257. $receiptLog->date = date ( "Y-m-d" );
  9258. $receiptLog->opinion = $opinion;
  9259. $receiptLog->img = $this->staff [0] ['avatar'];
  9260. $receiptLog->status = 3;
  9261. $receiptLog->rid = $rid;
  9262. $receiptLog->insert ();
  9263. //删除行程单
  9264. Doo::loadModel ( 'itinerary' );
  9265. $itinerary = new itinerary ();
  9266. $itinerary->delete ( array (
  9267. 'where' => 'rid="' . $rid . '"'
  9268. ) );
  9269. // 微信企业号通知
  9270. $this->setWXMsg ( $rid, 3 );
  9271. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9272. $receipt->status = 1;
  9273. $reviseSum = 0;
  9274. $receipt->verifyBreakup = $verifyString;
  9275. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9276. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9277. foreach ( $reviseDetail as $key => $value ) {
  9278. $receiptDetailObj = new receiptDetail ();
  9279. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9280. $receiptDetailObj->item = $value ['description'];
  9281. $receiptDetailObj->itemCategory = "报销金额调整";
  9282. $receiptDetailObj->price = $value ['price'];
  9283. $receiptDetailObj->date = $receiptDetail ['date'];
  9284. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9285. $receiptDetailObj->rid = $rid;
  9286. $receiptDetailObj->status = 1;
  9287. $receiptDetailObj->insert ();
  9288. $reviseSum += $value ['price'];
  9289. }
  9290. $itemStatistics = new itemStatistics ();
  9291. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9292. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9293. $itemStatistics->price = $reviseSum;
  9294. $itemStatistics->itemCategory = "报销金额调整";
  9295. $itemStatistics->date = $receiptDetail ['date'];
  9296. $itemStatistics->insert ();
  9297. }
  9298. $receiptDetailObj = new receiptDetail ();
  9299. $receiptDetailObj->status = 1;
  9300. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9301. $receiptDetailObj->update ( array (
  9302. 'where' => 'rid=' . $rid
  9303. ) );
  9304. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9305. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9306. $stat = $statistics->getOne ( array (
  9307. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9308. 'asArray' => true
  9309. ) );
  9310. if (empty ( $stat )) {
  9311. $statistics->date = $receiptDetail ['date'];
  9312. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9313. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9314. $statistics->agPrice = $receiptDetail ['sum'];
  9315. $statistics->rePrice = $reviseSum;
  9316. $statistics->insert ();
  9317. } else {
  9318. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9319. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9320. $statistics->update ( array (
  9321. 'where' => 'sid=' . $stat ['sid']
  9322. ) );
  9323. }
  9324. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9325. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9326. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9327. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9328. if ($key == "agencySum") {
  9329. $iStatistics = $itemStatistics->getOne ( array (
  9330. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9331. 'asArray' => true
  9332. ) );
  9333. if (empty ( $iStatistics )) {
  9334. $itemStatistics->cid = $receiptDetail ['cid'];
  9335. ;
  9336. $itemStatistics->staff = $receiptDetail ['staff'];
  9337. $itemStatistics->price = $value;
  9338. $itemStatistics->itemCategory = $this->AGENCY;
  9339. $itemStatistics->date = $receiptDetail ['date'];
  9340. $itemStatistics->insert ();
  9341. } else {
  9342. if (! empty ( $value )) {
  9343. $itemStatistics->price = $value + $iStatistics ['price'];
  9344. $itemStatistics->update ( array (
  9345. 'where' => 'sid=' . $iStatistics ['sid']
  9346. ) );
  9347. }
  9348. }
  9349. } elseif ($key == "travelSum") {
  9350. $iStatistics = $itemStatistics->getOne ( array (
  9351. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9352. 'asArray' => true
  9353. ) );
  9354. if (empty ( $iStatistics )) {
  9355. $itemStatistics->cid = $receiptDetail ['cid'];
  9356. $itemStatistics->staff = $receiptDetail ['staff'];
  9357. $itemStatistics->price = $value;
  9358. $itemStatistics->itemCategory = $this->TRAVEL;
  9359. $itemStatistics->date = $receiptDetail ['date'];
  9360. $itemStatistics->insert ();
  9361. } else {
  9362. if (! empty ( $value )) {
  9363. $itemStatistics->price = $value + $iStatistics ['price'];
  9364. $itemStatistics->update ( array (
  9365. 'where' => 'sid=' . $iStatistics ['sid']
  9366. ) );
  9367. }
  9368. }
  9369. } elseif ($key == "trainSum") {
  9370. $iStatistics = $itemStatistics->getOne ( array (
  9371. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9372. 'asArray' => true
  9373. ) );
  9374. if (empty ( $iStatistics )) {
  9375. $itemStatistics->cid = $receiptDetail ['cid'];
  9376. $itemStatistics->staff = $receiptDetail ['staff'];
  9377. $itemStatistics->price = $value;
  9378. $itemStatistics->itemCategory = $this->TRAIN;
  9379. $itemStatistics->date = $receiptDetail ['date'];
  9380. $itemStatistics->insert ();
  9381. } else {
  9382. if (! empty ( $value )) {
  9383. $itemStatistics->price = $value + $iStatistics ['price'];
  9384. $itemStatistics->update ( array (
  9385. 'where' => 'sid=' . $iStatistics ['sid']
  9386. ) );
  9387. }
  9388. }
  9389. } elseif ($key == "otherSum") {
  9390. $iStatistics = $itemStatistics->getOne ( array (
  9391. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9392. 'asArray' => true
  9393. ) );
  9394. if (empty ( $iStatistics )) {
  9395. $itemStatistics->cid = $receiptDetail ['cid'];
  9396. $itemStatistics->staff = $receiptDetail ['staff'];
  9397. $itemStatistics->price = $value;
  9398. $itemStatistics->itemCategory = $this->OTHER;
  9399. $itemStatistics->date = $receiptDetail ['date'];
  9400. $itemStatistics->insert ();
  9401. } else {
  9402. if (! empty ( $value )) {
  9403. $itemStatistics->price = $value + $iStatistics ['price'];
  9404. $itemStatistics->update ( array (
  9405. 'where' => 'sid=' . $iStatistics ['sid']
  9406. ) );
  9407. }
  9408. }
  9409. }
  9410. }
  9411. $receipt->pastDate = date ( "Y-m-d" );
  9412. // 微信企业号通知
  9413. $this->setWXMsg ( $rid, 1 );
  9414. }
  9415. //是否有流水
  9416. Doo::loadModel ( 'wasteBook' );
  9417. $wasteBook = new wasteBook ();
  9418. $accountType=3;
  9419. if ($receiptDetail['Rtype']==1){
  9420. $accountType=2;
  9421. }elseif($receiptDetail['Rtype']==2){
  9422. $accountType=4;
  9423. }
  9424. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9425. if (empty($wbDetail)){
  9426. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9427. $receipt->amount = $rsum;//$amount;
  9428. }
  9429. $receipt->update ( array (
  9430. 'where' => ' rid = ' . $rid
  9431. ) );
  9432. // 进入下一条审批费用新加需求
  9433. $vidList = array ();
  9434. $verifyDetail = $verify->find ( array (
  9435. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9436. 'asArray' => true
  9437. ) );
  9438. foreach ( $verifyDetail as $key => $value ) {
  9439. array_push ( $vidList, $value ['vid'] );
  9440. }
  9441. $vid = implode ( ",", $vidList );
  9442. if (empty ( $verifyDetail ))
  9443. $vid = 0;
  9444. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9445. $receipt = new receipt ();
  9446. $rd = $receipt->getOne ( array (
  9447. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9448. 'asc' => 'rid',
  9449. 'asArray' => true
  9450. ) );
  9451. if (empty ( $rd )) {
  9452. return '/approvalExpenses/pendApproval';
  9453. }
  9454. if ($rd ['Rtype'] == 1) {
  9455. if ($rd ['isBK'] == 1) {
  9456. return '/receiptburEdi/' . $rd ['rid'];
  9457. } else {
  9458. return '/expensesEdi/' . $rd ['rid'];
  9459. }
  9460. } elseif ($rd ['Rtype'] == 2) {
  9461. return '/remitApproval/' . $rd ['rid'];
  9462. } else {
  9463. return '/receiptburEdi/' . $rd ['rid'];
  9464. }
  9465. // return "/approvalExpenses/pendApproval";
  9466. }
  9467. }
  9468. function expensesRetreats() {
  9469. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9470. if (! empty ( $rid )) {
  9471. // 操作记录
  9472. Doo::loadModel ( "receipt" );
  9473. $receipt = new receipt ();
  9474. Doo::loadModel ( "receiptLog" );
  9475. $receiptLog = new receiptLog ();
  9476. Doo::loadModel ( "verify" );
  9477. $verify = new verify ();
  9478. $receiptInfo = $receipt->getOne ( array (
  9479. 'where' => 'rid=' . $rid,
  9480. 'asArray' => true
  9481. ) );
  9482. $vr = $verify->getOne ( array (
  9483. 'where' => 'vid=' . $receiptInfo ['verify'],
  9484. 'asArray' => true
  9485. ) );
  9486. $jd = json_decode ( $vr ['staff'] );
  9487. $roleId = 0;
  9488. foreach ( $jd as $key => $value ) {
  9489. if ($value [1] == 'ROLE') {
  9490. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9491. if ($pos !== false) {
  9492. $roleId = $value [0];
  9493. }
  9494. }
  9495. }
  9496. // 审批日志
  9497. // echo $roleId;die;
  9498. if (! empty ( $roleId )) {
  9499. Doo::loadModel ( "role" );
  9500. $role = new role ();
  9501. $roleInfo = $role->getOne ( array (
  9502. 'where' => 'rid=' . $roleId,
  9503. 'asArray' => true
  9504. ) );
  9505. $receiptLog->rolename = $roleInfo ['name'];
  9506. }
  9507. $receiptLog->username = $this->staff [0] ['username'];
  9508. $receiptLog->uid = $this->staff [0] ['sid'];
  9509. $receiptLog->date = date ( "Y-m-d" );
  9510. $receiptLog->opinion = '撤回';
  9511. $receiptLog->img = $this->staff [0] ['avatar'];
  9512. $receiptLog->status = 4;
  9513. $receiptLog->rid = $rid;
  9514. $receiptLog->insert ();
  9515. $receipt->status = 4;
  9516. $receipt->update ( array (
  9517. 'where' => 'rid=' . $rid
  9518. ) );
  9519. // 微信企业号通知
  9520. $this->setWXMsg ( $rid, 2 );
  9521. }
  9522. // echo "ddd";
  9523. return '/approvalExpenses/pendApproval';
  9524. }
  9525. function updateCheReceipt() {
  9526. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9527. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9528. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9529. if (! empty ( $rid )) {
  9530. // 操作记录
  9531. Doo::loadModel ( "receipt" );
  9532. $receipt = new receipt ();
  9533. Doo::loadModel ( "receiptLog" );
  9534. $receiptLog = new receiptLog ();
  9535. Doo::loadModel ( "verify" );
  9536. $verify = new verify ();
  9537. $receiptInfo = $receipt->getOne ( array (
  9538. 'where' => 'rid=' . $rid . ' and status=2',
  9539. 'asArray' => true
  9540. ) );
  9541. if (empty ( $receiptInfo )) {
  9542. echo json_encode ( array (
  9543. 'status' => 2
  9544. ) );
  9545. die ();
  9546. }
  9547. $vr = $verify->getOne ( array (
  9548. 'where' => 'vid=' . $receiptInfo ['verify'],
  9549. 'asArray' => true
  9550. ) );
  9551. $jd = json_decode ( $vr ['staff'] );
  9552. $roleId = 0;
  9553. foreach ( $jd as $key => $value ) {
  9554. if ($value [1] == 'ROLE') {
  9555. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9556. if ($pos !== false) {
  9557. $roleId = $value [0];
  9558. }
  9559. }
  9560. }
  9561. // 审批日志
  9562. // echo $roleId;die;
  9563. if (! empty ( $roleId )) {
  9564. Doo::loadModel ( "role" );
  9565. $role = new role ();
  9566. $roleInfo = $role->getOne ( array (
  9567. 'where' => 'rid=' . $roleId,
  9568. 'asArray' => true
  9569. ) );
  9570. $receiptLog->rolename = $roleInfo ['name'];
  9571. }
  9572. $receiptLog->username = $this->staff [0] ['username'];
  9573. $receiptLog->uid = $this->staff [0] ['sid'];
  9574. $receiptLog->date = date ( "Y-m-d" );
  9575. $receiptLog->opinion = $opinion;
  9576. $receiptLog->img = $this->staff [0] ['avatar'];
  9577. $receiptLog->status = 4;
  9578. $receiptLog->rid = $rid;
  9579. $receiptLog->insert ();
  9580. $receipt->status = 4;
  9581. $receipt->update ( array (
  9582. 'where' => 'rid=' . $rid
  9583. ) );
  9584. // 微信企业号通知
  9585. $this->setWXMsg ( $rid, 2 );
  9586. echo json_encode ( array (
  9587. 'status' => 1
  9588. ) );
  9589. // Header("HTTP/1.1 303 See Other");
  9590. // Header("Location: /approvalExpenses/pendApproval");
  9591. die ();
  9592. }
  9593. echo json_encode ( array (
  9594. 'status' => 2
  9595. ) );
  9596. die ();
  9597. // echo "ddd";
  9598. // return '/saeaBorad';
  9599. }
  9600. function revisePrice() {
  9601. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9602. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9603. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9604. // echo $price;die;
  9605. if (! empty ( $rid )) {
  9606. Doo::loadModel ( "receipt" );
  9607. $receipt = new receipt ();
  9608. $receiptDetail = $receipt->getOne ( array (
  9609. 'where' => 'rid=' . $rid . ' and status=2 ',
  9610. 'asArray' => true
  9611. ) );
  9612. if (empty ( $receiptDetail ))
  9613. die ( 'illegal request' );
  9614. $reviseDetail = array ();
  9615. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9616. array_push ( $reviseDetail, array (
  9617. 'sid' => $this->staff [0] ['sid'],
  9618. 'name' => $this->staff [0] ['username'],
  9619. 'description' => $description,
  9620. 'price' => $price
  9621. ) );
  9622. $reviseDetailString = json_encode ( $reviseDetail );
  9623. $receipt->reviseDetail = $reviseDetailString;
  9624. $receipt->revisePrice = $price;
  9625. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9626. } else {
  9627. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9628. array_push ( $reviseDetail, array (
  9629. 'sid' => $this->staff [0] ['sid'],
  9630. 'name' => $this->staff [0] ['username'],
  9631. 'description' => $description,
  9632. 'price' => $price
  9633. ) );
  9634. $reviseDetailString = json_encode ( $reviseDetail );
  9635. $receipt->reviseDetail = $reviseDetailString;
  9636. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9637. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9638. }
  9639. $receipt->update ( array (
  9640. 'where' => 'rid=' . $rid
  9641. ) );
  9642. if ($receiptDetail ['Rtype'] == 1) {
  9643. if ($receiptDetail ['isBK'] == 1) {
  9644. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9645. }
  9646. } elseif ($receiptDetail ['Rtype'] == 2) {
  9647. } else {
  9648. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9649. }
  9650. }
  9651. die ( 'illegal request' );
  9652. }
  9653. function personalCollect() {
  9654. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9655. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9656. $this->showCache ( $path );
  9657. Doo::loadModel ( "receiptDetail" );
  9658. Doo::loadModel ( "itemStatistics" );
  9659. Doo::loadModel ( 'statistics' );
  9660. $statistics = new statistics ();
  9661. $itemStatistics = new itemStatistics ();
  9662. $receiptDetail = new receiptDetail ();
  9663. $receiptCollectList = $receiptDetail->find ( array (
  9664. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9665. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9666. 'groupby' => 'itemCategory,Month(date)',
  9667. 'asArray' => true
  9668. ) );
  9669. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9670. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9671. 'asArray' => true
  9672. ) );
  9673. // create collect html
  9674. $collectArray = array (
  9675. '日常相关费用' => array (),
  9676. '差旅相关费用' => array (),
  9677. '培训班费用' => array (),
  9678. '其他' => array ()
  9679. );
  9680. $adjustment = array ();
  9681. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9682. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9683. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9684. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9685. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9686. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9687. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9688. array_push ( $collectArray ['其他'], $collectHtml );
  9689. $data ['collectArray'] = $collectArray;
  9690. // statistics html
  9691. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9692. if (empty ( $stList ))
  9693. $stList = array (
  9694. 'rePrice' => 0,
  9695. 'agPrice' => 0
  9696. );
  9697. $data ['stList'] = array (
  9698. 'rePrice' => $stList ['rePrice'],
  9699. 'agPrice' => $stList ['agPrice'],
  9700. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9701. );
  9702. // Adjustment price html
  9703. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9704. array_push ( $adjustment, $collectHtml );
  9705. $data ['adjustment'] = $adjustment;
  9706. // total price html
  9707. $collectHtml = "";
  9708. $total = 0;
  9709. for($i = 1; $i <= 12; $i ++) {
  9710. $sumPrice = 0;
  9711. foreach ( $receiptCollectList as $key => $value ) {
  9712. if ($value ['month'] == $i) {
  9713. $sumPrice += $value ['price'];
  9714. }
  9715. }
  9716. if ($sumPrice == 0)
  9717. $collectHtml .= '<td class="taR">-</td>';
  9718. else
  9719. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9720. $total += $sumPrice;
  9721. }
  9722. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9723. $data ['totalPrice'] = $collectHtml;
  9724. $dateHtml = "";
  9725. $now = date ( "Y" );
  9726. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9727. if ($YEARD <= $now) {
  9728. $dateHtml .= '<option ';
  9729. if ($year == $YEARD) {
  9730. $dateHtml .= 'selected ';
  9731. }
  9732. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9733. }
  9734. }
  9735. $data ['dateHtml'] = $dateHtml;
  9736. $data ['year'] = $year;
  9737. $data ['totalYear'] = $total;
  9738. $data ['memu'] = "receipt";
  9739. $data ['staff'] = $this->staff;
  9740. $data ['receiptMemu'] = 'personalCollect';
  9741. $data ['verifyId'] = $this->verifyId;
  9742. $data ['executeId'] = $this->executeId;
  9743. // year staff status 2,4
  9744. if ($year < date ( "Y" )) {
  9745. Doo::loadModel ( 'receipt' );
  9746. $receipt = new receipt ();
  9747. $receiptList = $receipt->find ( array (
  9748. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9749. 'asArray' => true
  9750. ) );
  9751. if (empty ( $receiptList )) {
  9752. ob_start ();
  9753. $this->render ( "/admin/saea_slist_collect", $data );
  9754. $this->cacheFile ( $path );
  9755. die ();
  9756. }
  9757. }
  9758. $this->render ( "/admin/saea_slist_collect", $data );
  9759. }
  9760. function personalCollectDetail() {
  9761. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9762. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9763. $this->showCache ( $path );
  9764. Doo::loadModel ( "receiptDetail" );
  9765. Doo::loadModel ( "itemStatistics" );
  9766. Doo::loadModel ( 'statistics' );
  9767. Doo::loadModel ( 'accountItem' );
  9768. $accountItem = new accountItem ();
  9769. $statistics = new statistics ();
  9770. $itemStatistics = new itemStatistics ();
  9771. $receiptDetail = new receiptDetail ();
  9772. $receiptCollectList = $receiptDetail->find ( array (
  9773. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9774. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9775. 'groupby' => 'item,Month(date)',
  9776. 'asArray' => true
  9777. ) );
  9778. $accountList = $accountItem->find ( array (
  9779. 'asArray' => true
  9780. ) );
  9781. // create CollectDetail HTML
  9782. $collectHtml = array ();
  9783. foreach ( $accountList as $key => $value ) {
  9784. $html = "";
  9785. $asum = 0;
  9786. for($i = 1; $i <= 12; $i ++) {
  9787. $falg = true;
  9788. foreach ( $receiptCollectList as $v ) {
  9789. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9790. $asum += $v ['price'];
  9791. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9792. $falg = false;
  9793. break;
  9794. }
  9795. }
  9796. if ($falg)
  9797. $html .= '<td class="taR">-</td>';
  9798. }
  9799. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9800. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9801. }
  9802. $data ['collectHtml'] = $collectHtml;
  9803. // create Adjustment price html
  9804. $receiptCollectList = $receiptDetail->find ( array (
  9805. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9806. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9807. 'groupby' => 'itemCategory,Month(date)',
  9808. 'asArray' => true
  9809. ) );
  9810. $adjustment = array ();
  9811. $collectArray = array (
  9812. '日常相关费用' => array (),
  9813. '差旅相关费用' => array (),
  9814. '培训班费用' => array (),
  9815. '其他' => array ()
  9816. );
  9817. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9818. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9819. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9820. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9821. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9822. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9823. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9824. array_push ( $collectArray ['其他'], $collectHtml );
  9825. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9826. array_push ( $adjustment, $collectHtml );
  9827. // total price html
  9828. $collectHtml = "";
  9829. $total = 0;
  9830. for($i = 1; $i <= 12; $i ++) {
  9831. $sumPrice = 0;
  9832. foreach ( $receiptCollectList as $key => $value ) {
  9833. if ($value ['month'] == $i) {
  9834. $sumPrice += $value ['price'];
  9835. }
  9836. }
  9837. if ($sumPrice == 0)
  9838. $collectHtml .= '<td class="taR">-</td>';
  9839. else
  9840. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9841. $total += $sumPrice;
  9842. }
  9843. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9844. // statistics html
  9845. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9846. if (empty ( $stList ))
  9847. $stList = array (
  9848. 'rePrice' => 0,
  9849. 'agPrice' => 0
  9850. );
  9851. $data ['stList'] = array (
  9852. 'rePrice' => $stList ['rePrice'],
  9853. 'agPrice' => $stList ['agPrice'],
  9854. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9855. );
  9856. $data ['collectArray'] = $collectArray;
  9857. $data ['adjustment'] = $adjustment;
  9858. $data ['totalPrice'] = $collectHtml;
  9859. $data ['totalYear'] = $total;
  9860. $data ['year'] = $year;
  9861. $dateHtml = "";
  9862. $now = date ( "Y" );
  9863. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9864. if ($YEARD <= $now) {
  9865. $dateHtml .= '<option ';
  9866. if ($year == $YEARD) {
  9867. $dateHtml .= 'selected ';
  9868. }
  9869. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9870. }
  9871. }
  9872. $data ['dateHtml'] = $dateHtml;
  9873. $data ['memu'] = "receipt";
  9874. $data ['staff'] = $this->staff;
  9875. $data ['receiptMemu'] = 'personalCollect';
  9876. $data ['verifyId'] = $this->verifyId;
  9877. $data ['executeId'] = $this->executeId;
  9878. // year staff status 2,4
  9879. if ($year < date ( "Y" )) {
  9880. Doo::loadModel ( 'receipt' );
  9881. $receipt = new receipt ();
  9882. $receiptList = $receipt->find ( array (
  9883. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9884. 'asArray' => true
  9885. ) );
  9886. if (empty ( $receiptList )) {
  9887. ob_start ();
  9888. $this->render ( "/admin/saeaCollectArticles", $data );
  9889. $this->cacheFile ( $path );
  9890. die ();
  9891. }
  9892. }
  9893. $this->render ( "/admin/saeaCollectArticles", $data );
  9894. }
  9895. function companyCategoryCollect() {
  9896. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9897. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9898. $this->showCache ( $path );
  9899. Doo::loadModel ( 'L_category' );
  9900. Doo::loadModel ( 'itemStatistics' );
  9901. Doo::loadModel ( 'statistics' );
  9902. $statistics = new statistics ();
  9903. $Lcategory = new L_category ();
  9904. $itemStatistics = new itemStatistics ();
  9905. Doo::loadModel ( "receiptAuthorityManage" );
  9906. $receiptAuthorityManage = new receiptAuthorityManage ();
  9907. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9908. $cidList = array ();
  9909. foreach ( $imcStaff as $key => $value ) {
  9910. array_push ( $cidList, $value ['cid'] );
  9911. }
  9912. $cidString = implode ( ',', $cidList );
  9913. $LcategoryList = $Lcategory->find ( array (
  9914. 'where' => ' cid in (' . $cidString . ')',
  9915. 'asArray' => true
  9916. ) ); // 'staff='.$this->staff[0]['sid']." and
  9917. $itemStatisticsList = $itemStatistics->find ( array (
  9918. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9919. 'where' => " Year(date)=" . $year,
  9920. 'groupby' => 'cid,Month(date)',
  9921. 'asArray' => true
  9922. ) );
  9923. // ceatre companyCollectHtml
  9924. foreach ( $LcategoryList as $value ) {
  9925. $html = "";
  9926. $asum = 0;
  9927. for($i = 1; $i <= 12; $i ++) {
  9928. $falg = true;
  9929. foreach ( $itemStatisticsList as $v ) {
  9930. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9931. $asum += $v ['price'];
  9932. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9933. $falg = false;
  9934. break;
  9935. }
  9936. }
  9937. if ($falg)
  9938. $html .= '<td class="taR">-</td>';
  9939. }
  9940. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9941. $collectHtml [$value ['title']] = array (
  9942. 'html' => $html,
  9943. 'cid' => $value ['cid']
  9944. );
  9945. }
  9946. $data ['companyHtml'] = $collectHtml;
  9947. // total price html
  9948. $collectHtml = "";
  9949. $total = 0;
  9950. for($i = 1; $i <= 12; $i ++) {
  9951. $sumPrice = 0;
  9952. foreach ( $itemStatisticsList as $key => $value ) {
  9953. if ($value ['month'] == $i) {
  9954. $sumPrice += $value ['price'];
  9955. }
  9956. }
  9957. if ($sumPrice == 0)
  9958. $collectHtml .= '<td class="taR">-</td>';
  9959. else
  9960. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9961. $total += $sumPrice;
  9962. }
  9963. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9964. $data ['companyTotalHtml'] = $collectHtml;
  9965. $data ['total'] = $total;
  9966. // statistics html
  9967. // echo $cidString;
  9968. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9969. if (empty ( $stList ))
  9970. $stList = array (
  9971. 'rePrice' => 0,
  9972. 'agPrice' => 0
  9973. );
  9974. $data ['stList'] = array (
  9975. 'rePrice' => $stList ['rePrice'],
  9976. 'agPrice' => $stList ['agPrice'],
  9977. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9978. );
  9979. $data ['year'] = $year;
  9980. $data ['memu'] = "receipt";
  9981. $data ['staff'] = $this->staff;
  9982. $data ['receiptMemu'] = 'companyCategoryCollect';
  9983. $data ['verifyId'] = $this->verifyId;
  9984. $data ['executeId'] = $this->executeId;
  9985. $dateHtml = "";
  9986. $now = date ( "Y" );
  9987. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9988. if ($YEARD <= $now) {
  9989. $dateHtml .= '<option ';
  9990. if ($year == $YEARD) {
  9991. $dateHtml .= 'selected ';
  9992. }
  9993. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9994. }
  9995. }
  9996. $data ['dateHtml'] = $dateHtml;
  9997. // year staff status 2,4
  9998. if ($year < date ( "Y" )) {
  9999. Doo::loadModel ( 'receipt' );
  10000. $receipt = new receipt ();
  10001. $receiptList = $receipt->find ( array (
  10002. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10003. 'asArray' => true
  10004. ) );
  10005. if (empty ( $receiptList )) {
  10006. ob_start ();
  10007. $this->render ( "/admin/saeaCompanyCollect", $data );
  10008. $this->cacheFile ( $path );
  10009. die ();
  10010. }
  10011. }
  10012. $this->render ( "/admin/saeaCompanyCollect", $data );
  10013. }
  10014. function categoryCollectDetail() {
  10015. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10016. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10017. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10018. $this->showCache ( $path ); */
  10019. Doo::loadModel ( 'statistics' );
  10020. $statistics = new statistics ();
  10021. Doo::loadModel ( "receiptDetail" );
  10022. $receiptDetail = new receiptDetail ();
  10023. Doo::loadModel ( 'L_category' );
  10024. $Lcategory = new L_category ();
  10025. Doo::loadModel ( 'accountItem' );
  10026. $accountItem = new accountItem ();
  10027. Doo::loadModel ( "receiptAuthorityManage" );
  10028. $receiptAuthorityManage = new receiptAuthorityManage ();
  10029. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10030. $cidList = array ();
  10031. foreach ( $imcStaff as $key => $value ) {
  10032. array_push ( $cidList, $value ['cid'] );
  10033. }
  10034. $cidString = implode ( ',', $cidList );
  10035. $LcategoryList = $Lcategory->find ( array (
  10036. 'where' => 'cid in (' . $cidString . ')',
  10037. 'asArray' => true
  10038. ) );
  10039. if ($cid == 0) {
  10040. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10041. if ($cid == 0)
  10042. $cid = $LcategoryList [0] ['cid'];
  10043. }
  10044. $data ['LcategoryList'] = $LcategoryList;
  10045. $receiptCollectList = $receiptDetail->find ( array (
  10046. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10047. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10048. 'groupby' => 'item,Month(pastDate)',
  10049. 'asArray' => true
  10050. ) );
  10051. $accountList = $accountItem->find ( array (
  10052. 'asArray' => true
  10053. ) );
  10054. // create CollectDetail HTML
  10055. $collectHtml = array ();
  10056. foreach ( $accountList as $key => $value ) {
  10057. $html = "";
  10058. $asum = 0;
  10059. for($i = 1; $i <= 12; $i ++) {
  10060. $falg = true;
  10061. foreach ( $receiptCollectList as $v ) {
  10062. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10063. $asum += $v ['price'];
  10064. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10065. $falg = false;
  10066. break;
  10067. }
  10068. }
  10069. if ($falg)
  10070. $html .= '<td class="taR">-</td>';
  10071. }
  10072. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10073. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10074. }
  10075. $data ['collectHtml'] = $collectHtml;
  10076. // create Adjustment price html
  10077. $receiptCollectList = $receiptDetail->find ( array (
  10078. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10079. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10080. 'groupby' => 'itemCategory,Month(pastDate)',
  10081. 'asArray' => true
  10082. ) );
  10083. $adjustment = array ();
  10084. $collectArray = array (
  10085. '日常相关费用' => array (),
  10086. '差旅相关费用' => array (),
  10087. '培训班费用' => array (),
  10088. '内部培训费用'=>array(),
  10089. '其他' => array ()
  10090. );
  10091. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10092. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10093. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10094. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10095. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10096. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10097. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10098. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10099. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10100. array_push ( $collectArray ['其他'], $collectHtml );
  10101. $data ['collectArray'] = $collectArray;
  10102. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10103. array_push ( $adjustment, $collectHtml );
  10104. $data ['adjustment'] = $adjustment;
  10105. // total price html
  10106. $collectHtml = "";
  10107. $total = 0;
  10108. for($i = 1; $i <= 12; $i ++) {
  10109. $sumPrice = 0;
  10110. foreach ( $receiptCollectList as $key => $value ) {
  10111. if ($value ['month'] == $i) {
  10112. $sumPrice += $value ['price'];
  10113. }
  10114. }
  10115. if ($sumPrice == 0)
  10116. $collectHtml .= '<td class="taR">-</td>';
  10117. else
  10118. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10119. $total += $sumPrice;
  10120. }
  10121. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10122. // statistics html
  10123. $stList = $statistics->statisticsByCid ( $year, $cid );
  10124. if (empty ( $stList ))
  10125. $stList = array (
  10126. 'rePrice' => 0,
  10127. 'agPrice' => 0
  10128. );
  10129. $data ['stList'] = array (
  10130. 'rePrice' => $stList ['rePrice'],
  10131. 'agPrice' => $stList ['agPrice'],
  10132. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10133. );
  10134. $data ['totalYear'] = $total;
  10135. $data ['year'] = $year;
  10136. $data ['cid'] = $cid;
  10137. $data ['memu'] = "receipt";
  10138. $data ['staff'] = $this->staff;
  10139. $data ['receiptMemu'] = 'companyCategoryCollect';
  10140. $data ['verifyId'] = $this->verifyId;
  10141. $data ['executeId'] = $this->executeId;
  10142. // year staff status 2,4
  10143. /* if ($year < date ( "Y" )) {
  10144. Doo::loadModel ( 'receipt' );
  10145. $receipt = new receipt ();
  10146. $receiptList = $receipt->find ( array (
  10147. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10148. 'asArray' => true
  10149. ) );
  10150. if (empty ( $receiptList )) {
  10151. ob_start ();
  10152. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10153. $this->cacheFile ( $path );
  10154. die ();
  10155. }
  10156. } */
  10157. $dateHtml = "";
  10158. $now = date ( "Y" );
  10159. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10160. if ($YEARD <= $now) {
  10161. $dateHtml .= '<option ';
  10162. if ($year == $YEARD) {
  10163. $dateHtml .= 'selected ';
  10164. }
  10165. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10166. }
  10167. }
  10168. $data ['dateHtml'] = $dateHtml;
  10169. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10170. }
  10171. function staffCollect() {
  10172. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10173. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10174. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10175. // $this->showCache($path);
  10176. Doo::loadModel ( 'statistics' );
  10177. $statistics = new statistics ();
  10178. Doo::loadModel ( "receiptDetail" );
  10179. $receiptDetail = new receiptDetail ();
  10180. Doo::loadModel ( 'L_category' );
  10181. $Lcategory = new L_category ();
  10182. Doo::loadModel ( 'accountItem' );
  10183. $accountItem = new accountItem ();
  10184. Doo::loadModel ( 'staff' );
  10185. $staff = new staff ();
  10186. Doo::loadModel ( 'itemStatistics' );
  10187. $itemStatistics = new itemStatistics ();
  10188. Doo::loadModel ( "receiptAuthorityManage" );
  10189. $receiptAuthorityManage = new receiptAuthorityManage ();
  10190. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10191. $cidList = array ();
  10192. foreach ( $imcStaff as $key => $value ) {
  10193. array_push ( $cidList, $value ['cid'] );
  10194. }
  10195. $cidString = implode ( ',', $cidList );
  10196. $naturecon='';
  10197. if ($nature=='ONJOB'){
  10198. $naturecon=' and (nature!=4 )';
  10199. }elseif($nature=='LEAVEJOB'){
  10200. $naturecon=' and (nature=4 )';
  10201. }else{
  10202. die ( 'illegal request--nature' );
  10203. }
  10204. // statistics html
  10205. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10206. if (empty ( $stList ))
  10207. $stList = array (
  10208. 'rePrice' => 0,
  10209. 'agPrice' => 0
  10210. );
  10211. $data ['stList'] = array (
  10212. 'rePrice' => $stList ['rePrice'],
  10213. 'agPrice' => $stList ['agPrice'],
  10214. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10215. );
  10216. // ---
  10217. $staffList = $staff->find ( array (
  10218. 'where' => 'username !="admin" '.$naturecon,
  10219. 'asArray' => true
  10220. ) );
  10221. $LcategoryList = $Lcategory->find ( array (
  10222. 'asArray' => true
  10223. ) ); // 'staff='.$this->staff[0]['sid']." and
  10224. $itemStatisticsList = $itemStatistics->find ( array (
  10225. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10226. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10227. 'groupby' => 'staff,Month(date)',
  10228. 'asArray' => true
  10229. ) );
  10230. $categoryList = $staff->find ( array (
  10231. 'select' => 'COUNT(*) as count,cid,category',
  10232. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10233. 'groupby' => 'cid',
  10234. 'asArray' => true
  10235. ) );
  10236. // print_r($itemStatisticsList);die;
  10237. // ceatre companyCollectHtml
  10238. foreach ( $categoryList as $vlu ) {
  10239. $count = $vlu ['count'] + 1;
  10240. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10241. $m1 = 0;
  10242. $m2 = 0;
  10243. $m3 = 0;
  10244. $m4 = 0;
  10245. $m5 = 0;
  10246. $m6 = 0;
  10247. $m7 = 0;
  10248. $m8 = 0;
  10249. $m9 = 0;
  10250. $m10 = 0;
  10251. $m11 = 0;
  10252. $m12 = 0;
  10253. $m13 = 0;
  10254. foreach ( $staffList as $value ) {
  10255. if ($vlu ['cid'] == $value ['cid']) {
  10256. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10257. $asum = 0;
  10258. for($i = 1; $i <= 12; $i ++) {
  10259. $falg = true;
  10260. foreach ( $itemStatisticsList as $v ) {
  10261. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10262. if ($v ['month'] == 1)
  10263. $m1 += $v ['price'];
  10264. if ($v ['month'] == 2)
  10265. $m2 += $v ['price'];
  10266. if ($v ['month'] == 3)
  10267. $m3 += $v ['price'];
  10268. if ($v ['month'] == 4)
  10269. $m4 += $v ['price'];
  10270. if ($v ['month'] == 5)
  10271. $m5 += $v ['price'];
  10272. if ($v ['month'] == 6)
  10273. $m6 += $v ['price'];
  10274. if ($v ['month'] == 7)
  10275. $m7 += $v ['price'];
  10276. if ($v ['month'] == 8)
  10277. $m8 += $v ['price'];
  10278. if ($v ['month'] == 9)
  10279. $m9 += $v ['price'];
  10280. if ($v ['month'] == 10)
  10281. $m10 += $v ['price'];
  10282. if ($v ['month'] == 11)
  10283. $m11 += $v ['price'];
  10284. if ($v ['month'] == 12)
  10285. $m12 += $v ['price'];
  10286. $asum += $v ['price'];
  10287. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10288. $falg = false;
  10289. break;
  10290. }
  10291. }
  10292. if ($falg)
  10293. $html .= '<td class="taR">-</td>';
  10294. }
  10295. $m13 += $asum;
  10296. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10297. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10298. 'html' => $html,
  10299. 'sid' => $value ['sid']
  10300. );
  10301. $html = "";
  10302. }
  10303. }
  10304. $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>
  10305. <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>
  10306. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10307. $collectHtml [$vlu ['cid']] = array (
  10308. 'html' => $hl,
  10309. 'sid' => ''
  10310. );
  10311. }
  10312. $data ['companyHtml'] = $collectHtml;
  10313. // total price html
  10314. $collectHtml = "";
  10315. $total = 0;
  10316. for($i = 1; $i <= 12; $i ++) {
  10317. $sumPrice = 0;
  10318. foreach ( $itemStatisticsList as $key => $value ) {
  10319. if ($value ['month'] == $i) {
  10320. $sumPrice += $value ['price'];
  10321. }
  10322. }
  10323. if ($sumPrice == 0)
  10324. $collectHtml .= '<td class="taR">-</td>';
  10325. else
  10326. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10327. $total += $sumPrice;
  10328. }
  10329. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10330. $data ['companyTotalHtml'] = $collectHtml;
  10331. $data ['total'] = $total;
  10332. $data ['nature'] =$nature;
  10333. $data ['year'] = $year;
  10334. $data ['memu'] = "receipt";
  10335. $data ['staff'] = $this->staff;
  10336. $data ['receiptMemu'] = 'companyCategoryCollect';
  10337. $data ['verifyId'] = $this->verifyId;
  10338. $data ['executeId'] = $this->executeId;
  10339. if ($year <= date ( "Y" )) {
  10340. Doo::loadModel ( 'receipt' );
  10341. $receipt = new receipt ();
  10342. $receiptList = $receipt->find ( array (
  10343. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10344. 'asArray' => true
  10345. ) );
  10346. if (empty ( $receiptList )) { // generated files
  10347. ob_start ();
  10348. $this->render ( "/admin/saeaStaffCollectB", $data );
  10349. $this->cacheFile ( $path );
  10350. die ();
  10351. }
  10352. }
  10353. $this->render ( "/admin/saeaStaffCollectB", $data );
  10354. }
  10355. function staffCollectBak() {
  10356. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10357. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10358. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10359. $this->showCache ( $path );
  10360. Doo::loadModel ( 'statistics' );
  10361. $statistics = new statistics ();
  10362. Doo::loadModel ( "receiptDetail" );
  10363. $receiptDetail = new receiptDetail ();
  10364. Doo::loadModel ( 'L_category' );
  10365. $Lcategory = new L_category ();
  10366. Doo::loadModel ( 'accountItem' );
  10367. $accountItem = new accountItem ();
  10368. Doo::loadModel ( 'staff' );
  10369. $staff = new staff ();
  10370. Doo::loadModel ( 'itemStatistics' );
  10371. $itemStatistics = new itemStatistics ();
  10372. $itemStatisticsList = $itemStatistics->find ( array (
  10373. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10374. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10375. 'groupby' => 'staff,itemCategory,Month(date)',
  10376. 'asArray' => true
  10377. ) );
  10378. $itemCategoryList = $itemStatistics->find ( array (
  10379. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10380. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10381. 'groupby' => 'cid,itemCategory,Month(date)',
  10382. 'asArray' => true
  10383. ) );
  10384. $LcategoryList = $Lcategory->find ( array (
  10385. 'asArray' => true
  10386. ) );
  10387. $staffList = $staff->find ( array (
  10388. 'asArray' => true
  10389. ) );
  10390. $htmlArray = array ();
  10391. foreach ( $LcategoryList as $value ) {
  10392. $htmlArray [$value ['title']] = array ();
  10393. foreach ( $staffList as $v ) {
  10394. if ($value ['cid'] == $v ['cid']) {
  10395. $html = "";
  10396. $falg = true;
  10397. $staffSumPrice = 0;
  10398. foreach ( $itemStatisticsList as $a ) {
  10399. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10400. if (empty ( $a ['price'] )) {
  10401. $html .= '<td class="taR">-</td>';
  10402. $falg = false;
  10403. break;
  10404. } else {
  10405. $staffSumPrice += $a ['price'];
  10406. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10407. $falg = false;
  10408. break;
  10409. }
  10410. }
  10411. }
  10412. if ($falg) {
  10413. $html .= '<td class="taR">-</td>';
  10414. $falg = true;
  10415. }
  10416. $falg = true;
  10417. foreach ( $itemStatisticsList as $a ) {
  10418. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10419. if (empty ( $a ['price'] )) {
  10420. $html .= '<td class="taR">-</td>';
  10421. $falg = false;
  10422. break;
  10423. } else {
  10424. $staffSumPrice += $a ['price'];
  10425. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10426. $falg = false;
  10427. break;
  10428. }
  10429. }
  10430. }
  10431. if ($falg) {
  10432. $html .= '<td class="taR">-</td>';
  10433. $falg = true;
  10434. }
  10435. $falg = true;
  10436. foreach ( $itemStatisticsList as $a ) {
  10437. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10438. if (empty ( $a ['price'] )) {
  10439. $html .= '<td class="taR">-</td>';
  10440. $falg = false;
  10441. break;
  10442. } else {
  10443. $staffSumPrice += $a ['price'];
  10444. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10445. $falg = false;
  10446. break;
  10447. }
  10448. }
  10449. }
  10450. if ($falg) {
  10451. $html .= '<td class="taR">-</td>';
  10452. $falg = true;
  10453. }
  10454. $falg = true;
  10455. foreach ( $itemStatisticsList as $a ) {
  10456. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10457. if (! empty ( $a ['price'] )) {
  10458. $staffSumPrice += $a ['price'];
  10459. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10460. $falg = false;
  10461. break;
  10462. } else {
  10463. $html .= '<td class="taR">-</td>';
  10464. $falg = false;
  10465. break;
  10466. }
  10467. }
  10468. }
  10469. if ($falg) {
  10470. $html .= '<td class="taR">-</td>';
  10471. $falg = true;
  10472. }
  10473. $falg = true;
  10474. foreach ( $itemStatisticsList as $a ) {
  10475. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10476. if (! empty ( $a ['price'] )) {
  10477. $staffSumPrice += $a ['price'];
  10478. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10479. $falg = false;
  10480. break;
  10481. } else {
  10482. $html .= '<td class="taR">-</td>';
  10483. $falg = false;
  10484. break;
  10485. }
  10486. }
  10487. }
  10488. if ($falg) {
  10489. $html .= '<td class="taR">-</td>';
  10490. $falg = true;
  10491. }
  10492. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10493. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10494. }
  10495. }
  10496. /* -- --- */
  10497. // 合计费用
  10498. $cateHtml = "";
  10499. $catePrice = 0;
  10500. $cateFalg = true;
  10501. foreach ( $itemCategoryList as $l ) {
  10502. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10503. if (empty ( $l ['price'] )) {
  10504. $cateHtml .= '<td class="colGreen taR">-</td>';
  10505. $cateFalg = false;
  10506. break;
  10507. } else {
  10508. $catePrice += $l ['price'];
  10509. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10510. $cateFalg = false;
  10511. break;
  10512. }
  10513. }
  10514. }
  10515. if ($cateFalg) {
  10516. $cateHtml .= '<td class="colGreen taR">-</td>';
  10517. $cateFalg = true;
  10518. }
  10519. $cateFalg = true;
  10520. foreach ( $itemCategoryList as $l ) {
  10521. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10522. if (empty ( $l ['price'] )) {
  10523. $cateHtml .= '<td class="colGreen taR">-</td>';
  10524. $cateFalg = false;
  10525. break;
  10526. } else {
  10527. $catePrice += $l ['price'];
  10528. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10529. $cateFalg = false;
  10530. break;
  10531. }
  10532. }
  10533. }
  10534. if ($cateFalg) {
  10535. $cateHtml .= '<td class="colGreen taR">-</td>';
  10536. $cateFalg = true;
  10537. }
  10538. $cateFalg = true;
  10539. foreach ( $itemCategoryList as $l ) {
  10540. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10541. if (empty ( $l ['price'] )) {
  10542. $cateHtml .= '<td class="colGreen taR">-</td>';
  10543. $cateFalg = false;
  10544. break;
  10545. } else {
  10546. $catePrice += $l ['price'];
  10547. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10548. $cateFalg = false;
  10549. break;
  10550. }
  10551. }
  10552. }
  10553. if ($cateFalg) {
  10554. $cateHtml .= '<td class="colGreen taR">-</td>';
  10555. $cateFalg = true;
  10556. }
  10557. $cateFalg = true;
  10558. foreach ( $itemCategoryList as $l ) {
  10559. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10560. if (empty ( $l ['price'] )) {
  10561. $cateHtml .= '<td class="colGreen taR">-</td>';
  10562. $cateFalg = false;
  10563. break;
  10564. } else {
  10565. $catePrice += $l ['price'];
  10566. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10567. $cateFalg = false;
  10568. break;
  10569. }
  10570. }
  10571. }
  10572. if ($cateFalg) {
  10573. $cateHtml .= '<td class="colGreen taR">-</td>';
  10574. $cateFalg = true;
  10575. }
  10576. $cateFalg = true;
  10577. foreach ( $itemCategoryList as $l ) {
  10578. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10579. if (empty ( $l ['price'] )) {
  10580. $cateHtml .= '<td class="colGreen taR">-</td>';
  10581. $cateFalg = false;
  10582. break;
  10583. } else {
  10584. $catePrice += $l ['price'];
  10585. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10586. $cateFalg = false;
  10587. break;
  10588. }
  10589. }
  10590. }
  10591. if ($cateFalg) {
  10592. $cateHtml .= '<td class="colGreen taR">-</td>';
  10593. $cateFalg = true;
  10594. }
  10595. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10596. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10597. /* -- --- */
  10598. }
  10599. // print_r($htmlArray);die;
  10600. $data ['htmlArray'] = $htmlArray;
  10601. // statistics html
  10602. $stList = $statistics->getOne ( array (
  10603. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10604. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10605. 'groupby' => 'Month(date)',
  10606. 'asArray' => true
  10607. ) );
  10608. if (empty ( $stList ))
  10609. $stList = array (
  10610. 'rePrice' => 0,
  10611. 'agPrice' => 0
  10612. );
  10613. $data ['stList'] = array (
  10614. 'rePrice' => $stList ['rePrice'],
  10615. 'agPrice' => $stList ['agPrice'],
  10616. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10617. );
  10618. $monthHtml = "";
  10619. for($i = 1; $i <= 12; $i ++) {
  10620. if ($i == $month)
  10621. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10622. else
  10623. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10624. }
  10625. $data ['monthHtml'] = $monthHtml;
  10626. $data ['year'] = $year;
  10627. $data ['month'] = $month;
  10628. $data ['memu'] = "receipt";
  10629. $data ['staff'] = $this->staff;
  10630. $data ['receiptMemu'] = 'companyCategoryCollect';
  10631. $data ['verifyId'] = $this->verifyId;
  10632. $data ['executeId'] = $this->executeId;
  10633. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10634. Doo::loadModel ( 'receipt' );
  10635. $receipt = new receipt ();
  10636. $receiptList = $receipt->find ( array (
  10637. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10638. 'asArray' => true
  10639. ) );
  10640. if (empty ( $receiptList )) { // generated files
  10641. ob_start ();
  10642. $this->render ( "/admin/saeaStaffCollect", $data );
  10643. $this->cacheFile ( $path );
  10644. die ();
  10645. }
  10646. }
  10647. $this->render ( "/admin/saeaStaffCollect", $data );
  10648. }
  10649. /**
  10650. * 日常收支
  10651. */
  10652. function payments() {
  10653. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10654. Doo::loadModel ( "execute" );
  10655. $execute = new execute ();
  10656. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10657. die ( 'illegal request' );
  10658. }
  10659. Doo::loadModel ( "accountBook" );
  10660. $accountBook = new accountBook ();
  10661. Doo::loadModel ( "accountBookStatistics" );
  10662. $accountBookStatistics = new accountBookStatistics ();
  10663. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10664. $list = $accountBook->getAccountBookByLimit ( 10 );
  10665. $data ['date'] = date ( "Y-m-d" );
  10666. $data ['statisticsList'] = $statisticsList;
  10667. $data ['list'] = $list;
  10668. $data ['memu'] = "receipt";
  10669. $data ['staff'] = $this->staff;
  10670. $data ['receiptMemu'] = 'payments';
  10671. $data ['verifyId'] = $this->verifyId;
  10672. $data ['executeId'] = $this->executeId;
  10673. $this->render ( "/expenses/payments", $data );
  10674. }
  10675. function paymentsIncomeDo() {
  10676. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10677. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10678. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10679. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10680. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10681. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10682. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10683. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10684. Doo::loadClass ( 'XDeode' );
  10685. $XDeode = new XDeode ( 5 );
  10686. Doo::loadModel ( "accountBook" );
  10687. Doo::loadModel ( "accountBookStatistics" );
  10688. Doo::loadModel ( 'wasteBook' );
  10689. // 记录流水时银行的转换
  10690. $accountBank = '';
  10691. if ($receivedBank == '纵横广发') {
  10692. $accountBank = 'CGBDeposit';
  10693. } elseif ($receivedBank == '纵横工行') {
  10694. $accountBank = 'ICBCDeposit';
  10695. } elseif ($receivedBank == '华润银行') {
  10696. $accountBank = 'HUADeposit';
  10697. } elseif ($receivedBank == '个人广发') {
  10698. $accountBank = 'PersonalDeposit';
  10699. }
  10700. if (empty ( $accountBank ))
  10701. die ( 'illegal request-bank' );
  10702. //TODO -存款功能 提取
  10703. if($accountType == 11 || $accountType == 12){
  10704. if($accountType == 11){
  10705. $receivedBank = '纵横广发';
  10706. }elseif($accountType == 12){
  10707. $receivedBank = '纵横工行';
  10708. }
  10709. // 添加一条收入
  10710. $accountBook = new accountBook ();
  10711. $accountBook->accountType = $accountType;
  10712. $accountBook->accountMsg = $accountMsg;
  10713. $accountBook->receivedPrice = $receivedPrice;
  10714. $accountBook->receivedMsg = $receivedMsg;
  10715. $accountBook->receivedBank = $receivedBank;
  10716. $accountBook->receivedDate = $receivedDate;
  10717. $accountBook->remarks = $remarks;
  10718. $accountBook->expensesType = 1;
  10719. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10720. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10721. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10722. $inComeId = $accountBook->insert ();
  10723. // 收支汇总-添加一条收入日常汇总
  10724. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10725. $accountBookStatistics = new accountBookStatistics ();
  10726. $item = array (
  10727. 'date' => date ( "Y-m-d" ),
  10728. 'accountType' => $abDetail ['accountType'],
  10729. 'accountMsg' => $abDetail ['accountMsg'],
  10730. 'aid' => $abDetail ['aid'],
  10731. 'inComePrice' => $abDetail ['receivedPrice'],
  10732. 'expensesType' => $abDetail ['expensesType']
  10733. );
  10734. $accountBookStatistics->setAccountBookStatistics ( $item );
  10735. // 添加收入流水
  10736. if($accountType == 11){
  10737. $accountBank = 'CGBDeposit';
  10738. }elseif($accountType == 12){
  10739. $accountBank = 'ICBCDeposit';
  10740. }
  10741. $wasteBook = new wasteBook ();
  10742. $itemWaste = array (
  10743. 'accountPriceShow' => $receivedPrice,
  10744. 'accountPrice' => $receivedPrice,
  10745. 'expensesType' => 1,
  10746. 'accountType' => 6, // 流水类型
  10747. 'dataID' => $inComeId,
  10748. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10749. 'accountBank' => $accountBank,
  10750. 'category' => $this->staff [0] ['category'],
  10751. 'cid' => $this->staff [0] ['cid'],
  10752. 'name' => $this->staff [0] ['username'],
  10753. 'sid' => $this->staff [0] ['sid'],
  10754. 'inputDate' => $receivedDate,
  10755. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10756. 'synPaymentDate'=>1,
  10757. );
  10758. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10759. }
  10760. //TODO --移除理财相关
  10761. // elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10762. // // if ($receivedBank == '个人广发') {
  10763. // // die ( '个人广发 illegal request' );
  10764. // // }
  10765. // // echo $receivedBank;
  10766. // die;
  10767. // // 添加一条收入
  10768. // $accountBook = new accountBook ();
  10769. // $accountBook->accountType = 10;
  10770. // $accountBook->accountMsg = $accountMsg;
  10771. // $accountBook->receivedPrice = $receivedPrice;
  10772. // $accountBook->receivedMsg = $receivedMsg;
  10773. // $accountBook->receivedBank = $receivedBank;
  10774. // $accountBook->receivedDate = $receivedDate;
  10775. // $accountBook->remarks = $remarks;
  10776. // $accountBook->expensesType = 1;
  10777. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10778. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10779. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10780. // $inComeId = $accountBook->insert ();
  10781. // // 收支汇总-添加一条收入日常汇总
  10782. // $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10783. // $accountBookStatistics = new accountBookStatistics ();
  10784. // $item = array (
  10785. // 'date' => date ( "Y-m-d" ),
  10786. // 'accountType' => $abDetail ['accountType'],
  10787. // 'accountMsg' => $abDetail ['accountMsg'],
  10788. // 'aid' => $abDetail ['aid'],
  10789. // 'inComePrice' => $abDetail ['receivedPrice'],
  10790. // 'expensesType' => $abDetail ['expensesType']
  10791. // );
  10792. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10793. // // 添加收入流水
  10794. // $wasteBook = new wasteBook ();
  10795. // $itemWaste = array (
  10796. // 'accountPriceShow' => $receivedPrice,
  10797. // 'accountPrice' => $receivedPrice,
  10798. // 'expensesType' => 1,
  10799. // 'accountType' => 6, // 流水类型
  10800. // 'dataID' => $inComeId,
  10801. // 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10802. // 'accountBank' => $accountBank,
  10803. // 'category' => $this->staff [0] ['category'],
  10804. // 'cid' => $this->staff [0] ['cid'],
  10805. // 'name' => $this->staff [0] ['username'],
  10806. // 'sid' => $this->staff [0] ['sid'],
  10807. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10808. // );
  10809. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10810. // // 添加一条理财支出
  10811. // $accountBank = 'CGBDeposit';
  10812. // $expenditureBank = '纵横广发';
  10813. // if($accountMsg=='个人(GR)'){
  10814. // $expenditureBank = '个人广发';
  10815. // }
  10816. // $dailyExpenditureType = 4;
  10817. // if ($accountType == 9) {
  10818. // $accountBank = 'ICBCDeposit';
  10819. // $expenditureBank = '纵横工行';
  10820. // $dailyExpenditureType = 6;
  10821. // }
  10822. // $accountBook = new accountBook ();
  10823. // $accountBook->expensesType = 2;
  10824. // $accountBook->expenditureType = $dailyExpenditureType;
  10825. // $accountBook->expenditureMsg = $accountMsg;
  10826. // $accountBook->expenditurePrice = $receivedPrice;
  10827. // $accountBook->expenditureBank = $expenditureBank;
  10828. // $accountBook->expenditureDate = $receivedDate;
  10829. // $accountBook->remarks = $remarks;
  10830. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10831. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10832. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10833. // $id = $accountBook->insert ();
  10834. // // 收支汇总-添加一条理财支出汇总
  10835. // $abDetail = $accountBook->getAccountBookByAid ( $id );
  10836. // $accountBookStatistics = new accountBookStatistics ();
  10837. // $item = array (
  10838. // 'date' => date ( "Y-m-d" ),
  10839. // 'accountType' => $abDetail ['accountType'],
  10840. // 'accountMsg' => $abDetail ['accountMsg'],
  10841. // 'aid' => $abDetail ['aid'],
  10842. // 'financingPrice' => - $receivedPrice,
  10843. // 'expensesType' => 3
  10844. // );
  10845. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10846. // //TODO -新增理财为个人时的情况 添加一条支出理财流水
  10847. // $accountTypeWaste = 5;
  10848. // if ($accountMsg == '公司固定') {
  10849. // $accountTypeWaste = 9;
  10850. // } elseif ($accountMsg == '公司活期') {
  10851. // $accountTypeWaste = 10;
  10852. // } elseif ($receivedBank == '个人广发') {
  10853. // $accountTypeWaste = 9;
  10854. // $accountBank = 'ICBCDeposit';
  10855. // }
  10856. // $itemWaste = array (
  10857. // 'expensesType' => 2,
  10858. // 'accountType' => $accountTypeWaste,
  10859. // 'accountPriceShow' => $receivedPrice,
  10860. // 'accountPrice' => - $receivedPrice,
  10861. // 'dataID' => $id,
  10862. // 'dailyExpenditureType' => $dailyExpenditureType,
  10863. // 'accountBank' => $accountBank,
  10864. // 'category' => $this->staff [0] ['category'],
  10865. // 'cid' => $this->staff [0] ['cid'],
  10866. // 'name' => $this->staff [0] ['username'],
  10867. // 'sid' => $this->staff [0] ['sid'],
  10868. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10869. // );
  10870. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10871. // }
  10872. elseif ($accountType == 1) {
  10873. // if ($receivedBank == '个人广发')
  10874. // die ( 'illegal request--no man' );
  10875. // 添加一条收入
  10876. $accountBook = new accountBook ();
  10877. $accountBook->accountType = $accountType;
  10878. $accountBook->accountMsg = $accountMsg;
  10879. $accountBook->receivedPrice = $receivedPrice;
  10880. $accountBook->receivedMsg = $receivedMsg;
  10881. $accountBook->receivedBank = $receivedBank;
  10882. $accountBook->receivedDate = $receivedDate;
  10883. $accountBook->remarks = $remarks;
  10884. $accountBook->expensesType = 1;
  10885. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10886. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10887. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10888. $id = $accountBook->insert ();
  10889. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10890. // 收支汇总-添加一条收入日常汇总
  10891. $accountBookStatistics = new accountBookStatistics ();
  10892. $item = array (
  10893. 'date' => date ( "Y-m-d" ),
  10894. 'accountType' => $abDetail ['accountType'],
  10895. 'accountMsg' => $abDetail ['accountMsg'],
  10896. 'aid' => $abDetail ['aid'],
  10897. 'expensesType' => $abDetail ['expensesType']
  10898. );
  10899. if ($abDetail ['accountType'] == 8) {
  10900. $item += array (
  10901. 'inComePrice' => $abDetail ['receivedPrice']
  10902. );
  10903. } else {
  10904. $item += array (
  10905. 'inComePrice' => $abDetail ['receivedPrice']
  10906. );
  10907. }
  10908. $accountBookStatistics->setAccountBookStatistics ( $item );
  10909. // 流水存储方向
  10910. $itemWaste = array (
  10911. 'accountType' => 6
  10912. ); // 流水类型
  10913. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10914. // }else
  10915. if ($accountMsg == '活期理财收益') {
  10916. $itemWaste = array (
  10917. 'accountType' => 10
  10918. ); // 流水类型
  10919. }
  10920. // 添加收入流水
  10921. $wasteBook = new wasteBook ();
  10922. $itemWaste += array (
  10923. 'accountPrice' => $receivedPrice,
  10924. 'accountPriceShow' => $receivedPrice,
  10925. 'expensesType' => 1,
  10926. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10927. 'dataID' => $id,
  10928. 'accountBank' => $accountBank,
  10929. 'category' => $this->staff [0] ['category'],
  10930. 'cid' => $this->staff [0] ['cid'],
  10931. 'name' => $this->staff [0] ['username'],
  10932. 'sid' => $this->staff [0] ['sid'],
  10933. 'inputDate' => $receivedDate,
  10934. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10935. 'synPaymentDate'=>1,
  10936. );
  10937. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10938. } else { // 普通日常收入处理
  10939. // 添加一条收入
  10940. $accountBook = new accountBook ();
  10941. $accountBook->accountType = $accountType;
  10942. $accountBook->accountMsg = $accountMsg;
  10943. $accountBook->receivedPrice = $receivedPrice;
  10944. $accountBook->receivedMsg = $receivedMsg;
  10945. $accountBook->receivedBank = $receivedBank;
  10946. $accountBook->receivedDate = $receivedDate;
  10947. $accountBook->remarks = $remarks;
  10948. $accountBook->expensesType = 1;
  10949. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10950. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10951. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10952. $id = $accountBook->insert ();
  10953. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10954. // 收支汇总-添加一条收入日常汇总
  10955. $accountBookStatistics = new accountBookStatistics ();
  10956. $item = array (
  10957. 'date' => date ( "Y-m-d" ),
  10958. 'accountType' => $abDetail ['accountType'],
  10959. 'accountMsg' => $abDetail ['accountMsg'],
  10960. 'aid' => $abDetail ['aid'],
  10961. 'expensesType' => $abDetail ['expensesType']
  10962. );
  10963. if ($abDetail ['accountType'] == 8) {
  10964. $item += array (
  10965. 'inComePrice' => $abDetail ['receivedPrice']
  10966. );
  10967. } else {
  10968. $item += array (
  10969. 'inComePrice' => $abDetail ['receivedPrice']
  10970. );
  10971. }
  10972. $accountBookStatistics->setAccountBookStatistics ( $item );
  10973. // 添加收入流水
  10974. // $itemWaste = array (
  10975. // 'accountPrice' => $receivedPrice
  10976. // );
  10977. // if ($receivedBank == '个人广发') {
  10978. // $itemWaste = array (
  10979. // 'accountPrice' => - $receivedPrice
  10980. // );
  10981. // }
  10982. $wasteBook = new wasteBook ();
  10983. $itemWaste = array (
  10984. 'accountPriceShow' => $receivedPrice,
  10985. 'accountPrice' => $receivedPrice,
  10986. 'expensesType' => 1,
  10987. 'accountType' => 6, // 流水类型
  10988. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10989. 'dataID' => $id,
  10990. 'accountBank' => $accountBank,
  10991. 'category' => $this->staff [0] ['category'],
  10992. 'cid' => $this->staff [0] ['cid'],
  10993. 'name' => $this->staff [0] ['username'],
  10994. 'sid' => $this->staff [0] ['sid'],
  10995. 'inputDate' => $receivedDate,
  10996. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10997. 'synPaymentDate'=>1,
  10998. );
  10999. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11000. }
  11001. }
  11002. return '/payments';
  11003. }
  11004. function paymentsExpenditureDo() {
  11005. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11006. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11007. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11008. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11009. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11010. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11011. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11012. // 理财支出特殊处理
  11013. Doo::loadModel ( "accountBook" );
  11014. Doo::loadModel ( "accountBookStatistics" );
  11015. Doo::loadModel ( 'wasteBook' );
  11016. $accountBank = '';
  11017. if ($expenditureBank == '纵横广发') {
  11018. $accountBank = 'CGBDeposit';
  11019. } elseif ($expenditureBank == '纵横工行') {
  11020. $accountBank = 'ICBCDeposit';
  11021. } elseif ($expenditureBank == '华润银行') {
  11022. $accountBank = 'HUADeposit';
  11023. } elseif ($expenditureBank == '个人广发') {
  11024. $accountBank = 'PersonalDeposit';
  11025. }
  11026. if (empty ( $accountBank ))
  11027. die ( 'illegal request' );
  11028. if($expenditureType == 8 || $expenditureType == 9){
  11029. // if($expenditureType == 8 ){
  11030. // $expenditureBank='纵横广发';
  11031. // }elseif($expenditureType == 9){
  11032. // $expenditureBank='纵横工行';
  11033. // }
  11034. // // 添加一笔日常支出
  11035. // $accountBook = new accountBook ();
  11036. // $accountBook->expensesType = 2;
  11037. // $accountBook->expenditureType = $expenditureType;
  11038. // $accountBook->expenditureMsg = $expenditureMsg;
  11039. // $accountBook->expenditurePrice = $expenditurePrice;
  11040. // $accountBook->expenditureBank = $expenditureBank;
  11041. // $accountBook->expenditureDate = $expenditureDate;
  11042. // $accountBook->remarks = $remarks;
  11043. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11044. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11045. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11046. // $expenditureId = $accountBook->insert ();
  11047. // // 添加日常支出汇总
  11048. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11049. // $accountBookStatistics = new accountBookStatistics ();
  11050. // $item = array (
  11051. // 'date' => date ( "Y-m-d" ),
  11052. // 'expenditureType' => $abDetail ['expenditureType'],
  11053. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11054. // 'aid' => $abDetail ['aid'],
  11055. // 'payPrice' => $abDetail ['expenditurePrice'],
  11056. // 'expensesType' => $abDetail ['expensesType']
  11057. // );
  11058. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11059. // // 公司日常支出流水
  11060. // if($expenditureType == 8 ){
  11061. // $accountBank = 'CGBDeposit';
  11062. // }elseif($expenditureType == 9){
  11063. // $accountBank = 'ICBCDeposit';
  11064. // }
  11065. // if($accountBank=='CGBDeposit'){
  11066. // $dailyExpenditureType='8';
  11067. // }elseif($accountBank=='ICBCDeposit'){
  11068. // $dailyExpenditureType='9';
  11069. // }elseif($accountBank=='PersonalDeposit'){
  11070. // $dailyExpenditureType='10';
  11071. // }elseif($accountBank=='HUADeposit'){
  11072. // $dailyExpenditureType='11';
  11073. // }
  11074. // $wasteBook = new wasteBook ();
  11075. // $itemWaste = array (
  11076. // 'expensesType' => 2,
  11077. // 'accountType' => 5,
  11078. // 'dailyExpenditureType' => $dailyExpenditureType,
  11079. // 'accountPriceShow' => $expenditurePrice,
  11080. // 'accountPrice' => - $expenditurePrice,
  11081. // 'dataID' => $expenditureId,
  11082. // 'accountBank' => $accountBank,
  11083. // 'category' => $this->staff [0] ['category'],
  11084. // 'cid' => $this->staff [0] ['cid'],
  11085. // 'name' => $this->staff [0] ['username'],
  11086. // 'sid' => $this->staff [0] ['sid'],
  11087. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11088. // );
  11089. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11090. //TODO 日常支出 个人理财情况的相关修改
  11091. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11092. // if ($expenditureBank == '个人广发') {
  11093. // die ( '个人广发 illegal request' );
  11094. // }
  11095. // echo $expenditureMsg;
  11096. die;
  11097. // // 添加一笔日常支出
  11098. // $accountBook = new accountBook ();
  11099. // $accountBook->expensesType = 2;
  11100. // $accountBook->expenditureType = 7;
  11101. // $accountBook->expenditureMsg = $expenditureMsg;
  11102. // $accountBook->expenditurePrice = $expenditurePrice;
  11103. // $accountBook->expenditureBank = $expenditureBank;
  11104. // $accountBook->expenditureDate = $expenditureDate;
  11105. // $accountBook->remarks = $remarks;
  11106. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11107. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11108. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11109. // $expenditureId = $accountBook->insert ();
  11110. // // 添加日常支出汇总
  11111. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11112. // $accountBookStatistics = new accountBookStatistics ();
  11113. // $item = array (
  11114. // 'date' => date ( "Y-m-d" ),
  11115. // 'expenditureType' => $abDetail ['expenditureType'],
  11116. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11117. // 'aid' => $abDetail ['aid'],
  11118. // 'payPrice' => $abDetail ['expenditurePrice'],
  11119. // 'expensesType' => $abDetail ['expensesType']
  11120. // );
  11121. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11122. // // 公司日常支出流水
  11123. // $wasteBook = new wasteBook ();
  11124. // $itemWaste = array (
  11125. // 'accountPrice' => - $expenditurePrice
  11126. // );
  11127. // if($expenditureMsg!='个人(GR)'){
  11128. // if ($expenditureBank == '个人广发') {
  11129. // $itemWaste = array (
  11130. // 'accountPrice' => $expenditurePrice
  11131. // );
  11132. // }
  11133. // }
  11134. // $itemWaste += array (
  11135. // 'expensesType' => 2,
  11136. // 'accountType' => 5,
  11137. // 'dailyExpenditureType' => $expenditureType,
  11138. // 'accountPriceShow' => $expenditurePrice,
  11139. // 'accountPrice' => - $expenditurePrice,
  11140. // 'dataID' => $expenditureId,
  11141. // 'accountBank' => $accountBank,
  11142. // 'category' => $this->staff [0] ['category'],
  11143. // 'cid' => $this->staff [0] ['cid'],
  11144. // 'name' => $this->staff [0] ['username'],
  11145. // 'sid' => $this->staff [0] ['sid'],
  11146. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11147. // );
  11148. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11149. // // 添加一笔理财收入
  11150. // $accountBank = 'CGBDeposit';
  11151. // $dailyIncomeType = 7;
  11152. // $receivedBank = '纵横广发';
  11153. // if ($expenditureType == 6) {
  11154. // $accountBank = 'ICBCDeposit';
  11155. // $receivedBank = '纵横工行';
  11156. // $dailyIncomeType = 9;
  11157. // }elseif($expenditureMsg=='个人(GR)'){
  11158. // $receivedBank = '个人广发';
  11159. // }
  11160. // $accountBook = new accountBook ();
  11161. // $accountBook->expensesType = 1;
  11162. // $accountBook->accountType = $dailyIncomeType;
  11163. // $accountBook->accountMsg = $expenditureMsg;
  11164. // $accountBook->receivedPrice = $expenditurePrice;
  11165. // $accountBook->receivedBank = $receivedBank;
  11166. // $accountBook->receivedDate = $expenditureDate;
  11167. // $accountBook->remarks = $remarks;
  11168. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11169. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11170. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11171. // $id = $accountBook->insert ();
  11172. // // 添加日常理财收入汇总
  11173. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11174. // $accountBookStatistics = new accountBookStatistics ();
  11175. // $item = array (
  11176. // 'date' => date ( "Y-m-d" ),
  11177. // 'expenditureType' => $abDetail ['expenditureType'],
  11178. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11179. // 'aid' => $abDetail ['aid'],
  11180. // 'financingPrice' => $expenditurePrice,
  11181. // 'expensesType' => 3
  11182. // );
  11183. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11184. // //TODO 修改理财收入 添加一笔收入流水
  11185. // if ($expenditureMsg == '公司固定') {
  11186. // $accountTypeWaste = 9;
  11187. // } elseif ($expenditureMsg == '公司活期') {
  11188. // $accountTypeWaste = 10;
  11189. // } elseif ($expenditureMsg == '个人(GR)') {
  11190. // $accountTypeWaste = 9;
  11191. // $accountBank = 'ICBCDeposit';
  11192. // }
  11193. // $itemWaste = array (
  11194. // 'expensesType' => 1,
  11195. // 'accountType' => $accountTypeWaste,
  11196. // 'accountPriceShow' => $expenditurePrice,
  11197. // 'accountPrice' => $expenditurePrice,
  11198. // 'dataID' => $id,
  11199. // 'dailyIncomeType' => $dailyIncomeType,
  11200. // 'accountBank' => $accountBank,
  11201. // 'category' => $this->staff [0] ['category'],
  11202. // 'cid' => $this->staff [0] ['cid'],
  11203. // 'name' => $this->staff [0] ['username'],
  11204. // 'sid' => $this->staff [0] ['sid'],
  11205. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11206. // );
  11207. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11208. } else {
  11209. // 添加一笔日常支出
  11210. $accountBook = new accountBook ();
  11211. $accountBook->expensesType = 2;
  11212. $accountBook->expenditureType = $expenditureType;
  11213. $accountBook->expenditureMsg = $expenditureMsg;
  11214. $accountBook->expenditurePrice = $expenditurePrice;
  11215. $accountBook->expenditureBank = $expenditureBank;
  11216. $accountBook->expenditureDate = $expenditureDate;
  11217. $accountBook->remarks = $remarks;
  11218. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11219. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11220. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11221. $id = $accountBook->insert ();
  11222. // 添加日常支出汇总
  11223. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11224. $accountBookStatistics = new accountBookStatistics ();
  11225. $item = array (
  11226. 'date' => date ( "Y-m-d" ),
  11227. 'expenditureType' => $abDetail ['expenditureType'],
  11228. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11229. 'aid' => $abDetail ['aid'],
  11230. 'expensesType' => $abDetail ['expensesType']
  11231. );
  11232. if ($expenditureType == 5) {
  11233. $item += array (
  11234. 'payPrice' => - $abDetail ['expenditurePrice']
  11235. );
  11236. } else {
  11237. $item += array (
  11238. 'payPrice' => $abDetail ['expenditurePrice']
  11239. );
  11240. }
  11241. $accountBookStatistics->setAccountBookStatistics ( $item );
  11242. // 公司日常支出流水
  11243. $wasteBook = new wasteBook ();
  11244. $itemWaste = array (
  11245. 'accountPrice' => - $expenditurePrice
  11246. );
  11247. if ($expenditureBank == '个人广发') {
  11248. $itemWaste = array (
  11249. 'accountPrice' => $expenditurePrice
  11250. );
  11251. }
  11252. $itemWaste += array (
  11253. 'expensesType' => 2,
  11254. 'accountType' => 5,
  11255. 'accountPriceShow' => $expenditurePrice,
  11256. 'dataID' => $id,
  11257. 'dailyExpenditureType' => $expenditureType,
  11258. 'accountBank' => $accountBank,
  11259. 'category' => $this->staff [0] ['category'],
  11260. 'cid' => $this->staff [0] ['cid'],
  11261. 'name' => $this->staff [0] ['username'],
  11262. 'sid' => $this->staff [0] ['sid'],
  11263. 'inputDate' => date ( "Y-m-d H:i:s" )
  11264. );
  11265. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11266. }
  11267. }
  11268. return '/payments';
  11269. }
  11270. /**
  11271. * 添加支出
  11272. */
  11273. function paymentsExpenditureDo_() {
  11274. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11275. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11276. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11277. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11278. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11279. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11280. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11281. $dailyExpenditureType = '';
  11282. $accountTypeWaste = 5;
  11283. $accountBank = '';
  11284. if ($expenditureBank == '纵横广发') {
  11285. $accountBank = 'CGBDeposit';
  11286. } elseif ($expenditureBank == '纵横工行') {
  11287. $accountBank = 'ICBCDeposit';
  11288. } elseif ($expenditureBank == '华润银行') {
  11289. $accountBank = 'HUADeposit';
  11290. } elseif ($expenditureBank == '个人广发') {
  11291. $accountBank = 'PersonalDeposit';
  11292. }
  11293. if (empty ( $accountBank ))
  11294. die ( 'illegal request' );
  11295. $itemWaste = array (
  11296. 'accountPrice' => - $expenditurePrice
  11297. );
  11298. if ($expenditureBank == '个人广发') {
  11299. $itemWaste = array (
  11300. 'accountPrice' => $expenditurePrice
  11301. );
  11302. }
  11303. if ($expenditureType == 4 || $expenditureType == 6) {
  11304. $dailyExpenditureType = 4;
  11305. if ($expenditureMsg == '公司固定') {
  11306. $accountTypeWaste = 9;
  11307. } elseif ($expenditureMsg == '公司活期') {
  11308. $accountTypeWaste = 10;
  11309. } elseif ($expenditureMsg == '个人(GR)') {
  11310. $accountBank = 'PersonalDeposit';
  11311. }
  11312. $itemWaste = array (
  11313. 'accountPrice' => $expenditurePrice
  11314. );
  11315. } elseif ($expenditureType == 1) {
  11316. $dailyExpenditureType = 1;
  11317. } elseif ($expenditureType == 2) {
  11318. $dailyExpenditureType = 2;
  11319. } elseif ($expenditureType == 3) {
  11320. $dailyExpenditureType = 3;
  11321. } elseif ($expenditureType == 5) {
  11322. $dailyExpenditureType = 5;
  11323. }
  11324. if (empty ( $dailyExpenditureType ))
  11325. die ( 'illegal request' );
  11326. Doo::loadModel ( "accountBook" );
  11327. $accountBook = new accountBook ();
  11328. $accountBook->expenditureType = $expenditureType;
  11329. $accountBook->expenditureMsg = $expenditureMsg;
  11330. $accountBook->expenditurePrice = $expenditurePrice;
  11331. $accountBook->expenditureBank = $expenditureBank;
  11332. $accountBook->expenditureDate = $expenditureDate;
  11333. $accountBook->remarks = $remarks;
  11334. $accountBook->expensesType = 2;
  11335. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11336. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11337. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11338. $id = $accountBook->insert ();
  11339. //
  11340. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11341. Doo::loadModel ( "accountBookStatistics" );
  11342. $accountBookStatistics = new accountBookStatistics ();
  11343. $item = array (
  11344. 'date' => date ( "Y-m-d" ),
  11345. 'expenditureType' => $abDetail ['expenditureType'],
  11346. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11347. 'aid' => $abDetail ['aid']
  11348. );
  11349. if ($abDetail ['expensesType'] == 2) {
  11350. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11351. $item += array (
  11352. 'financingPrice' => $expenditurePrice,
  11353. 'expensesType' => 3
  11354. );
  11355. } elseif ($abDetail ['expenditureType'] == 5) {
  11356. $item += array (
  11357. 'payPrice' => $abDetail ['expenditurePrice'],
  11358. 'expensesType' => $abDetail ['expensesType']
  11359. );
  11360. } else {
  11361. $item += array (
  11362. 'payPrice' => $abDetail ['expenditurePrice'],
  11363. 'expensesType' => $abDetail ['expensesType']
  11364. );
  11365. }
  11366. }
  11367. $accountBookStatistics->setAccountBookStatistics ( $item );
  11368. // 公司流水记录
  11369. Doo::loadModel ( 'wasteBook' );
  11370. $wasteBook = new wasteBook ();
  11371. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11372. // 银行
  11373. if (empty ( $abDetail )) {
  11374. $itemWaste += array (
  11375. 'accountPriceShow' => $expenditurePrice,
  11376. 'dataID' => $id,
  11377. 'expensesType' => 2,
  11378. 'accountType' => $accountTypeWaste,
  11379. 'dailyExpenditureType' => $expenditureType,
  11380. 'accountBank' => $accountBank,
  11381. 'category' => $this->staff [0] ['category'],
  11382. 'cid' => $this->staff [0] ['cid'],
  11383. 'name' => $this->staff [0] ['username'],
  11384. 'sid' => $this->staff [0] ['sid'],
  11385. 'inputDate' => date ( "Y-m-d H:i:s" )
  11386. );
  11387. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11388. }
  11389. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11390. if ($expenditureType == 4 || $expenditureType == 6) {
  11391. $accountBank = 'CGBDeposit';
  11392. $dailyIncomeType = 7;
  11393. $receivedBank = '纵横广发';
  11394. if ($expenditureType == 6) {
  11395. $accountBank = 'ICBCDeposit';
  11396. $receivedBank = '纵横工行';
  11397. $dailyIncomeType = 9;
  11398. }
  11399. // 添加一笔收入
  11400. $accountBook = new accountBook ();
  11401. $accountBook->accountType = $dailyIncomeType;
  11402. $accountBook->accountMsg = $expenditureMsg;
  11403. $accountBook->receivedPrice = $expenditurePrice;
  11404. $accountBook->receivedBank = $receivedBank;
  11405. $accountBook->receivedDate = $expenditureDate;
  11406. $accountBook->remarks = $remarks;
  11407. $accountBook->expensesType = 1;
  11408. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11409. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11410. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11411. $id = $accountBook->insert ();
  11412. // 添加一笔收入流水
  11413. $itemWaste = array (
  11414. 'accountPriceShow' => $expenditurePrice,
  11415. 'accountPrice' => - $expenditurePrice,
  11416. 'dataID' => $id,
  11417. 'expensesType' => 1,
  11418. 'accountType' => $accountTypeWaste,
  11419. 'dailyIncomeType' => $dailyIncomeType,
  11420. 'accountBank' => $accountBank,
  11421. 'category' => $this->staff [0] ['category'],
  11422. 'cid' => $this->staff [0] ['cid'],
  11423. 'name' => $this->staff [0] ['username'],
  11424. 'sid' => $this->staff [0] ['sid'],
  11425. 'inputDate' => date ( "Y-m-d H:i:s" )
  11426. );
  11427. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11428. }
  11429. }
  11430. return '/payments';
  11431. }
  11432. /**
  11433. * 所有收支
  11434. */
  11435. function paymentsAchieve() {
  11436. $page_size = 12;
  11437. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11438. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11439. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11440. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11441. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11442. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11443. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11444. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11445. Doo::loadModel ( "accountBookStatistics" );
  11446. $accountBookStatistics = new accountBookStatistics ();
  11447. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11448. $data ['statisticsList'] = $statisticsList;
  11449. Doo::loadModel ( "accountBook" );
  11450. $accountBook = new accountBook ();
  11451. $con = '';
  11452. if ($expensesType == 'INCOME')
  11453. $con = ' and expensesType=1 ';
  11454. elseif ($expensesType == 'PAY')
  11455. $con = ' and expensesType=2 ';
  11456. $dateArr = explode ( ':', $date );
  11457. $D1 = $dateString = '';
  11458. $D2 = '';
  11459. if (! empty ( $date )) {
  11460. $D1 = $dateArr [0];
  11461. if (isset ( $dateArr [1] ))
  11462. $D2 = $dateArr [1];
  11463. else
  11464. $D2 = '';
  11465. $dateString = $D1 . " : " . $D2;
  11466. }
  11467. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11468. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11469. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11470. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11471. if (! empty ( $price ))
  11472. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11473. if ($submitType == 1) {
  11474. if ($accountType != '') {
  11475. $expenditureType = '';
  11476. $con .= ' and accountType=' . $accountType;
  11477. if (! empty ( $accountMsg ))
  11478. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11479. }
  11480. } elseif ($submitType == 2) {
  11481. if ($expenditureType != '') {
  11482. $accountType = $accountMsg = '';
  11483. $con .= ' and expenditureType=' . $expenditureType;
  11484. }
  11485. } else {
  11486. $accountType = $accountMsg = $expenditureType = '';
  11487. }
  11488. $sql = "" . $con;
  11489. $action = "paymentsAchieve";
  11490. $get = '/' . $expensesType."?accountType=".$accountType."&expenditureType=".$expenditureType."&submitType=".$submitType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11491. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11492. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11493. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11494. $data ['expenditureType'] = $expenditureType;
  11495. $data ['accountMsg'] = $accountMsg;
  11496. $data ['accountType'] = $accountType;
  11497. $data ['inputDate'] = $date;
  11498. $data ['price'] = $price;
  11499. $data ['expensesType'] = $expensesType;
  11500. $data ['page'] = $pageinfo;
  11501. $data ['list'] = $list;
  11502. $data ['memu'] = "receipt";
  11503. $data ['staff'] = $this->staff;
  11504. $data ['receiptMemu'] = 'payments';
  11505. $data ['verifyId'] = $this->verifyId;
  11506. $data ['executeId'] = $this->executeId;
  11507. $this->render ( "/expenses/paymentsAchieve", $data );
  11508. }
  11509. function paymentsIncomeUpdateDo() {
  11510. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11511. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11512. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11513. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11514. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11515. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11516. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11517. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11518. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11519. Doo::loadClass ( 'XDeode' );
  11520. $XDeode = new XDeode ( 5 );
  11521. $aid = $XDeode->decode ( $aidKey );
  11522. Doo::loadModel ( "accountBook" );
  11523. $accountBook = new accountBook ();
  11524. //
  11525. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11526. $price = $receivedPrice - $abDetail [inComePrice];
  11527. Doo::loadModel ( "accountBookStatistics" );
  11528. $accountBookStatistics = new accountBookStatistics ();
  11529. if ($abDetail ['accountType'] == 7) {
  11530. $item += array (
  11531. 'date' => date ( "Y-m-d" ),
  11532. 'financingPrice' => - $price,
  11533. 'expensesType' => 3,
  11534. 'aid' => $abDetail ['aid']
  11535. );
  11536. } elseif ($abDetail ['accountType'] == 8) {
  11537. $item += array (
  11538. 'date' => date ( "Y-m-d" ),
  11539. 'expensesType' => $abDetail ['expensesType'],
  11540. 'inComePrice' => - $price,
  11541. 'aid' => $abDetail ['aid']
  11542. );
  11543. } else {
  11544. $item = array (
  11545. 'date' => date ( "Y-m-d" ),
  11546. 'expensesType' => $abDetail ['expensesType'],
  11547. 'inComePrice' => $price,
  11548. 'aid' => $abDetail ['aid']
  11549. );
  11550. }
  11551. $accountBookStatistics->setAccountBookStatistics ( $item );
  11552. $accountBook->accountType = $accountType;
  11553. $accountBook->accountMsg = $accountMsg;
  11554. $accountBook->receivedPrice = $receivedPrice;
  11555. $accountBook->receivedMsg = $receivedMsg;
  11556. $accountBook->receivedBank = $receivedBank;
  11557. $accountBook->receivedDate = $receivedDate;
  11558. $accountBook->remarks = $remarks;
  11559. $accountBook->aid = $aid;
  11560. $accountBook->update ();
  11561. }
  11562. return '/paymentsAchieve';
  11563. }
  11564. function paymentsExpenditureEdiDo() {
  11565. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11566. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11567. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11568. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11569. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11570. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11571. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11572. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11573. Doo::loadClass ( 'XDeode' );
  11574. $XDeode = new XDeode ( 5 );
  11575. $aid = $XDeode->decode ( $aidKey );
  11576. Doo::loadModel ( "accountBook" );
  11577. $accountBook = new accountBook ();
  11578. // 汇总信息
  11579. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11580. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11581. Doo::loadModel ( "accountBookStatistics" );
  11582. $accountBookStatistics = new accountBookStatistics ();
  11583. if ($abDetail ['expenditureType'] == 4) {
  11584. $item += array (
  11585. 'date' => date ( "Y-m-d" ),
  11586. 'financingPrice' => $price,
  11587. 'expensesType' => 3,
  11588. 'aid' => $abDetail ['aid']
  11589. );
  11590. } elseif ($abDetail ['expenditureType'] == 5) {
  11591. $item += array (
  11592. 'date' => date ( "Y-m-d" ),
  11593. 'expensesType' => $abDetail ['expensesType'],
  11594. 'payPrice' => $price,
  11595. 'aid' => $abDetail ['aid']
  11596. );
  11597. } else {
  11598. $item = array (
  11599. 'date' => date ( "Y-m-d" ),
  11600. 'expensesType' => $abDetail ['expensesType'],
  11601. 'payPrice' => $price,
  11602. 'aid' => $abDetail ['aid']
  11603. );
  11604. }
  11605. $accountBookStatistics->setAccountBookStatistics ( $item );
  11606. //
  11607. $accountBook->expenditureType = $expenditureType;
  11608. $accountBook->expenditureMsg = $expenditureMsg;
  11609. $accountBook->expenditurePrice = $expenditurePrice;
  11610. $accountBook->expenditureBank = $expenditureBank;
  11611. $accountBook->remarks = $remarks;
  11612. $accountBook->expenditureDate = $expenditureDate;
  11613. $accountBook->aid = $aid;
  11614. $id = $accountBook->update ();
  11615. }
  11616. return '/paymentsAchieve';
  11617. }
  11618. function paymentsDelDo() {
  11619. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11620. if (! empty ( $aidKey )) {
  11621. Doo::loadClass ( 'XDeode' );
  11622. $XDeode = new XDeode ( 5 );
  11623. $aid = $XDeode->decode ( $aidKey );
  11624. Doo::loadModel ( "accountBook" );
  11625. $accountBook = new accountBook ();
  11626. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11627. if (empty ( $abDetail ))
  11628. die ( 'illegal request' );
  11629. // 删除收支
  11630. Doo::loadModel ( "accountBookStatistics" );
  11631. $accountBookStatistics = new accountBookStatistics ();
  11632. $item = array (
  11633. 'date' => date ( "Y-m-d" ),
  11634. 'aid' => $abDetail ['aid']
  11635. );
  11636. $accountType = '';
  11637. if ($abDetail ['expensesType'] == 1) {
  11638. $accountType = 6;
  11639. if ($abDetail ['accountType'] != 7) {
  11640. $item += array (
  11641. 'expensesType' => $abDetail ['expensesType'],
  11642. 'inComePrice' => - $abDetail ['receivedPrice']
  11643. );
  11644. } else {
  11645. $item += array (
  11646. 'financingPrice' => $abDetail ['receivedPrice'],
  11647. 'expensesType' => 3
  11648. );
  11649. }
  11650. } elseif ($abDetail ['expensesType'] == 2) {
  11651. $accountType = 5;
  11652. if ($abDetail ['accountType'] != 7) {
  11653. $item += array (
  11654. 'expensesType' => $abDetail ['expensesType'],
  11655. 'payPrice' => - $abDetail ['expenditurePrice']
  11656. );
  11657. } else {
  11658. $item += array (
  11659. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11660. 'expensesType' => 3
  11661. );
  11662. }
  11663. }
  11664. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11665. if ($abDetail ['expenditureMsg'] == '公司固定')
  11666. $accountType = 9;
  11667. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11668. $accountType = 10;
  11669. }
  11670. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11671. if ($abDetail ['accountMsg'] == '公司固定')
  11672. $accountType = 9;
  11673. elseif ($abDetail ['accountMsg'] == '公司活期')
  11674. $accountType = 10;
  11675. }
  11676. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11677. $accountType = 10;
  11678. }
  11679. $accountBookStatistics->setAccountBookStatistics ( $item );
  11680. $accountBook->delete ( array (
  11681. 'where' => 'aid=' . $aid,
  11682. 'limit' => 1
  11683. ) );
  11684. // 删除收入流水
  11685. //TODO 2020-07-23 删除新增理财和银行存款流水
  11686. if (! empty ( $accountType )) {
  11687. Doo::loadModel ( 'wasteBook' );
  11688. $wasteBook = new wasteBook ();
  11689. $wasteBook->delete ( array (
  11690. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11691. 'limit' => 1
  11692. ) );
  11693. }
  11694. }
  11695. return '/paymentsAchieve';
  11696. }
  11697. function paymentsCollect() {
  11698. Doo::loadModel ( "execute" );
  11699. $execute = new execute ();
  11700. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11701. die ( 'illegal request' );
  11702. }
  11703. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11704. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11705. Doo::loadModel ( "accountBookStatistics" );
  11706. $accountBookStatistics = new accountBookStatistics ();
  11707. Doo::loadClass ( 'receipt.func' );
  11708. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11709. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11710. $data ['html'] = $html ['html'];
  11711. $data ['inSum'] = $html ['sum'];
  11712. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11713. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11714. $data ['payHtml'] = $html ['html'];
  11715. $data ['paySum'] = $html ['sum'];
  11716. // 余额统计
  11717. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11718. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11719. include './protected/config/wasteBook.conf.php';
  11720. Doo::loadModel ( 'wasteBook' );
  11721. $wasteBook = new wasteBook ();
  11722. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11723. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11724. // 获得年份之前所有金额
  11725. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11726. // print_r($detail);
  11727. // $waste['total'];
  11728. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11729. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11730. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11731. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11732. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11733. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11734. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11735. if (date ( 'Y' ) > $year) {
  11736. $limitMonth = 12;
  11737. }
  11738. for($i = 1; $i <= 12; $i ++) {
  11739. $inComeA = $payB = 0;
  11740. $falg = true;
  11741. foreach ( $inComePay as $key => $value ) {
  11742. if ($value ['month'] == $i) {
  11743. $falg = false;
  11744. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11745. $inSum += $value ['accountPrice'];
  11746. $showInSum += $value ['accountPriceShow'];
  11747. $inComeA = $value ['accountPrice'];
  11748. break;
  11749. }
  11750. }
  11751. if ($falg)
  11752. $inComeHtml .= '<td class="taR">-</td>';
  11753. $payFalg = true;
  11754. foreach ( $pay as $key => $value ) {
  11755. if ($value ['month'] == $i) {
  11756. $payFalg = false;
  11757. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11758. $paySum += $value ['accountPrice'];
  11759. $showPaySum += $value ['accountPriceShow'];
  11760. $payB = $value ['accountPrice'];
  11761. break;
  11762. }
  11763. }
  11764. if ($payFalg)
  11765. $payHtml .= '<td class="taR">-</td>';
  11766. if (empty ( $balanceC ) || $limitMonth < $i)
  11767. $lastBalanceHtml .= '<td class="taR">-</td>';
  11768. else
  11769. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11770. $balanceC = $balanceC + $inComeA + $payB;
  11771. $balanceSum += $balanceC;
  11772. if (empty ( $balanceC ) || $limitMonth < $i)
  11773. $BalanceHtml .= '<td class="taR">-</td>';
  11774. else
  11775. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11776. // 余额统计
  11777. }
  11778. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11779. $data ['inComeHtml'] = $inComeHtml;
  11780. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11781. $data ['payBalanceHtml'] = $payHtml;
  11782. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11783. $data ['BalanceHtml'] = $BalanceHtml;
  11784. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11785. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11786. $mothHtml = "";
  11787. for($i = 1; $i <= 12; $i ++) {
  11788. if ($moth == $i)
  11789. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11790. else
  11791. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11792. }
  11793. $data ['mothHtml'] = $mothHtml;
  11794. $dateHtml = "";
  11795. $now = date ( "Y" );
  11796. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11797. if ($YEARD <= $now) {
  11798. $dateHtml .= '<option ';
  11799. if ($year == $YEARD) {
  11800. $dateHtml .= 'selected ';
  11801. }
  11802. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11803. }
  11804. }
  11805. $data ['dateHtml'] = $dateHtml;
  11806. $data ['year'] = $year;
  11807. $data ['memu'] = "receipt";
  11808. $data ['staff'] = $this->staff;
  11809. $data ['receiptMemu'] = 'paymentsCollect';
  11810. $data ['verifyId'] = $this->verifyId;
  11811. $data ['executeId'] = $this->executeId;
  11812. $this->render ( "/expenses/paymentsCollect", $data );
  11813. }
  11814. function paymentsCollectDay() {
  11815. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11816. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11817. if (empty ( $moth ))
  11818. return 'paymentsCollect';
  11819. Doo::loadModel ( "accountBookStatistics" );
  11820. $accountBookStatistics = new accountBookStatistics ();
  11821. $i = 2;
  11822. $y = 2013;
  11823. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11824. Doo::loadClass ( 'receipt.func' );
  11825. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11826. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11827. $data ['html'] = $html ['html'];
  11828. $data ['inSum'] = $html ['sum'];
  11829. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11830. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11831. $data ['payHtml'] = $html ['html'];
  11832. $data ['paySum'] = $html ['sum'];
  11833. $mothHtml = "";
  11834. for($i = 1; $i <= 12; $i ++) {
  11835. if ($moth == $i)
  11836. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11837. else
  11838. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11839. }
  11840. $data ['mothHtml'] = $mothHtml;
  11841. $data ['year'] = $year;
  11842. // 余额
  11843. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11844. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11845. include './protected/config/wasteBook.conf.php';
  11846. Doo::loadModel ( 'wasteBook' );
  11847. $wasteBook = new wasteBook ();
  11848. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11849. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11850. // 获得年份之前所有金额
  11851. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11852. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11853. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11854. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11855. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11856. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11857. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11858. // $balanceC = 0;
  11859. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11860. $limitDay = date ( 'd' );
  11861. $monthLK = ( int ) date ( 'm' );
  11862. if (date ( 'Y' ) > $year) {
  11863. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11864. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11865. $limitDay = 0;
  11866. }
  11867. for($i = 1; $i <= $day; $i ++) {
  11868. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11869. $inComeA = $payB = 0;
  11870. $falg = true;
  11871. foreach ( $inComePay as $key => $value ) {
  11872. if ($value ['day'] == $i) {
  11873. $falg = false;
  11874. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11875. $inSum += $value ['accountPrice'];
  11876. $showInSum += $value ['accountPriceShow'];
  11877. $inComeA = $value ['accountPrice'];
  11878. break;
  11879. }
  11880. }
  11881. if ($falg)
  11882. $inComeHtml .= '<td class="taR">-</td>';
  11883. $payFalg = true;
  11884. foreach ( $pay as $key => $value ) {
  11885. if ($value ['day'] == $i) {
  11886. $payFalg = false;
  11887. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11888. $paySum += $value ['accountPrice'];
  11889. $showPaySum += $value ['accountPriceShow'];
  11890. $payB = $value ['accountPrice'];
  11891. break;
  11892. }
  11893. }
  11894. if ($payFalg)
  11895. $payHtml .= '<td class="taR">-</td>';
  11896. if (empty ( $balanceC ) || $limitDay < $i)
  11897. $lastBalanceHtml .= '<td class="taR">-</td>';
  11898. else
  11899. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11900. $balanceC = $balanceC + $inComeA + $payB;
  11901. $balanceSum += $balanceC;
  11902. if (empty ( $balanceC ) || $limitDay < $i)
  11903. $BalanceHtml .= '<td class="taR">-</td>';
  11904. else
  11905. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11906. }
  11907. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11908. $data ['inComeHtml'] = $inComeHtml;
  11909. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11910. $data ['payBalanceHtml'] = $payHtml;
  11911. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11912. $data ['BalanceHtml'] = $BalanceHtml;
  11913. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11914. $data ['dayHtml'] = $dayHtml;
  11915. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11916. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11917. $dateHtml = "";
  11918. $now = date ( "Y" );
  11919. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11920. if ($YEARD <= $now) {
  11921. $dateHtml .= '<option ';
  11922. if ($year == $YEARD) {
  11923. $dateHtml .= 'selected ';
  11924. }
  11925. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11926. }
  11927. }
  11928. $data ['dateHtml'] = $dateHtml;
  11929. $data ['memu'] = "receipt";
  11930. $data ['staff'] = $this->staff;
  11931. $data ['receiptMemu'] = 'paymentsCollect';
  11932. $data ['verifyId'] = $this->verifyId;
  11933. $data ['executeId'] = $this->executeId;
  11934. $this->render ( "/expenses/paymentsCollectDay", $data );
  11935. }
  11936. // 公司流水
  11937. function wasteBook() {
  11938. Doo::loadModel ( "execute" );
  11939. $execute = new execute ();
  11940. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11941. die ( 'illegal request' );
  11942. }
  11943. include './protected/config/wasteBook.conf.php';
  11944. Doo::loadModel ( 'wasteBook' );
  11945. $wasteBook = new wasteBook ();
  11946. $data ['store']=$waste;
  11947. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11948. //print_r($waste);
  11949. //1-收入支出流水金额合计
  11950. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11951. //echo $waste['bank']['CGBDeposit'].'</br>';
  11952. //2020-07-20 -理财相关-面板数据
  11953. Doo::loadClass ( 'wasteBook.finances.func' );
  11954. $financesStatistics=$wasteBook->getFinancesStatistics();
  11955. //print_r($waste);
  11956. // 展示使用
  11957. // 收入
  11958. //print_r($inComeStatistics);
  11959. $wasteStatistics['CGBDeposit']=0;
  11960. $wasteStatistics['ICBCDeposit']=0;
  11961. $wasteStatistics['HUADeposit']=0;
  11962. $wasteStatistics['PersonalDeposit']=0;
  11963. foreach ($inComeStatistics['incomeStatistics'] as $value ){
  11964. if($value['accountBank']=='CGBDeposit'){
  11965. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11966. }
  11967. if($value['accountBank']=='ICBCDeposit'){
  11968. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11969. }
  11970. if($value['accountBank']=='HUADeposit'){
  11971. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11972. }
  11973. if($value['accountBank']=='PersonalDeposit'){
  11974. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11975. }
  11976. }
  11977. $data ['wasteStatistics']=$wasteStatistics;
  11978. //支出
  11979. $wasteStatistics['CGBDeposit']=0;
  11980. $wasteStatistics['ICBCDeposit']=0;
  11981. $wasteStatistics['HUADeposit']=0;
  11982. $wasteStatistics['PersonalDeposit']=0;
  11983. foreach ($inComeStatistics['expenditureStatistics'] as $value ){
  11984. if($value['accountBank']=='CGBDeposit'){
  11985. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  11986. }
  11987. if($value['accountBank']=='ICBCDeposit'){
  11988. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  11989. }
  11990. if($value['accountBank']=='HUADeposit'){
  11991. $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  11992. }
  11993. if($value['accountBank']=='PersonalDeposit'){
  11994. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  11995. }
  11996. }
  11997. $data ['wastePay']=$wasteStatistics;
  11998. //理财公司账号部分
  11999. $wasteStatistics['CGBDeposit']=0;
  12000. $wasteStatistics['ICBCDeposit']=0;
  12001. $wasteStatistics['HUADeposit']=0;
  12002. $wasteStatistics['PersonalDeposit']=0;
  12003. foreach ($financesStatistics['companyAccount'] as $value ){
  12004. //(纵横广发)广发存款
  12005. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12006. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12007. }
  12008. //工行存款
  12009. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12010. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12011. }
  12012. //个人存款
  12013. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12014. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12015. }
  12016. }
  12017. $data ['wasteCompanyAccount']=$wasteStatistics;
  12018. //理财部分的金额计算
  12019. $waste =_getFinancesWBS ( $waste, $financesStatistics );
  12020. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12021. //存款面板数据--日常收支改变后的金额汇总
  12022. $bankSavingsStatistics=$wasteBook->getBankSavingsStatistics();
  12023. $waste =_getBankSavingsWBS ( $waste, $bankSavingsStatistics );
  12024. //展示调试BUG-使用
  12025. //print_r($bankSavingsStatistics);
  12026. $wasteStatistics['CGBDeposit']=0;
  12027. $wasteStatistics['ICBCDeposit']=0;
  12028. $wasteStatistics['PersonalDeposit']=0;
  12029. foreach ($bankSavingsStatistics as $value ){
  12030. //(纵横广发)广发存款
  12031. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12032. $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12033. }
  12034. //工行存款
  12035. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12036. $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12037. }
  12038. //个人存款
  12039. if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12040. $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12041. }
  12042. }
  12043. $data ['wasteNewPay']=$wasteStatistics;
  12044. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12045. //
  12046. $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'];
  12047. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12048. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12049. // print_r($waste);
  12050. $data ['total'] = number_format($total,2);
  12051. $data ['CGBDeposit_total'] = number_format($CGBDeposit_total,2);
  12052. $cashBalance=$CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12053. $data['cashBalance']= number_format($cashBalance,2);
  12054. $waste ['bank'] ['CGBDeposit']=sprintf("%.2f", round($waste ['bank'] ['CGBDeposit'], 2));
  12055. $data ['waste'] = $waste;
  12056. // 月流水数据结构
  12057. $monthStatistics = array ();
  12058. $incomeMothStatistics = array ();
  12059. $expenditureMothStatistics = array ();
  12060. for($i = 1; $i <= 12; $i ++) {
  12061. $month = date ( 'Y' ) . '-' . $i;
  12062. if ($i < 10)
  12063. $month = date ( 'Y' ) . '-0' . $i;
  12064. array_push ( $monthStatistics, $month );
  12065. }
  12066. foreach ( $monthStatistics as $value ) {
  12067. $falg = true;
  12068. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12069. if ($value == $v ['inputDate']) {
  12070. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12071. $falg = false;
  12072. }
  12073. }
  12074. if ($falg) {
  12075. array_push ( $incomeMothStatistics, '' );
  12076. }
  12077. $falgEx = true;
  12078. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12079. if ($value == $v ['inputDate']) {
  12080. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12081. $falg = false;
  12082. }
  12083. }
  12084. if ($falgEx) {
  12085. array_push ( $expenditureMothStatistics, '' );
  12086. }
  12087. }
  12088. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12089. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12090. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12091. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12092. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12093. // print_r($incomeList);
  12094. $data ['expenditureList'] = $expenditureList;
  12095. $data ['incomeList'] = $incomeList;
  12096. $data ['memu'] = "receipt";
  12097. $data ['staff'] = $this->staff;
  12098. $data ['receiptMemu'] = 'wasteBook';
  12099. $data ['verifyId'] = $this->verifyId;
  12100. $data ['executeId'] = $this->executeId;
  12101. $this->render ( "/expenses/wasteBook", $data );
  12102. }
  12103. function wasteBookIncome() {
  12104. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12105. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12106. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12107. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12108. $data ['dailyIncomeType'] = $dailyIncomeType;
  12109. Doo::loadModel ( 'wasteBook' );
  12110. $wasteBook = new wasteBook ();
  12111. Doo::loadModel ( 'L_category' );
  12112. $L_category = new L_category ();
  12113. Doo::loadClass ( 'XDeode' );
  12114. $XDeode = new XDeode ( 5 );
  12115. $year=date("Y");
  12116. $theDay=date("Y-m-d");
  12117. $dateArr = explode ( ':', $date );
  12118. $D1 = '';
  12119. $D2 = '';
  12120. $con = '';
  12121. if (! empty ( $date )) {
  12122. $D1 = $dateArr [0];
  12123. $D2 = $dateArr [1];
  12124. }
  12125. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12126. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12127. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12128. $con = ' and inputDate = "' . $D1 . '"';
  12129. else{
  12130. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12131. }
  12132. if ($cid != 'ALL') {
  12133. $cid = $XDeode->decode ( $cid );
  12134. $con .= ' and cid = "' . $cid . '"';
  12135. }
  12136. if ($accountType != 'ALL') {
  12137. if ($accountType == 'INVOICE') {
  12138. $con .= ' and (accountType = 7 or accountType = 8)';
  12139. } elseif ($accountType == 'PAYMENTS') {
  12140. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12141. if ($dailyIncomeType != 'ALL') {
  12142. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12143. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12144. }
  12145. }
  12146. }
  12147. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12148. foreach ($incomeList as $key=>$value){
  12149. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12150. $wasteBook = new wasteBook ();
  12151. $wasteBook->wid = $value['wid'];
  12152. $wasteBook->synPaymentDate = 1;
  12153. $wasteBook->inputDate = $value['data']['receivedDate'];
  12154. $wasteBook->update();
  12155. }
  12156. }
  12157. $sum = 0;$thsDaySum=0;
  12158. foreach ( $incomeList as $key => $value ) {
  12159. $sum += $value ['accountPrice'];
  12160. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12161. $thsDaySum+=$value ['accountPrice'];
  12162. }
  12163. }
  12164. // print_r($incomeList);
  12165. // 获得办事和部门
  12166. $categoryList = $L_category->getCategory ();
  12167. $data ['accountType'] = $accountType;
  12168. $data ['cid'] = $cid;
  12169. $data ['categoryList'] = $categoryList;
  12170. $data ['sum'] = $sum;
  12171. $data ['incomeList'] = $incomeList;
  12172. $data ['inputDate'] = $date;
  12173. $data['year']=$year;
  12174. $data ['thsDay'] =$theDay;
  12175. $data ['thsDaySum'] =$thsDaySum;
  12176. $data ['memu'] = "receipt";
  12177. $data ['staff'] = $this->staff;
  12178. $data ['receiptMemu'] = 'wasteBook';
  12179. $data ['verifyId'] = $this->verifyId;
  12180. $data ['executeId'] = $this->executeId;
  12181. $this->render ( "/expenses/wasteBookIncome", $data );
  12182. }
  12183. /**
  12184. * 所有支出
  12185. */
  12186. function wasteBookExpenditure() {
  12187. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12188. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12189. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12190. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12191. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12192. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12193. $data ['receiptType'] = $receiptType;
  12194. Doo::loadModel ( 'wasteBook' );
  12195. $wasteBook = new wasteBook ();
  12196. Doo::loadModel ( 'L_category' );
  12197. $L_category = new L_category ();
  12198. Doo::loadClass ( 'XDeode' );
  12199. $XDeode = new XDeode ( 5 );
  12200. $year=date("Y");
  12201. $theDay=date("Y-m-d");
  12202. $dateArr = explode ( ':', $date );
  12203. $D1 = '';
  12204. $D2 = '';
  12205. $con = '';
  12206. if (! empty ( $date )) {
  12207. $D1 = $dateArr [0];
  12208. $D2 = $dateArr [1];
  12209. }
  12210. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12211. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12212. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12213. $con = ' and inputDate = "' . $D1 . '"';
  12214. else{
  12215. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12216. }
  12217. if ($cid != 'ALL') {
  12218. $cid = $XDeode->decode ( $cid );
  12219. $con .= ' and cid = "' . $cid . '"';
  12220. }
  12221. if ($accountType != 'ALL') {
  12222. if ($accountType == 'INVOICE') {
  12223. $con .= ' and accountType = 11';
  12224. } elseif ($accountType == 'PAYMENTS') {
  12225. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12226. if ($dailyExpenditureType != 'ALL') {
  12227. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12228. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12229. }
  12230. } elseif ($accountType == 'RECEIPT') {
  12231. if ($receiptType == 'ALL') {
  12232. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12233. } else {
  12234. $receiptType = $XDeode->decode ( $receiptType );
  12235. echo $receiptType;
  12236. if ($receiptType == 1) {
  12237. $con .= ' and (accountType = 1 or accountType=2)';
  12238. } else {
  12239. $con .= ' and accountType = ' . $receiptType;
  12240. }
  12241. }
  12242. }
  12243. }
  12244. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12245. foreach ($incomeList as $key=>$value){
  12246. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12247. $wasteBook = new wasteBook ();
  12248. $wasteBook->wid = $value['wid'];
  12249. $wasteBook->synPaymentDate = 1;
  12250. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12251. $wasteBook->update();
  12252. }
  12253. }
  12254. $sum = 0;$thsDaySum=0;
  12255. foreach ( $incomeList as $key => $value ) {
  12256. $sum += $value ['accountPriceShow'];
  12257. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12258. $thsDaySum+=$value ['accountPriceShow'];
  12259. }
  12260. }
  12261. // print_r($incomeList);
  12262. // 获得办事和部门
  12263. $categoryList = $L_category->getCategory ();
  12264. $data ['accountType'] = $accountType;
  12265. $data ['cid'] = $cid;
  12266. $data ['categoryList'] = $categoryList;
  12267. $data ['sum'] = $sum;
  12268. $data ['incomeList'] = $incomeList;
  12269. $data ['inputDate'] = $date;
  12270. $data['year']=$year;
  12271. $data ['thsDay'] =$theDay;
  12272. $data ['thsDaySum'] =$thsDaySum;
  12273. $data ['memu'] = "receipt";
  12274. $data ['staff'] = $this->staff;
  12275. $data ['receiptMemu'] = 'wasteBook';
  12276. $data ['verifyId'] = $this->verifyId;
  12277. $data ['executeId'] = $this->executeId;
  12278. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12279. }
  12280. function ajaxGetWasteinvoiceReceivables() {
  12281. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12282. Doo::loadClass ( 'XDeode' );
  12283. $XDeode = new XDeode ( 5 );
  12284. $irid = $XDeode->decode ( $serial );
  12285. Doo::loadModel ( 'invoiceReceivables' );
  12286. $invoiceReceivables = new invoiceReceivables ();
  12287. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12288. echo json_encode ( array (
  12289. 'status' => 1,
  12290. 'detail' => $detail
  12291. ) );
  12292. }
  12293. function ajaxGetPaymentsByAid() {
  12294. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12295. Doo::loadModel ( "accountBook" );
  12296. $accountBook = new accountBook ();
  12297. $detail = $accountBook->getAccountBookByAid ( $serial );
  12298. echo json_encode ( array (
  12299. 'status' => 1,
  12300. 'detail' => $detail
  12301. ) );
  12302. }
  12303. function ajaxGetWasteInvoice() {
  12304. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12305. Doo::loadModel ( 'invoice' );
  12306. $invoice = new invoice ();
  12307. Doo::loadModel ( 'invoiceReceivables' );
  12308. $invoiceReceivables = new invoiceReceivables ();
  12309. $detail = $invoice->getInvoiceByIid ( $serial );
  12310. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12311. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12312. echo json_encode ( array (
  12313. 'status' => 1,
  12314. 'detail' => $detail
  12315. ) );
  12316. }
  12317. /**
  12318. */
  12319. function ajaxGetWasteReceipt() {
  12320. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12321. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12322. Doo::loadModel ( 'receipt' );
  12323. $receipt = new receipt ();
  12324. Doo::loadClass ( 'XDeode' );
  12325. $XDeode = new XDeode ( 5 );
  12326. $rid = $XDeode->decode ( $serial );
  12327. $accountType= $XDeode->decode ( $accountTypeKey );
  12328. // 获得个数据
  12329. $detail = $receipt->getReceiptByRid ( $rid );
  12330. // 初始化
  12331. $detail ['reviseDetail'] = array ();
  12332. if (! empty ( $value ['reviseDetail'] ))
  12333. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12334. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12335. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12336. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12337. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12338. // 获得费用html
  12339. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12340. // 获得费用审批人数据
  12341. $detail = $this->getReceiptApproverHtml ( $detail );
  12342. // 审批执行
  12343. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12344. <th class="taC" width="90">审批人</th>
  12345. <th class="taC">审批意见</th></tr>';
  12346. foreach ( $detail ['verifyList'] as $key => $value ) {
  12347. $html .= '<tr>
  12348. <td>' . $value [1] . '</td>
  12349. <td>' . $value ['opinion'] . '</td>
  12350. </tr>
  12351. ';
  12352. }
  12353. $html .= ' </tbody></table>';
  12354. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12355. <th class="taC" width="90">执行人</th>
  12356. <th class="taC">执行意见</th></tr>';
  12357. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12358. $html .= '<tr>
  12359. <td>' . $value [1] . '</td>
  12360. <td>' . $value ['opinion'] . '</td>
  12361. </tr>
  12362. ';
  12363. }
  12364. $html .= ' </tbody></table>';
  12365. if($accountType==1){
  12366. Doo::loadModel ( 'loanReceipt' );
  12367. $loanReceipt = new loanReceipt ();
  12368. $loanList = $loanReceipt->getOne ( array (
  12369. 'where' => 'rid=' . $detail ['loanRid'],
  12370. 'desc' => 'rid',
  12371. 'asArray' => true
  12372. ) );
  12373. $html .= '<table class="table table-bordered table-condensed">
  12374. <tr class="warning">
  12375. <td class="taR"><b>汇款金额</b></td>
  12376. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12377. </tr>
  12378. </table>';
  12379. }else{
  12380. $html .= '<table class="table table-bordered table-condensed">
  12381. <tr class="warning">
  12382. <td class="taR"><b>汇款金额</b></td>
  12383. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12384. </tr>
  12385. </table>';
  12386. }
  12387. // print_r($detail['verifyList']);
  12388. // header ( 'Content-Type:text/html;charset=utf-8' );
  12389. // echo $html;
  12390. echo json_encode ( array (
  12391. 'status' => 1,
  12392. 'html' => $html,
  12393. 'detail' => $detail
  12394. ) );
  12395. }
  12396. function getReceiptApproverHtml($detail = array()) {
  12397. Doo::loadModel ( 'loanReceipt' );
  12398. $loanReceipt = new loanReceipt ();
  12399. Doo::loadModel ( 'verify' );
  12400. $verify = new verify ();
  12401. Doo::loadModel ( 'staff' );
  12402. $staff = new staff ();
  12403. if (empty ( $detail ))
  12404. return array ();
  12405. $loanList = $loanReceipt->getOne ( array (
  12406. 'where' => 'rid=' . $detail ['loanRid'],
  12407. 'desc' => 'rid',
  12408. 'asArray' => true
  12409. ) );
  12410. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12411. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12412. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12413. else
  12414. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12415. } else
  12416. $verifyList = $verify->getOne ( array (
  12417. 'where' => 'vid=' . $detail ['verify'],
  12418. 'asArray' => true
  12419. ) );
  12420. $verifyList = json_decode ( $verifyList ['staff'], true );
  12421. Doo::loadModel ( 'role' );
  12422. $role = new role ();
  12423. $roleId = 0;
  12424. $flag = true;
  12425. $roleKey = 0;
  12426. $endStaffArray = array ();
  12427. $roleArrayCopy = array ();
  12428. foreach ( $verifyList as $k => $v ) {
  12429. // init verifyStaff
  12430. if ($v [1] == 'ROLE') {
  12431. if (! empty ( $verifyStaff )) {
  12432. $endStaffArray = end ( $verifyStaff );
  12433. }
  12434. $roleVerify = json_decode ( $v [3], true );
  12435. $roleKey = $k;
  12436. $roleArray = array ();
  12437. $rolename = $role->getOne ( array (
  12438. 'where' => 'rid=' . $v [0],
  12439. 'asArray' => true
  12440. ) );
  12441. foreach ( $roleVerify as $o => $p ) {
  12442. $staffID = explode ( '_', $p );
  12443. $staffInfo = $staff->getOne ( array (
  12444. 'where' => 'sid=' . $staffID [0],
  12445. 'asArray' => true
  12446. ) );
  12447. // print_r($staffID);
  12448. $exp = array (
  12449. 0 => $staffInfo ['sid'],
  12450. 1 => $staffID [1],
  12451. 2 => $staffInfo ['avatar'],
  12452. 'date' => '',
  12453. 'date' => '',
  12454. 'opinion' => '',
  12455. 'status' => '',
  12456. 'rolename' => $rolename ['name']
  12457. );
  12458. array_push ( $roleArray, $exp );
  12459. }
  12460. $roleArrayCopy [$v [0]] = $roleArray;
  12461. // $verifyList[$k]['roleArray']=$roleArray;
  12462. }
  12463. $verifyList [$k] ['date'] = "";
  12464. $verifyList [$k] ['opinion'] = "";
  12465. $verifyList [$k] ['status'] = "";
  12466. if (empty ( $verifyStaff )) {
  12467. $verifyList [$k] ['date'] = "";
  12468. $verifyList [$k] ['opinion'] = "";
  12469. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12470. $verifyList [$k] ['status'] = 4;
  12471. $flag = false;
  12472. }
  12473. } else {
  12474. foreach ( $verifyStaff as $m => $u ) {
  12475. if ($v [0] == $m) {
  12476. $verifyList [$k] ['date'] = $u ['date'];
  12477. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12478. $verifyList [$k] ['status'] = $u ['status'];
  12479. $flag = false;
  12480. break;
  12481. }
  12482. }
  12483. $endStaffArray = end ( $verifyStaff );
  12484. }
  12485. }
  12486. $rolename ['name'] = '';
  12487. if (! empty ( $roleId )) {
  12488. Doo::loadModel ( 'role' );
  12489. $role = new role ();
  12490. $rolename = $role->getOne ( array (
  12491. 'where' => 'rid=' . $roleId,
  12492. 'asArray' => true
  12493. ) );
  12494. }
  12495. if (! empty ( $verifyStaff ))
  12496. $endStaffArray = end ( $verifyStaff );
  12497. $KOP = false;
  12498. foreach ( $roleArrayCopy as $P => $A ) {
  12499. foreach ( $A as $MKI => $AVL ) {
  12500. if (! empty ( $verifyStaff )) {
  12501. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12502. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12503. $button = 4;
  12504. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12505. }
  12506. foreach ( $verifyStaff as $m => $u ) {
  12507. $AVLFK = $AVL [0] . '_R';
  12508. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12509. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12510. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12511. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12512. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12513. break;
  12514. }
  12515. }
  12516. } else {
  12517. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12518. $button = 4;
  12519. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12520. }
  12521. }
  12522. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12523. $KOP = true;
  12524. }
  12525. }
  12526. foreach ( $roleArrayCopy as $k => $v ) {
  12527. foreach ( $verifyList as $m => $n ) {
  12528. if ($n [0] == $k) {
  12529. array_splice ( $verifyList, $m, 1, $v );
  12530. }
  12531. }
  12532. }
  12533. // 费用执行人相关数据
  12534. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12535. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12536. foreach ( $executeCopy as $k => $v ) {
  12537. $executeCopy [$k] ['date'] = '';
  12538. $executeCopy [$k] ['opinion'] = '';
  12539. $executeCopy [$k] ['status'] = '';
  12540. if (! empty ( $executeStaff ))
  12541. foreach ( $executeStaff as $m => $u ) {
  12542. if ($v [0] == $m) {
  12543. $executeCopy [$k] ['date'] = $u ['date'];
  12544. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12545. $executeCopy [$k] ['status'] = $u ['status'];
  12546. break;
  12547. }
  12548. }
  12549. }
  12550. $detail ['executeCopy'] = $executeCopy;
  12551. $detail ['verifyList'] = $verifyList;
  12552. return $detail;
  12553. }
  12554. //获得新版报销单费用说明
  12555. private function getReceiptVerson1Explanation($value){
  12556. $version_1_explanation="";
  12557. if($value['version']==1){
  12558. if(!empty($value['officeJson'])){
  12559. $officeJson=json_decode($value['officeJson'],true);
  12560. $version_1_explanation.=$officeJson['officeExplain'][0]['officeExplain']."\n";
  12561. }
  12562. if(!empty($value['traveJson'])){
  12563. $traveJson=json_decode($value['traveJson'],true);
  12564. $version_1_explanation.=$traveJson['traveExplain'][0]['traveExplain']."\n";
  12565. }
  12566. if(!empty($value['trainJson'])){
  12567. $trainJson=json_decode($value['trainJson'],true);
  12568. $version_1_explanation.=$trainJson['trainExplain'][0]['trainExplain']."\n";
  12569. }
  12570. }
  12571. return $version_1_explanation;
  12572. }
  12573. //获得新版报销单 详情HTML
  12574. private function getReceiptVerson1Html($detail){
  12575. $html='<table class="table table-bordered table-condensed">
  12576. <tbody>';
  12577. if($detail['version']==1){
  12578. if(!empty($detail['officeJson'])){
  12579. $officeJson=json_decode($detail['officeJson'],true);
  12580. $html .= '
  12581. <tr>
  12582. <th colspan="2" class="taC">日常相关费用</th>
  12583. </tr>';
  12584. // 日常相关费用
  12585. $total=0;
  12586. foreach ( $officeJson['daily'] as $key => $value ) {
  12587. if(!empty($value['price'])){
  12588. $html .= '
  12589. <tr>
  12590. <th>' . $value ['name'] . '</th>
  12591. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12592. </tr>';
  12593. $total=bcadd($total,$value ['price'],2);
  12594. }
  12595. }
  12596. $html .= '
  12597. <tr>
  12598. <th class="taR">合计</th>
  12599. <td class="colGreen taR">¥' .$total . '</td>
  12600. </tr>';
  12601. // 其他
  12602. $html .= '<tr>
  12603. <th colspan="2" class="taC">其他</th>
  12604. </tr>';
  12605. $total=0;
  12606. foreach ( $officeJson['other'] as $key => $value ) {
  12607. if(!empty($value['price'])){
  12608. $html .= '
  12609. <tr>
  12610. <th>' . $value ['name'] . '</th>
  12611. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12612. </tr>';
  12613. $total=bcadd($total,$value ['price'],2);
  12614. }
  12615. }
  12616. $html .= '
  12617. <tr>
  12618. <th class="taR">合计</th>
  12619. <td class="colGreen taR">¥' . $total . '</td>
  12620. </tr>';
  12621. }
  12622. if(!empty($detail['traveJson'])){
  12623. $traveJson=json_decode($detail['traveJson'],true);
  12624. // 差旅
  12625. $html .= '<tr>
  12626. <th colspan="2" class="taC">差旅相关费用</th>
  12627. </tr>';
  12628. $total=0;
  12629. foreach ( $traveJson['trave'] as $key => $value ) {
  12630. if(!empty($value['price'])){
  12631. $html .= '
  12632. <tr>
  12633. <th>' . $value ['name'] . '</th>
  12634. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12635. </tr>';
  12636. $total=bcadd($total,$value ['price'],2);
  12637. }
  12638. }
  12639. $html .= '
  12640. <tr>
  12641. <th class="taR">合计</th>
  12642. <td class="colGreen taR">¥' . $total . '</td>
  12643. </tr>';
  12644. }
  12645. if(!empty($detail['trainJson'])){
  12646. $trainJson=json_decode($detail['trainJson'],true);
  12647. // 内部培训费用
  12648. $html .= '<tr>
  12649. <th colspan="2" class="taC">内部培训费用</th>
  12650. </tr>';
  12651. $total=0;
  12652. foreach ( $trainJson['train'] as $key => $value ) {
  12653. if(!empty($value['price'])){
  12654. $html .= '
  12655. <tr>
  12656. <th>' . $value ['name'] . '</th>
  12657. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12658. </tr>';
  12659. $total=bcadd($total,$value ['price'],2);
  12660. }
  12661. }
  12662. $html .= '
  12663. <tr>
  12664. <th class="taR">合计</th>
  12665. <td class="colGreen taR">¥' . $total . '</td>
  12666. </tr>';
  12667. }
  12668. }
  12669. return $html;
  12670. }
  12671. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12672. if (empty ( $detail ))
  12673. return '';
  12674. $html = '';
  12675. // die;
  12676. if ($detail ['Rtype'] == 0) { // 报销单
  12677. if($detail ['version']==1){
  12678. $html .= $this->getReceiptVerson1Html($detail);
  12679. }else{
  12680. $html .= '<table class="table table-bordered table-condensed">
  12681. <tbody>
  12682. <tr>
  12683. <th colspan="2" class="taC">日常相关费用</th>
  12684. </tr>';
  12685. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12686. $html .= '
  12687. <tr>
  12688. <th>' . $value ['name'] . '</th>
  12689. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12690. </tr>';
  12691. }
  12692. $html .= '
  12693. <tr>
  12694. <th class="taR">合计</th>
  12695. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12696. </tr>';
  12697. $html .= '<tr>
  12698. <th colspan="2" class="taC">差旅相关费用</th>
  12699. </tr>';
  12700. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12701. $html .= '
  12702. <tr>
  12703. <th>' . $value ['name'] . '</th>
  12704. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12705. </tr>';
  12706. }
  12707. $html .= '
  12708. <tr>
  12709. <th class="taR">合计</th>
  12710. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12711. </tr>';
  12712. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12713. $html .= '<tr>
  12714. <th colspan="2" class="taC">内部培训费用</th>
  12715. </tr>';
  12716. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12717. $html .= '
  12718. <tr>
  12719. <th>' . $value ['name'] . '</th>
  12720. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12721. </tr>';
  12722. }
  12723. $html .= '
  12724. <tr>
  12725. <th class="taR">合计</th>
  12726. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12727. </tr>';
  12728. }
  12729. $html .= '<tr>
  12730. <th colspan="2" class="taC">其他</th>
  12731. </tr>';
  12732. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12733. $html .= '
  12734. <tr>
  12735. <th>' . $value ['name'] . '</th>
  12736. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12737. </tr>';
  12738. }
  12739. $html .= '
  12740. <tr>
  12741. <th class="taR">合计</th>
  12742. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12743. </tr>';
  12744. }
  12745. $html .= '<tr>
  12746. <th colspan="2" class="taC">报销金额调整</th>
  12747. </tr>';
  12748. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12749. $html .= '
  12750. <tr>
  12751. <th>' . $value ['name'] . '</th>
  12752. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12753. </tr>';
  12754. }
  12755. $html .= '
  12756. <tr>
  12757. <th class="taR">合计</th>
  12758. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12759. </tr>';
  12760. $html .= '
  12761. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12762. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12763. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12764. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12765. <tr class="warning">
  12766. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12767. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12768. </tr>
  12769. </tbody>
  12770. </table>';
  12771. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12772. $html .= '
  12773. <table class="table table-bordered table-condensed">
  12774. <tbody>
  12775. <tr>
  12776. <th colspan="2" class="taC">办事处相关费用</th>
  12777. </tr>';
  12778. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12779. $html .= '
  12780. <tr>
  12781. <th>' . $value ['name'] . '</th>
  12782. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12783. </tr>';
  12784. }
  12785. $html .= '
  12786. <tr>
  12787. <th class="taR">合计</th>
  12788. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12789. </tr>';
  12790. $html .= '
  12791. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12792. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12793. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12794. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12795. <tr class="warning">
  12796. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12797. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12798. </tr>
  12799. </tbody>
  12800. </table>';
  12801. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12802. Doo::loadModel ( 'loanReceipt' );
  12803. $loanReceipt = new loanReceipt ();
  12804. $loanList = $loanReceipt->getOne ( array (
  12805. 'where' => 'rid=' . $detail ['loanRid'],
  12806. 'desc' => 'rid',
  12807. 'asArray' => true
  12808. ) );
  12809. // print_r($loanList);
  12810. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12811. $html .= '<table class="table table-bordered table-condensed">
  12812. <tbody>
  12813. <tr>
  12814. <th colspan="2" class="taC">借款费用</th>
  12815. </tr>';
  12816. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12817. $html .= '<tr>
  12818. <th>' . $value ['name'] . '</th>
  12819. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12820. </tr>';
  12821. }
  12822. $html .= '<tr>
  12823. <th class="taC" colspan="2">产生费用所在办事处</th>
  12824. </tr>
  12825. <tr>
  12826. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12827. </tr>
  12828. <tr>
  12829. <th class="taC" colspan="2">费用说明</th>
  12830. </tr>
  12831. <tr>
  12832. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12833. </tr>
  12834. <tr class="warning">
  12835. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12836. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12837. </tr>
  12838. </tbody>
  12839. </table>
  12840. ';
  12841. if ( $accountType==2) {
  12842. $balance=$detail ['sum']-$loanList ['sum'];
  12843. $balanceCN=$this->num_to_rmb($balance);
  12844. if($detail ['version']==1){
  12845. $html .= $this->getReceiptVerson1Html($detail);
  12846. }else{
  12847. $html .= '<table class="table table-bordered table-condensed">
  12848. <tbody>
  12849. <tr>
  12850. <th colspan="2" class="taC">日常相关费用</th>
  12851. </tr>';
  12852. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12853. $html .= '
  12854. <tr>
  12855. <th>' . $value ['name'] . '</th>
  12856. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12857. </tr>';
  12858. }
  12859. $html .= '
  12860. <tr>
  12861. <th class="taR">合计</th>
  12862. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12863. </tr>';
  12864. $html .= '<tr>
  12865. <th colspan="2" class="taC">差旅相关费用</th>
  12866. </tr>';
  12867. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12868. $html .= '
  12869. <tr>
  12870. <th>' . $value ['name'] . '</th>
  12871. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12872. </tr>';
  12873. }
  12874. $html .= '
  12875. <tr>
  12876. <th class="taR">合计</th>
  12877. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12878. </tr>';
  12879. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12880. $html .= '<tr>
  12881. <th colspan="2" class="taC">内部培训费用</th>
  12882. </tr>';
  12883. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12884. $html .= '
  12885. <tr>
  12886. <th>' . $value ['name'] . '</th>
  12887. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12888. </tr>';
  12889. }
  12890. $html .= '
  12891. <tr>
  12892. <th class="taR">合计</th>
  12893. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12894. </tr>';
  12895. }
  12896. $html .= '<tr>
  12897. <th colspan="2" class="taC">其他</th>
  12898. </tr>';
  12899. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12900. $html .= '
  12901. <tr>
  12902. <th>' . $value ['name'] . '</th>
  12903. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12904. </tr>';
  12905. }
  12906. $html .= '
  12907. <tr>
  12908. <th class="taR">合计</th>
  12909. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12910. </tr>';
  12911. }
  12912. $html .= '<tr>
  12913. <th colspan="2" class="taC">报销金额调整</th>
  12914. </tr>';
  12915. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12916. $html .= '
  12917. <tr>
  12918. <th>' . $value ['name'] . '</th>
  12919. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12920. </tr>';
  12921. }
  12922. $html .= '
  12923. <tr>
  12924. <th class="taR">合计</th>
  12925. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12926. </tr>';
  12927. $html .= '
  12928. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12929. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12930. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12931. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12932. <tr class="warning">
  12933. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12934. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12935. </tr>
  12936. <tr class="success">
  12937. <td class="taR"><b>借款结余</b></td>
  12938. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12939. </tr>
  12940. </tbody>
  12941. </table>';
  12942. }
  12943. }
  12944. return $html;
  12945. }
  12946. /**
  12947. * 计算流水
  12948. */
  12949. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12950. $bakWaste ['bank'] = array (
  12951. 'CGBDeposit' => 0,
  12952. 'ICBCDeposit' => 0,
  12953. 'HUADeposit' => 0,
  12954. 'PersonalDeposit' => 0
  12955. );
  12956. $bakWaste ['financial'] = array (
  12957. 'current' => array (
  12958. 'CGBDeposit' => 0,
  12959. 'ICBCDeposit' => 0
  12960. ),
  12961. 'fixed' => array (
  12962. 'CGBDeposit' => 0,
  12963. 'ICBCDeposit' => 0
  12964. )
  12965. );
  12966. // 存款
  12967. foreach ( $waste ['bank'] as $key => $value ) {
  12968. // 收入
  12969. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12970. // 广发
  12971. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12972. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12973. }
  12974. // 工商
  12975. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12976. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12977. }
  12978. // 华润
  12979. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12980. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12981. }
  12982. // 个人
  12983. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12984. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12985. }
  12986. }
  12987. }
  12988. foreach ( $waste ['bank'] as $key => $value ) {
  12989. // 支出
  12990. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12991. // 广发
  12992. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12993. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12994. }
  12995. // 工商
  12996. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12997. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12998. }
  12999. // 华润
  13000. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13001. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13002. }
  13003. // 个人
  13004. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13005. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13006. }
  13007. }
  13008. }
  13009. // 活期
  13010. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13011. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13012. // 广发
  13013. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13014. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13015. }
  13016. // 工商
  13017. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13018. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13019. }
  13020. // 个人
  13021. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13022. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13023. }
  13024. }
  13025. }
  13026. // print_r($inComeStatistics ['fixedStatistics']);
  13027. // 固期
  13028. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13029. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13030. // 广发
  13031. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13032. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13033. }
  13034. // 工商---已经转变成个人理财固定代表含义
  13035. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13036. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13037. }
  13038. // 个人
  13039. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13040. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13041. }
  13042. }
  13043. }
  13044. $waste ['bank'] ['ICBCDeposit'] = sprintf("%.2f", $waste ['bank'] ['ICBCDeposit']);
  13045. return $waste;
  13046. }
  13047. function lyt() {
  13048. Doo::loadModel ( "receiptDetail" );
  13049. $receiptDetail = new receiptDetail ();
  13050. $receiptCollectList = $receiptDetail->find ( array (
  13051. 'where' => 'status=1 ',
  13052. 'asArray' => true
  13053. ) );
  13054. foreach ( $receiptCollectList as $key => $value ) {
  13055. $receiptDetail = new receiptDetail ();
  13056. $receiptDetail->pastDate = $value ['date'];
  13057. $receiptDetail->update ( array (
  13058. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13059. ) );
  13060. }
  13061. }
  13062. function staffCollectMonthDetail() {
  13063. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13064. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13065. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13066. if (! $year)
  13067. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13068. if (! $month)
  13069. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13070. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13071. if (! $nature){
  13072. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13073. }
  13074. Doo::loadModel ( 'staff' );
  13075. $staff = new staff ();
  13076. Doo::loadModel ( "receiptDetail" );
  13077. $receiptDetail = new receiptDetail ();
  13078. Doo::loadModel ( 'accountItem' );
  13079. $accountItem = new accountItem ();
  13080. Doo::loadModel ( 'statistics' );
  13081. $statistics = new statistics ();
  13082. Doo::loadModel ( "receiptAuthorityManage" );
  13083. $receiptAuthorityManage = new receiptAuthorityManage ();
  13084. $aiList=$accountItem->getAccountItem();
  13085. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13086. $cidList = array ();
  13087. foreach ( $imcStaff as $key => $value ) {
  13088. array_push ( $cidList, $value ['cid'] );
  13089. }
  13090. $cidString = implode ( ',', $cidList );
  13091. $naturecon='';
  13092. if ($nature=='ONJOB'){
  13093. $naturecon=' and (nature!=4 )';
  13094. }elseif($nature=='LEAVEJOB'){
  13095. $naturecon=' and (nature=4 )';
  13096. }else{
  13097. die ( 'illegal request--nature' );
  13098. }
  13099. $staffList = $staff->find ( array (
  13100. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13101. 'asArray' => true
  13102. ) );
  13103. $categoryList = $staff->find ( array (
  13104. 'select' => 'COUNT(*) as count,cid,category',
  13105. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13106. 'groupby' => 'cid',
  13107. 'asArray' => true
  13108. ) );
  13109. $list = array ();
  13110. foreach($aiList as $key=>$value){
  13111. foreach ($value as $v){
  13112. $subtotal[$key][$v['name']]=0;
  13113. }
  13114. }
  13115. foreach ( $categoryList as $vlu ) {
  13116. $s1 = 0;
  13117. $m1 = 0;
  13118. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13119. foreach ( $staffList as $value ) {
  13120. if ($vlu ['cid'] == $value ['cid']) {
  13121. // pastDate
  13122. $receiptCollectList = $receiptDetail->find ( array (
  13123. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13124. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13125. 'groupby' => 'item,Month(pastDate),itemCategory',
  13126. 'asArray' => true
  13127. ) );
  13128. if (! empty ( $receiptCollectList )) {
  13129. $receiptL = array (
  13130. '日常相关费用' => array (),
  13131. '差旅相关费用' => array (),
  13132. '内部培训费用' => array (),
  13133. '培训班费用' => array (),
  13134. '其他' => array ()
  13135. );
  13136. $html = "";
  13137. $psum = 0;
  13138. foreach ( $aiList[$this->AGENCY] as $va ) {
  13139. $falg = true;
  13140. foreach ( $receiptCollectList as $v ) {
  13141. if ($v ['itemCategory'] == '日常相关费用') {
  13142. if ($v ['item'] == $va['name']) {
  13143. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13144. $psum += $v ['price'];
  13145. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13146. $falg = false;
  13147. break;
  13148. }
  13149. }
  13150. }
  13151. if ($falg)
  13152. $html .= '<td class="taR">-</td>';
  13153. }
  13154. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13155. if (! empty ( $psum ))
  13156. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13157. else
  13158. $psum = '<td class="colGreen taR">-</td>';
  13159. $receiptL ['日常相关费用'] = $psum . $html;
  13160. /* ----------------------------------- */
  13161. $html = "";
  13162. $psum = 0;
  13163. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13164. $falg = true;
  13165. foreach ( $receiptCollectList as $v ) {
  13166. if ($v ['itemCategory'] == '差旅相关费用') {
  13167. if ($v ['item'] == $va['name']) {
  13168. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13169. $psum += $v ['price'];
  13170. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13171. $falg = false;
  13172. break;
  13173. }
  13174. }
  13175. }
  13176. if ($falg)
  13177. $html .= '<td class="taR">-</td>';
  13178. }
  13179. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13180. if (! empty ( $psum ))
  13181. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13182. else
  13183. $psum = '<td class="colGreen taR">-</td>';
  13184. $receiptL ['差旅相关费用'] = $psum . $html;
  13185. /* ------------------------------------- */
  13186. $html = "";
  13187. $psum = 0;
  13188. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13189. $falg = true;
  13190. foreach ( $receiptCollectList as $v ) {
  13191. if ($v ['itemCategory'] == '内部培训费用') {
  13192. if ($v ['item'] == $va['name']) {
  13193. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13194. $psum += $v ['price'];
  13195. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13196. $falg = false;
  13197. break;
  13198. }
  13199. }
  13200. }
  13201. if ($falg)
  13202. $html .= '<td class="taR">-</td>';
  13203. }
  13204. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13205. if (! empty ( $psum ))
  13206. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13207. else
  13208. $psum = '<td class="colGreen taR">-</td>';
  13209. $receiptL ['内部培训费用'] = $psum . $html;
  13210. /* ----------------------------------- */
  13211. $html = "";
  13212. $psum = 0;
  13213. foreach ( $aiList[$this->TRAIN] as $va ) {
  13214. $falg = true;
  13215. foreach ( $receiptCollectList as $v ) {
  13216. if ($v ['itemCategory'] == '培训班费用') {
  13217. if ($v ['item'] == $va['name']) {
  13218. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13219. $psum += $v ['price'];
  13220. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13221. $falg = false;
  13222. break;
  13223. }
  13224. }
  13225. }
  13226. if ($falg)
  13227. $html .= '<td class="taR">-</td>';
  13228. }
  13229. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13230. if (! empty ( $psum ))
  13231. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13232. else
  13233. $psum = '<td class="colGreen taR">-</td>';
  13234. $receiptL ['培训班费用'] = $psum . $html;
  13235. /* ------------------------------------- */
  13236. $html = "";
  13237. $psum = 0;
  13238. foreach ( $aiList[$this->OTHER] as $va ) {
  13239. $falg = true;
  13240. foreach ( $receiptCollectList as $v ) {
  13241. if ($v ['itemCategory'] == '其他') {
  13242. if (trim ( $v ['item'] ) == $va['name']) {
  13243. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13244. $psum += $v ['price'];
  13245. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13246. $falg = false;
  13247. break;
  13248. }
  13249. }
  13250. }
  13251. if ($falg)
  13252. $html .= '<td class="taR">-</td>';
  13253. }
  13254. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13255. if (! empty ( $psum ))
  13256. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13257. else
  13258. $psum = '<td class="colGreen taR">-</td>';
  13259. $receiptL ['其他'] = $psum . $html;
  13260. /* ------------------------------------- */
  13261. $html = "";
  13262. $psum = 0;
  13263. foreach ( $receiptCollectList as $v ) {
  13264. if ($v ['itemCategory'] == '报销金额调整') {
  13265. if (! empty ( $v ['price'] )) {
  13266. $psum += $v ['price'];
  13267. }
  13268. }
  13269. }
  13270. $s1 += $psum;
  13271. if (! empty ( $psum ))
  13272. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13273. else
  13274. $psum = '<td class="taR colOrange">-</td>';
  13275. $receiptL ['报销金额调整'] = $psum . $html;
  13276. } else {
  13277. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13278. foreach ( $aiList[$this->AGENCY] as $va ) {
  13279. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13280. }
  13281. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13282. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13283. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13284. }
  13285. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13286. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13287. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13288. }
  13289. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13290. foreach ( $aiList[$this->TRAIN] as $va ) {
  13291. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13292. }
  13293. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13294. foreach ( $aiList[$this->OTHER] as $va ) {
  13295. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13296. }
  13297. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13298. }
  13299. $monthStaffPrice = $receiptDetail->find ( array (
  13300. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13301. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13302. 'groupby' => 'Month(pastDate)',
  13303. 'asArray' => true
  13304. ) );
  13305. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13306. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13307. $m1 += $monthStaffPrice [0] ['price'];
  13308. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13309. } else
  13310. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13311. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13312. $list [$value ['username']] = $receiptL;
  13313. }
  13314. }
  13315. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13316. foreach ( $aiList[$this->AGENCY] as $va ) {
  13317. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13318. $subtotal[$this->AGENCY][$va['name']]=0;
  13319. }
  13320. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13321. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13322. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13323. $subtotal[$this->TRAVEL][$va['name']]=0;
  13324. }
  13325. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13326. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13327. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13328. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13329. }
  13330. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13331. foreach ( $aiList[$this->TRAIN] as $va ) {
  13332. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13333. $subtotal[$this->TRAIN][$va['name']]=0;
  13334. }
  13335. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13336. foreach ( $aiList[$this->OTHER] as $va ) {
  13337. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13338. $subtotal[$this->OTHER][$va['name']]=0;
  13339. }
  13340. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13341. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13342. $receiptL ['usernameEn'] =false;
  13343. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13344. }
  13345. $data ['list'] = $list;
  13346. // print_r($list);
  13347. $receiptCollectList = $receiptDetail->find ( array (
  13348. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13349. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13350. 'groupby' => 'item,Month(pastDate),itemCategory',
  13351. 'asArray' => true
  13352. ) );
  13353. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13354. // statistics html
  13355. $stList = $statistics->getOne ( array (
  13356. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13357. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13358. 'groupby' => 'Month(date)',
  13359. 'asArray' => true
  13360. ) );
  13361. if (empty ( $stList ))
  13362. $stList = array (
  13363. 'rePrice' => 0,
  13364. 'agPrice' => 0
  13365. );
  13366. $data ['stList'] = array (
  13367. 'rePrice' => $stList ['rePrice'],
  13368. 'agPrice' => $stList ['agPrice'],
  13369. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13370. );
  13371. $monthHtml = "";
  13372. for($i = 1; $i <= 12; $i ++) {
  13373. if ($i == $month)
  13374. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13375. else
  13376. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13377. }
  13378. $data ['monthHtml'] = $monthHtml;
  13379. $data ['year'] = $year;
  13380. $data ['month'] = $month;
  13381. $data ['nature'] = $nature;
  13382. $data ['aiList'] = $aiList;
  13383. $data ['memu'] = "receipt";
  13384. $data ['staff'] = $this->staff;
  13385. $data ['receiptMemu'] = 'companyCategoryCollect';
  13386. $data ['verifyId'] = $this->verifyId;
  13387. $data ['executeId'] = $this->executeId;
  13388. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13389. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13390. }
  13391. function staffCollectMonthDetail2() {
  13392. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13393. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13394. if (! $year)
  13395. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13396. if (! $month)
  13397. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13398. Doo::loadModel ( 'staff' );
  13399. $staff = new staff ();
  13400. Doo::loadModel ( "receiptDetail" );
  13401. $receiptDetail = new receiptDetail ();
  13402. Doo::loadModel ( 'accountItem' );
  13403. $accountItem = new accountItem ();
  13404. Doo::loadModel ( 'statistics' );
  13405. $statistics = new statistics ();
  13406. Doo::loadModel ( 'L_category' );
  13407. $lCategory = new L_category ();
  13408. $staffList = $staff->find ( array (
  13409. 'where' => 'username!="admin"',
  13410. 'asArray' => true
  13411. ) );
  13412. $categoryList = $staff->find ( array (
  13413. 'select' => 'COUNT(*) as count,cid,category',
  13414. 'where' => 'username !="admin"',
  13415. 'groupby' => 'cid',
  13416. 'asArray' => true
  13417. ) );
  13418. $list = array ();
  13419. foreach ( $categoryList as $vlu ) {
  13420. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13421. $r1 = 0;
  13422. $r2 = 0;
  13423. $r3 = 0;
  13424. $r4 = 0;
  13425. $r5 = 0;
  13426. $r6 = 0;
  13427. $r7 = 0;
  13428. $r8 = 0;
  13429. $r9 = 0;
  13430. $r10 = 0;
  13431. $r11 = 0;
  13432. $r12 = 0;
  13433. $r13 = 0;
  13434. $r14 = 0;
  13435. $r15 = 0;
  13436. $c1 = 0;
  13437. $c2 = 0;
  13438. $c3 = 0;
  13439. $c4 = 0;
  13440. $c5 = 0;
  13441. $c6 = 0;
  13442. $p1 = 0;
  13443. $p2 = 0;
  13444. $p3 = 0;
  13445. $p4 = 0;
  13446. $p5 = 0;
  13447. $p6 = 0;
  13448. $p7 = 0;
  13449. $p8 = 0;
  13450. $p9 = 0;
  13451. $t1 = 0;
  13452. $t2 = 0;
  13453. $t3 = 0;
  13454. $t4 = 0;
  13455. $t5 = 0;
  13456. $s1 = 0;
  13457. $m1 = 0;
  13458. foreach ( $staffList as $value ) {
  13459. if ($vlu ['cid'] == $value ['cid']) {
  13460. $receiptCollectList = $receiptDetail->find ( array (
  13461. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13462. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13463. 'groupby' => 'item,Month(date),itemCategory',
  13464. 'asArray' => true
  13465. ) );
  13466. if (! empty ( $receiptCollectList )) {
  13467. $receiptL = array (
  13468. '日常相关费用' => array (),
  13469. '差旅相关费用' => array (),
  13470. '培训班费用' => array (),
  13471. '其他' => array ()
  13472. );
  13473. $html = "";
  13474. $psum = 0;
  13475. $item = array (
  13476. '市内交通费',
  13477. '市内出租费',
  13478. '办事处房租',
  13479. '电话费',
  13480. '水费',
  13481. '电费',
  13482. '办公费用',
  13483. '邮寄费',
  13484. '其他费用',
  13485. '车辆费用',
  13486. '广告费',
  13487. '团队建设费',
  13488. '物业管理费',
  13489. '宽带费'
  13490. );
  13491. foreach ( $item as $va ) {
  13492. $falg = true;
  13493. foreach ( $receiptCollectList as $v ) {
  13494. if ($v ['itemCategory'] == '日常相关费用') {
  13495. if ($v ['item'] == $va) {
  13496. if ($va == '市内交通费')
  13497. $r1 += $v ['price'];
  13498. if ($va == '市内出租费')
  13499. $r2 += $v ['price'];
  13500. if ($va == '办事处房租')
  13501. $r3 += $v ['price'];
  13502. if ($va == '电话费')
  13503. $r4 += $v ['price'];
  13504. if ($va == '水费')
  13505. $r5 += $v ['price'];
  13506. if ($va == '电费')
  13507. $r6 += $v ['price'];
  13508. if ($va == '办公费用')
  13509. $r7 += $v ['price'];
  13510. if ($va == '邮寄费')
  13511. $r8 += $v ['price'];
  13512. if ($va == '其他费用')
  13513. $r9 += $v ['price'];
  13514. if ($va == '车辆费用')
  13515. $r10 += $v ['price'];
  13516. if ($va == '广告费')
  13517. $r11 += $v ['price'];
  13518. if ($va == '团队建设费')
  13519. $r13 += $v ['price'];
  13520. if ($va == '物业管理费')
  13521. $r14 += $v ['price'];
  13522. if ($va == '宽带费')
  13523. $r15 += $v ['price'];
  13524. $psum += $v ['price'];
  13525. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13526. $falg = false;
  13527. break;
  13528. }
  13529. }
  13530. }
  13531. if ($falg)
  13532. $html .= '<td class="taR">-</td>';
  13533. }
  13534. $r12 += $psum;
  13535. if (! empty ( $psum ))
  13536. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13537. else
  13538. $psum = '<td class="colGreen taR">-</td>';
  13539. $receiptL ['日常相关费用'] = $psum . $html;
  13540. /* ----------------------------------- */
  13541. $html = "";
  13542. $psum = 0;
  13543. $item = array (
  13544. '往来交通费',
  13545. '市内交通费',
  13546. '出差住宿费',
  13547. '出差补助',
  13548. '其他费用'
  13549. );
  13550. foreach ( $item as $va ) {
  13551. $falg = true;
  13552. foreach ( $receiptCollectList as $v ) {
  13553. if ($v ['itemCategory'] == '差旅相关费用') {
  13554. if ($v ['item'] == $va) {
  13555. if ($va == '往来交通费')
  13556. $c1 += $v ['price'];
  13557. if ($va == '市内交通费')
  13558. $c2 += $v ['price'];
  13559. if ($va == '出差住宿费')
  13560. $c3 += $v ['price'];
  13561. if ($va == '出差补助')
  13562. $c4 += $v ['price'];
  13563. if ($va == '其他费用')
  13564. $c5 += $v ['price'];
  13565. $psum += $v ['price'];
  13566. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13567. $falg = false;
  13568. break;
  13569. }
  13570. }
  13571. }
  13572. if ($falg)
  13573. $html .= '<td class="taR">-</td>';
  13574. }
  13575. $c6 += $psum;
  13576. if (! empty ( $psum ))
  13577. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13578. else
  13579. $psum = '<td class="colGreen taR">-</td>';
  13580. $receiptL ['差旅相关费用'] = $psum . $html;
  13581. /* ------------------------------------- */
  13582. $html = "";
  13583. $psum = 0;
  13584. $item = array (
  13585. '场租费',
  13586. '薪酬',
  13587. '住宿费',
  13588. '交通费',
  13589. '餐饮费',
  13590. '办公费',
  13591. '公关费',
  13592. '其他'
  13593. );
  13594. foreach ( $item as $va ) {
  13595. $falg = true;
  13596. foreach ( $receiptCollectList as $v ) {
  13597. if ($v ['itemCategory'] == '培训班费用') {
  13598. if ($v ['item'] == $va) {
  13599. if ($va == '场租费')
  13600. $p1 += $v ['price'];
  13601. if ($va == '薪酬')
  13602. $p2 += $v ['price'];
  13603. if ($va == '住宿费')
  13604. $p3 += $v ['price'];
  13605. if ($va == '交通费')
  13606. $p4 += $v ['price'];
  13607. if ($va == '餐饮费')
  13608. $p5 += $v ['price'];
  13609. if ($va == '办公费')
  13610. $p6 += $v ['price'];
  13611. if ($va == '公关费')
  13612. $p7 += $v ['price'];
  13613. if ($va == '其他')
  13614. $p8 += $v ['price'];
  13615. $psum += $v ['price'];
  13616. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13617. $falg = false;
  13618. break;
  13619. }
  13620. }
  13621. }
  13622. if ($falg)
  13623. $html .= '<td class="taR">-</td>';
  13624. }
  13625. $p9 += $psum;
  13626. if (! empty ( $psum ))
  13627. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13628. else
  13629. $psum = '<td class="colGreen taR">-</td>';
  13630. $receiptL ['培训班费用'] = $psum . $html;
  13631. /* ------------------------------------- */
  13632. $html = "";
  13633. $psum = 0;
  13634. $item = array (
  13635. '公关费',
  13636. '广告费',
  13637. '借款',
  13638. '可自加费用'
  13639. );
  13640. foreach ( $item as $va ) {
  13641. $falg = true;
  13642. foreach ( $receiptCollectList as $v ) {
  13643. if ($v ['itemCategory'] == '其他') {
  13644. if ($v ['item'] == $va) {
  13645. if ($va == '公关费')
  13646. $t1 += $v ['price'];
  13647. if ($va == '广告费')
  13648. $t2 += $v ['price'];
  13649. if ($va == '借款')
  13650. $t3 += $v ['price'];
  13651. if ($va == '可自加费用')
  13652. $t4 += $v ['price'];
  13653. $psum += $v ['price'];
  13654. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13655. $falg = false;
  13656. break;
  13657. }
  13658. }
  13659. }
  13660. if ($falg)
  13661. $html .= '<td class="taR">-</td>';
  13662. }
  13663. $t5 += $psum;
  13664. if (! empty ( $psum ))
  13665. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13666. else
  13667. $psum = '<td class="colGreen taR">-</td>';
  13668. $receiptL ['其他'] = $psum . $html;
  13669. /* ------------------------------------- */
  13670. $html = "";
  13671. $psum = 0;
  13672. foreach ( $receiptCollectList as $v ) {
  13673. if ($v ['itemCategory'] == '报销金额调整') {
  13674. if (! empty ( $v ['price'] )) {
  13675. $psum += $v ['price'];
  13676. }
  13677. }
  13678. }
  13679. $s1 += $psum;
  13680. if (! empty ( $psum ))
  13681. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13682. else
  13683. $psum = '<td class="taR colOrange">-</td>';
  13684. $receiptL ['报销金额调整'] = $psum . $html;
  13685. } else {
  13686. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13687. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13688. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13689. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13690. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13691. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13692. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13693. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13694. }
  13695. $monthStaffPrice = $receiptDetail->find ( array (
  13696. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13697. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13698. 'asArray' => true
  13699. ) );
  13700. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13701. $m1 += $monthStaffPrice [0] ['price'];
  13702. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13703. } else
  13704. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13705. $list [$value ['username']] = $receiptL;
  13706. }
  13707. }
  13708. $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>
  13709. <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>
  13710. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13711. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13712. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13713. $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>
  13714. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13715. $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>';
  13716. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13717. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13718. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13719. }
  13720. $data ['list'] = $list;
  13721. $receiptCollectList = $receiptDetail->find ( array (
  13722. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13723. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13724. 'groupby' => 'item,Month(date),itemCategory',
  13725. 'asArray' => true
  13726. ) );
  13727. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13728. // statistics html
  13729. $stList = $statistics->getOne ( array (
  13730. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13731. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13732. 'groupby' => 'Month(date)',
  13733. 'asArray' => true
  13734. ) );
  13735. if (empty ( $stList ))
  13736. $stList = array (
  13737. 'rePrice' => 0,
  13738. 'agPrice' => 0
  13739. );
  13740. $data ['stList'] = array (
  13741. 'rePrice' => $stList ['rePrice'],
  13742. 'agPrice' => $stList ['agPrice'],
  13743. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13744. );
  13745. $monthHtml = "";
  13746. for($i = 1; $i <= 12; $i ++) {
  13747. if ($i == $month)
  13748. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13749. else
  13750. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13751. }
  13752. $data ['monthHtml'] = $monthHtml;
  13753. $data ['year'] = $year;
  13754. $data ['month'] = $month;
  13755. $data ['memu'] = "receipt";
  13756. $data ['staff'] = $this->staff;
  13757. $data ['receiptMemu'] = 'companyCategoryCollect';
  13758. $data ['verifyId'] = $this->verifyId;
  13759. $data ['executeId'] = $this->executeId;
  13760. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13761. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13762. }
  13763. /**
  13764. * 用户报销单列表
  13765. */
  13766. function receiptStatisticsStaffDetail() {
  13767. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13768. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13769. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13770. Doo::loadModel ( "receipt" );
  13771. $receipt = new receipt ();
  13772. Doo::loadModel ( "receiptDetail" );
  13773. $receiptDetail = new receiptDetail ();
  13774. Doo::loadModel ( 'staff' );
  13775. $staff = new staff ();
  13776. Doo::loadModel ( 'accountItem' );
  13777. $accountItem = new accountItem ();
  13778. Doo::loadModel ( 'statistics' );
  13779. $statistics = new statistics ();
  13780. if (! empty ( $username )) {
  13781. $username = addslashes ( urldecode ( $username ) );
  13782. $staffDetail = $staff->getStaffByName ( $username );
  13783. if (empty ( $staffDetail ))
  13784. die ( 'illegal request' );
  13785. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13786. $itemList = $accountItem->getAccountItem ();
  13787. $itemHtml = '';
  13788. $categoryHtml = '';
  13789. $itemKeyList = array_keys ( $itemList );
  13790. $revisePrice = 0;
  13791. // 报销单内容详情
  13792. foreach ( $list as $key => $value ) {
  13793. $accountItemList = json_decode ( $value ['accountItem'], true );
  13794. $list [$key] ['accountItemList'] = $accountItemList;
  13795. $receiptItemHtml = '';
  13796. foreach ( $itemKeyList as $v ) {
  13797. if ($v == '日常相关费用')
  13798. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13799. elseif ($v == '差旅相关费用')
  13800. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13801. elseif ($v == '培训班费用')
  13802. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13803. elseif ($v == '内部培训费用'){
  13804. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13805. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13806. }else{
  13807. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13808. }
  13809. }elseif ($v == '其他')
  13810. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13811. foreach ( $itemList [$v] as $ke => $va ) {
  13812. $falg = true;
  13813. if (! empty ( $accountItemList [$v] )) {
  13814. foreach ( $accountItemList [$v] as $ve ) {
  13815. if ($va ['name'] == $ve ['name']) {
  13816. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13817. $falg = false;
  13818. break;
  13819. }
  13820. }
  13821. }
  13822. if ($falg)
  13823. $receiptItemHtml .= '<td class="taR"></td>';
  13824. }
  13825. }
  13826. // 金额调整和费用查看
  13827. $revisePrice += $value ['revisePrice'];
  13828. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13829. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13830. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13831. }
  13832. // 报销单合计
  13833. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13834. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13835. $receiptTotalHtml = '';
  13836. // 报销单项目抬头
  13837. foreach ( $itemKeyList as $value ) {
  13838. $count = count ( $itemList [$value] ) + 1;
  13839. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13840. $categoryHtml .= '<th class="taC">合计</th>';
  13841. $sumfalg=true;
  13842. foreach ( $rtl as $rtlValue ) {
  13843. if ($rtlValue ['itemCategory'] == $value) {
  13844. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13845. $sumfalg=false;
  13846. break;
  13847. }
  13848. }
  13849. if ($sumfalg)
  13850. $receiptTotalHtml .= '<th></th>';
  13851. foreach ( $itemList [$value] as $k => $v ) {
  13852. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13853. // 合计
  13854. $falg = true;
  13855. foreach ( $receiptTotalList as $ve ) {
  13856. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13857. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13858. $falg = false;
  13859. break;
  13860. }
  13861. }
  13862. if ($falg)
  13863. $receiptTotalHtml .= '<th></th>';
  13864. }
  13865. }
  13866. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13867. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13868. if (empty ( $stList ))
  13869. $stList = array (
  13870. 'rePrice' => 0,
  13871. 'agPrice' => 0
  13872. );
  13873. $data ['stList'] = array (
  13874. 'rePrice' => $stList ['rePrice'],
  13875. 'agPrice' => $stList ['agPrice'],
  13876. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13877. );
  13878. $monthHtml = "";
  13879. for($i = 1; $i <= 12; $i ++) {
  13880. if ($i == $month)
  13881. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13882. else
  13883. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13884. }
  13885. $data ['username'] = urlencode ( $username );
  13886. $data ['usernameEN'] = $username;
  13887. $data ['monthHtml'] = $monthHtml;
  13888. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13889. $data ['list'] = $list;
  13890. $data ['categoryHtml'] = $categoryHtml;
  13891. $data ['itemHtml'] = $itemHtml;
  13892. $data ['itemList'] = $itemList;
  13893. $data ['year'] = $year;
  13894. $data ['month'] = $month;
  13895. $data ['memu'] = "receipt";
  13896. $data ['staff'] = $this->staff;
  13897. $data ['receiptMemu'] = 'companyCategoryCollect';
  13898. $data ['verifyId'] = $this->verifyId;
  13899. $data ['executeId'] = $this->executeId;
  13900. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13901. }
  13902. die ( 'illegal request' );
  13903. }
  13904. function companyMonthCollectDetail() {
  13905. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13906. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13907. if (! $year)
  13908. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13909. if (! $month)
  13910. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13911. Doo::loadModel ( 'staff' );
  13912. $staff = new staff ();
  13913. Doo::loadModel ( "receiptDetail" );
  13914. $receiptDetail = new receiptDetail ();
  13915. Doo::loadModel ( 'accountItem' );
  13916. $accountItem = new accountItem ();
  13917. Doo::loadModel ( 'statistics' );
  13918. $statistics = new statistics ();
  13919. Doo::loadModel ( 'L_category' );
  13920. $lCategory = new L_category ();
  13921. $staffList = $staff->find ( array (
  13922. 'where' => 'username!="admin"',
  13923. 'asArray' => true
  13924. ) );
  13925. $categoryList = $lCategory->find ( array (
  13926. 'asArray' => true
  13927. ) );
  13928. $aiList=$accountItem->getAccountItem();
  13929. $list = array ();
  13930. foreach ( $categoryList as $value ) {
  13931. $receiptCollectList = $receiptDetail->find ( array (
  13932. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13933. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13934. 'groupby' => 'item,Month(pastDate),itemCategory',
  13935. 'asArray' => true
  13936. ) );
  13937. if (! empty ( $receiptCollectList )) {
  13938. $receiptL = array (
  13939. '日常相关费用' => array (),
  13940. '差旅相关费用' => array (),
  13941. '内部培训费用' => array (),
  13942. '培训班费用' => array (),
  13943. '其他' => array ()
  13944. );
  13945. $html = "";
  13946. $psum = 0;
  13947. foreach ( $aiList[$this->AGENCY] as $va ) {
  13948. $falg = true;
  13949. foreach ( $receiptCollectList as $v ) {
  13950. if ($v ['itemCategory'] == $this->AGENCY) {
  13951. if ($v ['item'] == $va['name']) {
  13952. $psum += $v ['price'];
  13953. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13954. $falg = false;
  13955. break;
  13956. }
  13957. }
  13958. }
  13959. if ($falg)
  13960. $html .= '<td class="taR">-</td>';
  13961. }
  13962. if (! empty ( $psum ))
  13963. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13964. else
  13965. $psum = '<td class="colGreen taR">-</td>';
  13966. $receiptL [$this->AGENCY] = $psum . $html;
  13967. /* ----------------------------------- */
  13968. $html = "";
  13969. $psum = 0;
  13970. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13971. $falg = true;
  13972. foreach ( $receiptCollectList as $v ) {
  13973. if ($v ['itemCategory'] == $this->TRAVEL) {
  13974. if ($v ['item'] == $va['name']) {
  13975. $psum += $v ['price'];
  13976. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13977. $falg = false;
  13978. break;
  13979. }
  13980. }
  13981. }
  13982. if ($falg)
  13983. $html .= '<td class="taR">-</td>';
  13984. }
  13985. if (! empty ( $psum ))
  13986. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13987. else
  13988. $psum = '<td class="colGreen taR">-</td>';
  13989. $receiptL [$this->TRAVEL] = $psum . $html;
  13990. /* ------------------------------------- */
  13991. $html = "";
  13992. $psum = 0;
  13993. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13994. $falg = true;
  13995. foreach ( $receiptCollectList as $v ) {
  13996. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13997. if ($v ['item'] == $va['name']) {
  13998. $psum += $v ['price'];
  13999. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14000. $falg = false;
  14001. break;
  14002. }
  14003. }
  14004. }
  14005. if ($falg)
  14006. $html .= '<td class="taR">-</td>';
  14007. }
  14008. if (! empty ( $psum ))
  14009. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14010. else
  14011. $psum = '<td class="colGreen taR">-</td>';
  14012. $receiptL [$this->INTTRAIN] = $psum . $html;
  14013. /* ------------------------------------- */
  14014. $html = "";
  14015. $psum = 0;
  14016. foreach ( $aiList[$this->TRAIN] as $va ) {
  14017. $falg = true;
  14018. foreach ( $receiptCollectList as $v ) {
  14019. if ($v ['itemCategory'] == $this->TRAIN) {
  14020. if ($v ['item'] == $va['name']) {
  14021. $psum += $v ['price'];
  14022. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14023. $falg = false;
  14024. break;
  14025. }
  14026. }
  14027. }
  14028. if ($falg)
  14029. $html .= '<td class="taR">-</td>';
  14030. }
  14031. if (! empty ( $psum ))
  14032. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14033. else
  14034. $psum = '<td class="colGreen taR">-</td>';
  14035. $receiptL [$this->TRAIN] = $psum . $html;
  14036. /* ------------------------------------- */
  14037. $html = "";
  14038. $psum = 0;
  14039. foreach ( $aiList[$this->OTHER] as $va ) {
  14040. $falg = true;
  14041. foreach ( $receiptCollectList as $v ) {
  14042. if ($v ['itemCategory'] == $this->OTHER) {
  14043. if ($v ['item'] == $va['name']) {
  14044. $psum += $v ['price'];
  14045. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14046. $falg = false;
  14047. break;
  14048. }
  14049. }
  14050. }
  14051. if ($falg)
  14052. $html .= '<td class="taR">-</td>';
  14053. }
  14054. if (! empty ( $psum ))
  14055. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14056. else
  14057. $psum = '<td class="colGreen taR">-</td>';
  14058. $receiptL [$this->OTHER] = $psum . $html;
  14059. /* ------------------------------------- */
  14060. $html = "";
  14061. $psum = 0;
  14062. foreach ( $receiptCollectList as $v ) {
  14063. if ($v ['itemCategory'] == '报销金额调整') {
  14064. if (! empty ( $v ['price'] ))
  14065. $psum += $v ['price'];
  14066. }
  14067. }
  14068. if (! empty ( $psum ))
  14069. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14070. else
  14071. $psum = '<td class="taR colOrange">-</td>';
  14072. $receiptL ['报销金额调整'] = $psum . $html;
  14073. } else {
  14074. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14075. foreach ( $aiList[$this->AGENCY] as $va ) {
  14076. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14077. }
  14078. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14079. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14080. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14081. }
  14082. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14083. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14084. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14085. }
  14086. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14087. foreach ( $aiList[$this->TRAIN] as $va ) {
  14088. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14089. }
  14090. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14091. foreach ( $aiList[$this->OTHER] as $va ) {
  14092. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14093. }
  14094. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14095. }
  14096. $monthStaffPrice = $receiptDetail->find ( array (
  14097. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14098. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14099. 'asArray' => true
  14100. ) );
  14101. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14102. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14103. else
  14104. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14105. $list [$value ['title']] = $receiptL;
  14106. }
  14107. $data ['list'] = $list;
  14108. $receiptCollectList = $receiptDetail->find ( array (
  14109. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14110. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14111. 'groupby' => 'item,Month(pastDate),itemCategory',
  14112. 'asArray' => true
  14113. ) );
  14114. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14115. //print_r($data['monthPriceHtml']);
  14116. // foreach ($data['monthPriceHtml'] as $value){
  14117. // echo $value;
  14118. // }
  14119. // die;
  14120. // statistics html
  14121. $stList = $statistics->getOne ( array (
  14122. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14123. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14124. 'groupby' => 'Month(date)',
  14125. 'asArray' => true
  14126. ) );
  14127. if (empty ( $stList ))
  14128. $stList = array (
  14129. 'rePrice' => 0,
  14130. 'agPrice' => 0
  14131. );
  14132. $data ['stList'] = array (
  14133. 'rePrice' => $stList ['rePrice'],
  14134. 'agPrice' => $stList ['agPrice'],
  14135. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14136. );
  14137. $monthHtml = "";
  14138. for($i = 1; $i <= 12; $i ++) {
  14139. if ($i == $month)
  14140. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14141. else
  14142. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14143. }
  14144. $data ['aiList'] = $aiList;
  14145. $dateHtml = "";
  14146. $now = date ( "Y" );
  14147. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14148. if ($YEARD <= $now) {
  14149. $dateHtml .= '<option ';
  14150. if ($year == $YEARD) {
  14151. $dateHtml .= 'selected ';
  14152. }
  14153. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14154. }
  14155. }
  14156. $data ['dateHtml'] = $dateHtml;
  14157. $data ['monthHtml'] = $monthHtml;
  14158. $data ['year'] = $year;
  14159. $data ['month'] = $month;
  14160. $data ['memu'] = "receipt";
  14161. $data ['staff'] = $this->staff;
  14162. $data ['receiptMemu'] = 'companyCategoryCollect';
  14163. $data ['verifyId'] = $this->verifyId;
  14164. $data ['executeId'] = $this->executeId;
  14165. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14166. }
  14167. function staffCollectDetail() {
  14168. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14169. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14170. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14171. if (! $staffname) {
  14172. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14173. $staffname = urldecode ( $staffname );
  14174. }
  14175. Doo::loadModel ( 'staff' );
  14176. $staff = new staff ();
  14177. Doo::loadModel ( "receiptDetail" );
  14178. $receiptDetail = new receiptDetail ();
  14179. Doo::loadModel ( 'accountItem' );
  14180. $accountItem = new accountItem ();
  14181. Doo::loadModel ( 'statistics' );
  14182. $statistics = new statistics ();
  14183. Doo::loadModel ( 'L_category' );
  14184. $lCategory = new L_category ();
  14185. Doo::loadModel ( "receiptAuthorityManage" );
  14186. $receiptAuthorityManage = new receiptAuthorityManage ();
  14187. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14188. $cidList = array ();
  14189. foreach ( $imcStaff as $key => $value ) {
  14190. array_push ( $cidList, $value ['cid'] );
  14191. }
  14192. $cidString = implode ( ',', $cidList );
  14193. $staffList = $staff->find ( array (
  14194. 'where' => ' cid in (' . $cidString . ')',
  14195. 'asArray' => true
  14196. ) );
  14197. $stHtml = '';
  14198. $stTitle = "";
  14199. $staffId = 0;
  14200. $cid = 0;
  14201. $ocid = 0;
  14202. foreach ( $staffList as $value ) {
  14203. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14204. $stTitle = $value ['category'] . '-' . $value ['username'];
  14205. $staffId = $value ['sid'];
  14206. $cid = $value ['cid'];
  14207. $ocid = $value ['cid'];
  14208. if (! empty ( $value ['othercid'] ))
  14209. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14210. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14211. } elseif ($value ['username'] != 'admin')
  14212. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14213. }
  14214. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14215. 'where' => 'cid in(' . $cid . ')',
  14216. 'asArray' => true
  14217. ) );
  14218. if (empty ( $pcid ))
  14219. $pcid = $ocid;
  14220. $data ['ocid'] = $pcid;
  14221. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14222. $this->showCache ( $path );
  14223. //
  14224. $receiptCollectList = $receiptDetail->find ( array (
  14225. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14226. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14227. 'groupby' => 'item,Month(pastDate),itemCategory',
  14228. 'asArray' => true
  14229. ) );
  14230. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14231. // print_r($receiptCollectList);
  14232. $accountList = $accountItem->find ( array (
  14233. 'asArray' => true
  14234. ) );
  14235. // create CollectDetail HTML
  14236. $collectHtml = array ();
  14237. foreach ( $accountList as $key => $value ) {
  14238. $html = "";
  14239. $asum = 0;
  14240. for($i = 1; $i <= 12; $i ++) {
  14241. $falg = true;
  14242. foreach ( $receiptCollectList as $v ) {
  14243. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14244. if ($v ['item'] == '可自加费用') {
  14245. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14246. }
  14247. $asum += $v ['price'];
  14248. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14249. $falg = false;
  14250. break;
  14251. }
  14252. }
  14253. if ($falg)
  14254. $html .= '<td class="taR">-</td>';
  14255. }
  14256. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14257. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14258. }
  14259. $data ['collectHtml'] = $collectHtml;
  14260. // print_r($collectHtml);
  14261. // create Adjustment price html
  14262. $receiptCollectList = $receiptDetail->find ( array (
  14263. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14264. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14265. 'groupby' => 'itemCategory,Month(pastDate)',
  14266. 'asArray' => true
  14267. ) );
  14268. $adjustment = array ();
  14269. $collectArray = array (
  14270. '日常相关费用' => array (),
  14271. '差旅相关费用' => array (),
  14272. '培训班费用' => array (),
  14273. '内部培训费用'=>array(),
  14274. '其他' => array ()
  14275. );
  14276. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14277. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14278. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14279. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14280. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14281. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14282. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14283. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14284. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14285. array_push ( $collectArray ['其他'], $collectHtml );
  14286. $data ['collectArray'] = $collectArray;
  14287. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14288. array_push ( $adjustment, $collectHtml );
  14289. $data ['adjustment'] = $adjustment;
  14290. // total price html
  14291. $collectHtml = "";
  14292. $total = 0;
  14293. for($i = 1; $i <= 12; $i ++) {
  14294. $sumPrice = 0;
  14295. foreach ( $receiptCollectList as $key => $value ) {
  14296. if ($value ['month'] == $i) {
  14297. $sumPrice += $value ['price'];
  14298. }
  14299. }
  14300. if ($sumPrice == 0)
  14301. $collectHtml .= '<td class="taR">-</td>';
  14302. else
  14303. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14304. $total += $sumPrice;
  14305. }
  14306. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14307. // statistics html
  14308. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14309. if (empty ( $stList ))
  14310. $stList = array (
  14311. 'rePrice' => 0,
  14312. 'agPrice' => 0
  14313. );
  14314. $data ['stList'] = array (
  14315. 'rePrice' => $stList ['rePrice'],
  14316. 'agPrice' => $stList ['agPrice'],
  14317. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14318. );
  14319. $data ['totalPrice'] = $collectHtml;
  14320. $data ['totalYear'] = $total;
  14321. $data ['stHtml'] = $stHtml;
  14322. $data ['year'] = $year;
  14323. $data ['stTitle'] = $stTitle;
  14324. $data ['staffname'] = urlencode ( $staffname );
  14325. $data ['memu'] = "receipt";
  14326. $data ['staff'] = $this->staff;
  14327. $data ['receiptMemu'] = 'companyCategoryCollect';
  14328. $data ['verifyId'] = $this->verifyId;
  14329. $data ['executeId'] = $this->executeId;
  14330. if ($year < date ( "Y" )) {
  14331. Doo::loadModel ( 'receipt' );
  14332. $receipt = new receipt ();
  14333. $receiptList = $receipt->find ( array (
  14334. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14335. 'asArray' => true
  14336. ) );
  14337. if (empty ( $receiptList )) { // generated files
  14338. ob_start ();
  14339. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14340. $this->cacheFile ( $path );
  14341. die ();
  14342. }
  14343. }
  14344. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14345. }
  14346. function BUGFLAG() {
  14347. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14348. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14349. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14350. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14351. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14352. if (empty ( $status ))
  14353. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14354. $page_size = 12;
  14355. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14356. $vidList = array ();
  14357. $button = 0;
  14358. Doo::loadModel ( 'verify' );
  14359. $verify = new verify ();
  14360. Doo::loadModel ( 'receipt' );
  14361. $receipt = new receipt ();
  14362. Doo::loadModel ( 'staff' );
  14363. $staff = new staff ();
  14364. Doo::loadModel ( 'L_category' );
  14365. $Lcategory = new L_category ();
  14366. $dateCondition = " and Year(date) =" . $year;
  14367. if (! empty ( $month ))
  14368. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14369. $categoryList = $Lcategory->find ( array (
  14370. 'asArray' => true
  14371. ) );
  14372. $staffList = $staff->find ( array (
  14373. 'where' => 'cid=' . $cid,
  14374. 'asArray' => true
  14375. ) );
  14376. $cateCondition = "";
  14377. $staffCondition = "";
  14378. $approvalCondition = "";
  14379. if (! empty ( $cid ))
  14380. $cateCondition = ' and cid=' . $cid;
  14381. if (! empty ( $sid )) {
  14382. $staffCondition = ' and staff=' . $sid;
  14383. $cateCondition = "";
  14384. }
  14385. $approvalCondition = " and status=" . $status;
  14386. if ($status == 2) {
  14387. // 查找角色审批人
  14388. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14389. }
  14390. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14391. $approvalCondition = ' and status=2 ';
  14392. }
  14393. if ($status == 1) {
  14394. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14395. }
  14396. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14397. $pageinfo ['page'] = array (
  14398. 'previous' => ''
  14399. );
  14400. if ($status == 0) {
  14401. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14402. $receiptList = $receipt->find ( array (
  14403. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14404. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14405. 'desc' => 'rid',
  14406. 'asArray' => true
  14407. ) );
  14408. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14409. } else
  14410. $receiptList = $receipt->find ( array (
  14411. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14412. 'desc' => 'rid',
  14413. 'asArray' => true
  14414. ) );
  14415. $rLRes = $receipt->find ( array (
  14416. '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,
  14417. 'desc' => 'rid',
  14418. 'asArray' => true
  14419. ) );
  14420. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14421. // print_r($pageinfo);
  14422. $Locate = 0;
  14423. foreach ( $receiptList as $key => $value ) {
  14424. $receiptList [$key] ['Locate'] = $Locate;
  14425. $Locate ++;
  14426. $receiptList [$key] ['reviseDetail'] = array ();
  14427. if (! empty ( $value ['reviseDetail'] ))
  14428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14430. $categoryDetil = $Lcategory->getOne ( array (
  14431. 'where' => 'cid=' . $value ['cid'],
  14432. 'asArray' => true
  14433. ) );
  14434. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14435. $verifyList = $verify->getOne ( array (
  14436. 'where' => 'vid=' . $value ['verify'],
  14437. 'asArray' => true
  14438. ) );
  14439. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14440. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14441. foreach ( $verifyList as $k => $v ) {
  14442. // init verifyStaff
  14443. $verifyList [$k] ['date'] = "";
  14444. $verifyList [$k] ['opinion'] = "";
  14445. $verifyList [$k] ['status'] = "";
  14446. if (empty ( $verifyStaff )) {
  14447. $verifyList [$k] ['date'] = "";
  14448. $verifyList [$k] ['opinion'] = "";
  14449. if ($v [0] == $this->staff [0] ['sid']) {
  14450. $verifyList [$k] ['status'] = 4;
  14451. $button = 4;
  14452. }
  14453. } else {
  14454. $flag = true;
  14455. foreach ( $verifyStaff as $m => $u ) {
  14456. if ($v [0] == $m) {
  14457. $verifyList [$k] ['date'] = $u ['date'];
  14458. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14459. $verifyList [$k] ['status'] = $u ['status'];
  14460. $flag = false;
  14461. break;
  14462. }
  14463. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14464. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14465. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14466. }
  14467. if ($flag) { // 检测可编辑
  14468. if ($v [0] == $this->staff [0] ['sid']) {
  14469. $verifyList [$k] ['status'] = 4;
  14470. $button = 4;
  14471. }
  14472. }
  14473. }
  14474. }
  14475. $receiptList [$key] ['verifyList'] = $verifyList;
  14476. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14477. 'where' => 'sid=' . $value ['staff'],
  14478. 'asArray' => true
  14479. ) );
  14480. $receiptList [$key] ['button'] = $button;
  14481. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14482. }
  14483. // print_r($receiptList);die;
  14484. // $data['verifyDetail']=$verifyDetail;
  14485. $mothHtml = "";
  14486. for($i = 1; $i <= 12; $i ++) {
  14487. if ($month == $i)
  14488. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14489. else
  14490. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14491. }
  14492. $data ['mothHtml'] = $mothHtml;
  14493. $data ['page'] = $pageinfo;
  14494. $data ['receiptList'] = $receiptList;
  14495. $data ['receiptApprovalCount'] = count ( $rLRes );
  14496. $data ['status'] = $status;
  14497. $data ['year'] = $year;
  14498. $data ['categoryList'] = $categoryList;
  14499. $data ['staffList'] = $staffList;
  14500. $data ['cid'] = $cid;
  14501. $data ['sid'] = $sid;
  14502. // print_r($receiptList);
  14503. $data ['memu'] = "receipt";
  14504. $data ['staff'] = $this->staff;
  14505. $data ['receiptMemu'] = 'approvalExpenses';
  14506. $data ['verifyId'] = $this->verifyId;
  14507. $data ['executeId'] = $this->executeId;
  14508. $this->render ( "/admin/FALG", $data );
  14509. }
  14510. function ajaxGetReceiptOrder() {
  14511. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14512. if (! empty ( $receiptOrder )) {
  14513. Doo::loadModel ( 'receipt' );
  14514. $receipt = new receipt ();
  14515. Doo::loadModel ( 'staff' );
  14516. $staff = new staff ();
  14517. $receiptInfo = $receipt->getOne ( array (
  14518. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14519. 'asArray' => true
  14520. ) );
  14521. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14522. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14523. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14524. </tbody></table><table class="table table table-bordered"><tbody>';
  14525. foreach ( $verifyStaff as $key => $value ) {
  14526. $staffInfo = $staff->getOne ( array (
  14527. 'select' => 'username',
  14528. 'where' => ' sid="' . $key . '"',
  14529. 'asArray' => true
  14530. ) );
  14531. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14532. }
  14533. $html .= '</tbody></table></div></div>';
  14534. echo json_encode ( array (
  14535. 'status' => 1,
  14536. 'receiptHtml' => $html
  14537. ) );
  14538. die ();
  14539. }
  14540. echo json_encode ( array (
  14541. 'status' => 2,
  14542. 'receiptHtml' => ''
  14543. ) );
  14544. die ();
  14545. }
  14546. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14547. if (! empty ( $receiptCollectList )) {
  14548. $receiptL = array (
  14549. '日常相关费用' => array (),
  14550. '差旅相关费用' => array (),
  14551. '内部培训费用'=>array(),
  14552. '培训班费用' => array (),
  14553. '其他' => array ()
  14554. );
  14555. $html = "";
  14556. $psum = 0;
  14557. foreach ( $aiList[$this->AGENCY] as $value ) {
  14558. $falg = true;
  14559. foreach ( $receiptCollectList as $v ) {
  14560. if ($v ['itemCategory'] == '日常相关费用') {
  14561. if ($v ['item'] == $value['name']) {
  14562. $psum += $v ['price'];
  14563. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14564. $falg = false;
  14565. break;
  14566. }
  14567. }
  14568. }
  14569. if ($falg)
  14570. $html .= '<td class="taR">-</td>';
  14571. }
  14572. if (! empty ( $psum ))
  14573. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14574. else
  14575. $psum = '<td class="colGreen taR">-</td>';
  14576. $receiptL ['日常相关费用'] = $psum . $html;
  14577. /* ----------------------------------- */
  14578. $html = "";
  14579. $psum = 0;
  14580. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14581. $falg = true;
  14582. foreach ( $receiptCollectList as $v ) {
  14583. if ($v ['itemCategory'] == '差旅相关费用') {
  14584. if ($v ['item'] == $value['name']) {
  14585. $psum += $v ['price'];
  14586. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14587. $falg = false;
  14588. break;
  14589. }
  14590. }
  14591. }
  14592. if ($falg)
  14593. $html .= '<td class="taR">-</td>';
  14594. }
  14595. if (! empty ( $psum ))
  14596. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14597. else
  14598. $psum = '<td class="colGreen taR">-</td>';
  14599. $receiptL ['差旅相关费用'] = $psum . $html;
  14600. /* ----------------------------------- */
  14601. $html = "";
  14602. $psum = 0;
  14603. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14604. $falg = true;
  14605. foreach ( $receiptCollectList as $v ) {
  14606. if ($v ['itemCategory'] == '内部培训费用') {
  14607. if ($v ['item'] == $value['name']) {
  14608. $psum += $v ['price'];
  14609. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14610. $falg = false;
  14611. break;
  14612. }
  14613. }
  14614. }
  14615. if ($falg)
  14616. $html .= '<td class="taR">-</td>';
  14617. }
  14618. if (! empty ( $psum ))
  14619. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14620. else
  14621. $psum = '<td class="colGreen taR">-</td>';
  14622. $receiptL ['内部培训费用'] = $psum . $html;
  14623. /* ------------------------------------- */
  14624. $html = "";
  14625. $psum = 0;
  14626. foreach ( $aiList[$this->TRAIN] as $value ) {
  14627. $falg = true;
  14628. foreach ( $receiptCollectList as $v ) {
  14629. if ($v ['itemCategory'] == '培训班费用') {
  14630. if ($v ['item'] == $value['name']) {
  14631. $psum += $v ['price'];
  14632. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14633. $falg = false;
  14634. break;
  14635. }
  14636. }
  14637. }
  14638. if ($falg)
  14639. $html .= '<td class="taR">-</td>';
  14640. }
  14641. if (! empty ( $psum ))
  14642. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14643. else
  14644. $psum = '<td class="colGreen taR">-</td>';
  14645. $receiptL ['培训班费用'] = $psum . $html;
  14646. /* ------------------------------------- */
  14647. $html = "";
  14648. $psum = 0;
  14649. foreach ( $aiList[$this->OTHER] as $value ) {
  14650. $falg = true;
  14651. foreach ( $receiptCollectList as $v ) {
  14652. if ($v ['itemCategory'] == '其他') {
  14653. if ($v ['item'] == $value['name']) {
  14654. $psum += $v ['price'];
  14655. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14656. $falg = false;
  14657. break;
  14658. }
  14659. }
  14660. }
  14661. if ($falg)
  14662. $html .= '<td class="taR">-</td>';
  14663. }
  14664. if (! empty ( $psum ))
  14665. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14666. else
  14667. $psum = '<td class="colGreen taR">-</td>';
  14668. $receiptL ['其他'] = $psum . $html;
  14669. /* ------------------------------------- */
  14670. $html = "";
  14671. $psum = 0;
  14672. foreach ( $receiptCollectList as $v ) {
  14673. if ($v ['itemCategory'] == '报销金额调整') {
  14674. if (! empty ( $v ['price'] ))
  14675. $psum += $v ['price'];
  14676. }
  14677. }
  14678. if (! empty ( $psum ))
  14679. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14680. else
  14681. $psum = '<td class="taR colOrange">-</td>';
  14682. $receiptL ['报销金额调整'] = $psum . $html;
  14683. } else {
  14684. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14685. foreach ( $aiList[$this->AGENCY] as $va ) {
  14686. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14687. }
  14688. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14689. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14690. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14691. }
  14692. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14693. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14694. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14695. }
  14696. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14697. foreach ( $aiList[$this->TRAIN] as $va ) {
  14698. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14699. }
  14700. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14701. foreach ( $aiList[$this->OTHER] as $va ) {
  14702. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14703. }
  14704. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14705. }
  14706. return $receiptL;
  14707. }
  14708. function eMail() {
  14709. Doo::loadModel ( 'staff' );
  14710. $staff = new staff ();
  14711. Doo::loadModel ( 'receipt' );
  14712. $receipt = new receipt ();
  14713. Doo::loadModel ( 'L_category' );
  14714. $Lcategory = new L_category ();
  14715. Doo::loadModel ( "verify" );
  14716. $verify = new verify ();
  14717. $staffList = $staff->find ( array (
  14718. 'asArray' => true
  14719. ) );
  14720. foreach ( $staffList as $key => $value ) {
  14721. if ($value ['username'] != 'admin') {
  14722. // 提交人
  14723. $receiptList = $receipt->find ( array (
  14724. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14725. 'asArray' => true
  14726. ) );
  14727. if (! empty ( $receiptList )) {
  14728. $html = '<br><div><style></style>
  14729. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14730. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14731. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14732. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14733. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14734. <tbody><tr>
  14735. <td style="padding: 0 40px;" align="left">
  14736. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14737. </td></tr><tr>
  14738. <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>
  14739. </tr>
  14740. </tbody> </table></td> </tr> <tr><td>
  14741. <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">
  14742. <tbody> <tr><td>
  14743. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14744. 以下报销单完成了审批,等着收款吧:</p>
  14745. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14746. foreach ( $receiptList as $k => $v ) {
  14747. $category = $Lcategory->getOne ( array (
  14748. 'where' => 'cid=' . $v ['cid'],
  14749. 'asArray' => true
  14750. ) );
  14751. $html .= '
  14752. <tr>
  14753. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14754. <td align="left">
  14755. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14756. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14757. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14758. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14759. </tr>';
  14760. }
  14761. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14762. <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>
  14763. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14764. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14765. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14766. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14767. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14768. $receipt = new receipt ();
  14769. $receipt->notice = 1;
  14770. $receipt->update ( array (
  14771. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14772. ) );
  14773. }
  14774. }
  14775. // 审批人
  14776. $verifyList = $verify->find ( array (
  14777. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14778. 'asArray' => true
  14779. ) );
  14780. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14781. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14782. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14783. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14784. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14785. <tbody><tr><td style="padding: 0 40px;" align="left">
  14786. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14787. </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>
  14788. </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">
  14789. <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>
  14790. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14791. foreach ( $verifyList as $k => $v ) {
  14792. $receiptList = $receipt->find ( array (
  14793. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14794. 'asArray' => true
  14795. ) );
  14796. foreach ( $receiptList as $r => $l ) {
  14797. $category = $Lcategory->getOne ( array (
  14798. 'where' => 'cid=' . $l ['cid'],
  14799. 'asArray' => true
  14800. ) );
  14801. $staffDetile = $staff->getOne ( array (
  14802. 'where' => 'sid=' . $l ['staff'],
  14803. 'asArray' => true
  14804. ) );
  14805. $html .= '
  14806. <tr>
  14807. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14808. <td align="left">
  14809. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14810. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14811. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14812. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14813. </tr>';
  14814. }
  14815. }
  14816. $html .= '
  14817. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14818. <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>
  14819. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14820. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14821. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14822. // $receipt=new receipt();
  14823. // $receipt->notice=1;
  14824. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14825. }
  14826. }
  14827. }
  14828. }
  14829. function setWXMsg($rid, $type) {
  14830. Doo::loadModel ( "receipt" );
  14831. $receipt = new receipt ();
  14832. $receiptDetail = $receipt->getOne ( array (
  14833. 'where' => 'rid=' . $rid,
  14834. 'asArray' => true
  14835. ) );
  14836. if (! empty ( $receiptDetail )) {
  14837. Doo::loadModel ( 'staff' );
  14838. $staff = new staff ();
  14839. $staffmsg = $staff->getOne ( array (
  14840. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14841. 'asArray' => TRUE
  14842. ) );
  14843. if (! empty ( $staffmsg ['wxid'] )) {
  14844. require_once (SITE_PATH . '/protected/class/client.php');
  14845. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14846. $user = $staffmsg ['wxid'];
  14847. $receiptName = '';
  14848. $msg = '';
  14849. switch ($receiptDetail ['Rtype']) {
  14850. case 0 :
  14851. $receiptName = '报销';
  14852. break;
  14853. case 1 :
  14854. $receiptName = '借款';
  14855. break;
  14856. case 2 :
  14857. $receiptName = '对公汇款';
  14858. break;
  14859. }
  14860. switch ($type) {
  14861. case 1 :
  14862. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14863. break;
  14864. case 2 :
  14865. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14866. break;
  14867. case 3 :
  14868. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14869. break;
  14870. }
  14871. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14872. }
  14873. }
  14874. }
  14875. // Email发送函数
  14876. function SMail($toemail, $subject, $contents) {
  14877. Doo::loadClass ( 'class.phpmailer' );
  14878. $mail = new PHPMailer ();
  14879. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14880. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14881. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14882. $mail->Password = "cDO1GjtY1seH"; // 密码
  14883. $mail->CharSet = "UTF8";
  14884. $mail->SMTPAuth = true;
  14885. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14886. $mail->Mailer = "smtp";
  14887. $mail->Port = 25;
  14888. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14889. $mail->MsgHTML ( $contents );
  14890. $mail->AddAddress ( $toemail );
  14891. $mail->CharSet = "UTF-8";
  14892. return $mail->Send ();
  14893. }
  14894. function h5Upload() {
  14895. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14896. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14897. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14898. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14899. header ( "HTTP/1.1 500 Internal Server Error" );
  14900. echo "POST exceeded maximum allowed size.";
  14901. exit ( 0 );
  14902. }
  14903. // Settings
  14904. $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)
  14905. $upload_name = "Filedata";
  14906. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14907. $extension_whitelist = array (
  14908. "doc",
  14909. "txt",
  14910. "jpg",
  14911. "gif",
  14912. "png"
  14913. ); // Allowed file extensions
  14914. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14915. // Other variables
  14916. $MAX_FILENAME_LENGTH = 260;
  14917. $file_name = "";
  14918. $file_extension = "";
  14919. $uploadErrors = array (
  14920. 0 => "文件上传成功",
  14921. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14922. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14923. 3 => "上传的文件仅为部分文件",
  14924. 4 => "没有文件上传",
  14925. 6 => "缺少临时文件夹"
  14926. );
  14927. $nk = time ();
  14928. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14929. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14930. echo "文件无法保存.";
  14931. exit ( 0 );
  14932. }
  14933. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14934. echo json_encode ( array (
  14935. 'filename' => $file_name,
  14936. 'id' => $nk
  14937. ) );
  14938. exit ( 0 );
  14939. }
  14940. function swfupload() {
  14941. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14942. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14943. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14944. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14945. header ( "HTTP/1.1 500 Internal Server Error" );
  14946. echo "POST exceeded maximum allowed size.";
  14947. exit ( 0 );
  14948. }
  14949. // Settings
  14950. $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)
  14951. $upload_name = "Filedata";
  14952. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14953. $extension_whitelist = array (
  14954. "doc",
  14955. "txt",
  14956. "jpg",
  14957. "gif",
  14958. "png"
  14959. ); // Allowed file extensions
  14960. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14961. // Other variables
  14962. $MAX_FILENAME_LENGTH = 260;
  14963. $file_name = "";
  14964. $file_extension = "";
  14965. $uploadErrors = array (
  14966. 0 => "文件上传成功",
  14967. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14968. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14969. 3 => "上传的文件仅为部分文件",
  14970. 4 => "没有文件上传",
  14971. 6 => "缺少临时文件夹"
  14972. );
  14973. $nk = time ();
  14974. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14975. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14976. echo "文件无法保存.";
  14977. exit ( 0 );
  14978. }
  14979. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14980. echo json_encode ( array (
  14981. 'filename' => $file_name,
  14982. 'id' => $nk
  14983. ) );
  14984. exit ( 0 );
  14985. }
  14986. function _GetFileEXT($filename) {
  14987. $pics = explode ( '.', $filename );
  14988. $num = count ( $pics );
  14989. return $pics [$num - 1];
  14990. }
  14991. /**
  14992. * 获取get或者POST值
  14993. * @param string $name 属性名称
  14994. * @return fixed 值
  14995. */
  14996. function get_args($name) {
  14997. if (isset ( $_GET [$name] )) {
  14998. if (is_array ( $_GET [$name] ))
  14999. return $_GET [$name];
  15000. else
  15001. return addslashes ( $_GET [$name] );
  15002. } elseif (isset ( $_POST [$name] )) {
  15003. if (is_array ( $_POST [$name] ))
  15004. return $_POST [$name];
  15005. else
  15006. return addslashes ( $_POST [$name] );
  15007. } else
  15008. return false;
  15009. }
  15010. function num_to_rmb($num) {
  15011. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15012. $c2 = "分角元拾佰仟万拾佰仟亿";
  15013. // 精确到分后面就不要了,所以只留两个小数位
  15014. $num = round ( $num, 2 );
  15015. // 将数字转化为整数
  15016. $num = $num * 100;
  15017. if (strlen ( $num ) > 10) {
  15018. return "金额太大,请检查";
  15019. }
  15020. $i = 0;
  15021. $c = "";
  15022. while ( 1 ) {
  15023. if ($i == 0) {
  15024. // 获取最后一位数字
  15025. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15026. } else {
  15027. $n = $num % 10;
  15028. }
  15029. // 每次将最后一位数字转化为中文
  15030. $p1 = substr ( $c1, 3 * $n, 3 );
  15031. $p2 = substr ( $c2, 3 * $i, 3 );
  15032. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15033. $c = $p1 . $p2 . $c;
  15034. } else {
  15035. $c = $p1 . $c;
  15036. }
  15037. $i = $i + 1;
  15038. // 去掉数字最后一位了
  15039. $num = $num / 10;
  15040. // echo $num.'</br>';
  15041. $num = ( int ) $num;
  15042. // $num =floor($num);
  15043. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15044. // echo $num.'</br>';
  15045. // 结束循环
  15046. if ($num == 0) {
  15047. break;
  15048. }
  15049. }
  15050. // echo $c.'</br>';
  15051. $j = 0;
  15052. $slen = strlen ( $c );
  15053. while ( $j < $slen ) {
  15054. // utf8一个汉字相当3个字符
  15055. $m = substr ( $c, $j, 6 );
  15056. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15057. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15058. $left = substr ( $c, 0, $j );
  15059. $right = substr ( $c, $j + 3 );
  15060. $c = $left . $right;
  15061. $j = $j - 3;
  15062. $slen = $slen - 3;
  15063. }
  15064. $j = $j + 3;
  15065. }
  15066. // 这个是为了去掉类似23.0中最后一个“零”字
  15067. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15068. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15069. }
  15070. // 将处理的汉字加上“整”
  15071. if (empty ( $c )) {
  15072. return "零元整";
  15073. } else {
  15074. return $c . "整";
  15075. }
  15076. }
  15077. /**
  15078. * 获得分页数据
  15079. * @param unknown_type $table
  15080. * @param unknown_type $condition
  15081. * @param unknown_type $on_page
  15082. * @param unknown_type $page_size
  15083. */
  15084. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15085. $page_c = "";
  15086. $page ['previous'] = $this->get_previous ( $on_page );
  15087. $page ['on_page'] = $on_page;
  15088. $total_count = $this->get_table_count ( $table, $condition );
  15089. $total = intval ( $total_count / $page_size );
  15090. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15091. $page ['total_data'] = $total_count;
  15092. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15093. $i = 1;
  15094. $page_max = 1;
  15095. $page_width = 3;
  15096. if ($on_page >= $page_width) {
  15097. $page_max = intval ( $on_page / $page_width ) + 1;
  15098. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15099. }
  15100. for(; $i <= $page ['total_page']; $i ++) {
  15101. if ($i == $on_page)
  15102. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15103. else
  15104. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15105. if ($i == ($page_width * $page_max))
  15106. break;
  15107. }
  15108. $page ['page'] = $page_c;
  15109. $page ['lower'] = (-- $on_page) * $page_size;
  15110. return $page;
  15111. }
  15112. /**
  15113. * 获取总页数
  15114. * @param unknown_type $table
  15115. * @param unknown_type $condition
  15116. */
  15117. public function get_table_count($table = "", $condition = "") {
  15118. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15119. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15120. // echo $sql;die;
  15121. $query = Doo::db ()->query ( $sql );
  15122. $result = $query->fetch ();
  15123. return $result ['count'];
  15124. }
  15125. /**
  15126. * 获取上一页
  15127. * @param unknown_type $on_page
  15128. */
  15129. function get_previous($on_page = 1) {
  15130. return $on_page != 0 ? $on_page - 1 : $on_page;
  15131. }
  15132. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15133. // 收入合计
  15134. Doo::loadModel ( 'invoiceTraining' );
  15135. $invoiceTraining = new invoiceTraining ();
  15136. Doo::loadModel ( 'receipt' );
  15137. $receipt = new receipt ();
  15138. $invoiceTrainingDetail = array (
  15139. 'invoiceArriveAmount' => '0.00',
  15140. 'RIAmount' => '0.00',
  15141. 'invoiceTotalAmount' => '0.00',
  15142. 'invoiceCompanyAmount' => '0.00',
  15143. 'invoiceArriveAmountM'=>'0.00',
  15144. 'invoiceCompanyAmountM'=>'0.00'
  15145. );
  15146. if ($invoiceTrainId != 0) {
  15147. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15148. }
  15149. $invoiceArriveAmount = $RIAmount = 0;
  15150. if (! empty ( $invoiceTrainingDetail )) {
  15151. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15152. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15153. }
  15154. // 备用金
  15155. $sum = 0;
  15156. if (! empty ( $trainLoanRid )) {
  15157. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15158. foreach ($receiptLoanList as $key=>$value){
  15159. $sum+=$value['sum'];
  15160. }
  15161. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15162. // $sum = $receiptLoanDetailBak ['sum'];
  15163. }
  15164. // 支出项金额详情
  15165. // 项目金额合计
  15166. Doo::loadModel ( 'RItem' );
  15167. $RItem = new RItem ();
  15168. Doo::loadModel ( 'accountItem' );
  15169. $accountItem = new accountItem ();
  15170. // 讲师获得
  15171. Doo::loadModel ( 'RILecturer' );
  15172. $RILecturer = new RILecturer ();
  15173. $RItemList = $RItem->getRItemByRid ($rid );
  15174. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15175. // 支出项金额详情
  15176. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15177. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15178. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15179. return $payment;
  15180. }
  15181. }
  15182. ?>