ReceiptController.php 574 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. private function _itineraryDateMin(){
  58. Doo::loadModel ( "itinerary" );
  59. $itinerary = new itinerary ();
  60. $itineraryDetail=$itinerary->getOne(array (
  61. 'where'=>'sid ='.$this->staff [0] ['sid'],
  62. 'desc'=>'itineraryDate',
  63. 'asArray' => true
  64. ));
  65. return date("Y-m-d",strtotime("+1 day",strtotime($itineraryDetail['itineraryDate'])));
  66. }
  67. public function beforeRun($resource, $action) {
  68. Doo::loadClass ( 'XDeode' );
  69. $XDeode = new XDeode ( 5 );
  70. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  71. // 单独判断公司汇总的访问权限
  72. if ($action == 'companyCategoryCollect') {
  73. Doo::loadModel ( "receiptAuthorityManage" );
  74. $invoiceCompanyManage = new receiptAuthorityManage ();
  75. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  76. if (empty ( $icm ))
  77. die ( 'illegal request-statistics' );
  78. }
  79. Doo::loadModel ( 'staff' );
  80. $staff = new staff ();
  81. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  82. $accessModular = 'RECEIPTS';
  83. if (empty ( $detail ['cldAccessArray'] ))
  84. die ( 'illegal request' );
  85. else {
  86. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  87. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  88. $flag = true;
  89. } else {
  90. $flag = false;
  91. }
  92. } else {
  93. die ( 'illegal request' );
  94. }
  95. }
  96. if (! $flag)
  97. die ( 'illegal request' );
  98. }
  99. function __construct() {
  100. if (isset ( $_COOKIE ["staff"] )) {
  101. if (! empty ( $_COOKIE ["staff"] )) {
  102. Doo::loadModel ( 'staff' );
  103. Doo::loadModel ( 'verify' );
  104. $verify = new verify ();
  105. $staff = new staff ();
  106. Doo::loadModel ( "execute" );
  107. $execute = new execute ();
  108. $verifyList = $verify->find ( array (
  109. 'select' => 'staff',
  110. 'asArray' => true
  111. ) );
  112. $list = array ();
  113. // 判断角色的审批权限
  114. foreach ( $verifyList as $key => $value ) {
  115. $ver = json_decode ( $value ['staff'] );
  116. foreach ( $ver as $k => $v ) {
  117. if ($v [1] == 'ROLE') {
  118. $roleList = json_decode ( $v [3] );
  119. foreach ( $roleList as $t => $g ) {
  120. $gList = explode ( "_", $g );
  121. array_push ( $list, $gList [0] );
  122. // print_r($list);
  123. }
  124. } else
  125. array_push ( $list, $v [0] );
  126. }
  127. }
  128. // 判断执行人的审批权限
  129. $executeList = $execute->find ( array (
  130. 'where'=>'mold !="日常收支"',
  131. 'select' => 'staff',
  132. 'asArray' => true
  133. ) );
  134. $list2 = array ();
  135. foreach ( $executeList as $key => $value ) {
  136. $ver = json_decode ( $value ['staff'] );
  137. foreach ( $ver as $k => $v ) {
  138. array_push ( $list2, $v [0] );
  139. }
  140. }
  141. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  142. $eidList = array_filter ( explode ( ",", $eidList ) );
  143. $this->executeId = array_merge ( $list2, $eidList );
  144. $this->verifyId = $list;
  145. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  146. // 检测用户信息完成
  147. $this->data ['isStaffCompleteMsg'] = false;
  148. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  149. if (! empty ( $detail ))
  150. $this->data ['isStaffCompleteMsg'] = true;
  151. return "/";
  152. }
  153. }
  154. Doo::loadCore ( 'uri/DooUriRouter' );
  155. $router = new DooUriRouter ();
  156. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  157. if ($routeRs ['1'] != "login") {
  158. header ( 'Content-Type:text/html;charset=utf-8' );
  159. @header ( "Location: /login" );
  160. }
  161. }
  162. /**
  163. * 费用首页
  164. */
  165. function saeaBorad() {
  166. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  167. Doo::loadModel ( 'receipt' );
  168. $receipt = new receipt ();
  169. Doo::loadModel ( 'verify' );
  170. $verify = new verify ();
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. Doo::loadModel ( "role" );
  174. $role = new role ();
  175. Doo::loadModel ( "receiptLog" );
  176. $receiptLog = new receiptLog ();
  177. Doo::loadModel ( 'accountItem' );
  178. $accountItem = new accountItem ();
  179. Doo::loadClass ( 'XDeode' );
  180. $XDeode = new XDeode ( 7 );
  181. $XDeode9 = new XDeode ( 9 );
  182. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  183. $receiptDetail = $receipt->find ( array (
  184. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  185. 'desc' => 'rid',
  186. 'asArray' => true
  187. ) );
  188. foreach ( $receiptDetail as $key => $value ) {
  189. $receiptDetail [$key] ['receiptId'] = $XDeode9->encode ( $value ['rid'] );
  190. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  191. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  192. $veList = $verify->getOne ( array (
  193. 'where' => 'vid=' . $value ['verify'],
  194. 'asArray' => true
  195. ) );
  196. $v = json_decode ( $veList ['staff'] );
  197. array_push ( $v [0], $veList ['description'] );
  198. foreach ( $v as $n => $m ) {
  199. if ($m ['1'] == 'ROLE') {
  200. $roleInfo = $role->getOne ( array (
  201. 'where' => 'rid=' . $m [0],
  202. 'asArray' => true
  203. ) );
  204. $v [$n] [1] = $roleInfo ['name'];
  205. }
  206. }
  207. $receiptDetail [$key] ['staff'] = $v;
  208. $category = $lCategory->getOne ( array (
  209. 'where' => 'cid=' . $value ['cid'],
  210. 'asArray' => true
  211. ) );
  212. $receiptDetail [$key] ['category'] = $category ['title'];
  213. }
  214. // print_r($receiptLogList);
  215. // 协助修改TODO,只显示未完成的
  216. Doo::loadModel ( 'RAssist' );
  217. $RAssist = new RAssist ();
  218. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  219. //费用项目
  220. $acItem = $accountItem->find ( array ('asArray' => true) );
  221. if ($travel=='success'){
  222. $data ['travel'] =true;
  223. }else{
  224. $data ['travel'] =false;
  225. }
  226. $data ['acItem'] = $acItem;
  227. $data ['receiptExtendList'] = $receiptExtendList;
  228. $data ['receiptLogList'] = $receiptLogList;
  229. $data ['receiptDetail'] = $receiptDetail;
  230. $data ['memu'] = "receipt";
  231. $data ['staff'] = $this->staff;
  232. $data ['receiptMemu'] = 'saeaBorad';
  233. $data ['verifyId'] = $this->verifyId;
  234. $data ['executeId'] = $this->executeId;
  235. $this->render ( "/receipt/receiptFee", $data );
  236. }
  237. /**
  238. * 费用报销单-导流入哪个细分类
  239. */
  240. function receiptFeeDiversion(){
  241. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  242. if($feeType==2){
  243. return '/receipt/feeTravel';
  244. }elseif($feeType==3){
  245. return '/receipt/feeInternalTrain';
  246. }else{
  247. return '/receipt/feeAgency';
  248. }
  249. }
  250. private function _feeData(){
  251. Doo::loadModel ( 'L_category' );
  252. $lCategory = new L_category ();
  253. Doo::loadModel ( 'verify' );
  254. $verify = new verify ();
  255. Doo::loadModel ( 'accountItem' );
  256. $accountItem = new accountItem ();
  257. Doo::loadModel ( "role" );
  258. $role = new role ();
  259. $acItem = $accountItem->find ( array (
  260. 'asArray' => true
  261. ) );
  262. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  263. $data ['category'] = $lCategory->find ( array (
  264. 'asArray' => true
  265. ) );
  266. $data ['itineraryDate'] = $this->_itineraryDateMin();
  267. $data ['veList'] = $veList;
  268. $data ['acItem'] = $acItem;
  269. $data ['memu'] = "receipt";
  270. $data ['staff'] = $this->staff;
  271. $data ['receiptMemu'] = 'saeaBorad';
  272. $data ['verifyId'] = $this->verifyId;
  273. $data ['executeId'] = $this->executeId;
  274. return $data;
  275. }
  276. /**
  277. * 办事处相关费用
  278. */
  279. function feeAgency(){
  280. $data=$this->_feeData();
  281. $this->render ( "/receipt/feeAgency", $data );
  282. }
  283. /**
  284. * 办事处
  285. */
  286. function feeTravel(){
  287. $data=$this->_feeData();
  288. $this->render ( "/receipt/feeTravel", $data );
  289. }
  290. function feeInternalTrain(){
  291. $data=$this->_feeData();
  292. $this->render ( "/receipt/feeInternalTrain", $data );
  293. }
  294. /**
  295. * 添加费用报销单页面
  296. */
  297. function saeaCreate() {
  298. Doo::loadModel ( 'accountItem' );
  299. Doo::loadModel ( 'verify' );
  300. Doo::loadModel ( 'receipt' );
  301. Doo::loadModel ( 'L_category' );
  302. $lCategory = new L_category ();
  303. $receipt = new receipt ();
  304. $verify = new verify ();
  305. $accountItem = new accountItem ();
  306. Doo::loadModel ( "role" );
  307. $role = new role ();
  308. $acItem = $accountItem->find ( array (
  309. 'asArray' => true
  310. ) );
  311. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  312. $data ['category'] = $lCategory->find ( array (
  313. 'asArray' => true
  314. ) );
  315. $data ['veList'] = $veList;
  316. $data ['acItem'] = $acItem;
  317. $data ['memu'] = "receipt";
  318. $data ['staff'] = $this->staff;
  319. $data ['receiptMemu'] = 'saeaBorad';
  320. $data ['verifyId'] = $this->verifyId;
  321. $data ['executeId'] = $this->executeId;
  322. $this->render ( "/admin/saea_create", $data );
  323. }
  324. private function _storageItinerary($itinerary,$rid,$version=2){
  325. $itineraryJson=json_decode($itinerary,true);
  326. Doo::loadModel ( 'itinerary' );
  327. $itinerary = new itinerary ();
  328. $itinerary->delete(array('where' => 'rid=' . $rid ));
  329. if($version==2){
  330. foreach ($itineraryJson as $k=>$v){
  331. foreach ($v as $kk=>$vv){
  332. foreach ($vv as $key=>$value){
  333. if($key==0){
  334. $feeTraveItem=json_encode($value['feeTraveItem']);
  335. $itinerary = new itinerary ();
  336. $itinerary->rid=$rid;
  337. $itinerary->sid=$this->staff [0] ['sid'];
  338. $itinerary->itineraryDate=$value['departuredate'];
  339. $itinerary->itineraryCity=$value['departurecity'];
  340. $itinerary->feeTraveItem='';
  341. $itinerary->itineraryIndex=0;
  342. $itinerary->insert ();
  343. $itinerary = new itinerary ();
  344. $itinerary->rid=$rid;
  345. $itinerary->sid=$this->staff [0] ['sid'];
  346. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  347. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  348. $itinerary->feeTraveItem=$feeTraveItem;
  349. $itinerary->itineraryIndex=1;
  350. $itinerary->insert ();
  351. }else{
  352. $feeTraveItem=json_encode($value['feeTraveItem']);
  353. $itinerary = new itinerary ();
  354. $itinerary->rid=$rid;
  355. $itinerary->sid=$this->staff [0] ['sid'];
  356. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  357. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  358. $itinerary->feeTraveItem=$feeTraveItem;
  359. $itinerary->itineraryIndex=$key+1;
  360. $itinerary->insert ();
  361. }
  362. }
  363. }
  364. }
  365. }elseif($version==1){
  366. foreach ($itineraryJson as $key=>$value){
  367. if($key==0){
  368. $feeTraveItem=json_encode($value['feeTraveItem']);
  369. $itinerary = new itinerary ();
  370. $itinerary->rid=$rid;
  371. $itinerary->sid=$this->staff [0] ['sid'];
  372. $itinerary->itineraryDate=$value['departuredate'];
  373. $itinerary->itineraryCity=$value['departurecity'];
  374. $itinerary->feeTraveItem='';
  375. $itinerary->itineraryIndex=0;
  376. $itinerary->insert ();
  377. $itinerary = new itinerary ();
  378. $itinerary->rid=$rid;
  379. $itinerary->sid=$this->staff [0] ['sid'];
  380. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  381. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  382. $itinerary->feeTraveItem=$feeTraveItem;
  383. $itinerary->itineraryIndex=1;
  384. $itinerary->insert ();
  385. }else{
  386. $feeTraveItem=json_encode($value['feeTraveItem']);
  387. $itinerary = new itinerary ();
  388. $itinerary->rid=$rid;
  389. $itinerary->sid=$this->staff [0] ['sid'];
  390. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  391. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  392. $itinerary->feeTraveItem=$feeTraveItem;
  393. $itinerary->itineraryIndex=$key+1;
  394. $itinerary->insert ();
  395. }
  396. }
  397. }else{
  398. die ( '行程单版本不正确' );
  399. }
  400. }
  401. private function _verificationItinerary($itinerary){
  402. Doo::loadModel ( 'itinerary' );
  403. $itineraryObj = new itinerary ();
  404. if(empty($itinerary)){
  405. header ( 'Content-Type:text/html;charset=utf-8' );
  406. die ( '请填写行程单' );
  407. }
  408. $itineraryJson=json_decode($itinerary,true);
  409. foreach ($itineraryJson as $k=>$v){
  410. foreach ($v as $kk=>$vv){
  411. foreach ($vv as $key=>$value){
  412. if(empty($value['departuredate'])||empty($value['arrivalsdate'])){
  413. header ( 'Content-Type:text/html;charset=utf-8' );
  414. die ( '有行程的日期未设置' );
  415. }
  416. }
  417. }
  418. }
  419. $itineraryDate=array();$sql=array();
  420. foreach ($itineraryJson as $k=>$v){
  421. foreach ($v as $kk=>$vv){
  422. foreach ($vv as $key=>$value){
  423. if($key==0){
  424. array_push($itineraryDate, $value['departuredate']);
  425. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  426. array_push($sql,'?');array_push($sql,'?');
  427. }else{
  428. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  429. array_push($sql,'?');
  430. }
  431. }
  432. }
  433. }
  434. array_push($itineraryDate, $this->staff [0] ['sid']);
  435. $sql=implode(',',$sql);
  436. // $itineraryDate=array();$sql=array();
  437. // foreach ($itineraryJson as $key=>$value){
  438. // if($key==0){
  439. // array_push($itineraryDate, $value['departuredate']);
  440. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  441. // array_push($sql,'?');array_push($sql,'?');
  442. // }else{
  443. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  444. // array_push($sql,'?');
  445. // }
  446. // }
  447. // array_push($itineraryDate, $this->staff [0] ['sid']);
  448. // $sql=implode(',',$sql);
  449. if(empty($sql)){
  450. header ( 'Content-Type:text/html;charset=utf-8' );
  451. die ( '请填写行程单-2' );
  452. }
  453. $qualification=array(
  454. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  455. 'param' => $itineraryDate,
  456. 'asArray' => TRUE);
  457. $itDateList=$itineraryObj->find($qualification);
  458. if(empty($itDateList)){
  459. return false;
  460. }else{
  461. return true;
  462. }
  463. }
  464. private function _buildFeeData($receiptClass=1,$itinerary=''){
  465. $agency = $this->get_args ( 'agency' );
  466. $travel = $this->get_args ( 'travel' );
  467. $train = $this->get_args ( 'train' );
  468. $other = $this->get_args ( 'other' );
  469. $inttrain = $this->get_args ( 'inttrain' );
  470. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  471. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  472. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  473. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  474. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  475. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  476. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  477. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  478. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  479. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  480. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  481. header ( 'Content-Type:text/html;charset=utf-8' );
  482. die ( '请填写联行号' );
  483. }
  484. if($receiptClass==2){
  485. //TODO 日期检测
  486. if($this->_verificationItinerary($itinerary)){
  487. header ( 'Content-Type:text/html;charset=utf-8' );
  488. die ( '已申请过类此日期的行程' );
  489. }
  490. }
  491. $itinerary=str_replace('\n','<br/>',$itinerary);
  492. Doo::loadModel ( 'receipt' );
  493. Doo::loadModel ( 'receiptDetail' );
  494. Doo::loadModel ( 'accountItem' );
  495. $accountItem = new accountItem ();
  496. $receipt = new receipt ();
  497. Doo::loadModel ( 'enclosur' );
  498. Doo::loadModel ( 'execute' );
  499. $execute = new execute ();
  500. $executeDetail = $execute->getOne ( array (
  501. 'where' => 'mold="报销单执行人"',
  502. 'asArray' => true
  503. ) );
  504. $aItem = $accountItem->find ( array (
  505. 'asArray' => true
  506. ) );
  507. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  508. $ag = $tr = $ta = $ot= $it = 0;
  509. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  510. foreach ( $aItem as $key => $value ) {
  511. if ($value ['category'] == $this->AGENCY) {
  512. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  513. array_push ( $accountJson [$this->AGENCY], array (
  514. 'aid' => $value ['aid'],
  515. 'name' => $value ['name'],
  516. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  517. ) );
  518. $sum += $agency [$ag];
  519. $agencySum += $agency [$ag];
  520. }
  521. $ag ++;
  522. }
  523. if ($value ['category'] == $this->TRAVEL) {
  524. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  525. array_push ( $accountJson [$this->TRAVEL], array (
  526. 'aid' => $value ['aid'],
  527. 'name' => $value ['name'],
  528. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  529. ) );
  530. $sum += $travel [$tr];
  531. $travelSum += $travel [$tr];
  532. }
  533. $tr ++;
  534. }
  535. if ($value ['category'] == $this->TRAIN) {
  536. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  537. array_push ( $accountJson [$this->TRAIN], array (
  538. 'aid' => $value ['aid'],
  539. 'name' => $value ['name'],
  540. 'price' => number_format ( $train [$ta], 2, '.', '' )
  541. ) );
  542. $sum += $train [$ta];
  543. $trainSum += $train [$ta];
  544. }
  545. $ta ++;
  546. }
  547. if ($value ['category'] == $this->INTTRAIN) {
  548. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  549. array_push ( $accountJson [$this->INTTRAIN], array (
  550. 'aid' => $value ['aid'],
  551. 'name' => $value ['name'],
  552. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  553. ) );
  554. $sum += $inttrain [$it];
  555. $inttrainSum += $inttrain [$it];
  556. }
  557. $it ++;
  558. }
  559. if ($value ['category'] == $this->OTHER) {
  560. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  561. array_push ( $accountJson [$this->OTHER], array (
  562. 'aid' => $value ['aid'],
  563. 'name' => $value ['name'],
  564. 'price' => number_format ( $other [$ot], 2, '.', '' )
  565. ) );
  566. $sum += $other [$ot];
  567. $otherSum += $other [$ot];
  568. }
  569. $ot ++;
  570. }
  571. }
  572. $accountJson ['cSum'] = array (
  573. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  574. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  575. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  576. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  577. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  578. );
  579. // 报销单
  580. $receipt->accountItem = json_encode ( $accountJson );
  581. $receipt->staff = $this->staff [0] ['sid'];
  582. $receipt->sum = number_format ( $sum, 2, '.', '' );
  583. $receipt->date = date ( "Y-m-d" );
  584. $receipt->cid = $cid;
  585. $receipt->status = 5;
  586. // 修改审批流程加入角色
  587. $receipt->verify = $verify;
  588. $receipt->executeCopy = $executeDetail ['staff'];
  589. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  590. $order = array (
  591. "\r\n",
  592. "\n",
  593. "\r"
  594. );
  595. $replace = '<br/>';
  596. $explanation = str_replace ( $order, $replace, $explanation );
  597. $receipt->explanation = $explanation;
  598. $receipt->receiptClass = $receiptClass;
  599. $receipt->itinerary2=$itinerary;
  600. $receipt->remittanceName = $remittanceName;
  601. $receipt->bankName = $bankName;
  602. $receipt->bankNumber = $bankNumber;
  603. $receipt->remittanceBankType = $remittanceBankType;
  604. if ($remittanceBankType == 1) {
  605. $receipt->coupletNumber = $coupletNumber;
  606. }
  607. $rid = $receipt->insert ();
  608. //记录行程单
  609. $this->_storageItinerary($itinerary,$rid);
  610. // 附件
  611. if (! empty ( $enclosurName )) {
  612. $enclosurArray = explode ( '-', $enclosurName );
  613. foreach ( $enclosurArray as $value ) {
  614. $enclosur = new enclosur ();
  615. $enclosur->name = $value;
  616. $enclosur->rid = $rid;
  617. $enclosur->insert ();
  618. }
  619. }
  620. // 报销详情
  621. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  622. $receiptDetail = new receiptDetail ();
  623. $receiptDetail->staff = $this->staff [0] ['sid'];
  624. $receiptDetail->item = $value ['name'];
  625. $receiptDetail->itemCategory = $this->AGENCY;
  626. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  627. $receiptDetail->date = date ( "Y-m-d" );
  628. $receiptDetail->cid = $cid;
  629. $receiptDetail->rid = $rid;
  630. $receiptDetail->status = 4;
  631. $receiptDetail->insert ();
  632. }
  633. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  634. $receiptDetail = new receiptDetail ();
  635. $receiptDetail->staff = $this->staff [0] ['sid'];
  636. $receiptDetail->item = $value ['name'];
  637. $receiptDetail->itemCategory = $this->TRAVEL;
  638. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  639. $receiptDetail->date = date ( "Y-m-d" );
  640. $receiptDetail->cid = $cid;
  641. $receiptDetail->rid = $rid;
  642. $receiptDetail->status = 4;
  643. $receiptDetail->insert ();
  644. }
  645. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  646. $receiptDetail = new receiptDetail ();
  647. $receiptDetail->staff = $this->staff [0] ['sid'];
  648. $receiptDetail->item = $value ['name'];
  649. $receiptDetail->itemCategory = $this->TRAIN;
  650. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  651. $receiptDetail->date = date ( "Y-m-d" );
  652. $receiptDetail->cid = $cid;
  653. $receiptDetail->rid = $rid;
  654. $receiptDetail->status = 4;
  655. $receiptDetail->insert ();
  656. }
  657. // 内训
  658. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  659. $receiptDetail = new receiptDetail ();
  660. $receiptDetail->staff = $this->staff [0] ['sid'];
  661. $receiptDetail->item = $value ['name'];
  662. $receiptDetail->itemCategory = $this->INTTRAIN;
  663. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  664. $receiptDetail->date = date ( "Y-m-d" );
  665. $receiptDetail->cid = $cid;
  666. $receiptDetail->rid = $rid;
  667. $receiptDetail->status = 4;
  668. $receiptDetail->insert ();
  669. }
  670. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  671. $receiptDetail = new receiptDetail ();
  672. $receiptDetail->staff = $this->staff [0] ['sid'];
  673. $receiptDetail->item = $value ['name'];
  674. $receiptDetail->itemCategory = $this->OTHER;
  675. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  676. $receiptDetail->date = date ( "Y-m-d" );
  677. $receiptDetail->cid = $cid;
  678. $receiptDetail->rid = $rid;
  679. $receiptDetail->status = 4;
  680. $receiptDetail->insert ();
  681. }
  682. return true;
  683. } else
  684. return false;
  685. }
  686. function addReceipt() {
  687. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  688. if ($this->_buildFeeData(1)) {
  689. return "/saeaBorad";
  690. } else{
  691. die ( 'illegal request' );
  692. }
  693. }
  694. function addFeeTravel(){
  695. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  696. $itineraryList=json_decode($itinerary,true);
  697. // foreach ($itineraryList as $key=>$value){
  698. // if(empty($value['departuredate'])||empty($value['departurecity'])){
  699. // header ( 'Content-Type:text/html;charset=utf-8' );
  700. // die ( '请设置出发地和出发日期' );
  701. // }
  702. // }
  703. if ($this->_buildFeeData(2,$itinerary)) {
  704. return "/saeaBorad?travel=success";
  705. } else{
  706. die ( 'illegal request' );
  707. }
  708. }
  709. function addFeeInternalTrain(){
  710. if ($this->_buildFeeData(3)) {
  711. return "/saeaBorad";
  712. } else{
  713. die ( 'illegal request' );
  714. }
  715. }
  716. function referReceipt() {
  717. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  718. Doo::loadModel ( 'receipt' );
  719. Doo::loadModel ( 'verify' );
  720. $verify = new verify ();
  721. $receipt = new receipt ();
  722. Doo::loadModel ( 'L_category' );
  723. $lCategory = new L_category ();
  724. Doo::loadModel ( "role" );
  725. $role = new role ();
  726. $receiptDetail = $receipt->find ( array (
  727. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  728. 'asArray' => true
  729. ) );
  730. if (empty ( $receiptDetail ))
  731. return "/addReceipt";
  732. foreach ( $receiptDetail as $key => $value ) {
  733. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  734. $veList = $verify->getOne ( array (
  735. 'where' => 'vid=' . $value ['verify'],
  736. 'asArray' => true
  737. ) );
  738. $v = json_decode ( $veList ['staff'] );
  739. array_push ( $v [0], $veList ['description'] );
  740. foreach ( $v as $n => $m ) {
  741. if ($m ['1'] == 'ROLE') {
  742. $roleInfo = $role->getOne ( array (
  743. 'where' => 'rid=' . $m [0],
  744. 'asArray' => true
  745. ) );
  746. $v [$n] [1] = $roleInfo ['name'];
  747. }
  748. }
  749. $receiptDetail [$key] ['staff'] = $v;
  750. $category = $lCategory->getOne ( array (
  751. 'where' => 'cid=' . $value ['cid'],
  752. 'asArray' => true
  753. ) );
  754. $receiptDetail [$key] ['category'] = $category ['title'];
  755. }
  756. // print_r($receiptDetail);
  757. $data ['receiptDetail'] = $receiptDetail;
  758. $data ['memu'] = "receipt";
  759. $data ['staff'] = $this->staff;
  760. $data ['receiptMemu'] = 'saeaCreate';
  761. $data ['verifyId'] = $this->verifyId;
  762. $data ['executeId'] = $this->executeId;
  763. $this->render ( "/admin/saea_confirm", $data );
  764. }
  765. function editReceipt() {
  766. // edit status 4
  767. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  768. Doo::loadClass ( 'XDeode' );
  769. $XDeode = new XDeode ( 7 );
  770. $rid = $XDeode->decode ( $ridKey );
  771. if (empty ( $rid )) {
  772. die ( 'illegal request-id' );
  773. }
  774. // echo $rid.'sd';
  775. Doo::loadModel ( 'accountItem' );
  776. Doo::loadModel ( 'verify' );
  777. Doo::loadModel ( 'receipt' );
  778. $receipt = new receipt ();
  779. $verify = new verify ();
  780. $accountItem = new accountItem ();
  781. Doo::loadModel ( 'L_category' );
  782. $lCategory = new L_category ();
  783. Doo::loadModel ( "role" );
  784. $role = new role ();
  785. Doo::loadModel ( 'enclosur' );
  786. $enclosur = new enclosur ();
  787. $receiptDetail = $receipt->getOne ( array (
  788. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  789. 'asArray' => true
  790. ) );
  791. if (empty ( $receiptDetail )) {
  792. die ( 'illegal request-emptyData' );
  793. }
  794. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  795. $acItem = $accountItem->find ( array (
  796. 'asArray' => true
  797. ) );
  798. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  799. // 配置编辑信息
  800. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  801. foreach ( $acItem as $key => $value ) {
  802. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  803. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  804. $acItem [$key] ['price'] = $v ['price'];
  805. }
  806. }
  807. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  808. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  809. $acItem [$key] ['price'] = $v ['price'];
  810. }
  811. }
  812. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  813. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  814. $acItem [$key] ['price'] = $v ['price'];
  815. }
  816. }
  817. // 内训
  818. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  819. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  820. $acItem [$key] ['price'] = $v ['price'];
  821. }
  822. }
  823. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  824. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  825. $acItem [$key] ['price'] = $v ['price'];
  826. }
  827. }
  828. }
  829. //$receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  830. //nl2br($receiptDetail['explanation']);
  831. Doo::loadModel ( 'itinerary' );
  832. $itinerary = new itinerary ();
  833. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  834. $receiptDetail['explanation']= str_replace('<br/>',"\n",$receiptDetail['explanation']);
  835. $receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  836. $data ['category'] = $lCategory->find ( array (
  837. 'asArray' => true
  838. ) );
  839. $data ['cSum'] = $accountItemList ['cSum'];
  840. $data ['sum'] = $receiptDetail ['sum'];
  841. $data ['enclosurList'] = $enclosurList;
  842. $data ['receiptDetail'] = $receiptDetail;
  843. $data ['veList'] = $veList;
  844. $data ['acItem'] = $acItem;
  845. $data ['memu'] = "receipt";
  846. $data ['staff'] = $this->staff;
  847. $data ['receiptMemu'] = 'saeaBorad';
  848. $data ['verify'] = $receiptDetail ['verify'];
  849. $data ['verifyId'] = $this->verifyId;
  850. $data ['executeId'] = $this->executeId;
  851. $data ['rid'] = $ridKey;
  852. if($receiptDetail['receiptClass']==1){
  853. $this->render ( "/receipt/feeAgencyEdi", $data );
  854. }elseif($receiptDetail['receiptClass']==2){
  855. if(!empty($receiptDetail['itinerary2'])){
  856. //TODO 报销说明
  857. $this->render ( "/receipt/feeTravelEdi2", $data );
  858. }else{
  859. $this->render ( "/receipt/feeTravelEdi", $data );
  860. }
  861. }elseif($receiptDetail['receiptClass']==3){
  862. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  863. }else{
  864. $this->render ( "/admin/saea_edit", $data );
  865. //die ( 'illegal request-renderHtml' );
  866. }
  867. }
  868. function updateReceipt() {
  869. $agency = $this->get_args ( 'agency' );
  870. $travel = $this->get_args ( 'travel' );
  871. $train = $this->get_args ( 'train' );
  872. $other = $this->get_args ( 'other' );
  873. $inttrain = $this->get_args ( 'inttrain' );
  874. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  875. $traveVer = $this->get_args ( 'traveVer' ) ? $this->get_args ( 'traveVer' ) : "trave2";
  876. $itinerary = $_POST['itinerary'];
  877. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  878. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  879. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  880. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  881. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  882. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  883. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  884. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  885. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  886. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  887. Doo::loadClass ( 'XDeode' );
  888. $XDeode = new XDeode ( 7 );
  889. $rid = $XDeode->decode ( $ridKey );
  890. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  891. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  892. header ( 'Content-Type:text/html;charset=utf-8' );
  893. die ( '请填写联行号' );
  894. }
  895. if($traveVer!='trave1'){
  896. if($receiptClass=='trave'){
  897. //TODO 日期检测
  898. if($this->_verificationItinerary($itinerary)){
  899. header ( 'Content-Type:text/html;charset=utf-8' );
  900. die ( '已申请过类此日期的行程' );
  901. }
  902. }
  903. }
  904. Doo::loadModel ( 'receipt' );
  905. Doo::loadModel ( 'receiptDetail' );
  906. Doo::loadModel ( 'accountItem' );
  907. $accountItem = new accountItem ();
  908. $receipt = new receipt ();
  909. Doo::loadModel ( 'enclosur' );
  910. Doo::loadModel ( 'execute' );
  911. $execute = new execute ();
  912. $receiptDetail = $receipt->getOne ( array (
  913. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  914. 'asArray' => true
  915. ) );
  916. if (empty ( $receiptDetail )) {
  917. return "/saeaBorad";
  918. }
  919. //TODO 存储行程单-兼容旧版本的行程单
  920. $itinerary=str_replace('\n','<br/>',$itinerary);
  921. if(!empty($receiptDetail['itinerary2'])){
  922. $this->_storageItinerary($itinerary,$rid);
  923. }else{
  924. $this->_storageItinerary($itinerary,$rid,1);
  925. }
  926. if ($receiptDetail ['Rtype'] == 1) {
  927. $executeDetail = $execute->getOne ( array (
  928. 'where' => 'mold="借款费用执行人"',
  929. 'asArray' => true
  930. ) );
  931. } else {
  932. $executeDetail = $execute->getOne ( array (
  933. 'where' => 'mold="报销单执行人"',
  934. 'asArray' => true
  935. ) );
  936. }
  937. $aItem = $accountItem->find ( array (
  938. 'asArray' => true
  939. ) );
  940. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  941. $ag = $tr = $ta = $ot = $it = 0;
  942. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  943. foreach ( $aItem as $key => $value ) {
  944. if ($value ['category'] == $this->AGENCY) {
  945. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  946. array_push ( $accountJson [$this->AGENCY], array (
  947. 'aid' => $value ['aid'],
  948. 'name' => $value ['name'],
  949. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  950. ) );
  951. $sum += $agency [$ag];
  952. $agencySum += $agency [$ag];
  953. }
  954. $ag ++;
  955. }
  956. if ($value ['category'] == $this->TRAVEL) {
  957. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  958. array_push ( $accountJson [$this->TRAVEL], array (
  959. 'aid' => $value ['aid'],
  960. 'name' => $value ['name'],
  961. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  962. ) );
  963. $sum += $travel [$tr];
  964. $travelSum += $travel [$tr];
  965. }
  966. $tr ++;
  967. }
  968. if ($value ['category'] == $this->TRAIN) {
  969. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  970. array_push ( $accountJson [$this->TRAIN], array (
  971. 'aid' => $value ['aid'],
  972. 'name' => $value ['name'],
  973. 'price' => number_format ( $train [$ta], 2, '.', '' )
  974. ) );
  975. $sum += $train [$ta];
  976. $trainSum += $train [$ta];
  977. }
  978. $ta ++;
  979. }
  980. if ($value ['category'] == $this->INTTRAIN) {
  981. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  982. array_push ( $accountJson [$this->INTTRAIN], array (
  983. 'aid' => $value ['aid'],
  984. 'name' => $value ['name'],
  985. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  986. ) );
  987. $sum += $inttrain [$it];
  988. $inttrainSum += $inttrain [$it];
  989. }
  990. $it ++;
  991. }
  992. if ($value ['category'] == $this->OTHER) {
  993. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  994. array_push ( $accountJson [$this->OTHER], array (
  995. 'aid' => $value ['aid'],
  996. 'name' => $value ['name'],
  997. 'price' => number_format ( $other [$ot], 2, '.', '' )
  998. ) );
  999. $sum += $other [$ot];
  1000. $otherSum += $other [$ot];
  1001. }
  1002. $ot ++;
  1003. }
  1004. }
  1005. $accountJson ['cSum'] = array (
  1006. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1007. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1008. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1009. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  1010. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1011. );
  1012. // 报销单
  1013. $rid = $receipt->rid = $receiptDetail ['rid'];
  1014. $receipt->accountItem = json_encode ( $accountJson );
  1015. $receipt->staff = $this->staff [0] ['sid'];
  1016. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1017. $receipt->date = date ( "Y-m-d" );
  1018. $receipt->cid = $cid;
  1019. if (($receiptDetail ['status'] != 4)) {
  1020. if ($receiptDetail ['Rtype'] == 1) {
  1021. $receipt->status = 7;
  1022. } else {
  1023. $receipt->status = 5;
  1024. }
  1025. }
  1026. if ($receiptDetail != 4 && ! empty ( $verify ))
  1027. $receipt->verify = $verify;
  1028. $receipt->executeCopy = $executeDetail ['staff'];
  1029. $order = array (
  1030. "\r\n",
  1031. "\n",
  1032. "\r"
  1033. );
  1034. $replace = '<br/>';
  1035. $explanation = str_replace ( $order, $replace, $explanation );
  1036. $receipt->explanation = $explanation;
  1037. if($receiptClass=='trave'){
  1038. if(!empty($receiptDetail['itinerary2'])){//行程单版本
  1039. $receipt->itinerary2=$itinerary;
  1040. }else{
  1041. $receipt->itinerary=$itinerary;
  1042. }
  1043. }
  1044. $receipt->remittanceName = $remittanceName;
  1045. $receipt->bankName = $bankName;
  1046. $receipt->bankNumber = $bankNumber;
  1047. $receipt->remittanceBankType = $remittanceBankType;
  1048. if ($remittanceBankType == 1)
  1049. $receipt->coupletNumber = $coupletNumber;
  1050. $receipt->update ();
  1051. $receiptDetail = new receiptDetail ();
  1052. $receiptDetail->delete ( array (
  1053. 'where' => 'rid=' . $rid
  1054. ) );
  1055. // 报销详情
  1056. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1057. $receiptDetail = new receiptDetail ();
  1058. $receiptDetail->staff = $this->staff [0] ['sid'];
  1059. $receiptDetail->item = $value ['name'];
  1060. $receiptDetail->itemCategory = $this->AGENCY;
  1061. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1062. $receiptDetail->date = date ( "Y-m-d" );
  1063. $receiptDetail->cid = $cid;
  1064. $receiptDetail->rid = $rid;
  1065. $receiptDetail->status = 4;
  1066. $receiptDetail->insert ();
  1067. }
  1068. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1069. $receiptDetail = new receiptDetail ();
  1070. $receiptDetail->staff = $this->staff [0] ['sid'];
  1071. $receiptDetail->item = $value ['name'];
  1072. $receiptDetail->itemCategory = $this->TRAVEL;
  1073. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1074. $receiptDetail->date = date ( "Y-m-d" );
  1075. $receiptDetail->cid = $cid;
  1076. $receiptDetail->rid = $rid;
  1077. $receiptDetail->status = 4;
  1078. $receiptDetail->insert ();
  1079. }
  1080. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1081. $receiptDetail = new receiptDetail ();
  1082. $receiptDetail->staff = $this->staff [0] ['sid'];
  1083. $receiptDetail->item = $value ['name'];
  1084. $receiptDetail->itemCategory = $this->TRAIN;
  1085. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1086. $receiptDetail->date = date ( "Y-m-d" );
  1087. $receiptDetail->cid = $cid;
  1088. $receiptDetail->rid = $rid;
  1089. $receiptDetail->status = 4;
  1090. $receiptDetail->insert ();
  1091. }
  1092. // 内训
  1093. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1094. $receiptDetail = new receiptDetail ();
  1095. $receiptDetail->staff = $this->staff [0] ['sid'];
  1096. $receiptDetail->item = $value ['name'];
  1097. $receiptDetail->itemCategory = $this->INTTRAIN;
  1098. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1099. $receiptDetail->date = date ( "Y-m-d" );
  1100. $receiptDetail->cid = $cid;
  1101. $receiptDetail->rid = $rid;
  1102. $receiptDetail->status = 4;
  1103. $receiptDetail->insert ();
  1104. }
  1105. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1106. $receiptDetail = new receiptDetail ();
  1107. $receiptDetail->staff = $this->staff [0] ['sid'];
  1108. $receiptDetail->item = $value ['name'];
  1109. $receiptDetail->itemCategory = $this->OTHER;
  1110. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1111. $receiptDetail->date = date ( "Y-m-d" );
  1112. $receiptDetail->cid = $cid;
  1113. $receiptDetail->rid = $rid;
  1114. $receiptDetail->status = 4;
  1115. $receiptDetail->insert ();
  1116. }
  1117. // 附件
  1118. if (! empty ( $enclosurName )) {
  1119. $enclosurArray = explode ( '-', $enclosurName );
  1120. foreach ( $enclosurArray as $value ) {
  1121. $enclosur = new enclosur ();
  1122. $enclosur->name = $value;
  1123. $enclosur->rid = $rid;
  1124. $enclosur->insert ();
  1125. }
  1126. }
  1127. // return "/referReceipt/".$rid;
  1128. }
  1129. return "/saeaBorad";
  1130. }
  1131. function remitAdd() {
  1132. Doo::loadModel ( 'accountItem' );
  1133. Doo::loadModel ( 'verify' );
  1134. Doo::loadModel ( 'receipt' );
  1135. Doo::loadModel ( 'L_category' );
  1136. $lCategory = new L_category ();
  1137. $receipt = new receipt ();
  1138. $verify = new verify ();
  1139. $accountItem = new accountItem ();
  1140. Doo::loadModel ( "role" );
  1141. $role = new role ();
  1142. $acItem = $accountItem->find ( array (
  1143. 'asArray' => true
  1144. ) );
  1145. $veList = $verify->getVerifyBySubordinate('REMIT');
  1146. $data ['category'] = $lCategory->find ( array (
  1147. 'asArray' => true
  1148. ) );
  1149. $data ['veList'] = $veList;
  1150. $data ['acItem'] = $acItem;
  1151. $data ['memu'] = "receipt";
  1152. $data ['staff'] = $this->staff;
  1153. $data ['receiptMemu'] = 'saeaBorad';
  1154. $data ['verifyId'] = $this->verifyId;
  1155. $data ['executeId'] = $this->executeId;
  1156. $this->render ( "/admin/remitAdd", $data );
  1157. }
  1158. function remitAddDo() {
  1159. $agency = $this->get_args ( 'agency' );
  1160. $travel = $this->get_args ( 'travel' );
  1161. $train = $this->get_args ( 'train' );
  1162. $other = $this->get_args ( 'other' );
  1163. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1164. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1165. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1166. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1167. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1168. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1169. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1170. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1171. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1172. // print_r($agency);die;
  1173. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1174. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1175. header ( 'Content-Type:text/html;charset=utf-8' );
  1176. die ( '请填写联行号' );
  1177. }
  1178. Doo::loadModel ( 'receipt' );
  1179. Doo::loadModel ( 'receiptDetail' );
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $receipt = new receipt ();
  1183. Doo::loadModel ( 'enclosur' );
  1184. Doo::loadModel ( 'execute' );
  1185. $execute = new execute ();
  1186. $executeDetail = $execute->getOne ( array (
  1187. 'where' => 'mold="对公汇款执行人"',
  1188. 'asArray' => true
  1189. ) );
  1190. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1191. $aItem = $accountItem->find ( array (
  1192. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1193. 'asArray' => true
  1194. ) );
  1195. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1196. $ag = $tr = $ta = $ot = 0;
  1197. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1198. print_r($aItem);
  1199. foreach ( $aItem as $key => $value ) {
  1200. if ($value ['category'] == $this->AGENCY) {
  1201. if (isset ( $agency [$ag] )) {
  1202. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1203. array_push ( $accountJson [$this->AGENCY], array (
  1204. 'aid' => $value ['aid'],
  1205. 'name' => $value ['name'],
  1206. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1207. ) );
  1208. $sum += $agency [$ag];
  1209. $agencySum += $agency [$ag];
  1210. }
  1211. }
  1212. $ag ++;
  1213. }
  1214. }
  1215. $accountJson ['cSum'] = array (
  1216. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1217. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1218. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1219. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1220. );
  1221. //die;
  1222. // 报销单
  1223. $receipt->accountItem = json_encode ( $accountJson );
  1224. $receipt->staff = $this->staff [0] ['sid'];
  1225. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1226. $receipt->date = date ( "Y-m-d" );
  1227. $receipt->cid = $cid;
  1228. $receipt->status = 5;
  1229. $receipt->Rtype = 2;
  1230. // 修改审批流程加入角色
  1231. $receipt->verify = $verify;
  1232. $receipt->executeCopy = $executeDetail ['staff'];
  1233. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1234. $order = array (
  1235. "\r\n",
  1236. "\n",
  1237. "\r"
  1238. );
  1239. $replace = '<br/>';
  1240. $explanation = str_replace ( $order, $replace, $explanation );
  1241. $receipt->explanation = $explanation;
  1242. $receipt->remittanceName = $remittanceName;
  1243. $receipt->bankName = $bankName;
  1244. $receipt->bankNumber = $bankNumber;
  1245. $receipt->remittanceBankType = $remittanceBankType;
  1246. if ($remittanceBankType == 1)
  1247. $receipt->coupletNumber = $coupletNumber;
  1248. $rid = $receipt->insert ();
  1249. // 附件
  1250. if (! empty ( $enclosurName )) {
  1251. $enclosurArray = explode ( '-', $enclosurName );
  1252. foreach ( $enclosurArray as $value ) {
  1253. $enclosur = new enclosur ();
  1254. $enclosur->name = $value;
  1255. $enclosur->rid = $rid;
  1256. $enclosur->insert ();
  1257. }
  1258. // print_r($enclosurArray);die;
  1259. }
  1260. // 报销详情
  1261. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1262. $receiptDetail = new receiptDetail ();
  1263. $receiptDetail->staff = $this->staff [0] ['sid'];
  1264. $receiptDetail->item = $value ['name'];
  1265. $receiptDetail->itemCategory = $this->AGENCY;
  1266. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1267. $receiptDetail->date = date ( "Y-m-d" );
  1268. $receiptDetail->cid = $cid;
  1269. $receiptDetail->rid = $rid;
  1270. $receiptDetail->status = 4;
  1271. $receiptDetail->insert ();
  1272. }
  1273. return "/saeaBorad";
  1274. } else
  1275. die ( 'illegal request' );
  1276. }
  1277. function remitEdit() {
  1278. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1279. Doo::loadClass ( 'XDeode' );
  1280. $XDeode = new XDeode ( 7 );
  1281. $rid = $XDeode->decode ( $ridKey );
  1282. if (! is_numeric ( $rid ))
  1283. die ( 'illegal request' );
  1284. Doo::loadModel ( 'accountItem' );
  1285. Doo::loadModel ( 'verify' );
  1286. Doo::loadModel ( 'receipt' );
  1287. $receipt = new receipt ();
  1288. $verify = new verify ();
  1289. $accountItem = new accountItem ();
  1290. Doo::loadModel ( 'L_category' );
  1291. $lCategory = new L_category ();
  1292. Doo::loadModel ( "role" );
  1293. $role = new role ();
  1294. Doo::loadModel ( 'enclosur' );
  1295. $enclosur = new enclosur ();
  1296. $receiptDetail = $receipt->getOne ( array (
  1297. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1298. 'asArray' => true
  1299. ) );
  1300. if (empty ( $receiptDetail ))
  1301. return "/saeaCreate";
  1302. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1303. $acItem = $accountItem->find ( array (
  1304. 'asArray' => true
  1305. ) );
  1306. $veList = $verify->getVerifyBySubordinate('REMIT');
  1307. // 配置编辑信息
  1308. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1309. foreach ( $acItem as $key => $value ) {
  1310. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1311. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1312. $acItem [$key] ['price'] = $v ['price'];
  1313. }
  1314. }
  1315. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1316. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1317. $acItem [$key] ['price'] = $v ['price'];
  1318. }
  1319. }
  1320. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1321. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1322. $acItem [$key] ['price'] = $v ['price'];
  1323. }
  1324. }
  1325. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1326. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1327. $acItem [$key] ['price'] = $v ['price'];
  1328. }
  1329. }
  1330. }
  1331. $data ['category'] = $lCategory->find ( array (
  1332. 'asArray' => true
  1333. ) );
  1334. $data ['enclosurList'] = $enclosurList;
  1335. $data ['cSum'] = $accountItemList ['cSum'];
  1336. $data ['sum'] = $receiptDetail ['sum'];
  1337. $data ['receiptDetail'] = $receiptDetail;
  1338. $data ['veList'] = $veList;
  1339. $data ['acItem'] = $acItem;
  1340. $data ['memu'] = "receipt";
  1341. $data ['staff'] = $this->staff;
  1342. $data ['receiptMemu'] = 'saeaBorad';
  1343. $data ['verify'] = $receiptDetail ['verify'];
  1344. $data ['verifyId'] = $this->verifyId;
  1345. $data ['executeId'] = $this->executeId;
  1346. $data ['rid'] = $rid;
  1347. $data ['ridKey'] = $ridKey;
  1348. $this->render ( "/admin/remitEdit", $data );
  1349. }
  1350. function remitEdiDo() {
  1351. $agency = $this->get_args ( 'agency' );
  1352. $travel = $this->get_args ( 'travel' );
  1353. $train = $this->get_args ( 'train' );
  1354. $other = $this->get_args ( 'other' );
  1355. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1356. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1357. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1358. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1359. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1360. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1361. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1362. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1363. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1364. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1365. Doo::loadClass ( 'XDeode' );
  1366. $XDeode = new XDeode ( 7 );
  1367. $rid = $XDeode->decode ( $ridKey );
  1368. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1369. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1370. header ( 'Content-Type:text/html;charset=utf-8' );
  1371. die ( '请填写联行号' );
  1372. }
  1373. Doo::loadModel ( 'receipt' );
  1374. Doo::loadModel ( 'receiptDetail' );
  1375. Doo::loadModel ( 'accountItem' );
  1376. $accountItem = new accountItem ();
  1377. $receipt = new receipt ();
  1378. Doo::loadModel ( 'enclosur' );
  1379. $enclosur = new enclosur ();
  1380. Doo::loadModel ( 'execute' );
  1381. $execute = new execute ();
  1382. $executeDetail = $execute->getOne ( array (
  1383. 'where' => 'mold="对公汇款执行人"',
  1384. 'asArray' => true
  1385. ) );
  1386. $receiptDetail = $receipt->getOne ( array (
  1387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1388. 'asArray' => true
  1389. ) );
  1390. if (empty ( $receiptDetail ))
  1391. return "/saeaBorad";
  1392. $aItem = $accountItem->find ( array (
  1393. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1394. 'asArray' => true
  1395. ) );
  1396. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1397. $ag = $tr = $ta = $ot = 0;
  1398. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1399. foreach ( $aItem as $key => $value ) {
  1400. if ($value ['category'] == $this->AGENCY) {
  1401. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1402. array_push ( $accountJson [$this->AGENCY], array (
  1403. 'aid' => $value ['aid'],
  1404. 'name' => $value ['name'],
  1405. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1406. ) );
  1407. $sum += $agency [$ag];
  1408. $agencySum += $agency [$ag];
  1409. }
  1410. $ag ++;
  1411. }
  1412. }
  1413. $accountJson ['cSum'] = array (
  1414. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1415. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1416. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1417. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1418. );
  1419. // 报销单
  1420. $rid = $receipt->rid = $receiptDetail ['rid'];
  1421. $receipt->accountItem = json_encode ( $accountJson );
  1422. $receipt->staff = $this->staff [0] ['sid'];
  1423. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1424. $receipt->date = date ( "Y-m-d" );
  1425. $receipt->cid = $cid;
  1426. if ($receiptDetail ['Rtype'] == 1)
  1427. $receipt->status = 7;
  1428. else
  1429. $receipt->status = 5;
  1430. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1431. $receipt->verify = $verify;
  1432. $receipt->executeCopy = $executeDetail ['staff'];
  1433. $order = array (
  1434. "\r\n",
  1435. "\n",
  1436. "\r"
  1437. );
  1438. $replace = '<br/>';
  1439. $explanation = str_replace ( $order, $replace, $explanation );
  1440. $receipt->explanation = $explanation;
  1441. $receipt->remittanceName = $remittanceName;
  1442. $receipt->bankName = $bankName;
  1443. $receipt->bankNumber = $bankNumber;
  1444. $receipt->remittanceBankType = $remittanceBankType;
  1445. if ($remittanceBankType == 1)
  1446. $receipt->coupletNumber = $coupletNumber;
  1447. $receipt->update ();
  1448. $receiptDetail = new receiptDetail ();
  1449. $receiptDetail->delete ( array (
  1450. 'where' => 'rid=' . $rid
  1451. ) );
  1452. // 报销详情
  1453. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1454. $receiptDetail = new receiptDetail ();
  1455. $receiptDetail->staff = $this->staff [0] ['sid'];
  1456. $receiptDetail->item = $value ['name'];
  1457. $receiptDetail->itemCategory = $this->AGENCY;
  1458. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1459. $receiptDetail->date = date ( "Y-m-d" );
  1460. $receiptDetail->cid = $cid;
  1461. $receiptDetail->rid = $rid;
  1462. $receiptDetail->status = 4;
  1463. $receiptDetail->insert ();
  1464. }
  1465. // 附件
  1466. if (! empty ( $enclosurName )) {
  1467. $enclosurArray = explode ( '-', $enclosurName );
  1468. foreach ( $enclosurArray as $value ) {
  1469. $enclosur = new enclosur ();
  1470. $enclosur->name = $value;
  1471. $enclosur->rid = $rid;
  1472. $enclosur->insert ();
  1473. }
  1474. }
  1475. }
  1476. return "/saeaBorad";
  1477. }
  1478. function remitApproval() {
  1479. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1480. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1482. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1483. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1484. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1485. if (empty ( $status ))
  1486. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1487. $vidList = array ();
  1488. $button = 0;
  1489. Doo::loadModel ( 'verify' );
  1490. Doo::loadModel ( 'receipt' );
  1491. Doo::loadModel ( 'staff' );
  1492. $staff = new staff ();
  1493. $receipt = new receipt ();
  1494. $verify = new verify ();
  1495. Doo::loadModel ( 'L_category' );
  1496. $Lcategory = new L_category ();
  1497. Doo::loadModel ( 'enclosur' );
  1498. $enclosur = new enclosur ();
  1499. // user verify ID
  1500. $verifyDetail = $verify->find ( array (
  1501. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1502. 'asArray' => true
  1503. ) );
  1504. foreach ( $verifyDetail as $key => $value ) {
  1505. array_push ( $vidList, $value ['vid'] );
  1506. }
  1507. $vid = implode ( ",", $vidList );
  1508. if (empty ( $verifyDetail ))
  1509. $vid = 0;
  1510. $categoryList = $Lcategory->find ( array (
  1511. 'asArray' => true
  1512. ) );
  1513. $staffList = $staff->find ( array (
  1514. 'where' => 'cid=' . $cid,
  1515. 'asArray' => true
  1516. ) );
  1517. $ap = "";
  1518. if ($status == 4) {
  1519. $ap = 4;
  1520. $status = 2;
  1521. }
  1522. // get Receipt By verifyID status 2
  1523. $receiptList = $receipt->find ( array (
  1524. 'where' => 'rid =' . $rid . ' and status=2',
  1525. 'desc' => 'rid',
  1526. 'asArray' => true
  1527. ) );
  1528. if (empty ( $receiptList )) {
  1529. die ( 'illegal request' );
  1530. }
  1531. $Locate = 0;
  1532. $roleId = 0;
  1533. if ($ap == 4)
  1534. $status = 4;
  1535. foreach ( $receiptList as $key => $value ) {
  1536. $receiptList [$key] ['Locate'] = $Locate;
  1537. $Locate ++;
  1538. $receiptList [$key] ['reviseDetail'] = array ();
  1539. if (! empty ( $value ['reviseDetail'] ))
  1540. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1541. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1542. $categoryDetil = $Lcategory->getOne ( array (
  1543. 'where' => 'cid=' . $value ['cid'],
  1544. 'asArray' => true
  1545. ) );
  1546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1547. // 检测编辑状态
  1548. $verifyList = $verify->getOne ( array (
  1549. 'where' => 'vid=' . $value ['verify'],
  1550. 'asArray' => true
  1551. ) );
  1552. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1553. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1554. Doo::loadModel ( 'role' );
  1555. $role = new role ();
  1556. // print_r($verifyList);
  1557. $flag = true;
  1558. $roleKey = 0;
  1559. $endStaffArray = array ();
  1560. $roleArrayCopy = array ();
  1561. foreach ( $verifyList as $k => $v ) {
  1562. // init verifyStaff
  1563. if ($v [1] == 'ROLE') {
  1564. if (! empty ( $verifyStaff )) {
  1565. $endStaffArray = end ( $verifyStaff );
  1566. if ($v [0] == $endStaffArray ['nextStaff']) {
  1567. $roleId = $v [0];
  1568. }
  1569. }
  1570. $roleVerify = json_decode ( $v [3], true );
  1571. $roleKey = $k;
  1572. $roleArray = array ();
  1573. $rolename = $role->getOne ( array (
  1574. 'where' => 'rid=' . $v [0],
  1575. 'asArray' => true
  1576. ) );
  1577. foreach ( $roleVerify as $o => $p ) {
  1578. $staffID = explode ( '_', $p );
  1579. $staffInfo = $staff->getOne ( array (
  1580. 'where' => 'sid=' . $staffID [0],
  1581. 'asArray' => true
  1582. ) );
  1583. // print_r($staffID);
  1584. $exp = array (
  1585. 0 => $staffInfo ['sid'],
  1586. 1 => $staffID [1],
  1587. 2 => $staffInfo ['avatar'],
  1588. 'date' => '',
  1589. 'date' => '',
  1590. 'opinion' => '',
  1591. 'status' => '',
  1592. 'rolename' => $rolename ['name']
  1593. );
  1594. array_push ( $roleArray, $exp );
  1595. }
  1596. $roleArrayCopy [$v [0]] = $roleArray;
  1597. // $verifyList[$k]['roleArray']=$roleArray;
  1598. }
  1599. // print_r($roleArray);
  1600. $verifyList [$k] ['date'] = "";
  1601. $verifyList [$k] ['opinion'] = "";
  1602. $verifyList [$k] ['status'] = "";
  1603. if (empty ( $verifyStaff )) {
  1604. $verifyList [$k] ['date'] = "";
  1605. $verifyList [$k] ['opinion'] = "";
  1606. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1607. $verifyList [$k] ['status'] = 4;
  1608. $button = 4;
  1609. $flag = false;
  1610. }
  1611. } else {
  1612. foreach ( $verifyStaff as $m => $u ) {
  1613. if ($v [0] == $m) {
  1614. $verifyList [$k] ['date'] = $u ['date'];
  1615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1616. $verifyList [$k] ['status'] = $u ['status'];
  1617. $flag = false;
  1618. break;
  1619. }
  1620. }
  1621. $endStaffArray = end ( $verifyStaff );
  1622. if (isset ( $endStaffArray ['ROLE'] )) {
  1623. } else {
  1624. $endKey = key ( $verifyStaff );
  1625. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1626. $button = 4;
  1627. $verifyList [$k] ['status'] = 4;
  1628. }
  1629. }
  1630. }
  1631. }
  1632. $rolename ['name'] = '';
  1633. if (! empty ( $roleId )) {
  1634. Doo::loadModel ( 'role' );
  1635. $role = new role ();
  1636. $rolename = $role->getOne ( array (
  1637. 'where' => 'rid=' . $roleId,
  1638. 'asArray' => true
  1639. ) );
  1640. }
  1641. if (! empty ( $verifyStaff ))
  1642. $endStaffArray = end ( $verifyStaff );
  1643. $KOP = false;
  1644. foreach ( $roleArrayCopy as $P => $A ) {
  1645. foreach ( $A as $MKI => $AVL ) {
  1646. if (! empty ( $verifyStaff )) {
  1647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1649. $button = 4;
  1650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1651. }
  1652. foreach ( $verifyStaff as $m => $u ) {
  1653. $AVLFK = $AVL [0] . '_R';
  1654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1659. break;
  1660. }
  1661. }
  1662. } else {
  1663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1664. $button = 4;
  1665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1666. }
  1667. }
  1668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1669. $KOP = true;
  1670. }
  1671. }
  1672. foreach ( $roleArrayCopy as $k => $v ) {
  1673. foreach ( $verifyList as $m => $n ) {
  1674. if ($n [0] == $k) {
  1675. array_splice ( $verifyList, $m, 1, $v );
  1676. }
  1677. }
  1678. }
  1679. $receiptList [$key] ['verifyList'] = $verifyList;
  1680. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1681. 'where' => 'sid=' . $value ['staff'],
  1682. 'asArray' => true
  1683. ) );
  1684. $receiptList [$key] ['button'] = $button;
  1685. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1686. }
  1687. $mothHtml = "";
  1688. for($i = 1; $i <= 12; $i ++) {
  1689. if ($month == $i)
  1690. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1691. else
  1692. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1693. }
  1694. // 获取审批日志
  1695. Doo::loadModel ( 'receiptLog' );
  1696. $receiptLog = new receiptLog ();
  1697. $rlList = array ();
  1698. $rlInfo = $receiptLog->getOne ( array (
  1699. 'where' => 'rid=' . $rid . ' and status=4',
  1700. 'asArray' => true
  1701. ) );
  1702. $tijdate = $receiptLog->getOne ( array (
  1703. 'where' => 'rid=' . $rid . ' and status=2',
  1704. 'asc' => 'rlid',
  1705. 'asArray' => true
  1706. ) );
  1707. if (! empty ( $rlInfo )) {
  1708. $rlList = $receiptLog->find ( array (
  1709. 'where' => 'rid=' . $rid,
  1710. 'asc' => 'rlid',
  1711. 'asArray' => true
  1712. ) );
  1713. }
  1714. $receiptList [0] ['rlList'] = $rlList;
  1715. $enclosurList = $enclosur->find ( array (
  1716. 'where' => 'rid=' . $rid,
  1717. 'asArray' => true
  1718. ) );
  1719. $enclosurHtml = '';
  1720. foreach ( $enclosurList as $value ) {
  1721. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1722. }
  1723. // print_r($receiptList);
  1724. $data ['enclosurHtml'] = $enclosurHtml;
  1725. $data ['rolename'] = $rolename ['name'];
  1726. $data ['datetij'] = $tijdate ['date'];
  1727. $data ['mothHtml'] = $mothHtml;
  1728. $data ['rid'] = $rid;
  1729. $data ['receiptList'] = $receiptList;
  1730. $data ['receiptApprovalCount'] = count ( $receiptList );
  1731. $data ['status'] = $status;
  1732. $data ['year'] = $year;
  1733. $data ['categoryList'] = $categoryList;
  1734. $data ['staffList'] = $staffList;
  1735. $data ['cid'] = $cid;
  1736. $data ['sid'] = $sid;
  1737. $data ['ap'] = $ap;
  1738. $data ['memu'] = "receipt";
  1739. $data ['staff'] = $this->staff;
  1740. $data ['receiptMemu'] = 'approvalExpenses';
  1741. $data ['verifyId'] = $this->verifyId;
  1742. $data ['executeId'] = $this->executeId;
  1743. $this->render ( "/admin/remitApproval", $data );
  1744. }
  1745. function saeaLoanAdd() {
  1746. Doo::loadModel ( 'verify' );
  1747. $verify = new verify ();
  1748. Doo::loadModel ( "role" );
  1749. $role = new role ();
  1750. Doo::loadModel ( 'L_category' );
  1751. $lCategory = new L_category ();
  1752. $veList = $verify->getVerifyBySubordinate('LOAN');
  1753. $data ['category'] = $lCategory->find ( array (
  1754. 'asArray' => true
  1755. ) );
  1756. $data ['veList'] = $veList;
  1757. $data ['memu'] = "receipt";
  1758. $data ['staff'] = $this->staff;
  1759. $data ['receiptMemu'] = 'saeaBorad';
  1760. $data ['verifyId'] = $this->verifyId;
  1761. $data ['executeId'] = $this->executeId;
  1762. $this->render ( "/admin/saeaLoanAdd", $data );
  1763. }
  1764. function saeaLoanAddDo() {
  1765. $agency = $this->get_args ( 'agency' );
  1766. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1767. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1768. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1769. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1770. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1771. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1772. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1773. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1774. // die;
  1775. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1776. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1777. header ( 'Content-Type:text/html;charset=utf-8' );
  1778. die ( '请填写联行号' );
  1779. }
  1780. Doo::loadModel ( 'receipt' );
  1781. Doo::loadModel ( 'receiptDetail' );
  1782. Doo::loadModel ( 'accountItem' );
  1783. $accountItem = new accountItem ();
  1784. $receipt = new receipt ();
  1785. Doo::loadModel ( 'loanReceipt' );
  1786. $loanReceipt = new loanReceipt ();
  1787. Doo::loadModel ( 'execute' );
  1788. $execute = new execute ();
  1789. Doo::loadModel ( 'enclosur' );
  1790. $executeDetail = $execute->getOne ( array (
  1791. 'where' => 'mold="借款执行人"',
  1792. 'asArray' => true
  1793. ) );
  1794. $aItem = $accountItem->find ( array (
  1795. 'asArray' => true
  1796. ) );
  1797. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1798. $ag = $tr = $ta = $ot = 0;
  1799. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1800. array_push ( $accountJson ['借款费用'], array (
  1801. 'aid' => 0,
  1802. 'name' => '申请金额',
  1803. 'price' => number_format ( $agency, 2, '.', '' )
  1804. ) );
  1805. $sum += $agency;
  1806. $agencySum += $agency;
  1807. $accountJson ['cSum'] = array (
  1808. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1809. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1810. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1811. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1812. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1813. );
  1814. // 借款数据备份
  1815. $loanReceipt->loanItem = json_encode ( $accountJson );
  1816. $loanReceipt->staff = $this->staff [0] ['sid'];
  1817. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1818. $loanReceipt->date = date ( "Y-m-d" );
  1819. $loanReceipt->cid = $cid;
  1820. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1821. $loanReceipt->status = 5;
  1822. $loanReceipt->Rtype = 1;
  1823. $loanReceipt->verify = $verify;
  1824. $receipt->receiptOrder = $receipt->receiptOrder;
  1825. // 添加HTML换行符
  1826. // var_dump($explanation);
  1827. $order = array (
  1828. "\r\n",
  1829. "\n",
  1830. "\r"
  1831. );
  1832. $replace = '<br/>';
  1833. $explanation = str_replace ( $order, $replace, $explanation );
  1834. // $explanation=str_replace('\r',"<br/>",$explanation);
  1835. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1836. $loanReceipt->explanation = $explanation;
  1837. $loanRid = $loanReceipt->insert ();
  1838. // 报销单
  1839. $receipt->loanItem = json_encode ( $accountJson );
  1840. $receipt->staff = $this->staff [0] ['sid'];
  1841. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1842. $receipt->date = date ( "Y-m-d" );
  1843. $receipt->cid = $cid;
  1844. // 特殊状态
  1845. $receipt->status = 5;
  1846. $receipt->Rtype = 1;
  1847. $receipt->loanRid = $loanRid;
  1848. // 修改审批流程加入角色
  1849. $receipt->verify = $verify;
  1850. $receipt->executeCopy = $executeDetail ['staff'];
  1851. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1852. $receipt->explanation = $explanation;
  1853. $receipt->remittanceName = $remittanceName;
  1854. $receipt->bankName = $bankName;
  1855. $receipt->bankNumber = $bankNumber;
  1856. $receipt->remittanceBankType = $remittanceBankType;
  1857. if ($remittanceBankType == 1)
  1858. $receipt->coupletNumber = $coupletNumber;
  1859. $rid = $receipt->insert ();
  1860. return "/saeaBorad";
  1861. } else
  1862. die ( 'illegal request' );
  1863. }
  1864. function saeaLoanEdi() {
  1865. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1866. Doo::loadClass ( 'XDeode' );
  1867. $XDeode = new XDeode ( 7 );
  1868. $rid = $XDeode->decode ( $ridKey );
  1869. if (! is_numeric ( $rid ))
  1870. die ( 'illegal request' );
  1871. Doo::loadModel ( 'verify' );
  1872. $verify = new verify ();
  1873. Doo::loadModel ( "role" );
  1874. $role = new role ();
  1875. Doo::loadModel ( 'L_category' );
  1876. $lCategory = new L_category ();
  1877. Doo::loadModel ( 'receipt' );
  1878. $receipt = new receipt ();
  1879. $receiptInfo = $receipt->getOne ( array (
  1880. 'where' => 'rid=' . $rid,
  1881. 'asArray' => true
  1882. ) );
  1883. $veList = $verify->find ( array (
  1884. 'where'=>'subordinate like "%LOAN%"',
  1885. 'asArray' => true
  1886. ) );
  1887. foreach ( $veList as $key => $value ) {
  1888. $v = json_decode ( $value ['staff'] );
  1889. $list = array ();
  1890. foreach ( $v as $n => $m ) {
  1891. if ($m ['1'] == 'ROLE') {
  1892. $roleInfo = $role->getOne ( array (
  1893. 'where' => 'rid=' . $m [0],
  1894. 'asArray' => true
  1895. ) );
  1896. $v [$n] [1] = $roleInfo ['name'];
  1897. array_push ( $list, $roleInfo ['name'] );
  1898. } else {
  1899. array_push ( $list, $v [$n] [1] );
  1900. }
  1901. }
  1902. $veList [$key] ['staff'] = implode ( '>', $list );
  1903. }
  1904. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1905. // print_r($receiptInfo);
  1906. $data ['receiptInfo'] = $receiptInfo;
  1907. $data ['category'] = $lCategory->find ( array (
  1908. 'asArray' => true
  1909. ) );
  1910. $data ['veList'] = $veList;
  1911. $data ['ridKey'] = $ridKey;
  1912. $data ['memu'] = "receipt";
  1913. $data ['staff'] = $this->staff;
  1914. $data ['receiptMemu'] = 'saeaBorad';
  1915. $data ['verifyId'] = $this->verifyId;
  1916. $data ['executeId'] = $this->executeId;
  1917. $this->render ( "/admin/saeaLoanEdi", $data );
  1918. }
  1919. function saeaLoanEdiDo() {
  1920. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1921. $agency = $this->get_args ( 'agency' );
  1922. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1923. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1924. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1925. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1926. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1927. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1928. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1929. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1930. // die;
  1931. Doo::loadClass ( 'XDeode' );
  1932. $XDeode = new XDeode ( 7 );
  1933. $rid = $XDeode->decode ( $ridKey );
  1934. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1935. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1936. header ( 'Content-Type:text/html;charset=utf-8' );
  1937. die ( '请填写联行号' );
  1938. }
  1939. Doo::loadModel ( 'receipt' );
  1940. Doo::loadModel ( 'receiptDetail' );
  1941. Doo::loadModel ( 'accountItem' );
  1942. $accountItem = new accountItem ();
  1943. $receipt = new receipt ();
  1944. Doo::loadModel ( 'loanReceipt' );
  1945. $loanReceipt = new loanReceipt ();
  1946. Doo::loadModel ( 'enclosur' );
  1947. Doo::loadModel ( 'execute' );
  1948. $execute = new execute ();
  1949. $executeDetail = $execute->getOne ( array (
  1950. 'where' => 'mold="借款执行人"',
  1951. 'asArray' => true
  1952. ) );
  1953. $receiptDetail = $receipt->getOne ( array (
  1954. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1955. 'asArray' => true
  1956. ) );
  1957. if (empty ( $receiptDetail ))
  1958. die ( '参数错误' );
  1959. $aItem = $accountItem->find ( array (
  1960. 'asArray' => true
  1961. ) );
  1962. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1963. $ag = $tr = $ta = $ot = 0;
  1964. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1965. array_push ( $accountJson ['借款费用'], array (
  1966. 'aid' => 0,
  1967. 'name' => '申请金额',
  1968. 'price' => number_format ( $agency, 2, '.', '' )
  1969. ) );
  1970. $sum += $agency;
  1971. $agencySum += $agency;
  1972. $accountJson ['cSum'] = array (
  1973. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1974. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1975. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1976. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1977. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1978. );
  1979. // 报销单
  1980. $receipt->loanItem = json_encode ( $accountJson );
  1981. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1982. $receipt->cid = $cid;
  1983. // 特殊状态
  1984. // 修改审批流程加入角色
  1985. if ($receiptDetail ['status'] != 4)
  1986. $receipt->verify = $verify;
  1987. $order = array (
  1988. "\r\n",
  1989. "\n",
  1990. "\r"
  1991. );
  1992. $replace = '<br/>';
  1993. $explanation = str_replace ( $order, $replace, $explanation );
  1994. $receipt->explanation = $explanation;
  1995. $receipt->remittanceName = $remittanceName;
  1996. $receipt->bankName = $bankName;
  1997. $receipt->bankNumber = $bankNumber;
  1998. $receipt->remittanceBankType = $remittanceBankType;
  1999. if ($remittanceBankType == 1)
  2000. $receipt->coupletNumber = $coupletNumber;
  2001. $receipt->update ( array (
  2002. 'where' => 'rid=' . $rid
  2003. ) );
  2004. // 借款数据更新
  2005. $loanReceipt->loanItem = json_encode ( $accountJson );
  2006. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  2007. $loanReceipt->cid = $cid;
  2008. if ($receiptDetail ['status'] != 4)
  2009. $loanReceipt->verify = $verify;
  2010. $loanReceipt->explanation = $explanation;
  2011. $receipt->executeCopy = $executeDetail ['staff'];
  2012. $loanReceipt->update ( array (
  2013. 'where' => 'rid=' . $receiptDetail ['loanRid']
  2014. ) );
  2015. }
  2016. return "/saeaBorad";
  2017. }
  2018. function saeaLoanReceiptAdd() {
  2019. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2020. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2021. Doo::loadModel ( 'receipt' );
  2022. $receipt = new receipt ();
  2023. Doo::loadModel ( 'loanReceipt' );
  2024. $loanReceipt = new loanReceipt ();
  2025. Doo::loadModel ( 'L_category' );
  2026. $Lcategory = new L_category ();
  2027. Doo::loadModel ( 'verify' );
  2028. Doo::loadModel ( 'statistics' );
  2029. $statistics = new statistics ();
  2030. $verify = new verify ();
  2031. Doo::loadModel ( 'staff' );
  2032. $staff = new staff ();
  2033. $receiptDetail = $receipt->getOne ( array (
  2034. 'where' => 'rid=' . $rid,
  2035. 'desc' => 'rid',
  2036. 'asArray' => true
  2037. ) );
  2038. $receiptList = $loanReceipt->find ( array (
  2039. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2040. 'desc' => 'rid',
  2041. 'asArray' => true
  2042. ) );
  2043. $Locate = 0;
  2044. $roleId = 0;
  2045. $button = 0;
  2046. foreach ( $receiptList as $key => $value ) {
  2047. $receiptList [$key] ['Locate'] = $Locate;
  2048. $Locate ++;
  2049. $receiptList [$key] ['reviseDetail'] = array ();
  2050. if (! empty ( $value ['reviseDetail'] ))
  2051. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2052. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2053. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2054. $categoryDetil = $Lcategory->getOne ( array (
  2055. 'where' => 'cid=' . $value ['cid'],
  2056. 'asArray' => true
  2057. ) );
  2058. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2059. // 检测编辑状态
  2060. $verifyList = $verify->getOne ( array (
  2061. 'where' => 'vid=' . $value ['verify'],
  2062. 'asArray' => true
  2063. ) );
  2064. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2065. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2066. Doo::loadModel ( 'role' );
  2067. $role = new role ();
  2068. $flag = true;
  2069. $roleKey = 0;
  2070. $endStaffArray = array ();
  2071. $roleArrayCopy = array ();
  2072. foreach ( $verifyList as $k => $v ) {
  2073. // init verifyStaff
  2074. if ($v [1] == 'ROLE') {
  2075. if (! empty ( $verifyStaff )) {
  2076. $endStaffArray = end ( $verifyStaff );
  2077. // if ($v[0]==$endStaffArray['nextStaff']){
  2078. // $roleId=$v[0];
  2079. // }
  2080. }
  2081. $roleVerify = json_decode ( $v [3], true );
  2082. $roleKey = $k;
  2083. $roleArray = array ();
  2084. $rolename = $role->getOne ( array (
  2085. 'where' => 'rid=' . $v [0],
  2086. 'asArray' => true
  2087. ) );
  2088. foreach ( $roleVerify as $o => $p ) {
  2089. $staffID = explode ( '_', $p );
  2090. $staffInfo = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $staffID [0],
  2092. 'asArray' => true
  2093. ) );
  2094. // print_r($staffID);
  2095. $exp = array (
  2096. 0 => $staffInfo ['sid'],
  2097. 1 => $staffID [1],
  2098. 2 => $staffInfo ['avatar'],
  2099. 'date' => '',
  2100. 'date' => '',
  2101. 'opinion' => '',
  2102. 'status' => '',
  2103. 'rolename' => $rolename ['name']
  2104. );
  2105. array_push ( $roleArray, $exp );
  2106. }
  2107. $roleArrayCopy [$v [0]] = $roleArray;
  2108. // $verifyList[$k]['roleArray']=$roleArray;
  2109. }
  2110. $verifyList [$k] ['date'] = "";
  2111. $verifyList [$k] ['opinion'] = "";
  2112. $verifyList [$k] ['status'] = "";
  2113. if (empty ( $verifyStaff )) {
  2114. $verifyList [$k] ['date'] = "";
  2115. $verifyList [$k] ['opinion'] = "";
  2116. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2117. $verifyList [$k] ['status'] = 4;
  2118. $flag = false;
  2119. }
  2120. } else {
  2121. foreach ( $verifyStaff as $m => $u ) {
  2122. if ($v [0] == $m) {
  2123. $verifyList [$k] ['date'] = $u ['date'];
  2124. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2125. $verifyList [$k] ['status'] = $u ['status'];
  2126. $flag = false;
  2127. break;
  2128. }
  2129. }
  2130. $endStaffArray = end ( $verifyStaff );
  2131. if (isset ( $endStaffArray ['ROLE'] )) {
  2132. } else {
  2133. // $endKey=key($verifyStaff);
  2134. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2135. // $button=4;
  2136. // $verifyList[$k]['status']=4;
  2137. // }
  2138. }
  2139. }
  2140. }
  2141. $rolename ['name'] = '';
  2142. if (! empty ( $roleId )) {
  2143. Doo::loadModel ( 'role' );
  2144. $role = new role ();
  2145. $rolename = $role->getOne ( array (
  2146. 'where' => 'rid=' . $roleId,
  2147. 'asArray' => true
  2148. ) );
  2149. }
  2150. if (! empty ( $verifyStaff ))
  2151. $endStaffArray = end ( $verifyStaff );
  2152. $KOP = false;
  2153. foreach ( $roleArrayCopy as $P => $A ) {
  2154. foreach ( $A as $MKI => $AVL ) {
  2155. if (! empty ( $verifyStaff )) {
  2156. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2157. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2158. $button = 4;
  2159. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2160. }
  2161. foreach ( $verifyStaff as $m => $u ) {
  2162. $AVLFK = $AVL [0] . '_R';
  2163. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2164. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2165. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2166. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2167. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2168. break;
  2169. }
  2170. }
  2171. } else {
  2172. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2173. $button = 4;
  2174. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2175. }
  2176. }
  2177. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2178. $KOP = true;
  2179. }
  2180. }
  2181. foreach ( $roleArrayCopy as $k => $v ) {
  2182. foreach ( $verifyList as $m => $n ) {
  2183. if ($n [0] == $k) {
  2184. array_splice ( $verifyList, $m, 1, $v );
  2185. }
  2186. }
  2187. }
  2188. $receiptList [$key] ['verifyList'] = $verifyList;
  2189. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2190. 'where' => 'sid=' . $value ['staff'],
  2191. 'asArray' => true
  2192. ) );
  2193. $receiptList [$key] ['button'] = $button;
  2194. //
  2195. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2196. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2197. }
  2198. $data ['receiptList'] = $receiptList;
  2199. $data ['receiptDetail'] = $receiptDetail;
  2200. Doo::loadModel ( 'L_category' );
  2201. $lCategory = new L_category ();
  2202. Doo::loadModel ( 'accountItem' );
  2203. $accountItem = new accountItem ();
  2204. $acItem = $accountItem->find ( array (
  2205. 'asArray' => true
  2206. ) );
  2207. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2208. $data ['rid'] = $rid;
  2209. $data ['category'] = $lCategory->find ( array (
  2210. 'asArray' => true
  2211. ) );
  2212. $data ['veList'] = $veList;
  2213. $data ['acItem'] = $acItem;
  2214. $data['itineraryDate']=$this->_itineraryDateMin();
  2215. $data ['memu'] = "receipt";
  2216. $data ['staff'] = $this->staff;
  2217. $data ['receiptMemu'] = 'saeaBorad';
  2218. $data ['verifyId'] = $this->verifyId;
  2219. $data ['executeId'] = $this->executeId;
  2220. $data['receiptClass']=$receiptClass;
  2221. if($receiptClass=='trave'){
  2222. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2223. }else{
  2224. $this->render ( "/receipt/feeLoanReceipt", $data );
  2225. }
  2226. }
  2227. function saeaLoanReceiptAddDo() {
  2228. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2229. $agency = $this->get_args ( 'agency' );
  2230. $travel = $this->get_args ( 'travel' );
  2231. $train = $this->get_args ( 'train' );
  2232. $other = $this->get_args ( 'other' );
  2233. $inttrain = $this->get_args ( 'inttrain' );
  2234. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2235. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2236. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2237. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2238. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2239. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2240. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2241. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2242. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2243. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2244. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2245. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2246. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2247. header ( 'Content-Type:text/html;charset=utf-8' );
  2248. die ( '请填写联行号' );
  2249. }
  2250. if($receiptClass=='agency'){
  2251. $receiptClass=1;
  2252. }elseif($receiptClass=='trave'){
  2253. $receiptClass=2;
  2254. if($this->_verificationItinerary($itinerary)){
  2255. header ( 'Content-Type:text/html;charset=utf-8' );
  2256. die ( '已申请过类此日期的行程' );
  2257. }
  2258. }elseif($receiptClass=='internalTrain'){
  2259. $receiptClass=3;
  2260. }else{
  2261. header ( 'Content-Type:text/html;charset=utf-8' );
  2262. die ( '借款报销单分类不正确' );
  2263. }
  2264. Doo::loadModel ( 'receipt' );
  2265. Doo::loadModel ( 'receiptDetail' );
  2266. Doo::loadModel ( 'accountItem' );
  2267. $accountItem = new accountItem ();
  2268. $receipt = new receipt ();
  2269. Doo::loadModel ( 'enclosur' );
  2270. Doo::loadModel ( 'execute' );
  2271. $execute = new execute ();
  2272. $executeDetail = $execute->getOne ( array (
  2273. 'where' => 'mold="借款费用执行人"',
  2274. 'asArray' => true
  2275. ) );
  2276. $receiptDet = $receipt->getOne ( array (
  2277. 'where' => 'rid=' . $rid,
  2278. 'asArray' => true
  2279. ) );
  2280. // if(!empty($receiptDetail))
  2281. // return "/referReceipt/".$receiptDetail['rid'];
  2282. $aItem = $accountItem->find ( array (
  2283. 'asArray' => true
  2284. ) );
  2285. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2286. $ag = $tr = $ta = $ot =$it = 0;
  2287. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2288. foreach ( $aItem as $key => $value ) {
  2289. if ($value ['category'] == $this->AGENCY) {
  2290. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2291. array_push ( $accountJson [$this->AGENCY], array (
  2292. 'aid' => $value ['aid'],
  2293. 'name' => $value ['name'],
  2294. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2295. ) );
  2296. $sum += $agency [$ag];
  2297. $agencySum += $agency [$ag];
  2298. }
  2299. $ag ++;
  2300. }
  2301. if ($value ['category'] == $this->TRAVEL) {
  2302. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2303. array_push ( $accountJson [$this->TRAVEL], array (
  2304. 'aid' => $value ['aid'],
  2305. 'name' => $value ['name'],
  2306. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2307. ) );
  2308. $sum += $travel [$tr];
  2309. $travelSum += $travel [$tr];
  2310. }
  2311. $tr ++;
  2312. }
  2313. if ($value ['category'] == $this->INTTRAIN) {
  2314. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2315. array_push ( $accountJson [$this->INTTRAIN], array (
  2316. 'aid' => $value ['aid'],
  2317. 'name' => $value ['name'],
  2318. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2319. ) );
  2320. $sum += $inttrain [$it];
  2321. $inttrainSum += $inttrain [$it];
  2322. }
  2323. $it ++;
  2324. }
  2325. if ($value ['category'] == $this->TRAIN) {
  2326. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2327. array_push ( $accountJson [$this->TRAIN], array (
  2328. 'aid' => $value ['aid'],
  2329. 'name' => $value ['name'],
  2330. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2331. ) );
  2332. $sum += $train [$ta];
  2333. $trainSum += $train [$ta];
  2334. }
  2335. $ta ++;
  2336. }
  2337. if ($value ['category'] == $this->OTHER) {
  2338. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2339. array_push ( $accountJson [$this->OTHER], array (
  2340. 'aid' => $value ['aid'],
  2341. 'name' => $value ['name'],
  2342. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2343. ) );
  2344. $sum += $other [$ot];
  2345. $otherSum += $other [$ot];
  2346. }
  2347. $ot ++;
  2348. }
  2349. }
  2350. $accountJson ['cSum'] = array (
  2351. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2352. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2353. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2354. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2355. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2356. );
  2357. // 报销单
  2358. $receipt->accountItem = json_encode ( $accountJson );
  2359. $receipt->staff = $this->staff [0] ['sid'];
  2360. $receipt->loanSum = $receiptDet ['sum'];
  2361. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2362. $receipt->date = date ( "Y-m-d" );
  2363. $receipt->pastDate = '0000-00-00';
  2364. $receipt->cid = $cid;
  2365. $receipt->status = 7;
  2366. $receipt->receiptClass=$receiptClass;
  2367. if($receiptClass==2){
  2368. $receipt->itinerary2=$itinerary;
  2369. $this->_storageItinerary($itinerary, $rid);
  2370. }
  2371. // 修改审批流程加入角色
  2372. $receipt->verify = $verify;
  2373. $receipt->verifyStaff = '';
  2374. $receipt->executeStaff = '';
  2375. $receipt->executeCopy = $executeDetail ['staff'];
  2376. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2377. $receipt->explanation = $explanation;
  2378. $receipt->remittanceName = $remittanceName;
  2379. $receipt->bankName = $bankName;
  2380. $receipt->bankNumber = $bankNumber;
  2381. $receipt->remittanceBankType = $remittanceBankType;
  2382. if ($remittanceBankType == 1)
  2383. $receipt->coupletNumber = $coupletNumber;
  2384. $receipt->update ( array (
  2385. 'where' => 'rid=' . $rid
  2386. ) );
  2387. // 附件
  2388. if (! empty ( $enclosurName )) {
  2389. $enclosurArray = explode ( '-', $enclosurName );
  2390. foreach ( $enclosurArray as $value ) {
  2391. $enclosur = new enclosur ();
  2392. $enclosur->name = $value;
  2393. $enclosur->rid = $rid;
  2394. $enclosur->insert ();
  2395. }
  2396. // print_r($enclosurArray);die;
  2397. }
  2398. // 报销详情
  2399. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2400. $receiptDetail = new receiptDetail ();
  2401. $receiptDetail->staff = $this->staff [0] ['sid'];
  2402. $receiptDetail->item = $value ['name'];
  2403. $receiptDetail->itemCategory = $this->AGENCY;
  2404. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2405. $receiptDetail->date = date ( "Y-m-d" );
  2406. $receiptDetail->cid = $cid;
  2407. $receiptDetail->rid = $rid;
  2408. $receiptDetail->status = 4;
  2409. $receiptDetail->insert ();
  2410. }
  2411. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2412. $receiptDetail = new receiptDetail ();
  2413. $receiptDetail->staff = $this->staff [0] ['sid'];
  2414. $receiptDetail->item = $value ['name'];
  2415. $receiptDetail->itemCategory = $this->TRAVEL;
  2416. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2417. $receiptDetail->date = date ( "Y-m-d" );
  2418. $receiptDetail->cid = $cid;
  2419. $receiptDetail->rid = $rid;
  2420. $receiptDetail->status = 4;
  2421. $receiptDetail->insert ();
  2422. }
  2423. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2424. $receiptDetail = new receiptDetail ();
  2425. $receiptDetail->staff = $this->staff [0] ['sid'];
  2426. $receiptDetail->item = $value ['name'];
  2427. $receiptDetail->itemCategory = $this->TRAIN;
  2428. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2429. $receiptDetail->date = date ( "Y-m-d" );
  2430. $receiptDetail->cid = $cid;
  2431. $receiptDetail->rid = $rid;
  2432. $receiptDetail->status = 4;
  2433. $receiptDetail->insert ();
  2434. }
  2435. //内训
  2436. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2437. $receiptDetail = new receiptDetail ();
  2438. $receiptDetail->staff = $this->staff [0] ['sid'];
  2439. $receiptDetail->item = $value ['name'];
  2440. $receiptDetail->itemCategory = $this->INTTRAIN;
  2441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2442. $receiptDetail->date = date ( "Y-m-d" );
  2443. $receiptDetail->cid = $cid;
  2444. $receiptDetail->rid = $rid;
  2445. $receiptDetail->status = 4;
  2446. $receiptDetail->insert ();
  2447. }
  2448. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2449. $receiptDetail = new receiptDetail ();
  2450. $receiptDetail->staff = $this->staff [0] ['sid'];
  2451. $receiptDetail->item = $value ['name'];
  2452. $receiptDetail->itemCategory = $this->OTHER;
  2453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2454. $receiptDetail->date = date ( "Y-m-d" );
  2455. $receiptDetail->cid = $cid;
  2456. $receiptDetail->rid = $rid;
  2457. $receiptDetail->status = 4;
  2458. $receiptDetail->insert ();
  2459. }
  2460. return "/saeaBorad";
  2461. }
  2462. return "/saeaLoanReceiptAdd/" . $rid;
  2463. }
  2464. function saeaLoanReceiptEdi() {
  2465. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2466. Doo::loadClass ( 'XDeode' );
  2467. $XDeode = new XDeode ( 7 );
  2468. $rid = $XDeode->decode ( $ridKey );
  2469. if (! is_numeric ( $rid ))
  2470. die ( 'illegal request' );
  2471. Doo::loadModel ( 'accountItem' );
  2472. Doo::loadModel ( 'verify' );
  2473. Doo::loadModel ( 'receipt' );
  2474. $receipt = new receipt ();
  2475. $verify = new verify ();
  2476. $accountItem = new accountItem ();
  2477. Doo::loadModel ( 'L_category' );
  2478. $Lcategory = new L_category ();
  2479. Doo::loadModel ( "role" );
  2480. $role = new role ();
  2481. Doo::loadModel ( 'loanReceipt' );
  2482. $loanReceipt = new loanReceipt ();
  2483. Doo::loadModel ( 'staff' );
  2484. $staff = new staff ();
  2485. $receiptDetail = $receipt->getOne ( array (
  2486. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2487. 'asArray' => true
  2488. ) );
  2489. if (empty ( $receiptDetail ))
  2490. return "/saeaBorad";
  2491. $receiptList = $loanReceipt->find ( array (
  2492. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2493. 'desc' => 'rid',
  2494. 'asArray' => true
  2495. ) );
  2496. $Locate = 0;
  2497. $roleId = 0;
  2498. $button = 0;
  2499. foreach ( $receiptList as $key => $value ) {
  2500. $receiptList [$key] ['Locate'] = $Locate;
  2501. $Locate ++;
  2502. $receiptList [$key] ['reviseDetail'] = array ();
  2503. if (! empty ( $value ['reviseDetail'] ))
  2504. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2505. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2506. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2507. $categoryDetil = $Lcategory->getOne ( array (
  2508. 'where' => 'cid=' . $value ['cid'],
  2509. 'asArray' => true
  2510. ) );
  2511. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2512. // 检测编辑状态
  2513. $verifyList = $verify->getOne ( array (
  2514. 'where' => 'vid=' . $value ['verify'],
  2515. 'asArray' => true
  2516. ) );
  2517. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2518. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2519. Doo::loadModel ( 'role' );
  2520. $role = new role ();
  2521. $flag = true;
  2522. $roleKey = 0;
  2523. $endStaffArray = array ();
  2524. $roleArrayCopy = array ();
  2525. foreach ( $verifyList as $k => $v ) {
  2526. // init verifyStaff
  2527. if ($v [1] == 'ROLE') {
  2528. if (! empty ( $verifyStaff )) {
  2529. $endStaffArray = end ( $verifyStaff );
  2530. // if ($v[0]==$endStaffArray['nextStaff']){
  2531. // $roleId=$v[0];
  2532. // }
  2533. }
  2534. $roleVerify = json_decode ( $v [3], true );
  2535. $roleKey = $k;
  2536. $roleArray = array ();
  2537. $rolename = $role->getOne ( array (
  2538. 'where' => 'rid=' . $v [0],
  2539. 'asArray' => true
  2540. ) );
  2541. foreach ( $roleVerify as $o => $p ) {
  2542. $staffID = explode ( '_', $p );
  2543. $staffInfo = $staff->getOne ( array (
  2544. 'where' => 'sid=' . $staffID [0],
  2545. 'asArray' => true
  2546. ) );
  2547. // print_r($staffID);
  2548. $exp = array (
  2549. 0 => $staffInfo ['sid'],
  2550. 1 => $staffID [1],
  2551. 2 => $staffInfo ['avatar'],
  2552. 'date' => '',
  2553. 'date' => '',
  2554. 'opinion' => '',
  2555. 'status' => '',
  2556. 'rolename' => $rolename ['name']
  2557. );
  2558. array_push ( $roleArray, $exp );
  2559. }
  2560. $roleArrayCopy [$v [0]] = $roleArray;
  2561. // $verifyList[$k]['roleArray']=$roleArray;
  2562. }
  2563. $verifyList [$k] ['date'] = "";
  2564. $verifyList [$k] ['opinion'] = "";
  2565. $verifyList [$k] ['status'] = "";
  2566. if (empty ( $verifyStaff )) {
  2567. $verifyList [$k] ['date'] = "";
  2568. $verifyList [$k] ['opinion'] = "";
  2569. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2570. $verifyList [$k] ['status'] = 4;
  2571. $flag = false;
  2572. }
  2573. } else {
  2574. foreach ( $verifyStaff as $m => $u ) {
  2575. if ($v [0] == $m) {
  2576. $verifyList [$k] ['date'] = $u ['date'];
  2577. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2578. $verifyList [$k] ['status'] = $u ['status'];
  2579. $flag = false;
  2580. break;
  2581. }
  2582. }
  2583. $endStaffArray = end ( $verifyStaff );
  2584. if (isset ( $endStaffArray ['ROLE'] )) {
  2585. } else {
  2586. // $endKey=key($verifyStaff);
  2587. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2588. // $button=4;
  2589. // $verifyList[$k]['status']=4;
  2590. // }
  2591. }
  2592. }
  2593. }
  2594. $rolename ['name'] = '';
  2595. if (! empty ( $roleId )) {
  2596. Doo::loadModel ( 'role' );
  2597. $role = new role ();
  2598. $rolename = $role->getOne ( array (
  2599. 'where' => 'rid=' . $roleId,
  2600. 'asArray' => true
  2601. ) );
  2602. }
  2603. if (! empty ( $verifyStaff ))
  2604. $endStaffArray = end ( $verifyStaff );
  2605. $KOP = false;
  2606. foreach ( $roleArrayCopy as $P => $A ) {
  2607. foreach ( $A as $MKI => $AVL ) {
  2608. if (! empty ( $verifyStaff )) {
  2609. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2610. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2611. $button = 4;
  2612. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2613. }
  2614. foreach ( $verifyStaff as $m => $u ) {
  2615. $AVLFK = $AVL [0] . '_R';
  2616. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2617. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2618. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2619. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2620. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2621. break;
  2622. }
  2623. }
  2624. } else {
  2625. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2626. $button = 4;
  2627. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2628. }
  2629. }
  2630. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2631. $KOP = true;
  2632. }
  2633. }
  2634. foreach ( $roleArrayCopy as $k => $v ) {
  2635. foreach ( $verifyList as $m => $n ) {
  2636. if ($n [0] == $k) {
  2637. array_splice ( $verifyList, $m, 1, $v );
  2638. }
  2639. }
  2640. }
  2641. $receiptList [$key] ['verifyList'] = $verifyList;
  2642. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2643. 'where' => 'sid=' . $value ['staff'],
  2644. 'asArray' => true
  2645. ) );
  2646. $receiptList [$key] ['button'] = $button;
  2647. //
  2648. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2649. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2650. }
  2651. $data ['receiptList'] = $receiptList;
  2652. $acItem = $accountItem->find ( array (
  2653. 'asArray' => true
  2654. ) );
  2655. $veList = $verify->find ( array (
  2656. 'asArray' => true
  2657. ) );
  2658. foreach ( $veList as $key => $value ) {
  2659. $v = json_decode ( $value ['staff'] );
  2660. $list = array ();
  2661. foreach ( $v as $n => $m ) {
  2662. if ($m ['1'] == 'ROLE') {
  2663. $roleInfo = $role->getOne ( array (
  2664. 'where' => 'rid=' . $m [0],
  2665. 'asArray' => true
  2666. ) );
  2667. $v [$n] [1] = $roleInfo ['name'];
  2668. array_push ( $list, $roleInfo ['name'] );
  2669. } else {
  2670. array_push ( $list, $v [$n] [1] );
  2671. }
  2672. }
  2673. $veList [$key] ['staff'] = implode ( '>', $list );
  2674. }
  2675. // 配置编辑信息
  2676. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2677. foreach ( $acItem as $key => $value ) {
  2678. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2679. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2680. $acItem [$key] ['price'] = $v ['price'];
  2681. }
  2682. }
  2683. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2684. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2685. $acItem [$key] ['price'] = $v ['price'];
  2686. }
  2687. }
  2688. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2689. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2690. $acItem [$key] ['price'] = $v ['price'];
  2691. }
  2692. }
  2693. //内训
  2694. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2695. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2696. $acItem [$key] ['price'] = $v ['price'];
  2697. }
  2698. }
  2699. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2700. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2701. $acItem [$key] ['price'] = $v ['price'];
  2702. }
  2703. }
  2704. }
  2705. $data ['category'] = $Lcategory->find ( array (
  2706. 'asArray' => true
  2707. ) );
  2708. $data ['ridKey'] = $ridKey;
  2709. $data ['cSum'] = $accountItemList ['cSum'];
  2710. $data ['sum'] = $receiptDetail ['sum'];
  2711. $data ['receiptDetail'] = $receiptDetail;
  2712. $data ['veList'] = $veList;
  2713. $data ['acItem'] = $acItem;
  2714. $data ['memu'] = "receipt";
  2715. $data ['staff'] = $this->staff;
  2716. $data ['receiptMemu'] = 'saeaBorad';
  2717. $data ['verify'] = $receiptDetail ['verify'];
  2718. $data ['verifyId'] = $this->verifyId;
  2719. $data ['executeId'] = $this->executeId;
  2720. $data ['rid'] = $rid;
  2721. if($receiptDetail['receiptClass']==1){
  2722. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2723. }elseif($receiptDetail['receiptClass']==2){
  2724. Doo::loadModel ( 'itinerary' );
  2725. $itinerary = new itinerary ();
  2726. $itinerary->delete(array('where' => 'rid=' . $receiptDetail['rid'] ));
  2727. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2728. }elseif($receiptDetail['receiptClass']==3){
  2729. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2730. }else{
  2731. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2732. }
  2733. }
  2734. /**
  2735. * 培训班结算
  2736. */
  2737. function receiptTrainAdd() {
  2738. Doo::loadModel ( 'accountItem' );
  2739. $accountItem = new accountItem ();
  2740. $acItem = $accountItem->find ( array (
  2741. 'asArray' => true
  2742. ) );
  2743. // 审批组
  2744. Doo::loadModel ( 'verify' );
  2745. $verify = new verify ();
  2746. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2747. // 办事处
  2748. Doo::loadModel ( 'L_category' );
  2749. $lCategory = new L_category ();
  2750. $data ['category'] = $lCategory->getCategory ();
  2751. $data ['veList'] = $veList;
  2752. $data ['memu'] = "receipt";
  2753. $data ['staff'] = $this->staff;
  2754. $data ['acItem'] = $acItem;
  2755. $data ['receiptMemu'] = 'saeaBorad';
  2756. $data ['verifyId'] = $this->verifyId;
  2757. $data ['executeId'] = $this->executeId;
  2758. $this->render ( "/receipt/receiptTrainAdd", $data );
  2759. }
  2760. /**
  2761. * 添加培训班结算
  2762. */
  2763. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2764. // 培训班信息
  2765. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2766. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2767. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2768. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2769. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2770. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2771. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2772. // 发票信息
  2773. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2774. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2775. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2776. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2777. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2778. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2779. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2780. //&&! empty ( $participants )
  2781. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2782. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2783. header ( 'Content-Type:text/html;charset=utf-8' );
  2784. die ( '请填写联行号' );
  2785. }
  2786. Doo::loadModel ( 'execute' );
  2787. $execute = new execute ();
  2788. $executeDetail = $execute->getOne ( array (
  2789. 'where' => 'mold="培训班结算"',
  2790. 'asArray' => true
  2791. ) );
  2792. if (empty ( $executeDetail )) {
  2793. header ( 'Content-Type:text/html;charset=utf-8' );
  2794. die ( '未设置执行人' );
  2795. }
  2796. Doo::loadClass ( 'XDeode' );
  2797. $XDeode = new XDeode ( 5 );
  2798. $cid = $XDeode->decode ( $cid );
  2799. Doo::loadModel ( 'receipt' );
  2800. $receipt = new receipt ();
  2801. Doo::loadModel ( 'receiptTraining' );
  2802. $receiptTraining = new receiptTraining ();
  2803. // 创建费用培训班
  2804. $item = array (
  2805. 'cid' => $this->staff [0] ['cid'],
  2806. 'categoryName' => $this->staff [0] ['category'],
  2807. 'trainName' => $trainName,
  2808. 'trainStartDate' => $trainStartDate,
  2809. 'trainEndDate' => $trainEndDate,
  2810. 'participants' => $participants,
  2811. 'freeParticipants'=>$freeParticipants,
  2812. 'trainAddress' => $trainAddress,
  2813. 'trainRemarks' => $trainRemarks,
  2814. 'creator' => $this->staff [0] ['sid'],
  2815. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2816. );
  2817. $irid = $receiptTraining->addReceiptTraining ( $item );
  2818. // 报销单
  2819. $receipt->status = 5;
  2820. $receipt->trainId = $irid;
  2821. $receipt->Rtype = 3;
  2822. $receipt->staff = $this->staff [0] ['sid'];
  2823. $receipt->cid = $cid;
  2824. $receipt->verify = $verify;
  2825. $receipt->date = date ( "Y-m-d" );
  2826. $receipt->new_summary = 1;
  2827. $receipt->executeCopy = $executeDetail ['staff'];
  2828. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2829. $receipt->remittanceName = $remittanceName;
  2830. $receipt->bankName = $bankName;
  2831. $receipt->bankNumber = $bankNumber;
  2832. $receipt->remittanceBankType = $remittanceBankType;
  2833. if ($remittanceBankType == 1)
  2834. $receipt->coupletNumber = $coupletNumber;
  2835. $rid = $receipt->insert ();
  2836. $XDeode = new XDeode ( 7 );
  2837. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2838. } else
  2839. die ( 'illegal request' );
  2840. }
  2841. /**
  2842. * 培训班编辑
  2843. */
  2844. function receiptTrainEdi() {
  2845. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2846. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2847. Doo::loadClass ( 'XDeode' );
  2848. $XDeode = new XDeode ( 7 );
  2849. $rid = $XDeode->decode ( $ridKey );
  2850. if (! is_numeric ( $rid ))
  2851. die ( 'illegal request' );
  2852. Doo::loadModel ( 'receipt' );
  2853. $receipt = new receipt ();
  2854. Doo::loadModel ( 'receiptTraining' );
  2855. $receiptTraining = new receiptTraining ();
  2856. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2857. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2858. die ('illegal request--status');
  2859. }
  2860. //如有已入账已收款的发票,自动取消办事处已收款
  2861. // Doo::loadModel ( 'RIExtend' );
  2862. // $RIExtend = new RIExtend ();
  2863. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2864. // if (!empty($RIExtendList)){
  2865. // foreach ($RIExtendList as $key=>$value){
  2866. // $RIExtend = new RIExtend ();
  2867. // $RIExtend->delete(array (
  2868. // 'where' => 'iid=' . $value['iid'],
  2869. // 'limit' => 1
  2870. // ));
  2871. // }
  2872. // }
  2873. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2874. // 汇总表合计
  2875. // 收入合计--加入开票合计
  2876. Doo::loadModel ( 'invoiceTraining' );
  2877. $invoiceTraining = new invoiceTraining ();
  2878. $invoiceTrainingDetail = array (
  2879. 'invoiceArriveAmount' => 0,
  2880. 'RIAmount' => 0,
  2881. 'invoiceTotalAmount' => 0,
  2882. 'invoiceCompanyAmount'=>0
  2883. );
  2884. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2885. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2886. }
  2887. // print_r($invoiceTrainingDetail);
  2888. $invoiceArriveAmount = $RIAmount = 0;
  2889. if (! empty ( $invoiceTrainingDetail )) {
  2890. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2891. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2892. }
  2893. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2894. //print_r($invoiceTrainingDetail);
  2895. // 支出项目
  2896. Doo::loadModel ( 'accountItem' );
  2897. $accountItem = new accountItem ();
  2898. // 项目金额合计
  2899. Doo::loadModel ( 'RItem' );
  2900. $RItem = new RItem ();
  2901. // 讲师获得
  2902. Doo::loadModel ( 'RILecturer' );
  2903. $RILecturer = new RILecturer ();
  2904. $RItemList = $RItem->getRItemByRid ( $rid );
  2905. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2906. // 支出项金额详情
  2907. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2908. // print_r($aiData);
  2909. // 利润
  2910. $profit=$invoiceArriveAmount - $aiData ['total'];
  2911. $companyProfit=$profit * 0.6;
  2912. $categoryProfit=$profit * 0.4;
  2913. $data ['profit'] = sprintf("%.2f",$profit);
  2914. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2915. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2916. //发票利润
  2917. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2918. //发票公司利润
  2919. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2920. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2921. //办事处利润
  2922. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2923. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2924. // print_r($aiData['dataList']);
  2925. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2926. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2927. // 备用金
  2928. $sum = 0;
  2929. $data ['receiptLoanDetail'] = array (
  2930. 'sum' => '0.00'
  2931. );
  2932. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2933. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2934. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2935. $sum=0;
  2936. foreach ($receiptLoanList as $key=>$value){
  2937. $sum+=$value['sum'];
  2938. }
  2939. $data ['receiptLoanDetail'] = array (
  2940. 'sum' => $sum
  2941. );
  2942. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2943. }
  2944. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2945. $data ['payment'] = sprintf("%.2f",$payment);
  2946. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2947. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2948. $data ['aiList'] = $aiData ['dataList'];
  2949. // 占比计算
  2950. if ($invoiceArriveAmount != 0) {
  2951. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2952. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2953. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2954. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2955. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2956. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2957. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2958. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2959. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2960. } else {
  2961. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2962. }
  2963. //发票金额占比计算
  2964. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2965. //支出
  2966. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2967. //利润
  2968. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2969. //公司利润
  2970. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2971. //办事处利润
  2972. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2973. //公司收款
  2974. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2975. //备用金
  2976. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2977. //办事处收款
  2978. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2979. //办事处实际支出
  2980. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2981. //付总部款
  2982. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2983. }else{
  2984. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2985. }
  2986. //讲师人数
  2987. Doo::loadModel ( 'RILecturer' );
  2988. $RILecturer = new RILecturer ();
  2989. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2990. $data['lectureCount']=count($RILecturerList);
  2991. // 审批组
  2992. Doo::loadModel ( 'verify' );
  2993. $verify = new verify ();
  2994. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2995. // 办事处
  2996. Doo::loadModel ( 'L_category' );
  2997. $lCategory = new L_category ();
  2998. $data ['category'] = $lCategory->getCategory ();
  2999. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3000. $data ['receiptDetail'] = $receiptDetail;
  3001. $data ['veList'] = $veList;
  3002. $data ['trainEdiType'] = $trainEdiType;
  3003. $data ['ridKey'] = $ridKey;
  3004. $data ['memu'] = "receipt";
  3005. $data ['staff'] = $this->staff;
  3006. $data ['receiptMemu'] = 'saeaBorad';
  3007. $data ['verifyId'] = $this->verifyId;
  3008. $data ['executeId'] = $this->executeId;
  3009. $this->render ( "/receipt/receiptTrainEdi", $data );
  3010. }
  3011. /**
  3012. * 培训班借款编辑
  3013. */
  3014. function receiptTrainLoanEdi() {
  3015. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3016. Doo::loadClass ( 'XDeode' );
  3017. $XDeode = new XDeode ( 7 );
  3018. $rid = $XDeode->decode ( $ridKey );
  3019. if (! is_numeric ( $rid ))
  3020. die ( 'illegal request' );
  3021. Doo::loadModel ( 'receipt' );
  3022. $receipt = new receipt ();
  3023. Doo::loadModel ( 'receiptTraining' );
  3024. $receiptTraining = new receiptTraining ();
  3025. Doo::loadModel ( 'verify' );
  3026. $verify = new verify ();
  3027. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3028. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3029. die ();
  3030. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3031. // 借款详情HTML
  3032. // 获得借款信息
  3033. $receiptLoanHtml = '';
  3034. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3035. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3036. foreach ($receiptLoanList as $key=>$value){
  3037. // 获得某费用单审批信息
  3038. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3039. Doo::loadClass ( 'receipt.func' );
  3040. $extendHtml = '<p><a class="button"
  3041. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3042. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3043. }
  3044. }
  3045. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3046. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3047. $data ['receiptDetail'] = $receiptDetail;
  3048. $data ['trainEdiType'] = "LOAN";
  3049. $data ['ridKey'] = $ridKey;
  3050. $data ['memu'] = "receipt";
  3051. $data ['staff'] = $this->staff;
  3052. $data ['receiptMemu'] = 'saeaBorad';
  3053. $data ['verifyId'] = $this->verifyId;
  3054. $data ['executeId'] = $this->executeId;
  3055. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3056. }
  3057. /**
  3058. * 更新培训班结算基本信息
  3059. */
  3060. function receiptTrainInfoEdiDo() {
  3061. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3062. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3063. // 培训班信息
  3064. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3065. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3066. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3067. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3068. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3069. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3070. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3071. // 发票信息
  3072. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3073. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3074. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3075. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3076. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3077. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3078. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3079. //&& ! empty ( $participants )
  3080. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3081. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3082. header ( 'Content-Type:text/html;charset=utf-8' );
  3083. die ( '请填写联行号' );
  3084. }
  3085. Doo::loadClass ( 'XDeode' );
  3086. $XDeode = new XDeode ( 5 );
  3087. $cid = $XDeode->decode ( $cid );
  3088. $rtid = $XDeode->decode ( $rtid );
  3089. $rid = $XDeode->decode ( $rid );
  3090. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3091. die ( 'illegal request-IdError' );
  3092. }
  3093. Doo::loadModel ( 'receipt' );
  3094. $receipt = new receipt ();
  3095. Doo::loadModel ( 'receiptTraining' );
  3096. $receiptTraining = new receiptTraining ();
  3097. // 更新费用培训班
  3098. $item = array (
  3099. 'rtid' => $rtid,
  3100. 'trainName' => $trainName,
  3101. 'trainStartDate' => $trainStartDate,
  3102. 'trainEndDate' => $trainEndDate,
  3103. 'participants' => $participants,
  3104. 'freeParticipants'=>$freeParticipants,
  3105. 'trainAddress' => $trainAddress,
  3106. 'trainRemarks' => $trainRemarks
  3107. );
  3108. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3109. // 报销单
  3110. $receipt->rid = $rid;
  3111. $receipt->cid = $cid;
  3112. $receipt->verify = $verify;
  3113. $receipt->remittanceName = $remittanceName;
  3114. $receipt->bankName = $bankName;
  3115. $receipt->bankNumber = $bankNumber;
  3116. $receipt->remittanceBankType = $remittanceBankType;
  3117. if ($remittanceBankType == 1)
  3118. $receipt->coupletNumber = $coupletNumber;
  3119. $receipt->update ();
  3120. $XDeode = new XDeode ( 7 );
  3121. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3122. } else
  3123. die ( 'illegal request' );
  3124. }
  3125. /**
  3126. * 编辑培训班结算---更新借款
  3127. */
  3128. function receiptTrainLoanEdiDo() {
  3129. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3130. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3131. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3132. Doo::loadModel ( 'receipt' );
  3133. $receipt = new receipt ();
  3134. Doo::loadClass ( 'XDeode' );
  3135. $XDeode = new XDeode ( 5 );
  3136. $rid = $XDeode->decode ( $ridKey );
  3137. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3138. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3139. die ( 'illegal request-ridError' );
  3140. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3141. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3142. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3143. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3144. die ( 'illegal request-receiptError' );
  3145. }
  3146. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3147. die ( 'illegal request-receipLoantError' );
  3148. }
  3149. // 培训班结算挂钩借款
  3150. $receipt = new receipt ();
  3151. $trainLoanRid=$ridLoan;
  3152. if (!empty($receiptDetail['trainLoanRid'])){
  3153. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3154. }
  3155. $item = array (
  3156. 'rid' => $rid,
  3157. 'trainLoanRid' => $trainLoanRid
  3158. );
  3159. $receipt->setReceiptByCondition ( $item );
  3160. // 更新借款状态变成已挂钩
  3161. $receipt = new receipt ();
  3162. $item = array (
  3163. 'rid' => $ridLoan,
  3164. 'status' => 10,
  3165. 'statusTrain' => 1
  3166. );
  3167. $receipt->setReceiptByCondition ( $item );
  3168. $XDeode = new XDeode ( 7 );
  3169. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3170. } else
  3171. die ( 'illegal request' );
  3172. }
  3173. /**
  3174. * 编辑培训班结算--移除借款
  3175. */
  3176. function receiptTrainLoanRemoveDo() {
  3177. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3178. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3179. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3180. Doo::loadModel ( 'receipt' );
  3181. $receipt = new receipt ();
  3182. Doo::loadClass ( 'XDeode' );
  3183. $XDeode = new XDeode ( 5 );
  3184. $rid = $XDeode->decode ( $ridKey );
  3185. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3186. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3187. die ( 'illegal request-ridError' );
  3188. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3189. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3190. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3191. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3192. die ( 'illegal request-receiptError' );
  3193. }
  3194. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3195. die ( 'illegal request-receipLoantError' );
  3196. }
  3197. // 培训班结算挂钩借款
  3198. $receipt = new receipt ();
  3199. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3200. foreach ($trainLoanRidArray as $key=>$value){
  3201. if($value==$ridLoan){
  3202. unset($trainLoanRidArray[$key]);
  3203. }
  3204. }
  3205. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3206. $item = array (
  3207. 'rid' => $rid,
  3208. 'trainLoanRid' => $trainLoanRidString
  3209. );
  3210. $receipt->setReceiptByCondition ( $item );
  3211. // 更新借款状态变成已挂钩
  3212. $receipt = new receipt ();
  3213. $item = array (
  3214. 'rid' => $ridLoan,
  3215. 'status' => 8,
  3216. 'statusTrain' => 0
  3217. );
  3218. $receipt->setReceiptByCondition ( $item );
  3219. $XDeode = new XDeode ( 7 );
  3220. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3221. } else
  3222. die ( 'illegal request' );
  3223. }
  3224. /**
  3225. * 编辑培训班结算 ---开票
  3226. */
  3227. function receiptTrainInvoiceEdi() {
  3228. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3229. Doo::loadClass ( 'XDeode' );
  3230. $XDeode = new XDeode ( 7 );
  3231. $rid = $XDeode->decode ( $ridKey );
  3232. if (! is_numeric ( $rid ))
  3233. die ( 'illegal request' );
  3234. Doo::loadModel ( 'receipt' );
  3235. $receipt = new receipt ();
  3236. Doo::loadModel ( 'receiptTraining' );
  3237. $receiptTraining = new receiptTraining ();
  3238. Doo::loadModel ( 'invoice' );
  3239. $invoice = new invoice ();
  3240. Doo::loadModel ( 'invoiceTraining' );
  3241. $invoiceTraining = new invoiceTraining ();
  3242. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3243. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3244. die ();
  3245. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3246. $invoiceList = $invoiceTrainingDetail = array ();
  3247. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3248. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3249. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3250. }
  3251. //print_r($invoiceList);
  3252. $data ['invoiceList'] = $invoiceList;
  3253. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3254. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3255. $data ['receiptDetail'] = $receiptDetail;
  3256. $data ['trainEdiType'] = "INVOICE";
  3257. $data ['ridKey'] = $ridKey;
  3258. $data ['memu'] = "receipt";
  3259. $data ['staff'] = $this->staff;
  3260. $data ['receiptMemu'] = 'saeaBorad';
  3261. $data ['verifyId'] = $this->verifyId;
  3262. $data ['executeId'] = $this->executeId;
  3263. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3264. }
  3265. /**
  3266. * 编辑培训班结算---更新开票
  3267. */
  3268. function receiptTrainInvoiceEdiDo() {
  3269. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3270. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3271. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3272. Doo::loadModel ( 'receipt' );
  3273. $receipt = new receipt ();
  3274. Doo::loadModel ( 'invoiceTraining' );
  3275. $invoiceTraining = new invoiceTraining ();
  3276. Doo::loadClass ( 'XDeode' );
  3277. $XDeode = new XDeode ( 5 );
  3278. $rid = $XDeode->decode ( $ridKey );
  3279. $itid = $XDeode->decode ( $itidKey );
  3280. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3281. die ( 'illegal request-idError' );
  3282. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3283. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3284. // 不合法的数据
  3285. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3286. die ( 'illegal request-receiptError' );
  3287. }
  3288. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3289. die ( 'illegal request-receipLoantError' );
  3290. }
  3291. // 培训班结算挂钩借款
  3292. $receipt = new receipt ();
  3293. $item = array (
  3294. 'rid' => $rid,
  3295. 'invoiceTrainId' => $itid
  3296. );
  3297. $receipt->setReceiptByCondition ( $item );
  3298. $invoiceTraining = new invoiceTraining ();
  3299. $item = array (
  3300. 'bindReceipt' => 1,
  3301. 'itid' => $itid
  3302. );
  3303. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3304. $XDeode = new XDeode ( 7 );
  3305. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3306. } else
  3307. die ( 'illegal request' );
  3308. }
  3309. /**
  3310. * 更新培训班结算 收款和取消收款
  3311. */
  3312. function receiptTrainReceivables() {
  3313. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3314. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3315. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3316. Doo::loadClass ( 'XDeode' );
  3317. $XDeode = new XDeode ( 5 );
  3318. $rid = $XDeode->decode ( $ridKey );
  3319. $iid = $XDeode->decode ( $iidKey );
  3320. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3321. die ( 'illegal request-iid' );
  3322. Doo::loadModel ( 'RIExtend' );
  3323. $RIExtend = new RIExtend ();
  3324. if ($doType == 'CONFIRM') {
  3325. $RIExtend->rid = $rid;
  3326. $RIExtend->iid = $iid;
  3327. $RIExtend->RIstatus = 1;
  3328. $RIExtend->insert ();
  3329. echo json_encode ( array (
  3330. 'status' => 1,
  3331. ) );
  3332. die ( );
  3333. } elseif ($doType == 'CANCEL') {
  3334. $RIExtend->delete ( array (
  3335. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3336. 'limit' => 1
  3337. ) );
  3338. echo json_encode ( array (
  3339. 'status' => 1,
  3340. ) );
  3341. die ( );
  3342. } else {
  3343. echo json_encode ( array (
  3344. 'status' => 2,
  3345. ) );
  3346. die ( );
  3347. }
  3348. }
  3349. /**
  3350. * 移除挂钩的培训班发票
  3351. */
  3352. function receiptTrainReceivablesDelDo() {
  3353. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3354. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3355. Doo::loadModel ( 'receipt' );
  3356. $receipt = new receipt ();
  3357. Doo::loadModel ( 'RIExtend' );
  3358. $RIExtend = new RIExtend ();
  3359. Doo::loadClass ( 'XDeode' );
  3360. $XDeode = new XDeode ( 5 );
  3361. $rid = $XDeode->decode ( $ridKey );
  3362. $itid = $XDeode->decode ( $itidKey );
  3363. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3364. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3365. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3366. die ( 'illegal request-status' );
  3367. }
  3368. $receipt = new receipt ();
  3369. $receipt->rid = $rid;
  3370. $receipt->invoiceTrainId = 0;
  3371. $receipt->update ();
  3372. Doo::loadModel ( 'invoiceTraining' );
  3373. $invoiceTraining = new invoiceTraining ();
  3374. $item = array (
  3375. 'bindReceipt' => 0,
  3376. 'itid' => $itid
  3377. );
  3378. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3379. $RIExtend->delete ( array (
  3380. 'where' => 'rid=' . $rid
  3381. ) );
  3382. $XDeode = new XDeode ( 7 );
  3383. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3384. } else
  3385. die ( 'illegal request-iid' );
  3386. }
  3387. /**
  3388. * 编辑培训班结算
  3389. */
  3390. function receiptTrainItemEdi() {
  3391. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3392. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3393. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3394. Doo::loadClass ( 'XDeode' );
  3395. $XDeode = new XDeode ( 7 );
  3396. $rid = $XDeode->decode ( $ridKey );
  3397. if (! is_numeric ( $rid ))
  3398. die ( 'illegal request' );
  3399. Doo::loadModel ( 'receipt' );
  3400. $receipt = new receipt ();
  3401. Doo::loadModel ( 'receiptTraining' );
  3402. $receiptTraining = new receiptTraining ();
  3403. Doo::loadModel ( 'RItem' );
  3404. $RItem = new RItem ();
  3405. Doo::loadModel ( 'accountItem' );
  3406. $accountItem = new accountItem ();
  3407. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3408. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3409. die ();
  3410. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3411. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3412. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3413. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3414. // if($value['name']=='税款'){
  3415. // unset($aiList[$key]);break;
  3416. // }
  3417. // }
  3418. //print_r($RItemList);
  3419. $data ['name'] = $name;
  3420. $data ['RItemList'] = $RItemList;
  3421. $data ['aiList'] = $aiList;
  3422. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3423. $data ['receiptDetail'] = $receiptDetail;
  3424. $data ['trainEdiType'] = "ITEM";
  3425. $data ['ridKey'] = $ridKey;
  3426. $data ['memu'] = "receipt";
  3427. $data ['staff'] = $this->staff;
  3428. $data ['receiptMemu'] = 'saeaBorad';
  3429. $data ['verifyId'] = $this->verifyId;
  3430. $data ['executeId'] = $this->executeId;
  3431. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3432. }
  3433. /**
  3434. * 添加支出项 需要修改 费用金额合计
  3435. */
  3436. function receiptTrainItemAddDo() {
  3437. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3438. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3439. // 支出项信息
  3440. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3441. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3442. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3443. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3444. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3445. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3446. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3447. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3448. Doo::loadClass ( 'XDeode' );
  3449. $XDeode = new XDeode ( 5 );
  3450. Doo::loadModel ( 'RItem' );
  3451. $RItem = new RItem ();
  3452. $rid = $XDeode->decode ( $ridKey );
  3453. $rtid= $XDeode->decode ( $rtidKey );
  3454. if (! is_numeric ( $rid )){
  3455. die ( 'illegal request' );
  3456. }
  3457. Doo::loadModel ( 'receiptDetail' );
  3458. $receiptDetail = new receiptDetail ();
  3459. Doo::loadModel ( 'receipt' );
  3460. $receipt = new receipt ();
  3461. Doo::loadModel ( 'receiptTraining' );
  3462. $receiptTraining = new receiptTraining ();
  3463. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3464. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3465. $order = array (
  3466. "\r\n",
  3467. "\n",
  3468. "\r"
  3469. );
  3470. $replace = '<br/>';
  3471. $describe = str_replace ( $order, $replace, $describe );
  3472. $itemData = array (
  3473. 'rid' => $rid,
  3474. 'item' => $item,
  3475. 'price' => $price,
  3476. 'date' => $date,
  3477. 'inputer' => $inputer,
  3478. 'describe' => $describe,
  3479. 'creater' => $this->staff['0']['username'],
  3480. 'createrId' => $this->staff['0']['sid'],
  3481. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3482. 'identifying'=>$identifyingTotal
  3483. );
  3484. if($payType=='company'){
  3485. $itemData += array (
  3486. 'payType' => 1
  3487. );
  3488. }
  3489. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3490. //更新支出项标识总数
  3491. $itemData = array (
  3492. 'rtid'=>$rtid,
  3493. 'identifyingTotal'=>$identifyingTotal
  3494. );
  3495. $receiptTraining->setReceiptTrainByCondition($itemData);
  3496. $XDeode = new XDeode ( 7 );
  3497. if($payType=='company'){
  3498. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3499. }else{
  3500. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3501. }
  3502. } else
  3503. die ( 'illegal request-dataError' );
  3504. }
  3505. /**
  3506. * 培训班结算-讲师
  3507. */
  3508. function receiptTrainLecturerEdi() {
  3509. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3510. Doo::loadClass ( 'XDeode' );
  3511. $XDeode = new XDeode ( 7 );
  3512. $rid = $XDeode->decode ( $ridKey );
  3513. if (! is_numeric ( $rid ))
  3514. die ( 'illegal request' );
  3515. Doo::loadModel ( 'receipt' );
  3516. $receipt = new receipt ();
  3517. Doo::loadModel ( 'receiptTraining' );
  3518. $receiptTraining = new receiptTraining ();
  3519. Doo::loadModel ( 'RILecturer' );
  3520. $RILecturer = new RILecturer ();
  3521. Doo::loadModel ( 'lecturer' );
  3522. $lecturer = new lecturer ();
  3523. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3524. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3525. die ();
  3526. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3527. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3528. $lecturerList = $lecturer->getLecturerAll ();
  3529. $INSIDEhtml = $OUTSIDEhtml = '';
  3530. foreach ( $lecturerList as $key => $value ) {
  3531. if ($value ['ltype'] == 'INSIDE') {
  3532. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3533. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3534. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3535. }
  3536. }
  3537. $data ['INSIDEhtml'] = $INSIDEhtml;
  3538. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3539. // print_r($RItemList);
  3540. $data ['RILecturerList'] = $RILecturerList;
  3541. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3542. $data ['receiptDetail'] = $receiptDetail;
  3543. $data ['trainEdiType'] = "LECTURER";
  3544. $data ['ridKey'] = $ridKey;
  3545. $data ['memu'] = "receipt";
  3546. $data ['staff'] = $this->staff;
  3547. $data ['receiptMemu'] = 'saeaBorad';
  3548. $data ['verifyId'] = $this->verifyId;
  3549. $data ['executeId'] = $this->executeId;
  3550. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3551. }
  3552. /**
  3553. * 添加讲师
  3554. */
  3555. function receiptTrainLecturerAddDo() {
  3556. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3557. // 支出项信息
  3558. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3559. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3560. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3561. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3562. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3563. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3564. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3565. Doo::loadClass ( 'XDeode' );
  3566. $XDeode = new XDeode ( 5 );
  3567. Doo::loadModel ( 'RILecturer' );
  3568. $RILecturer = new RILecturer ();
  3569. $rid = $XDeode->decode ( $ridKey );
  3570. if (! is_numeric ( $rid ))
  3571. die ( 'illegal request' );
  3572. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3573. die ( 'illegal request-taxationError' );
  3574. $RILecturer->rid = $rid;
  3575. $RILecturer->ltype = $ltype;
  3576. if ($ltype == 'OUTSIDE') {
  3577. if ($taxation == 'TAXATION') {
  3578. $RILecturer->taxation = 1;
  3579. } elseif ($taxation == 'NOTAXATION') {
  3580. $RILecturer->taxation = 0;
  3581. }
  3582. }
  3583. $RILecturer->lecturerName = $lecturerName;
  3584. $RILecturer->schoolDay = $schoolDay;
  3585. $RILecturer->price = $price;
  3586. $RILecturer->fees=$fees;
  3587. $RILecturer->insert ();
  3588. // 添加公司汇总
  3589. // 报销详情
  3590. Doo::loadModel ( 'receiptDetail' );
  3591. $receiptDetail = new receiptDetail ();
  3592. Doo::loadModel ( 'receipt' );
  3593. $receipt = new receipt ();
  3594. // 金额总计
  3595. $price = $price * $schoolDay;
  3596. $rInfo = $receipt->getReceiptByRid ( $rid );
  3597. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3598. if (empty ( $rdInfo )) {
  3599. $receiptDetail = new receiptDetail ();
  3600. $receiptDetail->staff = $rInfo ['staff'];
  3601. $receiptDetail->item = '讲课费';
  3602. $receiptDetail->itemCategory = '培训班费用';
  3603. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3604. $receiptDetail->date = date ( "Y-m-d" );
  3605. $receiptDetail->cid = $rInfo ['cid'];
  3606. $receiptDetail->rid = $rid;
  3607. $receiptDetail->status = 4;
  3608. $receiptDetail->insert ();
  3609. } else {
  3610. $receiptDetail = new receiptDetail ();
  3611. $rdInfo ['price'] += $fees;
  3612. $receiptDetail->price = $rdInfo ['price'];
  3613. $receiptDetail->update ( array (
  3614. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3615. ) );
  3616. }
  3617. $receipt = new receipt ();
  3618. $receipt->sum=$rInfo['sum']+$fees;
  3619. $receipt->update ( array (
  3620. 'where' => 'rid=' . $rid
  3621. ) );
  3622. $XDeode = new XDeode ( 7 );
  3623. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3624. } else
  3625. die ( 'illegal request' );
  3626. }
  3627. /**
  3628. * 移除讲师
  3629. */
  3630. function receiptTrainLecturerDelDo() {
  3631. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3632. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3633. Doo::loadModel ( 'receipt' );
  3634. $receipt = new receipt ();
  3635. Doo::loadModel ( 'RILecturer' );
  3636. $RILecturer = new RILecturer ();
  3637. Doo::loadClass ( 'XDeode' );
  3638. $XDeode = new XDeode ( 5 );
  3639. $rid = $XDeode->decode ( $ridKey );
  3640. $rlid = $XDeode->decode ( $rlidKey );
  3641. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3642. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3643. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3644. die ( 'illegal request-status' );
  3645. }
  3646. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3647. if (empty($detail)){
  3648. die ( 'illegal request-data' );
  3649. }
  3650. $RILecturer->delete ( array (
  3651. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3652. ) );
  3653. //更新费用合计金额
  3654. $rInfo = $receipt->getReceiptByRid ( $rid );
  3655. $receipt = new receipt ();
  3656. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3657. $receipt->update ( array (
  3658. 'where' => 'rid=' . $rid
  3659. ) );
  3660. Doo::loadModel ( 'receiptDetail' );
  3661. $receiptDetail = new receiptDetail ();
  3662. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3663. $receiptDetail = new receiptDetail ();
  3664. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3665. $receiptDetail->price = $rdInfo ['price'];
  3666. $receiptDetail->update ( array (
  3667. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3668. ) );
  3669. $XDeode = new XDeode ( 7 );
  3670. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3671. } else
  3672. die ( 'illegal request-iid' );
  3673. }
  3674. /**
  3675. * 培训班提交审批
  3676. */
  3677. function receiptTrainDo() {
  3678. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3679. Doo::loadClass ( 'XDeode' );
  3680. $XDeode = new XDeode ( 7 );
  3681. $rid = $XDeode->decode ( $ridKey );
  3682. Doo::loadModel ( 'receipt' );
  3683. $receipt = new receipt ();
  3684. Doo::loadModel ( 'receiptDetail' );
  3685. $receiptDetail = new receiptDetail ();
  3686. Doo::loadModel ( 'statistics' );
  3687. $statistics = new statistics ();
  3688. Doo::loadModel ( "verify" );
  3689. $verify = new verify ();
  3690. // 审批状态的判定
  3691. $receiptDetailList = $receipt->getOne ( array (
  3692. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3693. 'asArray' => true
  3694. ) );
  3695. if (empty ( $receiptDetailList ))
  3696. return "/saeaBorad";
  3697. $verifyDetail = $verify->getOne ( array (
  3698. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3699. 'asArray' => true
  3700. ) );
  3701. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3702. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3703. $nowStaff = "";
  3704. $nowStaffList = array ();
  3705. if ($verifyDetail [0] [1] == 'ROLE') {
  3706. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3707. foreach ( $vStaffString as $key => $value ) {
  3708. $staffK = explode ( "_", $value );
  3709. array_push ( $nowStaffList, $staffK [0] );
  3710. }
  3711. $nowStaff = implode ( ',', $nowStaffList );
  3712. } else {
  3713. $nowStaff = $verifyDetail [0] [0];
  3714. }
  3715. $receipt->nowStaff = $nowStaff;
  3716. }
  3717. // echo $nowStaff;
  3718. // print_r($verifyDetail);die;
  3719. $receipt->rid = $receiptDetailList ['rid'];
  3720. $receipt->date = date ( "Y-m-d" );
  3721. $receipt->status = 2;
  3722. $receipt->update ();
  3723. $receiptDetail->status = 2;
  3724. $receiptDetail->update ( array (
  3725. 'where' => 'rid=' . $receiptDetailList ['rid']
  3726. ) );
  3727. Doo::loadModel ( "receiptLog" );
  3728. $receiptLog = new receiptLog ();
  3729. Doo::loadModel ( "verify" );
  3730. $verify = new verify ();
  3731. $vr = $verify->getOne ( array (
  3732. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3733. 'asArray' => true
  3734. ) );
  3735. $jd = json_decode ( $vr ['staff'] );
  3736. $roleId = 0;
  3737. foreach ( $jd as $key => $value ) {
  3738. if ($value [1] == 'ROLE') {
  3739. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3740. if ($pos !== false) {
  3741. $roleId = $value [0];
  3742. }
  3743. }
  3744. }
  3745. // 审批日志
  3746. // echo $roleId;die;
  3747. if (! empty ( $roleId )) {
  3748. Doo::loadModel ( "role" );
  3749. $role = new role ();
  3750. $roleInfo = $role->getOne ( array (
  3751. 'where' => 'rid=' . $roleId,
  3752. 'asArray' => true
  3753. ) );
  3754. // $receiptLog->rolename = $roleInfo ['name'];
  3755. }
  3756. $receiptLog->username = $this->staff [0] ['username'];
  3757. $receiptLog->uid = $this->staff [0] ['sid'];
  3758. $receiptLog->date = date ( "Y-m-d" );
  3759. $receiptLog->opinion = '提交审批';
  3760. $receiptLog->img = $this->staff [0] ['avatar'];
  3761. $receiptLog->status = 2;
  3762. $receiptLog->rid = $rid;
  3763. $receiptLog->insert ();
  3764. // 写入列表项
  3765. Doo::loadModel ( 'accountItem' );
  3766. $accountItem = new accountItem ();
  3767. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3768. // 项目金额合计
  3769. Doo::loadModel ( 'RItem' );
  3770. $RItem = new RItem ();
  3771. // 讲师获得
  3772. Doo::loadModel ( 'RILecturer' );
  3773. $RILecturer = new RILecturer ();
  3774. $RItemList = $RItem->getRItemByRid ( $rid );
  3775. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3776. // 支出项金额详情
  3777. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3778. // print_r($aItem);
  3779. // print_r($aiData);
  3780. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3781. $ag = $tr = $ta = $ot = 0;
  3782. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3783. foreach ( $aItem as $key => $value ) {
  3784. if ($value ['category'] == $this->TRAIN) {
  3785. foreach ( $aiData ['dataList'] as $k => $v ) {
  3786. if ($value ['name'] == $v ['name']) {
  3787. array_push ( $accountJson [$this->TRAIN], array (
  3788. 'aid' => $value ['aid'],
  3789. 'name' => $value ['name'],
  3790. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3791. ) );
  3792. $sum += $v ['price'];
  3793. $trainSum += $v ['price'];
  3794. unset ( $aiData ['dataList'] [$k] );
  3795. break;
  3796. }
  3797. }
  3798. }
  3799. }
  3800. $accountJson ['cSum'] = array (
  3801. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3802. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3803. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3804. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3805. );
  3806. // 报销单
  3807. $receipt = new receipt ();
  3808. $receipt->accountItem = json_encode ( $accountJson );
  3809. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3810. $receipt->update ( array (
  3811. 'where' => 'rid=' . $rid
  3812. ) );
  3813. // print_r($accountJson);
  3814. // statistics item 统计写入
  3815. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3816. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3817. $accountItem = $accountJson;
  3818. $stat = $statistics->getOne ( array (
  3819. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3820. 'asArray' => true
  3821. ) );
  3822. if (empty ( $stat )) {
  3823. $statistics->date = date ( "Y-m-d" );
  3824. $statistics->cid = $this->staff [0] ['cid'];
  3825. $statistics->staff = $this->staff [0] ['sid'];
  3826. $statistics->agPrice = 0;
  3827. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3828. $statistics->insert ();
  3829. } else {
  3830. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3831. $statistics->update ( array (
  3832. 'where' => 'sid=' . $stat ['sid']
  3833. ) );
  3834. }
  3835. return "/saeaBorad";
  3836. }
  3837. function confirmation() {
  3838. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3839. Doo::loadModel ( 'receipt' );
  3840. Doo::loadModel ( 'receiptDetail' );
  3841. $receipt = new receipt ();
  3842. $receiptDetail = new receiptDetail ();
  3843. Doo::loadModel ( 'statistics' );
  3844. Doo::loadModel ( 'itemStatistics' );
  3845. $statistics = new statistics ();
  3846. $itemStatistics = new itemStatistics ();
  3847. Doo::loadModel ( "verify" );
  3848. $verify = new verify ();
  3849. $receiptDetailList = $receipt->getOne ( array (
  3850. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3851. 'asArray' => true
  3852. ) );
  3853. if (empty ( $receiptDetailList ))
  3854. return "/saeaBorad";
  3855. $verifyDetail = $verify->getOne ( array (
  3856. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3857. 'asArray' => true
  3858. ) );
  3859. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3860. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3861. $nowStaff = "";
  3862. $nowStaffList = array ();
  3863. if ($verifyDetail [0] [1] == 'ROLE') {
  3864. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3865. foreach ( $vStaffString as $key => $value ) {
  3866. $staffK = explode ( "_", $value );
  3867. array_push ( $nowStaffList, $staffK [0] );
  3868. }
  3869. $nowStaff = implode ( ',', $nowStaffList );
  3870. } else {
  3871. $nowStaff = $verifyDetail [0] [0];
  3872. }
  3873. $receipt->nowStaff = $nowStaff;
  3874. }
  3875. // echo $nowStaff;
  3876. // print_r($verifyDetail);die;
  3877. $receipt->rid = $receiptDetailList ['rid'];
  3878. $receipt->status = 2;
  3879. $receipt->update ();
  3880. // 操作日志
  3881. Doo::loadModel ( "receiptLog" );
  3882. $receiptLog = new receiptLog ();
  3883. $verify = new verify ();
  3884. $receiptInfo = $receipt->getOne ( array (
  3885. 'where' => 'rid=' . $rid,
  3886. 'asArray' => true
  3887. ) );
  3888. $vr = $verify->getOne ( array (
  3889. 'where' => 'vid=' . $receiptInfo ['verify'],
  3890. 'asArray' => true
  3891. ) );
  3892. $jd = json_decode ( $vr ['staff'] );
  3893. $roleId = 0;
  3894. foreach ( $jd as $key => $value ) {
  3895. if ($value [1] == 'ROLE') {
  3896. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3897. if ($pos !== false) {
  3898. $roleId = $value [0];
  3899. }
  3900. }
  3901. }
  3902. // 审批日志
  3903. // echo $roleId;die;
  3904. if (! empty ( $roleId )) {
  3905. Doo::loadModel ( "role" );
  3906. $role = new role ();
  3907. $roleInfo = $role->getOne ( array (
  3908. 'where' => 'rid=' . $roleId,
  3909. 'asArray' => true
  3910. ) );
  3911. // $receiptLog->rolename = $roleInfo ['name'];
  3912. }
  3913. $receiptLog->username = $this->staff [0] ['username'];
  3914. $receiptLog->uid = $this->staff [0] ['sid'];
  3915. $receiptLog->date = date ( "Y-m-d" );
  3916. $receiptLog->opinion = '提交审批';
  3917. $receiptLog->img = $this->staff [0] ['avatar'];
  3918. $receiptLog->status = 2;
  3919. $receiptLog->rid = $rid;
  3920. $receiptLog->insert ();
  3921. return "/expenses";
  3922. }
  3923. function expenses() {
  3924. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3925. if (empty ( $item ))
  3926. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3927. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3928. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3929. Doo::loadClass ( 'XDeode' );
  3930. $XDeode = new XDeode ( 7 );
  3931. Doo::loadModel ( 'receipt' );
  3932. $receipt = new receipt ();
  3933. Doo::loadModel ( 'L_category' );
  3934. $Lcategory = new L_category ();
  3935. Doo::loadModel ( 'verify' );
  3936. Doo::loadModel ( 'statistics' );
  3937. $statistics = new statistics ();
  3938. $verify = new verify ();
  3939. Doo::loadModel ( 'staff' );
  3940. $staff = new staff ();
  3941. $condition = "";
  3942. if ($item == "expenses")
  3943. $condition = " and Rtype=1 ";
  3944. elseif ($item == "receipts")
  3945. $condition = " and Rtype=0 ";
  3946. elseif ($item == "remits")
  3947. $condition = " and Rtype=2 ";
  3948. elseif ($item == "train")
  3949. $condition = " and Rtype=3 ";
  3950. $dateCondition = " and Year(date) =" . $year;
  3951. if (! empty ( $moth )) {
  3952. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3953. $stList = $statistics->getOne ( array (
  3954. 'select' => 'rePrice ,agPrice',
  3955. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3956. 'asArray' => true
  3957. ) );
  3958. } else
  3959. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3960. if (empty ( $stList ))
  3961. $stList = array (
  3962. 'rePrice' => 0,
  3963. 'agPrice' => 0
  3964. );
  3965. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3966. if (! isset ( $noPassSum ['sum'] ))
  3967. $noPassSum ['sum'] = 0;
  3968. $data ['stList'] = array (
  3969. 'rePrice' => $stList ['rePrice'],
  3970. 'agPrice' => $stList ['agPrice'],
  3971. 'skPrice' => ($noPassSum ['sum'])
  3972. );
  3973. $receiptList = $receipt->find ( array (
  3974. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3975. 'desc' => 'rid',
  3976. 'asArray' => true
  3977. ) );
  3978. $Locate = 0;
  3979. $roleId = 0;
  3980. $button = 0;
  3981. foreach ( $receiptList as $key => $value ) {
  3982. $receiptList[$key]['balance']='';
  3983. if($value['Rtype']==1){
  3984. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3985. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3986. }elseif($value['Rtype']==3){
  3987. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3988. $receiptList[$key]['payment']=$payment;
  3989. $receiptList[$key]['paymentABS']=abs($payment);
  3990. }
  3991. $receiptList [$key] ['Locate'] = $Locate;
  3992. $Locate ++;
  3993. $receiptList [$key] ['reviseDetail'] = array ();
  3994. if (! empty ( $value ['reviseDetail'] ))
  3995. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3996. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3997. $categoryDetil = $Lcategory->getOne ( array (
  3998. 'where' => 'cid=' . $value ['cid'],
  3999. 'asArray' => true
  4000. ) );
  4001. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4002. // 检测编辑状态
  4003. $verifyList = $verify->getOne ( array (
  4004. 'where' => 'vid=' . $value ['verify'],
  4005. 'asArray' => true
  4006. ) );
  4007. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4008. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4009. Doo::loadModel ( 'role' );
  4010. $role = new role ();
  4011. $flag = true;
  4012. $roleKey = 0;
  4013. $endStaffArray = array ();
  4014. $roleArrayCopy = array ();
  4015. foreach ( $verifyList as $k => $v ) {
  4016. // init verifyStaff
  4017. if ($v [1] == 'ROLE') {
  4018. if (! empty ( $verifyStaff )) {
  4019. $endStaffArray = end ( $verifyStaff );
  4020. // if ($v[0]==$endStaffArray['nextStaff']){
  4021. // $roleId=$v[0];
  4022. // }
  4023. }
  4024. $roleVerify = json_decode ( $v [3], true );
  4025. $roleKey = $k;
  4026. $roleArray = array ();
  4027. $rolename = $role->getOne ( array (
  4028. 'where' => 'rid=' . $v [0],
  4029. 'asArray' => true
  4030. ) );
  4031. foreach ( $roleVerify as $o => $p ) {
  4032. $staffID = explode ( '_', $p );
  4033. $staffInfo = $staff->getOne ( array (
  4034. 'where' => 'sid=' . $staffID [0],
  4035. 'asArray' => true
  4036. ) );
  4037. // print_r($staffID);
  4038. $exp = array (
  4039. 0 => $staffInfo ['sid'],
  4040. 1 => $staffID [1],
  4041. 2 => $staffInfo ['avatar'],
  4042. 'date' => '',
  4043. 'date' => '',
  4044. 'opinion' => '',
  4045. 'status' => '',
  4046. 'rolename' => $rolename ['name']
  4047. );
  4048. array_push ( $roleArray, $exp );
  4049. }
  4050. $roleArrayCopy [$v [0]] = $roleArray;
  4051. // $verifyList[$k]['roleArray']=$roleArray;
  4052. }
  4053. $verifyList [$k] ['date'] = "";
  4054. $verifyList [$k] ['opinion'] = "";
  4055. $verifyList [$k] ['status'] = "";
  4056. if (empty ( $verifyStaff )) {
  4057. $verifyList [$k] ['date'] = "";
  4058. $verifyList [$k] ['opinion'] = "";
  4059. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4060. $verifyList [$k] ['status'] = 4;
  4061. $flag = false;
  4062. }
  4063. } else {
  4064. foreach ( $verifyStaff as $m => $u ) {
  4065. if ($v [0] == $m) {
  4066. $verifyList [$k] ['date'] = $u ['date'];
  4067. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4068. $verifyList [$k] ['status'] = $u ['status'];
  4069. $flag = false;
  4070. break;
  4071. }
  4072. }
  4073. $endStaffArray = end ( $verifyStaff );
  4074. if (isset ( $endStaffArray ['ROLE'] )) {
  4075. } else {
  4076. // $endKey=key($verifyStaff);
  4077. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4078. // $button=4;
  4079. // $verifyList[$k]['status']=4;
  4080. // }
  4081. }
  4082. }
  4083. }
  4084. $rolename ['name'] = '';
  4085. if (! empty ( $roleId )) {
  4086. Doo::loadModel ( 'role' );
  4087. $role = new role ();
  4088. $rolename = $role->getOne ( array (
  4089. 'where' => 'rid=' . $roleId,
  4090. 'asArray' => true
  4091. ) );
  4092. }
  4093. if (! empty ( $verifyStaff ))
  4094. $endStaffArray = end ( $verifyStaff );
  4095. $KOP = false;
  4096. foreach ( $roleArrayCopy as $P => $A ) {
  4097. foreach ( $A as $MKI => $AVL ) {
  4098. if (! empty ( $verifyStaff )) {
  4099. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4100. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4101. $button = 4;
  4102. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4103. }
  4104. foreach ( $verifyStaff as $m => $u ) {
  4105. $AVLFK = $AVL [0] . '_R';
  4106. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4107. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4108. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4109. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4110. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4111. break;
  4112. }
  4113. }
  4114. } else {
  4115. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4116. $button = 4;
  4117. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4118. }
  4119. }
  4120. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4121. $KOP = true;
  4122. }
  4123. }
  4124. foreach ( $roleArrayCopy as $k => $v ) {
  4125. foreach ( $verifyList as $m => $n ) {
  4126. if ($n [0] == $k) {
  4127. array_splice ( $verifyList, $m, 1, $v );
  4128. }
  4129. }
  4130. }
  4131. $receiptList [$key] ['verifyList'] = $verifyList;
  4132. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4133. 'where' => 'sid=' . $value ['staff'],
  4134. 'asArray' => true
  4135. ) );
  4136. $receiptList [$key] ['button'] = $button;
  4137. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4138. if($value['version']==1){
  4139. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4140. }
  4141. }
  4142. // print_r($receiptList);die;
  4143. $mothHtml = "";
  4144. for($i = 1; $i <= 12; $i ++) {
  4145. if ($moth == $i)
  4146. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4147. else
  4148. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4149. }
  4150. $dateHtml = "";
  4151. $now = date ( "Y" );
  4152. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4153. if ($YEARD <= $now) {
  4154. $dateHtml .= '<option ';
  4155. if ($year == $YEARD) {
  4156. $dateHtml .= 'selected ';
  4157. }
  4158. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4159. }
  4160. }
  4161. $data ['dateHtml'] = $dateHtml;
  4162. $data ['mothHtml'] = $mothHtml;
  4163. $data ['receiptList'] = $receiptList;
  4164. $data ['memu'] = "receipt";
  4165. $data ['staff'] = $this->staff;
  4166. $data ['receiptMemu'] = 'expenses';
  4167. $data ['verifyId'] = $this->verifyId;
  4168. $data ['executeId'] = $this->executeId;
  4169. $data ['item'] = $item;
  4170. $data ['year'] = $year;
  4171. $this->render ( "/admin/expenses", $data );
  4172. }
  4173. function expensesCollect() {
  4174. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4175. Doo::loadModel ( 'receipt' );
  4176. $receipt = new receipt ();
  4177. Doo::loadModel ( 'L_category' );
  4178. $Lcategory = new L_category ();
  4179. Doo::loadModel ( 'verify' );
  4180. Doo::loadModel ( 'statistics' );
  4181. $statistics = new statistics ();
  4182. $verify = new verify ();
  4183. Doo::loadModel ( 'staff' );
  4184. $staff = new staff ();
  4185. Doo::loadModel ( 'loanReceipt' );
  4186. $loanReceipt = new loanReceipt ();
  4187. $receiptList = $receipt->find ( array (//去掉
  4188. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4189. 'desc' => 'rid',
  4190. 'asArray' => true
  4191. ) );
  4192. $loanList = $loanReceipt->find ( array (
  4193. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4194. 'desc' => 'rid',
  4195. 'asArray' => true
  4196. ) );
  4197. /*
  4198. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  4199. */
  4200. $data ['explanation'] = '';
  4201. if (! empty ( $loanList ))
  4202. $data ['explanation'] = $loanList [0] ['explanation'];
  4203. $Locate = 0;
  4204. $roleId = 0;
  4205. $button = 0;
  4206. foreach ( $receiptList as $key => $value ) {
  4207. $receiptList [$key] ['Locate'] = $Locate;
  4208. $Locate ++;
  4209. $receiptList [$key] ['reviseDetail'] = array ();
  4210. if (! empty ( $value ['reviseDetail'] ))
  4211. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4212. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4213. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4214. $categoryDetil = $Lcategory->getOne ( array (
  4215. 'where' => 'cid=' . $value ['cid'],
  4216. 'asArray' => true
  4217. ) );
  4218. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4219. // 检测编辑状态
  4220. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4221. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4222. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4223. else
  4224. $verifyList ['staff'] = $value ['verifyBreakup'];
  4225. } else
  4226. $verifyList = $verify->getOne ( array (
  4227. 'where' => 'vid=' . $value ['verify'],
  4228. 'asArray' => true
  4229. ) );
  4230. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4231. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4232. Doo::loadModel ( 'role' );
  4233. $role = new role ();
  4234. $flag = true;
  4235. $roleKey = 0;
  4236. $endStaffArray = array ();
  4237. $roleArrayCopy = array ();
  4238. foreach ( $verifyList as $k => $v ) {
  4239. // init verifyStaff
  4240. if ($v [1] == 'ROLE') {
  4241. if (! empty ( $verifyStaff )) {
  4242. $endStaffArray = end ( $verifyStaff );
  4243. // if ($v[0]==$endStaffArray['nextStaff']){
  4244. // $roleId=$v[0];
  4245. // }
  4246. }
  4247. $roleVerify = json_decode ( $v [3], true );
  4248. $roleKey = $k;
  4249. $roleArray = array ();
  4250. $rolename = $role->getOne ( array (
  4251. 'where' => 'rid=' . $v [0],
  4252. 'asArray' => true
  4253. ) );
  4254. foreach ( $roleVerify as $o => $p ) {
  4255. $staffID = explode ( '_', $p );
  4256. $staffInfo = $staff->getOne ( array (
  4257. 'where' => 'sid=' . $staffID [0],
  4258. 'asArray' => true
  4259. ) );
  4260. // print_r($staffID);
  4261. $exp = array (
  4262. 0 => $staffInfo ['sid'],
  4263. 1 => $staffID [1],
  4264. 2 => $staffInfo ['avatar'],
  4265. 'date' => '',
  4266. 'date' => '',
  4267. 'opinion' => '',
  4268. 'status' => '',
  4269. 'rolename' => $rolename ['name']
  4270. );
  4271. array_push ( $roleArray, $exp );
  4272. }
  4273. $roleArrayCopy [$v [0]] = $roleArray;
  4274. // $verifyList[$k]['roleArray']=$roleArray;
  4275. }
  4276. $verifyList [$k] ['date'] = "";
  4277. $verifyList [$k] ['opinion'] = "";
  4278. $verifyList [$k] ['status'] = "";
  4279. if (empty ( $verifyStaff )) {
  4280. $verifyList [$k] ['date'] = "";
  4281. $verifyList [$k] ['opinion'] = "";
  4282. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4283. $verifyList [$k] ['status'] = 4;
  4284. $flag = false;
  4285. }
  4286. } else {
  4287. foreach ( $verifyStaff as $m => $u ) {
  4288. if ($v [0] == $m) {
  4289. $verifyList [$k] ['date'] = $u ['date'];
  4290. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4291. $verifyList [$k] ['status'] = $u ['status'];
  4292. $flag = false;
  4293. break;
  4294. }
  4295. }
  4296. $endStaffArray = end ( $verifyStaff );
  4297. if (isset ( $endStaffArray ['ROLE'] )) {
  4298. } else {
  4299. // $endKey=key($verifyStaff);
  4300. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4301. // $button=4;
  4302. // $verifyList[$k]['status']=4;
  4303. // }
  4304. }
  4305. }
  4306. }
  4307. $rolename ['name'] = '';
  4308. if (! empty ( $roleId )) {
  4309. Doo::loadModel ( 'role' );
  4310. $role = new role ();
  4311. $rolename = $role->getOne ( array (
  4312. 'where' => 'rid=' . $roleId,
  4313. 'asArray' => true
  4314. ) );
  4315. }
  4316. if (! empty ( $verifyStaff ))
  4317. $endStaffArray = end ( $verifyStaff );
  4318. $KOP = false;
  4319. foreach ( $roleArrayCopy as $P => $A ) {
  4320. foreach ( $A as $MKI => $AVL ) {
  4321. if (! empty ( $verifyStaff )) {
  4322. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4323. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4324. $button = 4;
  4325. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4326. }
  4327. foreach ( $verifyStaff as $m => $u ) {
  4328. $AVLFK = $AVL [0] . '_R';
  4329. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4330. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4331. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4332. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4333. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4334. break;
  4335. }
  4336. }
  4337. } else {
  4338. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4339. $button = 4;
  4340. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4341. }
  4342. }
  4343. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4344. $KOP = true;
  4345. }
  4346. }
  4347. foreach ( $roleArrayCopy as $k => $v ) {
  4348. foreach ( $verifyList as $m => $n ) {
  4349. if ($n [0] == $k) {
  4350. array_splice ( $verifyList, $m, 1, $v );
  4351. }
  4352. }
  4353. }
  4354. // 费用执行人相关数据
  4355. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4356. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4357. foreach ( $executeCopy as $k => $v ) {
  4358. $executeCopy [$k] ['date'] = '';
  4359. $executeCopy [$k] ['opinion'] = '';
  4360. $executeCopy [$k] ['status'] = '';
  4361. if (! empty ( $executeStaff ))
  4362. foreach ( $executeStaff as $m => $u ) {
  4363. if ($v [0] == $m) {
  4364. $executeCopy [$k] ['date'] = $u ['date'];
  4365. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4366. $executeCopy [$k] ['status'] = $u ['status'];
  4367. break;
  4368. }
  4369. }
  4370. }
  4371. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4372. $receiptList [$key] ['verifyList'] = $verifyList;
  4373. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4374. 'where' => 'sid=' . $value ['staff'],
  4375. 'asArray' => true
  4376. ) );
  4377. $receiptList [$key] ['button'] = $button;
  4378. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4379. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4380. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4381. $receiptList [$key] ['relust'] = $relust;
  4382. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4383. }
  4384. Doo::loadModel ( 'enclosur' );
  4385. $enclosur = new enclosur ();
  4386. $enclosurList = $enclosur->find ( array (
  4387. 'where' => 'rid=' . $rid,
  4388. 'asArray' => true
  4389. ) );
  4390. $enclosurHtml = '';
  4391. foreach ( $enclosurList as $value ) {
  4392. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4393. }
  4394. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  4395. $data ['enclosurHtml'] = $enclosurHtml;
  4396. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4397. if($receiptList[0]['version']==1){
  4398. require "protected/class/comm_cld.php";
  4399. $receiptList=makeReceiptDataVersion1($receiptList);
  4400. }
  4401. $data ['receiptList'] = $receiptList;
  4402. $data ['memu'] = "receipt";
  4403. $data ['staff'] = $this->staff;
  4404. $data ['receiptMemu'] = 'expenses';
  4405. $data ['verifyId'] = $this->verifyId;
  4406. $data ['executeId'] = $this->executeId;
  4407. if($receiptList[0]['version']==1){
  4408. $this->render ( "/fee/detail/receipt_compatible", $data );
  4409. die;
  4410. }
  4411. if($receiptList[0]['receiptClass']==2){
  4412. if(!empty($receiptList[0]['itinerary2'])){
  4413. $this->render ( "/receipt/feeTraveDetail2", $data );
  4414. }else{
  4415. $this->render ( "/receipt/feeTraveDetail", $data );
  4416. }
  4417. }else{
  4418. $this->render ( "/admin/expensesCollect", $data );
  4419. }
  4420. }
  4421. function approvalExpenses() {
  4422. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4423. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4424. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4425. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4426. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4427. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4428. // echo $rdate;
  4429. if (empty ( $status ))
  4430. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4431. $page_size = 8;
  4432. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4433. $vidList = array ();
  4434. $button = 0;
  4435. Doo::loadModel ( 'verify' );
  4436. $verify = new verify ();
  4437. Doo::loadModel ( 'receipt' );
  4438. $receipt = new receipt ();
  4439. Doo::loadModel ( 'staff' );
  4440. $staff = new staff ();
  4441. Doo::loadModel ( 'L_category' );
  4442. $Lcategory = new L_category ();
  4443. // user verify ID
  4444. $verifyDetail = $verify->find ( array (
  4445. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4446. 'asArray' => true
  4447. ) );
  4448. foreach ( $verifyDetail as $key => $value ) {
  4449. array_push ( $vidList, $value ['vid'] );
  4450. }
  4451. $vid = implode ( ",", $vidList );
  4452. if (empty ( $verifyDetail )){
  4453. $vid = 0;
  4454. }
  4455. $dateCondition = " ";
  4456. // if (! empty ( $month ))
  4457. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4458. if ($status == 'done' || $status == 'termination') {
  4459. if (! empty ( $year )) {
  4460. $dateCondition = " and Year(pastDate) =" . $year;
  4461. if (! empty ( $month ))
  4462. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4463. }
  4464. } elseif ($status == 'finish') {
  4465. if (! empty ( $year )) {
  4466. $dateCondition = " and Year(pastDate) =" . $year;
  4467. if (! empty ( $month ))
  4468. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4469. }
  4470. }
  4471. // date ( 'Y-m' )
  4472. // if (! empty ( $rdate ) && $status == 'done')
  4473. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4474. // elseif (! empty ( $rdate ))
  4475. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4476. $categoryList = $Lcategory->find ( array (
  4477. 'asArray' => true
  4478. ) );
  4479. $staffList = $staff->find ( array (
  4480. 'where' => 'cid=' . $cid,
  4481. 'asArray' => true
  4482. ) );
  4483. $cateCondition = "";
  4484. $staffCondition = "";
  4485. $approvalCondition = "";
  4486. if (! empty ( $cid )) {
  4487. $cateCondition = ' and cid=' . $cid;
  4488. }
  4489. if (! empty ( $sid )) {
  4490. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4491. $cateCondition = "";
  4492. }
  4493. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4494. if ($status == 'pendApproval') {
  4495. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4496. }
  4497. if ($status == 'ongoing') {
  4498. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4499. }
  4500. if ($status == 'done') {
  4501. $approvalCondition = ' and (status=8 or status=9 ) ';
  4502. }
  4503. if ($status == 'termination') {
  4504. $approvalCondition = " and status=3";
  4505. }
  4506. if ($status == 'finish') {
  4507. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4508. }
  4509. if($status == 'loan'){
  4510. $approvalCondition = " and (status=8 or status=7) and Rtype=1";
  4511. }
  4512. $pageinfo ['page'] = array (
  4513. 'previous' => ''
  4514. );
  4515. if(!empty($receiptOrder)){
  4516. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4517. $receiptList = $receipt->find ( array ( // $dateCondition
  4518. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4519. 'desc' => 'rid',
  4520. 'asArray' => true
  4521. ) );
  4522. }else{
  4523. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4524. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4525. $receiptList = $receipt->find ( array ( // $dateCondition.
  4526. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4527. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4528. 'desc' => 'rid',
  4529. 'asArray' => true
  4530. ) );
  4531. } else {
  4532. $receiptList = $receipt->find ( array ( // $dateCondition
  4533. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4534. 'desc' => 'rid',
  4535. 'asArray' => true
  4536. ) );
  4537. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4538. }
  4539. }
  4540. $rLRes = $receipt->find ( array (
  4541. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  4542. 'desc' => 'rid',
  4543. 'asArray' => true
  4544. ) );
  4545. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4546. // print_r($receiptList);
  4547. Doo::loadClass ( 'XDeode' );
  4548. $XDeode = new XDeode ( 7 );
  4549. $XDeode9 = new XDeode ( 9 );
  4550. $Locate = 0;
  4551. //
  4552. $reportList = $reportCateList = array ();
  4553. foreach ( $receiptList as $key => $value ) {
  4554. $receiptList [$key] ['rid_cld'] = $XDeode9->encode ( $value ['rid'] );
  4555. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4556. $receiptList [$key] ['Locate'] = $Locate;
  4557. $Locate ++;
  4558. $receiptList [$key] ['reviseDetail'] = array ();
  4559. if (! empty ( $value ['reviseDetail'] ))
  4560. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4561. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4562. $categoryDetil = $Lcategory->getOne ( array (
  4563. 'where' => 'cid=' . $value ['cid'],
  4564. 'asArray' => true
  4565. ) );
  4566. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4567. $verifyList = $verify->getOne ( array (
  4568. 'where' => 'vid=' . $value ['verify'],
  4569. 'asArray' => true
  4570. ) );
  4571. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4572. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4573. foreach ( $verifyList as $k => $v ) {
  4574. // init verifyStaff
  4575. $verifyList [$k] ['date'] = "";
  4576. $verifyList [$k] ['opinion'] = "";
  4577. $verifyList [$k] ['status'] = "";
  4578. if (empty ( $verifyStaff )) {
  4579. $verifyList [$k] ['date'] = "";
  4580. $verifyList [$k] ['opinion'] = "";
  4581. if ($v [0] == $this->staff [0] ['sid']) {
  4582. $verifyList [$k] ['status'] = 4;
  4583. $button = 4;
  4584. }
  4585. } else {
  4586. $flag = true;
  4587. foreach ( $verifyStaff as $m => $u ) {
  4588. if ($v [0] == $m) {
  4589. $verifyList [$k] ['date'] = $u ['date'];
  4590. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4591. $verifyList [$k] ['status'] = $u ['status'];
  4592. $flag = false;
  4593. break;
  4594. }
  4595. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4596. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4597. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4598. }
  4599. if ($flag) { // 检测可编辑
  4600. if ($v [0] == $this->staff [0] ['sid']) {
  4601. $verifyList [$k] ['status'] = 4;
  4602. $button = 4;
  4603. }
  4604. }
  4605. }
  4606. }
  4607. $receiptList [$key] ['verifyList'] = $verifyList;
  4608. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4609. 'where' => 'sid=' . $value ['staff'],
  4610. 'asArray' => true
  4611. ) );
  4612. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4613. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4614. $receiptList [$key] ['button'] = $button;
  4615. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4616. //获得培训班结算RID 借款费用--已经锁定
  4617. if($value['status']==10){
  4618. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4619. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4620. }
  4621. if($value['version']==1){
  4622. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  4623. }
  4624. }
  4625. $reportList = array_unique ( $reportList );
  4626. $reportHtml = '';
  4627. foreach ( $reportList as $key => $value ) {
  4628. $v = explode ( "-", $value );
  4629. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4630. }
  4631. // print_r($reportList)
  4632. $data ['reportHtml'] = $reportHtml;
  4633. $reportCateList = array_unique ( $reportCateList );
  4634. $reportCateHtml = '';
  4635. foreach ( $reportCateList as $key => $value ) {
  4636. $v = explode ( "-", $value );
  4637. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4638. }
  4639. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4640. $data ['reportCateHtml'] = $reportCateHtml;
  4641. // print_r($receiptList);die;
  4642. // $data['verifyDetail']=$verifyDetail;
  4643. $mothHtml = "";
  4644. for($i = 1; $i <= 12; $i ++) {
  4645. if ($month == $i)
  4646. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4647. else
  4648. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4649. }
  4650. $data ['mothHtml'] = $mothHtml;
  4651. $dateHtml = "";
  4652. $now = date ( "Y" );
  4653. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4654. if ($YEARD <= $now) {
  4655. $dateHtml .= '<option ';
  4656. if ($year == $YEARD) {
  4657. $dateHtml .= 'selected ';
  4658. }
  4659. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4660. }
  4661. }
  4662. $data ['dateHtml'] = $dateHtml;
  4663. $data ['page'] = $pageinfo;
  4664. $data ['receiptList'] = $receiptList;
  4665. $data ['receiptApprovalCount'] = count ( $rLRes );
  4666. $data ['status'] = $status;
  4667. $data ['year'] = $year;
  4668. $data ['month'] = $month;
  4669. $data ['categoryList'] = $categoryList;
  4670. $data ['staffList'] = $staffList;
  4671. $data ['cid'] = $cid;
  4672. $data ['sid'] = $sid;
  4673. // print_r($receiptList);
  4674. $data['receiptOrder']=$receiptOrder;
  4675. $data ['memu'] = "receipt";
  4676. $data ['staff'] = $this->staff;
  4677. $data ['receiptMemu'] = 'approvalExpenses';
  4678. $data ['verifyId'] = $this->verifyId;
  4679. $data ['executeId'] = $this->executeId;
  4680. $this->render ( "/admin/approvalExpenses", $data );
  4681. }
  4682. private function _expensesDoc(){
  4683. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4684. Doo::loadClass ( 'XDeode' );
  4685. $XDeode = new XDeode ( 5 );
  4686. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4687. $rid = $XDeode->decode ( $rid );
  4688. if (! is_numeric ( $rid ))
  4689. die ( 'illegal request' );
  4690. Doo::loadModel ( 'receipt' );
  4691. $receipt = new receipt ();
  4692. Doo::loadModel ( 'L_category' );
  4693. $Lcategory = new L_category ();
  4694. Doo::loadModel ( 'verify' );
  4695. Doo::loadModel ( 'statistics' );
  4696. $statistics = new statistics ();
  4697. $verify = new verify ();
  4698. Doo::loadModel ( 'staff' );
  4699. $staff = new staff ();
  4700. Doo::loadModel ( 'loanReceipt' );
  4701. $loanReceipt = new loanReceipt ();
  4702. $receiptList = $receipt->find ( array (
  4703. 'where' => ' rid=' . $rid,
  4704. 'desc' => 'rid',
  4705. 'asArray' => true
  4706. ) );
  4707. $loanList = array ();
  4708. if (! empty ( $receiptList ))
  4709. $loanList = $loanReceipt->find ( array (
  4710. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4711. 'desc' => 'rid',
  4712. 'asArray' => true
  4713. ) );
  4714. $Locate = 0;
  4715. $roleId = 0;
  4716. $button = 0;
  4717. foreach ( $loanList as $key => $value ) {
  4718. $loanList [$key] ['Locate'] = $Locate;
  4719. $Locate ++;
  4720. $loanList [$key] ['reviseDetail'] = array ();
  4721. if (! empty ( $value ['reviseDetail'] ))
  4722. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4723. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4724. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4725. $categoryDetil = $Lcategory->getOne ( array (
  4726. 'where' => 'cid=' . $value ['cid'],
  4727. 'asArray' => true
  4728. ) );
  4729. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4730. // 检测编辑状态
  4731. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4732. $verifyList ['staff'] = $value ['verifyBreakup'];
  4733. else
  4734. $verifyList = $verify->getOne ( array (
  4735. 'where' => 'vid=' . $value ['verify'],
  4736. 'asArray' => true
  4737. ) );
  4738. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4739. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4740. Doo::loadModel ( 'role' );
  4741. $role = new role ();
  4742. $flag = true;
  4743. $roleKey = 0;
  4744. $endStaffArray = array ();
  4745. $roleArrayCopy = array ();
  4746. foreach ( $verifyList as $k => $v ) {
  4747. // init verifyStaff
  4748. if ($v [1] == 'ROLE') {
  4749. if (! empty ( $verifyStaff )) {
  4750. $endStaffArray = end ( $verifyStaff );
  4751. // if ($v[0]==$endStaffArray['nextStaff']){
  4752. // $roleId=$v[0];
  4753. // }
  4754. }
  4755. $roleVerify = json_decode ( $v [3], true );
  4756. $roleKey = $k;
  4757. $roleArray = array ();
  4758. $rolename = $role->getOne ( array (
  4759. 'where' => 'rid=' . $v [0],
  4760. 'asArray' => true
  4761. ) );
  4762. foreach ( $roleVerify as $o => $p ) {
  4763. $staffID = explode ( '_', $p );
  4764. $staffInfo = $staff->getOne ( array (
  4765. 'where' => 'sid=' . $staffID [0],
  4766. 'asArray' => true
  4767. ) );
  4768. // print_r($staffID);
  4769. $exp = array (
  4770. 0 => $staffInfo ['sid'],
  4771. 1 => $staffID [1],
  4772. 2 => $staffInfo ['avatar'],
  4773. 'date' => '',
  4774. 'date' => '',
  4775. 'opinion' => '',
  4776. 'status' => '',
  4777. 'rolename' => $rolename ['name']
  4778. );
  4779. array_push ( $roleArray, $exp );
  4780. }
  4781. $roleArrayCopy [$v [0]] = $roleArray;
  4782. // $verifyList[$k]['roleArray']=$roleArray;
  4783. }
  4784. $verifyList [$k] ['date'] = "";
  4785. $verifyList [$k] ['opinion'] = "";
  4786. $verifyList [$k] ['status'] = "";
  4787. if (empty ( $verifyStaff )) {
  4788. $verifyList [$k] ['date'] = "";
  4789. $verifyList [$k] ['opinion'] = "";
  4790. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4791. $verifyList [$k] ['status'] = 4;
  4792. $flag = false;
  4793. }
  4794. } else {
  4795. foreach ( $verifyStaff as $m => $u ) {
  4796. if ($v [0] == $m) {
  4797. $verifyList [$k] ['date'] = $u ['date'];
  4798. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4799. $verifyList [$k] ['status'] = $u ['status'];
  4800. $flag = false;
  4801. break;
  4802. }
  4803. }
  4804. $endStaffArray = end ( $verifyStaff );
  4805. if (isset ( $endStaffArray ['ROLE'] )) {
  4806. } else {
  4807. // $endKey=key($verifyStaff);
  4808. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4809. // $button=4;
  4810. // $verifyList[$k]['status']=4;
  4811. // }
  4812. }
  4813. }
  4814. }
  4815. $rolename ['name'] = '';
  4816. if (! empty ( $roleId )) {
  4817. Doo::loadModel ( 'role' );
  4818. $role = new role ();
  4819. $rolename = $role->getOne ( array (
  4820. 'where' => 'rid=' . $roleId,
  4821. 'asArray' => true
  4822. ) );
  4823. }
  4824. if (! empty ( $verifyStaff ))
  4825. $endStaffArray = end ( $verifyStaff );
  4826. $KOP = false;
  4827. foreach ( $roleArrayCopy as $P => $A ) {
  4828. foreach ( $A as $MKI => $AVL ) {
  4829. if (! empty ( $verifyStaff )) {
  4830. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4831. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4832. $button = 4;
  4833. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4834. }
  4835. foreach ( $verifyStaff as $m => $u ) {
  4836. $AVLFK = $AVL [0] . '_R';
  4837. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4838. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4839. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4840. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4841. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4842. break;
  4843. }
  4844. }
  4845. } else {
  4846. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4847. $button = 4;
  4848. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4849. }
  4850. }
  4851. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4852. $KOP = true;
  4853. }
  4854. }
  4855. foreach ( $roleArrayCopy as $k => $v ) {
  4856. foreach ( $verifyList as $m => $n ) {
  4857. if ($n [0] == $k) {
  4858. array_splice ( $verifyList, $m, 1, $v );
  4859. }
  4860. }
  4861. }
  4862. $loanList [$key] ['verifyList'] = $verifyList;
  4863. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4864. 'where' => 'sid=' . $value ['staff'],
  4865. 'asArray' => true
  4866. ) );
  4867. $loanList [$key] ['button'] = $button;
  4868. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4869. }
  4870. $data ['loanList'] = $loanList;
  4871. $data ['explanation'] = '';
  4872. if (! empty ( $loanList )){
  4873. $data ['explanation'] = $loanList [0] ['explanation'];
  4874. }
  4875. //print_r($loanList);
  4876. $Locate = 0;
  4877. $roleId = 0;
  4878. $button = 0;
  4879. foreach ( $receiptList as $key => $value ) {
  4880. $receiptList [$key] ['Locate'] = $Locate;
  4881. $Locate ++;
  4882. $receiptList [$key] ['reviseDetail'] = array ();
  4883. if (! empty ( $value ['reviseDetail'] ))
  4884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4886. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4887. $categoryDetil = $Lcategory->getOne ( array (
  4888. 'where' => 'cid=' . $value ['cid'],
  4889. 'asArray' => true
  4890. ) );
  4891. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4892. // 检测编辑状态
  4893. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4894. $verifyList ['staff'] = $value ['verifyBreakup'];
  4895. } else
  4896. $verifyList = $verify->getOne ( array (
  4897. 'where' => 'vid=' . $value ['verify'],
  4898. 'asArray' => true
  4899. ) );
  4900. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4901. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4902. Doo::loadModel ( 'role' );
  4903. $role = new role ();
  4904. if ($verifyList == NULL)
  4905. $verifyList = array ();
  4906. $flag = true;
  4907. $roleKey = 0;
  4908. $endStaffArray = array ();
  4909. $roleArrayCopy = array ();
  4910. foreach ( $verifyList as $k => $v ) {
  4911. // init verifyStaff
  4912. if ($v [1] == 'ROLE') {
  4913. if (! empty ( $verifyStaff )) {
  4914. $endStaffArray = end ( $verifyStaff );
  4915. // if ($v[0]==$endStaffArray['nextStaff']){
  4916. // $roleId=$v[0];
  4917. // }
  4918. }
  4919. $roleVerify = json_decode ( $v [3], true );
  4920. $roleKey = $k;
  4921. $roleArray = array ();
  4922. $rolename = $role->getOne ( array (
  4923. 'where' => 'rid=' . $v [0],
  4924. 'asArray' => true
  4925. ) );
  4926. foreach ( $roleVerify as $o => $p ) {
  4927. $staffID = explode ( '_', $p );
  4928. $staffInfo = $staff->getOne ( array (
  4929. 'where' => 'sid=' . $staffID [0],
  4930. 'asArray' => true
  4931. ) );
  4932. // print_r($staffID);
  4933. $exp = array (
  4934. 0 => $staffInfo ['sid'],
  4935. 1 => $staffID [1],
  4936. 2 => $staffInfo ['avatar'],
  4937. 'date' => '',
  4938. 'date' => '',
  4939. 'opinion' => '',
  4940. 'status' => '',
  4941. 'rolename' => $rolename ['name']
  4942. );
  4943. array_push ( $roleArray, $exp );
  4944. }
  4945. $roleArrayCopy [$v [0]] = $roleArray;
  4946. // $verifyList[$k]['roleArray']=$roleArray;
  4947. }
  4948. $verifyList [$k] ['date'] = "";
  4949. $verifyList [$k] ['opinion'] = "";
  4950. $verifyList [$k] ['status'] = "";
  4951. if (empty ( $verifyStaff )) {
  4952. $verifyList [$k] ['date'] = "";
  4953. $verifyList [$k] ['opinion'] = "";
  4954. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4955. $verifyList [$k] ['status'] = 4;
  4956. $flag = false;
  4957. }
  4958. } else {
  4959. foreach ( $verifyStaff as $m => $u ) {
  4960. if ($v [0] == $m) {
  4961. $verifyList [$k] ['date'] = $u ['date'];
  4962. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4963. $verifyList [$k] ['status'] = $u ['status'];
  4964. $flag = false;
  4965. break;
  4966. }
  4967. }
  4968. $endStaffArray = end ( $verifyStaff );
  4969. if (isset ( $endStaffArray ['ROLE'] )) {
  4970. } else {
  4971. // $endKey=key($verifyStaff);
  4972. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4973. // $button=4;
  4974. // $verifyList[$k]['status']=4;
  4975. // }
  4976. }
  4977. }
  4978. }
  4979. $FC = @$rolename ['name'];
  4980. $rolename ['name'] = '';
  4981. if (! empty ( $roleId )) {
  4982. Doo::loadModel ( 'role' );
  4983. $role = new role ();
  4984. $rolename = $role->getOne ( array (
  4985. 'where' => 'rid=' . $roleId,
  4986. 'asArray' => true
  4987. ) );
  4988. }
  4989. if (! empty ( $verifyStaff ))
  4990. $endStaffArray = end ( $verifyStaff );
  4991. $KOP = false;
  4992. foreach ( $roleArrayCopy as $P => $A ) {
  4993. foreach ( $A as $MKI => $AVL ) {
  4994. if (! empty ( $verifyStaff )) {
  4995. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4996. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4997. $button = 4;
  4998. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4999. }
  5000. foreach ( $verifyStaff as $m => $u ) {
  5001. $AVLFK = $AVL [0] . '_R';
  5002. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5003. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5004. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5005. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5006. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5007. break;
  5008. }
  5009. }
  5010. } else {
  5011. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5012. $button = 4;
  5013. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5014. }
  5015. }
  5016. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5017. $KOP = true;
  5018. }
  5019. }
  5020. foreach ( $roleArrayCopy as $k => $v ) {
  5021. foreach ( $verifyList as $m => $n ) {
  5022. if ($n [0] == $k) {
  5023. array_splice ( $verifyList, $m, 1, $v );
  5024. }
  5025. }
  5026. }
  5027. // 费用执行人相关数据
  5028. $executeCopy = json_decode ( $value ['executeCopy'], true );
  5029. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5030. foreach ( $executeCopy as $k => $v ) {
  5031. $executeCopy [$k] ['date'] = '';
  5032. $executeCopy [$k] ['opinion'] = '';
  5033. $executeCopy [$k] ['status'] = '';
  5034. if (! empty ( $executeStaff ))
  5035. foreach ( $executeStaff as $m => $u ) {
  5036. if ($v [0] == $m) {
  5037. $executeCopy [$k] ['date'] = $u ['date'];
  5038. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5039. $executeCopy [$k] ['status'] = $u ['status'];
  5040. break;
  5041. }
  5042. }
  5043. }
  5044. $receiptList [$key] ['executeCopy'] = $executeCopy;
  5045. // print_r($verifyList);
  5046. $receiptList [$key] ['verifyList'] = $verifyList;
  5047. // print_r($verifyList);
  5048. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5049. 'where' => 'sid=' . $value ['staff'],
  5050. 'asArray' => true
  5051. ) );
  5052. $receiptList [$key] ['button'] = $button;
  5053. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5054. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5055. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5056. $receiptList [$key] ['relust'] = $relust;
  5057. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5058. }
  5059. // print_r($receiptList);
  5060. // 获取审批日志
  5061. Doo::loadModel ( 'receiptLog' );
  5062. $receiptLog = new receiptLog ();
  5063. $rlList = array ();
  5064. $rlInfo = $receiptLog->getOne ( array (
  5065. 'where' => 'rid=' . $rid . ' and status=4',
  5066. 'asArray' => true
  5067. ) );
  5068. // $tijdate = $receiptLog->getOne ( array (
  5069. // 'where' => 'rid=' . $rid . ' and status=2',
  5070. // 'asc' => 'rlid',
  5071. // 'asArray' => true
  5072. // ) );
  5073. if (! empty ( $rlInfo )) {
  5074. $rlList = $receiptLog->find ( array (
  5075. 'where' => 'rid=' . $rid,
  5076. 'asc' => 'rlid',
  5077. 'asArray' => true
  5078. ) );
  5079. }
  5080. $RN=array();
  5081. if (!empty( $rolename ['staff'])){
  5082. $RN = @json_decode ( $rolename ['staff'] );
  5083. }
  5084. //
  5085. foreach ( $rlList as $key => $value ) {
  5086. $rlList [$key] ['rolename'] = '';
  5087. foreach ( $RN as $k => $v ) {
  5088. $id = explode ( "_", $v );
  5089. if ($id [0] == $value ['uid']) {
  5090. $rlList [$key] ['rolename'] = $FC;
  5091. break;
  5092. }
  5093. }
  5094. }
  5095. Doo::loadModel ( 'enclosur' );
  5096. $enclosur = new enclosur ();
  5097. $enclosurList = $enclosur->find ( array (
  5098. 'where' => 'rid=' . $rid,
  5099. 'asArray' => true
  5100. ) );
  5101. $enclosurHtml = '';
  5102. foreach ( $enclosurList as $value ) {
  5103. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5104. }
  5105. if($receiptList[0]['version']==1){
  5106. require "protected/class/comm_cld.php";
  5107. $receiptList=makeReceiptDataVersion1($receiptList);
  5108. }
  5109. $data ['enclosurHtml'] = $enclosurHtml;
  5110. $receiptList [0] ['rlList'] = $rlList;
  5111. // print_r($rlList);
  5112. $data ['receiptList'] = $receiptList;
  5113. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5114. // print_r($receiptList);
  5115. $data ['memu'] = "receipt";
  5116. $data ['staff'] = $this->staff;
  5117. $data ['receiptMemu'] = 'approvalExpenses';
  5118. $data ['verifyId'] = $this->verifyId;
  5119. $data ['executeId'] = $this->executeId;
  5120. return $data;
  5121. }
  5122. function expensesDoc() {
  5123. $data=$this->_expensesDoc();
  5124. if($data['receiptList'][0]['version']==1){
  5125. $this->render ( "/fee/detail/receipt_compatible", $data );
  5126. die;
  5127. }
  5128. if(!empty($data['receiptList'][0]['itinerary2'])){
  5129. $this->render ( "/receipt/feeTraveView", $data );
  5130. }else{
  5131. $this->render ( "/admin/expensesDoc", $data );
  5132. }
  5133. }
  5134. function expensesDocPrint(){
  5135. $data=$this->_expensesDoc();
  5136. if($data['receiptList'][0]['version']==1){
  5137. $this->render ( "/fee/detail/receiptPrint_compatible", $data );
  5138. die;
  5139. }
  5140. $this->render ( "/receipt/expensesDocPrint", $data );
  5141. }
  5142. function expensesEdi() {
  5143. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5144. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5145. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5146. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5147. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5148. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5149. if (empty ( $status ))
  5150. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5151. $vidList = array ();
  5152. $button = 0;
  5153. Doo::loadModel ( 'verify' );
  5154. Doo::loadModel ( 'receipt' );
  5155. Doo::loadModel ( 'staff' );
  5156. $staff = new staff ();
  5157. $receipt = new receipt ();
  5158. $verify = new verify ();
  5159. Doo::loadModel ( 'L_category' );
  5160. $Lcategory = new L_category ();
  5161. Doo::loadModel ( 'enclosur' );
  5162. $enclosur = new enclosur ();
  5163. // user verify ID
  5164. $verifyDetail = $verify->find ( array (
  5165. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5166. 'asArray' => true
  5167. ) );
  5168. foreach ( $verifyDetail as $key => $value ) {
  5169. array_push ( $vidList, $value ['vid'] );
  5170. }
  5171. $vid = implode ( ",", $vidList );
  5172. if (empty ( $verifyDetail ))
  5173. $vid = 0;
  5174. $categoryList = $Lcategory->find ( array (
  5175. 'asArray' => true
  5176. ) );
  5177. $staffList = $staff->find ( array (
  5178. 'where' => 'cid=' . $cid,
  5179. 'asArray' => true
  5180. ) );
  5181. $ap = "";
  5182. if ($status == 4) {
  5183. $ap = 4;
  5184. $status = 2;
  5185. }
  5186. // get Receipt By verifyID status 2
  5187. $receiptList = $receipt->find ( array (
  5188. 'where' => 'rid =' . $rid . ' and status=2',
  5189. 'desc' => 'rid',
  5190. 'asArray' => true
  5191. ) );
  5192. if (empty ( $receiptList )) {
  5193. die ( 'illegal request' );
  5194. }
  5195. $Locate = 0;
  5196. $roleId = 0;
  5197. if ($ap == 4)
  5198. $status = 4;
  5199. foreach ( $receiptList as $key => $value ) {
  5200. $receiptList [$key] ['Locate'] = $Locate;
  5201. $Locate ++;
  5202. $receiptList [$key] ['reviseDetail'] = array ();
  5203. if (! empty ( $value ['reviseDetail'] ))
  5204. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5205. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5206. $categoryDetil = $Lcategory->getOne ( array (
  5207. 'where' => 'cid=' . $value ['cid'],
  5208. 'asArray' => true
  5209. ) );
  5210. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5211. // 检测编辑状态
  5212. $verifyList = $verify->getOne ( array (
  5213. 'where' => 'vid=' . $value ['verify'],
  5214. 'asArray' => true
  5215. ) );
  5216. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5217. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5218. Doo::loadModel ( 'role' );
  5219. $role = new role ();
  5220. // print_r($verifyList);
  5221. $flag = true;
  5222. $roleKey = 0;
  5223. $endStaffArray = array ();
  5224. $roleArrayCopy = array ();
  5225. foreach ( $verifyList as $k => $v ) {
  5226. // init verifyStaff
  5227. if ($v [1] == 'ROLE') {
  5228. if (! empty ( $verifyStaff )) {
  5229. $endStaffArray = end ( $verifyStaff );
  5230. if ($v [0] == $endStaffArray ['nextStaff']) {
  5231. $roleId = $v [0];
  5232. }
  5233. }
  5234. $roleVerify = json_decode ( $v [3], true );
  5235. $roleKey = $k;
  5236. $roleArray = array ();
  5237. $rolename = $role->getOne ( array (
  5238. 'where' => 'rid=' . $v [0],
  5239. 'asArray' => true
  5240. ) );
  5241. foreach ( $roleVerify as $o => $p ) {
  5242. $staffID = explode ( '_', $p );
  5243. $staffInfo = $staff->getOne ( array (
  5244. 'where' => 'sid=' . $staffID [0],
  5245. 'asArray' => true
  5246. ) );
  5247. // print_r($staffID);
  5248. $exp = array (
  5249. 0 => $staffInfo ['sid'],
  5250. 1 => $staffID [1],
  5251. 2 => $staffInfo ['avatar'],
  5252. 'date' => '',
  5253. 'date' => '',
  5254. 'opinion' => '',
  5255. 'status' => '',
  5256. 'rolename' => $rolename ['name']
  5257. );
  5258. array_push ( $roleArray, $exp );
  5259. }
  5260. $roleArrayCopy [$v [0]] = $roleArray;
  5261. // $verifyList[$k]['roleArray']=$roleArray;
  5262. }
  5263. // print_r($roleArray);
  5264. $verifyList [$k] ['date'] = "";
  5265. $verifyList [$k] ['opinion'] = "";
  5266. $verifyList [$k] ['status'] = "";
  5267. if (empty ( $verifyStaff )) {
  5268. $verifyList [$k] ['date'] = "";
  5269. $verifyList [$k] ['opinion'] = "";
  5270. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5271. $verifyList [$k] ['status'] = 4;
  5272. $button = 4;
  5273. $flag = false;
  5274. }
  5275. } else {
  5276. foreach ( $verifyStaff as $m => $u ) {
  5277. if ($v [0] == $m) {
  5278. $verifyList [$k] ['date'] = $u ['date'];
  5279. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5280. $verifyList [$k] ['status'] = $u ['status'];
  5281. $flag = false;
  5282. break;
  5283. }
  5284. }
  5285. $endStaffArray = end ( $verifyStaff );
  5286. if (isset ( $endStaffArray ['ROLE'] )) {
  5287. } else {
  5288. $endKey = key ( $verifyStaff );
  5289. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5290. $button = 4;
  5291. $verifyList [$k] ['status'] = 4;
  5292. }
  5293. }
  5294. }
  5295. }
  5296. $rolename ['name'] = '';
  5297. if (! empty ( $roleId )) {
  5298. Doo::loadModel ( 'role' );
  5299. $role = new role ();
  5300. $rolename = $role->getOne ( array (
  5301. 'where' => 'rid=' . $roleId,
  5302. 'asArray' => true
  5303. ) );
  5304. }
  5305. if (! empty ( $verifyStaff ))
  5306. $endStaffArray = end ( $verifyStaff );
  5307. $KOP = false;
  5308. foreach ( $roleArrayCopy as $P => $A ) {
  5309. foreach ( $A as $MKI => $AVL ) {
  5310. if (! empty ( $verifyStaff )) {
  5311. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5312. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5313. $button = 4;
  5314. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5315. }
  5316. foreach ( $verifyStaff as $m => $u ) {
  5317. $AVLFK = $AVL [0] . '_R';
  5318. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5319. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5320. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5321. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5322. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5323. break;
  5324. }
  5325. }
  5326. } else {
  5327. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5328. $button = 4;
  5329. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5330. }
  5331. }
  5332. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5333. $KOP = true;
  5334. }
  5335. }
  5336. // print_r($roleArrayCopy);
  5337. // echo $roleKey;
  5338. foreach ( $roleArrayCopy as $k => $v ) {
  5339. foreach ( $verifyList as $m => $n ) {
  5340. if ($n [0] == $k) {
  5341. array_splice ( $verifyList, $m, 1, $v );
  5342. }
  5343. }
  5344. }
  5345. $receiptList [$key] ['verifyList'] = $verifyList;
  5346. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5347. 'where' => 'sid=' . $value ['staff'],
  5348. 'asArray' => true
  5349. ) );
  5350. $receiptList [$key] ['button'] = $button;
  5351. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5352. }
  5353. // $data['verifyDetail']=$verifyDetail;
  5354. $mothHtml = "";
  5355. for($i = 1; $i <= 12; $i ++) {
  5356. if ($month == $i)
  5357. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5358. else
  5359. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5360. }
  5361. // 获取审批日志
  5362. Doo::loadModel ( 'receiptLog' );
  5363. $receiptLog = new receiptLog ();
  5364. $rlList = array ();
  5365. $rlInfo = $receiptLog->getOne ( array (
  5366. 'where' => 'rid=' . $rid . ' and status=4',
  5367. 'asArray' => true
  5368. ) );
  5369. $tijdate = $receiptLog->getOne ( array (
  5370. 'where' => 'rid=' . $rid . ' and status=2',
  5371. 'asc' => 'rlid',
  5372. 'asArray' => true
  5373. ) );
  5374. if (! empty ( $rlInfo )) {
  5375. $rlList = $receiptLog->find ( array (
  5376. 'where' => 'rid=' . $rid,
  5377. 'asc' => 'rlid',
  5378. 'asArray' => true
  5379. ) );
  5380. }
  5381. $receiptList [0] ['rlList'] = $rlList;
  5382. $enclosurList = $enclosur->find ( array (
  5383. 'where' => 'rid=' . $rid,
  5384. 'asArray' => true
  5385. ) );
  5386. $enclosurHtml = '';
  5387. foreach ( $enclosurList as $value ) {
  5388. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5389. }
  5390. // print_r($receiptList);
  5391. $data ['rid'] = $rid;
  5392. $data ['enclosurHtml'] = $enclosurHtml;
  5393. $data ['rolename'] = $rolename ['name'];
  5394. $data ['datetij'] = $tijdate ['date'];
  5395. $data ['mothHtml'] = $mothHtml;
  5396. $data ['receiptList'] = $receiptList;
  5397. $data ['receiptApprovalCount'] = count ( $receiptList );
  5398. $data ['status'] = $status;
  5399. $data ['year'] = $year;
  5400. $data ['categoryList'] = $categoryList;
  5401. $data ['staffList'] = $staffList;
  5402. $data ['cid'] = $cid;
  5403. $data ['sid'] = $sid;
  5404. $data ['ap'] = $ap;
  5405. $data ['memu'] = "receipt";
  5406. $data ['staff'] = $this->staff;
  5407. $data ['receiptMemu'] = 'approvalExpenses';
  5408. $data ['verifyId'] = $this->verifyId;
  5409. $data ['executeId'] = $this->executeId;
  5410. $this->render ( "/admin/expensesEdi", $data );
  5411. }
  5412. function expensesDefray() {
  5413. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5414. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5415. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5416. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5417. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5418. if (! empty ( $rid )) {
  5419. Doo::loadModel ( "verify" );
  5420. $verify = new verify ();
  5421. Doo::loadModel ( "receiptDetail" );
  5422. $receiptDetailObj = new receiptDetail ();
  5423. Doo::loadModel ( "itemStatistics" );
  5424. Doo::loadModel ( "statistics" );
  5425. $statistics = new statistics ();
  5426. $itemStatistics = new itemStatistics ();
  5427. Doo::loadModel ( "receipt" );
  5428. $receipt = new receipt ();
  5429. Doo::loadModel ( "loanReceipt" );
  5430. $loanReceipt = new loanReceipt ();
  5431. $receiptDetail = $receipt->getOne ( array (
  5432. 'where' => 'rid=' . $rid . ' and status=2 ',
  5433. 'asArray' => true
  5434. ) );
  5435. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5436. $nsflag = true;
  5437. foreach ( $nslist as $value ) {
  5438. if ($value == $this->staff ['0'] ['sid']) {
  5439. $nsflag = false;
  5440. break;
  5441. }
  5442. }
  5443. // print_r($nslist);die;
  5444. if (empty ( $receiptDetail ) || $nsflag)
  5445. return "/approvalExpenses/pendApproval";
  5446. $verifyDetail = $verify->getOne ( array (
  5447. 'where' => ' vid =' . $receiptDetail ['verify'],
  5448. 'asArray' => true
  5449. ) );
  5450. $verifyString = $verifyDetail ['staff'];
  5451. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5452. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5453. if (empty ( $opinion )) {
  5454. if ($status == 3)
  5455. $opinion = "终止";
  5456. else
  5457. $opinion = "同意支付";
  5458. }
  5459. $nowStaff = 0;
  5460. $nowStaffList = array ();
  5461. if (empty ( $verifyStaff )) {
  5462. // 还需加入是否已经进入角色审批
  5463. if ($verifyDetail [0] [1] == 'ROLE') {
  5464. // print_r($verifyDetail);echo "ddd";
  5465. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5466. foreach ( $vStaffString as $key => $value ) {
  5467. $staffK = explode ( "_", $value );
  5468. if ($staffK [0] != $this->staff [0] ['sid'])
  5469. array_push ( $nowStaffList, $staffK [0] );
  5470. }
  5471. // print_r($verifyDetail);
  5472. // die;
  5473. if (! empty ( $nowStaffList )) {
  5474. $nowStaff = implode ( ',', $nowStaffList );
  5475. $verifyStaff = array (
  5476. $this->staff [0] ['sid'] . "_R" => array (
  5477. 'date' => date ( 'Y-m-d' ),
  5478. 'opinion' => $opinion,
  5479. 'status' => $status,
  5480. 'nextStaff' => $verifyDetail [0] [0],
  5481. 'ROLE' => 1
  5482. )
  5483. );
  5484. } else {
  5485. $nowStaff = $verifyDetail [1] [0];
  5486. $verifyStaff = array (
  5487. $this->staff [0] ['sid'] . "_R" => array (
  5488. 'date' => date ( 'Y-m-d' ),
  5489. 'opinion' => $opinion,
  5490. 'status' => $status,
  5491. 'nextStaff' => $verifyDetail [1] [0]
  5492. )
  5493. );
  5494. }
  5495. } else {
  5496. if ($verifyDetail [1] [1] == 'ROLE') {
  5497. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5498. // echo "dd";
  5499. foreach ( $vStaffString as $key => $value ) {
  5500. $staffK = explode ( "_", $value );
  5501. array_push ( $nowStaffList, $staffK [0] );
  5502. }
  5503. $nowStaff = implode ( ',', $nowStaffList );
  5504. $verifyStaff = array (
  5505. $this->staff [0] ['sid'] => array (
  5506. 'date' => date ( 'Y-m-d' ),
  5507. 'opinion' => $opinion,
  5508. 'status' => $status,
  5509. 'nextStaff' => $verifyDetail [1] [0],
  5510. 'ROLE' => 1
  5511. )
  5512. );
  5513. } else {
  5514. $nowStaff = $verifyDetail [1] [0];
  5515. $verifyStaff = array (
  5516. $this->staff [0] ['sid'] => array (
  5517. 'date' => date ( 'Y-m-d' ),
  5518. 'opinion' => $opinion,
  5519. 'status' => $status,
  5520. 'nextStaff' => $verifyDetail [1] [0]
  5521. )
  5522. );
  5523. }
  5524. }
  5525. if ($status == 3)
  5526. $verifyStaff = array (
  5527. 'final' => $status,
  5528. $this->staff [0] ['sid'] => array (
  5529. 'date' => date ( 'Y-m-d' ),
  5530. 'opinion' => $opinion,
  5531. 'status' => $status
  5532. )
  5533. );
  5534. $vStaffString = json_encode ( $verifyStaff );
  5535. $receipt->nowStaff = $nowStaff;
  5536. $receipt->verifyStaff = $vStaffString;
  5537. $loanReceipt->nowStaff = $nowStaff;
  5538. $loanReceipt->verifyStaff = $vStaffString;
  5539. } else {
  5540. $VS = end ( $verifyStaff );
  5541. // 非角色审批
  5542. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5543. $nextStaff = 0;
  5544. $roleSTF = false;
  5545. foreach ( $verifyDetail as $key => $value ) {
  5546. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5547. if (isset ( $verifyDetail [$key + 1] )) {
  5548. $nextStaff = $verifyDetail [$key + 1] [0];
  5549. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5550. $roleSTF = true;
  5551. }
  5552. break;
  5553. }
  5554. }
  5555. if (! $roleSTF) {
  5556. $nowStaff = $nextStaff;
  5557. $verifyStaff [$this->staff [0] ['sid']] = array (
  5558. 'date' => date ( 'Y-m-d' ),
  5559. 'opinion' => $opinion,
  5560. 'status' => $status,
  5561. 'nextStaff' => $nextStaff
  5562. );
  5563. } else {
  5564. // 获取角色下的所有用户ID
  5565. $nowStaffList = array ();
  5566. foreach ( $verifyDetail as $vfk ) {
  5567. if ($vfk [1] == 'ROLE') {
  5568. $vStaffString = json_decode ( $vfk [3] );
  5569. foreach ( $vStaffString as $key => $value ) {
  5570. $staffK = explode ( "_", $value );
  5571. array_push ( $nowStaffList, $staffK [0] );
  5572. }
  5573. }
  5574. }
  5575. $nowStaff = implode ( ',', $nowStaffList );
  5576. $verifyStaff [$this->staff [0] ['sid']] = array (
  5577. 'date' => date ( 'Y-m-d' ),
  5578. 'opinion' => $opinion,
  5579. 'status' => $status,
  5580. 'nextStaff' => $nextStaff,
  5581. 'ROLE' => 0
  5582. );
  5583. }
  5584. if ($status == 3) {
  5585. $verifyStaff ['final'] = $status;
  5586. $verifyStaff [$this->staff [0] ['sid']] = array (
  5587. 'date' => date ( 'Y-m-d' ),
  5588. 'opinion' => $opinion,
  5589. 'status' => $status
  5590. );
  5591. }
  5592. $vStaffString = json_encode ( $verifyStaff );
  5593. $receipt->nowStaff = $nowStaff;
  5594. $receipt->verifyStaff = $vStaffString;
  5595. $loanReceipt->nowStaff = $nowStaff;
  5596. $loanReceipt->verifyStaff = $vStaffString;
  5597. }
  5598. // 角色审批
  5599. if (isset ( $VS ['ROLE'] )) {
  5600. // 找出角色人 当前审批角色组
  5601. $verifyJSStaff = array ();
  5602. $nowStaffList2 = array ();
  5603. foreach ( $verifyDetail as $key => $value ) {
  5604. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5605. $verifyJSStaff = json_decode ( $value [3] );
  5606. foreach ( $verifyJSStaff as $m ) {
  5607. $staffK = explode ( "_", $m );
  5608. array_push ( $nowStaffList2, $staffK [0] );
  5609. }
  5610. // print_r($nowStaffList2);
  5611. }
  5612. }
  5613. $RoleVerifyStaff = array ();
  5614. foreach ( $verifyStaff as $key => $value ) {
  5615. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5616. foreach ( $nowStaffList2 as $m ) {
  5617. if ($key == $m . "_R")
  5618. $RoleVerifyStaff [$key] = $value;
  5619. }
  5620. }
  5621. }
  5622. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5623. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5624. // 下一个审批人ID
  5625. $nextStaff = 0;
  5626. $falg = false;
  5627. foreach ( $verifyDetail as $key => $value ) {
  5628. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5629. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5630. $falg = true;
  5631. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5632. $nowStaffList = array ();
  5633. foreach ( $vStaffString as $v ) {
  5634. $staffK = explode ( "_", $v );
  5635. array_push ( $nowStaffList, $staffK [0] );
  5636. }
  5637. $nowStaff = implode ( ',', $nowStaffList );
  5638. $nextStaff = $verifyDetail [$key + 1] [0];
  5639. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5640. $nextStaff = $verifyDetail [$key + 1] [0];
  5641. $nowStaff = $nextStaff;
  5642. } else
  5643. $nowStaff = '';
  5644. break;
  5645. }
  5646. }
  5647. if ($falg)
  5648. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5649. 'date' => date ( 'Y-m-d' ),
  5650. 'opinion' => $opinion,
  5651. 'status' => $status,
  5652. 'nextStaff' => $nextStaff,
  5653. 'ROLE' => 1
  5654. );
  5655. else
  5656. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5657. 'date' => date ( 'Y-m-d' ),
  5658. 'opinion' => $opinion,
  5659. 'status' => $status,
  5660. 'nextStaff' => $nextStaff
  5661. );
  5662. // print_r($verifyStaff);
  5663. // echo $nowStaff;die;
  5664. } else { // 进入下一个角色或者审批人
  5665. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5666. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5667. 'date' => date ( 'Y-m-d' ),
  5668. 'opinion' => $opinion,
  5669. 'status' => $status,
  5670. 'nextStaff' => $VS ['nextStaff'],
  5671. 'ROLE' => 1
  5672. );
  5673. }
  5674. if ($status == 3) {
  5675. $verifyStaff ['final'] = $status;
  5676. $verifyStaff [$this->staff [0] ['sid']] = array (
  5677. 'date' => date ( 'Y-m-d' ),
  5678. 'opinion' => $opinion,
  5679. 'status' => $status
  5680. );
  5681. }
  5682. $vStaffString = json_encode ( $verifyStaff );
  5683. $receipt->verifyStaff = $vStaffString;
  5684. $receipt->nowStaff = $nowStaff;
  5685. $loanReceipt->nowStaff = $nowStaff;
  5686. $loanReceipt->verifyStaff = $vStaffString;
  5687. }
  5688. // print_r($verifyStaff);die;
  5689. }
  5690. $roleKey = 0;
  5691. $roleId = 0;
  5692. $verifyDetailCopy = array ();
  5693. foreach ( $verifyDetail as $k => $v ) {
  5694. if ($v [1] == 'ROLE') {
  5695. $roleId = $v [0];
  5696. $roleVerify = json_decode ( $v [3], true );
  5697. $roleKey = $k;
  5698. $roleArray = array ();
  5699. foreach ( $roleVerify as $o => $p ) {
  5700. $staffID = explode ( '_', $p );
  5701. $exp = array (
  5702. 0 => $staffID [0],
  5703. 1 => $staffID [1]
  5704. );
  5705. array_push ( $roleArray, $exp );
  5706. }
  5707. $verifyDetailCopy [$v [0]] = $roleArray;
  5708. }
  5709. }
  5710. // print_r($verifyDetail);
  5711. foreach ( $verifyDetailCopy as $k => $v ) {
  5712. foreach ( $verifyDetail as $m => $n ) {
  5713. if ($n [0] == $k) {
  5714. array_splice ( $verifyDetail, $m, 1, $v );
  5715. }
  5716. }
  5717. }
  5718. // 审批日志
  5719. if (! isset ( $verifyStaff ['final'] )) {
  5720. Doo::loadModel ( "receiptLog" );
  5721. $receiptLog = new receiptLog ();
  5722. if (! empty ( $roleId )) {
  5723. Doo::loadModel ( "role" );
  5724. $role = new role ();
  5725. $roleInfo = $role->getOne ( array (
  5726. 'where' => 'rid=' . $roleId,
  5727. 'asArray' => true
  5728. ) );
  5729. $receiptLog->rolename = $roleInfo ['name'];
  5730. }
  5731. $receiptLog->username = $this->staff [0] ['username'];
  5732. $receiptLog->uid = $this->staff [0] ['sid'];
  5733. $receiptLog->date = date ( "Y-m-d" );
  5734. $receiptLog->opinion = $opinion;
  5735. $receiptLog->img = $this->staff [0] ['avatar'];
  5736. $receiptLog->status = 1;
  5737. $receiptLog->rid = $rid;
  5738. $receiptLog->insert ();
  5739. }
  5740. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5741. $receipt->status = 3;
  5742. $receipt->verifyBreakup = $verifyString;
  5743. $receiptDetailObj->status = 3;
  5744. $receiptDetailObj->update ( array (
  5745. 'where' => 'rid=' . $rid
  5746. ) );
  5747. // 微信企业号通知
  5748. $this->setWXMsg ( $rid, 3 );
  5749. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5750. $receipt->status = 6;
  5751. $receipt->pastDate = date ( "Y-m-d" );
  5752. $receipt->isBK = 1;
  5753. $loanReceipt->verifyBreakup = $verifyString;
  5754. $loanReceipt->status = 1;
  5755. $loanReceipt->pastDate = date ( "Y-m-d" );
  5756. //生成流水后 不更新汇款金额
  5757. Doo::loadModel ( 'wasteBook' );
  5758. $wasteBook = new wasteBook ();
  5759. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5760. if (empty($wbDetail)){
  5761. $loanReceipt->amount = $receiptDetail ['amount'];
  5762. }
  5763. $loanReceipt->update ( array (
  5764. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5765. ) );
  5766. // 微信企业号通知
  5767. $this->setWXMsg ( $rid, 1 );
  5768. }
  5769. $receipt->amount = $receiptDetail['sum'];
  5770. $receipt->update ( array (
  5771. 'where' => ' rid = ' . $rid
  5772. ) );
  5773. // 进入下一条审批费用新加需求
  5774. $vidList = array ();
  5775. $verifyDetail = $verify->find ( array (
  5776. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5777. 'asArray' => true
  5778. ) );
  5779. foreach ( $verifyDetail as $key => $value ) {
  5780. array_push ( $vidList, $value ['vid'] );
  5781. }
  5782. $vid = implode ( ",", $vidList );
  5783. if (empty ( $verifyDetail ))
  5784. $vid = 0;
  5785. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5786. $receipt = new receipt ();
  5787. $rd = $receipt->getOne ( array (
  5788. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5789. 'asc' => 'rid',
  5790. 'asArray' => true
  5791. ) );
  5792. if (empty ( $rd )) {
  5793. return '/approvalExpenses/pendApproval';
  5794. }
  5795. if ($rd ['Rtype'] == 1) {
  5796. if ($rd ['isBK'] == 1) {
  5797. return '/receiptburEdi/' . $rd ['rid'];
  5798. } else {
  5799. return '/expensesEdi/' . $rd ['rid'];
  5800. }
  5801. } elseif ($rd ['Rtype'] == 2) {
  5802. return '/remitApproval/' . $rd ['rid'];
  5803. } else {
  5804. return '/receiptburEdi/' . $rd ['rid'];
  5805. }
  5806. // return "/approvalExpenses/pendApproval";
  5807. }
  5808. }
  5809. function ajaxExamineExe() {
  5810. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5811. Doo::loadModel ( 'receipt' );
  5812. $receipt = new receipt ();
  5813. Doo::loadClass ( 'XDeode' );
  5814. $XDeode = new XDeode ( 5 );
  5815. if (! empty ( $rid )) {
  5816. $rLRes = $receipt->find ( array (
  5817. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5818. 'asArray' => true
  5819. ) );
  5820. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5821. echo json_encode ( array (
  5822. 'status' => 1,
  5823. 'receipt' => $rLRes [0]
  5824. ) );
  5825. die ();
  5826. }
  5827. echo json_encode ( array (
  5828. 'status' => 0,
  5829. 'receipt' => array ()
  5830. ) );
  5831. die ();
  5832. }
  5833. function implement() {
  5834. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5835. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5836. Doo::loadClass ( 'XDeode' );
  5837. $XDeode = new XDeode ( 5 );
  5838. Doo::loadModel ( 'receipt' );
  5839. $receipt = new receipt ();
  5840. Doo::loadModel ( 'L_category' );
  5841. $Lcategory = new L_category ();
  5842. Doo::loadModel ( 'verify' );
  5843. $verify = new verify ();
  5844. Doo::loadModel ( 'staff' );
  5845. $staff = new staff ();
  5846. Doo::loadModel ( "execute" );
  5847. $execute = new execute ();
  5848. $rid = $XDeode->decode ( $rid );
  5849. $receiptList = $receipt->find ( array (
  5850. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5851. 'desc' => 'rid',
  5852. 'asArray' => true
  5853. ) );
  5854. Doo::loadModel ( 'loanReceipt' );
  5855. $loanReceipt = new loanReceipt ();
  5856. // print_r($receiptList);
  5857. $loanList = array ();
  5858. if (! isset ( $receiptList ))
  5859. $loanList = $loanReceipt->find ( array (
  5860. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5861. 'desc' => 'rid',
  5862. 'asArray' => true
  5863. ) );
  5864. $Locate = 0;
  5865. $roleId = 0;
  5866. $button = 0;
  5867. foreach ( $loanList as $key => $value ) {
  5868. $loanList [$key] ['Locate'] = $Locate;
  5869. $Locate ++;
  5870. $loanList [$key] ['reviseDetail'] = array ();
  5871. if (! empty ( $value ['reviseDetail'] ))
  5872. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5873. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5874. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5875. $categoryDetil = $Lcategory->getOne ( array (
  5876. 'where' => 'cid=' . $value ['cid'],
  5877. 'asArray' => true
  5878. ) );
  5879. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5880. // 检测编辑状态
  5881. $verifyList = $verify->getOne ( array (
  5882. 'where' => 'vid=' . $value ['verify'],
  5883. 'asArray' => true
  5884. ) );
  5885. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5886. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5887. Doo::loadModel ( 'role' );
  5888. $role = new role ();
  5889. $flag = true;
  5890. $roleKey = 0;
  5891. $endStaffArray = array ();
  5892. $roleArrayCopy = array ();
  5893. foreach ( $verifyList as $k => $v ) {
  5894. // init verifyStaff
  5895. if ($v [1] == 'ROLE') {
  5896. if (! empty ( $verifyStaff )) {
  5897. $endStaffArray = end ( $verifyStaff );
  5898. // if ($v[0]==$endStaffArray['nextStaff']){
  5899. // $roleId=$v[0];
  5900. // }
  5901. }
  5902. $roleVerify = json_decode ( $v [3], true );
  5903. $roleKey = $k;
  5904. $roleArray = array ();
  5905. $rolename = $role->getOne ( array (
  5906. 'where' => 'rid=' . $v [0],
  5907. 'asArray' => true
  5908. ) );
  5909. foreach ( $roleVerify as $o => $p ) {
  5910. $staffID = explode ( '_', $p );
  5911. $staffInfo = $staff->getOne ( array (
  5912. 'where' => 'sid=' . $staffID [0],
  5913. 'asArray' => true
  5914. ) );
  5915. // print_r($staffID);
  5916. $exp = array (
  5917. 0 => $staffInfo ['sid'],
  5918. 1 => $staffID [1],
  5919. 2 => $staffInfo ['avatar'],
  5920. 'date' => '',
  5921. 'date' => '',
  5922. 'opinion' => '',
  5923. 'status' => '',
  5924. 'rolename' => $rolename ['name']
  5925. );
  5926. array_push ( $roleArray, $exp );
  5927. }
  5928. $roleArrayCopy [$v [0]] = $roleArray;
  5929. // $verifyList[$k]['roleArray']=$roleArray;
  5930. }
  5931. $verifyList [$k] ['date'] = "";
  5932. $verifyList [$k] ['opinion'] = "";
  5933. $verifyList [$k] ['status'] = "";
  5934. if (empty ( $verifyStaff )) {
  5935. $verifyList [$k] ['date'] = "";
  5936. $verifyList [$k] ['opinion'] = "";
  5937. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5938. $verifyList [$k] ['status'] = 4;
  5939. $flag = false;
  5940. }
  5941. } else {
  5942. foreach ( $verifyStaff as $m => $u ) {
  5943. if ($v [0] == $m) {
  5944. $verifyList [$k] ['date'] = $u ['date'];
  5945. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5946. $verifyList [$k] ['status'] = $u ['status'];
  5947. $flag = false;
  5948. break;
  5949. }
  5950. }
  5951. $endStaffArray = end ( $verifyStaff );
  5952. if (isset ( $endStaffArray ['ROLE'] )) {
  5953. } else {
  5954. // $endKey=key($verifyStaff);
  5955. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5956. // $button=4;
  5957. // $verifyList[$k]['status']=4;
  5958. // }
  5959. }
  5960. }
  5961. }
  5962. $rolename ['name'] = '';
  5963. if (! empty ( $roleId )) {
  5964. Doo::loadModel ( 'role' );
  5965. $role = new role ();
  5966. $rolename = $role->getOne ( array (
  5967. 'where' => 'rid=' . $roleId,
  5968. 'asArray' => true
  5969. ) );
  5970. }
  5971. if (! empty ( $verifyStaff ))
  5972. $endStaffArray = end ( $verifyStaff );
  5973. $KOP = false;
  5974. foreach ( $roleArrayCopy as $P => $A ) {
  5975. foreach ( $A as $MKI => $AVL ) {
  5976. if (! empty ( $verifyStaff )) {
  5977. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5978. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5979. $button = 4;
  5980. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5981. }
  5982. foreach ( $verifyStaff as $m => $u ) {
  5983. $AVLFK = $AVL [0] . '_R';
  5984. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5985. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5986. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5987. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5988. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5989. break;
  5990. }
  5991. }
  5992. } else {
  5993. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5994. $button = 4;
  5995. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5996. }
  5997. }
  5998. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5999. $KOP = true;
  6000. }
  6001. }
  6002. foreach ( $roleArrayCopy as $k => $v ) {
  6003. foreach ( $verifyList as $m => $n ) {
  6004. if ($n [0] == $k) {
  6005. array_splice ( $verifyList, $m, 1, $v );
  6006. }
  6007. }
  6008. }
  6009. $loanList [$key] ['verifyList'] = $verifyList;
  6010. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6011. 'where' => 'sid=' . $value ['staff'],
  6012. 'asArray' => true
  6013. ) );
  6014. }
  6015. $data ['loanList'] = $loanList;
  6016. $Locate = 0;
  6017. $roleId = 0;
  6018. $button = 0;
  6019. Doo::loadClass ( 'XDeode' );
  6020. $XDeode = new XDeode ( 5 );
  6021. foreach ( $receiptList as $key => $value ) {
  6022. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6023. $button2 = 0;
  6024. $receiptList [$key] ['Locate'] = $Locate;
  6025. $Locate ++;
  6026. $receiptList [$key] ['reviseDetail'] = array ();
  6027. if (! empty ( $value ['reviseDetail'] ))
  6028. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6029. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6030. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6031. $categoryDetil = $Lcategory->getOne ( array (
  6032. 'where' => 'cid=' . $value ['cid'],
  6033. 'asArray' => true
  6034. ) );
  6035. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6036. $executeList = json_decode ( $value ['executeCopy'], true );
  6037. $executeStaff = array ();
  6038. if (! empty ( $value ['executeStaff'] ))
  6039. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6040. if (isset ( $executeList )) {
  6041. foreach ( $executeList as $op => $lo ) {
  6042. $executeList [$op] ['date'] = "";
  6043. $executeList [$op] ['opinion'] = "";
  6044. $executeList [$op] ['status'] = "";
  6045. foreach ( $executeStaff as $m => $u ) {
  6046. if ($lo [0] == $m) {
  6047. $executeList [$op] ['date'] = $u ['date'];
  6048. $executeList [$op] ['opinion'] = $u ['opinion'];
  6049. $executeList [$op] ['status'] = $u ['status'];
  6050. break;
  6051. }
  6052. }
  6053. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6054. $button2 = 1;
  6055. $executeList [$op] ['status'] = 4;
  6056. }
  6057. }
  6058. }
  6059. // 检测编辑状态
  6060. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6061. $verifyList ['staff'] = $value ['verifyBreakup'];
  6062. } else
  6063. $verifyList = $verify->getOne ( array (
  6064. 'where' => 'vid=' . $value ['verify'],
  6065. 'asArray' => true
  6066. ) );
  6067. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6068. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6069. Doo::loadModel ( 'role' );
  6070. $role = new role ();
  6071. if ($verifyList == NULL)
  6072. $verifyList = array ();
  6073. $flag = true;
  6074. $roleKey = 0;
  6075. $endStaffArray = array ();
  6076. $roleArrayCopy = array ();
  6077. foreach ( $verifyList as $k => $v ) {
  6078. // init verifyStaff
  6079. if ($v [1] == 'ROLE') {
  6080. if (! empty ( $verifyStaff )) {
  6081. $endStaffArray = end ( $verifyStaff );
  6082. // if ($v[0]==$endStaffArray['nextStaff']){
  6083. // $roleId=$v[0];
  6084. // }
  6085. }
  6086. $roleVerify = json_decode ( $v [3], true );
  6087. $roleKey = $k;
  6088. $roleArray = array ();
  6089. $rolename = $role->getOne ( array (
  6090. 'where' => 'rid=' . $v [0],
  6091. 'asArray' => true
  6092. ) );
  6093. foreach ( $roleVerify as $o => $p ) {
  6094. $staffID = explode ( '_', $p );
  6095. $staffInfo = $staff->getOne ( array (
  6096. 'where' => 'sid=' . $staffID [0],
  6097. 'asArray' => true
  6098. ) );
  6099. // print_r($staffID);
  6100. $exp = array (
  6101. 0 => $staffInfo ['sid'],
  6102. 1 => $staffID [1],
  6103. 2 => $staffInfo ['avatar'],
  6104. 'date' => '',
  6105. 'date' => '',
  6106. 'opinion' => '',
  6107. 'status' => '',
  6108. 'rolename' => $rolename ['name']
  6109. );
  6110. array_push ( $roleArray, $exp );
  6111. }
  6112. $roleArrayCopy [$v [0]] = $roleArray;
  6113. // $verifyList[$k]['roleArray']=$roleArray;
  6114. }
  6115. $verifyList [$k] ['date'] = "";
  6116. $verifyList [$k] ['opinion'] = "";
  6117. $verifyList [$k] ['status'] = "";
  6118. if (empty ( $verifyStaff )) {
  6119. $verifyList [$k] ['date'] = "";
  6120. $verifyList [$k] ['opinion'] = "";
  6121. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6122. $verifyList [$k] ['status'] = 4;
  6123. $flag = false;
  6124. }
  6125. } else {
  6126. foreach ( $verifyStaff as $m => $u ) {
  6127. if ($v [0] == $m) {
  6128. $verifyList [$k] ['date'] = $u ['date'];
  6129. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6130. $verifyList [$k] ['status'] = $u ['status'];
  6131. $flag = false;
  6132. break;
  6133. }
  6134. }
  6135. $endStaffArray = end ( $verifyStaff );
  6136. if (isset ( $endStaffArray ['ROLE'] )) {
  6137. } else {
  6138. // $endKey=key($verifyStaff);
  6139. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6140. // $button=4;
  6141. // $verifyList[$k]['status']=4;
  6142. // }
  6143. }
  6144. }
  6145. }
  6146. $rolename ['name'] = '';
  6147. if (! empty ( $roleId )) {
  6148. Doo::loadModel ( 'role' );
  6149. $role = new role ();
  6150. $rolename = $role->getOne ( array (
  6151. 'where' => 'rid=' . $roleId,
  6152. 'asArray' => true
  6153. ) );
  6154. }
  6155. if (! empty ( $verifyStaff ))
  6156. $endStaffArray = end ( $verifyStaff );
  6157. $KOP = false;
  6158. foreach ( $roleArrayCopy as $P => $A ) {
  6159. foreach ( $A as $MKI => $AVL ) {
  6160. if (! empty ( $verifyStaff )) {
  6161. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6162. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6163. $button = 4;
  6164. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6165. }
  6166. foreach ( $verifyStaff as $m => $u ) {
  6167. $AVLFK = $AVL [0] . '_R';
  6168. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6169. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6170. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6171. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6172. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6173. break;
  6174. }
  6175. }
  6176. } else {
  6177. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6178. $button = 4;
  6179. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6180. }
  6181. }
  6182. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6183. $KOP = true;
  6184. }
  6185. }
  6186. foreach ( $roleArrayCopy as $k => $v ) {
  6187. foreach ( $verifyList as $m => $n ) {
  6188. if ($n [0] == $k) {
  6189. array_splice ( $verifyList, $m, 1, $v );
  6190. }
  6191. }
  6192. }
  6193. $receiptList [$key] ['verifyList'] = $verifyList;
  6194. $receiptList [$key] ['executeList'] = $executeList;
  6195. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6196. 'where' => 'sid=' . $value ['staff'],
  6197. 'asArray' => true
  6198. ) );
  6199. $receiptList [$key] ['button2'] = $button2;
  6200. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6201. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6202. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6203. $receiptList [$key] ['relust'] = $relust;
  6204. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6205. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6206. }
  6207. //执行人是否是最后一位
  6208. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6209. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6210. $executePrimary=count($executeCopy)-1;
  6211. $lastOne=true;
  6212. if($executePrimary!=count($executeStaff)){
  6213. $lastOne=false;
  6214. }
  6215. $data['lastOne']=$lastOne;
  6216. // 是否写入过流水
  6217. $accountType = 0;
  6218. if ($receiptList [0] ['Rtype'] == 0) {
  6219. $accountType = 3;
  6220. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6221. if($receiptList [0]['version']==1){
  6222. $accountType = 2;
  6223. }else{
  6224. if (!empty($receiptList [0]['accountItem']) ){
  6225. // if (!empty($receiptList [0]['loanRid']) ){
  6226. $accountType = 2;
  6227. }else{
  6228. $accountType = 1;
  6229. }
  6230. }
  6231. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6232. $accountType = 4;
  6233. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6234. $accountType = 12;
  6235. }
  6236. Doo::loadModel ( 'wasteBook' );
  6237. $wasteBook = new wasteBook ();
  6238. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6239. $data ['wbDetail'] = $wbDetail;
  6240. $wbDetailLoan=array();
  6241. if ($accountType==2){
  6242. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6243. }
  6244. $data ['wbDetailLoan'] = $wbDetailLoan;
  6245. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6246. //print_r($wbDetail);
  6247. if($receiptList[0]['version']==1){
  6248. require "protected/class/comm_cld.php";
  6249. $receiptList=makeReceiptDataVersion1($receiptList);
  6250. }
  6251. $data ['receiptList'] = $receiptList;
  6252. $data ['memu'] = "receipt";
  6253. $data ['staff'] = $this->staff;
  6254. $data ['receiptMemu'] = 'implement';
  6255. $data ['verifyId'] = $this->verifyId;
  6256. $data ['executeId'] = $this->executeId;
  6257. if($receiptList[0]['version']==1){
  6258. if ($Rtype=="loan"){
  6259. $this->render ( "/fee/implement/loan_compatible", $data );
  6260. }else{
  6261. $this->render ( "/fee/implement/receipt_compatible", $data );
  6262. }
  6263. die;
  6264. }
  6265. if ($Rtype=="loan"){
  6266. $this->render ( "/receipt/receiptImplementLoan", $data );
  6267. }elseif($Rtype=="receipt"){
  6268. if($receiptList[0]['receiptClass']==2){
  6269. //TODO 费用执行行程单2.0
  6270. if(!empty($receiptList[0]['itinerary2'])){
  6271. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6272. }else{
  6273. $this->render ( "/receipt/receiptImplementTrave", $data );
  6274. }
  6275. }else{
  6276. $this->render ( "/receipt/receiptImplement", $data );
  6277. }
  6278. }elseif($Rtype=="public"){
  6279. $this->render ( "/receipt/receiptImplementPublic", $data );
  6280. }else{
  6281. //$this->render ( "/admin/implement", $data );
  6282. }
  6283. }
  6284. function implementDo() {
  6285. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6286. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6287. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6288. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6289. // $ab = '';
  6290. // if ($accountBank == 'CGBDeposit')
  6291. // $ab = '纵横广发';
  6292. // elseif ($accountBank == 'ICBCDeposit')
  6293. // $ab = '纵横工行';
  6294. // elseif ($accountBank == 'HUADeposit')
  6295. // $ab = '华润银行';
  6296. // elseif ($accountBank == 'PersonalDeposit')
  6297. // $ab = '个人广发';
  6298. // if (empty ( $ab ))
  6299. // die ( 'illegal request--22' );
  6300. if (! empty ( $rid )) {
  6301. Doo::loadModel ( 'receipt' );
  6302. $receipt = new receipt ();
  6303. Doo::loadClass ( 'XDeode' );
  6304. $XDeode = new XDeode ( 5 );
  6305. $rid=$XDeode->decode($rid);
  6306. if (!is_numeric($rid)){
  6307. die;
  6308. }
  6309. // $rinfo = $receipt->getOne ( array (
  6310. // 'where' => 'rid=' . $rid,
  6311. // 'asArray' => true
  6312. // ) );
  6313. $rinfo = $receipt->getReceiptByRid ( $rid );
  6314. // $accountType = '';
  6315. // if ($rinfo ['Rtype'] == 1) {
  6316. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6317. // $accountType = 2;
  6318. // else
  6319. // $accountType = 1;
  6320. // } elseif ($rinfo ['Rtype'] == 2) {
  6321. // $accountType = 4;
  6322. // } elseif ($rinfo ['Rtype'] == 0)
  6323. // $accountType = 3;
  6324. // if (empty ( $accountType ))
  6325. // die ( 'illegal request' );
  6326. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6327. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6328. if (empty ( $executeStaff )) {
  6329. $executeStaff = array (
  6330. $this->staff [0] ['sid'] => array (
  6331. 'date' => date ( 'Y-m-d' ),
  6332. 'opinion' => $implementOpinions,
  6333. 'status' => 1
  6334. )
  6335. );
  6336. } else {
  6337. $executeStaff [$this->staff [0] ['sid']] = array (
  6338. 'date' => date ( 'Y-m-d' ),
  6339. 'opinion' => $implementOpinions,
  6340. 'status' => 1
  6341. );
  6342. }
  6343. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6344. $receipt->executeStaff = json_encode ( $executeStaff );
  6345. $receipt->status = 8;
  6346. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6347. $receipt->status = 9;
  6348. if ($rinfo ['status'] == 6) {
  6349. $receipt->loanDate = date ( "Y-m-d" );
  6350. }
  6351. $receipt->executeDate = date ( "Y-m-d" );
  6352. } else {
  6353. $receipt->executeStaff = json_encode ( $executeStaff );
  6354. }
  6355. //$receipt->amount = $amount;
  6356. $receipt->update ( array (
  6357. 'where' => 'rid=' . $rid
  6358. ) );
  6359. // 公司流水记录
  6360. // Doo::loadModel ( 'wasteBook' );
  6361. // $wasteBook = new wasteBook ();
  6362. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6363. // // 银行
  6364. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6365. // $item = array (
  6366. // 'dataID' => $rid,
  6367. // 'expensesType' => 2,
  6368. // 'accountType' => $accountType,
  6369. // 'accountPriceShow' => $amount,
  6370. // 'accountPrice' => - $amount,
  6371. // 'accountBank' => $accountBank,
  6372. // 'category' => $rinfo ['category'] [0] ['title'],
  6373. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6374. // 'name' => $rinfo ['staffDetail'] ['username'],
  6375. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6376. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6377. // );
  6378. // $wasteBook->setAccountBookStatistics ( $item );
  6379. // }
  6380. }
  6381. //$ridKey = $XDeode->encode ( $rid );
  6382. return "/hisImplement";
  6383. // return "/implement/" . $ridKey . ".html";
  6384. }
  6385. function receiptburEdi() {
  6386. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  6387. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6388. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6389. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6390. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6391. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6392. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6393. if (empty ( $status ))
  6394. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6395. $vidList = array ();
  6396. $button = 0;
  6397. Doo::loadModel ( 'verify' );
  6398. Doo::loadModel ( 'receipt' );
  6399. Doo::loadModel ( 'staff' );
  6400. $staff = new staff ();
  6401. $receipt = new receipt ();
  6402. $verify = new verify ();
  6403. Doo::loadModel ( 'L_category' );
  6404. $Lcategory = new L_category ();
  6405. Doo::loadModel ( 'enclosur' );
  6406. $enclosur = new enclosur ();
  6407. Doo::loadModel ( 'loanReceipt' );
  6408. $loanReceipt = new loanReceipt ();
  6409. // user verify ID
  6410. $verifyDetail = $verify->find ( array (
  6411. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6412. 'asArray' => true
  6413. ) );
  6414. foreach ( $verifyDetail as $key => $value ) {
  6415. array_push ( $vidList, $value ['vid'] );
  6416. }
  6417. $vid = implode ( ",", $vidList );
  6418. if (empty ( $verifyDetail ))
  6419. $vid = 0;
  6420. $categoryList = $Lcategory->find ( array (
  6421. 'asArray' => true
  6422. ) );
  6423. $staffList = $staff->find ( array (
  6424. 'where' => 'cid=' . $cid,
  6425. 'asArray' => true
  6426. ) );
  6427. $ap = "";
  6428. if ($status == 4) {
  6429. $ap = 4;
  6430. $status = 2;
  6431. }
  6432. // get Receipt By verifyID status 2
  6433. $receiptList = $receipt->find ( array (
  6434. 'where' => 'rid =' . $rid . ' and status=2',
  6435. 'desc' => 'rid',
  6436. 'asArray' => true
  6437. ) );
  6438. if (empty ( $receiptList )) {
  6439. die ( 'illegal request' );
  6440. }
  6441. $loanList = $loanReceipt->find ( array (
  6442. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6443. 'desc' => 'rid',
  6444. 'asArray' => true
  6445. ) );
  6446. $data ['explanation'] = '';
  6447. if (! empty ( $loanList ))
  6448. $data ['explanation'] = $loanList [0] ['explanation'];
  6449. $Locate = 0;
  6450. $roleId = 0;
  6451. $button = 0;
  6452. foreach ( $loanList as $key => $value ) {
  6453. $loanList [$key] ['Locate'] = $Locate;
  6454. $Locate ++;
  6455. $loanList [$key] ['reviseDetail'] = array ();
  6456. if (! empty ( $value ['reviseDetail'] ))
  6457. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6458. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6459. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6460. $categoryDetil = $Lcategory->getOne ( array (
  6461. 'where' => 'cid=' . $value ['cid'],
  6462. 'asArray' => true
  6463. ) );
  6464. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6465. // 检测编辑状态
  6466. $verifyList = $verify->getOne ( array (
  6467. 'where' => 'vid=' . $value ['verify'],
  6468. 'asArray' => true
  6469. ) );
  6470. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6471. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6472. Doo::loadModel ( 'role' );
  6473. $role = new role ();
  6474. $flag = true;
  6475. $roleKey = 0;
  6476. $endStaffArray = array ();
  6477. $roleArrayCopy = array ();
  6478. foreach ( $verifyList as $k => $v ) {
  6479. // init verifyStaff
  6480. if ($v [1] == 'ROLE') {
  6481. if (! empty ( $verifyStaff )) {
  6482. $endStaffArray = end ( $verifyStaff );
  6483. }
  6484. $roleVerify = json_decode ( $v [3], true );
  6485. $roleKey = $k;
  6486. $roleArray = array ();
  6487. $rolename = $role->getOne ( array (
  6488. 'where' => 'rid=' . $v [0],
  6489. 'asArray' => true
  6490. ) );
  6491. foreach ( $roleVerify as $o => $p ) {
  6492. $staffID = explode ( '_', $p );
  6493. $staffInfo = $staff->getOne ( array (
  6494. 'where' => 'sid=' . $staffID [0],
  6495. 'asArray' => true
  6496. ) );
  6497. // print_r($staffID);
  6498. $exp = array (
  6499. 0 => $staffInfo ['sid'],
  6500. 1 => $staffID [1],
  6501. 2 => $staffInfo ['avatar'],
  6502. 'date' => '',
  6503. 'date' => '',
  6504. 'opinion' => '',
  6505. 'status' => '',
  6506. 'rolename' => $rolename ['name']
  6507. );
  6508. array_push ( $roleArray, $exp );
  6509. }
  6510. $roleArrayCopy [$v [0]] = $roleArray;
  6511. // $verifyList[$k]['roleArray']=$roleArray;
  6512. }
  6513. $verifyList [$k] ['date'] = "";
  6514. $verifyList [$k] ['opinion'] = "";
  6515. $verifyList [$k] ['status'] = "";
  6516. if (empty ( $verifyStaff )) {
  6517. $verifyList [$k] ['date'] = "";
  6518. $verifyList [$k] ['opinion'] = "";
  6519. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6520. $verifyList [$k] ['status'] = 4;
  6521. $flag = false;
  6522. }
  6523. } else {
  6524. foreach ( $verifyStaff as $m => $u ) {
  6525. if ($v [0] == $m) {
  6526. $verifyList [$k] ['date'] = $u ['date'];
  6527. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6528. $verifyList [$k] ['status'] = $u ['status'];
  6529. $flag = false;
  6530. break;
  6531. }
  6532. }
  6533. $endStaffArray = end ( $verifyStaff );
  6534. if (isset ( $endStaffArray ['ROLE'] )) {
  6535. } else {
  6536. }
  6537. }
  6538. }
  6539. $rolename ['name'] = '';
  6540. if (! empty ( $roleId )) {
  6541. Doo::loadModel ( 'role' );
  6542. $role = new role ();
  6543. $rolename = $role->getOne ( array (
  6544. 'where' => 'rid=' . $roleId,
  6545. 'asArray' => true
  6546. ) );
  6547. }
  6548. if (! empty ( $verifyStaff ))
  6549. $endStaffArray = end ( $verifyStaff );
  6550. $KOP = false;
  6551. foreach ( $roleArrayCopy as $P => $A ) {
  6552. foreach ( $A as $MKI => $AVL ) {
  6553. if (! empty ( $verifyStaff )) {
  6554. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6555. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6556. $button = 4;
  6557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6558. }
  6559. foreach ( $verifyStaff as $m => $u ) {
  6560. $AVLFK = $AVL [0] . '_R';
  6561. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6562. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6563. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6564. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6565. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6566. break;
  6567. }
  6568. }
  6569. } else {
  6570. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6571. $button = 4;
  6572. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6573. }
  6574. }
  6575. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6576. $KOP = true;
  6577. }
  6578. }
  6579. foreach ( $roleArrayCopy as $k => $v ) {
  6580. foreach ( $verifyList as $m => $n ) {
  6581. if ($n [0] == $k) {
  6582. array_splice ( $verifyList, $m, 1, $v );
  6583. }
  6584. }
  6585. }
  6586. $loanList [$key] ['verifyList'] = $verifyList;
  6587. }
  6588. $htmlLoan = '';
  6589. $data ['loanReceiptDate'] = '';
  6590. if (isset ( $loanList [0] )) {
  6591. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6592. if ($value ['status'] == 1)
  6593. $htmlLoan .= '<li class="done" >';
  6594. elseif ($value ['status'] == 3)
  6595. $htmlLoan .= '<li class="undone" >';
  6596. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6597. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6598. if (isset ( $value ['rolename'] ))
  6599. $htmlLoan .= $value ['rolename'];
  6600. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6601. }
  6602. $data ['loanDate'] = $loanList [0] ['date'];
  6603. } else {
  6604. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6605. }
  6606. $data ['htmlLoan'] = $htmlLoan;
  6607. // $data ['LoanReceipt']=$loanList[0];
  6608. // print_r($loanList);
  6609. $Locate = 0;
  6610. $roleId = 0;
  6611. $button = 0;
  6612. if ($ap == 4)
  6613. $status = 4;
  6614. Doo::loadClass ( 'XDeode' );
  6615. $XDeode = new XDeode ( 5 );
  6616. foreach ( $receiptList as $key => $value ) {
  6617. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6618. $receiptList [$key] ['Locate'] = $Locate;
  6619. $Locate ++;
  6620. $receiptList [$key] ['reviseDetail'] = array ();
  6621. // 调整金额 代码调整
  6622. if (! empty ( $value ['reviseDetail'] )) {
  6623. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6624. foreach ( $reviseDetail as $ry => $re ) {
  6625. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6626. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6627. }
  6628. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6629. // print_r($reviseDetail);
  6630. }
  6631. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6632. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6633. $categoryDetil = $Lcategory->getOne ( array (
  6634. 'where' => 'cid=' . $value ['cid'],
  6635. 'asArray' => true
  6636. ) );
  6637. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6638. // 检测编辑状态
  6639. $verifyList = $verify->getOne ( array (
  6640. 'where' => 'vid=' . $value ['verify'],
  6641. 'asArray' => true
  6642. ) );
  6643. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6644. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6645. Doo::loadModel ( 'role' );
  6646. $role = new role ();
  6647. // print_r($verifyList);
  6648. $flag = true;
  6649. $roleKey = 0;
  6650. $endStaffArray = array ();
  6651. $roleArrayCopy = array ();
  6652. foreach ( $verifyList as $k => $v ) {
  6653. // init verifyStaff
  6654. if ($v [1] == 'ROLE') {
  6655. if (! empty ( $verifyStaff )) {
  6656. $endStaffArray = end ( $verifyStaff );
  6657. if ($v [0] == $endStaffArray ['nextStaff']) {
  6658. $roleId = $v [0];
  6659. }
  6660. }
  6661. $roleVerify = json_decode ( $v [3], true );
  6662. $roleKey = $k;
  6663. $roleArray = array ();
  6664. $rolename = $role->getOne ( array (
  6665. 'where' => 'rid=' . $v [0],
  6666. 'asArray' => true
  6667. ) );
  6668. foreach ( $roleVerify as $o => $p ) {
  6669. $staffID = explode ( '_', $p );
  6670. $staffInfo = $staff->getOne ( array (
  6671. 'where' => 'sid=' . $staffID [0],
  6672. 'asArray' => true
  6673. ) );
  6674. // print_r($staffID);
  6675. $exp = array (
  6676. 0 => $staffInfo ['sid'],
  6677. 1 => $staffID [1],
  6678. 2 => $staffInfo ['avatar'],
  6679. 'date' => '',
  6680. 'date' => '',
  6681. 'opinion' => '',
  6682. 'status' => '',
  6683. 'rolename' => $rolename ['name']
  6684. );
  6685. array_push ( $roleArray, $exp );
  6686. }
  6687. $roleArrayCopy [$v [0]] = $roleArray;
  6688. // $verifyList[$k]['roleArray']=$roleArray;
  6689. }
  6690. // print_r($roleArray);
  6691. $verifyList [$k] ['date'] = "";
  6692. $verifyList [$k] ['opinion'] = "";
  6693. $verifyList [$k] ['status'] = "";
  6694. if (empty ( $verifyStaff )) {
  6695. $verifyList [$k] ['date'] = "";
  6696. $verifyList [$k] ['opinion'] = "";
  6697. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6698. $verifyList [$k] ['status'] = 4;
  6699. $button = 4;
  6700. $flag = false;
  6701. }
  6702. } else {
  6703. foreach ( $verifyStaff as $m => $u ) {
  6704. if ($v [0] == $m) {
  6705. $verifyList [$k] ['date'] = $u ['date'];
  6706. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6707. $verifyList [$k] ['status'] = $u ['status'];
  6708. $flag = false;
  6709. break;
  6710. }
  6711. }
  6712. $endStaffArray = end ( $verifyStaff );
  6713. if (isset ( $endStaffArray ['ROLE'] )) {
  6714. } else {
  6715. $endKey = key ( $verifyStaff );
  6716. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6717. $button = 4;
  6718. $verifyList [$k] ['status'] = 4;
  6719. }
  6720. }
  6721. }
  6722. }
  6723. $rolename ['name'] = '';
  6724. if (! empty ( $roleId )) {
  6725. Doo::loadModel ( 'role' );
  6726. $role = new role ();
  6727. $rolename = $role->getOne ( array (
  6728. 'where' => 'rid=' . $roleId,
  6729. 'asArray' => true
  6730. ) );
  6731. }
  6732. if (! empty ( $verifyStaff ))
  6733. $endStaffArray = end ( $verifyStaff );
  6734. $KOP = false;
  6735. foreach ( $roleArrayCopy as $P => $A ) {
  6736. foreach ( $A as $MKI => $AVL ) {
  6737. if (! empty ( $verifyStaff )) {
  6738. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6739. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6740. $button = 4;
  6741. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6742. }
  6743. foreach ( $verifyStaff as $m => $u ) {
  6744. $AVLFK = $AVL [0] . '_R';
  6745. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6746. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6747. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6748. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6749. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6750. break;
  6751. }
  6752. }
  6753. } else {
  6754. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6755. $button = 4;
  6756. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6757. }
  6758. }
  6759. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6760. $KOP = true;
  6761. }
  6762. }
  6763. foreach ( $roleArrayCopy as $k => $v ) {
  6764. foreach ( $verifyList as $m => $n ) {
  6765. if ($n [0] == $k) {
  6766. array_splice ( $verifyList, $m, 1, $v );
  6767. }
  6768. }
  6769. }
  6770. // print_r($verifyList);
  6771. $receiptList [$key] ['verifyList'] = $verifyList;
  6772. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6773. 'where' => 'sid=' . $value ['staff'],
  6774. 'asArray' => true
  6775. ) );
  6776. $receiptList [$key] ['button'] = $button;
  6777. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6778. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6779. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6780. $receiptList [$key] ['relust'] = $relust;
  6781. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6782. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6783. }
  6784. //print_r($receiptList);die;
  6785. // $data['verifyDetail']=$verifyDetail;
  6786. $mothHtml = "";
  6787. for($i = 1; $i <= 12; $i ++) {
  6788. if ($month == $i)
  6789. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6790. else
  6791. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6792. }
  6793. // 获取审批日志
  6794. Doo::loadModel ( 'receiptLog' );
  6795. $receiptLog = new receiptLog ();
  6796. $rlList = array ();
  6797. $rlInfo = $receiptLog->getOne ( array (
  6798. 'where' => 'rid=' . $rid . ' and status=4',
  6799. 'asArray' => true
  6800. ) );
  6801. $tijdate = $receiptLog->getOne ( array (
  6802. 'where' => 'rid=' . $rid . ' and status=2',
  6803. 'asc' => 'rlid',
  6804. 'asArray' => true
  6805. ) );
  6806. if (! empty ( $rlInfo )) {
  6807. $rlList = $receiptLog->find ( array (
  6808. 'where' => 'rid=' . $rid,
  6809. 'asc' => 'rlid',
  6810. 'asArray' => true
  6811. ) );
  6812. }
  6813. // echo $rid;
  6814. // print_r($receiptList);
  6815. $receiptList [0] ['rlList'] = $rlList;
  6816. // print_r($receiptList);
  6817. $enclosurList = $enclosur->find ( array (
  6818. 'where' => 'rid=' . $rid,
  6819. 'asArray' => true
  6820. ) );
  6821. $enclosurHtml = '';
  6822. foreach ( $enclosurList as $value ) {
  6823. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6824. }
  6825. $data ['enclosurHtml'] = $enclosurHtml;
  6826. $data ['rolename'] = $rolename ['name'];
  6827. $data ['mothHtml'] = $mothHtml;
  6828. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6829. if($receiptList[0]['version']==1){
  6830. require "protected/class/comm_cld.php";
  6831. $receiptList=makeReceiptDataVersion1($receiptList);
  6832. }
  6833. $data ['rid'] = $rid;
  6834. $data ['tijdate'] = $tijdate ['date'];
  6835. $data ['receiptList'] = $receiptList;
  6836. $data ['receiptApprovalCount'] = count ( $receiptList );
  6837. $data ['status'] = $status;
  6838. $data ['year'] = $year;
  6839. $data ['categoryList'] = $categoryList;
  6840. $data ['staffList'] = $staffList;
  6841. $data ['cid'] = $cid;
  6842. $data ['sid'] = $sid;
  6843. $data ['ap'] = $ap;
  6844. $data ['memu'] = "receipt";
  6845. $data ['staff'] = $this->staff;
  6846. $data ['receiptMemu'] = 'approvalExpenses';
  6847. $data ['verifyId'] = $this->verifyId;
  6848. $data ['executeId'] = $this->executeId;
  6849. if($receiptList[0]['version']==1){
  6850. $this->render ( "/fee/approval/receipt_compatible", $data );
  6851. die;
  6852. }
  6853. if($receiptList[0]['receiptClass']==1){
  6854. $this->render ( "/receipt/feeAgencyApproval", $data );
  6855. }elseif($receiptList[0]['receiptClass']==2){
  6856. //TODO 行程单2.0
  6857. if(!empty($receiptList[0]['itinerary2'])){
  6858. $this->render ( "/receipt/feeTraveApproval2", $data );
  6859. }else{
  6860. $this->render ( "/receipt/feeTraveApproval", $data );
  6861. }
  6862. }elseif($receiptList[0]['receiptClass']==3){
  6863. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6864. }else{
  6865. $this->render ( "/admin/receiptburEdi", $data );
  6866. }
  6867. }
  6868. function hisImplement() {
  6869. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  6870. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6871. if (empty ( $item ))
  6872. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6873. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6874. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6875. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6876. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6877. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6878. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6879. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6880. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6881. Doo::loadClass ( 'XDeode' );
  6882. $XDeode = new XDeode ( 5 );
  6883. Doo::loadModel ( 'receipt' );
  6884. $receipt = new receipt ();
  6885. Doo::loadModel ( 'L_category' );
  6886. $Lcategory = new L_category ();
  6887. Doo::loadModel ( 'verify' );
  6888. Doo::loadModel ( 'statistics' );
  6889. $statistics = new statistics ();
  6890. $verify = new verify ();
  6891. Doo::loadModel ( 'staff' );
  6892. $staff = new staff ();
  6893. Doo::loadClass ( 'XDeode' );
  6894. $XDeode = new XDeode ( 5 );
  6895. $XDeode7 = new XDeode ( 7 );
  6896. $cid = $XDeode->decode ( $cidKey );
  6897. $condition = "";
  6898. if ($item == "expenses")
  6899. $condition = " and Rtype=1 ";
  6900. elseif ($item == "receipts")
  6901. $condition = " and Rtype=0 ";
  6902. elseif ($item == "remits")
  6903. $condition = " and Rtype=2 ";
  6904. elseif($item == "train")
  6905. $condition = " and Rtype=3 ";
  6906. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6907. $sopString = $cidString = "";
  6908. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6909. if (empty ( $rdate ))
  6910. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6911. else
  6912. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6913. if ($status == 'pendImplement') {
  6914. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and (executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" or executeStaff is null ) ) ';
  6915. } elseif ($status == 'alerpts') {
  6916. $statusCon = '(status=8 or status=9 )';
  6917. if (empty ( $rdate )){
  6918. $dateCondition = " and Year(date) =" . $year;
  6919. }else{
  6920. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6921. }
  6922. }
  6923. if ($sop != 'SOP')
  6924. $sopString = " and staff=" . $sop;
  6925. if ($cidKey != 'ALL'){
  6926. $cidString = " and cid=" . $cid;
  6927. }
  6928. //汇款信息需要提取出来
  6929. // 单号检索
  6930. if(!empty($receiptOrder)){
  6931. $receiptList = $receipt->find ( array (
  6932. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6933. 'desc' => 'rid',
  6934. 'asArray' => true
  6935. ) );
  6936. // 员工筛选
  6937. $receiptList2 = $receipt->find ( array (
  6938. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6939. 'desc' => 'rid',
  6940. 'asArray' => true
  6941. ) );
  6942. }else{
  6943. $receiptList = $receipt->find ( array (
  6944. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6945. 'desc' => 'rid',
  6946. 'asArray' => true
  6947. ) );
  6948. // echo $statusCon . $condition . $dateCondition . $sopString . $cidString;
  6949. // 员工筛选
  6950. $receiptList2 = $receipt->find ( array (
  6951. 'where' => $statusCon . $condition . $dateCondition,
  6952. 'desc' => 'rid',
  6953. 'asArray' => true
  6954. ) );
  6955. }
  6956. $sopStaff = array ();
  6957. foreach ( $receiptList2 as $key => $value ) {
  6958. $staffDetail = $staff->getOne ( array (
  6959. 'select' => 'username',
  6960. 'where' => 'sid=' . $value ['staff'],
  6961. 'asArray' => true
  6962. ) );
  6963. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6964. }
  6965. // 办事处筛选
  6966. $categoryScreen = array ();
  6967. $categorList = $Lcategory->getCategory ();
  6968. foreach ( $receiptList2 as $key => $value ) {
  6969. foreach ( $categorList as $k => $v ) {
  6970. if ($value ['cid'] == $v ['cid']) {
  6971. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6972. break;
  6973. }
  6974. }
  6975. }
  6976. $categoryScreenHtml = "";
  6977. foreach ( $categoryScreen as $key => $value ) {
  6978. if ($cidKey == $key)
  6979. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6980. else
  6981. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6982. }
  6983. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6984. $data ['cidKey'] = $cidKey;
  6985. $Locate = 0;
  6986. $roleId = 0;
  6987. $button = 0;
  6988. $staffBatchNumber = 100001;
  6989. $remittanceList = array ();
  6990. foreach ( $receiptList as $key => $value ) {
  6991. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6992. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6993. $receiptList [$key] ['Texe'] = 'false';
  6994. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6995. $receiptList [$key] ['Texe'] = 'true';
  6996. }
  6997. $receiptList [$key] ['TRexe'] = 'true';
  6998. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6999. $receiptList [$key] ['TRexe'] = 'false';
  7000. }
  7001. $receiptList [$key] ['Locate'] = $Locate;
  7002. $Locate ++;
  7003. $receiptList [$key] ['reviseDetail'] = array ();
  7004. if (! empty ( $value ['reviseDetail'] ))
  7005. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7006. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7007. $categoryDetil = $Lcategory->getOne ( array (
  7008. 'where' => 'cid=' . $value ['cid'],
  7009. 'asArray' => true
  7010. ) );
  7011. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7012. // 检测编辑状态
  7013. $verifyList = $verify->getOne ( array (
  7014. 'where' => 'vid=' . $value ['verify'],
  7015. 'asArray' => true
  7016. ) );
  7017. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7018. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7019. Doo::loadModel ( 'role' );
  7020. $role = new role ();
  7021. $flag = true;
  7022. $roleKey = 0;
  7023. $endStaffArray = array ();
  7024. $roleArrayCopy = array ();
  7025. foreach ( $verifyList as $k => $v ) {
  7026. // init verifyStaff
  7027. if ($v [1] == 'ROLE') {
  7028. if (! empty ( $verifyStaff )) {
  7029. $endStaffArray = end ( $verifyStaff );
  7030. }
  7031. $roleVerify = json_decode ( $v [3], true );
  7032. $roleKey = $k;
  7033. $roleArray = array ();
  7034. $rolename = $role->getOne ( array (
  7035. 'where' => 'rid=' . $v [0],
  7036. 'asArray' => true
  7037. ) );
  7038. foreach ( $roleVerify as $o => $p ) {
  7039. $staffID = explode ( '_', $p );
  7040. $staffInfo = $staff->getOne ( array (
  7041. 'where' => 'sid=' . $staffID [0],
  7042. 'asArray' => true
  7043. ) );
  7044. $exp = array (
  7045. 0 => $staffInfo ['sid'],
  7046. 1 => $staffID [1],
  7047. 2 => $staffInfo ['avatar'],
  7048. 'date' => '',
  7049. 'date' => '',
  7050. 'opinion' => '',
  7051. 'status' => '',
  7052. 'rolename' => $rolename ['name']
  7053. );
  7054. array_push ( $roleArray, $exp );
  7055. }
  7056. $roleArrayCopy [$v [0]] = $roleArray;
  7057. }
  7058. $verifyList [$k] ['date'] = "";
  7059. $verifyList [$k] ['opinion'] = "";
  7060. $verifyList [$k] ['status'] = "";
  7061. if (empty ( $verifyStaff )) {
  7062. $verifyList [$k] ['date'] = "";
  7063. $verifyList [$k] ['opinion'] = "";
  7064. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7065. $verifyList [$k] ['status'] = 4;
  7066. $flag = false;
  7067. }
  7068. } else {
  7069. foreach ( $verifyStaff as $m => $u ) {
  7070. if ($v [0] == $m) {
  7071. $verifyList [$k] ['date'] = $u ['date'];
  7072. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7073. $verifyList [$k] ['status'] = $u ['status'];
  7074. $flag = false;
  7075. break;
  7076. }
  7077. }
  7078. $endStaffArray = end ( $verifyStaff );
  7079. }
  7080. }
  7081. $rolename ['name'] = '';
  7082. if (! empty ( $roleId )) {
  7083. Doo::loadModel ( 'role' );
  7084. $role = new role ();
  7085. $rolename = $role->getOne ( array (
  7086. 'where' => 'rid=' . $roleId,
  7087. 'asArray' => true
  7088. ) );
  7089. }
  7090. if (! empty ( $verifyStaff ))
  7091. $endStaffArray = end ( $verifyStaff );
  7092. $KOP = false;
  7093. foreach ( $roleArrayCopy as $P => $A ) {
  7094. foreach ( $A as $MKI => $AVL ) {
  7095. if (! empty ( $verifyStaff )) {
  7096. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7097. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7098. $button = 4;
  7099. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7100. }
  7101. foreach ( $verifyStaff as $m => $u ) {
  7102. $AVLFK = $AVL [0] . '_R';
  7103. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7104. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7105. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7106. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7107. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7108. break;
  7109. }
  7110. }
  7111. } else {
  7112. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7113. $button = 4;
  7114. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7115. }
  7116. }
  7117. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7118. $KOP = true;
  7119. }
  7120. }
  7121. foreach ( $roleArrayCopy as $k => $v ) {
  7122. foreach ( $verifyList as $m => $n ) {
  7123. if ($n [0] == $k) {
  7124. array_splice ( $verifyList, $m, 1, $v );
  7125. }
  7126. }
  7127. }
  7128. $receiptList [$key] ['verifyList'] = $verifyList;
  7129. $staffDetail = $staff->getOne ( array (
  7130. 'where' => 'sid=' . $value ['staff'],
  7131. 'asArray' => true
  7132. ) );
  7133. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7134. $receiptList [$key] ['button'] = $button;
  7135. $receiptList [$key] ['paymentABS']="";
  7136. if ($value['Rtype']==1){
  7137. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7138. $receiptList [$key] ['relustABS'] = sprintf("%.2f",abs($receiptList [$key] ['relust']));
  7139. }elseif($value['Rtype']==3){
  7140. // 收入合计
  7141. Doo::loadModel ( 'invoiceTraining' );
  7142. $invoiceTraining = new invoiceTraining ();
  7143. $invoiceTrainingDetail = array (
  7144. 'invoiceArriveAmount' => '0.00',
  7145. 'RIAmount' => '0.00',
  7146. 'invoiceTotalAmount' => '0.00',
  7147. 'invoiceCompanyAmount' => '0.00',
  7148. 'invoiceArriveAmountM'=>'0.00',
  7149. 'invoiceCompanyAmountM'=>'0.00'
  7150. );
  7151. if ($value ['invoiceTrainId'] != 0) {
  7152. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7153. }
  7154. $invoiceArriveAmount = $RIAmount = 0;
  7155. if (! empty ( $invoiceTrainingDetail )) {
  7156. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7157. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7158. }
  7159. // 备用金
  7160. $sum = 0;
  7161. if (! empty ( $value ['trainLoanRid'] )) {
  7162. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7163. foreach ($receiptLoanList as $kll=>$vll){
  7164. $sum+=$vll['sum'];
  7165. }
  7166. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7167. // $sum = $receiptLoanDetailBak ['sum'];
  7168. }
  7169. // 支出项金额详情
  7170. // 项目金额合计
  7171. Doo::loadModel ( 'RItem' );
  7172. $RItem = new RItem ();
  7173. Doo::loadModel ( 'accountItem' );
  7174. $accountItem = new accountItem ();
  7175. // 讲师获得
  7176. Doo::loadModel ( 'RILecturer' );
  7177. $RILecturer = new RILecturer ();
  7178. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7179. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7180. // 支出项金额详情
  7181. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7182. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7183. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7184. $receiptList [$key] ['payment'] =$payment;
  7185. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7186. }
  7187. // 设置导出汇款execl
  7188. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7189. $remittanceDetail = array (
  7190. $staffBatchNumber,
  7191. $value ['remittanceName'],
  7192. $value ['bankNumber'],
  7193. $value ['bankName'],
  7194. $value ['remittanceBankType'],
  7195. $value ['coupletNumber'],
  7196. $value ['sum'] ,
  7197. $receiptList [$key] ['paymentABS']
  7198. );
  7199. array_push ( $remittanceList, $remittanceDetail );
  7200. $staffBatchNumber ++;
  7201. }
  7202. if($value['version']==1){
  7203. $receiptList[$key]['version_1_explanation']=$this->getReceiptVerson1Explanation($value);
  7204. }
  7205. }
  7206. $data ['remittanceList'] = json_encode ( $remittanceList );
  7207. // print_r($receiptList);
  7208. $mothHtml = "";
  7209. for($i = 1; $i <= 12; $i ++) {
  7210. if ($moth == $i)
  7211. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7212. else
  7213. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7214. }
  7215. $dayHtml = "";
  7216. if ($day != "DAY" || $moth != "MONTH") {
  7217. for($i = 1; $i <= 31; $i ++) {
  7218. if ($day == $i)
  7219. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7220. else
  7221. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7222. }
  7223. }
  7224. $sopHtml = "";
  7225. foreach ( $sopStaff as $key => $value ) {
  7226. if ($sop == $key)
  7227. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7228. else
  7229. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7230. }
  7231. $data ['status'] = $status;
  7232. $data ['rdate'] = $rdate;
  7233. $data ['sopHtml'] = $sopHtml;
  7234. $data ['dayHtml'] = $dayHtml;
  7235. $data ['mothHtml'] = $mothHtml;
  7236. $data ['receiptList'] = $receiptList;
  7237. $data ['memu'] = "receipt";
  7238. $data ['staff'] = $this->staff;
  7239. $data ['receiptMemu'] = 'implement';
  7240. $data ['verifyId'] = $this->verifyId;
  7241. $data ['executeId'] = $this->executeId;
  7242. $data ['item'] = $item;
  7243. $data ['year'] = $year;
  7244. $data ['moth'] = $moth;
  7245. $data['receiptOrder']=$receiptOrder;
  7246. $data ['day'] = $day;
  7247. $data ['sop'] = $sop;
  7248. $this->render ( "/admin/hisImplement", $data );
  7249. }
  7250. /**
  7251. * 导出汇款信息的exelc
  7252. */
  7253. function exportRemittance() {
  7254. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7255. if (empty ( $remittanceInfo ))
  7256. die ( 'illegal request' );
  7257. $title = array (
  7258. '员工编号',
  7259. '姓名',
  7260. '员工账号',
  7261. '员工账户开户行',
  7262. '转账类型',
  7263. '联行号',
  7264. '金额',
  7265. '结算(培训班)'
  7266. );
  7267. $data = json_decode ( $remittanceInfo, true );
  7268. if (empty ( $data ))
  7269. die ( 'illegal request' );
  7270. Doo::loadClass ( 'receipt.func' );
  7271. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7272. header ( 'Content-Type:text/html;charset=utf-8' );
  7273. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7274. }
  7275. function ajaxExamine() {
  7276. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7277. Doo::loadModel ( 'receipt' );
  7278. $receipt = new receipt ();
  7279. if (! empty ( $rid )) {
  7280. $rLRes = $receipt->find ( array (
  7281. '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,
  7282. 'asArray' => true
  7283. ) );
  7284. if(!empty($rLRes)){
  7285. Doo::loadClass ( 'XDeode' );
  7286. $XDeode = new XDeode ( 7 );
  7287. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7288. echo json_encode ( array (
  7289. 'status' => 1,
  7290. 'receipt' => $rLRes [0]
  7291. ) );
  7292. die ();
  7293. }else{
  7294. echo json_encode ( array (
  7295. 'status' => 1,
  7296. 'receipt' => array ()
  7297. ) );
  7298. die ();
  7299. }
  7300. }
  7301. echo json_encode ( array (
  7302. 'status' => 0,
  7303. 'receipt' => array ()
  7304. ) );
  7305. die ();
  7306. }
  7307. /*
  7308. * 废弃
  7309. */
  7310. function myReceipt() {
  7311. // all approval past withdraw
  7312. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7313. if (empty ( $item ))
  7314. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7315. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7316. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7317. Doo::loadModel ( 'receipt' );
  7318. $receipt = new receipt ();
  7319. // pre-loaded
  7320. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7321. // have cache
  7322. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7323. if (! empty ( $moth )) // yearPage
  7324. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7325. $this->showCache ( $path );
  7326. }
  7327. Doo::loadModel ( 'L_category' );
  7328. $Lcategory = new L_category ();
  7329. Doo::loadModel ( 'verify' );
  7330. Doo::loadModel ( 'statistics' );
  7331. $statistics = new statistics ();
  7332. $verify = new verify ();
  7333. Doo::loadModel ( 'staff' );
  7334. $staff = new staff ();
  7335. $condition = " and status!=0 ";
  7336. if ($item == "approval")
  7337. $condition = " and status=2 ";
  7338. elseif ($item == "withdraw")
  7339. $condition = " and status=3 ";
  7340. elseif ($item == "past")
  7341. $condition = " and status=1 ";
  7342. elseif ($item == "whdw")
  7343. $condition = " and status=4 ";
  7344. $dateCondition = " and Year(date) =" . $year;
  7345. if (! empty ( $moth )) {
  7346. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7347. $stList = $statistics->getOne ( array (
  7348. 'select' => 'rePrice ,agPrice',
  7349. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7350. 'asArray' => true
  7351. ) );
  7352. } else
  7353. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7354. if (empty ( $stList ))
  7355. $stList = array (
  7356. 'rePrice' => 0,
  7357. 'agPrice' => 0
  7358. );
  7359. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7360. $data ['stList'] = array (
  7361. 'rePrice' => $stList ['rePrice'],
  7362. 'agPrice' => $stList ['agPrice'],
  7363. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7364. );
  7365. $receiptList = $receipt->find ( array (
  7366. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7367. 'desc' => 'rid',
  7368. 'asArray' => true
  7369. ) );
  7370. $Locate = 0;
  7371. $roleId = 0;
  7372. $button = 0;
  7373. foreach ( $receiptList as $key => $value ) {
  7374. $receiptList [$key] ['Locate'] = $Locate;
  7375. $Locate ++;
  7376. $receiptList [$key] ['reviseDetail'] = array ();
  7377. if (! empty ( $value ['reviseDetail'] ))
  7378. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7379. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7380. $categoryDetil = $Lcategory->getOne ( array (
  7381. 'where' => 'cid=' . $value ['cid'],
  7382. 'asArray' => true
  7383. ) );
  7384. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7385. // 检测编辑状态
  7386. $verifyList = $verify->getOne ( array (
  7387. 'where' => 'vid=' . $value ['verify'],
  7388. 'asArray' => true
  7389. ) );
  7390. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7391. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7392. Doo::loadModel ( 'role' );
  7393. $role = new role ();
  7394. $flag = true;
  7395. $roleKey = 0;
  7396. $endStaffArray = array ();
  7397. $roleArrayCopy = array ();
  7398. foreach ( $verifyList as $k => $v ) {
  7399. // init verifyStaff
  7400. if ($v [1] == 'ROLE') {
  7401. if (! empty ( $verifyStaff )) {
  7402. $endStaffArray = end ( $verifyStaff );
  7403. // if ($v[0]==$endStaffArray['nextStaff']){
  7404. // $roleId=$v[0];
  7405. // }
  7406. }
  7407. $roleVerify = json_decode ( $v [3], true );
  7408. $roleKey = $k;
  7409. $roleArray = array ();
  7410. $rolename = $role->getOne ( array (
  7411. 'where' => 'rid=' . $v [0],
  7412. 'asArray' => true
  7413. ) );
  7414. foreach ( $roleVerify as $o => $p ) {
  7415. $staffID = explode ( '_', $p );
  7416. $staffInfo = $staff->getOne ( array (
  7417. 'where' => 'sid=' . $staffID [0],
  7418. 'asArray' => true
  7419. ) );
  7420. // print_r($staffID);
  7421. $exp = array (
  7422. 0 => $staffInfo ['sid'],
  7423. 1 => $staffID [1],
  7424. 2 => $staffInfo ['avatar'],
  7425. 'date' => '',
  7426. 'date' => '',
  7427. 'opinion' => '',
  7428. 'status' => '',
  7429. 'rolename' => $rolename ['name']
  7430. );
  7431. array_push ( $roleArray, $exp );
  7432. }
  7433. $roleArrayCopy [$v [0]] = $roleArray;
  7434. // $verifyList[$k]['roleArray']=$roleArray;
  7435. }
  7436. $verifyList [$k] ['date'] = "";
  7437. $verifyList [$k] ['opinion'] = "";
  7438. $verifyList [$k] ['status'] = "";
  7439. if (empty ( $verifyStaff )) {
  7440. $verifyList [$k] ['date'] = "";
  7441. $verifyList [$k] ['opinion'] = "";
  7442. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7443. $verifyList [$k] ['status'] = 4;
  7444. $flag = false;
  7445. }
  7446. } else {
  7447. foreach ( $verifyStaff as $m => $u ) {
  7448. if ($v [0] == $m) {
  7449. $verifyList [$k] ['date'] = $u ['date'];
  7450. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7451. $verifyList [$k] ['status'] = $u ['status'];
  7452. $flag = false;
  7453. break;
  7454. }
  7455. }
  7456. $endStaffArray = end ( $verifyStaff );
  7457. if (isset ( $endStaffArray ['ROLE'] )) {
  7458. } else {
  7459. // $endKey=key($verifyStaff);
  7460. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7461. // $button=4;
  7462. // $verifyList[$k]['status']=4;
  7463. // }
  7464. }
  7465. }
  7466. }
  7467. $rolename ['name'] = '';
  7468. if (! empty ( $roleId )) {
  7469. Doo::loadModel ( 'role' );
  7470. $role = new role ();
  7471. $rolename = $role->getOne ( array (
  7472. 'where' => 'rid=' . $roleId,
  7473. 'asArray' => true
  7474. ) );
  7475. }
  7476. if (! empty ( $verifyStaff ))
  7477. $endStaffArray = end ( $verifyStaff );
  7478. $KOP = false;
  7479. foreach ( $roleArrayCopy as $P => $A ) {
  7480. foreach ( $A as $MKI => $AVL ) {
  7481. if (! empty ( $verifyStaff )) {
  7482. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7483. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7484. $button = 4;
  7485. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7486. }
  7487. foreach ( $verifyStaff as $m => $u ) {
  7488. $AVLFK = $AVL [0] . '_R';
  7489. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7490. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7491. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7492. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7493. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7494. break;
  7495. }
  7496. }
  7497. } else {
  7498. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7499. $button = 4;
  7500. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7501. }
  7502. }
  7503. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7504. $KOP = true;
  7505. }
  7506. }
  7507. foreach ( $roleArrayCopy as $k => $v ) {
  7508. foreach ( $verifyList as $m => $n ) {
  7509. if ($n [0] == $k) {
  7510. array_splice ( $verifyList, $m, 1, $v );
  7511. }
  7512. }
  7513. }
  7514. $receiptList [$key] ['verifyList'] = $verifyList;
  7515. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7516. 'where' => 'sid=' . $value ['staff'],
  7517. 'asArray' => true
  7518. ) );
  7519. $receiptList [$key] ['button'] = $button;
  7520. }
  7521. // print_r($receiptList);die;
  7522. $mothHtml = "";
  7523. for($i = 1; $i <= 12; $i ++) {
  7524. if ($moth == $i)
  7525. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7526. else
  7527. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7528. }
  7529. $data ['mothHtml'] = $mothHtml;
  7530. $data ['receiptList'] = $receiptList;
  7531. $data ['memu'] = "receipt";
  7532. $data ['staff'] = $this->staff;
  7533. $data ['receiptMemu'] = 'receipt';
  7534. $data ['verifyId'] = $this->verifyId;
  7535. $data ['executeId'] = $this->executeId;
  7536. $data ['item'] = $item;
  7537. $data ['year'] = $year;
  7538. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7539. // sufficient condition to generate cache
  7540. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7541. $receiptList = $receipt->find ( array (
  7542. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7543. 'asArray' => true
  7544. ) );
  7545. if (empty ( $receiptList )) { // generated files
  7546. ob_start ();
  7547. $this->render ( "/admin/saea_myList", $data );
  7548. $this->cacheFile ( $path );
  7549. die ();
  7550. // $content = ob_get_contents();
  7551. // $fp = fopen($path, "w");
  7552. // fwrite($fp, $content);
  7553. // fclose($fp);
  7554. }
  7555. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7556. $receiptList = $receipt->find ( array (
  7557. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7558. 'asArray' => true
  7559. ) );
  7560. if (empty ( $receiptList )) { // generated files
  7561. ob_start ();
  7562. $this->render ( "/admin/saea_myList", $data );
  7563. $this->cacheFile ( $path );
  7564. die ();
  7565. }
  7566. }
  7567. }
  7568. $this->render ( "/admin/saea_myList", $data );
  7569. }
  7570. function approvedReceipt() {
  7571. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7572. Doo::loadModel ( 'receipt' );
  7573. Doo::loadModel ( 'receiptDetail' );
  7574. $receipt = new receipt ();
  7575. $receiptDetail = new receiptDetail ();
  7576. Doo::loadModel ( 'statistics' );
  7577. Doo::loadModel ( 'itemStatistics' );
  7578. $statistics = new statistics ();
  7579. $itemStatistics = new itemStatistics ();
  7580. Doo::loadModel ( "verify" );
  7581. $verify = new verify ();
  7582. // 审批状态的判定
  7583. $receiptDetailList = $receipt->getOne ( array (
  7584. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7585. 'asArray' => true
  7586. ) );
  7587. if (empty ( $receiptDetailList )){
  7588. return "/saeaBorad";
  7589. }
  7590. // 如果是新报销单,有差旅的情况下写入日期
  7591. if($receiptDetailList['version']==1){
  7592. if(!empty($receiptDetailList['traveJson'])){
  7593. $traveJson=json_decode($receiptDetailList['traveJson'],true)['traveList'];
  7594. foreach ($traveJson as $key=>$value){
  7595. Doo::loadModel ( 'cld/traveDate_cld' );
  7596. $traveDate = new traveDate_cld ();
  7597. $traveDate->sid=$this->staff [0] ['sid'];
  7598. $traveDate->rid=$receiptDetailList['rid'];
  7599. $tripTime = explode(" - ", $value['tripTime']);
  7600. $traveDate->start=$tripTime[0];
  7601. $traveDate->end=$tripTime[1];
  7602. $traveDate->insert ();
  7603. }
  7604. }
  7605. }
  7606. $verifyDetail = $verify->getOne ( array (
  7607. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7608. 'asArray' => true
  7609. ) );
  7610. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7611. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7612. $nowStaff = "";
  7613. $nowStaffList = array ();
  7614. if ($verifyDetail [0] [1] == 'ROLE') {
  7615. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7616. foreach ( $vStaffString as $key => $value ) {
  7617. $staffK = explode ( "_", $value );
  7618. array_push ( $nowStaffList, $staffK [0] );
  7619. }
  7620. $nowStaff = implode ( ',', $nowStaffList );
  7621. } else {
  7622. $nowStaff = $verifyDetail [0] [0];
  7623. }
  7624. $receipt->nowStaff = $nowStaff;
  7625. }
  7626. // echo $nowStaff;
  7627. // print_r($verifyDetail);die;
  7628. $receipt->rid = $receiptDetailList ['rid'];
  7629. $receipt->date = date ( "Y-m-d" );
  7630. $receipt->status = 2;
  7631. $receipt->update ();
  7632. $receiptDetail->status = 2;
  7633. $receiptDetail->update ( array (
  7634. 'where' => 'rid=' . $receiptDetailList ['rid']
  7635. ) );
  7636. Doo::loadModel ( "receiptLog" );
  7637. $receiptLog = new receiptLog ();
  7638. Doo::loadModel ( "verify" );
  7639. $verify = new verify ();
  7640. $receiptInfo = $receipt->getOne ( array (
  7641. 'where' => 'rid=' . $rid,
  7642. 'asArray' => true
  7643. ) );
  7644. $vr = $verify->getOne ( array (
  7645. 'where' => 'vid=' . $receiptInfo ['verify'],
  7646. 'asArray' => true
  7647. ) );
  7648. $jd = json_decode ( $vr ['staff'] );
  7649. $roleId = 0;
  7650. foreach ( $jd as $key => $value ) {
  7651. if ($value [1] == 'ROLE') {
  7652. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7653. if ($pos !== false) {
  7654. $roleId = $value [0];
  7655. }
  7656. }
  7657. }
  7658. // 审批日志
  7659. // echo $roleId;die;
  7660. if (! empty ( $roleId )) {
  7661. Doo::loadModel ( "role" );
  7662. $role = new role ();
  7663. $roleInfo = $role->getOne ( array (
  7664. 'where' => 'rid=' . $roleId,
  7665. 'asArray' => true
  7666. ) );
  7667. // $receiptLog->rolename = $roleInfo ['name'];
  7668. }
  7669. $receiptLog->username = $this->staff [0] ['username'];
  7670. $receiptLog->uid = $this->staff [0] ['sid'];
  7671. $receiptLog->date = date ( "Y-m-d" );
  7672. $receiptLog->opinion = '提交审批';
  7673. $receiptLog->img = $this->staff [0] ['avatar'];
  7674. $receiptLog->status = 2;
  7675. $receiptLog->rid = $rid;
  7676. $receiptLog->insert ();
  7677. // statistics item
  7678. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7679. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7680. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7681. $stat = $statistics->getOne ( array (
  7682. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7683. 'asArray' => true
  7684. ) );
  7685. if (empty ( $stat )) {
  7686. $statistics->date = date ( "Y-m-d" );
  7687. $statistics->cid = $this->staff [0] ['cid'];
  7688. $statistics->staff = $this->staff [0] ['sid'];
  7689. $statistics->agPrice = 0;
  7690. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7691. $statistics->insert ();
  7692. } else {
  7693. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7694. $statistics->update ( array (
  7695. 'where' => 'sid=' . $stat ['sid']
  7696. ) );
  7697. }
  7698. return "/expenses";
  7699. }
  7700. function approval() {
  7701. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7702. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7703. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7704. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7705. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7706. if (empty ( $status ))
  7707. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7708. $vidList = array ();
  7709. $button = 0;
  7710. Doo::loadModel ( 'verify' );
  7711. $verify = new verify ();
  7712. Doo::loadModel ( 'receipt' );
  7713. $receipt = new receipt ();
  7714. Doo::loadModel ( 'staff' );
  7715. $staff = new staff ();
  7716. Doo::loadModel ( 'L_category' );
  7717. $Lcategory = new L_category ();
  7718. // user verify ID
  7719. $verifyDetail = $verify->find ( array (
  7720. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7721. 'asArray' => true
  7722. ) );
  7723. foreach ( $verifyDetail as $key => $value ) {
  7724. array_push ( $vidList, $value ['vid'] );
  7725. }
  7726. $vid = implode ( ",", $vidList );
  7727. if (empty ( $verifyDetail ))
  7728. $vid = 0;
  7729. /*
  7730. */
  7731. $dateCondition = " and Year(date) =" . $year;
  7732. if (! empty ( $month ))
  7733. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7734. $categoryList = $Lcategory->find ( array (
  7735. 'asArray' => true
  7736. ) );
  7737. $staffList = $staff->find ( array (
  7738. 'where' => 'cid=' . $cid,
  7739. 'asArray' => true
  7740. ) );
  7741. $cateCondition = "";
  7742. $staffCondition = "";
  7743. $approvalCondition = "";
  7744. if (! empty ( $cid ))
  7745. $cateCondition = ' and cid=' . $cid;
  7746. if (! empty ( $sid )) {
  7747. $staffCondition = ' and staff=' . $sid;
  7748. $cateCondition = "";
  7749. }
  7750. // elseif($status==1){
  7751. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7752. // }
  7753. if ($status == 2) {
  7754. // 查找角色审批人
  7755. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7756. }
  7757. $ap = "";
  7758. if ($status == 4) {
  7759. $ap = 4;
  7760. $status = 2;
  7761. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7762. }
  7763. if ($status == 5) {
  7764. $status = 4;
  7765. $ap = 5;
  7766. }
  7767. // echo $vid;
  7768. // get Receipt By verifyID status 2 .$approvalCondition
  7769. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7770. $receiptList = $receipt->find ( array (
  7771. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7772. 'desc' => 'rid',
  7773. 'asArray' => true
  7774. ) );
  7775. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7776. $Locate = 0;
  7777. if ($ap == 4)
  7778. $status = 4;
  7779. elseif ($ap == 5)
  7780. $status = 5;
  7781. foreach ( $receiptList as $key => $value ) {
  7782. $receiptList [$key] ['Locate'] = $Locate;
  7783. $Locate ++;
  7784. $receiptList [$key] ['reviseDetail'] = array ();
  7785. if (! empty ( $value ['reviseDetail'] ))
  7786. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7787. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7788. $categoryDetil = $Lcategory->getOne ( array (
  7789. 'where' => 'cid=' . $value ['cid'],
  7790. 'asArray' => true
  7791. ) );
  7792. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7793. $verifyList = $verify->getOne ( array (
  7794. 'where' => 'vid=' . $value ['verify'],
  7795. 'asArray' => true
  7796. ) );
  7797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7799. foreach ( $verifyList as $k => $v ) {
  7800. // init verifyStaff
  7801. $verifyList [$k] ['date'] = "";
  7802. $verifyList [$k] ['opinion'] = "";
  7803. $verifyList [$k] ['status'] = "";
  7804. if (empty ( $verifyStaff )) {
  7805. $verifyList [$k] ['date'] = "";
  7806. $verifyList [$k] ['opinion'] = "";
  7807. if ($v [0] == $this->staff [0] ['sid']) {
  7808. $verifyList [$k] ['status'] = 4;
  7809. $button = 4;
  7810. }
  7811. } else {
  7812. $flag = true;
  7813. foreach ( $verifyStaff as $m => $u ) {
  7814. if ($v [0] == $m) {
  7815. $verifyList [$k] ['date'] = $u ['date'];
  7816. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7817. $verifyList [$k] ['status'] = $u ['status'];
  7818. $flag = false;
  7819. break;
  7820. }
  7821. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7822. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7823. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7824. }
  7825. if ($flag) { // 检测可编辑
  7826. if ($v [0] == $this->staff [0] ['sid']) {
  7827. $verifyList [$k] ['status'] = 4;
  7828. $button = 4;
  7829. }
  7830. }
  7831. }
  7832. }
  7833. $receiptList [$key] ['verifyList'] = $verifyList;
  7834. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7835. 'where' => 'sid=' . $value ['staff'],
  7836. 'asArray' => true
  7837. ) );
  7838. $receiptList [$key] ['button'] = $button;
  7839. }
  7840. // print_r($receiptList);die;
  7841. // $data['verifyDetail']=$verifyDetail;
  7842. $mothHtml = "";
  7843. for($i = 1; $i <= 12; $i ++) {
  7844. if ($month == $i)
  7845. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7846. else
  7847. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7848. }
  7849. $data ['mothHtml'] = $mothHtml;
  7850. $data ['receiptList'] = $receiptList;
  7851. $data ['receiptApprovalCount'] = count ( $receiptList );
  7852. $data ['status'] = $status;
  7853. $data ['year'] = $year;
  7854. $data ['categoryList'] = $categoryList;
  7855. $data ['staffList'] = $staffList;
  7856. $data ['cid'] = $cid;
  7857. $data ['sid'] = $sid;
  7858. $data ['ap'] = $ap;
  7859. $data ['memu'] = "receipt";
  7860. $data ['staff'] = $this->staff;
  7861. $data ['receiptMemu'] = 'approval';
  7862. $data ['verifyId'] = $this->verifyId;
  7863. $data ['executeId'] = $this->executeId;
  7864. $this->render ( "/admin/saea_reportList", $data );
  7865. }
  7866. function approvalDetails() {
  7867. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7868. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7869. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7870. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7871. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7872. Doo::loadModel ( 'verify' );
  7873. $verify = new verify ();
  7874. Doo::loadModel ( 'receipt' );
  7875. $receipt = new receipt ();
  7876. Doo::loadModel ( 'staff' );
  7877. $staff = new staff ();
  7878. Doo::loadModel ( 'L_category' );
  7879. $Lcategory = new L_category ();
  7880. Doo::loadModel ( 'enclosur' );
  7881. $enclosur = new enclosur ();
  7882. $vidList = array ();
  7883. $verifyDetail = $verify->find ( array (
  7884. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7885. 'asArray' => true
  7886. ) );
  7887. foreach ( $verifyDetail as $key => $value ) {
  7888. array_push ( $vidList, $value ['vid'] );
  7889. }
  7890. $vid = implode ( ",", $vidList );
  7891. if (empty ( $verifyDetail ))
  7892. $vid = 0;
  7893. $categoryList = $Lcategory->find ( array (
  7894. 'asArray' => true
  7895. ) );
  7896. $staffList = $staff->find ( array (
  7897. 'where' => 'cid=' . $cid,
  7898. 'asArray' => true
  7899. ) );
  7900. $ap = 0;
  7901. $receiptList = $receipt->find ( array (
  7902. 'where' => 'rid =' . $rid,
  7903. 'desc' => 'rid',
  7904. 'asArray' => true
  7905. ) );
  7906. $Locate = 0;
  7907. $roleId = 0;
  7908. $button = 0;
  7909. foreach ( $receiptList as $key => $value ) {
  7910. $receiptList [$key] ['Locate'] = $Locate;
  7911. $Locate ++;
  7912. $receiptList [$key] ['reviseDetail'] = array ();
  7913. if (! empty ( $value ['reviseDetail'] ))
  7914. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7915. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7916. $categoryDetil = $Lcategory->getOne ( array (
  7917. 'where' => 'cid=' . $value ['cid'],
  7918. 'asArray' => true
  7919. ) );
  7920. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7921. // 检测编辑状态
  7922. $verifyList = $verify->getOne ( array (
  7923. 'where' => 'vid=' . $value ['verify'],
  7924. 'asArray' => true
  7925. ) );
  7926. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7927. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7928. Doo::loadModel ( 'role' );
  7929. $role = new role ();
  7930. // print_r($verifyList);
  7931. $flag = true;
  7932. $roleKey = 0;
  7933. $endStaffArray = array ();
  7934. $roleArrayCopy = array ();
  7935. foreach ( $verifyList as $k => $v ) {
  7936. // init verifyStaff
  7937. if ($v [1] == 'ROLE') {
  7938. if (! empty ( $verifyStaff )) {
  7939. $endStaffArray = end ( $verifyStaff );
  7940. if ($v [0] == $endStaffArray ['nextStaff']) {
  7941. $roleId = $v [0];
  7942. }
  7943. }
  7944. $roleVerify = json_decode ( $v [3], true );
  7945. $roleKey = $k;
  7946. $roleArray = array ();
  7947. $rolename = $role->getOne ( array (
  7948. 'where' => 'rid=' . $v [0],
  7949. 'asArray' => true
  7950. ) );
  7951. foreach ( $roleVerify as $o => $p ) {
  7952. $staffID = explode ( '_', $p );
  7953. $staffInfo = $staff->getOne ( array (
  7954. 'where' => 'sid=' . $staffID [0],
  7955. 'asArray' => true
  7956. ) );
  7957. // print_r($staffID);
  7958. $exp = array (
  7959. 0 => $staffInfo ['sid'],
  7960. 1 => $staffID [1],
  7961. 2 => $staffInfo ['avatar'],
  7962. 'date' => '',
  7963. 'date' => '',
  7964. 'opinion' => '',
  7965. 'status' => '',
  7966. 'rolename' => $rolename ['name']
  7967. );
  7968. array_push ( $roleArray, $exp );
  7969. }
  7970. $roleArrayCopy [$v [0]] = $roleArray;
  7971. // $verifyList[$k]['roleArray']=$roleArray;
  7972. }
  7973. // print_r($roleArray);
  7974. $verifyList [$k] ['date'] = "";
  7975. $verifyList [$k] ['opinion'] = "";
  7976. $verifyList [$k] ['status'] = "";
  7977. if (empty ( $verifyStaff )) {
  7978. $verifyList [$k] ['date'] = "";
  7979. $verifyList [$k] ['opinion'] = "";
  7980. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7981. $verifyList [$k] ['status'] = 4;
  7982. $button = 4;
  7983. $flag = false;
  7984. }
  7985. } else {
  7986. foreach ( $verifyStaff as $m => $u ) {
  7987. if ($v [0] == $m) {
  7988. $verifyList [$k] ['date'] = $u ['date'];
  7989. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7990. $verifyList [$k] ['status'] = $u ['status'];
  7991. $flag = false;
  7992. break;
  7993. }
  7994. }
  7995. $endStaffArray = end ( $verifyStaff );
  7996. if (isset ( $endStaffArray ['ROLE'] )) {
  7997. } else {
  7998. $endKey = key ( $verifyStaff );
  7999. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8000. $button = 4;
  8001. $verifyList [$k] ['status'] = 4;
  8002. }
  8003. }
  8004. }
  8005. }
  8006. $rolename ['name'] = '';
  8007. if (! empty ( $roleId )) {
  8008. Doo::loadModel ( 'role' );
  8009. $role = new role ();
  8010. $rolename = $role->getOne ( array (
  8011. 'where' => 'rid=' . $roleId,
  8012. 'asArray' => true
  8013. ) );
  8014. }
  8015. if (! empty ( $verifyStaff ))
  8016. $endStaffArray = end ( $verifyStaff );
  8017. $KOP = false;
  8018. foreach ( $roleArrayCopy as $P => $A ) {
  8019. foreach ( $A as $MKI => $AVL ) {
  8020. if (! empty ( $verifyStaff )) {
  8021. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8022. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8023. $button = 4;
  8024. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8025. }
  8026. foreach ( $verifyStaff as $m => $u ) {
  8027. $AVLFK = $AVL [0] . '_R';
  8028. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8029. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8030. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8031. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8032. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8033. break;
  8034. }
  8035. }
  8036. } else {
  8037. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8038. $button = 4;
  8039. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8040. }
  8041. }
  8042. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8043. $KOP = true;
  8044. }
  8045. }
  8046. foreach ( $roleArrayCopy as $k => $v ) {
  8047. foreach ( $verifyList as $m => $n ) {
  8048. if ($n [0] == $k) {
  8049. array_splice ( $verifyList, $m, 1, $v );
  8050. }
  8051. }
  8052. }
  8053. $receiptList [$key] ['verifyList'] = $verifyList;
  8054. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8055. 'where' => 'sid=' . $value ['staff'],
  8056. 'asArray' => true
  8057. ) );
  8058. $receiptList [$key] ['button'] = $button;
  8059. }
  8060. $mothHtml = "";
  8061. for($i = 1; $i <= 12; $i ++) {
  8062. if ($month == $i)
  8063. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8064. else
  8065. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8066. }
  8067. // 获取审批日志
  8068. Doo::loadModel ( 'receiptLog' );
  8069. $receiptLog = new receiptLog ();
  8070. $rlList = array ();
  8071. $rlInfo = $receiptLog->getOne ( array (
  8072. 'where' => 'rid=' . $rid . ' and status=4',
  8073. 'asArray' => true
  8074. ) );
  8075. $tijdate = $receiptLog->getOne ( array (
  8076. 'where' => 'rid=' . $rid . ' and status=2',
  8077. 'asc' => 'rlid',
  8078. 'asArray' => true
  8079. ) );
  8080. if (! empty ( $rlInfo )) {
  8081. $rlList = $receiptLog->find ( array (
  8082. 'where' => 'rid=' . $rid,
  8083. 'asc' => 'rlid',
  8084. 'asArray' => true
  8085. ) );
  8086. }
  8087. $receiptList [0] ['rlList'] = $rlList;
  8088. $enclosurList = $enclosur->find ( array (
  8089. 'where' => 'rid=' . $rid,
  8090. 'asArray' => true
  8091. ) );
  8092. $enclosurHtml = '';
  8093. foreach ( $enclosurList as $value ) {
  8094. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8095. }
  8096. $data ['enclosurHtml'] = $enclosurHtml;
  8097. $data ['rolename'] = $rolename ['name'];
  8098. $data ['datetij'] = $tijdate ['date'];
  8099. $data ['mothHtml'] = $mothHtml;
  8100. $data ['receiptList'] = $receiptList;
  8101. $data ['receiptApprovalCount'] = count ( $receiptList );
  8102. $data ['year'] = $year;
  8103. $data ['categoryList'] = $categoryList;
  8104. $data ['staffList'] = $staffList;
  8105. $data ['cid'] = $cid;
  8106. $data ['sid'] = $sid;
  8107. $data ['status'] = 0;
  8108. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8109. $ap = 4;
  8110. } else
  8111. $data ['status'] = $receiptList [0] ['status'];
  8112. if ($receiptList [0] ['status'] == 4) {
  8113. $data ['status'] = 5;
  8114. $ap = 0;
  8115. }
  8116. $data ['ap'] = $ap;
  8117. $data ['memu'] = "receipt";
  8118. $data ['staff'] = $this->staff;
  8119. $data ['receiptMemu'] = 'approval';
  8120. $data ['verifyId'] = $this->verifyId;
  8121. $data ['executeId'] = $this->executeId;
  8122. $this->render ( "/admin/saeaReportListReport", $data );
  8123. }
  8124. function approvalEdi() {
  8125. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8126. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8127. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8128. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8129. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8130. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8131. if (empty ( $status ))
  8132. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8133. $vidList = array ();
  8134. $button = 0;
  8135. Doo::loadModel ( 'verify' );
  8136. Doo::loadModel ( 'receipt' );
  8137. Doo::loadModel ( 'staff' );
  8138. $staff = new staff ();
  8139. $receipt = new receipt ();
  8140. $verify = new verify ();
  8141. Doo::loadModel ( 'L_category' );
  8142. $Lcategory = new L_category ();
  8143. Doo::loadModel ( 'enclosur' );
  8144. $enclosur = new enclosur ();
  8145. // user verify ID
  8146. $verifyDetail = $verify->find ( array (
  8147. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8148. 'asArray' => true
  8149. ) );
  8150. foreach ( $verifyDetail as $key => $value ) {
  8151. array_push ( $vidList, $value ['vid'] );
  8152. }
  8153. $vid = implode ( ",", $vidList );
  8154. if (empty ( $verifyDetail ))
  8155. $vid = 0;
  8156. $categoryList = $Lcategory->find ( array (
  8157. 'asArray' => true
  8158. ) );
  8159. $staffList = $staff->find ( array (
  8160. 'where' => 'cid=' . $cid,
  8161. 'asArray' => true
  8162. ) );
  8163. $ap = "";
  8164. if ($status == 4) {
  8165. $ap = 4;
  8166. $status = 2;
  8167. }
  8168. // get Receipt By verifyID status 2
  8169. $receiptList = $receipt->find ( array (
  8170. 'where' => 'rid =' . $rid,
  8171. 'desc' => 'rid',
  8172. 'asArray' => true
  8173. ) );
  8174. $Locate = 0;
  8175. $roleId = 0;
  8176. if ($ap == 4)
  8177. $status = 4;
  8178. foreach ( $receiptList as $key => $value ) {
  8179. $receiptList [$key] ['Locate'] = $Locate;
  8180. $Locate ++;
  8181. $receiptList [$key] ['reviseDetail'] = array ();
  8182. if (! empty ( $value ['reviseDetail'] ))
  8183. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8184. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8185. $categoryDetil = $Lcategory->getOne ( array (
  8186. 'where' => 'cid=' . $value ['cid'],
  8187. 'asArray' => true
  8188. ) );
  8189. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8190. // 检测编辑状态
  8191. $verifyList = $verify->getOne ( array (
  8192. 'where' => 'vid=' . $value ['verify'],
  8193. 'asArray' => true
  8194. ) );
  8195. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8196. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8197. // print_r($verifyList);
  8198. //
  8199. // if (empty($verifyStaff)){
  8200. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8201. // $verifyList[0]['status']=4;$button=4;
  8202. // }
  8203. //
  8204. // }else{
  8205. //
  8206. // }
  8207. // die;
  8208. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8209. // echo array_search("green",$a);
  8210. //
  8211. Doo::loadModel ( 'role' );
  8212. $role = new role ();
  8213. // print_r($verifyList);
  8214. $flag = true;
  8215. $roleKey = 0;
  8216. $endStaffArray = array ();
  8217. $roleArrayCopy = array ();
  8218. foreach ( $verifyList as $k => $v ) {
  8219. // init verifyStaff
  8220. if ($v [1] == 'ROLE') {
  8221. if (! empty ( $verifyStaff )) {
  8222. $endStaffArray = end ( $verifyStaff );
  8223. if ($v [0] == $endStaffArray ['nextStaff']) {
  8224. $roleId = $v [0];
  8225. }
  8226. }
  8227. $roleVerify = json_decode ( $v [3], true );
  8228. $roleKey = $k;
  8229. $roleArray = array ();
  8230. $rolename = $role->getOne ( array (
  8231. 'where' => 'rid=' . $v [0],
  8232. 'asArray' => true
  8233. ) );
  8234. foreach ( $roleVerify as $o => $p ) {
  8235. $staffID = explode ( '_', $p );
  8236. $staffInfo = $staff->getOne ( array (
  8237. 'where' => 'sid=' . $staffID [0],
  8238. 'asArray' => true
  8239. ) );
  8240. // print_r($staffID);
  8241. $exp = array (
  8242. 0 => $staffInfo ['sid'],
  8243. 1 => $staffID [1],
  8244. 2 => $staffInfo ['avatar'],
  8245. 'date' => '',
  8246. 'date' => '',
  8247. 'opinion' => '',
  8248. 'status' => '',
  8249. 'rolename' => $rolename ['name']
  8250. );
  8251. array_push ( $roleArray, $exp );
  8252. }
  8253. $roleArrayCopy [$v [0]] = $roleArray;
  8254. // $verifyList[$k]['roleArray']=$roleArray;
  8255. }
  8256. // print_r($roleArray);
  8257. $verifyList [$k] ['date'] = "";
  8258. $verifyList [$k] ['opinion'] = "";
  8259. $verifyList [$k] ['status'] = "";
  8260. if (empty ( $verifyStaff )) {
  8261. $verifyList [$k] ['date'] = "";
  8262. $verifyList [$k] ['opinion'] = "";
  8263. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8264. $verifyList [$k] ['status'] = 4;
  8265. $button = 4;
  8266. $flag = false;
  8267. }
  8268. } else {
  8269. foreach ( $verifyStaff as $m => $u ) {
  8270. if ($v [0] == $m) {
  8271. $verifyList [$k] ['date'] = $u ['date'];
  8272. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8273. $verifyList [$k] ['status'] = $u ['status'];
  8274. $flag = false;
  8275. break;
  8276. }
  8277. }
  8278. $endStaffArray = end ( $verifyStaff );
  8279. if (isset ( $endStaffArray ['ROLE'] )) {
  8280. } else {
  8281. $endKey = key ( $verifyStaff );
  8282. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8283. $button = 4;
  8284. $verifyList [$k] ['status'] = 4;
  8285. }
  8286. }
  8287. // print_r($endStaffArray);die;
  8288. // if (empty($verifyStaff)){
  8289. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8290. // $verifyList[$k]['status']=4;$button=4;
  8291. // }
  8292. //
  8293. // }else{
  8294. //
  8295. // }
  8296. // if($flag){//检测可编辑
  8297. // if($v[0]==$this->staff[0]['sid']){
  8298. // $verifyList[$k]['status']=4;$button=4;
  8299. // }
  8300. // }
  8301. }
  8302. }
  8303. $rolename ['name'] = '';
  8304. if (! empty ( $roleId )) {
  8305. Doo::loadModel ( 'role' );
  8306. $role = new role ();
  8307. $rolename = $role->getOne ( array (
  8308. 'where' => 'rid=' . $roleId,
  8309. 'asArray' => true
  8310. ) );
  8311. }
  8312. if (! empty ( $verifyStaff ))
  8313. $endStaffArray = end ( $verifyStaff );
  8314. $KOP = false;
  8315. foreach ( $roleArrayCopy as $P => $A ) {
  8316. foreach ( $A as $MKI => $AVL ) {
  8317. if (! empty ( $verifyStaff )) {
  8318. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8319. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8320. $button = 4;
  8321. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8322. }
  8323. foreach ( $verifyStaff as $m => $u ) {
  8324. $AVLFK = $AVL [0] . '_R';
  8325. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8326. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8327. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8328. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8329. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8330. break;
  8331. }
  8332. }
  8333. } else {
  8334. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8335. $button = 4;
  8336. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8337. }
  8338. }
  8339. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8340. $KOP = true;
  8341. }
  8342. }
  8343. // print_r($roleArrayCopy);
  8344. // echo $roleKey;
  8345. foreach ( $roleArrayCopy as $k => $v ) {
  8346. foreach ( $verifyList as $m => $n ) {
  8347. if ($n [0] == $k) {
  8348. array_splice ( $verifyList, $m, 1, $v );
  8349. }
  8350. }
  8351. }
  8352. // if ($KOP)
  8353. // array_splice($verifyList,$roleKey,1,$roleArray);
  8354. // print_r($verifyList);
  8355. $receiptList [$key] ['verifyList'] = $verifyList;
  8356. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8357. 'where' => 'sid=' . $value ['staff'],
  8358. 'asArray' => true
  8359. ) );
  8360. $receiptList [$key] ['button'] = $button;
  8361. }
  8362. // $data['verifyDetail']=$verifyDetail;
  8363. $mothHtml = "";
  8364. for($i = 1; $i <= 12; $i ++) {
  8365. if ($month == $i)
  8366. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8367. else
  8368. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8369. }
  8370. // 获取审批日志
  8371. Doo::loadModel ( 'receiptLog' );
  8372. $receiptLog = new receiptLog ();
  8373. $rlList = array ();
  8374. $rlInfo = $receiptLog->getOne ( array (
  8375. 'where' => 'rid=' . $rid . ' and status=4',
  8376. 'asArray' => true
  8377. ) );
  8378. $tijdate = $receiptLog->getOne ( array (
  8379. 'where' => 'rid=' . $rid . ' and status=2',
  8380. 'asc' => 'rlid',
  8381. 'asArray' => true
  8382. ) );
  8383. if (! empty ( $rlInfo )) {
  8384. $rlList = $receiptLog->find ( array (
  8385. 'where' => 'rid=' . $rid,
  8386. 'asc' => 'rlid',
  8387. 'asArray' => true
  8388. ) );
  8389. }
  8390. $receiptList [0] ['rlList'] = $rlList;
  8391. $enclosurList = $enclosur->find ( array (
  8392. 'where' => 'rid=' . $rid,
  8393. 'asArray' => true
  8394. ) );
  8395. $enclosurHtml = '';
  8396. foreach ( $enclosurList as $value ) {
  8397. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8398. }
  8399. $data ['enclosurHtml'] = $enclosurHtml;
  8400. $data ['rolename'] = $rolename ['name'];
  8401. $data ['datetij'] = $tijdate ['date'];
  8402. $data ['mothHtml'] = $mothHtml;
  8403. $data ['receiptList'] = $receiptList;
  8404. $data ['receiptApprovalCount'] = count ( $receiptList );
  8405. $data ['status'] = $status;
  8406. $data ['year'] = $year;
  8407. $data ['categoryList'] = $categoryList;
  8408. $data ['staffList'] = $staffList;
  8409. $data ['cid'] = $cid;
  8410. $data ['sid'] = $sid;
  8411. $data ['ap'] = $ap;
  8412. $data ['memu'] = "receipt";
  8413. $data ['staff'] = $this->staff;
  8414. $data ['receiptMemu'] = 'approval';
  8415. $data ['verifyId'] = $this->verifyId;
  8416. $data ['executeId'] = $this->executeId;
  8417. $this->render ( "/admin/saeaReportListReport", $data );
  8418. }
  8419. function remittanceHky() {
  8420. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8421. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8422. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8423. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8424. $page_size = 15;
  8425. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8426. Doo::loadModel ( 'receipt' );
  8427. $receipt = new receipt ();
  8428. Doo::loadModel ( 'staff' );
  8429. $staff = new staff ();
  8430. $dateCondition = " and Year(executeDate) =" . $year;
  8431. if ($moth != 'MONTH')
  8432. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8433. if ($day != 'DAY' && $moth != 'MONTH')
  8434. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8435. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8436. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8437. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8438. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8439. $dayList = $receipt->find ( array (
  8440. 'select' => 'executeDate,sum(amount) as amount',
  8441. 'where' => $sql,
  8442. 'desc' => 'executeDate',
  8443. 'groupby' => 'executeDate',
  8444. 'limit' => $limit,
  8445. 'asArray' => true
  8446. ) );
  8447. // print_r($dayList);
  8448. foreach ( $dayList as $key => $value ) {
  8449. $remitString = "";
  8450. $receiptList = $receipt->find ( array (
  8451. 'select' => 'rid,executeDate,amount,staff,cid',
  8452. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8453. 'desc' => 'executeDate',
  8454. 'asArray' => true
  8455. ) );
  8456. foreach ( $receiptList as $k => $v ) {
  8457. $sinfo = $staff->getOne ( array (
  8458. 'select' => 'username,category',
  8459. 'where' => ' sid=' . $v ['staff'],
  8460. 'asArray' => true
  8461. ) );
  8462. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8463. }
  8464. $dayList [$key] ['staff'] = $remitString;
  8465. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8466. }
  8467. // print_r($dayList);
  8468. $mothHtml = "";
  8469. for($i = 1; $i <= 12; $i ++) {
  8470. if ($moth == $i)
  8471. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8472. else
  8473. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8474. }
  8475. $dayHtml = "";
  8476. if ($day != "DAY" || $moth != "MONTH") {
  8477. for($i = 1; $i <= 31; $i ++) {
  8478. if ($day == $i)
  8479. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8480. else
  8481. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8482. }
  8483. }
  8484. $dateHtml = "";
  8485. $now = date ( "Y" );
  8486. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8487. if ($YEARD <= $now) {
  8488. $dateHtml .= '<option ';
  8489. if ($year == $YEARD) {
  8490. $dateHtml .= 'selected ';
  8491. }
  8492. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8493. }
  8494. }
  8495. $data ['dateHtml'] = $dateHtml;
  8496. $data ['page'] = $pageinfo;
  8497. $data ['year'] = $year;
  8498. $data ['moth'] = $moth;
  8499. $data ['day'] = $day;
  8500. $data ['get'] = $get;
  8501. $data ['dayHtml'] = $dayHtml;
  8502. $data ['mothHtml'] = $mothHtml;
  8503. $data ['receiptList'] = $dayList;
  8504. $data ['memu'] = "receipt";
  8505. $data ['staff'] = $this->staff;
  8506. $data ['receiptMemu'] = 'remittanceHky';
  8507. $data ['verifyId'] = $this->verifyId;
  8508. $data ['executeId'] = $this->executeId;
  8509. $this->render ( "/admin/remittanceHky", $data );
  8510. }
  8511. function remittancep() {
  8512. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8513. Doo::loadModel ( 'receipt' );
  8514. $receipt = new receipt ();
  8515. Doo::loadModel ( 'staff' );
  8516. $staff = new staff ();
  8517. Doo::loadClass ( 'XDeode' );
  8518. $XDeode = new XDeode ( 5 );
  8519. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8520. $rplist = $receipt->find ( array (
  8521. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8522. 'asArray' => true
  8523. ) );
  8524. $dayList = $receipt->find ( array (
  8525. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8526. 'desc' => 'executeDate',
  8527. 'groupby' => 'staff',
  8528. 'asArray' => true
  8529. ) );
  8530. $html = '';
  8531. foreach ( $dayList as $key => $value ) {
  8532. $sinfo = $staff->getOne ( array (
  8533. 'select' => 'username,category',
  8534. 'where' => ' sid=' . $value ['staff'],
  8535. 'asArray' => true
  8536. ) );
  8537. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8538. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8539. $au = 0;
  8540. foreach ( $rplist as $k => $v ) {
  8541. if ($value ['staff'] == $v ['staff']) {
  8542. $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>';
  8543. $au += $v ['amount'];
  8544. }
  8545. }
  8546. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8547. }
  8548. $data ['html'] = $html;
  8549. $data ['memu'] = "receipt";
  8550. $data ['staff'] = $this->staff;
  8551. $data ['receiptMemu'] = 'remittanceHky';
  8552. $data ['verifyId'] = $this->verifyId;
  8553. $data ['executeId'] = $this->executeId;
  8554. $this->render ( "/admin/remittancep", $data );
  8555. }
  8556. function ajaxGetReceiptDetails() {
  8557. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8558. Doo::loadClass ( 'XDeode' );
  8559. $XDeode = new XDeode ( 5 );
  8560. $rid = $XDeode->decode ( $rid );
  8561. if (empty ( $rid )) {
  8562. echo json_encode ( array (
  8563. 'status' => 2,
  8564. 'msg' => 'illegal request'
  8565. ) );
  8566. die ();
  8567. }
  8568. Doo::loadModel ( 'receipt' );
  8569. $receipt = new receipt ();
  8570. Doo::loadModel ( 'staff' );
  8571. $staff = new staff ();
  8572. $rinfo = $receipt->getOne ( array (
  8573. 'where' => 'rid= ' . $rid,
  8574. 'asArray' => true
  8575. ) );
  8576. $sinfo = $staff->getOne ( array (
  8577. 'select' => 'username,category',
  8578. 'where' => ' sid=' . $rinfo ['staff'],
  8579. 'asArray' => true
  8580. ) );
  8581. $rinfo ['reviseDetail'] = array ();
  8582. if (! empty ( $rinfo ['reviseDetail'] ))
  8583. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8584. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8585. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8586. $rinfo ['category'] = $sinfo ['category'];
  8587. $verifyStaff = array ();
  8588. if (! empty ( $rinfo ['verifyStaff'] ))
  8589. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8590. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8591. $rinfo ['relust'] = $relust;
  8592. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8593. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8594. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8595. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8596. // 费用执行人相关数据
  8597. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8598. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8599. foreach ( $executeCopy as $k => $v ) {
  8600. $executeCopy [$k] ['date'] = '';
  8601. $executeCopy [$k] ['opinion'] = '';
  8602. $executeCopy [$k] ['status'] = '';
  8603. if (! empty ( $executeStaff ))
  8604. foreach ( $executeStaff as $m => $u ) {
  8605. if ($v [0] == $m) {
  8606. $executeCopy [$k] ['date'] = $u ['date'];
  8607. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8608. $executeCopy [$k] ['status'] = $u ['status'];
  8609. break;
  8610. }
  8611. }
  8612. }
  8613. $rinfo ['executeCopy'] = $executeCopy;
  8614. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8615. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8616. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8617. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8618. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8619. $html .= '<tr><th>' . $value ['name'] . '</th>
  8620. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8621. }
  8622. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8623. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8624. <tr><th class="taC" colspan="2">费用说明</th>
  8625. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8626. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8627. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8628. </tbody></table>';
  8629. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8630. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8631. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8632. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8633. $html .= '<tr><th>' . $value ['name'] . '</th>
  8634. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8635. }
  8636. $html .= '<tr><th class="taR">合计</th>
  8637. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8638. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8639. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8640. $html .= '<tr><th>' . $value ['name'] . '</th>
  8641. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8642. }
  8643. $html .= '<tr><th class="taR">合计</th>
  8644. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8645. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8646. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8647. $html .= '<tr><th>' . $value ['name'] . '</th>
  8648. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8649. }
  8650. $html .= '<tr><th class="taR">合计</th>
  8651. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8652. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8653. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8654. $html .= '<tr><th>' . $value ['name'] . '</th>
  8655. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8656. }
  8657. $html .= '<tr><th class="taR">合计</th>
  8658. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8659. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8660. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8661. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8662. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8663. }
  8664. $html .= '<tr><th class="taR">合计</th>
  8665. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8666. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8667. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8668. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8669. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8670. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8671. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8672. <tr';
  8673. if ($rinfo ['relust'] >= 0) {
  8674. $html .= 'class="success"';
  8675. } else {
  8676. $html .= 'class="error"';
  8677. }
  8678. $html .= '><td class="taR"><b>借款结余</b></td>
  8679. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8680. </tbody></table>
  8681. ';
  8682. }
  8683. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8684. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8685. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8686. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8687. $html .= '<tr><th>' . $value ['name'] . '</th>
  8688. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8689. }
  8690. $html .= '<tr><th class="taR">合计</th>
  8691. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8692. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8693. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8694. <tr><th class="taC" colspan="2">费用说明</th>
  8695. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8696. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8697. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8698. </tbody></table>';
  8699. } else {
  8700. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8701. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8702. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8703. $html .= '<tr><th>' . $value ['name'] . '</th>
  8704. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8705. }
  8706. $html .= '<tr><th class="taR">合计</th>
  8707. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8708. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8709. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8710. $html .= '<tr><th>' . $value ['name'] . '</th>
  8711. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8712. }
  8713. $html .= '<tr><th class="taR">合计</th>
  8714. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8715. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8716. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8717. $html .= '<tr><th>' . $value ['name'] . '</th>
  8718. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8719. }
  8720. $html .= '<tr><th class="taR">合计</th>
  8721. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8722. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8723. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8724. $html .= '<tr><th>' . $value ['name'] . '</th>
  8725. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8726. }
  8727. $html .= '<tr><th class="taR">合计</th>
  8728. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8729. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8730. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8731. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8732. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8733. }
  8734. $html .= '<tr><th class="taR">合计</th>
  8735. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8736. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8737. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8738. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8739. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8740. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8741. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8742. $html .= '</tbody></table>';
  8743. /*
  8744. * <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>
  8745. */
  8746. }
  8747. // print_r($verifyStaff);die;
  8748. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8749. foreach ( $verifyStaff as $key => $value ) {
  8750. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8751. $sinfo = $staff->getOne ( array (
  8752. 'select' => 'username',
  8753. 'where' => ' sid=' . $key,
  8754. 'asArray' => true
  8755. ) );
  8756. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8757. }
  8758. $html .= '</tbody></table>';
  8759. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8760. foreach ( $rinfo ['executeCopy'] as $value ) {
  8761. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8762. }
  8763. $html .= '</tbody></table>';
  8764. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8765. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8766. </tr></table>';
  8767. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8768. echo json_encode ( array (
  8769. 'status' => 1,
  8770. 'html' => $html
  8771. ) );
  8772. die ();
  8773. }
  8774. /**
  8775. * 删除附件
  8776. */
  8777. function ajaxRemEnclousur() {
  8778. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8779. if (empty ( $key ))
  8780. echo json_encode ( array (
  8781. 'status' => 2
  8782. ) );
  8783. Doo::loadModel ( 'enclosur' );
  8784. $enclosur = new enclosur ();
  8785. $enclosur->delEnclosurByEid ( $key );
  8786. echo json_encode ( array (
  8787. 'status' => 1
  8788. ) );
  8789. }
  8790. function remittance() {
  8791. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8792. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8793. Doo::loadModel ( 'receipt' );
  8794. $receipt = new receipt ();
  8795. Doo::loadModel ( 'staff' );
  8796. $staff = new staff ();
  8797. $dateCondition = " and Year(pastDate) =" . $year;
  8798. if (! empty ( $month ))
  8799. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8800. // get Receipt By verifyID status 1
  8801. $receiptList = $receipt->find ( array (
  8802. 'select' => 'sum(sum) as sum,staff,pastDate',
  8803. 'where' => ' status=1' . $dateCondition,
  8804. 'desc' => 'pastDate',
  8805. 'groupby' => 'staff,pastDate',
  8806. 'asArray' => true
  8807. ) );
  8808. $dateList = $receipt->find ( array (
  8809. 'select' => 'pastDate,verifyStaff',
  8810. 'where' => ' status=1' . $dateCondition,
  8811. 'desc' => 'pastDate',
  8812. 'groupby' => 'pastDate',
  8813. 'asArray' => true
  8814. ) );
  8815. $dataList = array ();
  8816. foreach ( $dateList as $d => $a ) {
  8817. $dataList [$a ['pastDate']] = array ();
  8818. $daySum = 0;
  8819. foreach ( $receiptList as $key => $value ) {
  8820. if ($a ['pastDate'] == $value ['pastDate']) {
  8821. $oderList = $receipt->find ( array (
  8822. 'select' => 'receiptOrder',
  8823. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8824. 'asArray' => true
  8825. ) );
  8826. $list = array ();
  8827. $html = "";
  8828. foreach ( $oderList as $v ) {
  8829. array_push ( $list, $v ['receiptOrder'] );
  8830. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8831. }
  8832. $receiptList [$key] ['receiptOrder'] = $html;
  8833. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8834. $sinfo = $staff->getOne ( array (
  8835. 'select' => 'username ',
  8836. 'where' => ' sid=' . $value ['staff'],
  8837. 'asArray' => true
  8838. ) );
  8839. $receiptList [$key] ['username'] = $sinfo ['username'];
  8840. $daySum += $value ['sum'];
  8841. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8842. }
  8843. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8844. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8845. }
  8846. }
  8847. // print_r($dataList);
  8848. $data ['dataList'] = $dataList;
  8849. $mothHtml = "";
  8850. for($i = 1; $i <= 12; $i ++) {
  8851. if ($month == $i)
  8852. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8853. else
  8854. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8855. }
  8856. $data ['year'] = $year;
  8857. $data ['mothHtml'] = $mothHtml;
  8858. $data ['memu'] = "receipt";
  8859. $data ['staff'] = $this->staff;
  8860. $data ['receiptMemu'] = 'approval';
  8861. $data ['verifyId'] = $this->verifyId;
  8862. $data ['executeId'] = $this->executeId;
  8863. $this->render ( "/admin/saeaReportListPay", $data );
  8864. }
  8865. /**
  8866. * 金额调整,提高稳定性
  8867. * @return string
  8868. */
  8869. function revocationAdjustment() {
  8870. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8871. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8872. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8873. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8874. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8875. Doo::loadClass ( 'XDeode' );
  8876. $XDeode = new XDeode ( 5 );
  8877. Doo::loadModel ( 'receipt' );
  8878. $receipt = new receipt ();
  8879. $sid = $XDeode->decode ( $sidKey );
  8880. $rid = $XDeode->decode ( $ridKey );
  8881. $reviseKey = $XDeode->decode ( $reviseKey );
  8882. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8883. die ( 'illegal request' );
  8884. $receiptDetail = $receipt->getOne ( array (
  8885. 'where' => 'rid=' . $rid,
  8886. 'asArray' => true
  8887. ) );
  8888. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8889. die ( 'illegal request' );
  8890. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8891. if (! isset ( $reviseDetail [$reviseKey] ))
  8892. die ( 'illegal request' );
  8893. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8894. unset ( $reviseDetail [$reviseKey] );
  8895. $revisePrice = 0;
  8896. foreach ( $reviseDetail as $key => $value ) {
  8897. $revisePrice += $value ['price'];
  8898. }
  8899. $reviseDetailString = json_encode ( $reviseDetail );
  8900. $receipt->reviseDetail = $reviseDetailString;
  8901. $receipt->sum = $receiptDetail ['sum'] - $price;
  8902. $receipt->revisePrice = $revisePrice;
  8903. $receipt->update ( array (
  8904. 'where' => 'rid=' . $rid
  8905. ) );
  8906. return '/receiptburEdi/' . $rid;
  8907. } else
  8908. die ( 'illegal request2' );
  8909. }
  8910. function updateApprovalReceipt() {
  8911. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8912. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8913. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8914. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8915. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8916. if (! empty ( $rid )) {
  8917. Doo::loadModel ( "verify" );
  8918. $verify = new verify ();
  8919. Doo::loadModel ( "receiptDetail" );
  8920. $receiptDetailObj = new receiptDetail ();
  8921. Doo::loadModel ( "itemStatistics" );
  8922. Doo::loadModel ( "statistics" );
  8923. $statistics = new statistics ();
  8924. $itemStatistics = new itemStatistics ();
  8925. Doo::loadModel ( "receipt" );
  8926. $receipt = new receipt ();
  8927. $receiptDetail = $receipt->getOne ( array (
  8928. 'where' => 'rid=' . $rid . ' and status=2 ',
  8929. 'asArray' => true
  8930. ) );
  8931. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8932. $nsflag = true;
  8933. foreach ( $nslist as $value ) {
  8934. if ($value == $this->staff ['0'] ['sid']) {
  8935. $nsflag = false;
  8936. break;
  8937. }
  8938. }
  8939. if (empty ( $receiptDetail ) || $nsflag)
  8940. return "/approvalExpenses/pendApproval";
  8941. $verifyDetail = $verify->getOne ( array (
  8942. 'where' => ' vid =' . $receiptDetail ['verify'],
  8943. 'asArray' => true
  8944. ) );
  8945. $verifyString = $verifyDetail ['staff'];
  8946. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8947. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8948. if (empty ( $opinion )) {
  8949. if ($status == 3)
  8950. $opinion = "终止";
  8951. else
  8952. $opinion = "同意支付";
  8953. }
  8954. $nowStaff = 0;
  8955. $nowStaffList = array ();
  8956. if (empty ( $verifyStaff )) {
  8957. // 还需加入是否已经进入角色审批
  8958. if ($verifyDetail [0] [1] == 'ROLE') {
  8959. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8960. foreach ( $vStaffString as $key => $value ) {
  8961. $staffK = explode ( "_", $value );
  8962. if ($staffK [0] != $this->staff [0] ['sid'])
  8963. array_push ( $nowStaffList, $staffK [0] );
  8964. }
  8965. // print_r($verifyDetail);
  8966. // die;
  8967. if (! empty ( $nowStaffList )) {
  8968. $nowStaff = implode ( ',', $nowStaffList );
  8969. $verifyStaff = array (
  8970. $this->staff [0] ['sid'] . "_R" => array (
  8971. 'date' => date ( 'Y-m-d' ),
  8972. 'opinion' => $opinion,
  8973. 'status' => $status,
  8974. 'nextStaff' => $verifyDetail [0] [0],
  8975. 'ROLE' => 1
  8976. )
  8977. );
  8978. } else {
  8979. $nowStaff = $verifyDetail [1] [0];
  8980. $verifyStaff = array (
  8981. $this->staff [0] ['sid'] . "_R" => array (
  8982. 'date' => date ( 'Y-m-d' ),
  8983. 'opinion' => $opinion,
  8984. 'status' => $status,
  8985. 'nextStaff' => $verifyDetail [1] [0]
  8986. )
  8987. );
  8988. }
  8989. } else {
  8990. if ($verifyDetail [1] [1] == 'ROLE') {
  8991. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8992. // echo "dd";
  8993. foreach ( $vStaffString as $key => $value ) {
  8994. $staffK = explode ( "_", $value );
  8995. array_push ( $nowStaffList, $staffK [0] );
  8996. }
  8997. $nowStaff = implode ( ',', $nowStaffList );
  8998. $verifyStaff = array (
  8999. $this->staff [0] ['sid'] => array (
  9000. 'date' => date ( 'Y-m-d' ),
  9001. 'opinion' => $opinion,
  9002. 'status' => $status,
  9003. 'nextStaff' => $verifyDetail [1] [0],
  9004. 'ROLE' => 1
  9005. )
  9006. );
  9007. } else {
  9008. $nowStaff = $verifyDetail [1] [0];
  9009. $verifyStaff = array (
  9010. $this->staff [0] ['sid'] => array (
  9011. 'date' => date ( 'Y-m-d' ),
  9012. 'opinion' => $opinion,
  9013. 'status' => $status,
  9014. 'nextStaff' => $verifyDetail [1] [0]
  9015. )
  9016. );
  9017. }
  9018. }
  9019. if ($status == 3)
  9020. $verifyStaff = array (
  9021. 'final' => $status,
  9022. $this->staff [0] ['sid'] => array (
  9023. 'date' => date ( 'Y-m-d' ),
  9024. 'opinion' => $opinion,
  9025. 'status' => $status
  9026. )
  9027. );
  9028. $vStaffString = json_encode ( $verifyStaff );
  9029. $receipt->nowStaff = $nowStaff;
  9030. $receipt->verifyStaff = $vStaffString;
  9031. } else {
  9032. $VS = end ( $verifyStaff );
  9033. // 非角色审批
  9034. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9035. $nextStaff = 0;
  9036. $roleSTF = false;
  9037. foreach ( $verifyDetail as $key => $value ) {
  9038. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9039. if (isset ( $verifyDetail [$key + 1] )) {
  9040. $nextStaff = $verifyDetail [$key + 1] [0];
  9041. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9042. $roleSTF = true;
  9043. }
  9044. break;
  9045. }
  9046. }
  9047. if (! $roleSTF) {
  9048. $nowStaff = $nextStaff;
  9049. $verifyStaff [$this->staff [0] ['sid']] = array (
  9050. 'date' => date ( 'Y-m-d' ),
  9051. 'opinion' => $opinion,
  9052. 'status' => $status,
  9053. 'nextStaff' => $nextStaff
  9054. );
  9055. } else {
  9056. // 获取角色下的所有用户ID
  9057. $nowStaffList = array ();
  9058. foreach ( $verifyDetail as $vfk ) {
  9059. if ($vfk [1] == 'ROLE') {
  9060. $vStaffString = json_decode ( $vfk [3] );
  9061. foreach ( $vStaffString as $key => $value ) {
  9062. $staffK = explode ( "_", $value );
  9063. array_push ( $nowStaffList, $staffK [0] );
  9064. }
  9065. }
  9066. }
  9067. $nowStaff = implode ( ',', $nowStaffList );
  9068. $verifyStaff [$this->staff [0] ['sid']] = array (
  9069. 'date' => date ( 'Y-m-d' ),
  9070. 'opinion' => $opinion,
  9071. 'status' => $status,
  9072. 'nextStaff' => $nextStaff,
  9073. 'ROLE' => 0
  9074. );
  9075. }
  9076. if ($status == 3) {
  9077. $verifyStaff ['final'] = $status;
  9078. $verifyStaff [$this->staff [0] ['sid']] = array (
  9079. 'date' => date ( 'Y-m-d' ),
  9080. 'opinion' => $opinion,
  9081. 'status' => $status
  9082. );
  9083. }
  9084. $vStaffString = json_encode ( $verifyStaff );
  9085. $receipt->nowStaff = $nowStaff;
  9086. $receipt->verifyStaff = $vStaffString;
  9087. }
  9088. // 角色审批
  9089. if (isset ( $VS ['ROLE'] )) {
  9090. // 找出角色人 当前审批角色组
  9091. $verifyJSStaff = array ();
  9092. $nowStaffList2 = array ();
  9093. foreach ( $verifyDetail as $key => $value ) {
  9094. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9095. $verifyJSStaff = json_decode ( $value [3] );
  9096. foreach ( $verifyJSStaff as $m ) {
  9097. $staffK = explode ( "_", $m );
  9098. array_push ( $nowStaffList2, $staffK [0] );
  9099. }
  9100. // print_r($nowStaffList2);
  9101. }
  9102. }
  9103. $RoleVerifyStaff = array ();
  9104. foreach ( $verifyStaff as $key => $value ) {
  9105. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9106. foreach ( $nowStaffList2 as $m ) {
  9107. if ($key == $m . "_R")
  9108. $RoleVerifyStaff [$key] = $value;
  9109. }
  9110. }
  9111. }
  9112. // print_r($verifyStaff);
  9113. // print_r($nowStaffList2);
  9114. // print_r($RoleVerifyStaff);
  9115. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9116. // print_r($verifyJSStaff);
  9117. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9118. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9119. // 下一个审批人ID
  9120. $nextStaff = 0;
  9121. $falg = false;
  9122. foreach ( $verifyDetail as $key => $value ) {
  9123. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9124. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9125. $falg = true;
  9126. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9127. $nowStaffList = array ();
  9128. foreach ( $vStaffString as $v ) {
  9129. $staffK = explode ( "_", $v );
  9130. array_push ( $nowStaffList, $staffK [0] );
  9131. }
  9132. $nowStaff = implode ( ',', $nowStaffList );
  9133. $nextStaff = $verifyDetail [$key + 1] [0];
  9134. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9135. $nextStaff = $verifyDetail [$key + 1] [0];
  9136. $nowStaff = $nextStaff;
  9137. } else
  9138. $nowStaff = '';
  9139. break;
  9140. }
  9141. }
  9142. if ($falg)
  9143. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9144. 'date' => date ( 'Y-m-d' ),
  9145. 'opinion' => $opinion,
  9146. 'status' => $status,
  9147. 'nextStaff' => $nextStaff,
  9148. 'ROLE' => 1
  9149. );
  9150. else
  9151. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9152. 'date' => date ( 'Y-m-d' ),
  9153. 'opinion' => $opinion,
  9154. 'status' => $status,
  9155. 'nextStaff' => $nextStaff
  9156. );
  9157. // print_r($verifyStaff);
  9158. // echo $nowStaff;die;
  9159. } else { // 进入下一个角色或者审批人
  9160. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9161. //
  9162. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9163. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9164. 'date' => date ( 'Y-m-d' ),
  9165. 'opinion' => $opinion,
  9166. 'status' => $status,
  9167. 'nextStaff' => $VS ['nextStaff'],
  9168. 'ROLE' => 1
  9169. );
  9170. // print_r($verifyStaff);
  9171. // die;
  9172. }
  9173. if ($status == 3) {
  9174. $verifyStaff ['final'] = $status;
  9175. $verifyStaff [$this->staff [0] ['sid']] = array (
  9176. 'date' => date ( 'Y-m-d' ),
  9177. 'opinion' => $opinion,
  9178. 'status' => $status
  9179. );
  9180. }
  9181. $vStaffString = json_encode ( $verifyStaff );
  9182. $receipt->verifyStaff = $vStaffString;
  9183. $receipt->nowStaff = $nowStaff;
  9184. // die;
  9185. // }
  9186. // print_r($verifyStaff);
  9187. // die;
  9188. }
  9189. // print_r($verifyStaff);die;
  9190. }
  9191. // print_r($verifyDetail);
  9192. $roleKey = 0;
  9193. $roleId = 0;
  9194. $verifyDetailCopy = array ();
  9195. foreach ( $verifyDetail as $k => $v ) {
  9196. if ($v [1] == 'ROLE') {
  9197. $roleId = $v [0];
  9198. $roleVerify = json_decode ( $v [3], true );
  9199. $roleKey = $k;
  9200. $roleArray = array ();
  9201. foreach ( $roleVerify as $o => $p ) {
  9202. $staffID = explode ( '_', $p );
  9203. $exp = array (
  9204. 0 => $staffID [0],
  9205. 1 => $staffID [1]
  9206. );
  9207. array_push ( $roleArray, $exp );
  9208. }
  9209. $verifyDetailCopy [$v [0]] = $roleArray;
  9210. }
  9211. }
  9212. // print_r($verifyDetail);
  9213. foreach ( $verifyDetailCopy as $k => $v ) {
  9214. foreach ( $verifyDetail as $m => $n ) {
  9215. if ($n [0] == $k) {
  9216. array_splice ( $verifyDetail, $m, 1, $v );
  9217. }
  9218. }
  9219. }
  9220. // die;
  9221. // if (!empty($roleArray))
  9222. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9223. // echo $roleId;
  9224. // print_r($verifyStaff);
  9225. // print_r($verifyDetail);
  9226. // die;
  9227. Doo::loadModel ( "receiptLog" );
  9228. $receiptLog = new receiptLog ();
  9229. // 审批日志
  9230. if (! isset ( $verifyStaff ['final'] )) {
  9231. if (! empty ( $roleId )) {
  9232. Doo::loadModel ( "role" );
  9233. $role = new role ();
  9234. $roleInfo = $role->getOne ( array (
  9235. 'where' => 'rid=' . $roleId,
  9236. 'asArray' => true
  9237. ) );
  9238. $receiptLog->rolename = $roleInfo ['name'];
  9239. }
  9240. $receiptLog->username = $this->staff [0] ['username'];
  9241. $receiptLog->uid = $this->staff [0] ['sid'];
  9242. $receiptLog->date = date ( "Y-m-d" );
  9243. $receiptLog->opinion = $opinion;
  9244. $receiptLog->img = $this->staff [0] ['avatar'];
  9245. $receiptLog->status = 1;
  9246. $receiptLog->rid = $rid;
  9247. $receiptLog->insert ();
  9248. }
  9249. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9250. $receipt->verifyBreakup = $verifyString;
  9251. $receipt->status = 3;
  9252. $receiptDetailObj->status = 3;
  9253. $receiptDetailObj->update ( array (
  9254. 'where' => 'rid=' . $rid
  9255. ) );
  9256. if (! empty ( $roleId )) {
  9257. Doo::loadModel ( "role" );
  9258. $role = new role ();
  9259. $roleInfo = $role->getOne ( array (
  9260. 'where' => 'rid=' . $roleId,
  9261. 'asArray' => true
  9262. ) );
  9263. $receiptLog->rolename = $roleInfo ['name'];
  9264. }
  9265. $receiptLog->username = $this->staff [0] ['username'];
  9266. $receiptLog->uid = $this->staff [0] ['sid'];
  9267. $receiptLog->date = date ( "Y-m-d" );
  9268. $receiptLog->opinion = $opinion;
  9269. $receiptLog->img = $this->staff [0] ['avatar'];
  9270. $receiptLog->status = 3;
  9271. $receiptLog->rid = $rid;
  9272. $receiptLog->insert ();
  9273. //删除行程单
  9274. Doo::loadModel ( 'itinerary' );
  9275. $itinerary = new itinerary ();
  9276. $itinerary->delete ( array (
  9277. 'where' => 'rid="' . $rid . '"'
  9278. ) );
  9279. // 微信企业号通知
  9280. $this->setWXMsg ( $rid, 3 );
  9281. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9282. $receipt->status = 1;
  9283. $reviseSum = 0;
  9284. $receipt->verifyBreakup = $verifyString;
  9285. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9286. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9287. foreach ( $reviseDetail as $key => $value ) {
  9288. $receiptDetailObj = new receiptDetail ();
  9289. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9290. $receiptDetailObj->item = $value ['description'];
  9291. $receiptDetailObj->itemCategory = "报销金额调整";
  9292. $receiptDetailObj->price = $value ['price'];
  9293. $receiptDetailObj->date = $receiptDetail ['date'];
  9294. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9295. $receiptDetailObj->rid = $rid;
  9296. $receiptDetailObj->status = 1;
  9297. $receiptDetailObj->insert ();
  9298. $reviseSum += $value ['price'];
  9299. }
  9300. $itemStatistics = new itemStatistics ();
  9301. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9302. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9303. $itemStatistics->price = $reviseSum;
  9304. $itemStatistics->itemCategory = "报销金额调整";
  9305. $itemStatistics->date = $receiptDetail ['date'];
  9306. $itemStatistics->insert ();
  9307. }
  9308. $receiptDetailObj = new receiptDetail ();
  9309. $receiptDetailObj->status = 1;
  9310. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9311. $receiptDetailObj->update ( array (
  9312. 'where' => 'rid=' . $rid
  9313. ) );
  9314. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9315. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9316. $stat = $statistics->getOne ( array (
  9317. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9318. 'asArray' => true
  9319. ) );
  9320. if (empty ( $stat )) {
  9321. $statistics->date = $receiptDetail ['date'];
  9322. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9323. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9324. $statistics->agPrice = $receiptDetail ['sum'];
  9325. $statistics->rePrice = $reviseSum;
  9326. $statistics->insert ();
  9327. } else {
  9328. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9329. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9330. $statistics->update ( array (
  9331. 'where' => 'sid=' . $stat ['sid']
  9332. ) );
  9333. }
  9334. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9335. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9336. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9337. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9338. if ($key == "agencySum") {
  9339. $iStatistics = $itemStatistics->getOne ( array (
  9340. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9341. 'asArray' => true
  9342. ) );
  9343. if (empty ( $iStatistics )) {
  9344. $itemStatistics->cid = $receiptDetail ['cid'];
  9345. ;
  9346. $itemStatistics->staff = $receiptDetail ['staff'];
  9347. $itemStatistics->price = $value;
  9348. $itemStatistics->itemCategory = $this->AGENCY;
  9349. $itemStatistics->date = $receiptDetail ['date'];
  9350. $itemStatistics->insert ();
  9351. } else {
  9352. if (! empty ( $value )) {
  9353. $itemStatistics->price = $value + $iStatistics ['price'];
  9354. $itemStatistics->update ( array (
  9355. 'where' => 'sid=' . $iStatistics ['sid']
  9356. ) );
  9357. }
  9358. }
  9359. } elseif ($key == "travelSum") {
  9360. $iStatistics = $itemStatistics->getOne ( array (
  9361. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9362. 'asArray' => true
  9363. ) );
  9364. if (empty ( $iStatistics )) {
  9365. $itemStatistics->cid = $receiptDetail ['cid'];
  9366. $itemStatistics->staff = $receiptDetail ['staff'];
  9367. $itemStatistics->price = $value;
  9368. $itemStatistics->itemCategory = $this->TRAVEL;
  9369. $itemStatistics->date = $receiptDetail ['date'];
  9370. $itemStatistics->insert ();
  9371. } else {
  9372. if (! empty ( $value )) {
  9373. $itemStatistics->price = $value + $iStatistics ['price'];
  9374. $itemStatistics->update ( array (
  9375. 'where' => 'sid=' . $iStatistics ['sid']
  9376. ) );
  9377. }
  9378. }
  9379. } elseif ($key == "trainSum") {
  9380. $iStatistics = $itemStatistics->getOne ( array (
  9381. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9382. 'asArray' => true
  9383. ) );
  9384. if (empty ( $iStatistics )) {
  9385. $itemStatistics->cid = $receiptDetail ['cid'];
  9386. $itemStatistics->staff = $receiptDetail ['staff'];
  9387. $itemStatistics->price = $value;
  9388. $itemStatistics->itemCategory = $this->TRAIN;
  9389. $itemStatistics->date = $receiptDetail ['date'];
  9390. $itemStatistics->insert ();
  9391. } else {
  9392. if (! empty ( $value )) {
  9393. $itemStatistics->price = $value + $iStatistics ['price'];
  9394. $itemStatistics->update ( array (
  9395. 'where' => 'sid=' . $iStatistics ['sid']
  9396. ) );
  9397. }
  9398. }
  9399. } elseif ($key == "otherSum") {
  9400. $iStatistics = $itemStatistics->getOne ( array (
  9401. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9402. 'asArray' => true
  9403. ) );
  9404. if (empty ( $iStatistics )) {
  9405. $itemStatistics->cid = $receiptDetail ['cid'];
  9406. $itemStatistics->staff = $receiptDetail ['staff'];
  9407. $itemStatistics->price = $value;
  9408. $itemStatistics->itemCategory = $this->OTHER;
  9409. $itemStatistics->date = $receiptDetail ['date'];
  9410. $itemStatistics->insert ();
  9411. } else {
  9412. if (! empty ( $value )) {
  9413. $itemStatistics->price = $value + $iStatistics ['price'];
  9414. $itemStatistics->update ( array (
  9415. 'where' => 'sid=' . $iStatistics ['sid']
  9416. ) );
  9417. }
  9418. }
  9419. }
  9420. }
  9421. $receipt->pastDate = date ( "Y-m-d" );
  9422. // 微信企业号通知
  9423. $this->setWXMsg ( $rid, 1 );
  9424. }
  9425. //是否有流水
  9426. Doo::loadModel ( 'wasteBook' );
  9427. $wasteBook = new wasteBook ();
  9428. $accountType=3;
  9429. if ($receiptDetail['Rtype']==1){
  9430. $accountType=2;
  9431. }elseif($receiptDetail['Rtype']==2){
  9432. $accountType=4;
  9433. }
  9434. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9435. if (empty($wbDetail)){
  9436. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9437. $receipt->amount = $rsum;//$amount;
  9438. }
  9439. $receipt->update ( array (
  9440. 'where' => ' rid = ' . $rid
  9441. ) );
  9442. // 进入下一条审批费用新加需求
  9443. $vidList = array ();
  9444. $verifyDetail = $verify->find ( array (
  9445. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9446. 'asArray' => true
  9447. ) );
  9448. foreach ( $verifyDetail as $key => $value ) {
  9449. array_push ( $vidList, $value ['vid'] );
  9450. }
  9451. $vid = implode ( ",", $vidList );
  9452. if (empty ( $verifyDetail ))
  9453. $vid = 0;
  9454. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9455. $receipt = new receipt ();
  9456. $rd = $receipt->getOne ( array (
  9457. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9458. 'asc' => 'rid',
  9459. 'asArray' => true
  9460. ) );
  9461. if (empty ( $rd )) {
  9462. return '/approvalExpenses/pendApproval';
  9463. }
  9464. if ($rd ['Rtype'] == 1) {
  9465. if ($rd ['isBK'] == 1) {
  9466. return '/receiptburEdi/' . $rd ['rid'];
  9467. } else {
  9468. return '/expensesEdi/' . $rd ['rid'];
  9469. }
  9470. } elseif ($rd ['Rtype'] == 2) {
  9471. return '/remitApproval/' . $rd ['rid'];
  9472. } else {
  9473. return '/receiptburEdi/' . $rd ['rid'];
  9474. }
  9475. // return "/approvalExpenses/pendApproval";
  9476. }
  9477. }
  9478. function expensesRetreats() {
  9479. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9480. if (! empty ( $rid )) {
  9481. // 操作记录
  9482. Doo::loadModel ( "receipt" );
  9483. $receipt = new receipt ();
  9484. Doo::loadModel ( "receiptLog" );
  9485. $receiptLog = new receiptLog ();
  9486. Doo::loadModel ( "verify" );
  9487. $verify = new verify ();
  9488. $receiptInfo = $receipt->getOne ( array (
  9489. 'where' => 'rid=' . $rid,
  9490. 'asArray' => true
  9491. ) );
  9492. $vr = $verify->getOne ( array (
  9493. 'where' => 'vid=' . $receiptInfo ['verify'],
  9494. 'asArray' => true
  9495. ) );
  9496. $jd = json_decode ( $vr ['staff'] );
  9497. $roleId = 0;
  9498. foreach ( $jd as $key => $value ) {
  9499. if ($value [1] == 'ROLE') {
  9500. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9501. if ($pos !== false) {
  9502. $roleId = $value [0];
  9503. }
  9504. }
  9505. }
  9506. // 审批日志
  9507. // echo $roleId;die;
  9508. if (! empty ( $roleId )) {
  9509. Doo::loadModel ( "role" );
  9510. $role = new role ();
  9511. $roleInfo = $role->getOne ( array (
  9512. 'where' => 'rid=' . $roleId,
  9513. 'asArray' => true
  9514. ) );
  9515. $receiptLog->rolename = $roleInfo ['name'];
  9516. }
  9517. $receiptLog->username = $this->staff [0] ['username'];
  9518. $receiptLog->uid = $this->staff [0] ['sid'];
  9519. $receiptLog->date = date ( "Y-m-d" );
  9520. $receiptLog->opinion = '撤回';
  9521. $receiptLog->img = $this->staff [0] ['avatar'];
  9522. $receiptLog->status = 4;
  9523. $receiptLog->rid = $rid;
  9524. $receiptLog->insert ();
  9525. $receipt->status = 4;
  9526. $receipt->update ( array (
  9527. 'where' => 'rid=' . $rid
  9528. ) );
  9529. // 微信企业号通知
  9530. $this->setWXMsg ( $rid, 2 );
  9531. }
  9532. // echo "ddd";
  9533. return '/approvalExpenses/pendApproval';
  9534. }
  9535. function updateCheReceipt() {
  9536. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9537. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9538. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9539. if (! empty ( $rid )) {
  9540. // 操作记录
  9541. Doo::loadModel ( "receipt" );
  9542. $receipt = new receipt ();
  9543. Doo::loadModel ( "receiptLog" );
  9544. $receiptLog = new receiptLog ();
  9545. Doo::loadModel ( "verify" );
  9546. $verify = new verify ();
  9547. $receiptInfo = $receipt->getOne ( array (
  9548. 'where' => 'rid=' . $rid . ' and status=2',
  9549. 'asArray' => true
  9550. ) );
  9551. if (empty ( $receiptInfo )) {
  9552. echo json_encode ( array (
  9553. 'status' => 2
  9554. ) );
  9555. die ();
  9556. }
  9557. $vr = $verify->getOne ( array (
  9558. 'where' => 'vid=' . $receiptInfo ['verify'],
  9559. 'asArray' => true
  9560. ) );
  9561. $jd = json_decode ( $vr ['staff'] );
  9562. $roleId = 0;
  9563. foreach ( $jd as $key => $value ) {
  9564. if ($value [1] == 'ROLE') {
  9565. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9566. if ($pos !== false) {
  9567. $roleId = $value [0];
  9568. }
  9569. }
  9570. }
  9571. // 审批日志
  9572. // echo $roleId;die;
  9573. if (! empty ( $roleId )) {
  9574. Doo::loadModel ( "role" );
  9575. $role = new role ();
  9576. $roleInfo = $role->getOne ( array (
  9577. 'where' => 'rid=' . $roleId,
  9578. 'asArray' => true
  9579. ) );
  9580. $receiptLog->rolename = $roleInfo ['name'];
  9581. }
  9582. $receiptLog->username = $this->staff [0] ['username'];
  9583. $receiptLog->uid = $this->staff [0] ['sid'];
  9584. $receiptLog->date = date ( "Y-m-d" );
  9585. $receiptLog->opinion = $opinion;
  9586. $receiptLog->img = $this->staff [0] ['avatar'];
  9587. $receiptLog->status = 4;
  9588. $receiptLog->rid = $rid;
  9589. $receiptLog->insert ();
  9590. $receipt->status = 4;
  9591. $receipt->update ( array (
  9592. 'where' => 'rid=' . $rid
  9593. ) );
  9594. // 微信企业号通知
  9595. $this->setWXMsg ( $rid, 2 );
  9596. echo json_encode ( array (
  9597. 'status' => 1
  9598. ) );
  9599. // Header("HTTP/1.1 303 See Other");
  9600. // Header("Location: /approvalExpenses/pendApproval");
  9601. die ();
  9602. }
  9603. echo json_encode ( array (
  9604. 'status' => 2
  9605. ) );
  9606. die ();
  9607. // echo "ddd";
  9608. // return '/saeaBorad';
  9609. }
  9610. function revisePrice() {
  9611. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9612. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9613. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9614. // echo $price;die;
  9615. if (! empty ( $rid )) {
  9616. Doo::loadModel ( "receipt" );
  9617. $receipt = new receipt ();
  9618. $receiptDetail = $receipt->getOne ( array (
  9619. 'where' => 'rid=' . $rid . ' and status=2 ',
  9620. 'asArray' => true
  9621. ) );
  9622. if (empty ( $receiptDetail ))
  9623. die ( 'illegal request' );
  9624. $reviseDetail = array ();
  9625. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9626. array_push ( $reviseDetail, array (
  9627. 'sid' => $this->staff [0] ['sid'],
  9628. 'name' => $this->staff [0] ['username'],
  9629. 'description' => $description,
  9630. 'price' => $price
  9631. ) );
  9632. $reviseDetailString = json_encode ( $reviseDetail );
  9633. $receipt->reviseDetail = $reviseDetailString;
  9634. $receipt->revisePrice = $price;
  9635. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9636. } else {
  9637. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9638. array_push ( $reviseDetail, array (
  9639. 'sid' => $this->staff [0] ['sid'],
  9640. 'name' => $this->staff [0] ['username'],
  9641. 'description' => $description,
  9642. 'price' => $price
  9643. ) );
  9644. $reviseDetailString = json_encode ( $reviseDetail );
  9645. $receipt->reviseDetail = $reviseDetailString;
  9646. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9647. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9648. }
  9649. $receipt->update ( array (
  9650. 'where' => 'rid=' . $rid
  9651. ) );
  9652. if ($receiptDetail ['Rtype'] == 1) {
  9653. if ($receiptDetail ['isBK'] == 1) {
  9654. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9655. }
  9656. } elseif ($receiptDetail ['Rtype'] == 2) {
  9657. } else {
  9658. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9659. }
  9660. }
  9661. die ( 'illegal request' );
  9662. }
  9663. function personalCollect() {
  9664. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9665. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9666. $this->showCache ( $path );
  9667. Doo::loadModel ( "receiptDetail" );
  9668. Doo::loadModel ( "itemStatistics" );
  9669. Doo::loadModel ( 'statistics' );
  9670. $statistics = new statistics ();
  9671. $itemStatistics = new itemStatistics ();
  9672. $receiptDetail = new receiptDetail ();
  9673. $receiptCollectList = $receiptDetail->find ( array (
  9674. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9675. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9676. 'groupby' => 'itemCategory,Month(date)',
  9677. 'asArray' => true
  9678. ) );
  9679. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9680. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9681. 'asArray' => true
  9682. ) );
  9683. // create collect html
  9684. $collectArray = array (
  9685. '日常相关费用' => array (),
  9686. '差旅相关费用' => array (),
  9687. '培训班费用' => array (),
  9688. '其他' => array ()
  9689. );
  9690. $adjustment = array ();
  9691. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9692. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9693. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9694. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9695. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9696. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9697. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9698. array_push ( $collectArray ['其他'], $collectHtml );
  9699. $data ['collectArray'] = $collectArray;
  9700. // statistics html
  9701. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9702. if (empty ( $stList ))
  9703. $stList = array (
  9704. 'rePrice' => 0,
  9705. 'agPrice' => 0
  9706. );
  9707. $data ['stList'] = array (
  9708. 'rePrice' => $stList ['rePrice'],
  9709. 'agPrice' => $stList ['agPrice'],
  9710. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9711. );
  9712. // Adjustment price html
  9713. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9714. array_push ( $adjustment, $collectHtml );
  9715. $data ['adjustment'] = $adjustment;
  9716. // total price html
  9717. $collectHtml = "";
  9718. $total = 0;
  9719. for($i = 1; $i <= 12; $i ++) {
  9720. $sumPrice = 0;
  9721. foreach ( $receiptCollectList as $key => $value ) {
  9722. if ($value ['month'] == $i) {
  9723. $sumPrice += $value ['price'];
  9724. }
  9725. }
  9726. if ($sumPrice == 0)
  9727. $collectHtml .= '<td class="taR">-</td>';
  9728. else
  9729. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9730. $total += $sumPrice;
  9731. }
  9732. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9733. $data ['totalPrice'] = $collectHtml;
  9734. $dateHtml = "";
  9735. $now = date ( "Y" );
  9736. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9737. if ($YEARD <= $now) {
  9738. $dateHtml .= '<option ';
  9739. if ($year == $YEARD) {
  9740. $dateHtml .= 'selected ';
  9741. }
  9742. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9743. }
  9744. }
  9745. $data ['dateHtml'] = $dateHtml;
  9746. $data ['year'] = $year;
  9747. $data ['totalYear'] = $total;
  9748. $data ['memu'] = "receipt";
  9749. $data ['staff'] = $this->staff;
  9750. $data ['receiptMemu'] = 'personalCollect';
  9751. $data ['verifyId'] = $this->verifyId;
  9752. $data ['executeId'] = $this->executeId;
  9753. // year staff status 2,4
  9754. if ($year < date ( "Y" )) {
  9755. Doo::loadModel ( 'receipt' );
  9756. $receipt = new receipt ();
  9757. $receiptList = $receipt->find ( array (
  9758. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9759. 'asArray' => true
  9760. ) );
  9761. if (empty ( $receiptList )) {
  9762. ob_start ();
  9763. $this->render ( "/admin/saea_slist_collect", $data );
  9764. $this->cacheFile ( $path );
  9765. die ();
  9766. }
  9767. }
  9768. $this->render ( "/admin/saea_slist_collect", $data );
  9769. }
  9770. function personalCollectDetail() {
  9771. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9772. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9773. $this->showCache ( $path );
  9774. Doo::loadModel ( "receiptDetail" );
  9775. Doo::loadModel ( "itemStatistics" );
  9776. Doo::loadModel ( 'statistics' );
  9777. Doo::loadModel ( 'accountItem' );
  9778. $accountItem = new accountItem ();
  9779. $statistics = new statistics ();
  9780. $itemStatistics = new itemStatistics ();
  9781. $receiptDetail = new receiptDetail ();
  9782. $receiptCollectList = $receiptDetail->find ( array (
  9783. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9784. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9785. 'groupby' => 'item,Month(date)',
  9786. 'asArray' => true
  9787. ) );
  9788. $accountList = $accountItem->find ( array (
  9789. 'asArray' => true
  9790. ) );
  9791. // create CollectDetail HTML
  9792. $collectHtml = array ();
  9793. foreach ( $accountList as $key => $value ) {
  9794. $html = "";
  9795. $asum = 0;
  9796. for($i = 1; $i <= 12; $i ++) {
  9797. $falg = true;
  9798. foreach ( $receiptCollectList as $v ) {
  9799. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9800. $asum += $v ['price'];
  9801. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9802. $falg = false;
  9803. break;
  9804. }
  9805. }
  9806. if ($falg)
  9807. $html .= '<td class="taR">-</td>';
  9808. }
  9809. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9810. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9811. }
  9812. $data ['collectHtml'] = $collectHtml;
  9813. // create Adjustment price html
  9814. $receiptCollectList = $receiptDetail->find ( array (
  9815. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9816. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9817. 'groupby' => 'itemCategory,Month(date)',
  9818. 'asArray' => true
  9819. ) );
  9820. $adjustment = array ();
  9821. $collectArray = array (
  9822. '日常相关费用' => array (),
  9823. '差旅相关费用' => array (),
  9824. '培训班费用' => array (),
  9825. '其他' => array ()
  9826. );
  9827. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9828. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9829. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9830. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9831. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9832. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9833. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9834. array_push ( $collectArray ['其他'], $collectHtml );
  9835. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9836. array_push ( $adjustment, $collectHtml );
  9837. // total price html
  9838. $collectHtml = "";
  9839. $total = 0;
  9840. for($i = 1; $i <= 12; $i ++) {
  9841. $sumPrice = 0;
  9842. foreach ( $receiptCollectList as $key => $value ) {
  9843. if ($value ['month'] == $i) {
  9844. $sumPrice += $value ['price'];
  9845. }
  9846. }
  9847. if ($sumPrice == 0)
  9848. $collectHtml .= '<td class="taR">-</td>';
  9849. else
  9850. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9851. $total += $sumPrice;
  9852. }
  9853. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9854. // statistics html
  9855. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9856. if (empty ( $stList ))
  9857. $stList = array (
  9858. 'rePrice' => 0,
  9859. 'agPrice' => 0
  9860. );
  9861. $data ['stList'] = array (
  9862. 'rePrice' => $stList ['rePrice'],
  9863. 'agPrice' => $stList ['agPrice'],
  9864. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9865. );
  9866. $data ['collectArray'] = $collectArray;
  9867. $data ['adjustment'] = $adjustment;
  9868. $data ['totalPrice'] = $collectHtml;
  9869. $data ['totalYear'] = $total;
  9870. $data ['year'] = $year;
  9871. $dateHtml = "";
  9872. $now = date ( "Y" );
  9873. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9874. if ($YEARD <= $now) {
  9875. $dateHtml .= '<option ';
  9876. if ($year == $YEARD) {
  9877. $dateHtml .= 'selected ';
  9878. }
  9879. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9880. }
  9881. }
  9882. $data ['dateHtml'] = $dateHtml;
  9883. $data ['memu'] = "receipt";
  9884. $data ['staff'] = $this->staff;
  9885. $data ['receiptMemu'] = 'personalCollect';
  9886. $data ['verifyId'] = $this->verifyId;
  9887. $data ['executeId'] = $this->executeId;
  9888. // year staff status 2,4
  9889. if ($year < date ( "Y" )) {
  9890. Doo::loadModel ( 'receipt' );
  9891. $receipt = new receipt ();
  9892. $receiptList = $receipt->find ( array (
  9893. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9894. 'asArray' => true
  9895. ) );
  9896. if (empty ( $receiptList )) {
  9897. ob_start ();
  9898. $this->render ( "/admin/saeaCollectArticles", $data );
  9899. $this->cacheFile ( $path );
  9900. die ();
  9901. }
  9902. }
  9903. $this->render ( "/admin/saeaCollectArticles", $data );
  9904. }
  9905. function companyCategoryCollect() {
  9906. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9907. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9908. $this->showCache ( $path );
  9909. Doo::loadModel ( 'L_category' );
  9910. Doo::loadModel ( 'itemStatistics' );
  9911. Doo::loadModel ( 'statistics' );
  9912. $statistics = new statistics ();
  9913. $Lcategory = new L_category ();
  9914. $itemStatistics = new itemStatistics ();
  9915. Doo::loadModel ( "receiptAuthorityManage" );
  9916. $receiptAuthorityManage = new receiptAuthorityManage ();
  9917. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9918. $cidList = array ();
  9919. foreach ( $imcStaff as $key => $value ) {
  9920. array_push ( $cidList, $value ['cid'] );
  9921. }
  9922. $cidString = implode ( ',', $cidList );
  9923. $LcategoryList = $Lcategory->find ( array (
  9924. 'where' => ' cid in (' . $cidString . ')',
  9925. 'asArray' => true
  9926. ) ); // 'staff='.$this->staff[0]['sid']." and
  9927. $itemStatisticsList = $itemStatistics->find ( array (
  9928. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9929. 'where' => " Year(date)=" . $year,
  9930. 'groupby' => 'cid,Month(date)',
  9931. 'asArray' => true
  9932. ) );
  9933. // ceatre companyCollectHtml
  9934. foreach ( $LcategoryList as $value ) {
  9935. $html = "";
  9936. $asum = 0;
  9937. for($i = 1; $i <= 12; $i ++) {
  9938. $falg = true;
  9939. foreach ( $itemStatisticsList as $v ) {
  9940. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9941. $asum += $v ['price'];
  9942. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9943. $falg = false;
  9944. break;
  9945. }
  9946. }
  9947. if ($falg)
  9948. $html .= '<td class="taR">-</td>';
  9949. }
  9950. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9951. $collectHtml [$value ['title']] = array (
  9952. 'html' => $html,
  9953. 'cid' => $value ['cid']
  9954. );
  9955. }
  9956. $data ['companyHtml'] = $collectHtml;
  9957. // total price html
  9958. $collectHtml = "";
  9959. $total = 0;
  9960. for($i = 1; $i <= 12; $i ++) {
  9961. $sumPrice = 0;
  9962. foreach ( $itemStatisticsList as $key => $value ) {
  9963. if ($value ['month'] == $i) {
  9964. $sumPrice += $value ['price'];
  9965. }
  9966. }
  9967. if ($sumPrice == 0)
  9968. $collectHtml .= '<td class="taR">-</td>';
  9969. else
  9970. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9971. $total += $sumPrice;
  9972. }
  9973. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9974. $data ['companyTotalHtml'] = $collectHtml;
  9975. $data ['total'] = $total;
  9976. // statistics html
  9977. // echo $cidString;
  9978. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9979. if (empty ( $stList ))
  9980. $stList = array (
  9981. 'rePrice' => 0,
  9982. 'agPrice' => 0
  9983. );
  9984. $data ['stList'] = array (
  9985. 'rePrice' => $stList ['rePrice'],
  9986. 'agPrice' => $stList ['agPrice'],
  9987. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9988. );
  9989. $data ['year'] = $year;
  9990. $data ['memu'] = "receipt";
  9991. $data ['staff'] = $this->staff;
  9992. $data ['receiptMemu'] = 'companyCategoryCollect';
  9993. $data ['verifyId'] = $this->verifyId;
  9994. $data ['executeId'] = $this->executeId;
  9995. $dateHtml = "";
  9996. $now = date ( "Y" );
  9997. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9998. if ($YEARD <= $now) {
  9999. $dateHtml .= '<option ';
  10000. if ($year == $YEARD) {
  10001. $dateHtml .= 'selected ';
  10002. }
  10003. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10004. }
  10005. }
  10006. $data ['dateHtml'] = $dateHtml;
  10007. // year staff status 2,4
  10008. if ($year < date ( "Y" )) {
  10009. Doo::loadModel ( 'receipt' );
  10010. $receipt = new receipt ();
  10011. $receiptList = $receipt->find ( array (
  10012. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10013. 'asArray' => true
  10014. ) );
  10015. if (empty ( $receiptList )) {
  10016. ob_start ();
  10017. $this->render ( "/admin/saeaCompanyCollect", $data );
  10018. $this->cacheFile ( $path );
  10019. die ();
  10020. }
  10021. }
  10022. $this->render ( "/admin/saeaCompanyCollect", $data );
  10023. }
  10024. function categoryCollectDetail() {
  10025. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10026. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10027. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10028. $this->showCache ( $path ); */
  10029. Doo::loadModel ( 'statistics' );
  10030. $statistics = new statistics ();
  10031. Doo::loadModel ( "receiptDetail" );
  10032. $receiptDetail = new receiptDetail ();
  10033. Doo::loadModel ( 'L_category' );
  10034. $Lcategory = new L_category ();
  10035. Doo::loadModel ( 'accountItem' );
  10036. $accountItem = new accountItem ();
  10037. Doo::loadModel ( "receiptAuthorityManage" );
  10038. $receiptAuthorityManage = new receiptAuthorityManage ();
  10039. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10040. $cidList = array ();
  10041. foreach ( $imcStaff as $key => $value ) {
  10042. array_push ( $cidList, $value ['cid'] );
  10043. }
  10044. $cidString = implode ( ',', $cidList );
  10045. $LcategoryList = $Lcategory->find ( array (
  10046. 'where' => 'cid in (' . $cidString . ')',
  10047. 'asArray' => true
  10048. ) );
  10049. if ($cid == 0) {
  10050. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10051. if ($cid == 0)
  10052. $cid = $LcategoryList [0] ['cid'];
  10053. }
  10054. $data ['LcategoryList'] = $LcategoryList;
  10055. $receiptCollectList = $receiptDetail->find ( array (
  10056. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10057. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10058. 'groupby' => 'item,Month(pastDate)',
  10059. 'asArray' => true
  10060. ) );
  10061. $accountList = $accountItem->find ( array (
  10062. 'asArray' => true
  10063. ) );
  10064. // create CollectDetail HTML
  10065. $collectHtml = array ();
  10066. foreach ( $accountList as $key => $value ) {
  10067. $html = "";
  10068. $asum = 0;
  10069. for($i = 1; $i <= 12; $i ++) {
  10070. $falg = true;
  10071. foreach ( $receiptCollectList as $v ) {
  10072. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10073. $asum += $v ['price'];
  10074. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10075. $falg = false;
  10076. break;
  10077. }
  10078. }
  10079. if ($falg)
  10080. $html .= '<td class="taR">-</td>';
  10081. }
  10082. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10083. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10084. }
  10085. $data ['collectHtml'] = $collectHtml;
  10086. // create Adjustment price html
  10087. $receiptCollectList = $receiptDetail->find ( array (
  10088. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10089. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10090. 'groupby' => 'itemCategory,Month(pastDate)',
  10091. 'asArray' => true
  10092. ) );
  10093. $adjustment = array ();
  10094. $collectArray = array (
  10095. '日常相关费用' => array (),
  10096. '差旅相关费用' => array (),
  10097. '培训班费用' => array (),
  10098. '内部培训费用'=>array(),
  10099. '其他' => array ()
  10100. );
  10101. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10102. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10103. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10104. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10105. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10106. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10107. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10108. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10109. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10110. array_push ( $collectArray ['其他'], $collectHtml );
  10111. $data ['collectArray'] = $collectArray;
  10112. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10113. array_push ( $adjustment, $collectHtml );
  10114. $data ['adjustment'] = $adjustment;
  10115. // total price html
  10116. $collectHtml = "";
  10117. $total = 0;
  10118. for($i = 1; $i <= 12; $i ++) {
  10119. $sumPrice = 0;
  10120. foreach ( $receiptCollectList as $key => $value ) {
  10121. if ($value ['month'] == $i) {
  10122. $sumPrice += $value ['price'];
  10123. }
  10124. }
  10125. if ($sumPrice == 0)
  10126. $collectHtml .= '<td class="taR">-</td>';
  10127. else
  10128. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10129. $total += $sumPrice;
  10130. }
  10131. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10132. // statistics html
  10133. $stList = $statistics->statisticsByCid ( $year, $cid );
  10134. if (empty ( $stList ))
  10135. $stList = array (
  10136. 'rePrice' => 0,
  10137. 'agPrice' => 0
  10138. );
  10139. $data ['stList'] = array (
  10140. 'rePrice' => $stList ['rePrice'],
  10141. 'agPrice' => $stList ['agPrice'],
  10142. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10143. );
  10144. $data ['totalYear'] = $total;
  10145. $data ['year'] = $year;
  10146. $data ['cid'] = $cid;
  10147. $data ['memu'] = "receipt";
  10148. $data ['staff'] = $this->staff;
  10149. $data ['receiptMemu'] = 'companyCategoryCollect';
  10150. $data ['verifyId'] = $this->verifyId;
  10151. $data ['executeId'] = $this->executeId;
  10152. // year staff status 2,4
  10153. /* if ($year < date ( "Y" )) {
  10154. Doo::loadModel ( 'receipt' );
  10155. $receipt = new receipt ();
  10156. $receiptList = $receipt->find ( array (
  10157. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10158. 'asArray' => true
  10159. ) );
  10160. if (empty ( $receiptList )) {
  10161. ob_start ();
  10162. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10163. $this->cacheFile ( $path );
  10164. die ();
  10165. }
  10166. } */
  10167. $dateHtml = "";
  10168. $now = date ( "Y" );
  10169. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10170. if ($YEARD <= $now) {
  10171. $dateHtml .= '<option ';
  10172. if ($year == $YEARD) {
  10173. $dateHtml .= 'selected ';
  10174. }
  10175. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10176. }
  10177. }
  10178. $data ['dateHtml'] = $dateHtml;
  10179. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10180. }
  10181. function staffCollect() {
  10182. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10183. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10184. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10185. // $this->showCache($path);
  10186. Doo::loadModel ( 'statistics' );
  10187. $statistics = new statistics ();
  10188. Doo::loadModel ( "receiptDetail" );
  10189. $receiptDetail = new receiptDetail ();
  10190. Doo::loadModel ( 'L_category' );
  10191. $Lcategory = new L_category ();
  10192. Doo::loadModel ( 'accountItem' );
  10193. $accountItem = new accountItem ();
  10194. Doo::loadModel ( 'staff' );
  10195. $staff = new staff ();
  10196. Doo::loadModel ( 'itemStatistics' );
  10197. $itemStatistics = new itemStatistics ();
  10198. Doo::loadModel ( "receiptAuthorityManage" );
  10199. $receiptAuthorityManage = new receiptAuthorityManage ();
  10200. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10201. $cidList = array ();
  10202. foreach ( $imcStaff as $key => $value ) {
  10203. array_push ( $cidList, $value ['cid'] );
  10204. }
  10205. $cidString = implode ( ',', $cidList );
  10206. $naturecon='';
  10207. if ($nature=='ONJOB'){
  10208. $naturecon=' and (nature!=4 )';
  10209. }elseif($nature=='LEAVEJOB'){
  10210. $naturecon=' and (nature=4 )';
  10211. }else{
  10212. die ( 'illegal request--nature' );
  10213. }
  10214. // statistics html
  10215. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10216. if (empty ( $stList ))
  10217. $stList = array (
  10218. 'rePrice' => 0,
  10219. 'agPrice' => 0
  10220. );
  10221. $data ['stList'] = array (
  10222. 'rePrice' => $stList ['rePrice'],
  10223. 'agPrice' => $stList ['agPrice'],
  10224. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10225. );
  10226. // ---
  10227. $staffList = $staff->find ( array (
  10228. 'where' => 'username !="admin" '.$naturecon,
  10229. 'asArray' => true
  10230. ) );
  10231. $LcategoryList = $Lcategory->find ( array (
  10232. 'asArray' => true
  10233. ) ); // 'staff='.$this->staff[0]['sid']." and
  10234. $itemStatisticsList = $itemStatistics->find ( array (
  10235. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10236. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10237. 'groupby' => 'staff,Month(date)',
  10238. 'asArray' => true
  10239. ) );
  10240. $categoryList = $staff->find ( array (
  10241. 'select' => 'COUNT(*) as count,cid,category',
  10242. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10243. 'groupby' => 'cid',
  10244. 'asArray' => true
  10245. ) );
  10246. // print_r($itemStatisticsList);die;
  10247. // ceatre companyCollectHtml
  10248. foreach ( $categoryList as $vlu ) {
  10249. $count = $vlu ['count'] + 1;
  10250. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10251. $m1 = 0;
  10252. $m2 = 0;
  10253. $m3 = 0;
  10254. $m4 = 0;
  10255. $m5 = 0;
  10256. $m6 = 0;
  10257. $m7 = 0;
  10258. $m8 = 0;
  10259. $m9 = 0;
  10260. $m10 = 0;
  10261. $m11 = 0;
  10262. $m12 = 0;
  10263. $m13 = 0;
  10264. foreach ( $staffList as $value ) {
  10265. if ($vlu ['cid'] == $value ['cid']) {
  10266. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10267. $asum = 0;
  10268. for($i = 1; $i <= 12; $i ++) {
  10269. $falg = true;
  10270. foreach ( $itemStatisticsList as $v ) {
  10271. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10272. if ($v ['month'] == 1)
  10273. $m1 += $v ['price'];
  10274. if ($v ['month'] == 2)
  10275. $m2 += $v ['price'];
  10276. if ($v ['month'] == 3)
  10277. $m3 += $v ['price'];
  10278. if ($v ['month'] == 4)
  10279. $m4 += $v ['price'];
  10280. if ($v ['month'] == 5)
  10281. $m5 += $v ['price'];
  10282. if ($v ['month'] == 6)
  10283. $m6 += $v ['price'];
  10284. if ($v ['month'] == 7)
  10285. $m7 += $v ['price'];
  10286. if ($v ['month'] == 8)
  10287. $m8 += $v ['price'];
  10288. if ($v ['month'] == 9)
  10289. $m9 += $v ['price'];
  10290. if ($v ['month'] == 10)
  10291. $m10 += $v ['price'];
  10292. if ($v ['month'] == 11)
  10293. $m11 += $v ['price'];
  10294. if ($v ['month'] == 12)
  10295. $m12 += $v ['price'];
  10296. $asum += $v ['price'];
  10297. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10298. $falg = false;
  10299. break;
  10300. }
  10301. }
  10302. if ($falg)
  10303. $html .= '<td class="taR">-</td>';
  10304. }
  10305. $m13 += $asum;
  10306. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10307. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10308. 'html' => $html,
  10309. 'sid' => $value ['sid']
  10310. );
  10311. $html = "";
  10312. }
  10313. }
  10314. $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>
  10315. <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>
  10316. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10317. $collectHtml [$vlu ['cid']] = array (
  10318. 'html' => $hl,
  10319. 'sid' => ''
  10320. );
  10321. }
  10322. $data ['companyHtml'] = $collectHtml;
  10323. // total price html
  10324. $collectHtml = "";
  10325. $total = 0;
  10326. for($i = 1; $i <= 12; $i ++) {
  10327. $sumPrice = 0;
  10328. foreach ( $itemStatisticsList as $key => $value ) {
  10329. if ($value ['month'] == $i) {
  10330. $sumPrice += $value ['price'];
  10331. }
  10332. }
  10333. if ($sumPrice == 0)
  10334. $collectHtml .= '<td class="taR">-</td>';
  10335. else
  10336. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10337. $total += $sumPrice;
  10338. }
  10339. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10340. $data ['companyTotalHtml'] = $collectHtml;
  10341. $data ['total'] = $total;
  10342. $data ['nature'] =$nature;
  10343. $data ['year'] = $year;
  10344. $data ['memu'] = "receipt";
  10345. $data ['staff'] = $this->staff;
  10346. $data ['receiptMemu'] = 'companyCategoryCollect';
  10347. $data ['verifyId'] = $this->verifyId;
  10348. $data ['executeId'] = $this->executeId;
  10349. if ($year <= date ( "Y" )) {
  10350. Doo::loadModel ( 'receipt' );
  10351. $receipt = new receipt ();
  10352. $receiptList = $receipt->find ( array (
  10353. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10354. 'asArray' => true
  10355. ) );
  10356. if (empty ( $receiptList )) { // generated files
  10357. ob_start ();
  10358. $this->render ( "/admin/saeaStaffCollectB", $data );
  10359. $this->cacheFile ( $path );
  10360. die ();
  10361. }
  10362. }
  10363. $this->render ( "/admin/saeaStaffCollectB", $data );
  10364. }
  10365. function staffCollectBak() {
  10366. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10367. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10368. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10369. $this->showCache ( $path );
  10370. Doo::loadModel ( 'statistics' );
  10371. $statistics = new statistics ();
  10372. Doo::loadModel ( "receiptDetail" );
  10373. $receiptDetail = new receiptDetail ();
  10374. Doo::loadModel ( 'L_category' );
  10375. $Lcategory = new L_category ();
  10376. Doo::loadModel ( 'accountItem' );
  10377. $accountItem = new accountItem ();
  10378. Doo::loadModel ( 'staff' );
  10379. $staff = new staff ();
  10380. Doo::loadModel ( 'itemStatistics' );
  10381. $itemStatistics = new itemStatistics ();
  10382. $itemStatisticsList = $itemStatistics->find ( array (
  10383. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10384. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10385. 'groupby' => 'staff,itemCategory,Month(date)',
  10386. 'asArray' => true
  10387. ) );
  10388. $itemCategoryList = $itemStatistics->find ( array (
  10389. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10390. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10391. 'groupby' => 'cid,itemCategory,Month(date)',
  10392. 'asArray' => true
  10393. ) );
  10394. $LcategoryList = $Lcategory->find ( array (
  10395. 'asArray' => true
  10396. ) );
  10397. $staffList = $staff->find ( array (
  10398. 'asArray' => true
  10399. ) );
  10400. $htmlArray = array ();
  10401. foreach ( $LcategoryList as $value ) {
  10402. $htmlArray [$value ['title']] = array ();
  10403. foreach ( $staffList as $v ) {
  10404. if ($value ['cid'] == $v ['cid']) {
  10405. $html = "";
  10406. $falg = true;
  10407. $staffSumPrice = 0;
  10408. foreach ( $itemStatisticsList as $a ) {
  10409. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10410. if (empty ( $a ['price'] )) {
  10411. $html .= '<td class="taR">-</td>';
  10412. $falg = false;
  10413. break;
  10414. } else {
  10415. $staffSumPrice += $a ['price'];
  10416. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10417. $falg = false;
  10418. break;
  10419. }
  10420. }
  10421. }
  10422. if ($falg) {
  10423. $html .= '<td class="taR">-</td>';
  10424. $falg = true;
  10425. }
  10426. $falg = true;
  10427. foreach ( $itemStatisticsList as $a ) {
  10428. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10429. if (empty ( $a ['price'] )) {
  10430. $html .= '<td class="taR">-</td>';
  10431. $falg = false;
  10432. break;
  10433. } else {
  10434. $staffSumPrice += $a ['price'];
  10435. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10436. $falg = false;
  10437. break;
  10438. }
  10439. }
  10440. }
  10441. if ($falg) {
  10442. $html .= '<td class="taR">-</td>';
  10443. $falg = true;
  10444. }
  10445. $falg = true;
  10446. foreach ( $itemStatisticsList as $a ) {
  10447. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10448. if (empty ( $a ['price'] )) {
  10449. $html .= '<td class="taR">-</td>';
  10450. $falg = false;
  10451. break;
  10452. } else {
  10453. $staffSumPrice += $a ['price'];
  10454. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10455. $falg = false;
  10456. break;
  10457. }
  10458. }
  10459. }
  10460. if ($falg) {
  10461. $html .= '<td class="taR">-</td>';
  10462. $falg = true;
  10463. }
  10464. $falg = true;
  10465. foreach ( $itemStatisticsList as $a ) {
  10466. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10467. if (! empty ( $a ['price'] )) {
  10468. $staffSumPrice += $a ['price'];
  10469. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10470. $falg = false;
  10471. break;
  10472. } else {
  10473. $html .= '<td class="taR">-</td>';
  10474. $falg = false;
  10475. break;
  10476. }
  10477. }
  10478. }
  10479. if ($falg) {
  10480. $html .= '<td class="taR">-</td>';
  10481. $falg = true;
  10482. }
  10483. $falg = true;
  10484. foreach ( $itemStatisticsList as $a ) {
  10485. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10486. if (! empty ( $a ['price'] )) {
  10487. $staffSumPrice += $a ['price'];
  10488. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10489. $falg = false;
  10490. break;
  10491. } else {
  10492. $html .= '<td class="taR">-</td>';
  10493. $falg = false;
  10494. break;
  10495. }
  10496. }
  10497. }
  10498. if ($falg) {
  10499. $html .= '<td class="taR">-</td>';
  10500. $falg = true;
  10501. }
  10502. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10503. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10504. }
  10505. }
  10506. /* -- --- */
  10507. // 合计费用
  10508. $cateHtml = "";
  10509. $catePrice = 0;
  10510. $cateFalg = true;
  10511. foreach ( $itemCategoryList as $l ) {
  10512. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10513. if (empty ( $l ['price'] )) {
  10514. $cateHtml .= '<td class="colGreen taR">-</td>';
  10515. $cateFalg = false;
  10516. break;
  10517. } else {
  10518. $catePrice += $l ['price'];
  10519. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10520. $cateFalg = false;
  10521. break;
  10522. }
  10523. }
  10524. }
  10525. if ($cateFalg) {
  10526. $cateHtml .= '<td class="colGreen taR">-</td>';
  10527. $cateFalg = true;
  10528. }
  10529. $cateFalg = true;
  10530. foreach ( $itemCategoryList as $l ) {
  10531. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10532. if (empty ( $l ['price'] )) {
  10533. $cateHtml .= '<td class="colGreen taR">-</td>';
  10534. $cateFalg = false;
  10535. break;
  10536. } else {
  10537. $catePrice += $l ['price'];
  10538. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10539. $cateFalg = false;
  10540. break;
  10541. }
  10542. }
  10543. }
  10544. if ($cateFalg) {
  10545. $cateHtml .= '<td class="colGreen taR">-</td>';
  10546. $cateFalg = true;
  10547. }
  10548. $cateFalg = true;
  10549. foreach ( $itemCategoryList as $l ) {
  10550. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10551. if (empty ( $l ['price'] )) {
  10552. $cateHtml .= '<td class="colGreen taR">-</td>';
  10553. $cateFalg = false;
  10554. break;
  10555. } else {
  10556. $catePrice += $l ['price'];
  10557. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10558. $cateFalg = false;
  10559. break;
  10560. }
  10561. }
  10562. }
  10563. if ($cateFalg) {
  10564. $cateHtml .= '<td class="colGreen taR">-</td>';
  10565. $cateFalg = true;
  10566. }
  10567. $cateFalg = true;
  10568. foreach ( $itemCategoryList as $l ) {
  10569. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10570. if (empty ( $l ['price'] )) {
  10571. $cateHtml .= '<td class="colGreen taR">-</td>';
  10572. $cateFalg = false;
  10573. break;
  10574. } else {
  10575. $catePrice += $l ['price'];
  10576. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10577. $cateFalg = false;
  10578. break;
  10579. }
  10580. }
  10581. }
  10582. if ($cateFalg) {
  10583. $cateHtml .= '<td class="colGreen taR">-</td>';
  10584. $cateFalg = true;
  10585. }
  10586. $cateFalg = true;
  10587. foreach ( $itemCategoryList as $l ) {
  10588. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10589. if (empty ( $l ['price'] )) {
  10590. $cateHtml .= '<td class="colGreen taR">-</td>';
  10591. $cateFalg = false;
  10592. break;
  10593. } else {
  10594. $catePrice += $l ['price'];
  10595. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10596. $cateFalg = false;
  10597. break;
  10598. }
  10599. }
  10600. }
  10601. if ($cateFalg) {
  10602. $cateHtml .= '<td class="colGreen taR">-</td>';
  10603. $cateFalg = true;
  10604. }
  10605. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10606. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10607. /* -- --- */
  10608. }
  10609. // print_r($htmlArray);die;
  10610. $data ['htmlArray'] = $htmlArray;
  10611. // statistics html
  10612. $stList = $statistics->getOne ( array (
  10613. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10614. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10615. 'groupby' => 'Month(date)',
  10616. 'asArray' => true
  10617. ) );
  10618. if (empty ( $stList ))
  10619. $stList = array (
  10620. 'rePrice' => 0,
  10621. 'agPrice' => 0
  10622. );
  10623. $data ['stList'] = array (
  10624. 'rePrice' => $stList ['rePrice'],
  10625. 'agPrice' => $stList ['agPrice'],
  10626. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10627. );
  10628. $monthHtml = "";
  10629. for($i = 1; $i <= 12; $i ++) {
  10630. if ($i == $month)
  10631. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10632. else
  10633. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10634. }
  10635. $data ['monthHtml'] = $monthHtml;
  10636. $data ['year'] = $year;
  10637. $data ['month'] = $month;
  10638. $data ['memu'] = "receipt";
  10639. $data ['staff'] = $this->staff;
  10640. $data ['receiptMemu'] = 'companyCategoryCollect';
  10641. $data ['verifyId'] = $this->verifyId;
  10642. $data ['executeId'] = $this->executeId;
  10643. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10644. Doo::loadModel ( 'receipt' );
  10645. $receipt = new receipt ();
  10646. $receiptList = $receipt->find ( array (
  10647. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10648. 'asArray' => true
  10649. ) );
  10650. if (empty ( $receiptList )) { // generated files
  10651. ob_start ();
  10652. $this->render ( "/admin/saeaStaffCollect", $data );
  10653. $this->cacheFile ( $path );
  10654. die ();
  10655. }
  10656. }
  10657. $this->render ( "/admin/saeaStaffCollect", $data );
  10658. }
  10659. /**
  10660. * 日常收支
  10661. */
  10662. function payments() {
  10663. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10664. Doo::loadModel ( "execute" );
  10665. $execute = new execute ();
  10666. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10667. die ( 'illegal request' );
  10668. }
  10669. Doo::loadModel ( "accountBook" );
  10670. $accountBook = new accountBook ();
  10671. Doo::loadModel ( "accountBookStatistics" );
  10672. $accountBookStatistics = new accountBookStatistics ();
  10673. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10674. $list = $accountBook->getAccountBookByLimit ( 10 );
  10675. $data ['date'] = date ( "Y-m-d" );
  10676. $data ['statisticsList'] = $statisticsList;
  10677. $data ['list'] = $list;
  10678. $data ['memu'] = "receipt";
  10679. $data ['staff'] = $this->staff;
  10680. $data ['receiptMemu'] = 'payments';
  10681. $data ['verifyId'] = $this->verifyId;
  10682. $data ['executeId'] = $this->executeId;
  10683. $this->render ( "/expenses/payments", $data );
  10684. }
  10685. function paymentsIncomeDo() {
  10686. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10687. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10688. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10689. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10690. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10691. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10692. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10693. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10694. Doo::loadClass ( 'XDeode' );
  10695. $XDeode = new XDeode ( 5 );
  10696. Doo::loadModel ( "accountBook" );
  10697. Doo::loadModel ( "accountBookStatistics" );
  10698. Doo::loadModel ( 'wasteBook' );
  10699. // 记录流水时银行的转换
  10700. $accountBank = '';
  10701. if ($receivedBank == '纵横广发') {
  10702. $accountBank = 'CGBDeposit';
  10703. } elseif ($receivedBank == '纵横工行') {
  10704. $accountBank = 'ICBCDeposit';
  10705. } elseif ($receivedBank == '华润银行') {
  10706. $accountBank = 'HUADeposit';
  10707. } elseif ($receivedBank == '个人广发') {
  10708. $accountBank = 'PersonalDeposit';
  10709. }
  10710. if (empty ( $accountBank ))
  10711. die ( 'illegal request-bank' );
  10712. //TODO -存款功能 提取
  10713. if($accountType == 11 || $accountType == 12){
  10714. if($accountType == 11){
  10715. $receivedBank = '纵横广发';
  10716. }elseif($accountType == 12){
  10717. $receivedBank = '纵横工行';
  10718. }
  10719. // 添加一条收入
  10720. $accountBook = new accountBook ();
  10721. $accountBook->accountType = $accountType;
  10722. $accountBook->accountMsg = $accountMsg;
  10723. $accountBook->receivedPrice = $receivedPrice;
  10724. $accountBook->receivedMsg = $receivedMsg;
  10725. $accountBook->receivedBank = $receivedBank;
  10726. $accountBook->receivedDate = $receivedDate;
  10727. $accountBook->remarks = $remarks;
  10728. $accountBook->expensesType = 1;
  10729. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10730. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10731. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10732. $inComeId = $accountBook->insert ();
  10733. // 收支汇总-添加一条收入日常汇总
  10734. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10735. $accountBookStatistics = new accountBookStatistics ();
  10736. $item = array (
  10737. 'date' => date ( "Y-m-d" ),
  10738. 'accountType' => $abDetail ['accountType'],
  10739. 'accountMsg' => $abDetail ['accountMsg'],
  10740. 'aid' => $abDetail ['aid'],
  10741. 'inComePrice' => $abDetail ['receivedPrice'],
  10742. 'expensesType' => $abDetail ['expensesType']
  10743. );
  10744. $accountBookStatistics->setAccountBookStatistics ( $item );
  10745. // 添加收入流水
  10746. if($accountType == 11){
  10747. $accountBank = 'CGBDeposit';
  10748. }elseif($accountType == 12){
  10749. $accountBank = 'ICBCDeposit';
  10750. }
  10751. $wasteBook = new wasteBook ();
  10752. $itemWaste = array (
  10753. 'accountPriceShow' => $receivedPrice,
  10754. 'accountPrice' => $receivedPrice,
  10755. 'expensesType' => 1,
  10756. 'accountType' => 6, // 流水类型
  10757. 'dataID' => $inComeId,
  10758. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10759. 'accountBank' => $accountBank,
  10760. 'category' => $this->staff [0] ['category'],
  10761. 'cid' => $this->staff [0] ['cid'],
  10762. 'name' => $this->staff [0] ['username'],
  10763. 'sid' => $this->staff [0] ['sid'],
  10764. 'inputDate' => $receivedDate,
  10765. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10766. 'synPaymentDate'=>1,
  10767. );
  10768. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10769. }
  10770. //TODO --移除理财相关
  10771. // elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10772. // // if ($receivedBank == '个人广发') {
  10773. // // die ( '个人广发 illegal request' );
  10774. // // }
  10775. // // echo $receivedBank;
  10776. // die;
  10777. // // 添加一条收入
  10778. // $accountBook = new accountBook ();
  10779. // $accountBook->accountType = 10;
  10780. // $accountBook->accountMsg = $accountMsg;
  10781. // $accountBook->receivedPrice = $receivedPrice;
  10782. // $accountBook->receivedMsg = $receivedMsg;
  10783. // $accountBook->receivedBank = $receivedBank;
  10784. // $accountBook->receivedDate = $receivedDate;
  10785. // $accountBook->remarks = $remarks;
  10786. // $accountBook->expensesType = 1;
  10787. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10788. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10789. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10790. // $inComeId = $accountBook->insert ();
  10791. // // 收支汇总-添加一条收入日常汇总
  10792. // $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10793. // $accountBookStatistics = new accountBookStatistics ();
  10794. // $item = array (
  10795. // 'date' => date ( "Y-m-d" ),
  10796. // 'accountType' => $abDetail ['accountType'],
  10797. // 'accountMsg' => $abDetail ['accountMsg'],
  10798. // 'aid' => $abDetail ['aid'],
  10799. // 'inComePrice' => $abDetail ['receivedPrice'],
  10800. // 'expensesType' => $abDetail ['expensesType']
  10801. // );
  10802. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10803. // // 添加收入流水
  10804. // $wasteBook = new wasteBook ();
  10805. // $itemWaste = array (
  10806. // 'accountPriceShow' => $receivedPrice,
  10807. // 'accountPrice' => $receivedPrice,
  10808. // 'expensesType' => 1,
  10809. // 'accountType' => 6, // 流水类型
  10810. // 'dataID' => $inComeId,
  10811. // 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10812. // 'accountBank' => $accountBank,
  10813. // 'category' => $this->staff [0] ['category'],
  10814. // 'cid' => $this->staff [0] ['cid'],
  10815. // 'name' => $this->staff [0] ['username'],
  10816. // 'sid' => $this->staff [0] ['sid'],
  10817. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10818. // );
  10819. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10820. // // 添加一条理财支出
  10821. // $accountBank = 'CGBDeposit';
  10822. // $expenditureBank = '纵横广发';
  10823. // if($accountMsg=='个人(GR)'){
  10824. // $expenditureBank = '个人广发';
  10825. // }
  10826. // $dailyExpenditureType = 4;
  10827. // if ($accountType == 9) {
  10828. // $accountBank = 'ICBCDeposit';
  10829. // $expenditureBank = '纵横工行';
  10830. // $dailyExpenditureType = 6;
  10831. // }
  10832. // $accountBook = new accountBook ();
  10833. // $accountBook->expensesType = 2;
  10834. // $accountBook->expenditureType = $dailyExpenditureType;
  10835. // $accountBook->expenditureMsg = $accountMsg;
  10836. // $accountBook->expenditurePrice = $receivedPrice;
  10837. // $accountBook->expenditureBank = $expenditureBank;
  10838. // $accountBook->expenditureDate = $receivedDate;
  10839. // $accountBook->remarks = $remarks;
  10840. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10841. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10842. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  10843. // $id = $accountBook->insert ();
  10844. // // 收支汇总-添加一条理财支出汇总
  10845. // $abDetail = $accountBook->getAccountBookByAid ( $id );
  10846. // $accountBookStatistics = new accountBookStatistics ();
  10847. // $item = array (
  10848. // 'date' => date ( "Y-m-d" ),
  10849. // 'accountType' => $abDetail ['accountType'],
  10850. // 'accountMsg' => $abDetail ['accountMsg'],
  10851. // 'aid' => $abDetail ['aid'],
  10852. // 'financingPrice' => - $receivedPrice,
  10853. // 'expensesType' => 3
  10854. // );
  10855. // $accountBookStatistics->setAccountBookStatistics ( $item );
  10856. // //TODO -新增理财为个人时的情况 添加一条支出理财流水
  10857. // $accountTypeWaste = 5;
  10858. // if ($accountMsg == '公司固定') {
  10859. // $accountTypeWaste = 9;
  10860. // } elseif ($accountMsg == '公司活期') {
  10861. // $accountTypeWaste = 10;
  10862. // } elseif ($receivedBank == '个人广发') {
  10863. // $accountTypeWaste = 9;
  10864. // $accountBank = 'ICBCDeposit';
  10865. // }
  10866. // $itemWaste = array (
  10867. // 'expensesType' => 2,
  10868. // 'accountType' => $accountTypeWaste,
  10869. // 'accountPriceShow' => $receivedPrice,
  10870. // 'accountPrice' => - $receivedPrice,
  10871. // 'dataID' => $id,
  10872. // 'dailyExpenditureType' => $dailyExpenditureType,
  10873. // 'accountBank' => $accountBank,
  10874. // 'category' => $this->staff [0] ['category'],
  10875. // 'cid' => $this->staff [0] ['cid'],
  10876. // 'name' => $this->staff [0] ['username'],
  10877. // 'sid' => $this->staff [0] ['sid'],
  10878. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10879. // );
  10880. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10881. // }
  10882. elseif ($accountType == 1) {
  10883. // if ($receivedBank == '个人广发')
  10884. // die ( 'illegal request--no man' );
  10885. // 添加一条收入
  10886. $accountBook = new accountBook ();
  10887. $accountBook->accountType = $accountType;
  10888. $accountBook->accountMsg = $accountMsg;
  10889. $accountBook->receivedPrice = $receivedPrice;
  10890. $accountBook->receivedMsg = $receivedMsg;
  10891. $accountBook->receivedBank = $receivedBank;
  10892. $accountBook->receivedDate = $receivedDate;
  10893. $accountBook->remarks = $remarks;
  10894. $accountBook->expensesType = 1;
  10895. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10896. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10897. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10898. $id = $accountBook->insert ();
  10899. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10900. // 收支汇总-添加一条收入日常汇总
  10901. $accountBookStatistics = new accountBookStatistics ();
  10902. $item = array (
  10903. 'date' => date ( "Y-m-d" ),
  10904. 'accountType' => $abDetail ['accountType'],
  10905. 'accountMsg' => $abDetail ['accountMsg'],
  10906. 'aid' => $abDetail ['aid'],
  10907. 'expensesType' => $abDetail ['expensesType']
  10908. );
  10909. if ($abDetail ['accountType'] == 8) {
  10910. $item += array (
  10911. 'inComePrice' => $abDetail ['receivedPrice']
  10912. );
  10913. } else {
  10914. $item += array (
  10915. 'inComePrice' => $abDetail ['receivedPrice']
  10916. );
  10917. }
  10918. $accountBookStatistics->setAccountBookStatistics ( $item );
  10919. // 流水存储方向
  10920. $itemWaste = array (
  10921. 'accountType' => 6
  10922. ); // 流水类型
  10923. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10924. // }else
  10925. if ($accountMsg == '活期理财收益') {
  10926. $itemWaste = array (
  10927. 'accountType' => 10
  10928. ); // 流水类型
  10929. }
  10930. // 添加收入流水
  10931. $wasteBook = new wasteBook ();
  10932. $itemWaste += array (
  10933. 'accountPrice' => $receivedPrice,
  10934. 'accountPriceShow' => $receivedPrice,
  10935. 'expensesType' => 1,
  10936. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10937. 'dataID' => $id,
  10938. 'accountBank' => $accountBank,
  10939. 'category' => $this->staff [0] ['category'],
  10940. 'cid' => $this->staff [0] ['cid'],
  10941. 'name' => $this->staff [0] ['username'],
  10942. 'sid' => $this->staff [0] ['sid'],
  10943. 'inputDate' => $receivedDate,
  10944. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10945. 'synPaymentDate'=>1,
  10946. );
  10947. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10948. } else { // 普通日常收入处理
  10949. // 添加一条收入
  10950. $accountBook = new accountBook ();
  10951. $accountBook->accountType = $accountType;
  10952. $accountBook->accountMsg = $accountMsg;
  10953. $accountBook->receivedPrice = $receivedPrice;
  10954. $accountBook->receivedMsg = $receivedMsg;
  10955. $accountBook->receivedBank = $receivedBank;
  10956. $accountBook->receivedDate = $receivedDate;
  10957. $accountBook->remarks = $remarks;
  10958. $accountBook->expensesType = 1;
  10959. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10960. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10961. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10962. $id = $accountBook->insert ();
  10963. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10964. // 收支汇总-添加一条收入日常汇总
  10965. $accountBookStatistics = new accountBookStatistics ();
  10966. $item = array (
  10967. 'date' => date ( "Y-m-d" ),
  10968. 'accountType' => $abDetail ['accountType'],
  10969. 'accountMsg' => $abDetail ['accountMsg'],
  10970. 'aid' => $abDetail ['aid'],
  10971. 'expensesType' => $abDetail ['expensesType']
  10972. );
  10973. if ($abDetail ['accountType'] == 8) {
  10974. $item += array (
  10975. 'inComePrice' => $abDetail ['receivedPrice']
  10976. );
  10977. } else {
  10978. $item += array (
  10979. 'inComePrice' => $abDetail ['receivedPrice']
  10980. );
  10981. }
  10982. $accountBookStatistics->setAccountBookStatistics ( $item );
  10983. // 添加收入流水
  10984. // $itemWaste = array (
  10985. // 'accountPrice' => $receivedPrice
  10986. // );
  10987. // if ($receivedBank == '个人广发') {
  10988. // $itemWaste = array (
  10989. // 'accountPrice' => - $receivedPrice
  10990. // );
  10991. // }
  10992. $wasteBook = new wasteBook ();
  10993. $itemWaste = array (
  10994. 'accountPriceShow' => $receivedPrice,
  10995. 'accountPrice' => $receivedPrice,
  10996. 'expensesType' => 1,
  10997. 'accountType' => 6, // 流水类型
  10998. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10999. 'dataID' => $id,
  11000. 'accountBank' => $accountBank,
  11001. 'category' => $this->staff [0] ['category'],
  11002. 'cid' => $this->staff [0] ['cid'],
  11003. 'name' => $this->staff [0] ['username'],
  11004. 'sid' => $this->staff [0] ['sid'],
  11005. 'inputDate' => $receivedDate,
  11006. 'createAt'=>date ( "Y-m-d H:i:s" ),
  11007. 'synPaymentDate'=>1,
  11008. );
  11009. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11010. }
  11011. }
  11012. return '/payments';
  11013. }
  11014. function paymentsExpenditureDo() {
  11015. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11016. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11017. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11018. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11019. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11020. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11021. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11022. // 理财支出特殊处理
  11023. Doo::loadModel ( "accountBook" );
  11024. Doo::loadModel ( "accountBookStatistics" );
  11025. Doo::loadModel ( 'wasteBook' );
  11026. $accountBank = '';
  11027. if ($expenditureBank == '纵横广发') {
  11028. $accountBank = 'CGBDeposit';
  11029. } elseif ($expenditureBank == '纵横工行') {
  11030. $accountBank = 'ICBCDeposit';
  11031. } elseif ($expenditureBank == '华润银行') {
  11032. $accountBank = 'HUADeposit';
  11033. } elseif ($expenditureBank == '个人广发') {
  11034. $accountBank = 'PersonalDeposit';
  11035. }
  11036. if (empty ( $accountBank ))
  11037. die ( 'illegal request' );
  11038. if($expenditureType == 8 || $expenditureType == 9){
  11039. // if($expenditureType == 8 ){
  11040. // $expenditureBank='纵横广发';
  11041. // }elseif($expenditureType == 9){
  11042. // $expenditureBank='纵横工行';
  11043. // }
  11044. // // 添加一笔日常支出
  11045. // $accountBook = new accountBook ();
  11046. // $accountBook->expensesType = 2;
  11047. // $accountBook->expenditureType = $expenditureType;
  11048. // $accountBook->expenditureMsg = $expenditureMsg;
  11049. // $accountBook->expenditurePrice = $expenditurePrice;
  11050. // $accountBook->expenditureBank = $expenditureBank;
  11051. // $accountBook->expenditureDate = $expenditureDate;
  11052. // $accountBook->remarks = $remarks;
  11053. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11054. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11055. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11056. // $expenditureId = $accountBook->insert ();
  11057. // // 添加日常支出汇总
  11058. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11059. // $accountBookStatistics = new accountBookStatistics ();
  11060. // $item = array (
  11061. // 'date' => date ( "Y-m-d" ),
  11062. // 'expenditureType' => $abDetail ['expenditureType'],
  11063. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11064. // 'aid' => $abDetail ['aid'],
  11065. // 'payPrice' => $abDetail ['expenditurePrice'],
  11066. // 'expensesType' => $abDetail ['expensesType']
  11067. // );
  11068. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11069. // // 公司日常支出流水
  11070. // if($expenditureType == 8 ){
  11071. // $accountBank = 'CGBDeposit';
  11072. // }elseif($expenditureType == 9){
  11073. // $accountBank = 'ICBCDeposit';
  11074. // }
  11075. // if($accountBank=='CGBDeposit'){
  11076. // $dailyExpenditureType='8';
  11077. // }elseif($accountBank=='ICBCDeposit'){
  11078. // $dailyExpenditureType='9';
  11079. // }elseif($accountBank=='PersonalDeposit'){
  11080. // $dailyExpenditureType='10';
  11081. // }elseif($accountBank=='HUADeposit'){
  11082. // $dailyExpenditureType='11';
  11083. // }
  11084. // $wasteBook = new wasteBook ();
  11085. // $itemWaste = array (
  11086. // 'expensesType' => 2,
  11087. // 'accountType' => 5,
  11088. // 'dailyExpenditureType' => $dailyExpenditureType,
  11089. // 'accountPriceShow' => $expenditurePrice,
  11090. // 'accountPrice' => - $expenditurePrice,
  11091. // 'dataID' => $expenditureId,
  11092. // 'accountBank' => $accountBank,
  11093. // 'category' => $this->staff [0] ['category'],
  11094. // 'cid' => $this->staff [0] ['cid'],
  11095. // 'name' => $this->staff [0] ['username'],
  11096. // 'sid' => $this->staff [0] ['sid'],
  11097. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11098. // );
  11099. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11100. //TODO 日常支出 个人理财情况的相关修改
  11101. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11102. // if ($expenditureBank == '个人广发') {
  11103. // die ( '个人广发 illegal request' );
  11104. // }
  11105. // echo $expenditureMsg;
  11106. die;
  11107. // // 添加一笔日常支出
  11108. // $accountBook = new accountBook ();
  11109. // $accountBook->expensesType = 2;
  11110. // $accountBook->expenditureType = 7;
  11111. // $accountBook->expenditureMsg = $expenditureMsg;
  11112. // $accountBook->expenditurePrice = $expenditurePrice;
  11113. // $accountBook->expenditureBank = $expenditureBank;
  11114. // $accountBook->expenditureDate = $expenditureDate;
  11115. // $accountBook->remarks = $remarks;
  11116. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11117. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11118. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11119. // $expenditureId = $accountBook->insert ();
  11120. // // 添加日常支出汇总
  11121. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11122. // $accountBookStatistics = new accountBookStatistics ();
  11123. // $item = array (
  11124. // 'date' => date ( "Y-m-d" ),
  11125. // 'expenditureType' => $abDetail ['expenditureType'],
  11126. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11127. // 'aid' => $abDetail ['aid'],
  11128. // 'payPrice' => $abDetail ['expenditurePrice'],
  11129. // 'expensesType' => $abDetail ['expensesType']
  11130. // );
  11131. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11132. // // 公司日常支出流水
  11133. // $wasteBook = new wasteBook ();
  11134. // $itemWaste = array (
  11135. // 'accountPrice' => - $expenditurePrice
  11136. // );
  11137. // if($expenditureMsg!='个人(GR)'){
  11138. // if ($expenditureBank == '个人广发') {
  11139. // $itemWaste = array (
  11140. // 'accountPrice' => $expenditurePrice
  11141. // );
  11142. // }
  11143. // }
  11144. // $itemWaste += array (
  11145. // 'expensesType' => 2,
  11146. // 'accountType' => 5,
  11147. // 'dailyExpenditureType' => $expenditureType,
  11148. // 'accountPriceShow' => $expenditurePrice,
  11149. // 'accountPrice' => - $expenditurePrice,
  11150. // 'dataID' => $expenditureId,
  11151. // 'accountBank' => $accountBank,
  11152. // 'category' => $this->staff [0] ['category'],
  11153. // 'cid' => $this->staff [0] ['cid'],
  11154. // 'name' => $this->staff [0] ['username'],
  11155. // 'sid' => $this->staff [0] ['sid'],
  11156. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11157. // );
  11158. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11159. // // 添加一笔理财收入
  11160. // $accountBank = 'CGBDeposit';
  11161. // $dailyIncomeType = 7;
  11162. // $receivedBank = '纵横广发';
  11163. // if ($expenditureType == 6) {
  11164. // $accountBank = 'ICBCDeposit';
  11165. // $receivedBank = '纵横工行';
  11166. // $dailyIncomeType = 9;
  11167. // }elseif($expenditureMsg=='个人(GR)'){
  11168. // $receivedBank = '个人广发';
  11169. // }
  11170. // $accountBook = new accountBook ();
  11171. // $accountBook->expensesType = 1;
  11172. // $accountBook->accountType = $dailyIncomeType;
  11173. // $accountBook->accountMsg = $expenditureMsg;
  11174. // $accountBook->receivedPrice = $expenditurePrice;
  11175. // $accountBook->receivedBank = $receivedBank;
  11176. // $accountBook->receivedDate = $expenditureDate;
  11177. // $accountBook->remarks = $remarks;
  11178. // $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11179. // $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11180. // $accountBook->inputStaff = $this->staff [0] ['sid'];
  11181. // $id = $accountBook->insert ();
  11182. // // 添加日常理财收入汇总
  11183. // $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11184. // $accountBookStatistics = new accountBookStatistics ();
  11185. // $item = array (
  11186. // 'date' => date ( "Y-m-d" ),
  11187. // 'expenditureType' => $abDetail ['expenditureType'],
  11188. // 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11189. // 'aid' => $abDetail ['aid'],
  11190. // 'financingPrice' => $expenditurePrice,
  11191. // 'expensesType' => 3
  11192. // );
  11193. // $accountBookStatistics->setAccountBookStatistics ( $item );
  11194. // //TODO 修改理财收入 添加一笔收入流水
  11195. // if ($expenditureMsg == '公司固定') {
  11196. // $accountTypeWaste = 9;
  11197. // } elseif ($expenditureMsg == '公司活期') {
  11198. // $accountTypeWaste = 10;
  11199. // } elseif ($expenditureMsg == '个人(GR)') {
  11200. // $accountTypeWaste = 9;
  11201. // $accountBank = 'ICBCDeposit';
  11202. // }
  11203. // $itemWaste = array (
  11204. // 'expensesType' => 1,
  11205. // 'accountType' => $accountTypeWaste,
  11206. // 'accountPriceShow' => $expenditurePrice,
  11207. // 'accountPrice' => $expenditurePrice,
  11208. // 'dataID' => $id,
  11209. // 'dailyIncomeType' => $dailyIncomeType,
  11210. // 'accountBank' => $accountBank,
  11211. // 'category' => $this->staff [0] ['category'],
  11212. // 'cid' => $this->staff [0] ['cid'],
  11213. // 'name' => $this->staff [0] ['username'],
  11214. // 'sid' => $this->staff [0] ['sid'],
  11215. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11216. // );
  11217. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11218. } else {
  11219. // 添加一笔日常支出
  11220. $accountBook = new accountBook ();
  11221. $accountBook->expensesType = 2;
  11222. $accountBook->expenditureType = $expenditureType;
  11223. $accountBook->expenditureMsg = $expenditureMsg;
  11224. $accountBook->expenditurePrice = $expenditurePrice;
  11225. $accountBook->expenditureBank = $expenditureBank;
  11226. $accountBook->expenditureDate = $expenditureDate;
  11227. $accountBook->remarks = $remarks;
  11228. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11229. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11230. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11231. $id = $accountBook->insert ();
  11232. // 添加日常支出汇总
  11233. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11234. $accountBookStatistics = new accountBookStatistics ();
  11235. $item = array (
  11236. 'date' => date ( "Y-m-d" ),
  11237. 'expenditureType' => $abDetail ['expenditureType'],
  11238. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11239. 'aid' => $abDetail ['aid'],
  11240. 'expensesType' => $abDetail ['expensesType']
  11241. );
  11242. if ($expenditureType == 5) {
  11243. $item += array (
  11244. 'payPrice' => - $abDetail ['expenditurePrice']
  11245. );
  11246. } else {
  11247. $item += array (
  11248. 'payPrice' => $abDetail ['expenditurePrice']
  11249. );
  11250. }
  11251. $accountBookStatistics->setAccountBookStatistics ( $item );
  11252. // 公司日常支出流水
  11253. $wasteBook = new wasteBook ();
  11254. $itemWaste = array (
  11255. 'accountPrice' => - $expenditurePrice
  11256. );
  11257. if ($expenditureBank == '个人广发') {
  11258. $itemWaste = array (
  11259. 'accountPrice' => $expenditurePrice
  11260. );
  11261. }
  11262. $itemWaste += array (
  11263. 'expensesType' => 2,
  11264. 'accountType' => 5,
  11265. 'accountPriceShow' => $expenditurePrice,
  11266. 'dataID' => $id,
  11267. 'dailyExpenditureType' => $expenditureType,
  11268. 'accountBank' => $accountBank,
  11269. 'category' => $this->staff [0] ['category'],
  11270. 'cid' => $this->staff [0] ['cid'],
  11271. 'name' => $this->staff [0] ['username'],
  11272. 'sid' => $this->staff [0] ['sid'],
  11273. 'inputDate' => date ( "Y-m-d H:i:s" )
  11274. );
  11275. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11276. }
  11277. }
  11278. return '/payments';
  11279. }
  11280. /**
  11281. * 添加支出
  11282. */
  11283. function paymentsExpenditureDo_() {
  11284. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11285. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11286. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11287. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11288. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11289. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11290. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11291. $dailyExpenditureType = '';
  11292. $accountTypeWaste = 5;
  11293. $accountBank = '';
  11294. if ($expenditureBank == '纵横广发') {
  11295. $accountBank = 'CGBDeposit';
  11296. } elseif ($expenditureBank == '纵横工行') {
  11297. $accountBank = 'ICBCDeposit';
  11298. } elseif ($expenditureBank == '华润银行') {
  11299. $accountBank = 'HUADeposit';
  11300. } elseif ($expenditureBank == '个人广发') {
  11301. $accountBank = 'PersonalDeposit';
  11302. }
  11303. if (empty ( $accountBank ))
  11304. die ( 'illegal request' );
  11305. $itemWaste = array (
  11306. 'accountPrice' => - $expenditurePrice
  11307. );
  11308. if ($expenditureBank == '个人广发') {
  11309. $itemWaste = array (
  11310. 'accountPrice' => $expenditurePrice
  11311. );
  11312. }
  11313. if ($expenditureType == 4 || $expenditureType == 6) {
  11314. $dailyExpenditureType = 4;
  11315. if ($expenditureMsg == '公司固定') {
  11316. $accountTypeWaste = 9;
  11317. } elseif ($expenditureMsg == '公司活期') {
  11318. $accountTypeWaste = 10;
  11319. } elseif ($expenditureMsg == '个人(GR)') {
  11320. $accountBank = 'PersonalDeposit';
  11321. }
  11322. $itemWaste = array (
  11323. 'accountPrice' => $expenditurePrice
  11324. );
  11325. } elseif ($expenditureType == 1) {
  11326. $dailyExpenditureType = 1;
  11327. } elseif ($expenditureType == 2) {
  11328. $dailyExpenditureType = 2;
  11329. } elseif ($expenditureType == 3) {
  11330. $dailyExpenditureType = 3;
  11331. } elseif ($expenditureType == 5) {
  11332. $dailyExpenditureType = 5;
  11333. }
  11334. if (empty ( $dailyExpenditureType ))
  11335. die ( 'illegal request' );
  11336. Doo::loadModel ( "accountBook" );
  11337. $accountBook = new accountBook ();
  11338. $accountBook->expenditureType = $expenditureType;
  11339. $accountBook->expenditureMsg = $expenditureMsg;
  11340. $accountBook->expenditurePrice = $expenditurePrice;
  11341. $accountBook->expenditureBank = $expenditureBank;
  11342. $accountBook->expenditureDate = $expenditureDate;
  11343. $accountBook->remarks = $remarks;
  11344. $accountBook->expensesType = 2;
  11345. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11346. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11347. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11348. $id = $accountBook->insert ();
  11349. //
  11350. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11351. Doo::loadModel ( "accountBookStatistics" );
  11352. $accountBookStatistics = new accountBookStatistics ();
  11353. $item = array (
  11354. 'date' => date ( "Y-m-d" ),
  11355. 'expenditureType' => $abDetail ['expenditureType'],
  11356. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11357. 'aid' => $abDetail ['aid']
  11358. );
  11359. if ($abDetail ['expensesType'] == 2) {
  11360. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11361. $item += array (
  11362. 'financingPrice' => $expenditurePrice,
  11363. 'expensesType' => 3
  11364. );
  11365. } elseif ($abDetail ['expenditureType'] == 5) {
  11366. $item += array (
  11367. 'payPrice' => $abDetail ['expenditurePrice'],
  11368. 'expensesType' => $abDetail ['expensesType']
  11369. );
  11370. } else {
  11371. $item += array (
  11372. 'payPrice' => $abDetail ['expenditurePrice'],
  11373. 'expensesType' => $abDetail ['expensesType']
  11374. );
  11375. }
  11376. }
  11377. $accountBookStatistics->setAccountBookStatistics ( $item );
  11378. // 公司流水记录
  11379. Doo::loadModel ( 'wasteBook' );
  11380. $wasteBook = new wasteBook ();
  11381. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11382. // 银行
  11383. if (empty ( $abDetail )) {
  11384. $itemWaste += array (
  11385. 'accountPriceShow' => $expenditurePrice,
  11386. 'dataID' => $id,
  11387. 'expensesType' => 2,
  11388. 'accountType' => $accountTypeWaste,
  11389. 'dailyExpenditureType' => $expenditureType,
  11390. 'accountBank' => $accountBank,
  11391. 'category' => $this->staff [0] ['category'],
  11392. 'cid' => $this->staff [0] ['cid'],
  11393. 'name' => $this->staff [0] ['username'],
  11394. 'sid' => $this->staff [0] ['sid'],
  11395. 'inputDate' => date ( "Y-m-d H:i:s" )
  11396. );
  11397. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11398. }
  11399. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11400. if ($expenditureType == 4 || $expenditureType == 6) {
  11401. $accountBank = 'CGBDeposit';
  11402. $dailyIncomeType = 7;
  11403. $receivedBank = '纵横广发';
  11404. if ($expenditureType == 6) {
  11405. $accountBank = 'ICBCDeposit';
  11406. $receivedBank = '纵横工行';
  11407. $dailyIncomeType = 9;
  11408. }
  11409. // 添加一笔收入
  11410. $accountBook = new accountBook ();
  11411. $accountBook->accountType = $dailyIncomeType;
  11412. $accountBook->accountMsg = $expenditureMsg;
  11413. $accountBook->receivedPrice = $expenditurePrice;
  11414. $accountBook->receivedBank = $receivedBank;
  11415. $accountBook->receivedDate = $expenditureDate;
  11416. $accountBook->remarks = $remarks;
  11417. $accountBook->expensesType = 1;
  11418. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11419. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11420. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11421. $id = $accountBook->insert ();
  11422. // 添加一笔收入流水
  11423. $itemWaste = array (
  11424. 'accountPriceShow' => $expenditurePrice,
  11425. 'accountPrice' => - $expenditurePrice,
  11426. 'dataID' => $id,
  11427. 'expensesType' => 1,
  11428. 'accountType' => $accountTypeWaste,
  11429. 'dailyIncomeType' => $dailyIncomeType,
  11430. 'accountBank' => $accountBank,
  11431. 'category' => $this->staff [0] ['category'],
  11432. 'cid' => $this->staff [0] ['cid'],
  11433. 'name' => $this->staff [0] ['username'],
  11434. 'sid' => $this->staff [0] ['sid'],
  11435. 'inputDate' => date ( "Y-m-d H:i:s" )
  11436. );
  11437. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11438. }
  11439. }
  11440. return '/payments';
  11441. }
  11442. /**
  11443. * 所有收支
  11444. */
  11445. function paymentsAchieve() {
  11446. $page_size = 12;
  11447. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11448. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11449. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11450. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11451. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11452. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11453. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11454. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11455. Doo::loadModel ( "accountBookStatistics" );
  11456. $accountBookStatistics = new accountBookStatistics ();
  11457. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11458. $data ['statisticsList'] = $statisticsList;
  11459. Doo::loadModel ( "accountBook" );
  11460. $accountBook = new accountBook ();
  11461. $con = '';
  11462. if ($expensesType == 'INCOME')
  11463. $con = ' and expensesType=1 ';
  11464. elseif ($expensesType == 'PAY')
  11465. $con = ' and expensesType=2 ';
  11466. $dateArr = explode ( ':', $date );
  11467. $D1 = $dateString = '';
  11468. $D2 = '';
  11469. if (! empty ( $date )) {
  11470. $D1 = $dateArr [0];
  11471. if (isset ( $dateArr [1] ))
  11472. $D2 = $dateArr [1];
  11473. else
  11474. $D2 = '';
  11475. $dateString = $D1 . " : " . $D2;
  11476. }
  11477. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11478. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11479. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11480. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11481. if (! empty ( $price ))
  11482. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11483. if ($submitType == 1) {
  11484. if ($accountType != '') {
  11485. $expenditureType = '';
  11486. $con .= ' and accountType=' . $accountType;
  11487. if (! empty ( $accountMsg ))
  11488. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11489. }
  11490. } elseif ($submitType == 2) {
  11491. if ($expenditureType != '') {
  11492. $accountType = $accountMsg = '';
  11493. $con .= ' and expenditureType=' . $expenditureType;
  11494. }
  11495. } else {
  11496. $accountType = $accountMsg = $expenditureType = '';
  11497. }
  11498. $sql = "" . $con;
  11499. $action = "paymentsAchieve";
  11500. $get = '/' . $expensesType."?accountType=".$accountType."&expenditureType=".$expenditureType."&submitType=".$submitType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11501. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11502. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11503. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11504. $data ['expenditureType'] = $expenditureType;
  11505. $data ['accountMsg'] = $accountMsg;
  11506. $data ['accountType'] = $accountType;
  11507. $data ['inputDate'] = $date;
  11508. $data ['price'] = $price;
  11509. $data ['expensesType'] = $expensesType;
  11510. $data ['page'] = $pageinfo;
  11511. $data ['list'] = $list;
  11512. $data ['memu'] = "receipt";
  11513. $data ['staff'] = $this->staff;
  11514. $data ['receiptMemu'] = 'payments';
  11515. $data ['verifyId'] = $this->verifyId;
  11516. $data ['executeId'] = $this->executeId;
  11517. $this->render ( "/expenses/paymentsAchieve", $data );
  11518. }
  11519. function paymentsIncomeUpdateDo() {
  11520. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11521. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11522. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11523. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11524. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11525. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11526. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11527. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11528. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11529. Doo::loadClass ( 'XDeode' );
  11530. $XDeode = new XDeode ( 5 );
  11531. $aid = $XDeode->decode ( $aidKey );
  11532. Doo::loadModel ( "accountBook" );
  11533. $accountBook = new accountBook ();
  11534. //
  11535. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11536. $price = $receivedPrice - $abDetail [inComePrice];
  11537. Doo::loadModel ( "accountBookStatistics" );
  11538. $accountBookStatistics = new accountBookStatistics ();
  11539. if ($abDetail ['accountType'] == 7) {
  11540. $item += array (
  11541. 'date' => date ( "Y-m-d" ),
  11542. 'financingPrice' => - $price,
  11543. 'expensesType' => 3,
  11544. 'aid' => $abDetail ['aid']
  11545. );
  11546. } elseif ($abDetail ['accountType'] == 8) {
  11547. $item += array (
  11548. 'date' => date ( "Y-m-d" ),
  11549. 'expensesType' => $abDetail ['expensesType'],
  11550. 'inComePrice' => - $price,
  11551. 'aid' => $abDetail ['aid']
  11552. );
  11553. } else {
  11554. $item = array (
  11555. 'date' => date ( "Y-m-d" ),
  11556. 'expensesType' => $abDetail ['expensesType'],
  11557. 'inComePrice' => $price,
  11558. 'aid' => $abDetail ['aid']
  11559. );
  11560. }
  11561. $accountBookStatistics->setAccountBookStatistics ( $item );
  11562. $accountBook->accountType = $accountType;
  11563. $accountBook->accountMsg = $accountMsg;
  11564. $accountBook->receivedPrice = $receivedPrice;
  11565. $accountBook->receivedMsg = $receivedMsg;
  11566. $accountBook->receivedBank = $receivedBank;
  11567. $accountBook->receivedDate = $receivedDate;
  11568. $accountBook->remarks = $remarks;
  11569. $accountBook->aid = $aid;
  11570. $accountBook->update ();
  11571. }
  11572. return '/paymentsAchieve';
  11573. }
  11574. function paymentsExpenditureEdiDo() {
  11575. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11576. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11577. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11578. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11579. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11580. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11581. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11582. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11583. Doo::loadClass ( 'XDeode' );
  11584. $XDeode = new XDeode ( 5 );
  11585. $aid = $XDeode->decode ( $aidKey );
  11586. Doo::loadModel ( "accountBook" );
  11587. $accountBook = new accountBook ();
  11588. // 汇总信息
  11589. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11590. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11591. Doo::loadModel ( "accountBookStatistics" );
  11592. $accountBookStatistics = new accountBookStatistics ();
  11593. if ($abDetail ['expenditureType'] == 4) {
  11594. $item += array (
  11595. 'date' => date ( "Y-m-d" ),
  11596. 'financingPrice' => $price,
  11597. 'expensesType' => 3,
  11598. 'aid' => $abDetail ['aid']
  11599. );
  11600. } elseif ($abDetail ['expenditureType'] == 5) {
  11601. $item += array (
  11602. 'date' => date ( "Y-m-d" ),
  11603. 'expensesType' => $abDetail ['expensesType'],
  11604. 'payPrice' => $price,
  11605. 'aid' => $abDetail ['aid']
  11606. );
  11607. } else {
  11608. $item = array (
  11609. 'date' => date ( "Y-m-d" ),
  11610. 'expensesType' => $abDetail ['expensesType'],
  11611. 'payPrice' => $price,
  11612. 'aid' => $abDetail ['aid']
  11613. );
  11614. }
  11615. $accountBookStatistics->setAccountBookStatistics ( $item );
  11616. //
  11617. $accountBook->expenditureType = $expenditureType;
  11618. $accountBook->expenditureMsg = $expenditureMsg;
  11619. $accountBook->expenditurePrice = $expenditurePrice;
  11620. $accountBook->expenditureBank = $expenditureBank;
  11621. $accountBook->remarks = $remarks;
  11622. $accountBook->expenditureDate = $expenditureDate;
  11623. $accountBook->aid = $aid;
  11624. $id = $accountBook->update ();
  11625. }
  11626. return '/paymentsAchieve';
  11627. }
  11628. function paymentsDelDo() {
  11629. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11630. if (! empty ( $aidKey )) {
  11631. Doo::loadClass ( 'XDeode' );
  11632. $XDeode = new XDeode ( 5 );
  11633. $aid = $XDeode->decode ( $aidKey );
  11634. Doo::loadModel ( "accountBook" );
  11635. $accountBook = new accountBook ();
  11636. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11637. if (empty ( $abDetail ))
  11638. die ( 'illegal request' );
  11639. // 删除收支
  11640. Doo::loadModel ( "accountBookStatistics" );
  11641. $accountBookStatistics = new accountBookStatistics ();
  11642. $item = array (
  11643. 'date' => date ( "Y-m-d" ),
  11644. 'aid' => $abDetail ['aid']
  11645. );
  11646. $accountType = '';
  11647. if ($abDetail ['expensesType'] == 1) {
  11648. $accountType = 6;
  11649. if ($abDetail ['accountType'] != 7) {
  11650. $item += array (
  11651. 'expensesType' => $abDetail ['expensesType'],
  11652. 'inComePrice' => - $abDetail ['receivedPrice']
  11653. );
  11654. } else {
  11655. $item += array (
  11656. 'financingPrice' => $abDetail ['receivedPrice'],
  11657. 'expensesType' => 3
  11658. );
  11659. }
  11660. } elseif ($abDetail ['expensesType'] == 2) {
  11661. $accountType = 5;
  11662. if ($abDetail ['accountType'] != 7) {
  11663. $item += array (
  11664. 'expensesType' => $abDetail ['expensesType'],
  11665. 'payPrice' => - $abDetail ['expenditurePrice']
  11666. );
  11667. } else {
  11668. $item += array (
  11669. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11670. 'expensesType' => 3
  11671. );
  11672. }
  11673. }
  11674. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11675. if ($abDetail ['expenditureMsg'] == '公司固定')
  11676. $accountType = 9;
  11677. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11678. $accountType = 10;
  11679. }
  11680. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11681. if ($abDetail ['accountMsg'] == '公司固定')
  11682. $accountType = 9;
  11683. elseif ($abDetail ['accountMsg'] == '公司活期')
  11684. $accountType = 10;
  11685. }
  11686. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11687. $accountType = 10;
  11688. }
  11689. $accountBookStatistics->setAccountBookStatistics ( $item );
  11690. $accountBook->delete ( array (
  11691. 'where' => 'aid=' . $aid,
  11692. 'limit' => 1
  11693. ) );
  11694. // 删除收入流水
  11695. //TODO 2020-07-23 删除新增理财和银行存款流水
  11696. if (! empty ( $accountType )) {
  11697. Doo::loadModel ( 'wasteBook' );
  11698. $wasteBook = new wasteBook ();
  11699. $wasteBook->delete ( array (
  11700. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11701. 'limit' => 1
  11702. ) );
  11703. }
  11704. }
  11705. return '/paymentsAchieve';
  11706. }
  11707. function paymentsCollect() {
  11708. Doo::loadModel ( "execute" );
  11709. $execute = new execute ();
  11710. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11711. die ( 'illegal request' );
  11712. }
  11713. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11714. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11715. Doo::loadModel ( "accountBookStatistics" );
  11716. $accountBookStatistics = new accountBookStatistics ();
  11717. Doo::loadClass ( 'receipt.func' );
  11718. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11719. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11720. $data ['html'] = $html ['html'];
  11721. $data ['inSum'] = $html ['sum'];
  11722. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11723. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11724. $data ['payHtml'] = $html ['html'];
  11725. $data ['paySum'] = $html ['sum'];
  11726. // 余额统计
  11727. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11728. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11729. include './protected/config/wasteBook.conf.php';
  11730. Doo::loadModel ( 'wasteBook' );
  11731. $wasteBook = new wasteBook ();
  11732. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11733. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11734. // 获得年份之前所有金额
  11735. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11736. // print_r($detail);
  11737. // $waste['total'];
  11738. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11739. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11740. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11741. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11742. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11743. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11744. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11745. if (date ( 'Y' ) > $year) {
  11746. $limitMonth = 12;
  11747. }
  11748. for($i = 1; $i <= 12; $i ++) {
  11749. $inComeA = $payB = 0;
  11750. $falg = true;
  11751. foreach ( $inComePay as $key => $value ) {
  11752. if ($value ['month'] == $i) {
  11753. $falg = false;
  11754. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11755. $inSum += $value ['accountPrice'];
  11756. $showInSum += $value ['accountPriceShow'];
  11757. $inComeA = $value ['accountPrice'];
  11758. break;
  11759. }
  11760. }
  11761. if ($falg)
  11762. $inComeHtml .= '<td class="taR">-</td>';
  11763. $payFalg = true;
  11764. foreach ( $pay as $key => $value ) {
  11765. if ($value ['month'] == $i) {
  11766. $payFalg = false;
  11767. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11768. $paySum += $value ['accountPrice'];
  11769. $showPaySum += $value ['accountPriceShow'];
  11770. $payB = $value ['accountPrice'];
  11771. break;
  11772. }
  11773. }
  11774. if ($payFalg)
  11775. $payHtml .= '<td class="taR">-</td>';
  11776. if (empty ( $balanceC ) || $limitMonth < $i)
  11777. $lastBalanceHtml .= '<td class="taR">-</td>';
  11778. else
  11779. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11780. $balanceC = $balanceC + $inComeA + $payB;
  11781. $balanceSum += $balanceC;
  11782. if (empty ( $balanceC ) || $limitMonth < $i)
  11783. $BalanceHtml .= '<td class="taR">-</td>';
  11784. else
  11785. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11786. // 余额统计
  11787. }
  11788. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11789. $data ['inComeHtml'] = $inComeHtml;
  11790. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11791. $data ['payBalanceHtml'] = $payHtml;
  11792. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11793. $data ['BalanceHtml'] = $BalanceHtml;
  11794. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11795. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11796. $mothHtml = "";
  11797. for($i = 1; $i <= 12; $i ++) {
  11798. if ($moth == $i)
  11799. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11800. else
  11801. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11802. }
  11803. $data ['mothHtml'] = $mothHtml;
  11804. $dateHtml = "";
  11805. $now = date ( "Y" );
  11806. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11807. if ($YEARD <= $now) {
  11808. $dateHtml .= '<option ';
  11809. if ($year == $YEARD) {
  11810. $dateHtml .= 'selected ';
  11811. }
  11812. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11813. }
  11814. }
  11815. $data ['dateHtml'] = $dateHtml;
  11816. $data ['year'] = $year;
  11817. $data ['memu'] = "receipt";
  11818. $data ['staff'] = $this->staff;
  11819. $data ['receiptMemu'] = 'paymentsCollect';
  11820. $data ['verifyId'] = $this->verifyId;
  11821. $data ['executeId'] = $this->executeId;
  11822. $this->render ( "/expenses/paymentsCollect", $data );
  11823. }
  11824. function paymentsCollectDay() {
  11825. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11826. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11827. if (empty ( $moth ))
  11828. return 'paymentsCollect';
  11829. Doo::loadModel ( "accountBookStatistics" );
  11830. $accountBookStatistics = new accountBookStatistics ();
  11831. $i = 2;
  11832. $y = 2013;
  11833. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11834. Doo::loadClass ( 'receipt.func' );
  11835. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11836. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11837. $data ['html'] = $html ['html'];
  11838. $data ['inSum'] = $html ['sum'];
  11839. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11840. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11841. $data ['payHtml'] = $html ['html'];
  11842. $data ['paySum'] = $html ['sum'];
  11843. $mothHtml = "";
  11844. for($i = 1; $i <= 12; $i ++) {
  11845. if ($moth == $i)
  11846. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11847. else
  11848. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11849. }
  11850. $data ['mothHtml'] = $mothHtml;
  11851. $data ['year'] = $year;
  11852. // 余额
  11853. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11854. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11855. include './protected/config/wasteBook.conf.php';
  11856. Doo::loadModel ( 'wasteBook' );
  11857. $wasteBook = new wasteBook ();
  11858. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11859. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11860. // 获得年份之前所有金额
  11861. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11862. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11863. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11864. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11865. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11866. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11867. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11868. // $balanceC = 0;
  11869. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11870. $limitDay = date ( 'd' );
  11871. $monthLK = ( int ) date ( 'm' );
  11872. if (date ( 'Y' ) > $year) {
  11873. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11874. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11875. $limitDay = 0;
  11876. }
  11877. for($i = 1; $i <= $day; $i ++) {
  11878. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11879. $inComeA = $payB = 0;
  11880. $falg = true;
  11881. foreach ( $inComePay as $key => $value ) {
  11882. if ($value ['day'] == $i) {
  11883. $falg = false;
  11884. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11885. $inSum += $value ['accountPrice'];
  11886. $showInSum += $value ['accountPriceShow'];
  11887. $inComeA = $value ['accountPrice'];
  11888. break;
  11889. }
  11890. }
  11891. if ($falg)
  11892. $inComeHtml .= '<td class="taR">-</td>';
  11893. $payFalg = true;
  11894. foreach ( $pay as $key => $value ) {
  11895. if ($value ['day'] == $i) {
  11896. $payFalg = false;
  11897. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11898. $paySum += $value ['accountPrice'];
  11899. $showPaySum += $value ['accountPriceShow'];
  11900. $payB = $value ['accountPrice'];
  11901. break;
  11902. }
  11903. }
  11904. if ($payFalg)
  11905. $payHtml .= '<td class="taR">-</td>';
  11906. if (empty ( $balanceC ) || $limitDay < $i)
  11907. $lastBalanceHtml .= '<td class="taR">-</td>';
  11908. else
  11909. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11910. $balanceC = $balanceC + $inComeA + $payB;
  11911. $balanceSum += $balanceC;
  11912. if (empty ( $balanceC ) || $limitDay < $i)
  11913. $BalanceHtml .= '<td class="taR">-</td>';
  11914. else
  11915. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11916. }
  11917. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11918. $data ['inComeHtml'] = $inComeHtml;
  11919. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11920. $data ['payBalanceHtml'] = $payHtml;
  11921. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11922. $data ['BalanceHtml'] = $BalanceHtml;
  11923. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11924. $data ['dayHtml'] = $dayHtml;
  11925. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11926. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11927. $dateHtml = "";
  11928. $now = date ( "Y" );
  11929. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11930. if ($YEARD <= $now) {
  11931. $dateHtml .= '<option ';
  11932. if ($year == $YEARD) {
  11933. $dateHtml .= 'selected ';
  11934. }
  11935. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11936. }
  11937. }
  11938. $data ['dateHtml'] = $dateHtml;
  11939. $data ['memu'] = "receipt";
  11940. $data ['staff'] = $this->staff;
  11941. $data ['receiptMemu'] = 'paymentsCollect';
  11942. $data ['verifyId'] = $this->verifyId;
  11943. $data ['executeId'] = $this->executeId;
  11944. $this->render ( "/expenses/paymentsCollectDay", $data );
  11945. }
  11946. // 公司流水
  11947. function wasteBook() {
  11948. Doo::loadModel ( "execute" );
  11949. $execute = new execute ();
  11950. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11951. die ( 'illegal request' );
  11952. }
  11953. Doo::loadModel ( 'wasteBook' );
  11954. $wasteBook = new wasteBook ();
  11955. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11956. include './protected/config/wasteBook.conf.php';
  11957. $wasteBook = new wasteBook ();
  11958. $list=$wasteBook->GetAll();
  11959. $total=0;
  11960. $noInPrice=array(
  11961. "LC_HQ"=>0,
  11962. "LC_GD"=>0,
  11963. //工行理财固定
  11964. "GH_LC_GD"=>0,
  11965. "CK"=>0,
  11966. "HQ1"=>0,
  11967. );
  11968. //理财活期
  11969. $GD_LC_HQ=0;$GH_LC_HQ=0;
  11970. //理财固定
  11971. $GD_LC_GD=0;$GR_LC_GD=0;
  11972. //存款
  11973. $GF_CK=0;$GH_CK=0;$GR_CK=0;$ZH_CK=0;
  11974. foreach ($list as $key=>$value){
  11975. // 存款 旧理财部分 dailyType=0 accountType=9,10
  11976. if($value['dailyType']==0){
  11977. //旧理财部分 -活期
  11978. if($value['accountType']==10){
  11979. //广发理财
  11980. if($value['accountBank']=="CGBDeposit"){
  11981. $GD_LC_HQ+=$value["accountPrice"];
  11982. //工行理财
  11983. }elseif($value['accountBank']=="ICBCDeposit"){
  11984. $GH_LC_HQ+=$value["accountPrice"];
  11985. }else{
  11986. //未统计到金额
  11987. $noInPrice['LC_HQ']+=$value["accountPrice"];
  11988. }
  11989. //旧理财部分 -固定
  11990. }elseif($value['accountType']==9){
  11991. //广发理财
  11992. if($value['accountBank']=="CGBDeposit"){
  11993. $GD_LC_HQ+=$value["accountPrice"];
  11994. //个人理财--- 原是工行理财固定-不统计入内
  11995. }elseif($value['accountBank']=="ICBCDeposit"){
  11996. // $GR_LC_GD+=$value["accountPrice"];
  11997. $noInPrice['GH_LC_GD']+=$value["accountPrice"];
  11998. }else{
  11999. //未统计到金额
  12000. $noInPrice['LC_GD']+=$value["accountPrice"];
  12001. }
  12002. //存款
  12003. }else{
  12004. //广发存款
  12005. if($value['accountBank']=="CGBDeposit"){
  12006. $GF_CK+=$value["accountPrice"];
  12007. //工行存款
  12008. }elseif($value['accountBank']=="ICBCDeposit"){
  12009. $GH_CK+=$value["accountPrice"];
  12010. //个人存款
  12011. }elseif($value['accountBank']=="PersonalDeposit"){
  12012. $GR_CK+=$value["accountPrice"];
  12013. //(广发)纵横知道--原华润银行
  12014. }elseif($value['accountBank']=="HUADeposit"){
  12015. $ZH_CK+=$value["accountPrice"];
  12016. }else{
  12017. $noInPrice['CK']+=$value["accountPrice"];
  12018. }
  12019. }
  12020. }else{
  12021. // 理财部分 其中 公司账户为存款部分
  12022. //理财账号
  12023. if($value['operatingBankType']==1){
  12024. //广发理财活期
  12025. if ($value['depositMethod'] == '活期' && $value['accountBank'] == 'CGBDeposit') {
  12026. $GD_LC_HQ += $value['accountPrice'];
  12027. //工行理财活期
  12028. }elseif ($value['depositMethod'] == '活期' && $value['accountBank'] == 'ICBCDeposit') {
  12029. $GH_LC_HQ += $value['accountPrice'];
  12030. //个人理财固定(广发)
  12031. }elseif ($value['depositMethod'] == '固定' && $value['accountBank'] == 'CGBPersonalDeposit') {
  12032. $GR_LC_GD += $value['accountPrice'];
  12033. //广发理财-固定
  12034. }elseif ($value['depositMethod'] == '固定' && $value['accountBank'] == 'CGBDeposit') {
  12035. $GD_LC_GD += $value['accountPrice'];
  12036. }else{
  12037. $noInPrice['HQ1']+=$value["accountPrice"];
  12038. }
  12039. //公司账号
  12040. }elseif($value['operatingBankType']==2){
  12041. //(纵横广发)广发存款
  12042. if ( $value['accountBank'] == 'CGBDeposit') {
  12043. $GF_CK += $value['accountPrice'];
  12044. }elseif ( $value['accountBank'] == 'ICBCDeposit') {
  12045. //工行存款
  12046. $GH_CK += $value['accountPrice'];
  12047. }elseif ( $value['accountBank'] == 'PersonalDeposit') {
  12048. //个人存款
  12049. $GR_CK += $value['accountPrice'];
  12050. }else{
  12051. $noInPrice['HQ2']+=$value["accountPrice"];
  12052. }
  12053. }else{
  12054. $noInPrice['HQ3']+=$value["accountPrice"];
  12055. }
  12056. }
  12057. }
  12058. $data['GF_CK']=bcadd($GF_CK,$waste['bank']['CGBDeposit'],2);
  12059. $data['ZH_CK']=bcadd($ZH_CK,$waste['bank']['HUADeposit'],2);
  12060. $data['CK_TO']=bcadd($data['GF_CK'],$data['ZH_CK'],2);
  12061. $data['GD_LC_HQ']=bcadd($GD_LC_HQ,$waste['financial']['current']['CGBDeposit'],2);
  12062. $data['GH_LC_HQ']=bcadd($GH_LC_HQ,$waste['financial']['current']['ICBCDeposit'],2);
  12063. $data['GH_CK']=bcadd($GH_CK,$waste['bank']['ICBCDeposit'],2);
  12064. $data['GR_CK']=bcadd($GR_CK,$waste['bank']['PersonalDeposit'],2);
  12065. $data['HQ_TO']=bcadd($data['GD_LC_HQ']+$data['GH_LC_HQ'],$data['GH_CK']+$data['GR_CK'],2);
  12066. $data['GD_LC_GD']=bcadd($GD_LC_GD,$waste['financial']['fixed']['CGBDeposit'],2);
  12067. $data['GR_LC_GD']=bcadd($GR_LC_GD,$waste['financial']['fixed']['ICBCDeposit'],2);
  12068. $data['total']=bcadd($data['CK_TO']+$data['HQ_TO'],$data['GD_LC_GD']+$data['GR_LC_GD'],2);
  12069. // echo $waste;
  12070. // $data['total']=bcadd($total,$waste,2);
  12071. // include './protected/config/wasteBook.conf.php';
  12072. // Doo::loadModel ( 'wasteBook' );
  12073. // $wasteBook = new wasteBook ();
  12074. // $data ['store']=$waste;
  12075. // $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  12076. // //print_r($waste);
  12077. // //1-收入支出流水金额合计
  12078. // $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  12079. // //echo $waste['bank']['CGBDeposit'].'</br>';
  12080. // //2020-07-20 -理财相关-面板数据
  12081. // Doo::loadClass ( 'wasteBook.finances.func' );
  12082. // $financesStatistics=$wasteBook->getFinancesStatistics();
  12083. // //print_r($waste);
  12084. // // 展示使用
  12085. // // 收入
  12086. // //print_r($inComeStatistics);
  12087. // $wasteStatistics['CGBDeposit']=0;
  12088. // $wasteStatistics['ICBCDeposit']=0;
  12089. // $wasteStatistics['HUADeposit']=0;
  12090. // $wasteStatistics['PersonalDeposit']=0;
  12091. // foreach ($inComeStatistics['incomeStatistics'] as $value ){
  12092. // if($value['accountBank']=='CGBDeposit'){
  12093. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12094. // }
  12095. // if($value['accountBank']=='ICBCDeposit'){
  12096. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12097. // }
  12098. // if($value['accountBank']=='HUADeposit'){
  12099. // $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  12100. // }
  12101. // if($value['accountBank']=='PersonalDeposit'){
  12102. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12103. // }
  12104. // }
  12105. // $data ['wasteStatistics']=$wasteStatistics;
  12106. // //支出
  12107. // $wasteStatistics['CGBDeposit']=0;
  12108. // $wasteStatistics['ICBCDeposit']=0;
  12109. // $wasteStatistics['HUADeposit']=0;
  12110. // $wasteStatistics['PersonalDeposit']=0;
  12111. // foreach ($inComeStatistics['expenditureStatistics'] as $value ){
  12112. // if($value['accountBank']=='CGBDeposit'){
  12113. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12114. // }
  12115. // if($value['accountBank']=='ICBCDeposit'){
  12116. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12117. // }
  12118. // if($value['accountBank']=='HUADeposit'){
  12119. // $wasteStatistics['HUADeposit']+=$value['accountPrice'];
  12120. // }
  12121. // if($value['accountBank']=='PersonalDeposit'){
  12122. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12123. // }
  12124. // }
  12125. // $data ['wastePay']=$wasteStatistics;
  12126. // //理财公司账号部分
  12127. // $wasteStatistics['CGBDeposit']=0;
  12128. // $wasteStatistics['ICBCDeposit']=0;
  12129. // $wasteStatistics['HUADeposit']=0;
  12130. // $wasteStatistics['PersonalDeposit']=0;
  12131. // foreach ($financesStatistics['companyAccount'] as $value ){
  12132. // //(纵横广发)广发存款
  12133. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12134. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12135. // }
  12136. // //工行存款
  12137. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12138. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12139. // }
  12140. // //个人存款
  12141. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12142. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12143. // }
  12144. // }
  12145. // $data ['wasteCompanyAccount']=$wasteStatistics;
  12146. // //理财部分的金额计算
  12147. // $waste =_getFinancesWBS ( $waste, $financesStatistics );
  12148. // //echo $waste['bank']['CGBDeposit'].'</br>';;
  12149. // //存款面板数据--日常收支改变后的金额汇总
  12150. // $bankSavingsStatistics=$wasteBook->getBankSavingsStatistics();
  12151. // $waste =_getBankSavingsWBS ( $waste, $bankSavingsStatistics );
  12152. // //展示调试BUG-使用
  12153. // //print_r($bankSavingsStatistics);
  12154. // $wasteStatistics['CGBDeposit']=0;
  12155. // $wasteStatistics['ICBCDeposit']=0;
  12156. // $wasteStatistics['PersonalDeposit']=0;
  12157. // foreach ($bankSavingsStatistics as $value ){
  12158. // //(纵横广发)广发存款
  12159. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'CGBDeposit') {
  12160. // $wasteStatistics['CGBDeposit']+=$value['accountPrice'];
  12161. // }
  12162. // //工行存款
  12163. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'ICBCDeposit') {
  12164. // $wasteStatistics['ICBCDeposit']+=$value['accountPrice'];
  12165. // }
  12166. // //个人存款
  12167. // if ($value['operatingBankType'] == 2 && $value['accountBank'] == 'PersonalDeposit') {
  12168. // $wasteStatistics['PersonalDeposit']+=$value['accountPrice'];
  12169. // }
  12170. // }
  12171. // $data ['wasteNewPay']=$wasteStatistics;
  12172. //echo $waste['bank']['CGBDeposit'].'</br>';;
  12173. //
  12174. // $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'];
  12175. // $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12176. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12177. // print_r($waste);
  12178. // $data ['total'] = number_format($total,2);
  12179. // $data ['CGBDeposit_total'] = number_format($CGBDeposit_total,2);
  12180. // $cashBalance=$CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12181. // $data['cashBalance']= number_format($cashBalance,2);
  12182. // $waste ['bank'] ['CGBDeposit']=sprintf("%.2f", round($waste ['bank'] ['CGBDeposit'], 2));
  12183. // $data ['waste'] = $waste;
  12184. // 月流水数据结构
  12185. $monthStatistics = array ();
  12186. $incomeMothStatistics = array ();
  12187. $expenditureMothStatistics = array ();
  12188. for($i = 1; $i <= 12; $i ++) {
  12189. $month = date ( 'Y' ) . '-' . $i;
  12190. if ($i < 10)
  12191. $month = date ( 'Y' ) . '-0' . $i;
  12192. array_push ( $monthStatistics, $month );
  12193. }
  12194. foreach ( $monthStatistics as $value ) {
  12195. $falg = true;
  12196. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12197. if ($value == $v ['inputDate']) {
  12198. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12199. $falg = false;
  12200. }
  12201. }
  12202. if ($falg) {
  12203. array_push ( $incomeMothStatistics, '' );
  12204. }
  12205. $falgEx = true;
  12206. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12207. if ($value == $v ['inputDate']) {
  12208. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12209. $falg = false;
  12210. }
  12211. }
  12212. if ($falgEx) {
  12213. array_push ( $expenditureMothStatistics, '' );
  12214. }
  12215. }
  12216. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12217. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12218. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12219. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12220. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12221. // print_r($incomeList);
  12222. $data ['expenditureList'] = $expenditureList;
  12223. $data ['incomeList'] = $incomeList;
  12224. $data ['memu'] = "receipt";
  12225. $data ['staff'] = $this->staff;
  12226. $data ['receiptMemu'] = 'wasteBook';
  12227. $data ['verifyId'] = $this->verifyId;
  12228. $data ['executeId'] = $this->executeId;
  12229. $this->render ( "/expenses/wasteBook", $data );
  12230. }
  12231. function wasteBookIncome() {
  12232. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12233. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12234. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12235. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12236. $data ['dailyIncomeType'] = $dailyIncomeType;
  12237. Doo::loadModel ( 'wasteBook' );
  12238. $wasteBook = new wasteBook ();
  12239. Doo::loadModel ( 'L_category' );
  12240. $L_category = new L_category ();
  12241. Doo::loadClass ( 'XDeode' );
  12242. $XDeode = new XDeode ( 5 );
  12243. $year=date("Y");
  12244. $theDay=date("Y-m-d");
  12245. $dateArr = explode ( ':', $date );
  12246. $D1 = '';
  12247. $D2 = '';
  12248. $con = '';
  12249. if (! empty ( $date )) {
  12250. $D1 = $dateArr [0];
  12251. $D2 = $dateArr [1];
  12252. }
  12253. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12254. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12255. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12256. $con = ' and inputDate = "' . $D1 . '"';
  12257. else{
  12258. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12259. }
  12260. if ($cid != 'ALL') {
  12261. $cid = $XDeode->decode ( $cid );
  12262. $con .= ' and cid = "' . $cid . '"';
  12263. }
  12264. if ($accountType != 'ALL') {
  12265. if ($accountType == 'INVOICE') {
  12266. $con .= ' and (accountType = 7 or accountType = 8)';
  12267. } elseif ($accountType == 'PAYMENTS') {
  12268. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12269. if ($dailyIncomeType != 'ALL') {
  12270. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12271. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12272. }
  12273. }
  12274. }
  12275. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12276. foreach ($incomeList as $key=>$value){
  12277. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12278. $wasteBook = new wasteBook ();
  12279. $wasteBook->wid = $value['wid'];
  12280. $wasteBook->synPaymentDate = 1;
  12281. $wasteBook->inputDate = $value['data']['receivedDate'];
  12282. $wasteBook->update();
  12283. }
  12284. }
  12285. $sum = 0;$thsDaySum=0;
  12286. foreach ( $incomeList as $key => $value ) {
  12287. $sum += $value ['accountPrice'];
  12288. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12289. $thsDaySum+=$value ['accountPrice'];
  12290. }
  12291. }
  12292. // print_r($incomeList);
  12293. // 获得办事和部门
  12294. $categoryList = $L_category->getCategory ();
  12295. $data ['accountType'] = $accountType;
  12296. $data ['cid'] = $cid;
  12297. $data ['categoryList'] = $categoryList;
  12298. $data ['sum'] = $sum;
  12299. $data ['incomeList'] = $incomeList;
  12300. $data ['inputDate'] = $date;
  12301. $data['year']=$year;
  12302. $data ['thsDay'] =$theDay;
  12303. $data ['thsDaySum'] =$thsDaySum;
  12304. $data ['memu'] = "receipt";
  12305. $data ['staff'] = $this->staff;
  12306. $data ['receiptMemu'] = 'wasteBook';
  12307. $data ['verifyId'] = $this->verifyId;
  12308. $data ['executeId'] = $this->executeId;
  12309. $this->render ( "/expenses/wasteBookIncome", $data );
  12310. }
  12311. /**
  12312. * 所有支出
  12313. */
  12314. function wasteBookExpenditure() {
  12315. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12316. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12317. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12318. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12319. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12320. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12321. $data ['receiptType'] = $receiptType;
  12322. Doo::loadModel ( 'wasteBook' );
  12323. $wasteBook = new wasteBook ();
  12324. Doo::loadModel ( 'L_category' );
  12325. $L_category = new L_category ();
  12326. Doo::loadClass ( 'XDeode' );
  12327. $XDeode = new XDeode ( 5 );
  12328. $year=date("Y");
  12329. $theDay=date("Y-m-d");
  12330. $dateArr = explode ( ':', $date );
  12331. $D1 = '';
  12332. $D2 = '';
  12333. $con = '';
  12334. if (! empty ( $date )) {
  12335. $D1 = $dateArr [0];
  12336. $D2 = $dateArr [1];
  12337. }
  12338. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12339. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12340. elseif (! empty ( $D1 ) && empty ( $D2 )){
  12341. $startYear=$D1.":00.00.00";
  12342. $endYear=$D1.":23.59.59";
  12343. $con = ' and inputDate >= "'.$startYear.'" and inputDate <= "'.$endYear.'"';
  12344. }else{
  12345. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12346. }
  12347. if ($cid != 'ALL') {
  12348. $cid = $XDeode->decode ( $cid );
  12349. $con .= ' and cid = "' . $cid . '"';
  12350. }
  12351. if ($accountType != 'ALL') {
  12352. if ($accountType == 'INVOICE') {
  12353. $con .= ' and accountType = 11';
  12354. } elseif ($accountType == 'PAYMENTS') {
  12355. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12356. if ($dailyExpenditureType != 'ALL') {
  12357. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12358. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12359. }
  12360. } elseif ($accountType == 'RECEIPT') {
  12361. if ($receiptType == 'ALL') {
  12362. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12363. } else {
  12364. $receiptType = $XDeode->decode ( $receiptType );
  12365. echo $receiptType;
  12366. if ($receiptType == 1) {
  12367. $con .= ' and (accountType = 1 or accountType=2)';
  12368. } else {
  12369. $con .= ' and accountType = ' . $receiptType;
  12370. }
  12371. }
  12372. }
  12373. }
  12374. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12375. foreach ($incomeList as $key=>$value){
  12376. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12377. $wasteBook = new wasteBook ();
  12378. $wasteBook->wid = $value['wid'];
  12379. $wasteBook->synPaymentDate = 1;
  12380. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12381. $wasteBook->update();
  12382. }
  12383. }
  12384. $sum = 0;$thsDaySum=0;
  12385. foreach ( $incomeList as $key => $value ) {
  12386. $sum += $value ['accountPriceShow'];
  12387. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12388. $thsDaySum+=$value ['accountPriceShow'];
  12389. }
  12390. }
  12391. // print_r($incomeList);
  12392. // 获得办事和部门
  12393. $categoryList = $L_category->getCategory ();
  12394. $data ['accountType'] = $accountType;
  12395. $data ['cid'] = $cid;
  12396. $data ['categoryList'] = $categoryList;
  12397. $data ['sum'] = $sum;
  12398. $data ['incomeList'] = $incomeList;
  12399. $data ['inputDate'] = $date;
  12400. $data['year']=$year;
  12401. $data ['thsDay'] =$theDay;
  12402. $data ['thsDaySum'] =$thsDaySum;
  12403. $data ['memu'] = "receipt";
  12404. $data ['staff'] = $this->staff;
  12405. $data ['receiptMemu'] = 'wasteBook';
  12406. $data ['verifyId'] = $this->verifyId;
  12407. $data ['executeId'] = $this->executeId;
  12408. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12409. }
  12410. function ajaxGetWasteinvoiceReceivables() {
  12411. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12412. Doo::loadClass ( 'XDeode' );
  12413. $XDeode = new XDeode ( 5 );
  12414. $irid = $XDeode->decode ( $serial );
  12415. Doo::loadModel ( 'invoiceReceivables' );
  12416. $invoiceReceivables = new invoiceReceivables ();
  12417. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12418. echo json_encode ( array (
  12419. 'status' => 1,
  12420. 'detail' => $detail
  12421. ) );
  12422. }
  12423. function ajaxGetPaymentsByAid() {
  12424. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12425. Doo::loadModel ( "accountBook" );
  12426. $accountBook = new accountBook ();
  12427. $detail = $accountBook->getAccountBookByAid ( $serial );
  12428. echo json_encode ( array (
  12429. 'status' => 1,
  12430. 'detail' => $detail
  12431. ) );
  12432. }
  12433. function ajaxGetWasteInvoice() {
  12434. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12435. Doo::loadModel ( 'invoice' );
  12436. $invoice = new invoice ();
  12437. Doo::loadModel ( 'invoiceReceivables' );
  12438. $invoiceReceivables = new invoiceReceivables ();
  12439. $detail = $invoice->getInvoiceByIid ( $serial );
  12440. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12441. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12442. echo json_encode ( array (
  12443. 'status' => 1,
  12444. 'detail' => $detail
  12445. ) );
  12446. }
  12447. /**
  12448. */
  12449. function ajaxGetWasteReceipt() {
  12450. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12451. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12452. Doo::loadModel ( 'receipt' );
  12453. $receipt = new receipt ();
  12454. Doo::loadClass ( 'XDeode' );
  12455. $XDeode = new XDeode ( 5 );
  12456. $rid = $XDeode->decode ( $serial );
  12457. $accountType= $XDeode->decode ( $accountTypeKey );
  12458. // 获得个数据
  12459. $detail = $receipt->getReceiptByRid ( $rid );
  12460. // 初始化
  12461. $detail ['reviseDetail'] = array ();
  12462. if (! empty ( $value ['reviseDetail'] ))
  12463. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12464. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12465. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12466. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12467. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12468. // 获得费用html
  12469. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12470. // 获得费用审批人数据
  12471. $detail = $this->getReceiptApproverHtml ( $detail );
  12472. // 审批执行
  12473. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12474. <th class="taC" width="90">审批人</th>
  12475. <th class="taC">审批意见</th></tr>';
  12476. foreach ( $detail ['verifyList'] as $key => $value ) {
  12477. $html .= '<tr>
  12478. <td>' . $value [1] . '</td>
  12479. <td>' . $value ['opinion'] . '</td>
  12480. </tr>
  12481. ';
  12482. }
  12483. $html .= ' </tbody></table>';
  12484. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12485. <th class="taC" width="90">执行人</th>
  12486. <th class="taC">执行意见</th></tr>';
  12487. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12488. $html .= '<tr>
  12489. <td>' . $value [1] . '</td>
  12490. <td>' . $value ['opinion'] . '</td>
  12491. </tr>
  12492. ';
  12493. }
  12494. $html .= ' </tbody></table>';
  12495. if($accountType==1){
  12496. Doo::loadModel ( 'loanReceipt' );
  12497. $loanReceipt = new loanReceipt ();
  12498. $loanList = $loanReceipt->getOne ( array (
  12499. 'where' => 'rid=' . $detail ['loanRid'],
  12500. 'desc' => 'rid',
  12501. 'asArray' => true
  12502. ) );
  12503. $html .= '<table class="table table-bordered table-condensed">
  12504. <tr class="warning">
  12505. <td class="taR"><b>汇款金额</b></td>
  12506. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12507. </tr>
  12508. </table>';
  12509. }else{
  12510. $html .= '<table class="table table-bordered table-condensed">
  12511. <tr class="warning">
  12512. <td class="taR"><b>汇款金额</b></td>
  12513. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12514. </tr>
  12515. </table>';
  12516. }
  12517. // print_r($detail['verifyList']);
  12518. // header ( 'Content-Type:text/html;charset=utf-8' );
  12519. // echo $html;
  12520. echo json_encode ( array (
  12521. 'status' => 1,
  12522. 'html' => $html,
  12523. 'detail' => $detail
  12524. ) );
  12525. }
  12526. function getReceiptApproverHtml($detail = array()) {
  12527. Doo::loadModel ( 'loanReceipt' );
  12528. $loanReceipt = new loanReceipt ();
  12529. Doo::loadModel ( 'verify' );
  12530. $verify = new verify ();
  12531. Doo::loadModel ( 'staff' );
  12532. $staff = new staff ();
  12533. if (empty ( $detail ))
  12534. return array ();
  12535. $loanList = $loanReceipt->getOne ( array (
  12536. 'where' => 'rid=' . $detail ['loanRid'],
  12537. 'desc' => 'rid',
  12538. 'asArray' => true
  12539. ) );
  12540. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12541. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12542. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12543. else
  12544. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12545. } else
  12546. $verifyList = $verify->getOne ( array (
  12547. 'where' => 'vid=' . $detail ['verify'],
  12548. 'asArray' => true
  12549. ) );
  12550. $verifyList = json_decode ( $verifyList ['staff'], true );
  12551. Doo::loadModel ( 'role' );
  12552. $role = new role ();
  12553. $roleId = 0;
  12554. $flag = true;
  12555. $roleKey = 0;
  12556. $endStaffArray = array ();
  12557. $roleArrayCopy = array ();
  12558. foreach ( $verifyList as $k => $v ) {
  12559. // init verifyStaff
  12560. if ($v [1] == 'ROLE') {
  12561. if (! empty ( $verifyStaff )) {
  12562. $endStaffArray = end ( $verifyStaff );
  12563. }
  12564. $roleVerify = json_decode ( $v [3], true );
  12565. $roleKey = $k;
  12566. $roleArray = array ();
  12567. $rolename = $role->getOne ( array (
  12568. 'where' => 'rid=' . $v [0],
  12569. 'asArray' => true
  12570. ) );
  12571. foreach ( $roleVerify as $o => $p ) {
  12572. $staffID = explode ( '_', $p );
  12573. $staffInfo = $staff->getOne ( array (
  12574. 'where' => 'sid=' . $staffID [0],
  12575. 'asArray' => true
  12576. ) );
  12577. // print_r($staffID);
  12578. $exp = array (
  12579. 0 => $staffInfo ['sid'],
  12580. 1 => $staffID [1],
  12581. 2 => $staffInfo ['avatar'],
  12582. 'date' => '',
  12583. 'date' => '',
  12584. 'opinion' => '',
  12585. 'status' => '',
  12586. 'rolename' => $rolename ['name']
  12587. );
  12588. array_push ( $roleArray, $exp );
  12589. }
  12590. $roleArrayCopy [$v [0]] = $roleArray;
  12591. // $verifyList[$k]['roleArray']=$roleArray;
  12592. }
  12593. $verifyList [$k] ['date'] = "";
  12594. $verifyList [$k] ['opinion'] = "";
  12595. $verifyList [$k] ['status'] = "";
  12596. if (empty ( $verifyStaff )) {
  12597. $verifyList [$k] ['date'] = "";
  12598. $verifyList [$k] ['opinion'] = "";
  12599. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12600. $verifyList [$k] ['status'] = 4;
  12601. $flag = false;
  12602. }
  12603. } else {
  12604. foreach ( $verifyStaff as $m => $u ) {
  12605. if ($v [0] == $m) {
  12606. $verifyList [$k] ['date'] = $u ['date'];
  12607. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12608. $verifyList [$k] ['status'] = $u ['status'];
  12609. $flag = false;
  12610. break;
  12611. }
  12612. }
  12613. $endStaffArray = end ( $verifyStaff );
  12614. }
  12615. }
  12616. $rolename ['name'] = '';
  12617. if (! empty ( $roleId )) {
  12618. Doo::loadModel ( 'role' );
  12619. $role = new role ();
  12620. $rolename = $role->getOne ( array (
  12621. 'where' => 'rid=' . $roleId,
  12622. 'asArray' => true
  12623. ) );
  12624. }
  12625. if (! empty ( $verifyStaff ))
  12626. $endStaffArray = end ( $verifyStaff );
  12627. $KOP = false;
  12628. foreach ( $roleArrayCopy as $P => $A ) {
  12629. foreach ( $A as $MKI => $AVL ) {
  12630. if (! empty ( $verifyStaff )) {
  12631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12633. $button = 4;
  12634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12635. }
  12636. foreach ( $verifyStaff as $m => $u ) {
  12637. $AVLFK = $AVL [0] . '_R';
  12638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12643. break;
  12644. }
  12645. }
  12646. } else {
  12647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12648. $button = 4;
  12649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12650. }
  12651. }
  12652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12653. $KOP = true;
  12654. }
  12655. }
  12656. foreach ( $roleArrayCopy as $k => $v ) {
  12657. foreach ( $verifyList as $m => $n ) {
  12658. if ($n [0] == $k) {
  12659. array_splice ( $verifyList, $m, 1, $v );
  12660. }
  12661. }
  12662. }
  12663. // 费用执行人相关数据
  12664. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12665. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12666. foreach ( $executeCopy as $k => $v ) {
  12667. $executeCopy [$k] ['date'] = '';
  12668. $executeCopy [$k] ['opinion'] = '';
  12669. $executeCopy [$k] ['status'] = '';
  12670. if (! empty ( $executeStaff ))
  12671. foreach ( $executeStaff as $m => $u ) {
  12672. if ($v [0] == $m) {
  12673. $executeCopy [$k] ['date'] = $u ['date'];
  12674. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12675. $executeCopy [$k] ['status'] = $u ['status'];
  12676. break;
  12677. }
  12678. }
  12679. }
  12680. $detail ['executeCopy'] = $executeCopy;
  12681. $detail ['verifyList'] = $verifyList;
  12682. return $detail;
  12683. }
  12684. //获得新版报销单费用说明
  12685. private function getReceiptVerson1Explanation($value){
  12686. $version_1_explanation="";
  12687. if($value['version']==1){
  12688. if(!empty($value['officeJson'])){
  12689. $officeJson=json_decode($value['officeJson'],true);
  12690. $version_1_explanation.=$officeJson['officeExplain'][0]['officeExplain']."\n";
  12691. }
  12692. if(!empty($value['traveJson'])){
  12693. $traveJson=json_decode($value['traveJson'],true);
  12694. $version_1_explanation.=$traveJson['traveExplain'][0]['traveExplain']."\n";
  12695. }
  12696. if(!empty($value['trainJson'])){
  12697. $trainJson=json_decode($value['trainJson'],true);
  12698. $version_1_explanation.=$trainJson['trainExplain'][0]['trainExplain']."\n";
  12699. }
  12700. }
  12701. return $version_1_explanation;
  12702. }
  12703. //获得新版报销单 详情HTML
  12704. private function getReceiptVerson1Html($detail){
  12705. $html='<table class="table table-bordered table-condensed">
  12706. <tbody>';
  12707. if($detail['version']==1){
  12708. if(!empty($detail['officeJson'])){
  12709. $officeJson=json_decode($detail['officeJson'],true);
  12710. $html .= '
  12711. <tr>
  12712. <th colspan="2" class="taC">日常相关费用</th>
  12713. </tr>';
  12714. // 日常相关费用
  12715. $total=0;
  12716. foreach ( $officeJson['daily'] as $key => $value ) {
  12717. if(!empty($value['price'])){
  12718. $html .= '
  12719. <tr>
  12720. <th>' . $value ['name'] . '</th>
  12721. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12722. </tr>';
  12723. $total=bcadd($total,$value ['price'],2);
  12724. }
  12725. }
  12726. $html .= '
  12727. <tr>
  12728. <th class="taR">合计</th>
  12729. <td class="colGreen taR">¥' .$total . '</td>
  12730. </tr>';
  12731. // 其他
  12732. $html .= '<tr>
  12733. <th colspan="2" class="taC">其他</th>
  12734. </tr>';
  12735. $total=0;
  12736. foreach ( $officeJson['other'] as $key => $value ) {
  12737. if(!empty($value['price'])){
  12738. $html .= '
  12739. <tr>
  12740. <th>' . $value ['name'] . '</th>
  12741. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12742. </tr>';
  12743. $total=bcadd($total,$value ['price'],2);
  12744. }
  12745. }
  12746. $html .= '
  12747. <tr>
  12748. <th class="taR">合计</th>
  12749. <td class="colGreen taR">¥' . $total . '</td>
  12750. </tr>';
  12751. }
  12752. if(!empty($detail['traveJson'])){
  12753. $traveJson=json_decode($detail['traveJson'],true);
  12754. // 差旅
  12755. $html .= '<tr>
  12756. <th colspan="2" class="taC">差旅相关费用</th>
  12757. </tr>';
  12758. $total=0;
  12759. foreach ( $traveJson['trave'] as $key => $value ) {
  12760. if(!empty($value['price'])){
  12761. $html .= '
  12762. <tr>
  12763. <th>' . $value ['name'] . '</th>
  12764. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12765. </tr>';
  12766. $total=bcadd($total,$value ['price'],2);
  12767. }
  12768. }
  12769. $html .= '
  12770. <tr>
  12771. <th class="taR">合计</th>
  12772. <td class="colGreen taR">¥' . $total . '</td>
  12773. </tr>';
  12774. }
  12775. if(!empty($detail['trainJson'])){
  12776. $trainJson=json_decode($detail['trainJson'],true);
  12777. // 内部培训费用
  12778. $html .= '<tr>
  12779. <th colspan="2" class="taC">内部培训费用</th>
  12780. </tr>';
  12781. $total=0;
  12782. foreach ( $trainJson['train'] as $key => $value ) {
  12783. if(!empty($value['price'])){
  12784. $html .= '
  12785. <tr>
  12786. <th>' . $value ['name'] . '</th>
  12787. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12788. </tr>';
  12789. $total=bcadd($total,$value ['price'],2);
  12790. }
  12791. }
  12792. $html .= '
  12793. <tr>
  12794. <th class="taR">合计</th>
  12795. <td class="colGreen taR">¥' . $total . '</td>
  12796. </tr>';
  12797. }
  12798. }
  12799. return $html;
  12800. }
  12801. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12802. if (empty ( $detail ))
  12803. return '';
  12804. $html = '';
  12805. // die;
  12806. if ($detail ['Rtype'] == 0) { // 报销单
  12807. if($detail ['version']==1){
  12808. $html .= $this->getReceiptVerson1Html($detail);
  12809. }else{
  12810. $html .= '<table class="table table-bordered table-condensed">
  12811. <tbody>
  12812. <tr>
  12813. <th colspan="2" class="taC">日常相关费用</th>
  12814. </tr>';
  12815. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12816. $html .= '
  12817. <tr>
  12818. <th>' . $value ['name'] . '</th>
  12819. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12820. </tr>';
  12821. }
  12822. $html .= '
  12823. <tr>
  12824. <th class="taR">合计</th>
  12825. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12826. </tr>';
  12827. $html .= '<tr>
  12828. <th colspan="2" class="taC">差旅相关费用</th>
  12829. </tr>';
  12830. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12831. $html .= '
  12832. <tr>
  12833. <th>' . $value ['name'] . '</th>
  12834. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12835. </tr>';
  12836. }
  12837. $html .= '
  12838. <tr>
  12839. <th class="taR">合计</th>
  12840. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12841. </tr>';
  12842. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12843. $html .= '<tr>
  12844. <th colspan="2" class="taC">内部培训费用</th>
  12845. </tr>';
  12846. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12847. $html .= '
  12848. <tr>
  12849. <th>' . $value ['name'] . '</th>
  12850. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12851. </tr>';
  12852. }
  12853. $html .= '
  12854. <tr>
  12855. <th class="taR">合计</th>
  12856. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12857. </tr>';
  12858. }
  12859. $html .= '<tr>
  12860. <th colspan="2" class="taC">其他</th>
  12861. </tr>';
  12862. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12863. $html .= '
  12864. <tr>
  12865. <th>' . $value ['name'] . '</th>
  12866. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12867. </tr>';
  12868. }
  12869. $html .= '
  12870. <tr>
  12871. <th class="taR">合计</th>
  12872. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12873. </tr>';
  12874. }
  12875. $html .= '<tr>
  12876. <th colspan="2" class="taC">报销金额调整</th>
  12877. </tr>';
  12878. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12879. $html .= '
  12880. <tr>
  12881. <th>' . $value ['name'] . '</th>
  12882. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12883. </tr>';
  12884. }
  12885. $html .= '
  12886. <tr>
  12887. <th class="taR">合计</th>
  12888. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12889. </tr>';
  12890. $html .= '
  12891. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12892. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12893. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12894. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12895. <tr class="warning">
  12896. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12897. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12898. </tr>
  12899. </tbody>
  12900. </table>';
  12901. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12902. $html .= '
  12903. <table class="table table-bordered table-condensed">
  12904. <tbody>
  12905. <tr>
  12906. <th colspan="2" class="taC">办事处相关费用</th>
  12907. </tr>';
  12908. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12909. $html .= '
  12910. <tr>
  12911. <th>' . $value ['name'] . '</th>
  12912. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12913. </tr>';
  12914. }
  12915. $html .= '
  12916. <tr>
  12917. <th class="taR">合计</th>
  12918. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12919. </tr>';
  12920. $html .= '
  12921. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12922. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12923. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12924. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12925. <tr class="warning">
  12926. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12927. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12928. </tr>
  12929. </tbody>
  12930. </table>';
  12931. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12932. Doo::loadModel ( 'loanReceipt' );
  12933. $loanReceipt = new loanReceipt ();
  12934. $loanList = $loanReceipt->getOne ( array (
  12935. 'where' => 'rid=' . $detail ['loanRid'],
  12936. 'desc' => 'rid',
  12937. 'asArray' => true
  12938. ) );
  12939. // print_r($loanList);
  12940. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12941. $html .= '<table class="table table-bordered table-condensed">
  12942. <tbody>
  12943. <tr>
  12944. <th colspan="2" class="taC">借款费用</th>
  12945. </tr>';
  12946. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12947. $html .= '<tr>
  12948. <th>' . $value ['name'] . '</th>
  12949. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12950. </tr>';
  12951. }
  12952. $html .= '<tr>
  12953. <th class="taC" colspan="2">产生费用所在办事处</th>
  12954. </tr>
  12955. <tr>
  12956. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12957. </tr>
  12958. <tr>
  12959. <th class="taC" colspan="2">费用说明</th>
  12960. </tr>
  12961. <tr>
  12962. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12963. </tr>
  12964. <tr class="warning">
  12965. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12966. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12967. </tr>
  12968. </tbody>
  12969. </table>
  12970. ';
  12971. if ( $accountType==2) {
  12972. $balance=$detail ['sum']-$loanList ['sum'];
  12973. $balanceCN=$this->num_to_rmb($balance);
  12974. if($detail ['version']==1){
  12975. $html .= $this->getReceiptVerson1Html($detail);
  12976. }else{
  12977. $html .= '<table class="table table-bordered table-condensed">
  12978. <tbody>
  12979. <tr>
  12980. <th colspan="2" class="taC">日常相关费用</th>
  12981. </tr>';
  12982. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12983. $html .= '
  12984. <tr>
  12985. <th>' . $value ['name'] . '</th>
  12986. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12987. </tr>';
  12988. }
  12989. $html .= '
  12990. <tr>
  12991. <th class="taR">合计</th>
  12992. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12993. </tr>';
  12994. $html .= '<tr>
  12995. <th colspan="2" class="taC">差旅相关费用</th>
  12996. </tr>';
  12997. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12998. $html .= '
  12999. <tr>
  13000. <th>' . $value ['name'] . '</th>
  13001. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13002. </tr>';
  13003. }
  13004. $html .= '
  13005. <tr>
  13006. <th class="taR">合计</th>
  13007. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  13008. </tr>';
  13009. if(isset($detail ['accountItem'] ['内部培训费用'])){
  13010. $html .= '<tr>
  13011. <th colspan="2" class="taC">内部培训费用</th>
  13012. </tr>';
  13013. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  13014. $html .= '
  13015. <tr>
  13016. <th>' . $value ['name'] . '</th>
  13017. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13018. </tr>';
  13019. }
  13020. $html .= '
  13021. <tr>
  13022. <th class="taR">合计</th>
  13023. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  13024. </tr>';
  13025. }
  13026. $html .= '<tr>
  13027. <th colspan="2" class="taC">其他</th>
  13028. </tr>';
  13029. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  13030. $html .= '
  13031. <tr>
  13032. <th>' . $value ['name'] . '</th>
  13033. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13034. </tr>';
  13035. }
  13036. $html .= '
  13037. <tr>
  13038. <th class="taR">合计</th>
  13039. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  13040. </tr>';
  13041. }
  13042. $html .= '<tr>
  13043. <th colspan="2" class="taC">报销金额调整</th>
  13044. </tr>';
  13045. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  13046. $html .= '
  13047. <tr>
  13048. <th>' . $value ['name'] . '</th>
  13049. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  13050. </tr>';
  13051. }
  13052. $html .= '
  13053. <tr>
  13054. <th class="taR">合计</th>
  13055. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  13056. </tr>';
  13057. $html .= '
  13058. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  13059. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  13060. <tr><th class="taC" colspan="2">报销说明</th></tr>
  13061. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  13062. <tr class="warning">
  13063. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  13064. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  13065. </tr>
  13066. <tr class="success">
  13067. <td class="taR"><b>借款结余</b></td>
  13068. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  13069. </tr>
  13070. </tbody>
  13071. </table>';
  13072. }
  13073. }
  13074. return $html;
  13075. }
  13076. /**
  13077. * 计算流水
  13078. */
  13079. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  13080. $bakWaste ['bank'] = array (
  13081. 'CGBDeposit' => 0,
  13082. 'ICBCDeposit' => 0,
  13083. 'HUADeposit' => 0,
  13084. 'PersonalDeposit' => 0
  13085. );
  13086. $bakWaste ['financial'] = array (
  13087. 'current' => array (
  13088. 'CGBDeposit' => 0,
  13089. 'ICBCDeposit' => 0
  13090. ),
  13091. 'fixed' => array (
  13092. 'CGBDeposit' => 0,
  13093. 'ICBCDeposit' => 0
  13094. )
  13095. );
  13096. // 存款
  13097. foreach ( $waste ['bank'] as $key => $value ) {
  13098. // 收入
  13099. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  13100. // 广发
  13101. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13102. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13103. }
  13104. // 工商
  13105. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13106. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13107. }
  13108. // 华润
  13109. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13110. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13111. }
  13112. // 个人
  13113. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13114. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13115. }
  13116. }
  13117. }
  13118. foreach ( $waste ['bank'] as $key => $value ) {
  13119. // 支出
  13120. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  13121. // 广发
  13122. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13123. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13124. }
  13125. // 工商
  13126. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13127. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13128. }
  13129. // 华润
  13130. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13131. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13132. }
  13133. // 个人
  13134. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13135. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13136. }
  13137. }
  13138. }
  13139. // 活期
  13140. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13141. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13142. // 广发
  13143. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13144. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13145. }
  13146. // 工商
  13147. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13148. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13149. }
  13150. // 个人
  13151. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13152. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13153. }
  13154. }
  13155. }
  13156. // print_r($inComeStatistics ['fixedStatistics']);
  13157. // 固期
  13158. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13159. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13160. // 广发
  13161. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13162. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13163. }
  13164. // 工商---已经转变成个人理财固定代表含义
  13165. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13166. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13167. }
  13168. // 个人
  13169. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13170. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13171. }
  13172. }
  13173. }
  13174. $waste ['bank'] ['ICBCDeposit'] = sprintf("%.2f", $waste ['bank'] ['ICBCDeposit']);
  13175. return $waste;
  13176. }
  13177. function lyt() {
  13178. Doo::loadModel ( "receiptDetail" );
  13179. $receiptDetail = new receiptDetail ();
  13180. $receiptCollectList = $receiptDetail->find ( array (
  13181. 'where' => 'status=1 ',
  13182. 'asArray' => true
  13183. ) );
  13184. foreach ( $receiptCollectList as $key => $value ) {
  13185. $receiptDetail = new receiptDetail ();
  13186. $receiptDetail->pastDate = $value ['date'];
  13187. $receiptDetail->update ( array (
  13188. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13189. ) );
  13190. }
  13191. }
  13192. function staffCollectMonthDetail() {
  13193. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13194. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13195. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13196. if (! $year)
  13197. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13198. if (! $month)
  13199. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13200. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13201. if (! $nature){
  13202. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13203. }
  13204. Doo::loadModel ( 'staff' );
  13205. $staff = new staff ();
  13206. Doo::loadModel ( "receiptDetail" );
  13207. $receiptDetail = new receiptDetail ();
  13208. Doo::loadModel ( 'accountItem' );
  13209. $accountItem = new accountItem ();
  13210. Doo::loadModel ( 'statistics' );
  13211. $statistics = new statistics ();
  13212. Doo::loadModel ( "receiptAuthorityManage" );
  13213. $receiptAuthorityManage = new receiptAuthorityManage ();
  13214. $aiList=$accountItem->getAccountItem();
  13215. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13216. $cidList = array ();
  13217. foreach ( $imcStaff as $key => $value ) {
  13218. array_push ( $cidList, $value ['cid'] );
  13219. }
  13220. $cidString = implode ( ',', $cidList );
  13221. $naturecon='';
  13222. if ($nature=='ONJOB'){
  13223. $naturecon=' and (nature!=4 )';
  13224. }elseif($nature=='LEAVEJOB'){
  13225. $naturecon=' and (nature=4 )';
  13226. }else{
  13227. die ( 'illegal request--nature' );
  13228. }
  13229. $staffList = $staff->find ( array (
  13230. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13231. 'asArray' => true
  13232. ) );
  13233. $categoryList = $staff->find ( array (
  13234. 'select' => 'COUNT(*) as count,cid,category',
  13235. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13236. 'groupby' => 'cid',
  13237. 'asArray' => true
  13238. ) );
  13239. $list = array ();
  13240. foreach($aiList as $key=>$value){
  13241. foreach ($value as $v){
  13242. $subtotal[$key][$v['name']]=0;
  13243. }
  13244. }
  13245. foreach ( $categoryList as $vlu ) {
  13246. $s1 = 0;
  13247. $m1 = 0;
  13248. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13249. foreach ( $staffList as $value ) {
  13250. if ($vlu ['cid'] == $value ['cid']) {
  13251. // pastDate
  13252. $receiptCollectList = $receiptDetail->find ( array (
  13253. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13254. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13255. 'groupby' => 'item,Month(pastDate),itemCategory',
  13256. 'asArray' => true
  13257. ) );
  13258. if (! empty ( $receiptCollectList )) {
  13259. $receiptL = array (
  13260. '日常相关费用' => array (),
  13261. '差旅相关费用' => array (),
  13262. '内部培训费用' => array (),
  13263. '培训班费用' => array (),
  13264. '其他' => array ()
  13265. );
  13266. $html = "";
  13267. $psum = 0;
  13268. foreach ( $aiList[$this->AGENCY] as $va ) {
  13269. $falg = true;
  13270. foreach ( $receiptCollectList as $v ) {
  13271. if ($v ['itemCategory'] == '日常相关费用') {
  13272. if ($v ['item'] == $va['name']) {
  13273. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13274. $psum += $v ['price'];
  13275. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13276. $falg = false;
  13277. break;
  13278. }
  13279. }
  13280. }
  13281. if ($falg)
  13282. $html .= '<td class="taR">-</td>';
  13283. }
  13284. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13285. if (! empty ( $psum ))
  13286. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13287. else
  13288. $psum = '<td class="colGreen taR">-</td>';
  13289. $receiptL ['日常相关费用'] = $psum . $html;
  13290. /* ----------------------------------- */
  13291. $html = "";
  13292. $psum = 0;
  13293. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13294. $falg = true;
  13295. foreach ( $receiptCollectList as $v ) {
  13296. if ($v ['itemCategory'] == '差旅相关费用') {
  13297. if ($v ['item'] == $va['name']) {
  13298. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13299. $psum += $v ['price'];
  13300. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13301. $falg = false;
  13302. break;
  13303. }
  13304. }
  13305. }
  13306. if ($falg)
  13307. $html .= '<td class="taR">-</td>';
  13308. }
  13309. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13310. if (! empty ( $psum ))
  13311. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13312. else
  13313. $psum = '<td class="colGreen taR">-</td>';
  13314. $receiptL ['差旅相关费用'] = $psum . $html;
  13315. /* ------------------------------------- */
  13316. $html = "";
  13317. $psum = 0;
  13318. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13319. $falg = true;
  13320. foreach ( $receiptCollectList as $v ) {
  13321. if ($v ['itemCategory'] == '内部培训费用') {
  13322. if ($v ['item'] == $va['name']) {
  13323. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13324. $psum += $v ['price'];
  13325. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13326. $falg = false;
  13327. break;
  13328. }
  13329. }
  13330. }
  13331. if ($falg)
  13332. $html .= '<td class="taR">-</td>';
  13333. }
  13334. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13335. if (! empty ( $psum ))
  13336. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13337. else
  13338. $psum = '<td class="colGreen taR">-</td>';
  13339. $receiptL ['内部培训费用'] = $psum . $html;
  13340. /* ----------------------------------- */
  13341. $html = "";
  13342. $psum = 0;
  13343. foreach ( $aiList[$this->TRAIN] as $va ) {
  13344. $falg = true;
  13345. foreach ( $receiptCollectList as $v ) {
  13346. if ($v ['itemCategory'] == '培训班费用') {
  13347. if ($v ['item'] == $va['name']) {
  13348. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13349. $psum += $v ['price'];
  13350. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13351. $falg = false;
  13352. break;
  13353. }
  13354. }
  13355. }
  13356. if ($falg)
  13357. $html .= '<td class="taR">-</td>';
  13358. }
  13359. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13360. if (! empty ( $psum ))
  13361. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13362. else
  13363. $psum = '<td class="colGreen taR">-</td>';
  13364. $receiptL ['培训班费用'] = $psum . $html;
  13365. /* ------------------------------------- */
  13366. $html = "";
  13367. $psum = 0;
  13368. foreach ( $aiList[$this->OTHER] as $va ) {
  13369. $falg = true;
  13370. foreach ( $receiptCollectList as $v ) {
  13371. if ($v ['itemCategory'] == '其他') {
  13372. if (trim ( $v ['item'] ) == $va['name']) {
  13373. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13374. $psum += $v ['price'];
  13375. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13376. $falg = false;
  13377. break;
  13378. }
  13379. }
  13380. }
  13381. if ($falg)
  13382. $html .= '<td class="taR">-</td>';
  13383. }
  13384. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13385. if (! empty ( $psum ))
  13386. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13387. else
  13388. $psum = '<td class="colGreen taR">-</td>';
  13389. $receiptL ['其他'] = $psum . $html;
  13390. /* ------------------------------------- */
  13391. $html = "";
  13392. $psum = 0;
  13393. foreach ( $receiptCollectList as $v ) {
  13394. if ($v ['itemCategory'] == '报销金额调整') {
  13395. if (! empty ( $v ['price'] )) {
  13396. $psum += $v ['price'];
  13397. }
  13398. }
  13399. }
  13400. $s1 += $psum;
  13401. if (! empty ( $psum ))
  13402. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13403. else
  13404. $psum = '<td class="taR colOrange">-</td>';
  13405. $receiptL ['报销金额调整'] = $psum . $html;
  13406. } else {
  13407. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13408. foreach ( $aiList[$this->AGENCY] as $va ) {
  13409. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13410. }
  13411. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13412. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13413. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13414. }
  13415. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13416. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13417. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13418. }
  13419. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13420. foreach ( $aiList[$this->TRAIN] as $va ) {
  13421. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13422. }
  13423. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13424. foreach ( $aiList[$this->OTHER] as $va ) {
  13425. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13426. }
  13427. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13428. }
  13429. $monthStaffPrice = $receiptDetail->find ( array (
  13430. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13431. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13432. 'groupby' => 'Month(pastDate)',
  13433. 'asArray' => true
  13434. ) );
  13435. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13436. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13437. $m1 += $monthStaffPrice [0] ['price'];
  13438. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13439. } else
  13440. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13441. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13442. $list [$value ['username']] = $receiptL;
  13443. }
  13444. }
  13445. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13446. foreach ( $aiList[$this->AGENCY] as $va ) {
  13447. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13448. $subtotal[$this->AGENCY][$va['name']]=0;
  13449. }
  13450. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13451. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13452. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13453. $subtotal[$this->TRAVEL][$va['name']]=0;
  13454. }
  13455. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13456. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13457. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13458. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13459. }
  13460. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13461. foreach ( $aiList[$this->TRAIN] as $va ) {
  13462. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13463. $subtotal[$this->TRAIN][$va['name']]=0;
  13464. }
  13465. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13466. foreach ( $aiList[$this->OTHER] as $va ) {
  13467. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13468. $subtotal[$this->OTHER][$va['name']]=0;
  13469. }
  13470. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13471. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13472. $receiptL ['usernameEn'] =false;
  13473. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13474. }
  13475. $data ['list'] = $list;
  13476. // print_r($list);
  13477. $receiptCollectList = $receiptDetail->find ( array (
  13478. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13479. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13480. 'groupby' => 'item,Month(pastDate),itemCategory',
  13481. 'asArray' => true
  13482. ) );
  13483. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13484. // statistics html
  13485. $stList = $statistics->getOne ( array (
  13486. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13487. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13488. 'groupby' => 'Month(date)',
  13489. 'asArray' => true
  13490. ) );
  13491. if (empty ( $stList ))
  13492. $stList = array (
  13493. 'rePrice' => 0,
  13494. 'agPrice' => 0
  13495. );
  13496. $data ['stList'] = array (
  13497. 'rePrice' => $stList ['rePrice'],
  13498. 'agPrice' => $stList ['agPrice'],
  13499. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13500. );
  13501. $monthHtml = "";
  13502. for($i = 1; $i <= 12; $i ++) {
  13503. if ($i == $month)
  13504. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13505. else
  13506. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13507. }
  13508. $data ['monthHtml'] = $monthHtml;
  13509. $data ['year'] = $year;
  13510. $data ['month'] = $month;
  13511. $data ['nature'] = $nature;
  13512. $data ['aiList'] = $aiList;
  13513. $data ['memu'] = "receipt";
  13514. $data ['staff'] = $this->staff;
  13515. $data ['receiptMemu'] = 'companyCategoryCollect';
  13516. $data ['verifyId'] = $this->verifyId;
  13517. $data ['executeId'] = $this->executeId;
  13518. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13519. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13520. }
  13521. function staffCollectMonthDetail2() {
  13522. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13523. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13524. if (! $year)
  13525. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13526. if (! $month)
  13527. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13528. Doo::loadModel ( 'staff' );
  13529. $staff = new staff ();
  13530. Doo::loadModel ( "receiptDetail" );
  13531. $receiptDetail = new receiptDetail ();
  13532. Doo::loadModel ( 'accountItem' );
  13533. $accountItem = new accountItem ();
  13534. Doo::loadModel ( 'statistics' );
  13535. $statistics = new statistics ();
  13536. Doo::loadModel ( 'L_category' );
  13537. $lCategory = new L_category ();
  13538. $staffList = $staff->find ( array (
  13539. 'where' => 'username!="admin"',
  13540. 'asArray' => true
  13541. ) );
  13542. $categoryList = $staff->find ( array (
  13543. 'select' => 'COUNT(*) as count,cid,category',
  13544. 'where' => 'username !="admin"',
  13545. 'groupby' => 'cid',
  13546. 'asArray' => true
  13547. ) );
  13548. $list = array ();
  13549. foreach ( $categoryList as $vlu ) {
  13550. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13551. $r1 = 0;
  13552. $r2 = 0;
  13553. $r3 = 0;
  13554. $r4 = 0;
  13555. $r5 = 0;
  13556. $r6 = 0;
  13557. $r7 = 0;
  13558. $r8 = 0;
  13559. $r9 = 0;
  13560. $r10 = 0;
  13561. $r11 = 0;
  13562. $r12 = 0;
  13563. $r13 = 0;
  13564. $r14 = 0;
  13565. $r15 = 0;
  13566. $c1 = 0;
  13567. $c2 = 0;
  13568. $c3 = 0;
  13569. $c4 = 0;
  13570. $c5 = 0;
  13571. $c6 = 0;
  13572. $p1 = 0;
  13573. $p2 = 0;
  13574. $p3 = 0;
  13575. $p4 = 0;
  13576. $p5 = 0;
  13577. $p6 = 0;
  13578. $p7 = 0;
  13579. $p8 = 0;
  13580. $p9 = 0;
  13581. $t1 = 0;
  13582. $t2 = 0;
  13583. $t3 = 0;
  13584. $t4 = 0;
  13585. $t5 = 0;
  13586. $s1 = 0;
  13587. $m1 = 0;
  13588. foreach ( $staffList as $value ) {
  13589. if ($vlu ['cid'] == $value ['cid']) {
  13590. $receiptCollectList = $receiptDetail->find ( array (
  13591. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13592. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13593. 'groupby' => 'item,Month(date),itemCategory',
  13594. 'asArray' => true
  13595. ) );
  13596. if (! empty ( $receiptCollectList )) {
  13597. $receiptL = array (
  13598. '日常相关费用' => array (),
  13599. '差旅相关费用' => array (),
  13600. '培训班费用' => array (),
  13601. '其他' => array ()
  13602. );
  13603. $html = "";
  13604. $psum = 0;
  13605. $item = array (
  13606. '市内交通费',
  13607. '市内出租费',
  13608. '办事处房租',
  13609. '电话费',
  13610. '水费',
  13611. '电费',
  13612. '办公费用',
  13613. '邮寄费',
  13614. '其他费用',
  13615. '车辆费用',
  13616. '广告费',
  13617. '团队建设费',
  13618. '物业管理费',
  13619. '宽带费'
  13620. );
  13621. foreach ( $item as $va ) {
  13622. $falg = true;
  13623. foreach ( $receiptCollectList as $v ) {
  13624. if ($v ['itemCategory'] == '日常相关费用') {
  13625. if ($v ['item'] == $va) {
  13626. if ($va == '市内交通费')
  13627. $r1 += $v ['price'];
  13628. if ($va == '市内出租费')
  13629. $r2 += $v ['price'];
  13630. if ($va == '办事处房租')
  13631. $r3 += $v ['price'];
  13632. if ($va == '电话费')
  13633. $r4 += $v ['price'];
  13634. if ($va == '水费')
  13635. $r5 += $v ['price'];
  13636. if ($va == '电费')
  13637. $r6 += $v ['price'];
  13638. if ($va == '办公费用')
  13639. $r7 += $v ['price'];
  13640. if ($va == '邮寄费')
  13641. $r8 += $v ['price'];
  13642. if ($va == '其他费用')
  13643. $r9 += $v ['price'];
  13644. if ($va == '车辆费用')
  13645. $r10 += $v ['price'];
  13646. if ($va == '广告费')
  13647. $r11 += $v ['price'];
  13648. if ($va == '团队建设费')
  13649. $r13 += $v ['price'];
  13650. if ($va == '物业管理费')
  13651. $r14 += $v ['price'];
  13652. if ($va == '宽带费')
  13653. $r15 += $v ['price'];
  13654. $psum += $v ['price'];
  13655. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13656. $falg = false;
  13657. break;
  13658. }
  13659. }
  13660. }
  13661. if ($falg)
  13662. $html .= '<td class="taR">-</td>';
  13663. }
  13664. $r12 += $psum;
  13665. if (! empty ( $psum ))
  13666. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13667. else
  13668. $psum = '<td class="colGreen taR">-</td>';
  13669. $receiptL ['日常相关费用'] = $psum . $html;
  13670. /* ----------------------------------- */
  13671. $html = "";
  13672. $psum = 0;
  13673. $item = array (
  13674. '往来交通费',
  13675. '市内交通费',
  13676. '出差住宿费',
  13677. '出差补助',
  13678. '其他费用'
  13679. );
  13680. foreach ( $item as $va ) {
  13681. $falg = true;
  13682. foreach ( $receiptCollectList as $v ) {
  13683. if ($v ['itemCategory'] == '差旅相关费用') {
  13684. if ($v ['item'] == $va) {
  13685. if ($va == '往来交通费')
  13686. $c1 += $v ['price'];
  13687. if ($va == '市内交通费')
  13688. $c2 += $v ['price'];
  13689. if ($va == '出差住宿费')
  13690. $c3 += $v ['price'];
  13691. if ($va == '出差补助')
  13692. $c4 += $v ['price'];
  13693. if ($va == '其他费用')
  13694. $c5 += $v ['price'];
  13695. $psum += $v ['price'];
  13696. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13697. $falg = false;
  13698. break;
  13699. }
  13700. }
  13701. }
  13702. if ($falg)
  13703. $html .= '<td class="taR">-</td>';
  13704. }
  13705. $c6 += $psum;
  13706. if (! empty ( $psum ))
  13707. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13708. else
  13709. $psum = '<td class="colGreen taR">-</td>';
  13710. $receiptL ['差旅相关费用'] = $psum . $html;
  13711. /* ------------------------------------- */
  13712. $html = "";
  13713. $psum = 0;
  13714. $item = array (
  13715. '场租费',
  13716. '薪酬',
  13717. '住宿费',
  13718. '交通费',
  13719. '餐饮费',
  13720. '办公费',
  13721. '公关费',
  13722. '其他'
  13723. );
  13724. foreach ( $item as $va ) {
  13725. $falg = true;
  13726. foreach ( $receiptCollectList as $v ) {
  13727. if ($v ['itemCategory'] == '培训班费用') {
  13728. if ($v ['item'] == $va) {
  13729. if ($va == '场租费')
  13730. $p1 += $v ['price'];
  13731. if ($va == '薪酬')
  13732. $p2 += $v ['price'];
  13733. if ($va == '住宿费')
  13734. $p3 += $v ['price'];
  13735. if ($va == '交通费')
  13736. $p4 += $v ['price'];
  13737. if ($va == '餐饮费')
  13738. $p5 += $v ['price'];
  13739. if ($va == '办公费')
  13740. $p6 += $v ['price'];
  13741. if ($va == '公关费')
  13742. $p7 += $v ['price'];
  13743. if ($va == '其他')
  13744. $p8 += $v ['price'];
  13745. $psum += $v ['price'];
  13746. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13747. $falg = false;
  13748. break;
  13749. }
  13750. }
  13751. }
  13752. if ($falg)
  13753. $html .= '<td class="taR">-</td>';
  13754. }
  13755. $p9 += $psum;
  13756. if (! empty ( $psum ))
  13757. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13758. else
  13759. $psum = '<td class="colGreen taR">-</td>';
  13760. $receiptL ['培训班费用'] = $psum . $html;
  13761. /* ------------------------------------- */
  13762. $html = "";
  13763. $psum = 0;
  13764. $item = array (
  13765. '公关费',
  13766. '广告费',
  13767. '借款',
  13768. '可自加费用'
  13769. );
  13770. foreach ( $item as $va ) {
  13771. $falg = true;
  13772. foreach ( $receiptCollectList as $v ) {
  13773. if ($v ['itemCategory'] == '其他') {
  13774. if ($v ['item'] == $va) {
  13775. if ($va == '公关费')
  13776. $t1 += $v ['price'];
  13777. if ($va == '广告费')
  13778. $t2 += $v ['price'];
  13779. if ($va == '借款')
  13780. $t3 += $v ['price'];
  13781. if ($va == '可自加费用')
  13782. $t4 += $v ['price'];
  13783. $psum += $v ['price'];
  13784. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13785. $falg = false;
  13786. break;
  13787. }
  13788. }
  13789. }
  13790. if ($falg)
  13791. $html .= '<td class="taR">-</td>';
  13792. }
  13793. $t5 += $psum;
  13794. if (! empty ( $psum ))
  13795. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13796. else
  13797. $psum = '<td class="colGreen taR">-</td>';
  13798. $receiptL ['其他'] = $psum . $html;
  13799. /* ------------------------------------- */
  13800. $html = "";
  13801. $psum = 0;
  13802. foreach ( $receiptCollectList as $v ) {
  13803. if ($v ['itemCategory'] == '报销金额调整') {
  13804. if (! empty ( $v ['price'] )) {
  13805. $psum += $v ['price'];
  13806. }
  13807. }
  13808. }
  13809. $s1 += $psum;
  13810. if (! empty ( $psum ))
  13811. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13812. else
  13813. $psum = '<td class="taR colOrange">-</td>';
  13814. $receiptL ['报销金额调整'] = $psum . $html;
  13815. } else {
  13816. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13817. <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>';
  13818. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13819. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13820. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13821. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13822. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13823. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13824. }
  13825. $monthStaffPrice = $receiptDetail->find ( array (
  13826. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13827. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13828. 'asArray' => true
  13829. ) );
  13830. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13831. $m1 += $monthStaffPrice [0] ['price'];
  13832. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13833. } else
  13834. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13835. $list [$value ['username']] = $receiptL;
  13836. }
  13837. }
  13838. $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>
  13839. <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>
  13840. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13841. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13842. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13843. $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>
  13844. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13845. $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>';
  13846. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13847. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13848. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13849. }
  13850. $data ['list'] = $list;
  13851. $receiptCollectList = $receiptDetail->find ( array (
  13852. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13853. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13854. 'groupby' => 'item,Month(date),itemCategory',
  13855. 'asArray' => true
  13856. ) );
  13857. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13858. // statistics html
  13859. $stList = $statistics->getOne ( array (
  13860. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13861. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13862. 'groupby' => 'Month(date)',
  13863. 'asArray' => true
  13864. ) );
  13865. if (empty ( $stList ))
  13866. $stList = array (
  13867. 'rePrice' => 0,
  13868. 'agPrice' => 0
  13869. );
  13870. $data ['stList'] = array (
  13871. 'rePrice' => $stList ['rePrice'],
  13872. 'agPrice' => $stList ['agPrice'],
  13873. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13874. );
  13875. $monthHtml = "";
  13876. for($i = 1; $i <= 12; $i ++) {
  13877. if ($i == $month)
  13878. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13879. else
  13880. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13881. }
  13882. $data ['monthHtml'] = $monthHtml;
  13883. $data ['year'] = $year;
  13884. $data ['month'] = $month;
  13885. $data ['memu'] = "receipt";
  13886. $data ['staff'] = $this->staff;
  13887. $data ['receiptMemu'] = 'companyCategoryCollect';
  13888. $data ['verifyId'] = $this->verifyId;
  13889. $data ['executeId'] = $this->executeId;
  13890. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13891. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13892. }
  13893. /**
  13894. * 用户报销单列表
  13895. */
  13896. function receiptStatisticsStaffDetail() {
  13897. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13898. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13899. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13900. Doo::loadModel ( "receipt" );
  13901. $receipt = new receipt ();
  13902. Doo::loadModel ( "receiptDetail" );
  13903. $receiptDetail = new receiptDetail ();
  13904. Doo::loadModel ( 'staff' );
  13905. $staff = new staff ();
  13906. Doo::loadModel ( 'accountItem' );
  13907. $accountItem = new accountItem ();
  13908. Doo::loadModel ( 'statistics' );
  13909. $statistics = new statistics ();
  13910. if (! empty ( $username )) {
  13911. $username = addslashes ( urldecode ( $username ) );
  13912. $staffDetail = $staff->getStaffByName ( $username );
  13913. if (empty ( $staffDetail ))
  13914. die ( 'illegal request' );
  13915. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13916. $itemList = $accountItem->getAccountItem ();
  13917. $itemHtml = '';
  13918. $categoryHtml = '';
  13919. $itemKeyList = array_keys ( $itemList );
  13920. $revisePrice = 0;
  13921. // 报销单内容详情
  13922. foreach ( $list as $key => $value ) {
  13923. $accountItemList = json_decode ( $value ['accountItem'], true );
  13924. $list [$key] ['accountItemList'] = $accountItemList;
  13925. $receiptItemHtml = '';
  13926. foreach ( $itemKeyList as $v ) {
  13927. if ($v == '日常相关费用')
  13928. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13929. elseif ($v == '差旅相关费用')
  13930. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13931. elseif ($v == '培训班费用')
  13932. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13933. elseif ($v == '内部培训费用'){
  13934. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13935. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13936. }else{
  13937. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13938. }
  13939. }elseif ($v == '其他')
  13940. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13941. foreach ( $itemList [$v] as $ke => $va ) {
  13942. $falg = true;
  13943. if (! empty ( $accountItemList [$v] )) {
  13944. foreach ( $accountItemList [$v] as $ve ) {
  13945. if ($va ['name'] == $ve ['name']) {
  13946. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13947. $falg = false;
  13948. break;
  13949. }
  13950. }
  13951. }
  13952. if ($falg)
  13953. $receiptItemHtml .= '<td class="taR"></td>';
  13954. }
  13955. }
  13956. // 金额调整和费用查看
  13957. $revisePrice += $value ['revisePrice'];
  13958. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13959. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13960. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13961. }
  13962. // 报销单合计
  13963. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13964. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13965. $receiptTotalHtml = '';
  13966. // 报销单项目抬头
  13967. foreach ( $itemKeyList as $value ) {
  13968. $count = count ( $itemList [$value] ) + 1;
  13969. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13970. $categoryHtml .= '<th class="taC">合计</th>';
  13971. $sumfalg=true;
  13972. foreach ( $rtl as $rtlValue ) {
  13973. if ($rtlValue ['itemCategory'] == $value) {
  13974. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13975. $sumfalg=false;
  13976. break;
  13977. }
  13978. }
  13979. if ($sumfalg)
  13980. $receiptTotalHtml .= '<th></th>';
  13981. foreach ( $itemList [$value] as $k => $v ) {
  13982. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13983. // 合计
  13984. $falg = true;
  13985. foreach ( $receiptTotalList as $ve ) {
  13986. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13987. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13988. $falg = false;
  13989. break;
  13990. }
  13991. }
  13992. if ($falg)
  13993. $receiptTotalHtml .= '<th></th>';
  13994. }
  13995. }
  13996. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13997. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13998. if (empty ( $stList ))
  13999. $stList = array (
  14000. 'rePrice' => 0,
  14001. 'agPrice' => 0
  14002. );
  14003. $data ['stList'] = array (
  14004. 'rePrice' => $stList ['rePrice'],
  14005. 'agPrice' => $stList ['agPrice'],
  14006. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14007. );
  14008. $monthHtml = "";
  14009. for($i = 1; $i <= 12; $i ++) {
  14010. if ($i == $month)
  14011. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14012. else
  14013. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14014. }
  14015. $data ['username'] = urlencode ( $username );
  14016. $data ['usernameEN'] = $username;
  14017. $data ['monthHtml'] = $monthHtml;
  14018. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  14019. $data ['list'] = $list;
  14020. $data ['categoryHtml'] = $categoryHtml;
  14021. $data ['itemHtml'] = $itemHtml;
  14022. $data ['itemList'] = $itemList;
  14023. $data ['year'] = $year;
  14024. $data ['month'] = $month;
  14025. $data ['memu'] = "receipt";
  14026. $data ['staff'] = $this->staff;
  14027. $data ['receiptMemu'] = 'companyCategoryCollect';
  14028. $data ['verifyId'] = $this->verifyId;
  14029. $data ['executeId'] = $this->executeId;
  14030. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  14031. }
  14032. die ( 'illegal request' );
  14033. }
  14034. function companyMonthCollectDetail() {
  14035. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  14036. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14037. if (! $year)
  14038. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  14039. if (! $month)
  14040. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  14041. Doo::loadModel ( 'staff' );
  14042. $staff = new staff ();
  14043. Doo::loadModel ( "receiptDetail" );
  14044. $receiptDetail = new receiptDetail ();
  14045. Doo::loadModel ( 'accountItem' );
  14046. $accountItem = new accountItem ();
  14047. Doo::loadModel ( 'statistics' );
  14048. $statistics = new statistics ();
  14049. Doo::loadModel ( 'L_category' );
  14050. $lCategory = new L_category ();
  14051. $staffList = $staff->find ( array (
  14052. 'where' => 'username!="admin"',
  14053. 'asArray' => true
  14054. ) );
  14055. $categoryList = $lCategory->find ( array (
  14056. 'asArray' => true
  14057. ) );
  14058. $aiList=$accountItem->getAccountItem();
  14059. $list = array ();
  14060. foreach ( $categoryList as $value ) {
  14061. $receiptCollectList = $receiptDetail->find ( array (
  14062. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14063. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14064. 'groupby' => 'item,Month(pastDate),itemCategory',
  14065. 'asArray' => true
  14066. ) );
  14067. if (! empty ( $receiptCollectList )) {
  14068. $receiptL = array (
  14069. '日常相关费用' => array (),
  14070. '差旅相关费用' => array (),
  14071. '内部培训费用' => array (),
  14072. '培训班费用' => array (),
  14073. '其他' => array ()
  14074. );
  14075. $html = "";
  14076. $psum = 0;
  14077. foreach ( $aiList[$this->AGENCY] as $va ) {
  14078. $falg = true;
  14079. foreach ( $receiptCollectList as $v ) {
  14080. if ($v ['itemCategory'] == $this->AGENCY) {
  14081. if ($v ['item'] == $va['name']) {
  14082. $psum += $v ['price'];
  14083. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14084. $falg = false;
  14085. break;
  14086. }
  14087. }
  14088. }
  14089. if ($falg)
  14090. $html .= '<td class="taR">-</td>';
  14091. }
  14092. if (! empty ( $psum ))
  14093. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14094. else
  14095. $psum = '<td class="colGreen taR">-</td>';
  14096. $receiptL [$this->AGENCY] = $psum . $html;
  14097. /* ----------------------------------- */
  14098. $html = "";
  14099. $psum = 0;
  14100. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14101. $falg = true;
  14102. foreach ( $receiptCollectList as $v ) {
  14103. if ($v ['itemCategory'] == $this->TRAVEL) {
  14104. if ($v ['item'] == $va['name']) {
  14105. $psum += $v ['price'];
  14106. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14107. $falg = false;
  14108. break;
  14109. }
  14110. }
  14111. }
  14112. if ($falg)
  14113. $html .= '<td class="taR">-</td>';
  14114. }
  14115. if (! empty ( $psum ))
  14116. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14117. else
  14118. $psum = '<td class="colGreen taR">-</td>';
  14119. $receiptL [$this->TRAVEL] = $psum . $html;
  14120. /* ------------------------------------- */
  14121. $html = "";
  14122. $psum = 0;
  14123. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14124. $falg = true;
  14125. foreach ( $receiptCollectList as $v ) {
  14126. if ($v ['itemCategory'] == $this->INTTRAIN) {
  14127. if ($v ['item'] == $va['name']) {
  14128. $psum += $v ['price'];
  14129. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14130. $falg = false;
  14131. break;
  14132. }
  14133. }
  14134. }
  14135. if ($falg)
  14136. $html .= '<td class="taR">-</td>';
  14137. }
  14138. if (! empty ( $psum ))
  14139. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14140. else
  14141. $psum = '<td class="colGreen taR">-</td>';
  14142. $receiptL [$this->INTTRAIN] = $psum . $html;
  14143. /* ------------------------------------- */
  14144. $html = "";
  14145. $psum = 0;
  14146. foreach ( $aiList[$this->TRAIN] as $va ) {
  14147. $falg = true;
  14148. foreach ( $receiptCollectList as $v ) {
  14149. if ($v ['itemCategory'] == $this->TRAIN) {
  14150. if ($v ['item'] == $va['name']) {
  14151. $psum += $v ['price'];
  14152. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14153. $falg = false;
  14154. break;
  14155. }
  14156. }
  14157. }
  14158. if ($falg)
  14159. $html .= '<td class="taR">-</td>';
  14160. }
  14161. if (! empty ( $psum ))
  14162. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14163. else
  14164. $psum = '<td class="colGreen taR">-</td>';
  14165. $receiptL [$this->TRAIN] = $psum . $html;
  14166. /* ------------------------------------- */
  14167. $html = "";
  14168. $psum = 0;
  14169. foreach ( $aiList[$this->OTHER] as $va ) {
  14170. $falg = true;
  14171. foreach ( $receiptCollectList as $v ) {
  14172. if ($v ['itemCategory'] == $this->OTHER) {
  14173. if ($v ['item'] == $va['name']) {
  14174. $psum += $v ['price'];
  14175. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14176. $falg = false;
  14177. break;
  14178. }
  14179. }
  14180. }
  14181. if ($falg)
  14182. $html .= '<td class="taR">-</td>';
  14183. }
  14184. if (! empty ( $psum ))
  14185. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14186. else
  14187. $psum = '<td class="colGreen taR">-</td>';
  14188. $receiptL [$this->OTHER] = $psum . $html;
  14189. /* ------------------------------------- */
  14190. $html = "";
  14191. $psum = 0;
  14192. foreach ( $receiptCollectList as $v ) {
  14193. if ($v ['itemCategory'] == '报销金额调整') {
  14194. if (! empty ( $v ['price'] ))
  14195. $psum += $v ['price'];
  14196. }
  14197. }
  14198. if (! empty ( $psum ))
  14199. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14200. else
  14201. $psum = '<td class="taR colOrange">-</td>';
  14202. $receiptL ['报销金额调整'] = $psum . $html;
  14203. } else {
  14204. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14205. foreach ( $aiList[$this->AGENCY] as $va ) {
  14206. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14207. }
  14208. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14209. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14210. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14211. }
  14212. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14213. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14214. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14215. }
  14216. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14217. foreach ( $aiList[$this->TRAIN] as $va ) {
  14218. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14219. }
  14220. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14221. foreach ( $aiList[$this->OTHER] as $va ) {
  14222. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14223. }
  14224. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14225. }
  14226. $monthStaffPrice = $receiptDetail->find ( array (
  14227. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14228. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14229. 'asArray' => true
  14230. ) );
  14231. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14232. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14233. else
  14234. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14235. $list [$value ['title']] = $receiptL;
  14236. }
  14237. $data ['list'] = $list;
  14238. $receiptCollectList = $receiptDetail->find ( array (
  14239. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14240. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14241. 'groupby' => 'item,Month(pastDate),itemCategory',
  14242. 'asArray' => true
  14243. ) );
  14244. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14245. //print_r($data['monthPriceHtml']);
  14246. // foreach ($data['monthPriceHtml'] as $value){
  14247. // echo $value;
  14248. // }
  14249. // die;
  14250. // statistics html
  14251. $stList = $statistics->getOne ( array (
  14252. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14253. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14254. 'groupby' => 'Month(date)',
  14255. 'asArray' => true
  14256. ) );
  14257. if (empty ( $stList ))
  14258. $stList = array (
  14259. 'rePrice' => 0,
  14260. 'agPrice' => 0
  14261. );
  14262. $data ['stList'] = array (
  14263. 'rePrice' => $stList ['rePrice'],
  14264. 'agPrice' => $stList ['agPrice'],
  14265. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14266. );
  14267. $monthHtml = "";
  14268. for($i = 1; $i <= 12; $i ++) {
  14269. if ($i == $month)
  14270. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14271. else
  14272. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14273. }
  14274. $data ['aiList'] = $aiList;
  14275. $dateHtml = "";
  14276. $now = date ( "Y" );
  14277. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14278. if ($YEARD <= $now) {
  14279. $dateHtml .= '<option ';
  14280. if ($year == $YEARD) {
  14281. $dateHtml .= 'selected ';
  14282. }
  14283. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14284. }
  14285. }
  14286. $data ['dateHtml'] = $dateHtml;
  14287. $data ['monthHtml'] = $monthHtml;
  14288. $data ['year'] = $year;
  14289. $data ['month'] = $month;
  14290. $data ['memu'] = "receipt";
  14291. $data ['staff'] = $this->staff;
  14292. $data ['receiptMemu'] = 'companyCategoryCollect';
  14293. $data ['verifyId'] = $this->verifyId;
  14294. $data ['executeId'] = $this->executeId;
  14295. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14296. }
  14297. function staffCollectDetail() {
  14298. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14299. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14300. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14301. if (! $staffname) {
  14302. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14303. $staffname = urldecode ( $staffname );
  14304. }
  14305. Doo::loadModel ( 'staff' );
  14306. $staff = new staff ();
  14307. Doo::loadModel ( "receiptDetail" );
  14308. $receiptDetail = new receiptDetail ();
  14309. Doo::loadModel ( 'accountItem' );
  14310. $accountItem = new accountItem ();
  14311. Doo::loadModel ( 'statistics' );
  14312. $statistics = new statistics ();
  14313. Doo::loadModel ( 'L_category' );
  14314. $lCategory = new L_category ();
  14315. Doo::loadModel ( "receiptAuthorityManage" );
  14316. $receiptAuthorityManage = new receiptAuthorityManage ();
  14317. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14318. $cidList = array ();
  14319. foreach ( $imcStaff as $key => $value ) {
  14320. array_push ( $cidList, $value ['cid'] );
  14321. }
  14322. $cidString = implode ( ',', $cidList );
  14323. $staffList = $staff->find ( array (
  14324. 'where' => ' cid in (' . $cidString . ')',
  14325. 'asArray' => true
  14326. ) );
  14327. $stHtml = '';
  14328. $stTitle = "";
  14329. $staffId = 0;
  14330. $cid = 0;
  14331. $ocid = 0;
  14332. foreach ( $staffList as $value ) {
  14333. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14334. $stTitle = $value ['category'] . '-' . $value ['username'];
  14335. $staffId = $value ['sid'];
  14336. $cid = $value ['cid'];
  14337. $ocid = $value ['cid'];
  14338. if (! empty ( $value ['othercid'] ))
  14339. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14340. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14341. } elseif ($value ['username'] != 'admin')
  14342. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14343. }
  14344. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14345. 'where' => 'cid in(' . $cid . ')',
  14346. 'asArray' => true
  14347. ) );
  14348. if (empty ( $pcid ))
  14349. $pcid = $ocid;
  14350. $data ['ocid'] = $pcid;
  14351. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14352. $this->showCache ( $path );
  14353. //
  14354. $receiptCollectList = $receiptDetail->find ( array (
  14355. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14356. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14357. 'groupby' => 'item,Month(pastDate),itemCategory',
  14358. 'asArray' => true
  14359. ) );
  14360. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14361. // print_r($receiptCollectList);
  14362. $accountList = $accountItem->find ( array (
  14363. 'asArray' => true
  14364. ) );
  14365. // create CollectDetail HTML
  14366. $collectHtml = array ();
  14367. foreach ( $accountList as $key => $value ) {
  14368. $html = "";
  14369. $asum = 0;
  14370. for($i = 1; $i <= 12; $i ++) {
  14371. $falg = true;
  14372. foreach ( $receiptCollectList as $v ) {
  14373. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14374. if ($v ['item'] == '可自加费用') {
  14375. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14376. }
  14377. $asum += $v ['price'];
  14378. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14379. $falg = false;
  14380. break;
  14381. }
  14382. }
  14383. if ($falg)
  14384. $html .= '<td class="taR">-</td>';
  14385. }
  14386. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14387. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14388. }
  14389. $data ['collectHtml'] = $collectHtml;
  14390. // print_r($collectHtml);
  14391. // create Adjustment price html
  14392. $receiptCollectList = $receiptDetail->find ( array (
  14393. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14394. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14395. 'groupby' => 'itemCategory,Month(pastDate)',
  14396. 'asArray' => true
  14397. ) );
  14398. $adjustment = array ();
  14399. $collectArray = array (
  14400. '日常相关费用' => array (),
  14401. '差旅相关费用' => array (),
  14402. '培训班费用' => array (),
  14403. '内部培训费用'=>array(),
  14404. '其他' => array ()
  14405. );
  14406. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14407. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14408. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14409. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14410. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14411. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14412. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14413. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14414. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14415. array_push ( $collectArray ['其他'], $collectHtml );
  14416. $data ['collectArray'] = $collectArray;
  14417. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14418. array_push ( $adjustment, $collectHtml );
  14419. $data ['adjustment'] = $adjustment;
  14420. // total price html
  14421. $collectHtml = "";
  14422. $total = 0;
  14423. for($i = 1; $i <= 12; $i ++) {
  14424. $sumPrice = 0;
  14425. foreach ( $receiptCollectList as $key => $value ) {
  14426. if ($value ['month'] == $i) {
  14427. $sumPrice += $value ['price'];
  14428. }
  14429. }
  14430. if ($sumPrice == 0)
  14431. $collectHtml .= '<td class="taR">-</td>';
  14432. else
  14433. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14434. $total += $sumPrice;
  14435. }
  14436. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14437. // statistics html
  14438. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14439. if (empty ( $stList ))
  14440. $stList = array (
  14441. 'rePrice' => 0,
  14442. 'agPrice' => 0
  14443. );
  14444. $data ['stList'] = array (
  14445. 'rePrice' => $stList ['rePrice'],
  14446. 'agPrice' => $stList ['agPrice'],
  14447. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14448. );
  14449. $data ['totalPrice'] = $collectHtml;
  14450. $data ['totalYear'] = $total;
  14451. $data ['stHtml'] = $stHtml;
  14452. $data ['year'] = $year;
  14453. $data ['stTitle'] = $stTitle;
  14454. $data ['staffname'] = urlencode ( $staffname );
  14455. $data ['memu'] = "receipt";
  14456. $data ['staff'] = $this->staff;
  14457. $data ['receiptMemu'] = 'companyCategoryCollect';
  14458. $data ['verifyId'] = $this->verifyId;
  14459. $data ['executeId'] = $this->executeId;
  14460. if ($year < date ( "Y" )) {
  14461. Doo::loadModel ( 'receipt' );
  14462. $receipt = new receipt ();
  14463. $receiptList = $receipt->find ( array (
  14464. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14465. 'asArray' => true
  14466. ) );
  14467. if (empty ( $receiptList )) { // generated files
  14468. ob_start ();
  14469. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14470. $this->cacheFile ( $path );
  14471. die ();
  14472. }
  14473. }
  14474. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14475. }
  14476. function BUGFLAG() {
  14477. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14478. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14479. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14480. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14481. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14482. if (empty ( $status ))
  14483. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14484. $page_size = 12;
  14485. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14486. $vidList = array ();
  14487. $button = 0;
  14488. Doo::loadModel ( 'verify' );
  14489. $verify = new verify ();
  14490. Doo::loadModel ( 'receipt' );
  14491. $receipt = new receipt ();
  14492. Doo::loadModel ( 'staff' );
  14493. $staff = new staff ();
  14494. Doo::loadModel ( 'L_category' );
  14495. $Lcategory = new L_category ();
  14496. $dateCondition = " and Year(date) =" . $year;
  14497. if (! empty ( $month ))
  14498. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14499. $categoryList = $Lcategory->find ( array (
  14500. 'asArray' => true
  14501. ) );
  14502. $staffList = $staff->find ( array (
  14503. 'where' => 'cid=' . $cid,
  14504. 'asArray' => true
  14505. ) );
  14506. $cateCondition = "";
  14507. $staffCondition = "";
  14508. $approvalCondition = "";
  14509. if (! empty ( $cid ))
  14510. $cateCondition = ' and cid=' . $cid;
  14511. if (! empty ( $sid )) {
  14512. $staffCondition = ' and staff=' . $sid;
  14513. $cateCondition = "";
  14514. }
  14515. $approvalCondition = " and status=" . $status;
  14516. if ($status == 2) {
  14517. // 查找角色审批人
  14518. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14519. }
  14520. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14521. $approvalCondition = ' and status=2 ';
  14522. }
  14523. if ($status == 1) {
  14524. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14525. }
  14526. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14527. $pageinfo ['page'] = array (
  14528. 'previous' => ''
  14529. );
  14530. if ($status == 0) {
  14531. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14532. $receiptList = $receipt->find ( array (
  14533. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14534. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14535. 'desc' => 'rid',
  14536. 'asArray' => true
  14537. ) );
  14538. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14539. } else
  14540. $receiptList = $receipt->find ( array (
  14541. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14542. 'desc' => 'rid',
  14543. 'asArray' => true
  14544. ) );
  14545. $rLRes = $receipt->find ( array (
  14546. '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,
  14547. 'desc' => 'rid',
  14548. 'asArray' => true
  14549. ) );
  14550. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14551. // print_r($pageinfo);
  14552. $Locate = 0;
  14553. foreach ( $receiptList as $key => $value ) {
  14554. $receiptList [$key] ['Locate'] = $Locate;
  14555. $Locate ++;
  14556. $receiptList [$key] ['reviseDetail'] = array ();
  14557. if (! empty ( $value ['reviseDetail'] ))
  14558. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14559. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14560. $categoryDetil = $Lcategory->getOne ( array (
  14561. 'where' => 'cid=' . $value ['cid'],
  14562. 'asArray' => true
  14563. ) );
  14564. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14565. $verifyList = $verify->getOne ( array (
  14566. 'where' => 'vid=' . $value ['verify'],
  14567. 'asArray' => true
  14568. ) );
  14569. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14570. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14571. foreach ( $verifyList as $k => $v ) {
  14572. // init verifyStaff
  14573. $verifyList [$k] ['date'] = "";
  14574. $verifyList [$k] ['opinion'] = "";
  14575. $verifyList [$k] ['status'] = "";
  14576. if (empty ( $verifyStaff )) {
  14577. $verifyList [$k] ['date'] = "";
  14578. $verifyList [$k] ['opinion'] = "";
  14579. if ($v [0] == $this->staff [0] ['sid']) {
  14580. $verifyList [$k] ['status'] = 4;
  14581. $button = 4;
  14582. }
  14583. } else {
  14584. $flag = true;
  14585. foreach ( $verifyStaff as $m => $u ) {
  14586. if ($v [0] == $m) {
  14587. $verifyList [$k] ['date'] = $u ['date'];
  14588. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14589. $verifyList [$k] ['status'] = $u ['status'];
  14590. $flag = false;
  14591. break;
  14592. }
  14593. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14594. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14595. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14596. }
  14597. if ($flag) { // 检测可编辑
  14598. if ($v [0] == $this->staff [0] ['sid']) {
  14599. $verifyList [$k] ['status'] = 4;
  14600. $button = 4;
  14601. }
  14602. }
  14603. }
  14604. }
  14605. $receiptList [$key] ['verifyList'] = $verifyList;
  14606. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14607. 'where' => 'sid=' . $value ['staff'],
  14608. 'asArray' => true
  14609. ) );
  14610. $receiptList [$key] ['button'] = $button;
  14611. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14612. }
  14613. // print_r($receiptList);die;
  14614. // $data['verifyDetail']=$verifyDetail;
  14615. $mothHtml = "";
  14616. for($i = 1; $i <= 12; $i ++) {
  14617. if ($month == $i)
  14618. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14619. else
  14620. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14621. }
  14622. $data ['mothHtml'] = $mothHtml;
  14623. $data ['page'] = $pageinfo;
  14624. $data ['receiptList'] = $receiptList;
  14625. $data ['receiptApprovalCount'] = count ( $rLRes );
  14626. $data ['status'] = $status;
  14627. $data ['year'] = $year;
  14628. $data ['categoryList'] = $categoryList;
  14629. $data ['staffList'] = $staffList;
  14630. $data ['cid'] = $cid;
  14631. $data ['sid'] = $sid;
  14632. // print_r($receiptList);
  14633. $data ['memu'] = "receipt";
  14634. $data ['staff'] = $this->staff;
  14635. $data ['receiptMemu'] = 'approvalExpenses';
  14636. $data ['verifyId'] = $this->verifyId;
  14637. $data ['executeId'] = $this->executeId;
  14638. $this->render ( "/admin/FALG", $data );
  14639. }
  14640. function ajaxGetReceiptOrder() {
  14641. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14642. if (! empty ( $receiptOrder )) {
  14643. Doo::loadModel ( 'receipt' );
  14644. $receipt = new receipt ();
  14645. Doo::loadModel ( 'staff' );
  14646. $staff = new staff ();
  14647. $receiptInfo = $receipt->getOne ( array (
  14648. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14649. 'asArray' => true
  14650. ) );
  14651. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14652. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14653. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14654. </tbody></table><table class="table table table-bordered"><tbody>';
  14655. foreach ( $verifyStaff as $key => $value ) {
  14656. $staffInfo = $staff->getOne ( array (
  14657. 'select' => 'username',
  14658. 'where' => ' sid="' . $key . '"',
  14659. 'asArray' => true
  14660. ) );
  14661. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14662. }
  14663. $html .= '</tbody></table></div></div>';
  14664. echo json_encode ( array (
  14665. 'status' => 1,
  14666. 'receiptHtml' => $html
  14667. ) );
  14668. die ();
  14669. }
  14670. echo json_encode ( array (
  14671. 'status' => 2,
  14672. 'receiptHtml' => ''
  14673. ) );
  14674. die ();
  14675. }
  14676. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14677. if (! empty ( $receiptCollectList )) {
  14678. $receiptL = array (
  14679. '日常相关费用' => array (),
  14680. '差旅相关费用' => array (),
  14681. '内部培训费用'=>array(),
  14682. '培训班费用' => array (),
  14683. '其他' => array ()
  14684. );
  14685. $html = "";
  14686. $psum = 0;
  14687. foreach ( $aiList[$this->AGENCY] as $value ) {
  14688. $falg = true;
  14689. foreach ( $receiptCollectList as $v ) {
  14690. if ($v ['itemCategory'] == '日常相关费用') {
  14691. if ($v ['item'] == $value['name']) {
  14692. $psum += $v ['price'];
  14693. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14694. $falg = false;
  14695. break;
  14696. }
  14697. }
  14698. }
  14699. if ($falg)
  14700. $html .= '<td class="taR">-</td>';
  14701. }
  14702. if (! empty ( $psum ))
  14703. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14704. else
  14705. $psum = '<td class="colGreen taR">-</td>';
  14706. $receiptL ['日常相关费用'] = $psum . $html;
  14707. /* ----------------------------------- */
  14708. $html = "";
  14709. $psum = 0;
  14710. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14711. $falg = true;
  14712. foreach ( $receiptCollectList as $v ) {
  14713. if ($v ['itemCategory'] == '差旅相关费用') {
  14714. if ($v ['item'] == $value['name']) {
  14715. $psum += $v ['price'];
  14716. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14717. $falg = false;
  14718. break;
  14719. }
  14720. }
  14721. }
  14722. if ($falg)
  14723. $html .= '<td class="taR">-</td>';
  14724. }
  14725. if (! empty ( $psum ))
  14726. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14727. else
  14728. $psum = '<td class="colGreen taR">-</td>';
  14729. $receiptL ['差旅相关费用'] = $psum . $html;
  14730. /* ----------------------------------- */
  14731. $html = "";
  14732. $psum = 0;
  14733. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14734. $falg = true;
  14735. foreach ( $receiptCollectList as $v ) {
  14736. if ($v ['itemCategory'] == '内部培训费用') {
  14737. if ($v ['item'] == $value['name']) {
  14738. $psum += $v ['price'];
  14739. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14740. $falg = false;
  14741. break;
  14742. }
  14743. }
  14744. }
  14745. if ($falg)
  14746. $html .= '<td class="taR">-</td>';
  14747. }
  14748. if (! empty ( $psum ))
  14749. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14750. else
  14751. $psum = '<td class="colGreen taR">-</td>';
  14752. $receiptL ['内部培训费用'] = $psum . $html;
  14753. /* ------------------------------------- */
  14754. $html = "";
  14755. $psum = 0;
  14756. foreach ( $aiList[$this->TRAIN] as $value ) {
  14757. $falg = true;
  14758. foreach ( $receiptCollectList as $v ) {
  14759. if ($v ['itemCategory'] == '培训班费用') {
  14760. if ($v ['item'] == $value['name']) {
  14761. $psum += $v ['price'];
  14762. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14763. $falg = false;
  14764. break;
  14765. }
  14766. }
  14767. }
  14768. if ($falg)
  14769. $html .= '<td class="taR">-</td>';
  14770. }
  14771. if (! empty ( $psum ))
  14772. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14773. else
  14774. $psum = '<td class="colGreen taR">-</td>';
  14775. $receiptL ['培训班费用'] = $psum . $html;
  14776. /* ------------------------------------- */
  14777. $html = "";
  14778. $psum = 0;
  14779. foreach ( $aiList[$this->OTHER] as $value ) {
  14780. $falg = true;
  14781. foreach ( $receiptCollectList as $v ) {
  14782. if ($v ['itemCategory'] == '其他') {
  14783. if ($v ['item'] == $value['name']) {
  14784. $psum += $v ['price'];
  14785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14786. $falg = false;
  14787. break;
  14788. }
  14789. }
  14790. }
  14791. if ($falg)
  14792. $html .= '<td class="taR">-</td>';
  14793. }
  14794. if (! empty ( $psum ))
  14795. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14796. else
  14797. $psum = '<td class="colGreen taR">-</td>';
  14798. $receiptL ['其他'] = $psum . $html;
  14799. /* ------------------------------------- */
  14800. $html = "";
  14801. $psum = 0;
  14802. foreach ( $receiptCollectList as $v ) {
  14803. if ($v ['itemCategory'] == '报销金额调整') {
  14804. if (! empty ( $v ['price'] ))
  14805. $psum += $v ['price'];
  14806. }
  14807. }
  14808. if (! empty ( $psum ))
  14809. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14810. else
  14811. $psum = '<td class="taR colOrange">-</td>';
  14812. $receiptL ['报销金额调整'] = $psum . $html;
  14813. } else {
  14814. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14815. foreach ( $aiList[$this->AGENCY] as $va ) {
  14816. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14817. }
  14818. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14819. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14820. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14821. }
  14822. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14823. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14824. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14825. }
  14826. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14827. foreach ( $aiList[$this->TRAIN] as $va ) {
  14828. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14829. }
  14830. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14831. foreach ( $aiList[$this->OTHER] as $va ) {
  14832. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14833. }
  14834. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14835. }
  14836. return $receiptL;
  14837. }
  14838. function eMail() {
  14839. Doo::loadModel ( 'staff' );
  14840. $staff = new staff ();
  14841. Doo::loadModel ( 'receipt' );
  14842. $receipt = new receipt ();
  14843. Doo::loadModel ( 'L_category' );
  14844. $Lcategory = new L_category ();
  14845. Doo::loadModel ( "verify" );
  14846. $verify = new verify ();
  14847. $staffList = $staff->find ( array (
  14848. 'asArray' => true
  14849. ) );
  14850. foreach ( $staffList as $key => $value ) {
  14851. if ($value ['username'] != 'admin') {
  14852. // 提交人
  14853. $receiptList = $receipt->find ( array (
  14854. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14855. 'asArray' => true
  14856. ) );
  14857. if (! empty ( $receiptList )) {
  14858. $html = '<br><div><style></style>
  14859. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14860. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14861. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14862. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14863. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14864. <tbody><tr>
  14865. <td style="padding: 0 40px;" align="left">
  14866. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14867. </td></tr><tr>
  14868. <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>
  14869. </tr>
  14870. </tbody> </table></td> </tr> <tr><td>
  14871. <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">
  14872. <tbody> <tr><td>
  14873. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14874. 以下报销单完成了审批,等着收款吧:</p>
  14875. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14876. foreach ( $receiptList as $k => $v ) {
  14877. $category = $Lcategory->getOne ( array (
  14878. 'where' => 'cid=' . $v ['cid'],
  14879. 'asArray' => true
  14880. ) );
  14881. $html .= '
  14882. <tr>
  14883. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14884. <td align="left">
  14885. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14886. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14887. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14888. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14889. </tr>';
  14890. }
  14891. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14892. <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>
  14893. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14894. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14895. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14896. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14897. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14898. $receipt = new receipt ();
  14899. $receipt->notice = 1;
  14900. $receipt->update ( array (
  14901. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14902. ) );
  14903. }
  14904. }
  14905. // 审批人
  14906. $verifyList = $verify->find ( array (
  14907. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14908. 'asArray' => true
  14909. ) );
  14910. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14911. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14912. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14913. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14914. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14915. <tbody><tr><td style="padding: 0 40px;" align="left">
  14916. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14917. </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>
  14918. </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">
  14919. <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>
  14920. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14921. foreach ( $verifyList as $k => $v ) {
  14922. $receiptList = $receipt->find ( array (
  14923. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14924. 'asArray' => true
  14925. ) );
  14926. foreach ( $receiptList as $r => $l ) {
  14927. $category = $Lcategory->getOne ( array (
  14928. 'where' => 'cid=' . $l ['cid'],
  14929. 'asArray' => true
  14930. ) );
  14931. $staffDetile = $staff->getOne ( array (
  14932. 'where' => 'sid=' . $l ['staff'],
  14933. 'asArray' => true
  14934. ) );
  14935. $html .= '
  14936. <tr>
  14937. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14938. <td align="left">
  14939. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14940. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14941. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14942. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14943. </tr>';
  14944. }
  14945. }
  14946. $html .= '
  14947. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14948. <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>
  14949. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14950. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14951. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14952. // $receipt=new receipt();
  14953. // $receipt->notice=1;
  14954. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14955. }
  14956. }
  14957. }
  14958. }
  14959. function setWXMsg($rid, $type) {
  14960. Doo::loadModel ( "receipt" );
  14961. $receipt = new receipt ();
  14962. $receiptDetail = $receipt->getOne ( array (
  14963. 'where' => 'rid=' . $rid,
  14964. 'asArray' => true
  14965. ) );
  14966. if (! empty ( $receiptDetail )) {
  14967. Doo::loadModel ( 'staff' );
  14968. $staff = new staff ();
  14969. $staffmsg = $staff->getOne ( array (
  14970. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14971. 'asArray' => TRUE
  14972. ) );
  14973. if (! empty ( $staffmsg ['wxid'] )) {
  14974. require_once (SITE_PATH . '/protected/class/client.php');
  14975. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14976. $user = $staffmsg ['wxid'];
  14977. $receiptName = '';
  14978. $msg = '';
  14979. switch ($receiptDetail ['Rtype']) {
  14980. case 0 :
  14981. $receiptName = '报销';
  14982. break;
  14983. case 1 :
  14984. $receiptName = '借款';
  14985. break;
  14986. case 2 :
  14987. $receiptName = '对公汇款';
  14988. break;
  14989. }
  14990. switch ($type) {
  14991. case 1 :
  14992. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14993. break;
  14994. case 2 :
  14995. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14996. break;
  14997. case 3 :
  14998. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14999. break;
  15000. }
  15001. // $result = $client->SendMsg ( $user, $msg, 'text' );
  15002. }
  15003. }
  15004. }
  15005. // Email发送函数
  15006. function SMail($toemail, $subject, $contents) {
  15007. Doo::loadClass ( 'class.phpmailer' );
  15008. $mail = new PHPMailer ();
  15009. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  15010. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  15011. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  15012. $mail->Password = "cDO1GjtY1seH"; // 密码
  15013. $mail->CharSet = "UTF8";
  15014. $mail->SMTPAuth = true;
  15015. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  15016. $mail->Mailer = "smtp";
  15017. $mail->Port = 25;
  15018. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  15019. $mail->MsgHTML ( $contents );
  15020. $mail->AddAddress ( $toemail );
  15021. $mail->CharSet = "UTF-8";
  15022. return $mail->Send ();
  15023. }
  15024. function h5Upload() {
  15025. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  15026. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  15027. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  15028. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  15029. header ( "HTTP/1.1 500 Internal Server Error" );
  15030. echo "POST exceeded maximum allowed size.";
  15031. exit ( 0 );
  15032. }
  15033. // Settings
  15034. $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)
  15035. $upload_name = "Filedata";
  15036. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  15037. $extension_whitelist = array (
  15038. "doc",
  15039. "txt",
  15040. "jpg",
  15041. "gif",
  15042. "png"
  15043. ); // Allowed file extensions
  15044. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  15045. // Other variables
  15046. $MAX_FILENAME_LENGTH = 260;
  15047. $file_name = "";
  15048. $file_extension = "";
  15049. $uploadErrors = array (
  15050. 0 => "文件上传成功",
  15051. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  15052. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  15053. 3 => "上传的文件仅为部分文件",
  15054. 4 => "没有文件上传",
  15055. 6 => "缺少临时文件夹"
  15056. );
  15057. $nk = time ();
  15058. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  15059. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  15060. echo "文件无法保存.";
  15061. exit ( 0 );
  15062. }
  15063. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  15064. echo json_encode ( array (
  15065. 'filename' => $file_name,
  15066. 'id' => $nk
  15067. ) );
  15068. exit ( 0 );
  15069. }
  15070. function swfupload() {
  15071. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  15072. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  15073. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  15074. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  15075. header ( "HTTP/1.1 500 Internal Server Error" );
  15076. echo "POST exceeded maximum allowed size.";
  15077. exit ( 0 );
  15078. }
  15079. // Settings
  15080. $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)
  15081. $upload_name = "Filedata";
  15082. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  15083. $extension_whitelist = array (
  15084. "doc",
  15085. "txt",
  15086. "jpg",
  15087. "gif",
  15088. "png"
  15089. ); // Allowed file extensions
  15090. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  15091. // Other variables
  15092. $MAX_FILENAME_LENGTH = 260;
  15093. $file_name = "";
  15094. $file_extension = "";
  15095. $uploadErrors = array (
  15096. 0 => "文件上传成功",
  15097. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  15098. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  15099. 3 => "上传的文件仅为部分文件",
  15100. 4 => "没有文件上传",
  15101. 6 => "缺少临时文件夹"
  15102. );
  15103. $nk = time ();
  15104. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  15105. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  15106. echo "文件无法保存.";
  15107. exit ( 0 );
  15108. }
  15109. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  15110. echo json_encode ( array (
  15111. 'filename' => $file_name,
  15112. 'id' => $nk
  15113. ) );
  15114. exit ( 0 );
  15115. }
  15116. function _GetFileEXT($filename) {
  15117. $pics = explode ( '.', $filename );
  15118. $num = count ( $pics );
  15119. return $pics [$num - 1];
  15120. }
  15121. /**
  15122. * 获取get或者POST值
  15123. * @param string $name 属性名称
  15124. * @return fixed 值
  15125. */
  15126. function get_args($name) {
  15127. if (isset ( $_GET [$name] )) {
  15128. if (is_array ( $_GET [$name] ))
  15129. return $_GET [$name];
  15130. else
  15131. return addslashes ( $_GET [$name] );
  15132. } elseif (isset ( $_POST [$name] )) {
  15133. if (is_array ( $_POST [$name] ))
  15134. return $_POST [$name];
  15135. else
  15136. return addslashes ( $_POST [$name] );
  15137. } else
  15138. return false;
  15139. }
  15140. function num_to_rmb($num) {
  15141. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15142. $c2 = "分角元拾佰仟万拾佰仟亿";
  15143. // 精确到分后面就不要了,所以只留两个小数位
  15144. $num = round ( $num, 2 );
  15145. // 将数字转化为整数
  15146. $num = $num * 100;
  15147. if (strlen ( $num ) > 10) {
  15148. return "金额太大,请检查";
  15149. }
  15150. $i = 0;
  15151. $c = "";
  15152. while ( 1 ) {
  15153. if ($i == 0) {
  15154. // 获取最后一位数字
  15155. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15156. } else {
  15157. $n = $num % 10;
  15158. }
  15159. // 每次将最后一位数字转化为中文
  15160. $p1 = substr ( $c1, 3 * $n, 3 );
  15161. $p2 = substr ( $c2, 3 * $i, 3 );
  15162. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15163. $c = $p1 . $p2 . $c;
  15164. } else {
  15165. $c = $p1 . $c;
  15166. }
  15167. $i = $i + 1;
  15168. // 去掉数字最后一位了
  15169. $num = $num / 10;
  15170. // echo $num.'</br>';
  15171. $num = ( int ) $num;
  15172. // $num =floor($num);
  15173. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15174. // echo $num.'</br>';
  15175. // 结束循环
  15176. if ($num == 0) {
  15177. break;
  15178. }
  15179. }
  15180. // echo $c.'</br>';
  15181. $j = 0;
  15182. $slen = strlen ( $c );
  15183. while ( $j < $slen ) {
  15184. // utf8一个汉字相当3个字符
  15185. $m = substr ( $c, $j, 6 );
  15186. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15187. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15188. $left = substr ( $c, 0, $j );
  15189. $right = substr ( $c, $j + 3 );
  15190. $c = $left . $right;
  15191. $j = $j - 3;
  15192. $slen = $slen - 3;
  15193. }
  15194. $j = $j + 3;
  15195. }
  15196. // 这个是为了去掉类似23.0中最后一个“零”字
  15197. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15198. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15199. }
  15200. // 将处理的汉字加上“整”
  15201. if (empty ( $c )) {
  15202. return "零元整";
  15203. } else {
  15204. return $c . "整";
  15205. }
  15206. }
  15207. /**
  15208. * 获得分页数据
  15209. * @param unknown_type $table
  15210. * @param unknown_type $condition
  15211. * @param unknown_type $on_page
  15212. * @param unknown_type $page_size
  15213. */
  15214. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15215. $page_c = "";
  15216. $page ['previous'] = $this->get_previous ( $on_page );
  15217. $page ['on_page'] = $on_page;
  15218. $total_count = $this->get_table_count ( $table, $condition );
  15219. $total = intval ( $total_count / $page_size );
  15220. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15221. $page ['total_data'] = $total_count;
  15222. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15223. $i = 1;
  15224. $page_max = 1;
  15225. $page_width = 3;
  15226. if ($on_page >= $page_width) {
  15227. $page_max = intval ( $on_page / $page_width ) + 1;
  15228. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15229. }
  15230. for(; $i <= $page ['total_page']; $i ++) {
  15231. if ($i == $on_page)
  15232. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15233. else
  15234. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15235. if ($i == ($page_width * $page_max))
  15236. break;
  15237. }
  15238. $page ['page'] = $page_c;
  15239. $page ['lower'] = (-- $on_page) * $page_size;
  15240. return $page;
  15241. }
  15242. /**
  15243. * 获取总页数
  15244. * @param unknown_type $table
  15245. * @param unknown_type $condition
  15246. */
  15247. public function get_table_count($table = "", $condition = "") {
  15248. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15249. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15250. // echo $sql;die;
  15251. $query = Doo::db ()->query ( $sql );
  15252. $result = $query->fetch ();
  15253. return $result ['count'];
  15254. }
  15255. /**
  15256. * 获取上一页
  15257. * @param unknown_type $on_page
  15258. */
  15259. function get_previous($on_page = 1) {
  15260. return $on_page != 0 ? $on_page - 1 : $on_page;
  15261. }
  15262. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15263. // 收入合计
  15264. Doo::loadModel ( 'invoiceTraining' );
  15265. $invoiceTraining = new invoiceTraining ();
  15266. Doo::loadModel ( 'receipt' );
  15267. $receipt = new receipt ();
  15268. $invoiceTrainingDetail = array (
  15269. 'invoiceArriveAmount' => '0.00',
  15270. 'RIAmount' => '0.00',
  15271. 'invoiceTotalAmount' => '0.00',
  15272. 'invoiceCompanyAmount' => '0.00',
  15273. 'invoiceArriveAmountM'=>'0.00',
  15274. 'invoiceCompanyAmountM'=>'0.00'
  15275. );
  15276. if ($invoiceTrainId != 0) {
  15277. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15278. }
  15279. $invoiceArriveAmount = $RIAmount = 0;
  15280. if (! empty ( $invoiceTrainingDetail )) {
  15281. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15282. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15283. }
  15284. // 备用金
  15285. $sum = 0;
  15286. if (! empty ( $trainLoanRid )) {
  15287. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15288. foreach ($receiptLoanList as $key=>$value){
  15289. $sum+=$value['sum'];
  15290. }
  15291. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15292. // $sum = $receiptLoanDetailBak ['sum'];
  15293. }
  15294. // 支出项金额详情
  15295. // 项目金额合计
  15296. Doo::loadModel ( 'RItem' );
  15297. $RItem = new RItem ();
  15298. Doo::loadModel ( 'accountItem' );
  15299. $accountItem = new accountItem ();
  15300. // 讲师获得
  15301. Doo::loadModel ( 'RILecturer' );
  15302. $RILecturer = new RILecturer ();
  15303. $RItemList = $RItem->getRItemByRid ($rid );
  15304. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15305. // 支出项金额详情
  15306. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15307. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15308. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15309. return $payment;
  15310. }
  15311. }
  15312. ?>