ReceiptController.php 557 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. public $INTTRAIN='内部培训费用';
  15. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  16. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  17. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  18. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  19. private function showCache($path) {
  20. if (file_exists ( $path )) {
  21. echo "<!DOCTYPE html>";
  22. include $path;
  23. die ();
  24. }
  25. }
  26. private function cacheFile($path) {
  27. $content = ob_get_contents ();
  28. $fp = fopen ( $path, "w" );
  29. fwrite ( $fp, $content );
  30. fclose ( $fp );
  31. }
  32. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  33. $collectHtml = "";
  34. $sumPrice = 0.00;
  35. for($i = 1; $i <= 12; $i ++) {
  36. $falg = true;
  37. foreach ( $receiptCollectList as $key => $value ) {
  38. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  39. $sumPrice += $value ['price'];
  40. if ($classType == "b") {
  41. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  42. $falg = false;
  43. break;
  44. } else {
  45. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  46. $falg = false;
  47. break;
  48. }
  49. }
  50. }
  51. if ($falg)
  52. $collectHtml .= '<td class="taR">-</td>';
  53. }
  54. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  55. return $collectHtml;
  56. }
  57. private function _itineraryDateMin(){
  58. Doo::loadModel ( "itinerary" );
  59. $itinerary = new itinerary ();
  60. $itineraryDetail=$itinerary->getOne(array (
  61. 'where'=>'sid ='.$this->staff [0] ['sid'],
  62. 'desc'=>'itineraryDate',
  63. 'asArray' => true
  64. ));
  65. return date("Y-m-d",strtotime("+1 day",strtotime($itineraryDetail['itineraryDate'])));
  66. }
  67. public function beforeRun($resource, $action) {
  68. Doo::loadClass ( 'XDeode' );
  69. $XDeode = new XDeode ( 5 );
  70. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  71. // 单独判断公司汇总的访问权限
  72. if ($action == 'companyCategoryCollect') {
  73. Doo::loadModel ( "receiptAuthorityManage" );
  74. $invoiceCompanyManage = new receiptAuthorityManage ();
  75. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  76. if (empty ( $icm ))
  77. die ( 'illegal request-statistics' );
  78. }
  79. Doo::loadModel ( 'staff' );
  80. $staff = new staff ();
  81. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  82. $accessModular = 'RECEIPTS';
  83. if (empty ( $detail ['cldAccessArray'] ))
  84. die ( 'illegal request' );
  85. else {
  86. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  87. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  88. $flag = true;
  89. } else {
  90. $flag = false;
  91. }
  92. } else {
  93. die ( 'illegal request' );
  94. }
  95. }
  96. if (! $flag)
  97. die ( 'illegal request' );
  98. }
  99. function __construct() {
  100. if (isset ( $_COOKIE ["staff"] )) {
  101. if (! empty ( $_COOKIE ["staff"] )) {
  102. Doo::loadModel ( 'staff' );
  103. Doo::loadModel ( 'verify' );
  104. $verify = new verify ();
  105. $staff = new staff ();
  106. Doo::loadModel ( "execute" );
  107. $execute = new execute ();
  108. $verifyList = $verify->find ( array (
  109. 'select' => 'staff',
  110. 'asArray' => true
  111. ) );
  112. $list = array ();
  113. // 判断角色的审批权限
  114. foreach ( $verifyList as $key => $value ) {
  115. $ver = json_decode ( $value ['staff'] );
  116. foreach ( $ver as $k => $v ) {
  117. if ($v [1] == 'ROLE') {
  118. $roleList = json_decode ( $v [3] );
  119. foreach ( $roleList as $t => $g ) {
  120. $gList = explode ( "_", $g );
  121. array_push ( $list, $gList [0] );
  122. // print_r($list);
  123. }
  124. } else
  125. array_push ( $list, $v [0] );
  126. }
  127. }
  128. // 判断执行人的审批权限
  129. $executeList = $execute->find ( array (
  130. 'where'=>'mold !="日常收支"',
  131. 'select' => 'staff',
  132. 'asArray' => true
  133. ) );
  134. $list2 = array ();
  135. foreach ( $executeList as $key => $value ) {
  136. $ver = json_decode ( $value ['staff'] );
  137. foreach ( $ver as $k => $v ) {
  138. array_push ( $list2, $v [0] );
  139. }
  140. }
  141. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  142. $eidList = array_filter ( explode ( ",", $eidList ) );
  143. $this->executeId = array_merge ( $list2, $eidList );
  144. //print_r($this->executeId);
  145. $this->verifyId = $list;
  146. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  147. // 检测用户信息完成
  148. $this->data ['isStaffCompleteMsg'] = false;
  149. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  150. if (! empty ( $detail ))
  151. $this->data ['isStaffCompleteMsg'] = true;
  152. return "/";
  153. }
  154. }
  155. Doo::loadCore ( 'uri/DooUriRouter' );
  156. $router = new DooUriRouter ();
  157. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  158. if ($routeRs ['1'] != "login") {
  159. header ( 'Content-Type:text/html;charset=utf-8' );
  160. @header ( "Location: /login" );
  161. }
  162. }
  163. /**
  164. * 费用首页
  165. */
  166. function saeaBorad() {
  167. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  168. Doo::loadModel ( 'receipt' );
  169. $receipt = new receipt ();
  170. Doo::loadModel ( 'verify' );
  171. $verify = new verify ();
  172. Doo::loadModel ( 'L_category' );
  173. $lCategory = new L_category ();
  174. Doo::loadModel ( "role" );
  175. $role = new role ();
  176. Doo::loadModel ( "receiptLog" );
  177. $receiptLog = new receiptLog ();
  178. Doo::loadModel ( 'accountItem' );
  179. $accountItem = new accountItem ();
  180. Doo::loadClass ( 'XDeode' );
  181. $XDeode = new XDeode ( 7 );
  182. $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] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  190. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  191. $veList = $verify->getOne ( array (
  192. 'where' => 'vid=' . $value ['verify'],
  193. 'asArray' => true
  194. ) );
  195. $v = json_decode ( $veList ['staff'] );
  196. array_push ( $v [0], $veList ['description'] );
  197. foreach ( $v as $n => $m ) {
  198. if ($m ['1'] == 'ROLE') {
  199. $roleInfo = $role->getOne ( array (
  200. 'where' => 'rid=' . $m [0],
  201. 'asArray' => true
  202. ) );
  203. $v [$n] [1] = $roleInfo ['name'];
  204. }
  205. }
  206. $receiptDetail [$key] ['staff'] = $v;
  207. $category = $lCategory->getOne ( array (
  208. 'where' => 'cid=' . $value ['cid'],
  209. 'asArray' => true
  210. ) );
  211. $receiptDetail [$key] ['category'] = $category ['title'];
  212. }
  213. // print_r($receiptLogList);
  214. Doo::loadModel ( 'RAssist' );
  215. $RAssist = new RAssist ();
  216. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  217. //费用项目
  218. $acItem = $accountItem->find ( array ('asArray' => true) );
  219. if ($travel=='success'){
  220. $data ['travel'] =true;
  221. }else{
  222. $data ['travel'] =false;
  223. }
  224. $data ['acItem'] = $acItem;
  225. $data ['receiptExtendList'] = $receiptExtendList;
  226. $data ['receiptLogList'] = $receiptLogList;
  227. $data ['receiptDetail'] = $receiptDetail;
  228. $data ['memu'] = "receipt";
  229. $data ['staff'] = $this->staff;
  230. $data ['receiptMemu'] = 'saeaBorad';
  231. $data ['verifyId'] = $this->verifyId;
  232. $data ['executeId'] = $this->executeId;
  233. $this->render ( "/receipt/receiptFee", $data );
  234. }
  235. /**
  236. * 费用报销单-导流入哪个细分类
  237. */
  238. function receiptFeeDiversion(){
  239. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  240. if($feeType==2){
  241. return '/receipt/feeTravel';
  242. }elseif($feeType==3){
  243. return '/receipt/feeInternalTrain';
  244. }else{
  245. return '/receipt/feeAgency';
  246. }
  247. }
  248. private function _feeData(){
  249. Doo::loadModel ( 'L_category' );
  250. $lCategory = new L_category ();
  251. Doo::loadModel ( 'verify' );
  252. $verify = new verify ();
  253. Doo::loadModel ( 'accountItem' );
  254. $accountItem = new accountItem ();
  255. Doo::loadModel ( "role" );
  256. $role = new role ();
  257. $acItem = $accountItem->find ( array (
  258. 'asArray' => true
  259. ) );
  260. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  261. $data ['category'] = $lCategory->find ( array (
  262. 'asArray' => true
  263. ) );
  264. $data ['itineraryDate'] = $this->_itineraryDateMin();
  265. $data ['veList'] = $veList;
  266. $data ['acItem'] = $acItem;
  267. $data ['memu'] = "receipt";
  268. $data ['staff'] = $this->staff;
  269. $data ['receiptMemu'] = 'saeaBorad';
  270. $data ['verifyId'] = $this->verifyId;
  271. $data ['executeId'] = $this->executeId;
  272. return $data;
  273. }
  274. /**
  275. * 办事处相关费用
  276. */
  277. function feeAgency(){
  278. $data=$this->_feeData();
  279. $this->render ( "/receipt/feeAgency", $data );
  280. }
  281. /**
  282. * 办事处
  283. */
  284. function feeTravel(){
  285. $data=$this->_feeData();
  286. $this->render ( "/receipt/feeTravel", $data );
  287. }
  288. function feeInternalTrain(){
  289. $data=$this->_feeData();
  290. $this->render ( "/receipt/feeInternalTrain", $data );
  291. }
  292. /**
  293. * 添加费用报销单页面
  294. */
  295. function saeaCreate() {
  296. Doo::loadModel ( 'accountItem' );
  297. Doo::loadModel ( 'verify' );
  298. Doo::loadModel ( 'receipt' );
  299. Doo::loadModel ( 'L_category' );
  300. $lCategory = new L_category ();
  301. $receipt = new receipt ();
  302. $verify = new verify ();
  303. $accountItem = new accountItem ();
  304. Doo::loadModel ( "role" );
  305. $role = new role ();
  306. $acItem = $accountItem->find ( array (
  307. 'asArray' => true
  308. ) );
  309. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  310. $data ['category'] = $lCategory->find ( array (
  311. 'asArray' => true
  312. ) );
  313. $data ['veList'] = $veList;
  314. $data ['acItem'] = $acItem;
  315. $data ['memu'] = "receipt";
  316. $data ['staff'] = $this->staff;
  317. $data ['receiptMemu'] = 'saeaBorad';
  318. $data ['verifyId'] = $this->verifyId;
  319. $data ['executeId'] = $this->executeId;
  320. $this->render ( "/admin/saea_create", $data );
  321. }
  322. private function _storageItinerary($itinerary,$rid,$version=2){
  323. $itineraryJson=json_decode($itinerary,true);
  324. Doo::loadModel ( 'itinerary' );
  325. $itinerary = new itinerary ();
  326. $itinerary->delete(array('where' => 'rid=' . $rid ));
  327. if($version==2){
  328. foreach ($itineraryJson as $k=>$v){
  329. foreach ($v as $kk=>$vv){
  330. foreach ($vv as $key=>$value){
  331. if($key==0){
  332. $feeTraveItem=json_encode($value['feeTraveItem']);
  333. $itinerary = new itinerary ();
  334. $itinerary->rid=$rid;
  335. $itinerary->sid=$this->staff [0] ['sid'];
  336. $itinerary->itineraryDate=$value['departuredate'];
  337. $itinerary->itineraryCity=$value['departurecity'];
  338. $itinerary->feeTraveItem='';
  339. $itinerary->itineraryIndex=0;
  340. $itinerary->insert ();
  341. $itinerary = new itinerary ();
  342. $itinerary->rid=$rid;
  343. $itinerary->sid=$this->staff [0] ['sid'];
  344. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  345. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  346. $itinerary->feeTraveItem=$feeTraveItem;
  347. $itinerary->itineraryIndex=1;
  348. $itinerary->insert ();
  349. }else{
  350. $feeTraveItem=json_encode($value['feeTraveItem']);
  351. $itinerary = new itinerary ();
  352. $itinerary->rid=$rid;
  353. $itinerary->sid=$this->staff [0] ['sid'];
  354. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  355. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  356. $itinerary->feeTraveItem=$feeTraveItem;
  357. $itinerary->itineraryIndex=$key+1;
  358. $itinerary->insert ();
  359. }
  360. }
  361. }
  362. }
  363. }elseif($version==1){
  364. foreach ($itineraryJson as $key=>$value){
  365. if($key==0){
  366. $feeTraveItem=json_encode($value['feeTraveItem']);
  367. $itinerary = new itinerary ();
  368. $itinerary->rid=$rid;
  369. $itinerary->sid=$this->staff [0] ['sid'];
  370. $itinerary->itineraryDate=$value['departuredate'];
  371. $itinerary->itineraryCity=$value['departurecity'];
  372. $itinerary->feeTraveItem='';
  373. $itinerary->itineraryIndex=0;
  374. $itinerary->insert ();
  375. $itinerary = new itinerary ();
  376. $itinerary->rid=$rid;
  377. $itinerary->sid=$this->staff [0] ['sid'];
  378. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  379. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  380. $itinerary->feeTraveItem=$feeTraveItem;
  381. $itinerary->itineraryIndex=1;
  382. $itinerary->insert ();
  383. }else{
  384. $feeTraveItem=json_encode($value['feeTraveItem']);
  385. $itinerary = new itinerary ();
  386. $itinerary->rid=$rid;
  387. $itinerary->sid=$this->staff [0] ['sid'];
  388. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  389. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  390. $itinerary->feeTraveItem=$feeTraveItem;
  391. $itinerary->itineraryIndex=$key+1;
  392. $itinerary->insert ();
  393. }
  394. }
  395. }else{
  396. die ( '行程单版本不正确' );
  397. }
  398. }
  399. private function _verificationItinerary($itinerary){
  400. Doo::loadModel ( 'itinerary' );
  401. $itineraryObj = new itinerary ();
  402. if(empty($itinerary)){
  403. header ( 'Content-Type:text/html;charset=utf-8' );
  404. die ( '请填写行程单' );
  405. }
  406. $itineraryJson=json_decode($itinerary,true);
  407. $itineraryDate=array();$sql=array();
  408. foreach ($itineraryJson as $k=>$v){
  409. foreach ($v as $kk=>$vv){
  410. foreach ($vv as $key=>$value){
  411. if(empty($value['departuredate'])||empty($value['arrivalsdate'])){
  412. header ( 'Content-Type:text/html;charset=utf-8' );
  413. die ( '有行程的日期未设置' );
  414. }
  415. if($key==0){
  416. array_push($itineraryDate, $value['departuredate']);
  417. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  418. array_push($sql,'?');array_push($sql,'?');
  419. }else{
  420. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  421. array_push($sql,'?');
  422. }
  423. }
  424. }
  425. }
  426. array_push($itineraryDate, $this->staff [0] ['sid']);
  427. $sql=implode(',',$sql);
  428. // $itineraryDate=array();$sql=array();
  429. // foreach ($itineraryJson as $key=>$value){
  430. // if($key==0){
  431. // array_push($itineraryDate, $value['departuredate']);
  432. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  433. // array_push($sql,'?');array_push($sql,'?');
  434. // }else{
  435. // array_push($itineraryDate, substr($value['arrivalsdate'],1));
  436. // array_push($sql,'?');
  437. // }
  438. // }
  439. // array_push($itineraryDate, $this->staff [0] ['sid']);
  440. // $sql=implode(',',$sql);
  441. if(empty($sql)){
  442. header ( 'Content-Type:text/html;charset=utf-8' );
  443. die ( '请填写行程单-2' );
  444. }
  445. $qualification=array(
  446. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  447. 'param' => $itineraryDate,
  448. 'asArray' => TRUE);
  449. $itDateList=$itineraryObj->find($qualification);
  450. if(empty($itDateList)){
  451. return false;
  452. }else{
  453. return true;
  454. }
  455. }
  456. private function _buildFeeData($receiptClass=1,$itinerary=''){
  457. $agency = $this->get_args ( 'agency' );
  458. $travel = $this->get_args ( 'travel' );
  459. $train = $this->get_args ( 'train' );
  460. $other = $this->get_args ( 'other' );
  461. $inttrain = $this->get_args ( 'inttrain' );
  462. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  463. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  464. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  465. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  466. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  467. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  468. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  469. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  470. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  471. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  472. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  473. header ( 'Content-Type:text/html;charset=utf-8' );
  474. die ( '请填写联行号' );
  475. }
  476. if($receiptClass==2){
  477. //TODO 日期检测
  478. if($this->_verificationItinerary($itinerary)){
  479. header ( 'Content-Type:text/html;charset=utf-8' );
  480. die ( '已申请过类此日期的行程' );
  481. }
  482. }
  483. $itinerary=str_replace('\n','<br/>',$itinerary);
  484. Doo::loadModel ( 'receipt' );
  485. Doo::loadModel ( 'receiptDetail' );
  486. Doo::loadModel ( 'accountItem' );
  487. $accountItem = new accountItem ();
  488. $receipt = new receipt ();
  489. Doo::loadModel ( 'enclosur' );
  490. Doo::loadModel ( 'execute' );
  491. $execute = new execute ();
  492. $executeDetail = $execute->getOne ( array (
  493. 'where' => 'mold="报销单执行人"',
  494. 'asArray' => true
  495. ) );
  496. $aItem = $accountItem->find ( array (
  497. 'asArray' => true
  498. ) );
  499. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  500. $ag = $tr = $ta = $ot= $it = 0;
  501. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  502. foreach ( $aItem as $key => $value ) {
  503. if ($value ['category'] == $this->AGENCY) {
  504. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  505. array_push ( $accountJson [$this->AGENCY], array (
  506. 'aid' => $value ['aid'],
  507. 'name' => $value ['name'],
  508. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  509. ) );
  510. $sum += $agency [$ag];
  511. $agencySum += $agency [$ag];
  512. }
  513. $ag ++;
  514. }
  515. if ($value ['category'] == $this->TRAVEL) {
  516. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  517. array_push ( $accountJson [$this->TRAVEL], array (
  518. 'aid' => $value ['aid'],
  519. 'name' => $value ['name'],
  520. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  521. ) );
  522. $sum += $travel [$tr];
  523. $travelSum += $travel [$tr];
  524. }
  525. $tr ++;
  526. }
  527. if ($value ['category'] == $this->TRAIN) {
  528. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  529. array_push ( $accountJson [$this->TRAIN], array (
  530. 'aid' => $value ['aid'],
  531. 'name' => $value ['name'],
  532. 'price' => number_format ( $train [$ta], 2, '.', '' )
  533. ) );
  534. $sum += $train [$ta];
  535. $trainSum += $train [$ta];
  536. }
  537. $ta ++;
  538. }
  539. if ($value ['category'] == $this->INTTRAIN) {
  540. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  541. array_push ( $accountJson [$this->INTTRAIN], array (
  542. 'aid' => $value ['aid'],
  543. 'name' => $value ['name'],
  544. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  545. ) );
  546. $sum += $inttrain [$it];
  547. $inttrainSum += $inttrain [$it];
  548. }
  549. $it ++;
  550. }
  551. if ($value ['category'] == $this->OTHER) {
  552. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  553. array_push ( $accountJson [$this->OTHER], array (
  554. 'aid' => $value ['aid'],
  555. 'name' => $value ['name'],
  556. 'price' => number_format ( $other [$ot], 2, '.', '' )
  557. ) );
  558. $sum += $other [$ot];
  559. $otherSum += $other [$ot];
  560. }
  561. $ot ++;
  562. }
  563. }
  564. $accountJson ['cSum'] = array (
  565. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  566. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  567. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  568. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  569. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  570. );
  571. // 报销单
  572. $receipt->accountItem = json_encode ( $accountJson );
  573. $receipt->staff = $this->staff [0] ['sid'];
  574. $receipt->sum = number_format ( $sum, 2, '.', '' );
  575. $receipt->date = date ( "Y-m-d" );
  576. $receipt->cid = $cid;
  577. $receipt->status = 5;
  578. // 修改审批流程加入角色
  579. $receipt->verify = $verify;
  580. $receipt->executeCopy = $executeDetail ['staff'];
  581. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  582. $order = array (
  583. "\r\n",
  584. "\n",
  585. "\r"
  586. );
  587. $replace = '<br/>';
  588. $explanation = str_replace ( $order, $replace, $explanation );
  589. $receipt->explanation = $explanation;
  590. $receipt->receiptClass = $receiptClass;
  591. $receipt->itinerary2=$itinerary;
  592. $receipt->remittanceName = $remittanceName;
  593. $receipt->bankName = $bankName;
  594. $receipt->bankNumber = $bankNumber;
  595. $receipt->remittanceBankType = $remittanceBankType;
  596. if ($remittanceBankType == 1) {
  597. $receipt->coupletNumber = $coupletNumber;
  598. }
  599. $rid = $receipt->insert ();
  600. //记录行程单
  601. $this->_storageItinerary($itinerary,$rid);
  602. // 附件
  603. if (! empty ( $enclosurName )) {
  604. $enclosurArray = explode ( '-', $enclosurName );
  605. foreach ( $enclosurArray as $value ) {
  606. $enclosur = new enclosur ();
  607. $enclosur->name = $value;
  608. $enclosur->rid = $rid;
  609. $enclosur->insert ();
  610. }
  611. }
  612. // 报销详情
  613. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  614. $receiptDetail = new receiptDetail ();
  615. $receiptDetail->staff = $this->staff [0] ['sid'];
  616. $receiptDetail->item = $value ['name'];
  617. $receiptDetail->itemCategory = $this->AGENCY;
  618. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  619. $receiptDetail->date = date ( "Y-m-d" );
  620. $receiptDetail->cid = $cid;
  621. $receiptDetail->rid = $rid;
  622. $receiptDetail->status = 4;
  623. $receiptDetail->insert ();
  624. }
  625. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  626. $receiptDetail = new receiptDetail ();
  627. $receiptDetail->staff = $this->staff [0] ['sid'];
  628. $receiptDetail->item = $value ['name'];
  629. $receiptDetail->itemCategory = $this->TRAVEL;
  630. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  631. $receiptDetail->date = date ( "Y-m-d" );
  632. $receiptDetail->cid = $cid;
  633. $receiptDetail->rid = $rid;
  634. $receiptDetail->status = 4;
  635. $receiptDetail->insert ();
  636. }
  637. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  638. $receiptDetail = new receiptDetail ();
  639. $receiptDetail->staff = $this->staff [0] ['sid'];
  640. $receiptDetail->item = $value ['name'];
  641. $receiptDetail->itemCategory = $this->TRAIN;
  642. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  643. $receiptDetail->date = date ( "Y-m-d" );
  644. $receiptDetail->cid = $cid;
  645. $receiptDetail->rid = $rid;
  646. $receiptDetail->status = 4;
  647. $receiptDetail->insert ();
  648. }
  649. // 内训
  650. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  651. $receiptDetail = new receiptDetail ();
  652. $receiptDetail->staff = $this->staff [0] ['sid'];
  653. $receiptDetail->item = $value ['name'];
  654. $receiptDetail->itemCategory = $this->INTTRAIN;
  655. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  656. $receiptDetail->date = date ( "Y-m-d" );
  657. $receiptDetail->cid = $cid;
  658. $receiptDetail->rid = $rid;
  659. $receiptDetail->status = 4;
  660. $receiptDetail->insert ();
  661. }
  662. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  663. $receiptDetail = new receiptDetail ();
  664. $receiptDetail->staff = $this->staff [0] ['sid'];
  665. $receiptDetail->item = $value ['name'];
  666. $receiptDetail->itemCategory = $this->OTHER;
  667. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  668. $receiptDetail->date = date ( "Y-m-d" );
  669. $receiptDetail->cid = $cid;
  670. $receiptDetail->rid = $rid;
  671. $receiptDetail->status = 4;
  672. $receiptDetail->insert ();
  673. }
  674. return true;
  675. } else
  676. return false;
  677. }
  678. function addReceipt() {
  679. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  680. if ($this->_buildFeeData(1)) {
  681. return "/saeaBorad";
  682. } else{
  683. die ( 'illegal request' );
  684. }
  685. }
  686. function addFeeTravel(){
  687. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  688. $itineraryList=json_decode($itinerary,true);
  689. // foreach ($itineraryList as $key=>$value){
  690. // if(empty($value['departuredate'])||empty($value['departurecity'])){
  691. // header ( 'Content-Type:text/html;charset=utf-8' );
  692. // die ( '请设置出发地和出发日期' );
  693. // }
  694. // }
  695. if ($this->_buildFeeData(2,$itinerary)) {
  696. return "/saeaBorad?travel=success";
  697. } else{
  698. die ( 'illegal request' );
  699. }
  700. }
  701. function addFeeInternalTrain(){
  702. if ($this->_buildFeeData(3)) {
  703. return "/saeaBorad";
  704. } else{
  705. die ( 'illegal request' );
  706. }
  707. }
  708. function referReceipt() {
  709. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  710. Doo::loadModel ( 'receipt' );
  711. Doo::loadModel ( 'verify' );
  712. $verify = new verify ();
  713. $receipt = new receipt ();
  714. Doo::loadModel ( 'L_category' );
  715. $lCategory = new L_category ();
  716. Doo::loadModel ( "role" );
  717. $role = new role ();
  718. $receiptDetail = $receipt->find ( array (
  719. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  720. 'asArray' => true
  721. ) );
  722. if (empty ( $receiptDetail ))
  723. return "/addReceipt";
  724. foreach ( $receiptDetail as $key => $value ) {
  725. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  726. $veList = $verify->getOne ( array (
  727. 'where' => 'vid=' . $value ['verify'],
  728. 'asArray' => true
  729. ) );
  730. $v = json_decode ( $veList ['staff'] );
  731. array_push ( $v [0], $veList ['description'] );
  732. foreach ( $v as $n => $m ) {
  733. if ($m ['1'] == 'ROLE') {
  734. $roleInfo = $role->getOne ( array (
  735. 'where' => 'rid=' . $m [0],
  736. 'asArray' => true
  737. ) );
  738. $v [$n] [1] = $roleInfo ['name'];
  739. }
  740. }
  741. $receiptDetail [$key] ['staff'] = $v;
  742. $category = $lCategory->getOne ( array (
  743. 'where' => 'cid=' . $value ['cid'],
  744. 'asArray' => true
  745. ) );
  746. $receiptDetail [$key] ['category'] = $category ['title'];
  747. }
  748. // print_r($receiptDetail);
  749. $data ['receiptDetail'] = $receiptDetail;
  750. $data ['memu'] = "receipt";
  751. $data ['staff'] = $this->staff;
  752. $data ['receiptMemu'] = 'saeaCreate';
  753. $data ['verifyId'] = $this->verifyId;
  754. $data ['executeId'] = $this->executeId;
  755. $this->render ( "/admin/saea_confirm", $data );
  756. }
  757. function editReceipt() {
  758. // edit status 4
  759. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  760. Doo::loadClass ( 'XDeode' );
  761. $XDeode = new XDeode ( 7 );
  762. $rid = $XDeode->decode ( $ridKey );
  763. if (empty ( $rid )) {
  764. die ( 'illegal request-id' );
  765. }
  766. // echo $rid.'sd';
  767. Doo::loadModel ( 'accountItem' );
  768. Doo::loadModel ( 'verify' );
  769. Doo::loadModel ( 'receipt' );
  770. $receipt = new receipt ();
  771. $verify = new verify ();
  772. $accountItem = new accountItem ();
  773. Doo::loadModel ( 'L_category' );
  774. $lCategory = new L_category ();
  775. Doo::loadModel ( "role" );
  776. $role = new role ();
  777. Doo::loadModel ( 'enclosur' );
  778. $enclosur = new enclosur ();
  779. $receiptDetail = $receipt->getOne ( array (
  780. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  781. 'asArray' => true
  782. ) );
  783. if (empty ( $receiptDetail )) {
  784. die ( 'illegal request-emptyData' );
  785. }
  786. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  787. $acItem = $accountItem->find ( array (
  788. 'asArray' => true
  789. ) );
  790. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  791. // 配置编辑信息
  792. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  793. foreach ( $acItem as $key => $value ) {
  794. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  795. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  796. $acItem [$key] ['price'] = $v ['price'];
  797. }
  798. }
  799. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  800. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  801. $acItem [$key] ['price'] = $v ['price'];
  802. }
  803. }
  804. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  805. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  806. $acItem [$key] ['price'] = $v ['price'];
  807. }
  808. }
  809. // 内训
  810. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  811. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  812. $acItem [$key] ['price'] = $v ['price'];
  813. }
  814. }
  815. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  816. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  817. $acItem [$key] ['price'] = $v ['price'];
  818. }
  819. }
  820. }
  821. //$receiptDetail['itinerary']=str_replace('\n','<br/>',$receiptDetail['itinerary']);
  822. //nl2br($receiptDetail['explanation']);
  823. $receiptDetail['explanation']= str_replace('<br/>',"\n",$receiptDetail['explanation']);
  824. $data ['category'] = $lCategory->find ( array (
  825. 'asArray' => true
  826. ) );
  827. $data ['cSum'] = $accountItemList ['cSum'];
  828. $data ['sum'] = $receiptDetail ['sum'];
  829. $data ['enclosurList'] = $enclosurList;
  830. $data ['receiptDetail'] = $receiptDetail;
  831. $data ['veList'] = $veList;
  832. $data ['acItem'] = $acItem;
  833. $data ['memu'] = "receipt";
  834. $data ['staff'] = $this->staff;
  835. $data ['receiptMemu'] = 'saeaBorad';
  836. $data ['verify'] = $receiptDetail ['verify'];
  837. $data ['verifyId'] = $this->verifyId;
  838. $data ['executeId'] = $this->executeId;
  839. $data ['rid'] = $ridKey;
  840. if($receiptDetail['receiptClass']==1){
  841. $this->render ( "/receipt/feeAgencyEdi", $data );
  842. }elseif($receiptDetail['receiptClass']==2){
  843. if(!empty($receiptDetail['itinerary2'])){
  844. //TODO 报销说明
  845. $this->render ( "/receipt/feeTravelEdi2", $data );
  846. }else{
  847. $this->render ( "/receipt/feeTravelEdi", $data );
  848. }
  849. }elseif($receiptDetail['receiptClass']==3){
  850. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  851. }else{
  852. $this->render ( "/admin/saea_edit", $data );
  853. //die ( 'illegal request-renderHtml' );
  854. }
  855. }
  856. function updateReceipt() {
  857. $agency = $this->get_args ( 'agency' );
  858. $travel = $this->get_args ( 'travel' );
  859. $train = $this->get_args ( 'train' );
  860. $other = $this->get_args ( 'other' );
  861. $inttrain = $this->get_args ( 'inttrain' );
  862. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  863. $itinerary = $_POST['itinerary'];
  864. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  865. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  866. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  867. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  868. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  869. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  870. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  871. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  872. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  873. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  874. Doo::loadClass ( 'XDeode' );
  875. $XDeode = new XDeode ( 7 );
  876. $rid = $XDeode->decode ( $ridKey );
  877. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  878. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  879. header ( 'Content-Type:text/html;charset=utf-8' );
  880. die ( '请填写联行号' );
  881. }
  882. Doo::loadModel ( 'receipt' );
  883. Doo::loadModel ( 'receiptDetail' );
  884. Doo::loadModel ( 'accountItem' );
  885. $accountItem = new accountItem ();
  886. $receipt = new receipt ();
  887. Doo::loadModel ( 'enclosur' );
  888. Doo::loadModel ( 'execute' );
  889. $execute = new execute ();
  890. $receiptDetail = $receipt->getOne ( array (
  891. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  892. 'asArray' => true
  893. ) );
  894. if (empty ( $receiptDetail )) {
  895. return "/saeaBorad";
  896. }
  897. //TODO 存储行程单-兼容旧版本的行程单
  898. $itinerary=str_replace('\n','<br/>',$itinerary);
  899. if(!empty($receiptDetail['itinerary2'])){
  900. $this->_storageItinerary($itinerary,$rid);
  901. }else{
  902. $this->_storageItinerary($itinerary,$rid,1);
  903. }
  904. if ($receiptDetail ['Rtype'] == 1) {
  905. $executeDetail = $execute->getOne ( array (
  906. 'where' => 'mold="借款费用执行人"',
  907. 'asArray' => true
  908. ) );
  909. } else {
  910. $executeDetail = $execute->getOne ( array (
  911. 'where' => 'mold="报销单执行人"',
  912. 'asArray' => true
  913. ) );
  914. }
  915. $aItem = $accountItem->find ( array (
  916. 'asArray' => true
  917. ) );
  918. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  919. $ag = $tr = $ta = $ot = $it = 0;
  920. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  921. foreach ( $aItem as $key => $value ) {
  922. if ($value ['category'] == $this->AGENCY) {
  923. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  924. array_push ( $accountJson [$this->AGENCY], array (
  925. 'aid' => $value ['aid'],
  926. 'name' => $value ['name'],
  927. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  928. ) );
  929. $sum += $agency [$ag];
  930. $agencySum += $agency [$ag];
  931. }
  932. $ag ++;
  933. }
  934. if ($value ['category'] == $this->TRAVEL) {
  935. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  936. array_push ( $accountJson [$this->TRAVEL], array (
  937. 'aid' => $value ['aid'],
  938. 'name' => $value ['name'],
  939. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  940. ) );
  941. $sum += $travel [$tr];
  942. $travelSum += $travel [$tr];
  943. }
  944. $tr ++;
  945. }
  946. if ($value ['category'] == $this->TRAIN) {
  947. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  948. array_push ( $accountJson [$this->TRAIN], array (
  949. 'aid' => $value ['aid'],
  950. 'name' => $value ['name'],
  951. 'price' => number_format ( $train [$ta], 2, '.', '' )
  952. ) );
  953. $sum += $train [$ta];
  954. $trainSum += $train [$ta];
  955. }
  956. $ta ++;
  957. }
  958. if ($value ['category'] == $this->INTTRAIN) {
  959. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  960. array_push ( $accountJson [$this->INTTRAIN], array (
  961. 'aid' => $value ['aid'],
  962. 'name' => $value ['name'],
  963. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  964. ) );
  965. $sum += $inttrain [$it];
  966. $inttrainSum += $inttrain [$it];
  967. }
  968. $it ++;
  969. }
  970. if ($value ['category'] == $this->OTHER) {
  971. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  972. array_push ( $accountJson [$this->OTHER], array (
  973. 'aid' => $value ['aid'],
  974. 'name' => $value ['name'],
  975. 'price' => number_format ( $other [$ot], 2, '.', '' )
  976. ) );
  977. $sum += $other [$ot];
  978. $otherSum += $other [$ot];
  979. }
  980. $ot ++;
  981. }
  982. }
  983. $accountJson ['cSum'] = array (
  984. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  985. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  986. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  987. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  988. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  989. );
  990. // 报销单
  991. $rid = $receipt->rid = $receiptDetail ['rid'];
  992. $receipt->accountItem = json_encode ( $accountJson );
  993. $receipt->staff = $this->staff [0] ['sid'];
  994. $receipt->sum = number_format ( $sum, 2, '.', '' );
  995. $receipt->date = date ( "Y-m-d" );
  996. $receipt->cid = $cid;
  997. if (($receiptDetail ['status'] != 4)) {
  998. if ($receiptDetail ['Rtype'] == 1) {
  999. $receipt->status = 7;
  1000. } else {
  1001. $receipt->status = 5;
  1002. }
  1003. }
  1004. if ($receiptDetail != 4 && ! empty ( $verify ))
  1005. $receipt->verify = $verify;
  1006. $receipt->executeCopy = $executeDetail ['staff'];
  1007. $order = array (
  1008. "\r\n",
  1009. "\n",
  1010. "\r"
  1011. );
  1012. $replace = '<br/>';
  1013. $explanation = str_replace ( $order, $replace, $explanation );
  1014. $receipt->explanation = $explanation;
  1015. if($receiptClass=='trave'){
  1016. if(!empty($receiptDetail['itinerary2'])){//行程单版本
  1017. $receipt->itinerary2=$itinerary;
  1018. }else{
  1019. $receipt->itinerary=$itinerary;
  1020. }
  1021. }
  1022. $receipt->remittanceName = $remittanceName;
  1023. $receipt->bankName = $bankName;
  1024. $receipt->bankNumber = $bankNumber;
  1025. $receipt->remittanceBankType = $remittanceBankType;
  1026. if ($remittanceBankType == 1)
  1027. $receipt->coupletNumber = $coupletNumber;
  1028. $receipt->update ();
  1029. $receiptDetail = new receiptDetail ();
  1030. $receiptDetail->delete ( array (
  1031. 'where' => 'rid=' . $rid
  1032. ) );
  1033. // 报销详情
  1034. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1035. $receiptDetail = new receiptDetail ();
  1036. $receiptDetail->staff = $this->staff [0] ['sid'];
  1037. $receiptDetail->item = $value ['name'];
  1038. $receiptDetail->itemCategory = $this->AGENCY;
  1039. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1040. $receiptDetail->date = date ( "Y-m-d" );
  1041. $receiptDetail->cid = $cid;
  1042. $receiptDetail->rid = $rid;
  1043. $receiptDetail->status = 4;
  1044. $receiptDetail->insert ();
  1045. }
  1046. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1047. $receiptDetail = new receiptDetail ();
  1048. $receiptDetail->staff = $this->staff [0] ['sid'];
  1049. $receiptDetail->item = $value ['name'];
  1050. $receiptDetail->itemCategory = $this->TRAVEL;
  1051. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1052. $receiptDetail->date = date ( "Y-m-d" );
  1053. $receiptDetail->cid = $cid;
  1054. $receiptDetail->rid = $rid;
  1055. $receiptDetail->status = 4;
  1056. $receiptDetail->insert ();
  1057. }
  1058. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1059. $receiptDetail = new receiptDetail ();
  1060. $receiptDetail->staff = $this->staff [0] ['sid'];
  1061. $receiptDetail->item = $value ['name'];
  1062. $receiptDetail->itemCategory = $this->TRAIN;
  1063. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1064. $receiptDetail->date = date ( "Y-m-d" );
  1065. $receiptDetail->cid = $cid;
  1066. $receiptDetail->rid = $rid;
  1067. $receiptDetail->status = 4;
  1068. $receiptDetail->insert ();
  1069. }
  1070. // 内训
  1071. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  1072. $receiptDetail = new receiptDetail ();
  1073. $receiptDetail->staff = $this->staff [0] ['sid'];
  1074. $receiptDetail->item = $value ['name'];
  1075. $receiptDetail->itemCategory = $this->INTTRAIN;
  1076. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1077. $receiptDetail->date = date ( "Y-m-d" );
  1078. $receiptDetail->cid = $cid;
  1079. $receiptDetail->rid = $rid;
  1080. $receiptDetail->status = 4;
  1081. $receiptDetail->insert ();
  1082. }
  1083. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1084. $receiptDetail = new receiptDetail ();
  1085. $receiptDetail->staff = $this->staff [0] ['sid'];
  1086. $receiptDetail->item = $value ['name'];
  1087. $receiptDetail->itemCategory = $this->OTHER;
  1088. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1089. $receiptDetail->date = date ( "Y-m-d" );
  1090. $receiptDetail->cid = $cid;
  1091. $receiptDetail->rid = $rid;
  1092. $receiptDetail->status = 4;
  1093. $receiptDetail->insert ();
  1094. }
  1095. // 附件
  1096. if (! empty ( $enclosurName )) {
  1097. $enclosurArray = explode ( '-', $enclosurName );
  1098. foreach ( $enclosurArray as $value ) {
  1099. $enclosur = new enclosur ();
  1100. $enclosur->name = $value;
  1101. $enclosur->rid = $rid;
  1102. $enclosur->insert ();
  1103. }
  1104. }
  1105. // return "/referReceipt/".$rid;
  1106. }
  1107. return "/saeaBorad";
  1108. }
  1109. function remitAdd() {
  1110. Doo::loadModel ( 'accountItem' );
  1111. Doo::loadModel ( 'verify' );
  1112. Doo::loadModel ( 'receipt' );
  1113. Doo::loadModel ( 'L_category' );
  1114. $lCategory = new L_category ();
  1115. $receipt = new receipt ();
  1116. $verify = new verify ();
  1117. $accountItem = new accountItem ();
  1118. Doo::loadModel ( "role" );
  1119. $role = new role ();
  1120. $acItem = $accountItem->find ( array (
  1121. 'asArray' => true
  1122. ) );
  1123. $veList = $verify->getVerifyBySubordinate('REMIT');
  1124. $data ['category'] = $lCategory->find ( array (
  1125. 'asArray' => true
  1126. ) );
  1127. $data ['veList'] = $veList;
  1128. $data ['acItem'] = $acItem;
  1129. $data ['memu'] = "receipt";
  1130. $data ['staff'] = $this->staff;
  1131. $data ['receiptMemu'] = 'saeaBorad';
  1132. $data ['verifyId'] = $this->verifyId;
  1133. $data ['executeId'] = $this->executeId;
  1134. $this->render ( "/admin/remitAdd", $data );
  1135. }
  1136. function remitAddDo() {
  1137. $agency = $this->get_args ( 'agency' );
  1138. $travel = $this->get_args ( 'travel' );
  1139. $train = $this->get_args ( 'train' );
  1140. $other = $this->get_args ( 'other' );
  1141. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1142. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1143. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1144. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1145. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1146. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1147. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1148. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1149. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1150. // print_r($agency);die;
  1151. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1152. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1153. header ( 'Content-Type:text/html;charset=utf-8' );
  1154. die ( '请填写联行号' );
  1155. }
  1156. Doo::loadModel ( 'receipt' );
  1157. Doo::loadModel ( 'receiptDetail' );
  1158. Doo::loadModel ( 'accountItem' );
  1159. $accountItem = new accountItem ();
  1160. $receipt = new receipt ();
  1161. Doo::loadModel ( 'enclosur' );
  1162. Doo::loadModel ( 'execute' );
  1163. $execute = new execute ();
  1164. $executeDetail = $execute->getOne ( array (
  1165. 'where' => 'mold="对公汇款执行人"',
  1166. 'asArray' => true
  1167. ) );
  1168. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1169. $aItem = $accountItem->find ( array (
  1170. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1171. 'asArray' => true
  1172. ) );
  1173. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1174. $ag = $tr = $ta = $ot = 0;
  1175. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1176. print_r($aItem);
  1177. foreach ( $aItem as $key => $value ) {
  1178. if ($value ['category'] == $this->AGENCY) {
  1179. if (isset ( $agency [$ag] )) {
  1180. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1181. array_push ( $accountJson [$this->AGENCY], array (
  1182. 'aid' => $value ['aid'],
  1183. 'name' => $value ['name'],
  1184. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1185. ) );
  1186. $sum += $agency [$ag];
  1187. $agencySum += $agency [$ag];
  1188. }
  1189. }
  1190. $ag ++;
  1191. }
  1192. }
  1193. $accountJson ['cSum'] = array (
  1194. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1195. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1196. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1197. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1198. );
  1199. //die;
  1200. // 报销单
  1201. $receipt->accountItem = json_encode ( $accountJson );
  1202. $receipt->staff = $this->staff [0] ['sid'];
  1203. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1204. $receipt->date = date ( "Y-m-d" );
  1205. $receipt->cid = $cid;
  1206. $receipt->status = 5;
  1207. $receipt->Rtype = 2;
  1208. // 修改审批流程加入角色
  1209. $receipt->verify = $verify;
  1210. $receipt->executeCopy = $executeDetail ['staff'];
  1211. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1212. $order = array (
  1213. "\r\n",
  1214. "\n",
  1215. "\r"
  1216. );
  1217. $replace = '<br/>';
  1218. $explanation = str_replace ( $order, $replace, $explanation );
  1219. $receipt->explanation = $explanation;
  1220. $receipt->remittanceName = $remittanceName;
  1221. $receipt->bankName = $bankName;
  1222. $receipt->bankNumber = $bankNumber;
  1223. $receipt->remittanceBankType = $remittanceBankType;
  1224. if ($remittanceBankType == 1)
  1225. $receipt->coupletNumber = $coupletNumber;
  1226. $rid = $receipt->insert ();
  1227. // 附件
  1228. if (! empty ( $enclosurName )) {
  1229. $enclosurArray = explode ( '-', $enclosurName );
  1230. foreach ( $enclosurArray as $value ) {
  1231. $enclosur = new enclosur ();
  1232. $enclosur->name = $value;
  1233. $enclosur->rid = $rid;
  1234. $enclosur->insert ();
  1235. }
  1236. // print_r($enclosurArray);die;
  1237. }
  1238. // 报销详情
  1239. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1240. $receiptDetail = new receiptDetail ();
  1241. $receiptDetail->staff = $this->staff [0] ['sid'];
  1242. $receiptDetail->item = $value ['name'];
  1243. $receiptDetail->itemCategory = $this->AGENCY;
  1244. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1245. $receiptDetail->date = date ( "Y-m-d" );
  1246. $receiptDetail->cid = $cid;
  1247. $receiptDetail->rid = $rid;
  1248. $receiptDetail->status = 4;
  1249. $receiptDetail->insert ();
  1250. }
  1251. return "/saeaBorad";
  1252. } else
  1253. die ( 'illegal request' );
  1254. }
  1255. function remitEdit() {
  1256. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1257. Doo::loadClass ( 'XDeode' );
  1258. $XDeode = new XDeode ( 7 );
  1259. $rid = $XDeode->decode ( $ridKey );
  1260. if (! is_numeric ( $rid ))
  1261. die ( 'illegal request' );
  1262. Doo::loadModel ( 'accountItem' );
  1263. Doo::loadModel ( 'verify' );
  1264. Doo::loadModel ( 'receipt' );
  1265. $receipt = new receipt ();
  1266. $verify = new verify ();
  1267. $accountItem = new accountItem ();
  1268. Doo::loadModel ( 'L_category' );
  1269. $lCategory = new L_category ();
  1270. Doo::loadModel ( "role" );
  1271. $role = new role ();
  1272. Doo::loadModel ( 'enclosur' );
  1273. $enclosur = new enclosur ();
  1274. $receiptDetail = $receipt->getOne ( array (
  1275. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1276. 'asArray' => true
  1277. ) );
  1278. if (empty ( $receiptDetail ))
  1279. return "/saeaCreate";
  1280. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1281. $acItem = $accountItem->find ( array (
  1282. 'asArray' => true
  1283. ) );
  1284. $veList = $verify->getVerifyBySubordinate('REMIT');
  1285. // 配置编辑信息
  1286. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1287. foreach ( $acItem as $key => $value ) {
  1288. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1289. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1290. $acItem [$key] ['price'] = $v ['price'];
  1291. }
  1292. }
  1293. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1294. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1295. $acItem [$key] ['price'] = $v ['price'];
  1296. }
  1297. }
  1298. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1299. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1300. $acItem [$key] ['price'] = $v ['price'];
  1301. }
  1302. }
  1303. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1304. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1305. $acItem [$key] ['price'] = $v ['price'];
  1306. }
  1307. }
  1308. }
  1309. $data ['category'] = $lCategory->find ( array (
  1310. 'asArray' => true
  1311. ) );
  1312. $data ['enclosurList'] = $enclosurList;
  1313. $data ['cSum'] = $accountItemList ['cSum'];
  1314. $data ['sum'] = $receiptDetail ['sum'];
  1315. $data ['receiptDetail'] = $receiptDetail;
  1316. $data ['veList'] = $veList;
  1317. $data ['acItem'] = $acItem;
  1318. $data ['memu'] = "receipt";
  1319. $data ['staff'] = $this->staff;
  1320. $data ['receiptMemu'] = 'saeaBorad';
  1321. $data ['verify'] = $receiptDetail ['verify'];
  1322. $data ['verifyId'] = $this->verifyId;
  1323. $data ['executeId'] = $this->executeId;
  1324. $data ['rid'] = $rid;
  1325. $data ['ridKey'] = $ridKey;
  1326. $this->render ( "/admin/remitEdit", $data );
  1327. }
  1328. function remitEdiDo() {
  1329. $agency = $this->get_args ( 'agency' );
  1330. $travel = $this->get_args ( 'travel' );
  1331. $train = $this->get_args ( 'train' );
  1332. $other = $this->get_args ( 'other' );
  1333. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1334. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1335. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1336. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1337. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1338. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1339. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1340. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1341. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1342. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1343. Doo::loadClass ( 'XDeode' );
  1344. $XDeode = new XDeode ( 7 );
  1345. $rid = $XDeode->decode ( $ridKey );
  1346. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1347. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1348. header ( 'Content-Type:text/html;charset=utf-8' );
  1349. die ( '请填写联行号' );
  1350. }
  1351. Doo::loadModel ( 'receipt' );
  1352. Doo::loadModel ( 'receiptDetail' );
  1353. Doo::loadModel ( 'accountItem' );
  1354. $accountItem = new accountItem ();
  1355. $receipt = new receipt ();
  1356. Doo::loadModel ( 'enclosur' );
  1357. $enclosur = new enclosur ();
  1358. Doo::loadModel ( 'execute' );
  1359. $execute = new execute ();
  1360. $executeDetail = $execute->getOne ( array (
  1361. 'where' => 'mold="对公汇款执行人"',
  1362. 'asArray' => true
  1363. ) );
  1364. $receiptDetail = $receipt->getOne ( array (
  1365. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1366. 'asArray' => true
  1367. ) );
  1368. if (empty ( $receiptDetail ))
  1369. return "/saeaBorad";
  1370. $aItem = $accountItem->find ( array (
  1371. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1372. 'asArray' => true
  1373. ) );
  1374. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1375. $ag = $tr = $ta = $ot = 0;
  1376. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1377. foreach ( $aItem as $key => $value ) {
  1378. if ($value ['category'] == $this->AGENCY) {
  1379. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1380. array_push ( $accountJson [$this->AGENCY], array (
  1381. 'aid' => $value ['aid'],
  1382. 'name' => $value ['name'],
  1383. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1384. ) );
  1385. $sum += $agency [$ag];
  1386. $agencySum += $agency [$ag];
  1387. }
  1388. $ag ++;
  1389. }
  1390. }
  1391. $accountJson ['cSum'] = array (
  1392. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1393. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1394. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1395. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1396. );
  1397. // 报销单
  1398. $rid = $receipt->rid = $receiptDetail ['rid'];
  1399. $receipt->accountItem = json_encode ( $accountJson );
  1400. $receipt->staff = $this->staff [0] ['sid'];
  1401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1402. $receipt->date = date ( "Y-m-d" );
  1403. $receipt->cid = $cid;
  1404. if ($receiptDetail ['Rtype'] == 1)
  1405. $receipt->status = 7;
  1406. else
  1407. $receipt->status = 5;
  1408. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1409. $receipt->verify = $verify;
  1410. $receipt->executeCopy = $executeDetail ['staff'];
  1411. $order = array (
  1412. "\r\n",
  1413. "\n",
  1414. "\r"
  1415. );
  1416. $replace = '<br/>';
  1417. $explanation = str_replace ( $order, $replace, $explanation );
  1418. $receipt->explanation = $explanation;
  1419. $receipt->remittanceName = $remittanceName;
  1420. $receipt->bankName = $bankName;
  1421. $receipt->bankNumber = $bankNumber;
  1422. $receipt->remittanceBankType = $remittanceBankType;
  1423. if ($remittanceBankType == 1)
  1424. $receipt->coupletNumber = $coupletNumber;
  1425. $receipt->update ();
  1426. $receiptDetail = new receiptDetail ();
  1427. $receiptDetail->delete ( array (
  1428. 'where' => 'rid=' . $rid
  1429. ) );
  1430. // 报销详情
  1431. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1432. $receiptDetail = new receiptDetail ();
  1433. $receiptDetail->staff = $this->staff [0] ['sid'];
  1434. $receiptDetail->item = $value ['name'];
  1435. $receiptDetail->itemCategory = $this->AGENCY;
  1436. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1437. $receiptDetail->date = date ( "Y-m-d" );
  1438. $receiptDetail->cid = $cid;
  1439. $receiptDetail->rid = $rid;
  1440. $receiptDetail->status = 4;
  1441. $receiptDetail->insert ();
  1442. }
  1443. // 附件
  1444. if (! empty ( $enclosurName )) {
  1445. $enclosurArray = explode ( '-', $enclosurName );
  1446. foreach ( $enclosurArray as $value ) {
  1447. $enclosur = new enclosur ();
  1448. $enclosur->name = $value;
  1449. $enclosur->rid = $rid;
  1450. $enclosur->insert ();
  1451. }
  1452. }
  1453. }
  1454. return "/saeaBorad";
  1455. }
  1456. function remitApproval() {
  1457. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1458. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1459. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1460. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1461. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1462. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1463. if (empty ( $status ))
  1464. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1465. $vidList = array ();
  1466. $button = 0;
  1467. Doo::loadModel ( 'verify' );
  1468. Doo::loadModel ( 'receipt' );
  1469. Doo::loadModel ( 'staff' );
  1470. $staff = new staff ();
  1471. $receipt = new receipt ();
  1472. $verify = new verify ();
  1473. Doo::loadModel ( 'L_category' );
  1474. $Lcategory = new L_category ();
  1475. Doo::loadModel ( 'enclosur' );
  1476. $enclosur = new enclosur ();
  1477. // user verify ID
  1478. $verifyDetail = $verify->find ( array (
  1479. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1480. 'asArray' => true
  1481. ) );
  1482. foreach ( $verifyDetail as $key => $value ) {
  1483. array_push ( $vidList, $value ['vid'] );
  1484. }
  1485. $vid = implode ( ",", $vidList );
  1486. if (empty ( $verifyDetail ))
  1487. $vid = 0;
  1488. $categoryList = $Lcategory->find ( array (
  1489. 'asArray' => true
  1490. ) );
  1491. $staffList = $staff->find ( array (
  1492. 'where' => 'cid=' . $cid,
  1493. 'asArray' => true
  1494. ) );
  1495. $ap = "";
  1496. if ($status == 4) {
  1497. $ap = 4;
  1498. $status = 2;
  1499. }
  1500. // get Receipt By verifyID status 2
  1501. $receiptList = $receipt->find ( array (
  1502. 'where' => 'rid =' . $rid . ' and status=2',
  1503. 'desc' => 'rid',
  1504. 'asArray' => true
  1505. ) );
  1506. if (empty ( $receiptList )) {
  1507. die ( 'illegal request' );
  1508. }
  1509. $Locate = 0;
  1510. $roleId = 0;
  1511. if ($ap == 4)
  1512. $status = 4;
  1513. foreach ( $receiptList as $key => $value ) {
  1514. $receiptList [$key] ['Locate'] = $Locate;
  1515. $Locate ++;
  1516. $receiptList [$key] ['reviseDetail'] = array ();
  1517. if (! empty ( $value ['reviseDetail'] ))
  1518. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1519. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1520. $categoryDetil = $Lcategory->getOne ( array (
  1521. 'where' => 'cid=' . $value ['cid'],
  1522. 'asArray' => true
  1523. ) );
  1524. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1525. // 检测编辑状态
  1526. $verifyList = $verify->getOne ( array (
  1527. 'where' => 'vid=' . $value ['verify'],
  1528. 'asArray' => true
  1529. ) );
  1530. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1531. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1532. Doo::loadModel ( 'role' );
  1533. $role = new role ();
  1534. // print_r($verifyList);
  1535. $flag = true;
  1536. $roleKey = 0;
  1537. $endStaffArray = array ();
  1538. $roleArrayCopy = array ();
  1539. foreach ( $verifyList as $k => $v ) {
  1540. // init verifyStaff
  1541. if ($v [1] == 'ROLE') {
  1542. if (! empty ( $verifyStaff )) {
  1543. $endStaffArray = end ( $verifyStaff );
  1544. if ($v [0] == $endStaffArray ['nextStaff']) {
  1545. $roleId = $v [0];
  1546. }
  1547. }
  1548. $roleVerify = json_decode ( $v [3], true );
  1549. $roleKey = $k;
  1550. $roleArray = array ();
  1551. $rolename = $role->getOne ( array (
  1552. 'where' => 'rid=' . $v [0],
  1553. 'asArray' => true
  1554. ) );
  1555. foreach ( $roleVerify as $o => $p ) {
  1556. $staffID = explode ( '_', $p );
  1557. $staffInfo = $staff->getOne ( array (
  1558. 'where' => 'sid=' . $staffID [0],
  1559. 'asArray' => true
  1560. ) );
  1561. // print_r($staffID);
  1562. $exp = array (
  1563. 0 => $staffInfo ['sid'],
  1564. 1 => $staffID [1],
  1565. 2 => $staffInfo ['avatar'],
  1566. 'date' => '',
  1567. 'date' => '',
  1568. 'opinion' => '',
  1569. 'status' => '',
  1570. 'rolename' => $rolename ['name']
  1571. );
  1572. array_push ( $roleArray, $exp );
  1573. }
  1574. $roleArrayCopy [$v [0]] = $roleArray;
  1575. // $verifyList[$k]['roleArray']=$roleArray;
  1576. }
  1577. // print_r($roleArray);
  1578. $verifyList [$k] ['date'] = "";
  1579. $verifyList [$k] ['opinion'] = "";
  1580. $verifyList [$k] ['status'] = "";
  1581. if (empty ( $verifyStaff )) {
  1582. $verifyList [$k] ['date'] = "";
  1583. $verifyList [$k] ['opinion'] = "";
  1584. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1585. $verifyList [$k] ['status'] = 4;
  1586. $button = 4;
  1587. $flag = false;
  1588. }
  1589. } else {
  1590. foreach ( $verifyStaff as $m => $u ) {
  1591. if ($v [0] == $m) {
  1592. $verifyList [$k] ['date'] = $u ['date'];
  1593. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1594. $verifyList [$k] ['status'] = $u ['status'];
  1595. $flag = false;
  1596. break;
  1597. }
  1598. }
  1599. $endStaffArray = end ( $verifyStaff );
  1600. if (isset ( $endStaffArray ['ROLE'] )) {
  1601. } else {
  1602. $endKey = key ( $verifyStaff );
  1603. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1604. $button = 4;
  1605. $verifyList [$k] ['status'] = 4;
  1606. }
  1607. }
  1608. }
  1609. }
  1610. $rolename ['name'] = '';
  1611. if (! empty ( $roleId )) {
  1612. Doo::loadModel ( 'role' );
  1613. $role = new role ();
  1614. $rolename = $role->getOne ( array (
  1615. 'where' => 'rid=' . $roleId,
  1616. 'asArray' => true
  1617. ) );
  1618. }
  1619. if (! empty ( $verifyStaff ))
  1620. $endStaffArray = end ( $verifyStaff );
  1621. $KOP = false;
  1622. foreach ( $roleArrayCopy as $P => $A ) {
  1623. foreach ( $A as $MKI => $AVL ) {
  1624. if (! empty ( $verifyStaff )) {
  1625. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1626. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1627. $button = 4;
  1628. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1629. }
  1630. foreach ( $verifyStaff as $m => $u ) {
  1631. $AVLFK = $AVL [0] . '_R';
  1632. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1633. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1634. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1635. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1636. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1637. break;
  1638. }
  1639. }
  1640. } else {
  1641. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1642. $button = 4;
  1643. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1644. }
  1645. }
  1646. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1647. $KOP = true;
  1648. }
  1649. }
  1650. foreach ( $roleArrayCopy as $k => $v ) {
  1651. foreach ( $verifyList as $m => $n ) {
  1652. if ($n [0] == $k) {
  1653. array_splice ( $verifyList, $m, 1, $v );
  1654. }
  1655. }
  1656. }
  1657. $receiptList [$key] ['verifyList'] = $verifyList;
  1658. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1659. 'where' => 'sid=' . $value ['staff'],
  1660. 'asArray' => true
  1661. ) );
  1662. $receiptList [$key] ['button'] = $button;
  1663. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1664. }
  1665. $mothHtml = "";
  1666. for($i = 1; $i <= 12; $i ++) {
  1667. if ($month == $i)
  1668. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1669. else
  1670. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1671. }
  1672. // 获取审批日志
  1673. Doo::loadModel ( 'receiptLog' );
  1674. $receiptLog = new receiptLog ();
  1675. $rlList = array ();
  1676. $rlInfo = $receiptLog->getOne ( array (
  1677. 'where' => 'rid=' . $rid . ' and status=4',
  1678. 'asArray' => true
  1679. ) );
  1680. $tijdate = $receiptLog->getOne ( array (
  1681. 'where' => 'rid=' . $rid . ' and status=2',
  1682. 'asc' => 'rlid',
  1683. 'asArray' => true
  1684. ) );
  1685. if (! empty ( $rlInfo )) {
  1686. $rlList = $receiptLog->find ( array (
  1687. 'where' => 'rid=' . $rid,
  1688. 'asc' => 'rlid',
  1689. 'asArray' => true
  1690. ) );
  1691. }
  1692. $receiptList [0] ['rlList'] = $rlList;
  1693. $enclosurList = $enclosur->find ( array (
  1694. 'where' => 'rid=' . $rid,
  1695. 'asArray' => true
  1696. ) );
  1697. $enclosurHtml = '';
  1698. foreach ( $enclosurList as $value ) {
  1699. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1700. }
  1701. // print_r($receiptList);
  1702. $data ['enclosurHtml'] = $enclosurHtml;
  1703. $data ['rolename'] = $rolename ['name'];
  1704. $data ['datetij'] = $tijdate ['date'];
  1705. $data ['mothHtml'] = $mothHtml;
  1706. $data ['rid'] = $rid;
  1707. $data ['receiptList'] = $receiptList;
  1708. $data ['receiptApprovalCount'] = count ( $receiptList );
  1709. $data ['status'] = $status;
  1710. $data ['year'] = $year;
  1711. $data ['categoryList'] = $categoryList;
  1712. $data ['staffList'] = $staffList;
  1713. $data ['cid'] = $cid;
  1714. $data ['sid'] = $sid;
  1715. $data ['ap'] = $ap;
  1716. $data ['memu'] = "receipt";
  1717. $data ['staff'] = $this->staff;
  1718. $data ['receiptMemu'] = 'approvalExpenses';
  1719. $data ['verifyId'] = $this->verifyId;
  1720. $data ['executeId'] = $this->executeId;
  1721. $this->render ( "/admin/remitApproval", $data );
  1722. }
  1723. function saeaLoanAdd() {
  1724. Doo::loadModel ( 'verify' );
  1725. $verify = new verify ();
  1726. Doo::loadModel ( "role" );
  1727. $role = new role ();
  1728. Doo::loadModel ( 'L_category' );
  1729. $lCategory = new L_category ();
  1730. $veList = $verify->getVerifyBySubordinate('LOAN');
  1731. $data ['category'] = $lCategory->find ( array (
  1732. 'asArray' => true
  1733. ) );
  1734. $data ['veList'] = $veList;
  1735. $data ['memu'] = "receipt";
  1736. $data ['staff'] = $this->staff;
  1737. $data ['receiptMemu'] = 'saeaBorad';
  1738. $data ['verifyId'] = $this->verifyId;
  1739. $data ['executeId'] = $this->executeId;
  1740. $this->render ( "/admin/saeaLoanAdd", $data );
  1741. }
  1742. function saeaLoanAddDo() {
  1743. $agency = $this->get_args ( 'agency' );
  1744. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1745. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1746. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1747. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1748. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1749. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1750. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1751. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1752. // die;
  1753. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1754. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1755. header ( 'Content-Type:text/html;charset=utf-8' );
  1756. die ( '请填写联行号' );
  1757. }
  1758. Doo::loadModel ( 'receipt' );
  1759. Doo::loadModel ( 'receiptDetail' );
  1760. Doo::loadModel ( 'accountItem' );
  1761. $accountItem = new accountItem ();
  1762. $receipt = new receipt ();
  1763. Doo::loadModel ( 'loanReceipt' );
  1764. $loanReceipt = new loanReceipt ();
  1765. Doo::loadModel ( 'execute' );
  1766. $execute = new execute ();
  1767. Doo::loadModel ( 'enclosur' );
  1768. $executeDetail = $execute->getOne ( array (
  1769. 'where' => 'mold="借款执行人"',
  1770. 'asArray' => true
  1771. ) );
  1772. $aItem = $accountItem->find ( array (
  1773. 'asArray' => true
  1774. ) );
  1775. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1776. $ag = $tr = $ta = $ot = 0;
  1777. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1778. array_push ( $accountJson ['借款费用'], array (
  1779. 'aid' => 0,
  1780. 'name' => '申请金额',
  1781. 'price' => number_format ( $agency, 2, '.', '' )
  1782. ) );
  1783. $sum += $agency;
  1784. $agencySum += $agency;
  1785. $accountJson ['cSum'] = array (
  1786. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1787. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1788. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1789. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1790. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1791. );
  1792. // 借款数据备份
  1793. $loanReceipt->loanItem = json_encode ( $accountJson );
  1794. $loanReceipt->staff = $this->staff [0] ['sid'];
  1795. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1796. $loanReceipt->date = date ( "Y-m-d" );
  1797. $loanReceipt->cid = $cid;
  1798. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1799. $loanReceipt->status = 5;
  1800. $loanReceipt->Rtype = 1;
  1801. $loanReceipt->verify = $verify;
  1802. $receipt->receiptOrder = $receipt->receiptOrder;
  1803. // 添加HTML换行符
  1804. // var_dump($explanation);
  1805. $order = array (
  1806. "\r\n",
  1807. "\n",
  1808. "\r"
  1809. );
  1810. $replace = '<br/>';
  1811. $explanation = str_replace ( $order, $replace, $explanation );
  1812. // $explanation=str_replace('\r',"<br/>",$explanation);
  1813. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1814. $loanReceipt->explanation = $explanation;
  1815. $loanRid = $loanReceipt->insert ();
  1816. // 报销单
  1817. $receipt->loanItem = json_encode ( $accountJson );
  1818. $receipt->staff = $this->staff [0] ['sid'];
  1819. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1820. $receipt->date = date ( "Y-m-d" );
  1821. $receipt->cid = $cid;
  1822. // 特殊状态
  1823. $receipt->status = 5;
  1824. $receipt->Rtype = 1;
  1825. $receipt->loanRid = $loanRid;
  1826. // 修改审批流程加入角色
  1827. $receipt->verify = $verify;
  1828. $receipt->executeCopy = $executeDetail ['staff'];
  1829. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1830. $receipt->explanation = $explanation;
  1831. $receipt->remittanceName = $remittanceName;
  1832. $receipt->bankName = $bankName;
  1833. $receipt->bankNumber = $bankNumber;
  1834. $receipt->remittanceBankType = $remittanceBankType;
  1835. if ($remittanceBankType == 1)
  1836. $receipt->coupletNumber = $coupletNumber;
  1837. $rid = $receipt->insert ();
  1838. return "/saeaBorad";
  1839. } else
  1840. die ( 'illegal request' );
  1841. }
  1842. function saeaLoanEdi() {
  1843. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1844. Doo::loadClass ( 'XDeode' );
  1845. $XDeode = new XDeode ( 7 );
  1846. $rid = $XDeode->decode ( $ridKey );
  1847. if (! is_numeric ( $rid ))
  1848. die ( 'illegal request' );
  1849. Doo::loadModel ( 'verify' );
  1850. $verify = new verify ();
  1851. Doo::loadModel ( "role" );
  1852. $role = new role ();
  1853. Doo::loadModel ( 'L_category' );
  1854. $lCategory = new L_category ();
  1855. Doo::loadModel ( 'receipt' );
  1856. $receipt = new receipt ();
  1857. $receiptInfo = $receipt->getOne ( array (
  1858. 'where' => 'rid=' . $rid,
  1859. 'asArray' => true
  1860. ) );
  1861. $veList = $verify->find ( array (
  1862. 'where'=>'subordinate like "%LOAN%"',
  1863. 'asArray' => true
  1864. ) );
  1865. foreach ( $veList as $key => $value ) {
  1866. $v = json_decode ( $value ['staff'] );
  1867. $list = array ();
  1868. foreach ( $v as $n => $m ) {
  1869. if ($m ['1'] == 'ROLE') {
  1870. $roleInfo = $role->getOne ( array (
  1871. 'where' => 'rid=' . $m [0],
  1872. 'asArray' => true
  1873. ) );
  1874. $v [$n] [1] = $roleInfo ['name'];
  1875. array_push ( $list, $roleInfo ['name'] );
  1876. } else {
  1877. array_push ( $list, $v [$n] [1] );
  1878. }
  1879. }
  1880. $veList [$key] ['staff'] = implode ( '>', $list );
  1881. }
  1882. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1883. // print_r($receiptInfo);
  1884. $data ['receiptInfo'] = $receiptInfo;
  1885. $data ['category'] = $lCategory->find ( array (
  1886. 'asArray' => true
  1887. ) );
  1888. $data ['veList'] = $veList;
  1889. $data ['ridKey'] = $ridKey;
  1890. $data ['memu'] = "receipt";
  1891. $data ['staff'] = $this->staff;
  1892. $data ['receiptMemu'] = 'saeaBorad';
  1893. $data ['verifyId'] = $this->verifyId;
  1894. $data ['executeId'] = $this->executeId;
  1895. $this->render ( "/admin/saeaLoanEdi", $data );
  1896. }
  1897. function saeaLoanEdiDo() {
  1898. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1899. $agency = $this->get_args ( 'agency' );
  1900. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1901. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1902. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1903. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1904. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1905. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1906. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1907. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1908. // die;
  1909. Doo::loadClass ( 'XDeode' );
  1910. $XDeode = new XDeode ( 7 );
  1911. $rid = $XDeode->decode ( $ridKey );
  1912. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1913. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1914. header ( 'Content-Type:text/html;charset=utf-8' );
  1915. die ( '请填写联行号' );
  1916. }
  1917. Doo::loadModel ( 'receipt' );
  1918. Doo::loadModel ( 'receiptDetail' );
  1919. Doo::loadModel ( 'accountItem' );
  1920. $accountItem = new accountItem ();
  1921. $receipt = new receipt ();
  1922. Doo::loadModel ( 'loanReceipt' );
  1923. $loanReceipt = new loanReceipt ();
  1924. Doo::loadModel ( 'enclosur' );
  1925. Doo::loadModel ( 'execute' );
  1926. $execute = new execute ();
  1927. $executeDetail = $execute->getOne ( array (
  1928. 'where' => 'mold="借款执行人"',
  1929. 'asArray' => true
  1930. ) );
  1931. $receiptDetail = $receipt->getOne ( array (
  1932. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1933. 'asArray' => true
  1934. ) );
  1935. if (empty ( $receiptDetail ))
  1936. die ( '参数错误' );
  1937. $aItem = $accountItem->find ( array (
  1938. 'asArray' => true
  1939. ) );
  1940. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1941. $ag = $tr = $ta = $ot = 0;
  1942. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1943. array_push ( $accountJson ['借款费用'], array (
  1944. 'aid' => 0,
  1945. 'name' => '申请金额',
  1946. 'price' => number_format ( $agency, 2, '.', '' )
  1947. ) );
  1948. $sum += $agency;
  1949. $agencySum += $agency;
  1950. $accountJson ['cSum'] = array (
  1951. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1952. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1953. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1954. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1955. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1956. );
  1957. // 报销单
  1958. $receipt->loanItem = json_encode ( $accountJson );
  1959. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1960. $receipt->cid = $cid;
  1961. // 特殊状态
  1962. // 修改审批流程加入角色
  1963. if ($receiptDetail ['status'] != 4)
  1964. $receipt->verify = $verify;
  1965. $order = array (
  1966. "\r\n",
  1967. "\n",
  1968. "\r"
  1969. );
  1970. $replace = '<br/>';
  1971. $explanation = str_replace ( $order, $replace, $explanation );
  1972. $receipt->explanation = $explanation;
  1973. $receipt->remittanceName = $remittanceName;
  1974. $receipt->bankName = $bankName;
  1975. $receipt->bankNumber = $bankNumber;
  1976. $receipt->remittanceBankType = $remittanceBankType;
  1977. if ($remittanceBankType == 1)
  1978. $receipt->coupletNumber = $coupletNumber;
  1979. $receipt->update ( array (
  1980. 'where' => 'rid=' . $rid
  1981. ) );
  1982. // 借款数据更新
  1983. $loanReceipt->loanItem = json_encode ( $accountJson );
  1984. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1985. $loanReceipt->cid = $cid;
  1986. if ($receiptDetail ['status'] != 4)
  1987. $loanReceipt->verify = $verify;
  1988. $loanReceipt->explanation = $explanation;
  1989. $receipt->executeCopy = $executeDetail ['staff'];
  1990. $loanReceipt->update ( array (
  1991. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1992. ) );
  1993. }
  1994. return "/saeaBorad";
  1995. }
  1996. function saeaLoanReceiptAdd() {
  1997. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1998. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  1999. Doo::loadModel ( 'receipt' );
  2000. $receipt = new receipt ();
  2001. Doo::loadModel ( 'loanReceipt' );
  2002. $loanReceipt = new loanReceipt ();
  2003. Doo::loadModel ( 'L_category' );
  2004. $Lcategory = new L_category ();
  2005. Doo::loadModel ( 'verify' );
  2006. Doo::loadModel ( 'statistics' );
  2007. $statistics = new statistics ();
  2008. $verify = new verify ();
  2009. Doo::loadModel ( 'staff' );
  2010. $staff = new staff ();
  2011. $receiptDetail = $receipt->getOne ( array (
  2012. 'where' => 'rid=' . $rid,
  2013. 'desc' => 'rid',
  2014. 'asArray' => true
  2015. ) );
  2016. $receiptList = $loanReceipt->find ( array (
  2017. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2018. 'desc' => 'rid',
  2019. 'asArray' => true
  2020. ) );
  2021. $Locate = 0;
  2022. $roleId = 0;
  2023. $button = 0;
  2024. foreach ( $receiptList as $key => $value ) {
  2025. $receiptList [$key] ['Locate'] = $Locate;
  2026. $Locate ++;
  2027. $receiptList [$key] ['reviseDetail'] = array ();
  2028. if (! empty ( $value ['reviseDetail'] ))
  2029. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2030. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2031. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2032. $categoryDetil = $Lcategory->getOne ( array (
  2033. 'where' => 'cid=' . $value ['cid'],
  2034. 'asArray' => true
  2035. ) );
  2036. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2037. // 检测编辑状态
  2038. $verifyList = $verify->getOne ( array (
  2039. 'where' => 'vid=' . $value ['verify'],
  2040. 'asArray' => true
  2041. ) );
  2042. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2043. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2044. Doo::loadModel ( 'role' );
  2045. $role = new role ();
  2046. $flag = true;
  2047. $roleKey = 0;
  2048. $endStaffArray = array ();
  2049. $roleArrayCopy = array ();
  2050. foreach ( $verifyList as $k => $v ) {
  2051. // init verifyStaff
  2052. if ($v [1] == 'ROLE') {
  2053. if (! empty ( $verifyStaff )) {
  2054. $endStaffArray = end ( $verifyStaff );
  2055. // if ($v[0]==$endStaffArray['nextStaff']){
  2056. // $roleId=$v[0];
  2057. // }
  2058. }
  2059. $roleVerify = json_decode ( $v [3], true );
  2060. $roleKey = $k;
  2061. $roleArray = array ();
  2062. $rolename = $role->getOne ( array (
  2063. 'where' => 'rid=' . $v [0],
  2064. 'asArray' => true
  2065. ) );
  2066. foreach ( $roleVerify as $o => $p ) {
  2067. $staffID = explode ( '_', $p );
  2068. $staffInfo = $staff->getOne ( array (
  2069. 'where' => 'sid=' . $staffID [0],
  2070. 'asArray' => true
  2071. ) );
  2072. // print_r($staffID);
  2073. $exp = array (
  2074. 0 => $staffInfo ['sid'],
  2075. 1 => $staffID [1],
  2076. 2 => $staffInfo ['avatar'],
  2077. 'date' => '',
  2078. 'date' => '',
  2079. 'opinion' => '',
  2080. 'status' => '',
  2081. 'rolename' => $rolename ['name']
  2082. );
  2083. array_push ( $roleArray, $exp );
  2084. }
  2085. $roleArrayCopy [$v [0]] = $roleArray;
  2086. // $verifyList[$k]['roleArray']=$roleArray;
  2087. }
  2088. $verifyList [$k] ['date'] = "";
  2089. $verifyList [$k] ['opinion'] = "";
  2090. $verifyList [$k] ['status'] = "";
  2091. if (empty ( $verifyStaff )) {
  2092. $verifyList [$k] ['date'] = "";
  2093. $verifyList [$k] ['opinion'] = "";
  2094. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2095. $verifyList [$k] ['status'] = 4;
  2096. $flag = false;
  2097. }
  2098. } else {
  2099. foreach ( $verifyStaff as $m => $u ) {
  2100. if ($v [0] == $m) {
  2101. $verifyList [$k] ['date'] = $u ['date'];
  2102. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2103. $verifyList [$k] ['status'] = $u ['status'];
  2104. $flag = false;
  2105. break;
  2106. }
  2107. }
  2108. $endStaffArray = end ( $verifyStaff );
  2109. if (isset ( $endStaffArray ['ROLE'] )) {
  2110. } else {
  2111. // $endKey=key($verifyStaff);
  2112. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2113. // $button=4;
  2114. // $verifyList[$k]['status']=4;
  2115. // }
  2116. }
  2117. }
  2118. }
  2119. $rolename ['name'] = '';
  2120. if (! empty ( $roleId )) {
  2121. Doo::loadModel ( 'role' );
  2122. $role = new role ();
  2123. $rolename = $role->getOne ( array (
  2124. 'where' => 'rid=' . $roleId,
  2125. 'asArray' => true
  2126. ) );
  2127. }
  2128. if (! empty ( $verifyStaff ))
  2129. $endStaffArray = end ( $verifyStaff );
  2130. $KOP = false;
  2131. foreach ( $roleArrayCopy as $P => $A ) {
  2132. foreach ( $A as $MKI => $AVL ) {
  2133. if (! empty ( $verifyStaff )) {
  2134. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2135. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2136. $button = 4;
  2137. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2138. }
  2139. foreach ( $verifyStaff as $m => $u ) {
  2140. $AVLFK = $AVL [0] . '_R';
  2141. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2142. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2143. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2144. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2145. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2146. break;
  2147. }
  2148. }
  2149. } else {
  2150. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2151. $button = 4;
  2152. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2153. }
  2154. }
  2155. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2156. $KOP = true;
  2157. }
  2158. }
  2159. foreach ( $roleArrayCopy as $k => $v ) {
  2160. foreach ( $verifyList as $m => $n ) {
  2161. if ($n [0] == $k) {
  2162. array_splice ( $verifyList, $m, 1, $v );
  2163. }
  2164. }
  2165. }
  2166. $receiptList [$key] ['verifyList'] = $verifyList;
  2167. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2168. 'where' => 'sid=' . $value ['staff'],
  2169. 'asArray' => true
  2170. ) );
  2171. $receiptList [$key] ['button'] = $button;
  2172. //
  2173. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2174. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2175. }
  2176. $data ['receiptList'] = $receiptList;
  2177. $data ['receiptDetail'] = $receiptDetail;
  2178. Doo::loadModel ( 'L_category' );
  2179. $lCategory = new L_category ();
  2180. Doo::loadModel ( 'accountItem' );
  2181. $accountItem = new accountItem ();
  2182. $acItem = $accountItem->find ( array (
  2183. 'asArray' => true
  2184. ) );
  2185. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2186. $data ['rid'] = $rid;
  2187. $data ['category'] = $lCategory->find ( array (
  2188. 'asArray' => true
  2189. ) );
  2190. $data ['veList'] = $veList;
  2191. $data ['acItem'] = $acItem;
  2192. $data['itineraryDate']=$this->_itineraryDateMin();
  2193. $data ['memu'] = "receipt";
  2194. $data ['staff'] = $this->staff;
  2195. $data ['receiptMemu'] = 'saeaBorad';
  2196. $data ['verifyId'] = $this->verifyId;
  2197. $data ['executeId'] = $this->executeId;
  2198. $data['receiptClass']=$receiptClass;
  2199. if($receiptClass=='trave'){
  2200. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2201. }else{
  2202. $this->render ( "/receipt/feeLoanReceipt", $data );
  2203. }
  2204. }
  2205. function saeaLoanReceiptAddDo() {
  2206. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2207. $agency = $this->get_args ( 'agency' );
  2208. $travel = $this->get_args ( 'travel' );
  2209. $train = $this->get_args ( 'train' );
  2210. $other = $this->get_args ( 'other' );
  2211. $inttrain = $this->get_args ( 'inttrain' );
  2212. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2213. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2214. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2215. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2216. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2217. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2218. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2219. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2220. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2221. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2222. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2223. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2224. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2225. header ( 'Content-Type:text/html;charset=utf-8' );
  2226. die ( '请填写联行号' );
  2227. }
  2228. if($receiptClass=='agency'){
  2229. $receiptClass=1;
  2230. }elseif($receiptClass=='trave'){
  2231. $receiptClass=2;
  2232. if($this->_verificationItinerary($itinerary)){
  2233. header ( 'Content-Type:text/html;charset=utf-8' );
  2234. die ( '已申请过类此日期的行程' );
  2235. }
  2236. }elseif($receiptClass=='internalTrain'){
  2237. $receiptClass=3;
  2238. }else{
  2239. header ( 'Content-Type:text/html;charset=utf-8' );
  2240. die ( '借款报销单分类不正确' );
  2241. }
  2242. Doo::loadModel ( 'receipt' );
  2243. Doo::loadModel ( 'receiptDetail' );
  2244. Doo::loadModel ( 'accountItem' );
  2245. $accountItem = new accountItem ();
  2246. $receipt = new receipt ();
  2247. Doo::loadModel ( 'enclosur' );
  2248. Doo::loadModel ( 'execute' );
  2249. $execute = new execute ();
  2250. $executeDetail = $execute->getOne ( array (
  2251. 'where' => 'mold="借款费用执行人"',
  2252. 'asArray' => true
  2253. ) );
  2254. $receiptDet = $receipt->getOne ( array (
  2255. 'where' => 'rid=' . $rid,
  2256. 'asArray' => true
  2257. ) );
  2258. // if(!empty($receiptDetail))
  2259. // return "/referReceipt/".$receiptDetail['rid'];
  2260. $aItem = $accountItem->find ( array (
  2261. 'asArray' => true
  2262. ) );
  2263. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2264. $ag = $tr = $ta = $ot =$it = 0;
  2265. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2266. foreach ( $aItem as $key => $value ) {
  2267. if ($value ['category'] == $this->AGENCY) {
  2268. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2269. array_push ( $accountJson [$this->AGENCY], array (
  2270. 'aid' => $value ['aid'],
  2271. 'name' => $value ['name'],
  2272. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2273. ) );
  2274. $sum += $agency [$ag];
  2275. $agencySum += $agency [$ag];
  2276. }
  2277. $ag ++;
  2278. }
  2279. if ($value ['category'] == $this->TRAVEL) {
  2280. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2281. array_push ( $accountJson [$this->TRAVEL], array (
  2282. 'aid' => $value ['aid'],
  2283. 'name' => $value ['name'],
  2284. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2285. ) );
  2286. $sum += $travel [$tr];
  2287. $travelSum += $travel [$tr];
  2288. }
  2289. $tr ++;
  2290. }
  2291. if ($value ['category'] == $this->INTTRAIN) {
  2292. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2293. array_push ( $accountJson [$this->INTTRAIN], array (
  2294. 'aid' => $value ['aid'],
  2295. 'name' => $value ['name'],
  2296. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2297. ) );
  2298. $sum += $inttrain [$it];
  2299. $inttrainSum += $inttrain [$it];
  2300. }
  2301. $it ++;
  2302. }
  2303. if ($value ['category'] == $this->TRAIN) {
  2304. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2305. array_push ( $accountJson [$this->TRAIN], array (
  2306. 'aid' => $value ['aid'],
  2307. 'name' => $value ['name'],
  2308. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2309. ) );
  2310. $sum += $train [$ta];
  2311. $trainSum += $train [$ta];
  2312. }
  2313. $ta ++;
  2314. }
  2315. if ($value ['category'] == $this->OTHER) {
  2316. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2317. array_push ( $accountJson [$this->OTHER], array (
  2318. 'aid' => $value ['aid'],
  2319. 'name' => $value ['name'],
  2320. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2321. ) );
  2322. $sum += $other [$ot];
  2323. $otherSum += $other [$ot];
  2324. }
  2325. $ot ++;
  2326. }
  2327. }
  2328. $accountJson ['cSum'] = array (
  2329. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2330. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2331. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2332. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2333. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2334. );
  2335. // 报销单
  2336. $receipt->accountItem = json_encode ( $accountJson );
  2337. $receipt->staff = $this->staff [0] ['sid'];
  2338. $receipt->loanSum = $receiptDet ['sum'];
  2339. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2340. $receipt->date = date ( "Y-m-d" );
  2341. $receipt->pastDate = '0000-00-00';
  2342. $receipt->cid = $cid;
  2343. $receipt->status = 7;
  2344. $receipt->receiptClass=$receiptClass;
  2345. if($receiptClass==2){
  2346. $receipt->itinerary=$itinerary;
  2347. $this->_storageItinerary($itinerary, $rid);
  2348. }
  2349. // 修改审批流程加入角色
  2350. $receipt->verify = $verify;
  2351. $receipt->verifyStaff = '';
  2352. $receipt->executeStaff = '';
  2353. $receipt->executeCopy = $executeDetail ['staff'];
  2354. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2355. $receipt->explanation = $explanation;
  2356. $receipt->remittanceName = $remittanceName;
  2357. $receipt->bankName = $bankName;
  2358. $receipt->bankNumber = $bankNumber;
  2359. $receipt->remittanceBankType = $remittanceBankType;
  2360. if ($remittanceBankType == 1)
  2361. $receipt->coupletNumber = $coupletNumber;
  2362. $receipt->update ( array (
  2363. 'where' => 'rid=' . $rid
  2364. ) );
  2365. // 附件
  2366. if (! empty ( $enclosurName )) {
  2367. $enclosurArray = explode ( '-', $enclosurName );
  2368. foreach ( $enclosurArray as $value ) {
  2369. $enclosur = new enclosur ();
  2370. $enclosur->name = $value;
  2371. $enclosur->rid = $rid;
  2372. $enclosur->insert ();
  2373. }
  2374. // print_r($enclosurArray);die;
  2375. }
  2376. // 报销详情
  2377. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2378. $receiptDetail = new receiptDetail ();
  2379. $receiptDetail->staff = $this->staff [0] ['sid'];
  2380. $receiptDetail->item = $value ['name'];
  2381. $receiptDetail->itemCategory = $this->AGENCY;
  2382. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2383. $receiptDetail->date = date ( "Y-m-d" );
  2384. $receiptDetail->cid = $cid;
  2385. $receiptDetail->rid = $rid;
  2386. $receiptDetail->status = 4;
  2387. $receiptDetail->insert ();
  2388. }
  2389. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2390. $receiptDetail = new receiptDetail ();
  2391. $receiptDetail->staff = $this->staff [0] ['sid'];
  2392. $receiptDetail->item = $value ['name'];
  2393. $receiptDetail->itemCategory = $this->TRAVEL;
  2394. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2395. $receiptDetail->date = date ( "Y-m-d" );
  2396. $receiptDetail->cid = $cid;
  2397. $receiptDetail->rid = $rid;
  2398. $receiptDetail->status = 4;
  2399. $receiptDetail->insert ();
  2400. }
  2401. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2402. $receiptDetail = new receiptDetail ();
  2403. $receiptDetail->staff = $this->staff [0] ['sid'];
  2404. $receiptDetail->item = $value ['name'];
  2405. $receiptDetail->itemCategory = $this->TRAIN;
  2406. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2407. $receiptDetail->date = date ( "Y-m-d" );
  2408. $receiptDetail->cid = $cid;
  2409. $receiptDetail->rid = $rid;
  2410. $receiptDetail->status = 4;
  2411. $receiptDetail->insert ();
  2412. }
  2413. //内训
  2414. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2415. $receiptDetail = new receiptDetail ();
  2416. $receiptDetail->staff = $this->staff [0] ['sid'];
  2417. $receiptDetail->item = $value ['name'];
  2418. $receiptDetail->itemCategory = $this->INTTRAIN;
  2419. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2420. $receiptDetail->date = date ( "Y-m-d" );
  2421. $receiptDetail->cid = $cid;
  2422. $receiptDetail->rid = $rid;
  2423. $receiptDetail->status = 4;
  2424. $receiptDetail->insert ();
  2425. }
  2426. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2427. $receiptDetail = new receiptDetail ();
  2428. $receiptDetail->staff = $this->staff [0] ['sid'];
  2429. $receiptDetail->item = $value ['name'];
  2430. $receiptDetail->itemCategory = $this->OTHER;
  2431. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2432. $receiptDetail->date = date ( "Y-m-d" );
  2433. $receiptDetail->cid = $cid;
  2434. $receiptDetail->rid = $rid;
  2435. $receiptDetail->status = 4;
  2436. $receiptDetail->insert ();
  2437. }
  2438. return "/saeaBorad";
  2439. }
  2440. return "/saeaLoanReceiptAdd/" . $rid;
  2441. }
  2442. function saeaLoanReceiptEdi() {
  2443. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2444. Doo::loadClass ( 'XDeode' );
  2445. $XDeode = new XDeode ( 7 );
  2446. $rid = $XDeode->decode ( $ridKey );
  2447. if (! is_numeric ( $rid ))
  2448. die ( 'illegal request' );
  2449. Doo::loadModel ( 'accountItem' );
  2450. Doo::loadModel ( 'verify' );
  2451. Doo::loadModel ( 'receipt' );
  2452. $receipt = new receipt ();
  2453. $verify = new verify ();
  2454. $accountItem = new accountItem ();
  2455. Doo::loadModel ( 'L_category' );
  2456. $Lcategory = new L_category ();
  2457. Doo::loadModel ( "role" );
  2458. $role = new role ();
  2459. Doo::loadModel ( 'loanReceipt' );
  2460. $loanReceipt = new loanReceipt ();
  2461. Doo::loadModel ( 'staff' );
  2462. $staff = new staff ();
  2463. $receiptDetail = $receipt->getOne ( array (
  2464. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2465. 'asArray' => true
  2466. ) );
  2467. if (empty ( $receiptDetail ))
  2468. return "/saeaBorad";
  2469. $receiptList = $loanReceipt->find ( array (
  2470. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2471. 'desc' => 'rid',
  2472. 'asArray' => true
  2473. ) );
  2474. $Locate = 0;
  2475. $roleId = 0;
  2476. $button = 0;
  2477. foreach ( $receiptList as $key => $value ) {
  2478. $receiptList [$key] ['Locate'] = $Locate;
  2479. $Locate ++;
  2480. $receiptList [$key] ['reviseDetail'] = array ();
  2481. if (! empty ( $value ['reviseDetail'] ))
  2482. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2483. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2484. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2485. $categoryDetil = $Lcategory->getOne ( array (
  2486. 'where' => 'cid=' . $value ['cid'],
  2487. 'asArray' => true
  2488. ) );
  2489. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2490. // 检测编辑状态
  2491. $verifyList = $verify->getOne ( array (
  2492. 'where' => 'vid=' . $value ['verify'],
  2493. 'asArray' => true
  2494. ) );
  2495. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2496. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2497. Doo::loadModel ( 'role' );
  2498. $role = new role ();
  2499. $flag = true;
  2500. $roleKey = 0;
  2501. $endStaffArray = array ();
  2502. $roleArrayCopy = array ();
  2503. foreach ( $verifyList as $k => $v ) {
  2504. // init verifyStaff
  2505. if ($v [1] == 'ROLE') {
  2506. if (! empty ( $verifyStaff )) {
  2507. $endStaffArray = end ( $verifyStaff );
  2508. // if ($v[0]==$endStaffArray['nextStaff']){
  2509. // $roleId=$v[0];
  2510. // }
  2511. }
  2512. $roleVerify = json_decode ( $v [3], true );
  2513. $roleKey = $k;
  2514. $roleArray = array ();
  2515. $rolename = $role->getOne ( array (
  2516. 'where' => 'rid=' . $v [0],
  2517. 'asArray' => true
  2518. ) );
  2519. foreach ( $roleVerify as $o => $p ) {
  2520. $staffID = explode ( '_', $p );
  2521. $staffInfo = $staff->getOne ( array (
  2522. 'where' => 'sid=' . $staffID [0],
  2523. 'asArray' => true
  2524. ) );
  2525. // print_r($staffID);
  2526. $exp = array (
  2527. 0 => $staffInfo ['sid'],
  2528. 1 => $staffID [1],
  2529. 2 => $staffInfo ['avatar'],
  2530. 'date' => '',
  2531. 'date' => '',
  2532. 'opinion' => '',
  2533. 'status' => '',
  2534. 'rolename' => $rolename ['name']
  2535. );
  2536. array_push ( $roleArray, $exp );
  2537. }
  2538. $roleArrayCopy [$v [0]] = $roleArray;
  2539. // $verifyList[$k]['roleArray']=$roleArray;
  2540. }
  2541. $verifyList [$k] ['date'] = "";
  2542. $verifyList [$k] ['opinion'] = "";
  2543. $verifyList [$k] ['status'] = "";
  2544. if (empty ( $verifyStaff )) {
  2545. $verifyList [$k] ['date'] = "";
  2546. $verifyList [$k] ['opinion'] = "";
  2547. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2548. $verifyList [$k] ['status'] = 4;
  2549. $flag = false;
  2550. }
  2551. } else {
  2552. foreach ( $verifyStaff as $m => $u ) {
  2553. if ($v [0] == $m) {
  2554. $verifyList [$k] ['date'] = $u ['date'];
  2555. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2556. $verifyList [$k] ['status'] = $u ['status'];
  2557. $flag = false;
  2558. break;
  2559. }
  2560. }
  2561. $endStaffArray = end ( $verifyStaff );
  2562. if (isset ( $endStaffArray ['ROLE'] )) {
  2563. } else {
  2564. // $endKey=key($verifyStaff);
  2565. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2566. // $button=4;
  2567. // $verifyList[$k]['status']=4;
  2568. // }
  2569. }
  2570. }
  2571. }
  2572. $rolename ['name'] = '';
  2573. if (! empty ( $roleId )) {
  2574. Doo::loadModel ( 'role' );
  2575. $role = new role ();
  2576. $rolename = $role->getOne ( array (
  2577. 'where' => 'rid=' . $roleId,
  2578. 'asArray' => true
  2579. ) );
  2580. }
  2581. if (! empty ( $verifyStaff ))
  2582. $endStaffArray = end ( $verifyStaff );
  2583. $KOP = false;
  2584. foreach ( $roleArrayCopy as $P => $A ) {
  2585. foreach ( $A as $MKI => $AVL ) {
  2586. if (! empty ( $verifyStaff )) {
  2587. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2588. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2589. $button = 4;
  2590. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2591. }
  2592. foreach ( $verifyStaff as $m => $u ) {
  2593. $AVLFK = $AVL [0] . '_R';
  2594. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2595. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2596. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2597. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2598. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2599. break;
  2600. }
  2601. }
  2602. } else {
  2603. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2604. $button = 4;
  2605. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2606. }
  2607. }
  2608. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2609. $KOP = true;
  2610. }
  2611. }
  2612. foreach ( $roleArrayCopy as $k => $v ) {
  2613. foreach ( $verifyList as $m => $n ) {
  2614. if ($n [0] == $k) {
  2615. array_splice ( $verifyList, $m, 1, $v );
  2616. }
  2617. }
  2618. }
  2619. $receiptList [$key] ['verifyList'] = $verifyList;
  2620. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2621. 'where' => 'sid=' . $value ['staff'],
  2622. 'asArray' => true
  2623. ) );
  2624. $receiptList [$key] ['button'] = $button;
  2625. //
  2626. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2627. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2628. }
  2629. $data ['receiptList'] = $receiptList;
  2630. $acItem = $accountItem->find ( array (
  2631. 'asArray' => true
  2632. ) );
  2633. $veList = $verify->find ( array (
  2634. 'asArray' => true
  2635. ) );
  2636. foreach ( $veList as $key => $value ) {
  2637. $v = json_decode ( $value ['staff'] );
  2638. $list = array ();
  2639. foreach ( $v as $n => $m ) {
  2640. if ($m ['1'] == 'ROLE') {
  2641. $roleInfo = $role->getOne ( array (
  2642. 'where' => 'rid=' . $m [0],
  2643. 'asArray' => true
  2644. ) );
  2645. $v [$n] [1] = $roleInfo ['name'];
  2646. array_push ( $list, $roleInfo ['name'] );
  2647. } else {
  2648. array_push ( $list, $v [$n] [1] );
  2649. }
  2650. }
  2651. $veList [$key] ['staff'] = implode ( '>', $list );
  2652. }
  2653. // 配置编辑信息
  2654. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2655. foreach ( $acItem as $key => $value ) {
  2656. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2657. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2658. $acItem [$key] ['price'] = $v ['price'];
  2659. }
  2660. }
  2661. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2662. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2663. $acItem [$key] ['price'] = $v ['price'];
  2664. }
  2665. }
  2666. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2667. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2668. $acItem [$key] ['price'] = $v ['price'];
  2669. }
  2670. }
  2671. //内训
  2672. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2673. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2674. $acItem [$key] ['price'] = $v ['price'];
  2675. }
  2676. }
  2677. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2678. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2679. $acItem [$key] ['price'] = $v ['price'];
  2680. }
  2681. }
  2682. }
  2683. $data ['category'] = $Lcategory->find ( array (
  2684. 'asArray' => true
  2685. ) );
  2686. $data ['ridKey'] = $ridKey;
  2687. $data ['cSum'] = $accountItemList ['cSum'];
  2688. $data ['sum'] = $receiptDetail ['sum'];
  2689. $data ['receiptDetail'] = $receiptDetail;
  2690. $data ['veList'] = $veList;
  2691. $data ['acItem'] = $acItem;
  2692. $data ['memu'] = "receipt";
  2693. $data ['staff'] = $this->staff;
  2694. $data ['receiptMemu'] = 'saeaBorad';
  2695. $data ['verify'] = $receiptDetail ['verify'];
  2696. $data ['verifyId'] = $this->verifyId;
  2697. $data ['executeId'] = $this->executeId;
  2698. $data ['rid'] = $rid;
  2699. if($receiptDetail['receiptClass']==1){
  2700. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2701. }elseif($receiptDetail['receiptClass']==2){
  2702. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2703. }elseif($receiptDetail['receiptClass']==3){
  2704. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2705. }else{
  2706. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2707. }
  2708. }
  2709. /**
  2710. * 培训班结算
  2711. */
  2712. function receiptTrainAdd() {
  2713. Doo::loadModel ( 'accountItem' );
  2714. $accountItem = new accountItem ();
  2715. $acItem = $accountItem->find ( array (
  2716. 'asArray' => true
  2717. ) );
  2718. // 审批组
  2719. Doo::loadModel ( 'verify' );
  2720. $verify = new verify ();
  2721. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2722. // 办事处
  2723. Doo::loadModel ( 'L_category' );
  2724. $lCategory = new L_category ();
  2725. $data ['category'] = $lCategory->getCategory ();
  2726. $data ['veList'] = $veList;
  2727. $data ['memu'] = "receipt";
  2728. $data ['staff'] = $this->staff;
  2729. $data ['acItem'] = $acItem;
  2730. $data ['receiptMemu'] = 'saeaBorad';
  2731. $data ['verifyId'] = $this->verifyId;
  2732. $data ['executeId'] = $this->executeId;
  2733. $this->render ( "/receipt/receiptTrainAdd", $data );
  2734. }
  2735. /**
  2736. * 添加培训班结算
  2737. */
  2738. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2739. // 培训班信息
  2740. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2741. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2742. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2743. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2744. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2745. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2746. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2747. // 发票信息
  2748. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2749. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2750. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2751. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2752. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2753. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2754. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2755. //&&! empty ( $participants )
  2756. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2757. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2758. header ( 'Content-Type:text/html;charset=utf-8' );
  2759. die ( '请填写联行号' );
  2760. }
  2761. Doo::loadModel ( 'execute' );
  2762. $execute = new execute ();
  2763. $executeDetail = $execute->getOne ( array (
  2764. 'where' => 'mold="培训班结算"',
  2765. 'asArray' => true
  2766. ) );
  2767. if (empty ( $executeDetail )) {
  2768. header ( 'Content-Type:text/html;charset=utf-8' );
  2769. die ( '未设置执行人' );
  2770. }
  2771. Doo::loadClass ( 'XDeode' );
  2772. $XDeode = new XDeode ( 5 );
  2773. $cid = $XDeode->decode ( $cid );
  2774. Doo::loadModel ( 'receipt' );
  2775. $receipt = new receipt ();
  2776. Doo::loadModel ( 'receiptTraining' );
  2777. $receiptTraining = new receiptTraining ();
  2778. // 创建费用培训班
  2779. $item = array (
  2780. 'cid' => $this->staff [0] ['cid'],
  2781. 'categoryName' => $this->staff [0] ['category'],
  2782. 'trainName' => $trainName,
  2783. 'trainStartDate' => $trainStartDate,
  2784. 'trainEndDate' => $trainEndDate,
  2785. 'participants' => $participants,
  2786. 'freeParticipants'=>$freeParticipants,
  2787. 'trainAddress' => $trainAddress,
  2788. 'trainRemarks' => $trainRemarks,
  2789. 'creator' => $this->staff [0] ['sid'],
  2790. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2791. );
  2792. $irid = $receiptTraining->addReceiptTraining ( $item );
  2793. // 报销单
  2794. $receipt->status = 5;
  2795. $receipt->trainId = $irid;
  2796. $receipt->Rtype = 3;
  2797. $receipt->staff = $this->staff [0] ['sid'];
  2798. $receipt->cid = $cid;
  2799. $receipt->verify = $verify;
  2800. $receipt->date = date ( "Y-m-d" );
  2801. $receipt->executeCopy = $executeDetail ['staff'];
  2802. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2803. $receipt->remittanceName = $remittanceName;
  2804. $receipt->bankName = $bankName;
  2805. $receipt->bankNumber = $bankNumber;
  2806. $receipt->remittanceBankType = $remittanceBankType;
  2807. if ($remittanceBankType == 1)
  2808. $receipt->coupletNumber = $coupletNumber;
  2809. $rid = $receipt->insert ();
  2810. $XDeode = new XDeode ( 7 );
  2811. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2812. } else
  2813. die ( 'illegal request' );
  2814. }
  2815. /**
  2816. * 培训班编辑
  2817. */
  2818. function receiptTrainEdi() {
  2819. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2820. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2821. Doo::loadClass ( 'XDeode' );
  2822. $XDeode = new XDeode ( 7 );
  2823. $rid = $XDeode->decode ( $ridKey );
  2824. if (! is_numeric ( $rid ))
  2825. die ( 'illegal request' );
  2826. Doo::loadModel ( 'receipt' );
  2827. $receipt = new receipt ();
  2828. Doo::loadModel ( 'receiptTraining' );
  2829. $receiptTraining = new receiptTraining ();
  2830. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2831. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2832. die ('illegal request--status');
  2833. }
  2834. //如有已入账已收款的发票,自动取消办事处已收款
  2835. // Doo::loadModel ( 'RIExtend' );
  2836. // $RIExtend = new RIExtend ();
  2837. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2838. // if (!empty($RIExtendList)){
  2839. // foreach ($RIExtendList as $key=>$value){
  2840. // $RIExtend = new RIExtend ();
  2841. // $RIExtend->delete(array (
  2842. // 'where' => 'iid=' . $value['iid'],
  2843. // 'limit' => 1
  2844. // ));
  2845. // }
  2846. // }
  2847. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2848. // 汇总表合计
  2849. // 收入合计--加入开票合计
  2850. Doo::loadModel ( 'invoiceTraining' );
  2851. $invoiceTraining = new invoiceTraining ();
  2852. $invoiceTrainingDetail = array (
  2853. 'invoiceArriveAmount' => 0,
  2854. 'RIAmount' => 0,
  2855. 'invoiceTotalAmount' => 0,
  2856. 'invoiceCompanyAmount'=>0
  2857. );
  2858. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2859. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2860. }
  2861. // print_r($invoiceTrainingDetail);
  2862. $invoiceArriveAmount = $RIAmount = 0;
  2863. if (! empty ( $invoiceTrainingDetail )) {
  2864. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2865. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2866. }
  2867. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2868. //print_r($invoiceTrainingDetail);
  2869. // 支出项目
  2870. Doo::loadModel ( 'accountItem' );
  2871. $accountItem = new accountItem ();
  2872. // 项目金额合计
  2873. Doo::loadModel ( 'RItem' );
  2874. $RItem = new RItem ();
  2875. // 讲师获得
  2876. Doo::loadModel ( 'RILecturer' );
  2877. $RILecturer = new RILecturer ();
  2878. $RItemList = $RItem->getRItemByRid ( $rid );
  2879. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2880. // 支出项金额详情
  2881. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2882. // print_r($aiData);
  2883. // 利润
  2884. $profit=$invoiceArriveAmount - $aiData ['total'];
  2885. $companyProfit=$profit * 0.6;
  2886. $categoryProfit=$profit * 0.4;
  2887. $data ['profit'] = sprintf("%.2f",$profit);
  2888. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2889. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2890. //发票利润
  2891. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2892. //发票公司利润
  2893. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2894. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2895. //办事处利润
  2896. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2897. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2898. // print_r($aiData['dataList']);
  2899. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2900. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2901. // 备用金
  2902. $sum = 0;
  2903. $data ['receiptLoanDetail'] = array (
  2904. 'sum' => '0.00'
  2905. );
  2906. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2907. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2908. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2909. $sum=0;
  2910. foreach ($receiptLoanList as $key=>$value){
  2911. $sum+=$value['sum'];
  2912. }
  2913. $data ['receiptLoanDetail'] = array (
  2914. 'sum' => $sum
  2915. );
  2916. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2917. }
  2918. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2919. $data ['payment'] = sprintf("%.2f",$payment);
  2920. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2921. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2922. $data ['aiList'] = $aiData ['dataList'];
  2923. // 占比计算
  2924. if ($invoiceArriveAmount != 0) {
  2925. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2926. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2927. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2928. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2929. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2930. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2931. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2932. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2933. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2934. } else {
  2935. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2936. }
  2937. //发票金额占比计算
  2938. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2939. //支出
  2940. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2941. //利润
  2942. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2943. //公司利润
  2944. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2945. //办事处利润
  2946. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2947. //公司收款
  2948. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2949. //备用金
  2950. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2951. //办事处收款
  2952. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2953. //办事处实际支出
  2954. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2955. //付总部款
  2956. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2957. }else{
  2958. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2959. }
  2960. //讲师人数
  2961. Doo::loadModel ( 'RILecturer' );
  2962. $RILecturer = new RILecturer ();
  2963. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2964. $data['lectureCount']=count($RILecturerList);
  2965. // 审批组
  2966. Doo::loadModel ( 'verify' );
  2967. $verify = new verify ();
  2968. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2969. // 办事处
  2970. Doo::loadModel ( 'L_category' );
  2971. $lCategory = new L_category ();
  2972. $data ['category'] = $lCategory->getCategory ();
  2973. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2974. $data ['receiptDetail'] = $receiptDetail;
  2975. $data ['veList'] = $veList;
  2976. $data ['trainEdiType'] = $trainEdiType;
  2977. $data ['ridKey'] = $ridKey;
  2978. $data ['memu'] = "receipt";
  2979. $data ['staff'] = $this->staff;
  2980. $data ['receiptMemu'] = 'saeaBorad';
  2981. $data ['verifyId'] = $this->verifyId;
  2982. $data ['executeId'] = $this->executeId;
  2983. $this->render ( "/receipt/receiptTrainEdi", $data );
  2984. }
  2985. /**
  2986. * 培训班借款编辑
  2987. */
  2988. function receiptTrainLoanEdi() {
  2989. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2990. Doo::loadClass ( 'XDeode' );
  2991. $XDeode = new XDeode ( 7 );
  2992. $rid = $XDeode->decode ( $ridKey );
  2993. if (! is_numeric ( $rid ))
  2994. die ( 'illegal request' );
  2995. Doo::loadModel ( 'receipt' );
  2996. $receipt = new receipt ();
  2997. Doo::loadModel ( 'receiptTraining' );
  2998. $receiptTraining = new receiptTraining ();
  2999. Doo::loadModel ( 'verify' );
  3000. $verify = new verify ();
  3001. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3002. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3003. die ();
  3004. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3005. // 借款详情HTML
  3006. // 获得借款信息
  3007. $receiptLoanHtml = '';
  3008. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  3009. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  3010. foreach ($receiptLoanList as $key=>$value){
  3011. // 获得某费用单审批信息
  3012. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  3013. Doo::loadClass ( 'receipt.func' );
  3014. $extendHtml = '<p><a class="button"
  3015. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  3016. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  3017. }
  3018. }
  3019. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  3020. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3021. $data ['receiptDetail'] = $receiptDetail;
  3022. $data ['trainEdiType'] = "LOAN";
  3023. $data ['ridKey'] = $ridKey;
  3024. $data ['memu'] = "receipt";
  3025. $data ['staff'] = $this->staff;
  3026. $data ['receiptMemu'] = 'saeaBorad';
  3027. $data ['verifyId'] = $this->verifyId;
  3028. $data ['executeId'] = $this->executeId;
  3029. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  3030. }
  3031. /**
  3032. * 更新培训班结算基本信息
  3033. */
  3034. function receiptTrainInfoEdiDo() {
  3035. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  3036. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  3037. // 培训班信息
  3038. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  3039. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  3040. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  3041. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  3042. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  3043. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  3044. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  3045. // 发票信息
  3046. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  3047. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3048. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  3049. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  3050. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  3051. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  3052. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  3053. //&& ! empty ( $participants )
  3054. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  3055. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  3056. header ( 'Content-Type:text/html;charset=utf-8' );
  3057. die ( '请填写联行号' );
  3058. }
  3059. Doo::loadClass ( 'XDeode' );
  3060. $XDeode = new XDeode ( 5 );
  3061. $cid = $XDeode->decode ( $cid );
  3062. $rtid = $XDeode->decode ( $rtid );
  3063. $rid = $XDeode->decode ( $rid );
  3064. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  3065. die ( 'illegal request-IdError' );
  3066. }
  3067. Doo::loadModel ( 'receipt' );
  3068. $receipt = new receipt ();
  3069. Doo::loadModel ( 'receiptTraining' );
  3070. $receiptTraining = new receiptTraining ();
  3071. // 更新费用培训班
  3072. $item = array (
  3073. 'rtid' => $rtid,
  3074. 'trainName' => $trainName,
  3075. 'trainStartDate' => $trainStartDate,
  3076. 'trainEndDate' => $trainEndDate,
  3077. 'participants' => $participants,
  3078. 'freeParticipants'=>$freeParticipants,
  3079. 'trainAddress' => $trainAddress,
  3080. 'trainRemarks' => $trainRemarks
  3081. );
  3082. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3083. // 报销单
  3084. $receipt->rid = $rid;
  3085. $receipt->cid = $cid;
  3086. $receipt->verify = $verify;
  3087. $receipt->remittanceName = $remittanceName;
  3088. $receipt->bankName = $bankName;
  3089. $receipt->bankNumber = $bankNumber;
  3090. $receipt->remittanceBankType = $remittanceBankType;
  3091. if ($remittanceBankType == 1)
  3092. $receipt->coupletNumber = $coupletNumber;
  3093. $receipt->update ();
  3094. $XDeode = new XDeode ( 7 );
  3095. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3096. } else
  3097. die ( 'illegal request' );
  3098. }
  3099. /**
  3100. * 编辑培训班结算---更新借款
  3101. */
  3102. function receiptTrainLoanEdiDo() {
  3103. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3104. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3105. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3106. Doo::loadModel ( 'receipt' );
  3107. $receipt = new receipt ();
  3108. Doo::loadClass ( 'XDeode' );
  3109. $XDeode = new XDeode ( 5 );
  3110. $rid = $XDeode->decode ( $ridKey );
  3111. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3112. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3113. die ( 'illegal request-ridError' );
  3114. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3115. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3116. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3117. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3118. die ( 'illegal request-receiptError' );
  3119. }
  3120. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3121. die ( 'illegal request-receipLoantError' );
  3122. }
  3123. // 培训班结算挂钩借款
  3124. $receipt = new receipt ();
  3125. $trainLoanRid=$ridLoan;
  3126. if (!empty($receiptDetail['trainLoanRid'])){
  3127. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3128. }
  3129. $item = array (
  3130. 'rid' => $rid,
  3131. 'trainLoanRid' => $trainLoanRid
  3132. );
  3133. $receipt->setReceiptByCondition ( $item );
  3134. // 更新借款状态变成已挂钩
  3135. $receipt = new receipt ();
  3136. $item = array (
  3137. 'rid' => $ridLoan,
  3138. 'status' => 10,
  3139. 'statusTrain' => 1
  3140. );
  3141. $receipt->setReceiptByCondition ( $item );
  3142. $XDeode = new XDeode ( 7 );
  3143. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3144. } else
  3145. die ( 'illegal request' );
  3146. }
  3147. /**
  3148. * 编辑培训班结算--移除借款
  3149. */
  3150. function receiptTrainLoanRemoveDo() {
  3151. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3152. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3153. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3154. Doo::loadModel ( 'receipt' );
  3155. $receipt = new receipt ();
  3156. Doo::loadClass ( 'XDeode' );
  3157. $XDeode = new XDeode ( 5 );
  3158. $rid = $XDeode->decode ( $ridKey );
  3159. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3160. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3161. die ( 'illegal request-ridError' );
  3162. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3163. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3164. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3165. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3166. die ( 'illegal request-receiptError' );
  3167. }
  3168. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3169. die ( 'illegal request-receipLoantError' );
  3170. }
  3171. // 培训班结算挂钩借款
  3172. $receipt = new receipt ();
  3173. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3174. foreach ($trainLoanRidArray as $key=>$value){
  3175. if($value==$ridLoan){
  3176. unset($trainLoanRidArray[$key]);
  3177. }
  3178. }
  3179. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3180. $item = array (
  3181. 'rid' => $rid,
  3182. 'trainLoanRid' => $trainLoanRidString
  3183. );
  3184. $receipt->setReceiptByCondition ( $item );
  3185. // 更新借款状态变成已挂钩
  3186. $receipt = new receipt ();
  3187. $item = array (
  3188. 'rid' => $ridLoan,
  3189. 'status' => 8,
  3190. 'statusTrain' => 0
  3191. );
  3192. $receipt->setReceiptByCondition ( $item );
  3193. $XDeode = new XDeode ( 7 );
  3194. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3195. } else
  3196. die ( 'illegal request' );
  3197. }
  3198. /**
  3199. * 编辑培训班结算 ---开票
  3200. */
  3201. function receiptTrainInvoiceEdi() {
  3202. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3203. Doo::loadClass ( 'XDeode' );
  3204. $XDeode = new XDeode ( 7 );
  3205. $rid = $XDeode->decode ( $ridKey );
  3206. if (! is_numeric ( $rid ))
  3207. die ( 'illegal request' );
  3208. Doo::loadModel ( 'receipt' );
  3209. $receipt = new receipt ();
  3210. Doo::loadModel ( 'receiptTraining' );
  3211. $receiptTraining = new receiptTraining ();
  3212. Doo::loadModel ( 'invoice' );
  3213. $invoice = new invoice ();
  3214. Doo::loadModel ( 'invoiceTraining' );
  3215. $invoiceTraining = new invoiceTraining ();
  3216. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3217. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3218. die ();
  3219. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3220. $invoiceList = $invoiceTrainingDetail = array ();
  3221. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3222. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3223. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3224. }
  3225. //print_r($invoiceList);
  3226. $data ['invoiceList'] = $invoiceList;
  3227. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3228. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3229. $data ['receiptDetail'] = $receiptDetail;
  3230. $data ['trainEdiType'] = "INVOICE";
  3231. $data ['ridKey'] = $ridKey;
  3232. $data ['memu'] = "receipt";
  3233. $data ['staff'] = $this->staff;
  3234. $data ['receiptMemu'] = 'saeaBorad';
  3235. $data ['verifyId'] = $this->verifyId;
  3236. $data ['executeId'] = $this->executeId;
  3237. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3238. }
  3239. /**
  3240. * 编辑培训班结算---更新开票
  3241. */
  3242. function receiptTrainInvoiceEdiDo() {
  3243. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3244. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3245. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3246. Doo::loadModel ( 'receipt' );
  3247. $receipt = new receipt ();
  3248. Doo::loadModel ( 'invoiceTraining' );
  3249. $invoiceTraining = new invoiceTraining ();
  3250. Doo::loadClass ( 'XDeode' );
  3251. $XDeode = new XDeode ( 5 );
  3252. $rid = $XDeode->decode ( $ridKey );
  3253. $itid = $XDeode->decode ( $itidKey );
  3254. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3255. die ( 'illegal request-idError' );
  3256. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3257. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3258. // 不合法的数据
  3259. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3260. die ( 'illegal request-receiptError' );
  3261. }
  3262. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3263. die ( 'illegal request-receipLoantError' );
  3264. }
  3265. // 培训班结算挂钩借款
  3266. $receipt = new receipt ();
  3267. $item = array (
  3268. 'rid' => $rid,
  3269. 'invoiceTrainId' => $itid
  3270. );
  3271. $receipt->setReceiptByCondition ( $item );
  3272. $invoiceTraining = new invoiceTraining ();
  3273. $item = array (
  3274. 'bindReceipt' => 1,
  3275. 'itid' => $itid
  3276. );
  3277. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3278. $XDeode = new XDeode ( 7 );
  3279. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3280. } else
  3281. die ( 'illegal request' );
  3282. }
  3283. /**
  3284. * 更新培训班结算 收款和取消收款
  3285. */
  3286. function receiptTrainReceivables() {
  3287. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3288. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3289. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3290. Doo::loadClass ( 'XDeode' );
  3291. $XDeode = new XDeode ( 5 );
  3292. $rid = $XDeode->decode ( $ridKey );
  3293. $iid = $XDeode->decode ( $iidKey );
  3294. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3295. die ( 'illegal request-iid' );
  3296. Doo::loadModel ( 'RIExtend' );
  3297. $RIExtend = new RIExtend ();
  3298. if ($doType == 'CONFIRM') {
  3299. $RIExtend->rid = $rid;
  3300. $RIExtend->iid = $iid;
  3301. $RIExtend->RIstatus = 1;
  3302. $RIExtend->insert ();
  3303. echo json_encode ( array (
  3304. 'status' => 1,
  3305. ) );
  3306. die ( );
  3307. } elseif ($doType == 'CANCEL') {
  3308. $RIExtend->delete ( array (
  3309. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3310. 'limit' => 1
  3311. ) );
  3312. echo json_encode ( array (
  3313. 'status' => 1,
  3314. ) );
  3315. die ( );
  3316. } else {
  3317. echo json_encode ( array (
  3318. 'status' => 2,
  3319. ) );
  3320. die ( );
  3321. }
  3322. }
  3323. /**
  3324. * 移除挂钩的培训班发票
  3325. */
  3326. function receiptTrainReceivablesDelDo() {
  3327. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3328. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3329. Doo::loadModel ( 'receipt' );
  3330. $receipt = new receipt ();
  3331. Doo::loadModel ( 'RIExtend' );
  3332. $RIExtend = new RIExtend ();
  3333. Doo::loadClass ( 'XDeode' );
  3334. $XDeode = new XDeode ( 5 );
  3335. $rid = $XDeode->decode ( $ridKey );
  3336. $itid = $XDeode->decode ( $itidKey );
  3337. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3338. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3339. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3340. die ( 'illegal request-status' );
  3341. }
  3342. $receipt = new receipt ();
  3343. $receipt->rid = $rid;
  3344. $receipt->invoiceTrainId = 0;
  3345. $receipt->update ();
  3346. Doo::loadModel ( 'invoiceTraining' );
  3347. $invoiceTraining = new invoiceTraining ();
  3348. $item = array (
  3349. 'bindReceipt' => 0,
  3350. 'itid' => $itid
  3351. );
  3352. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3353. $RIExtend->delete ( array (
  3354. 'where' => 'rid=' . $rid
  3355. ) );
  3356. $XDeode = new XDeode ( 7 );
  3357. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3358. } else
  3359. die ( 'illegal request-iid' );
  3360. }
  3361. /**
  3362. * 编辑培训班结算
  3363. */
  3364. function receiptTrainItemEdi() {
  3365. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3366. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3367. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3368. Doo::loadClass ( 'XDeode' );
  3369. $XDeode = new XDeode ( 7 );
  3370. $rid = $XDeode->decode ( $ridKey );
  3371. if (! is_numeric ( $rid ))
  3372. die ( 'illegal request' );
  3373. Doo::loadModel ( 'receipt' );
  3374. $receipt = new receipt ();
  3375. Doo::loadModel ( 'receiptTraining' );
  3376. $receiptTraining = new receiptTraining ();
  3377. Doo::loadModel ( 'RItem' );
  3378. $RItem = new RItem ();
  3379. Doo::loadModel ( 'accountItem' );
  3380. $accountItem = new accountItem ();
  3381. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3382. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3383. die ();
  3384. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3385. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3386. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3387. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3388. // if($value['name']=='税款'){
  3389. // unset($aiList[$key]);break;
  3390. // }
  3391. // }
  3392. //print_r($RItemList);
  3393. $data ['name'] = $name;
  3394. $data ['RItemList'] = $RItemList;
  3395. $data ['aiList'] = $aiList;
  3396. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3397. $data ['receiptDetail'] = $receiptDetail;
  3398. $data ['trainEdiType'] = "ITEM";
  3399. $data ['ridKey'] = $ridKey;
  3400. $data ['memu'] = "receipt";
  3401. $data ['staff'] = $this->staff;
  3402. $data ['receiptMemu'] = 'saeaBorad';
  3403. $data ['verifyId'] = $this->verifyId;
  3404. $data ['executeId'] = $this->executeId;
  3405. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3406. }
  3407. /**
  3408. * 添加支出项 需要修改 费用金额合计
  3409. */
  3410. function receiptTrainItemAddDo() {
  3411. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3412. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3413. // 支出项信息
  3414. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3415. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3416. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3417. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3418. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3419. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3420. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3421. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3422. Doo::loadClass ( 'XDeode' );
  3423. $XDeode = new XDeode ( 5 );
  3424. Doo::loadModel ( 'RItem' );
  3425. $RItem = new RItem ();
  3426. $rid = $XDeode->decode ( $ridKey );
  3427. $rtid= $XDeode->decode ( $rtidKey );
  3428. if (! is_numeric ( $rid )){
  3429. die ( 'illegal request' );
  3430. }
  3431. Doo::loadModel ( 'receiptDetail' );
  3432. $receiptDetail = new receiptDetail ();
  3433. Doo::loadModel ( 'receipt' );
  3434. $receipt = new receipt ();
  3435. Doo::loadModel ( 'receiptTraining' );
  3436. $receiptTraining = new receiptTraining ();
  3437. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3438. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3439. $order = array (
  3440. "\r\n",
  3441. "\n",
  3442. "\r"
  3443. );
  3444. $replace = '<br/>';
  3445. $describe = str_replace ( $order, $replace, $describe );
  3446. $itemData = array (
  3447. 'rid' => $rid,
  3448. 'item' => $item,
  3449. 'price' => $price,
  3450. 'date' => $date,
  3451. 'inputer' => $inputer,
  3452. 'describe' => $describe,
  3453. 'creater' => $this->staff['0']['username'],
  3454. 'createrId' => $this->staff['0']['sid'],
  3455. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3456. 'identifying'=>$identifyingTotal
  3457. );
  3458. if($payType=='company'){
  3459. $itemData += array (
  3460. 'payType' => 1
  3461. );
  3462. }
  3463. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3464. //更新支出项标识总数
  3465. $itemData = array (
  3466. 'rtid'=>$rtid,
  3467. 'identifyingTotal'=>$identifyingTotal
  3468. );
  3469. $receiptTraining->setReceiptTrainByCondition($itemData);
  3470. $XDeode = new XDeode ( 7 );
  3471. if($payType=='company'){
  3472. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3473. }else{
  3474. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3475. }
  3476. } else
  3477. die ( 'illegal request-dataError' );
  3478. }
  3479. /**
  3480. * 培训班结算-讲师
  3481. */
  3482. function receiptTrainLecturerEdi() {
  3483. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3484. Doo::loadClass ( 'XDeode' );
  3485. $XDeode = new XDeode ( 7 );
  3486. $rid = $XDeode->decode ( $ridKey );
  3487. if (! is_numeric ( $rid ))
  3488. die ( 'illegal request' );
  3489. Doo::loadModel ( 'receipt' );
  3490. $receipt = new receipt ();
  3491. Doo::loadModel ( 'receiptTraining' );
  3492. $receiptTraining = new receiptTraining ();
  3493. Doo::loadModel ( 'RILecturer' );
  3494. $RILecturer = new RILecturer ();
  3495. Doo::loadModel ( 'lecturer' );
  3496. $lecturer = new lecturer ();
  3497. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3498. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3499. die ();
  3500. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3501. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3502. $lecturerList = $lecturer->getLecturerAll ();
  3503. $INSIDEhtml = $OUTSIDEhtml = '';
  3504. foreach ( $lecturerList as $key => $value ) {
  3505. if ($value ['ltype'] == 'INSIDE') {
  3506. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3507. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3508. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3509. }
  3510. }
  3511. $data ['INSIDEhtml'] = $INSIDEhtml;
  3512. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3513. // print_r($RItemList);
  3514. $data ['RILecturerList'] = $RILecturerList;
  3515. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3516. $data ['receiptDetail'] = $receiptDetail;
  3517. $data ['trainEdiType'] = "LECTURER";
  3518. $data ['ridKey'] = $ridKey;
  3519. $data ['memu'] = "receipt";
  3520. $data ['staff'] = $this->staff;
  3521. $data ['receiptMemu'] = 'saeaBorad';
  3522. $data ['verifyId'] = $this->verifyId;
  3523. $data ['executeId'] = $this->executeId;
  3524. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3525. }
  3526. /**
  3527. * 添加讲师
  3528. */
  3529. function receiptTrainLecturerAddDo() {
  3530. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3531. // 支出项信息
  3532. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3533. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3534. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3535. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3536. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3537. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3538. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3539. Doo::loadClass ( 'XDeode' );
  3540. $XDeode = new XDeode ( 5 );
  3541. Doo::loadModel ( 'RILecturer' );
  3542. $RILecturer = new RILecturer ();
  3543. $rid = $XDeode->decode ( $ridKey );
  3544. if (! is_numeric ( $rid ))
  3545. die ( 'illegal request' );
  3546. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3547. die ( 'illegal request-taxationError' );
  3548. $RILecturer->rid = $rid;
  3549. $RILecturer->ltype = $ltype;
  3550. if ($ltype == 'OUTSIDE') {
  3551. if ($taxation == 'TAXATION') {
  3552. $RILecturer->taxation = 1;
  3553. } elseif ($taxation == 'NOTAXATION') {
  3554. $RILecturer->taxation = 0;
  3555. }
  3556. }
  3557. $RILecturer->lecturerName = $lecturerName;
  3558. $RILecturer->schoolDay = $schoolDay;
  3559. $RILecturer->price = $price;
  3560. $RILecturer->fees=$fees;
  3561. $RILecturer->insert ();
  3562. // 添加公司汇总
  3563. // 报销详情
  3564. Doo::loadModel ( 'receiptDetail' );
  3565. $receiptDetail = new receiptDetail ();
  3566. Doo::loadModel ( 'receipt' );
  3567. $receipt = new receipt ();
  3568. // 金额总计
  3569. $price = $price * $schoolDay;
  3570. $rInfo = $receipt->getReceiptByRid ( $rid );
  3571. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3572. if (empty ( $rdInfo )) {
  3573. $receiptDetail = new receiptDetail ();
  3574. $receiptDetail->staff = $rInfo ['staff'];
  3575. $receiptDetail->item = '讲课费';
  3576. $receiptDetail->itemCategory = '培训班费用';
  3577. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3578. $receiptDetail->date = date ( "Y-m-d" );
  3579. $receiptDetail->cid = $rInfo ['cid'];
  3580. $receiptDetail->rid = $rid;
  3581. $receiptDetail->status = 4;
  3582. $receiptDetail->insert ();
  3583. } else {
  3584. $receiptDetail = new receiptDetail ();
  3585. $rdInfo ['price'] += $fees;
  3586. $receiptDetail->price = $rdInfo ['price'];
  3587. $receiptDetail->update ( array (
  3588. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3589. ) );
  3590. }
  3591. $receipt = new receipt ();
  3592. $receipt->sum=$rInfo['sum']+$fees;
  3593. $receipt->update ( array (
  3594. 'where' => 'rid=' . $rid
  3595. ) );
  3596. $XDeode = new XDeode ( 7 );
  3597. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3598. } else
  3599. die ( 'illegal request' );
  3600. }
  3601. /**
  3602. * 移除讲师
  3603. */
  3604. function receiptTrainLecturerDelDo() {
  3605. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3606. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3607. Doo::loadModel ( 'receipt' );
  3608. $receipt = new receipt ();
  3609. Doo::loadModel ( 'RILecturer' );
  3610. $RILecturer = new RILecturer ();
  3611. Doo::loadClass ( 'XDeode' );
  3612. $XDeode = new XDeode ( 5 );
  3613. $rid = $XDeode->decode ( $ridKey );
  3614. $rlid = $XDeode->decode ( $rlidKey );
  3615. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3616. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3617. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3618. die ( 'illegal request-status' );
  3619. }
  3620. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3621. if (empty($detail)){
  3622. die ( 'illegal request-data' );
  3623. }
  3624. $RILecturer->delete ( array (
  3625. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3626. ) );
  3627. //更新费用合计金额
  3628. $rInfo = $receipt->getReceiptByRid ( $rid );
  3629. $receipt = new receipt ();
  3630. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3631. $receipt->update ( array (
  3632. 'where' => 'rid=' . $rid
  3633. ) );
  3634. Doo::loadModel ( 'receiptDetail' );
  3635. $receiptDetail = new receiptDetail ();
  3636. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3637. $receiptDetail = new receiptDetail ();
  3638. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3639. $receiptDetail->price = $rdInfo ['price'];
  3640. $receiptDetail->update ( array (
  3641. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3642. ) );
  3643. $XDeode = new XDeode ( 7 );
  3644. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3645. } else
  3646. die ( 'illegal request-iid' );
  3647. }
  3648. /**
  3649. * 培训班提交审批
  3650. */
  3651. function receiptTrainDo() {
  3652. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3653. Doo::loadClass ( 'XDeode' );
  3654. $XDeode = new XDeode ( 7 );
  3655. $rid = $XDeode->decode ( $ridKey );
  3656. Doo::loadModel ( 'receipt' );
  3657. $receipt = new receipt ();
  3658. Doo::loadModel ( 'receiptDetail' );
  3659. $receiptDetail = new receiptDetail ();
  3660. Doo::loadModel ( 'statistics' );
  3661. $statistics = new statistics ();
  3662. Doo::loadModel ( "verify" );
  3663. $verify = new verify ();
  3664. // 审批状态的判定
  3665. $receiptDetailList = $receipt->getOne ( array (
  3666. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3667. 'asArray' => true
  3668. ) );
  3669. if (empty ( $receiptDetailList ))
  3670. return "/saeaBorad";
  3671. $verifyDetail = $verify->getOne ( array (
  3672. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3673. 'asArray' => true
  3674. ) );
  3675. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3676. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3677. $nowStaff = "";
  3678. $nowStaffList = array ();
  3679. if ($verifyDetail [0] [1] == 'ROLE') {
  3680. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3681. foreach ( $vStaffString as $key => $value ) {
  3682. $staffK = explode ( "_", $value );
  3683. array_push ( $nowStaffList, $staffK [0] );
  3684. }
  3685. $nowStaff = implode ( ',', $nowStaffList );
  3686. } else {
  3687. $nowStaff = $verifyDetail [0] [0];
  3688. }
  3689. $receipt->nowStaff = $nowStaff;
  3690. }
  3691. // echo $nowStaff;
  3692. // print_r($verifyDetail);die;
  3693. $receipt->rid = $receiptDetailList ['rid'];
  3694. $receipt->date = date ( "Y-m-d" );
  3695. $receipt->status = 2;
  3696. $receipt->update ();
  3697. $receiptDetail->status = 2;
  3698. $receiptDetail->update ( array (
  3699. 'where' => 'rid=' . $receiptDetailList ['rid']
  3700. ) );
  3701. Doo::loadModel ( "receiptLog" );
  3702. $receiptLog = new receiptLog ();
  3703. Doo::loadModel ( "verify" );
  3704. $verify = new verify ();
  3705. $vr = $verify->getOne ( array (
  3706. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3707. 'asArray' => true
  3708. ) );
  3709. $jd = json_decode ( $vr ['staff'] );
  3710. $roleId = 0;
  3711. foreach ( $jd as $key => $value ) {
  3712. if ($value [1] == 'ROLE') {
  3713. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3714. if ($pos !== false) {
  3715. $roleId = $value [0];
  3716. }
  3717. }
  3718. }
  3719. // 审批日志
  3720. // echo $roleId;die;
  3721. if (! empty ( $roleId )) {
  3722. Doo::loadModel ( "role" );
  3723. $role = new role ();
  3724. $roleInfo = $role->getOne ( array (
  3725. 'where' => 'rid=' . $roleId,
  3726. 'asArray' => true
  3727. ) );
  3728. // $receiptLog->rolename = $roleInfo ['name'];
  3729. }
  3730. $receiptLog->username = $this->staff [0] ['username'];
  3731. $receiptLog->uid = $this->staff [0] ['sid'];
  3732. $receiptLog->date = date ( "Y-m-d" );
  3733. $receiptLog->opinion = '提交审批';
  3734. $receiptLog->img = $this->staff [0] ['avatar'];
  3735. $receiptLog->status = 2;
  3736. $receiptLog->rid = $rid;
  3737. $receiptLog->insert ();
  3738. // 写入列表项
  3739. Doo::loadModel ( 'accountItem' );
  3740. $accountItem = new accountItem ();
  3741. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3742. // 项目金额合计
  3743. Doo::loadModel ( 'RItem' );
  3744. $RItem = new RItem ();
  3745. // 讲师获得
  3746. Doo::loadModel ( 'RILecturer' );
  3747. $RILecturer = new RILecturer ();
  3748. $RItemList = $RItem->getRItemByRid ( $rid );
  3749. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3750. // 支出项金额详情
  3751. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3752. // print_r($aItem);
  3753. // print_r($aiData);
  3754. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3755. $ag = $tr = $ta = $ot = 0;
  3756. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3757. foreach ( $aItem as $key => $value ) {
  3758. if ($value ['category'] == $this->TRAIN) {
  3759. foreach ( $aiData ['dataList'] as $k => $v ) {
  3760. if ($value ['name'] == $v ['name']) {
  3761. array_push ( $accountJson [$this->TRAIN], array (
  3762. 'aid' => $value ['aid'],
  3763. 'name' => $value ['name'],
  3764. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3765. ) );
  3766. $sum += $v ['price'];
  3767. $trainSum += $v ['price'];
  3768. unset ( $aiData ['dataList'] [$k] );
  3769. break;
  3770. }
  3771. }
  3772. }
  3773. }
  3774. $accountJson ['cSum'] = array (
  3775. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3776. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3777. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3778. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3779. );
  3780. // 报销单
  3781. $receipt = new receipt ();
  3782. $receipt->accountItem = json_encode ( $accountJson );
  3783. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3784. $receipt->update ( array (
  3785. 'where' => 'rid=' . $rid
  3786. ) );
  3787. // print_r($accountJson);
  3788. // statistics item 统计写入
  3789. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3790. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3791. $accountItem = $accountJson;
  3792. $stat = $statistics->getOne ( array (
  3793. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3794. 'asArray' => true
  3795. ) );
  3796. if (empty ( $stat )) {
  3797. $statistics->date = date ( "Y-m-d" );
  3798. $statistics->cid = $this->staff [0] ['cid'];
  3799. $statistics->staff = $this->staff [0] ['sid'];
  3800. $statistics->agPrice = 0;
  3801. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3802. $statistics->insert ();
  3803. } else {
  3804. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3805. $statistics->update ( array (
  3806. 'where' => 'sid=' . $stat ['sid']
  3807. ) );
  3808. }
  3809. return "/saeaBorad";
  3810. }
  3811. function confirmation() {
  3812. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3813. Doo::loadModel ( 'receipt' );
  3814. Doo::loadModel ( 'receiptDetail' );
  3815. $receipt = new receipt ();
  3816. $receiptDetail = new receiptDetail ();
  3817. Doo::loadModel ( 'statistics' );
  3818. Doo::loadModel ( 'itemStatistics' );
  3819. $statistics = new statistics ();
  3820. $itemStatistics = new itemStatistics ();
  3821. Doo::loadModel ( "verify" );
  3822. $verify = new verify ();
  3823. $receiptDetailList = $receipt->getOne ( array (
  3824. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3825. 'asArray' => true
  3826. ) );
  3827. if (empty ( $receiptDetailList ))
  3828. return "/saeaBorad";
  3829. $verifyDetail = $verify->getOne ( array (
  3830. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3831. 'asArray' => true
  3832. ) );
  3833. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3834. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3835. $nowStaff = "";
  3836. $nowStaffList = array ();
  3837. if ($verifyDetail [0] [1] == 'ROLE') {
  3838. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3839. foreach ( $vStaffString as $key => $value ) {
  3840. $staffK = explode ( "_", $value );
  3841. array_push ( $nowStaffList, $staffK [0] );
  3842. }
  3843. $nowStaff = implode ( ',', $nowStaffList );
  3844. } else {
  3845. $nowStaff = $verifyDetail [0] [0];
  3846. }
  3847. $receipt->nowStaff = $nowStaff;
  3848. }
  3849. // echo $nowStaff;
  3850. // print_r($verifyDetail);die;
  3851. $receipt->rid = $receiptDetailList ['rid'];
  3852. $receipt->status = 2;
  3853. $receipt->update ();
  3854. // 操作日志
  3855. Doo::loadModel ( "receiptLog" );
  3856. $receiptLog = new receiptLog ();
  3857. $verify = new verify ();
  3858. $receiptInfo = $receipt->getOne ( array (
  3859. 'where' => 'rid=' . $rid,
  3860. 'asArray' => true
  3861. ) );
  3862. $vr = $verify->getOne ( array (
  3863. 'where' => 'vid=' . $receiptInfo ['verify'],
  3864. 'asArray' => true
  3865. ) );
  3866. $jd = json_decode ( $vr ['staff'] );
  3867. $roleId = 0;
  3868. foreach ( $jd as $key => $value ) {
  3869. if ($value [1] == 'ROLE') {
  3870. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3871. if ($pos !== false) {
  3872. $roleId = $value [0];
  3873. }
  3874. }
  3875. }
  3876. // 审批日志
  3877. // echo $roleId;die;
  3878. if (! empty ( $roleId )) {
  3879. Doo::loadModel ( "role" );
  3880. $role = new role ();
  3881. $roleInfo = $role->getOne ( array (
  3882. 'where' => 'rid=' . $roleId,
  3883. 'asArray' => true
  3884. ) );
  3885. // $receiptLog->rolename = $roleInfo ['name'];
  3886. }
  3887. $receiptLog->username = $this->staff [0] ['username'];
  3888. $receiptLog->uid = $this->staff [0] ['sid'];
  3889. $receiptLog->date = date ( "Y-m-d" );
  3890. $receiptLog->opinion = '提交审批';
  3891. $receiptLog->img = $this->staff [0] ['avatar'];
  3892. $receiptLog->status = 2;
  3893. $receiptLog->rid = $rid;
  3894. $receiptLog->insert ();
  3895. return "/expenses";
  3896. }
  3897. function expenses() {
  3898. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3899. if (empty ( $item ))
  3900. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3901. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3902. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3903. Doo::loadClass ( 'XDeode' );
  3904. $XDeode = new XDeode ( 7 );
  3905. Doo::loadModel ( 'receipt' );
  3906. $receipt = new receipt ();
  3907. Doo::loadModel ( 'L_category' );
  3908. $Lcategory = new L_category ();
  3909. Doo::loadModel ( 'verify' );
  3910. Doo::loadModel ( 'statistics' );
  3911. $statistics = new statistics ();
  3912. $verify = new verify ();
  3913. Doo::loadModel ( 'staff' );
  3914. $staff = new staff ();
  3915. $condition = "";
  3916. if ($item == "expenses")
  3917. $condition = " and Rtype=1 ";
  3918. elseif ($item == "receipts")
  3919. $condition = " and Rtype=0 ";
  3920. elseif ($item == "remits")
  3921. $condition = " and Rtype=2 ";
  3922. elseif ($item == "train")
  3923. $condition = " and Rtype=3 ";
  3924. $dateCondition = " and Year(date) =" . $year;
  3925. if (! empty ( $moth )) {
  3926. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3927. $stList = $statistics->getOne ( array (
  3928. 'select' => 'rePrice ,agPrice',
  3929. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3930. 'asArray' => true
  3931. ) );
  3932. } else
  3933. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3934. if (empty ( $stList ))
  3935. $stList = array (
  3936. 'rePrice' => 0,
  3937. 'agPrice' => 0
  3938. );
  3939. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3940. if (! isset ( $noPassSum ['sum'] ))
  3941. $noPassSum ['sum'] = 0;
  3942. $data ['stList'] = array (
  3943. 'rePrice' => $stList ['rePrice'],
  3944. 'agPrice' => $stList ['agPrice'],
  3945. 'skPrice' => ($noPassSum ['sum'])
  3946. );
  3947. $receiptList = $receipt->find ( array (
  3948. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3949. 'desc' => 'rid',
  3950. 'asArray' => true
  3951. ) );
  3952. $Locate = 0;
  3953. $roleId = 0;
  3954. $button = 0;
  3955. foreach ( $receiptList as $key => $value ) {
  3956. $receiptList[$key]['balance']='';
  3957. if($value['Rtype']==1){
  3958. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3959. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3960. }elseif($value['Rtype']==3){
  3961. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3962. $receiptList[$key]['payment']=$payment;
  3963. $receiptList[$key]['paymentABS']=abs($payment);
  3964. }
  3965. $receiptList [$key] ['Locate'] = $Locate;
  3966. $Locate ++;
  3967. $receiptList [$key] ['reviseDetail'] = array ();
  3968. if (! empty ( $value ['reviseDetail'] ))
  3969. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3970. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3971. $categoryDetil = $Lcategory->getOne ( array (
  3972. 'where' => 'cid=' . $value ['cid'],
  3973. 'asArray' => true
  3974. ) );
  3975. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3976. // 检测编辑状态
  3977. $verifyList = $verify->getOne ( array (
  3978. 'where' => 'vid=' . $value ['verify'],
  3979. 'asArray' => true
  3980. ) );
  3981. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3982. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3983. Doo::loadModel ( 'role' );
  3984. $role = new role ();
  3985. $flag = true;
  3986. $roleKey = 0;
  3987. $endStaffArray = array ();
  3988. $roleArrayCopy = array ();
  3989. foreach ( $verifyList as $k => $v ) {
  3990. // init verifyStaff
  3991. if ($v [1] == 'ROLE') {
  3992. if (! empty ( $verifyStaff )) {
  3993. $endStaffArray = end ( $verifyStaff );
  3994. // if ($v[0]==$endStaffArray['nextStaff']){
  3995. // $roleId=$v[0];
  3996. // }
  3997. }
  3998. $roleVerify = json_decode ( $v [3], true );
  3999. $roleKey = $k;
  4000. $roleArray = array ();
  4001. $rolename = $role->getOne ( array (
  4002. 'where' => 'rid=' . $v [0],
  4003. 'asArray' => true
  4004. ) );
  4005. foreach ( $roleVerify as $o => $p ) {
  4006. $staffID = explode ( '_', $p );
  4007. $staffInfo = $staff->getOne ( array (
  4008. 'where' => 'sid=' . $staffID [0],
  4009. 'asArray' => true
  4010. ) );
  4011. // print_r($staffID);
  4012. $exp = array (
  4013. 0 => $staffInfo ['sid'],
  4014. 1 => $staffID [1],
  4015. 2 => $staffInfo ['avatar'],
  4016. 'date' => '',
  4017. 'date' => '',
  4018. 'opinion' => '',
  4019. 'status' => '',
  4020. 'rolename' => $rolename ['name']
  4021. );
  4022. array_push ( $roleArray, $exp );
  4023. }
  4024. $roleArrayCopy [$v [0]] = $roleArray;
  4025. // $verifyList[$k]['roleArray']=$roleArray;
  4026. }
  4027. $verifyList [$k] ['date'] = "";
  4028. $verifyList [$k] ['opinion'] = "";
  4029. $verifyList [$k] ['status'] = "";
  4030. if (empty ( $verifyStaff )) {
  4031. $verifyList [$k] ['date'] = "";
  4032. $verifyList [$k] ['opinion'] = "";
  4033. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4034. $verifyList [$k] ['status'] = 4;
  4035. $flag = false;
  4036. }
  4037. } else {
  4038. foreach ( $verifyStaff as $m => $u ) {
  4039. if ($v [0] == $m) {
  4040. $verifyList [$k] ['date'] = $u ['date'];
  4041. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4042. $verifyList [$k] ['status'] = $u ['status'];
  4043. $flag = false;
  4044. break;
  4045. }
  4046. }
  4047. $endStaffArray = end ( $verifyStaff );
  4048. if (isset ( $endStaffArray ['ROLE'] )) {
  4049. } else {
  4050. // $endKey=key($verifyStaff);
  4051. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4052. // $button=4;
  4053. // $verifyList[$k]['status']=4;
  4054. // }
  4055. }
  4056. }
  4057. }
  4058. $rolename ['name'] = '';
  4059. if (! empty ( $roleId )) {
  4060. Doo::loadModel ( 'role' );
  4061. $role = new role ();
  4062. $rolename = $role->getOne ( array (
  4063. 'where' => 'rid=' . $roleId,
  4064. 'asArray' => true
  4065. ) );
  4066. }
  4067. if (! empty ( $verifyStaff ))
  4068. $endStaffArray = end ( $verifyStaff );
  4069. $KOP = false;
  4070. foreach ( $roleArrayCopy as $P => $A ) {
  4071. foreach ( $A as $MKI => $AVL ) {
  4072. if (! empty ( $verifyStaff )) {
  4073. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4074. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4075. $button = 4;
  4076. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4077. }
  4078. foreach ( $verifyStaff as $m => $u ) {
  4079. $AVLFK = $AVL [0] . '_R';
  4080. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4081. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4082. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4083. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4084. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4085. break;
  4086. }
  4087. }
  4088. } else {
  4089. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4090. $button = 4;
  4091. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4092. }
  4093. }
  4094. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4095. $KOP = true;
  4096. }
  4097. }
  4098. foreach ( $roleArrayCopy as $k => $v ) {
  4099. foreach ( $verifyList as $m => $n ) {
  4100. if ($n [0] == $k) {
  4101. array_splice ( $verifyList, $m, 1, $v );
  4102. }
  4103. }
  4104. }
  4105. $receiptList [$key] ['verifyList'] = $verifyList;
  4106. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4107. 'where' => 'sid=' . $value ['staff'],
  4108. 'asArray' => true
  4109. ) );
  4110. $receiptList [$key] ['button'] = $button;
  4111. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4112. }
  4113. // print_r($receiptList);die;
  4114. $mothHtml = "";
  4115. for($i = 1; $i <= 12; $i ++) {
  4116. if ($moth == $i)
  4117. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4118. else
  4119. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4120. }
  4121. $dateHtml = "";
  4122. $now = date ( "Y" );
  4123. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4124. if ($YEARD <= $now) {
  4125. $dateHtml .= '<option ';
  4126. if ($year == $YEARD) {
  4127. $dateHtml .= 'selected ';
  4128. }
  4129. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4130. }
  4131. }
  4132. $data ['dateHtml'] = $dateHtml;
  4133. $data ['mothHtml'] = $mothHtml;
  4134. $data ['receiptList'] = $receiptList;
  4135. $data ['memu'] = "receipt";
  4136. $data ['staff'] = $this->staff;
  4137. $data ['receiptMemu'] = 'expenses';
  4138. $data ['verifyId'] = $this->verifyId;
  4139. $data ['executeId'] = $this->executeId;
  4140. $data ['item'] = $item;
  4141. $data ['year'] = $year;
  4142. $this->render ( "/admin/expenses", $data );
  4143. }
  4144. function expensesCollect() {
  4145. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4146. Doo::loadModel ( 'receipt' );
  4147. $receipt = new receipt ();
  4148. Doo::loadModel ( 'L_category' );
  4149. $Lcategory = new L_category ();
  4150. Doo::loadModel ( 'verify' );
  4151. Doo::loadModel ( 'statistics' );
  4152. $statistics = new statistics ();
  4153. $verify = new verify ();
  4154. Doo::loadModel ( 'staff' );
  4155. $staff = new staff ();
  4156. Doo::loadModel ( 'loanReceipt' );
  4157. $loanReceipt = new loanReceipt ();
  4158. $receiptList = $receipt->find ( array (//去掉
  4159. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4160. 'desc' => 'rid',
  4161. 'asArray' => true
  4162. ) );
  4163. $loanList = $loanReceipt->find ( array (
  4164. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4165. 'desc' => 'rid',
  4166. 'asArray' => true
  4167. ) );
  4168. /*
  4169. * $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;
  4170. */
  4171. $data ['explanation'] = '';
  4172. if (! empty ( $loanList ))
  4173. $data ['explanation'] = $loanList [0] ['explanation'];
  4174. $Locate = 0;
  4175. $roleId = 0;
  4176. $button = 0;
  4177. foreach ( $receiptList as $key => $value ) {
  4178. $receiptList [$key] ['Locate'] = $Locate;
  4179. $Locate ++;
  4180. $receiptList [$key] ['reviseDetail'] = array ();
  4181. if (! empty ( $value ['reviseDetail'] ))
  4182. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4183. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4184. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4185. $categoryDetil = $Lcategory->getOne ( array (
  4186. 'where' => 'cid=' . $value ['cid'],
  4187. 'asArray' => true
  4188. ) );
  4189. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4190. // 检测编辑状态
  4191. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4192. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4193. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4194. else
  4195. $verifyList ['staff'] = $value ['verifyBreakup'];
  4196. } else
  4197. $verifyList = $verify->getOne ( array (
  4198. 'where' => 'vid=' . $value ['verify'],
  4199. 'asArray' => true
  4200. ) );
  4201. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4202. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4203. Doo::loadModel ( 'role' );
  4204. $role = new role ();
  4205. $flag = true;
  4206. $roleKey = 0;
  4207. $endStaffArray = array ();
  4208. $roleArrayCopy = array ();
  4209. foreach ( $verifyList as $k => $v ) {
  4210. // init verifyStaff
  4211. if ($v [1] == 'ROLE') {
  4212. if (! empty ( $verifyStaff )) {
  4213. $endStaffArray = end ( $verifyStaff );
  4214. // if ($v[0]==$endStaffArray['nextStaff']){
  4215. // $roleId=$v[0];
  4216. // }
  4217. }
  4218. $roleVerify = json_decode ( $v [3], true );
  4219. $roleKey = $k;
  4220. $roleArray = array ();
  4221. $rolename = $role->getOne ( array (
  4222. 'where' => 'rid=' . $v [0],
  4223. 'asArray' => true
  4224. ) );
  4225. foreach ( $roleVerify as $o => $p ) {
  4226. $staffID = explode ( '_', $p );
  4227. $staffInfo = $staff->getOne ( array (
  4228. 'where' => 'sid=' . $staffID [0],
  4229. 'asArray' => true
  4230. ) );
  4231. // print_r($staffID);
  4232. $exp = array (
  4233. 0 => $staffInfo ['sid'],
  4234. 1 => $staffID [1],
  4235. 2 => $staffInfo ['avatar'],
  4236. 'date' => '',
  4237. 'date' => '',
  4238. 'opinion' => '',
  4239. 'status' => '',
  4240. 'rolename' => $rolename ['name']
  4241. );
  4242. array_push ( $roleArray, $exp );
  4243. }
  4244. $roleArrayCopy [$v [0]] = $roleArray;
  4245. // $verifyList[$k]['roleArray']=$roleArray;
  4246. }
  4247. $verifyList [$k] ['date'] = "";
  4248. $verifyList [$k] ['opinion'] = "";
  4249. $verifyList [$k] ['status'] = "";
  4250. if (empty ( $verifyStaff )) {
  4251. $verifyList [$k] ['date'] = "";
  4252. $verifyList [$k] ['opinion'] = "";
  4253. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4254. $verifyList [$k] ['status'] = 4;
  4255. $flag = false;
  4256. }
  4257. } else {
  4258. foreach ( $verifyStaff as $m => $u ) {
  4259. if ($v [0] == $m) {
  4260. $verifyList [$k] ['date'] = $u ['date'];
  4261. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4262. $verifyList [$k] ['status'] = $u ['status'];
  4263. $flag = false;
  4264. break;
  4265. }
  4266. }
  4267. $endStaffArray = end ( $verifyStaff );
  4268. if (isset ( $endStaffArray ['ROLE'] )) {
  4269. } else {
  4270. // $endKey=key($verifyStaff);
  4271. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4272. // $button=4;
  4273. // $verifyList[$k]['status']=4;
  4274. // }
  4275. }
  4276. }
  4277. }
  4278. $rolename ['name'] = '';
  4279. if (! empty ( $roleId )) {
  4280. Doo::loadModel ( 'role' );
  4281. $role = new role ();
  4282. $rolename = $role->getOne ( array (
  4283. 'where' => 'rid=' . $roleId,
  4284. 'asArray' => true
  4285. ) );
  4286. }
  4287. if (! empty ( $verifyStaff ))
  4288. $endStaffArray = end ( $verifyStaff );
  4289. $KOP = false;
  4290. foreach ( $roleArrayCopy as $P => $A ) {
  4291. foreach ( $A as $MKI => $AVL ) {
  4292. if (! empty ( $verifyStaff )) {
  4293. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4294. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4295. $button = 4;
  4296. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4297. }
  4298. foreach ( $verifyStaff as $m => $u ) {
  4299. $AVLFK = $AVL [0] . '_R';
  4300. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4301. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4302. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4303. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4304. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4305. break;
  4306. }
  4307. }
  4308. } else {
  4309. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4310. $button = 4;
  4311. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4312. }
  4313. }
  4314. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4315. $KOP = true;
  4316. }
  4317. }
  4318. foreach ( $roleArrayCopy as $k => $v ) {
  4319. foreach ( $verifyList as $m => $n ) {
  4320. if ($n [0] == $k) {
  4321. array_splice ( $verifyList, $m, 1, $v );
  4322. }
  4323. }
  4324. }
  4325. // 费用执行人相关数据
  4326. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4327. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4328. foreach ( $executeCopy as $k => $v ) {
  4329. $executeCopy [$k] ['date'] = '';
  4330. $executeCopy [$k] ['opinion'] = '';
  4331. $executeCopy [$k] ['status'] = '';
  4332. if (! empty ( $executeStaff ))
  4333. foreach ( $executeStaff as $m => $u ) {
  4334. if ($v [0] == $m) {
  4335. $executeCopy [$k] ['date'] = $u ['date'];
  4336. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4337. $executeCopy [$k] ['status'] = $u ['status'];
  4338. break;
  4339. }
  4340. }
  4341. }
  4342. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4343. $receiptList [$key] ['verifyList'] = $verifyList;
  4344. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4345. 'where' => 'sid=' . $value ['staff'],
  4346. 'asArray' => true
  4347. ) );
  4348. $receiptList [$key] ['button'] = $button;
  4349. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4350. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4351. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4352. $receiptList [$key] ['relust'] = $relust;
  4353. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4354. }
  4355. Doo::loadModel ( 'enclosur' );
  4356. $enclosur = new enclosur ();
  4357. $enclosurList = $enclosur->find ( array (
  4358. 'where' => 'rid=' . $rid,
  4359. 'asArray' => true
  4360. ) );
  4361. $enclosurHtml = '';
  4362. foreach ( $enclosurList as $value ) {
  4363. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4364. }
  4365. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  4366. $data ['enclosurHtml'] = $enclosurHtml;
  4367. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4368. $data ['receiptList'] = $receiptList;
  4369. $data ['memu'] = "receipt";
  4370. $data ['staff'] = $this->staff;
  4371. $data ['receiptMemu'] = 'expenses';
  4372. $data ['verifyId'] = $this->verifyId;
  4373. $data ['executeId'] = $this->executeId;
  4374. if($receiptList[0]['receiptClass']==2){
  4375. if(!empty($receiptList[0]['itinerary2'])){
  4376. $this->render ( "/receipt/feeTraveDetail2", $data );
  4377. }else{
  4378. $this->render ( "/receipt/feeTraveDetail", $data );
  4379. }
  4380. }else{
  4381. $this->render ( "/admin/expensesCollect", $data );
  4382. }
  4383. }
  4384. function approvalExpenses() {
  4385. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4386. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4387. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4388. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4389. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4390. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4391. // echo $rdate;
  4392. if (empty ( $status ))
  4393. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4394. $page_size = 8;
  4395. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4396. $vidList = array ();
  4397. $button = 0;
  4398. Doo::loadModel ( 'verify' );
  4399. $verify = new verify ();
  4400. Doo::loadModel ( 'receipt' );
  4401. $receipt = new receipt ();
  4402. Doo::loadModel ( 'staff' );
  4403. $staff = new staff ();
  4404. Doo::loadModel ( 'L_category' );
  4405. $Lcategory = new L_category ();
  4406. // user verify ID
  4407. $verifyDetail = $verify->find ( array (
  4408. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4409. 'asArray' => true
  4410. ) );
  4411. foreach ( $verifyDetail as $key => $value ) {
  4412. array_push ( $vidList, $value ['vid'] );
  4413. }
  4414. $vid = implode ( ",", $vidList );
  4415. if (empty ( $verifyDetail ))
  4416. $vid = 0;
  4417. // if ($status==0)
  4418. // $dateCondition="";
  4419. // else
  4420. $dateCondition = " ";
  4421. // if (! empty ( $month ))
  4422. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4423. if ($status == 'done' || $status == 'termination') {
  4424. if (! empty ( $year )) {
  4425. $dateCondition = " and Year(pastDate) =" . $year;
  4426. if (! empty ( $month ))
  4427. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4428. }
  4429. } elseif ($status == 'finish') {
  4430. if (! empty ( $year )) {
  4431. $dateCondition = " and Year(pastDate) =" . $year;
  4432. if (! empty ( $month ))
  4433. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4434. }
  4435. }
  4436. // date ( 'Y-m' )
  4437. // if (! empty ( $rdate ) && $status == 'done')
  4438. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4439. // elseif (! empty ( $rdate ))
  4440. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4441. $categoryList = $Lcategory->find ( array (
  4442. 'asArray' => true
  4443. ) );
  4444. $staffList = $staff->find ( array (
  4445. 'where' => 'cid=' . $cid,
  4446. 'asArray' => true
  4447. ) );
  4448. $cateCondition = "";
  4449. $staffCondition = "";
  4450. $approvalCondition = "";
  4451. if (! empty ( $cid )) {
  4452. $cateCondition = ' and cid=' . $cid;
  4453. }
  4454. if (! empty ( $sid )) {
  4455. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4456. $cateCondition = "";
  4457. }
  4458. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4459. if ($status == 'pendApproval') {
  4460. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4461. }
  4462. if ($status == 'ongoing') {
  4463. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4464. }
  4465. if ($status == 'done') {
  4466. $approvalCondition = ' and (status=8 or status=9 ) ';
  4467. }
  4468. if ($status == 'termination') {
  4469. $approvalCondition = " and status=3";
  4470. }
  4471. if ($status == 'finish') {
  4472. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4473. }
  4474. $pageinfo ['page'] = array (
  4475. 'previous' => ''
  4476. );
  4477. if(!empty($receiptOrder)){
  4478. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4479. $receiptList = $receipt->find ( array ( // $dateCondition
  4480. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4481. 'desc' => 'rid',
  4482. 'asArray' => true
  4483. ) );
  4484. }else{
  4485. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4486. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4487. $receiptList = $receipt->find ( array ( // $dateCondition.
  4488. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4489. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4490. 'desc' => 'rid',
  4491. 'asArray' => true
  4492. ) );
  4493. } else {
  4494. $receiptList = $receipt->find ( array ( // $dateCondition
  4495. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4496. 'desc' => 'rid',
  4497. 'asArray' => true
  4498. ) );
  4499. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4500. }
  4501. }
  4502. $rLRes = $receipt->find ( array (
  4503. '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 . ')',
  4504. 'desc' => 'rid',
  4505. 'asArray' => true
  4506. ) );
  4507. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4508. // print_r($receiptList);
  4509. Doo::loadClass ( 'XDeode' );
  4510. $XDeode = new XDeode ( 7 );
  4511. $Locate = 0;
  4512. //
  4513. $reportList = $reportCateList = array ();
  4514. foreach ( $receiptList as $key => $value ) {
  4515. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4516. $receiptList [$key] ['Locate'] = $Locate;
  4517. $Locate ++;
  4518. $receiptList [$key] ['reviseDetail'] = array ();
  4519. if (! empty ( $value ['reviseDetail'] ))
  4520. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4521. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4522. $categoryDetil = $Lcategory->getOne ( array (
  4523. 'where' => 'cid=' . $value ['cid'],
  4524. 'asArray' => true
  4525. ) );
  4526. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4527. $verifyList = $verify->getOne ( array (
  4528. 'where' => 'vid=' . $value ['verify'],
  4529. 'asArray' => true
  4530. ) );
  4531. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4532. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4533. foreach ( $verifyList as $k => $v ) {
  4534. // init verifyStaff
  4535. $verifyList [$k] ['date'] = "";
  4536. $verifyList [$k] ['opinion'] = "";
  4537. $verifyList [$k] ['status'] = "";
  4538. if (empty ( $verifyStaff )) {
  4539. $verifyList [$k] ['date'] = "";
  4540. $verifyList [$k] ['opinion'] = "";
  4541. if ($v [0] == $this->staff [0] ['sid']) {
  4542. $verifyList [$k] ['status'] = 4;
  4543. $button = 4;
  4544. }
  4545. } else {
  4546. $flag = true;
  4547. foreach ( $verifyStaff as $m => $u ) {
  4548. if ($v [0] == $m) {
  4549. $verifyList [$k] ['date'] = $u ['date'];
  4550. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4551. $verifyList [$k] ['status'] = $u ['status'];
  4552. $flag = false;
  4553. break;
  4554. }
  4555. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4556. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4557. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4558. }
  4559. if ($flag) { // 检测可编辑
  4560. if ($v [0] == $this->staff [0] ['sid']) {
  4561. $verifyList [$k] ['status'] = 4;
  4562. $button = 4;
  4563. }
  4564. }
  4565. }
  4566. }
  4567. $receiptList [$key] ['verifyList'] = $verifyList;
  4568. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4569. 'where' => 'sid=' . $value ['staff'],
  4570. 'asArray' => true
  4571. ) );
  4572. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4573. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4574. $receiptList [$key] ['button'] = $button;
  4575. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4576. //获得培训班结算RID 借款费用--已经锁定
  4577. if($value['status']==10){
  4578. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4579. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4580. }
  4581. }
  4582. $reportList = array_unique ( $reportList );
  4583. $reportHtml = '';
  4584. foreach ( $reportList as $key => $value ) {
  4585. $v = explode ( "-", $value );
  4586. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4587. }
  4588. // print_r($reportList)
  4589. $data ['reportHtml'] = $reportHtml;
  4590. $reportCateList = array_unique ( $reportCateList );
  4591. $reportCateHtml = '';
  4592. foreach ( $reportCateList as $key => $value ) {
  4593. $v = explode ( "-", $value );
  4594. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4595. }
  4596. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4597. $data ['reportCateHtml'] = $reportCateHtml;
  4598. // print_r($receiptList);die;
  4599. // $data['verifyDetail']=$verifyDetail;
  4600. $mothHtml = "";
  4601. for($i = 1; $i <= 12; $i ++) {
  4602. if ($month == $i)
  4603. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4604. else
  4605. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4606. }
  4607. $data ['mothHtml'] = $mothHtml;
  4608. $dateHtml = "";
  4609. $now = date ( "Y" );
  4610. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4611. if ($YEARD <= $now) {
  4612. $dateHtml .= '<option ';
  4613. if ($year == $YEARD) {
  4614. $dateHtml .= 'selected ';
  4615. }
  4616. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4617. }
  4618. }
  4619. $data ['dateHtml'] = $dateHtml;
  4620. $data ['page'] = $pageinfo;
  4621. $data ['receiptList'] = $receiptList;
  4622. $data ['receiptApprovalCount'] = count ( $rLRes );
  4623. $data ['status'] = $status;
  4624. $data ['year'] = $year;
  4625. $data ['month'] = $month;
  4626. $data ['categoryList'] = $categoryList;
  4627. $data ['staffList'] = $staffList;
  4628. $data ['cid'] = $cid;
  4629. $data ['sid'] = $sid;
  4630. // print_r($receiptList);
  4631. $data['receiptOrder']=$receiptOrder;
  4632. $data ['memu'] = "receipt";
  4633. $data ['staff'] = $this->staff;
  4634. $data ['receiptMemu'] = 'approvalExpenses';
  4635. $data ['verifyId'] = $this->verifyId;
  4636. $data ['executeId'] = $this->executeId;
  4637. $this->render ( "/admin/approvalExpenses", $data );
  4638. }
  4639. private function _expensesDoc(){
  4640. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4641. Doo::loadClass ( 'XDeode' );
  4642. $XDeode = new XDeode ( 5 );
  4643. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4644. $rid = $XDeode->decode ( $rid );
  4645. if (! is_numeric ( $rid ))
  4646. die ( 'illegal request' );
  4647. Doo::loadModel ( 'receipt' );
  4648. $receipt = new receipt ();
  4649. Doo::loadModel ( 'L_category' );
  4650. $Lcategory = new L_category ();
  4651. Doo::loadModel ( 'verify' );
  4652. Doo::loadModel ( 'statistics' );
  4653. $statistics = new statistics ();
  4654. $verify = new verify ();
  4655. Doo::loadModel ( 'staff' );
  4656. $staff = new staff ();
  4657. Doo::loadModel ( 'loanReceipt' );
  4658. $loanReceipt = new loanReceipt ();
  4659. $receiptList = $receipt->find ( array (
  4660. 'where' => ' rid=' . $rid,
  4661. 'desc' => 'rid',
  4662. 'asArray' => true
  4663. ) );
  4664. $loanList = array ();
  4665. if (! empty ( $receiptList ))
  4666. $loanList = $loanReceipt->find ( array (
  4667. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4668. 'desc' => 'rid',
  4669. 'asArray' => true
  4670. ) );
  4671. $Locate = 0;
  4672. $roleId = 0;
  4673. $button = 0;
  4674. foreach ( $loanList as $key => $value ) {
  4675. $loanList [$key] ['Locate'] = $Locate;
  4676. $Locate ++;
  4677. $loanList [$key] ['reviseDetail'] = array ();
  4678. if (! empty ( $value ['reviseDetail'] ))
  4679. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4680. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4681. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4682. $categoryDetil = $Lcategory->getOne ( array (
  4683. 'where' => 'cid=' . $value ['cid'],
  4684. 'asArray' => true
  4685. ) );
  4686. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4687. // 检测编辑状态
  4688. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4689. $verifyList ['staff'] = $value ['verifyBreakup'];
  4690. else
  4691. $verifyList = $verify->getOne ( array (
  4692. 'where' => 'vid=' . $value ['verify'],
  4693. 'asArray' => true
  4694. ) );
  4695. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4696. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4697. Doo::loadModel ( 'role' );
  4698. $role = new role ();
  4699. $flag = true;
  4700. $roleKey = 0;
  4701. $endStaffArray = array ();
  4702. $roleArrayCopy = array ();
  4703. foreach ( $verifyList as $k => $v ) {
  4704. // init verifyStaff
  4705. if ($v [1] == 'ROLE') {
  4706. if (! empty ( $verifyStaff )) {
  4707. $endStaffArray = end ( $verifyStaff );
  4708. // if ($v[0]==$endStaffArray['nextStaff']){
  4709. // $roleId=$v[0];
  4710. // }
  4711. }
  4712. $roleVerify = json_decode ( $v [3], true );
  4713. $roleKey = $k;
  4714. $roleArray = array ();
  4715. $rolename = $role->getOne ( array (
  4716. 'where' => 'rid=' . $v [0],
  4717. 'asArray' => true
  4718. ) );
  4719. foreach ( $roleVerify as $o => $p ) {
  4720. $staffID = explode ( '_', $p );
  4721. $staffInfo = $staff->getOne ( array (
  4722. 'where' => 'sid=' . $staffID [0],
  4723. 'asArray' => true
  4724. ) );
  4725. // print_r($staffID);
  4726. $exp = array (
  4727. 0 => $staffInfo ['sid'],
  4728. 1 => $staffID [1],
  4729. 2 => $staffInfo ['avatar'],
  4730. 'date' => '',
  4731. 'date' => '',
  4732. 'opinion' => '',
  4733. 'status' => '',
  4734. 'rolename' => $rolename ['name']
  4735. );
  4736. array_push ( $roleArray, $exp );
  4737. }
  4738. $roleArrayCopy [$v [0]] = $roleArray;
  4739. // $verifyList[$k]['roleArray']=$roleArray;
  4740. }
  4741. $verifyList [$k] ['date'] = "";
  4742. $verifyList [$k] ['opinion'] = "";
  4743. $verifyList [$k] ['status'] = "";
  4744. if (empty ( $verifyStaff )) {
  4745. $verifyList [$k] ['date'] = "";
  4746. $verifyList [$k] ['opinion'] = "";
  4747. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4748. $verifyList [$k] ['status'] = 4;
  4749. $flag = false;
  4750. }
  4751. } else {
  4752. foreach ( $verifyStaff as $m => $u ) {
  4753. if ($v [0] == $m) {
  4754. $verifyList [$k] ['date'] = $u ['date'];
  4755. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4756. $verifyList [$k] ['status'] = $u ['status'];
  4757. $flag = false;
  4758. break;
  4759. }
  4760. }
  4761. $endStaffArray = end ( $verifyStaff );
  4762. if (isset ( $endStaffArray ['ROLE'] )) {
  4763. } else {
  4764. // $endKey=key($verifyStaff);
  4765. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4766. // $button=4;
  4767. // $verifyList[$k]['status']=4;
  4768. // }
  4769. }
  4770. }
  4771. }
  4772. $rolename ['name'] = '';
  4773. if (! empty ( $roleId )) {
  4774. Doo::loadModel ( 'role' );
  4775. $role = new role ();
  4776. $rolename = $role->getOne ( array (
  4777. 'where' => 'rid=' . $roleId,
  4778. 'asArray' => true
  4779. ) );
  4780. }
  4781. if (! empty ( $verifyStaff ))
  4782. $endStaffArray = end ( $verifyStaff );
  4783. $KOP = false;
  4784. foreach ( $roleArrayCopy as $P => $A ) {
  4785. foreach ( $A as $MKI => $AVL ) {
  4786. if (! empty ( $verifyStaff )) {
  4787. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4788. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4789. $button = 4;
  4790. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4791. }
  4792. foreach ( $verifyStaff as $m => $u ) {
  4793. $AVLFK = $AVL [0] . '_R';
  4794. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4795. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4796. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4797. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4798. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4799. break;
  4800. }
  4801. }
  4802. } else {
  4803. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4804. $button = 4;
  4805. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4806. }
  4807. }
  4808. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4809. $KOP = true;
  4810. }
  4811. }
  4812. foreach ( $roleArrayCopy as $k => $v ) {
  4813. foreach ( $verifyList as $m => $n ) {
  4814. if ($n [0] == $k) {
  4815. array_splice ( $verifyList, $m, 1, $v );
  4816. }
  4817. }
  4818. }
  4819. $loanList [$key] ['verifyList'] = $verifyList;
  4820. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4821. 'where' => 'sid=' . $value ['staff'],
  4822. 'asArray' => true
  4823. ) );
  4824. $loanList [$key] ['button'] = $button;
  4825. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4826. }
  4827. $data ['loanList'] = $loanList;
  4828. //print_r($loanList);
  4829. $Locate = 0;
  4830. $roleId = 0;
  4831. $button = 0;
  4832. foreach ( $receiptList as $key => $value ) {
  4833. $receiptList [$key] ['Locate'] = $Locate;
  4834. $Locate ++;
  4835. $receiptList [$key] ['reviseDetail'] = array ();
  4836. if (! empty ( $value ['reviseDetail'] ))
  4837. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4838. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4839. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4840. $categoryDetil = $Lcategory->getOne ( array (
  4841. 'where' => 'cid=' . $value ['cid'],
  4842. 'asArray' => true
  4843. ) );
  4844. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4845. // 检测编辑状态
  4846. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4847. $verifyList ['staff'] = $value ['verifyBreakup'];
  4848. } else
  4849. $verifyList = $verify->getOne ( array (
  4850. 'where' => 'vid=' . $value ['verify'],
  4851. 'asArray' => true
  4852. ) );
  4853. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4854. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4855. Doo::loadModel ( 'role' );
  4856. $role = new role ();
  4857. if ($verifyList == NULL)
  4858. $verifyList = array ();
  4859. $flag = true;
  4860. $roleKey = 0;
  4861. $endStaffArray = array ();
  4862. $roleArrayCopy = array ();
  4863. foreach ( $verifyList as $k => $v ) {
  4864. // init verifyStaff
  4865. if ($v [1] == 'ROLE') {
  4866. if (! empty ( $verifyStaff )) {
  4867. $endStaffArray = end ( $verifyStaff );
  4868. // if ($v[0]==$endStaffArray['nextStaff']){
  4869. // $roleId=$v[0];
  4870. // }
  4871. }
  4872. $roleVerify = json_decode ( $v [3], true );
  4873. $roleKey = $k;
  4874. $roleArray = array ();
  4875. $rolename = $role->getOne ( array (
  4876. 'where' => 'rid=' . $v [0],
  4877. 'asArray' => true
  4878. ) );
  4879. foreach ( $roleVerify as $o => $p ) {
  4880. $staffID = explode ( '_', $p );
  4881. $staffInfo = $staff->getOne ( array (
  4882. 'where' => 'sid=' . $staffID [0],
  4883. 'asArray' => true
  4884. ) );
  4885. // print_r($staffID);
  4886. $exp = array (
  4887. 0 => $staffInfo ['sid'],
  4888. 1 => $staffID [1],
  4889. 2 => $staffInfo ['avatar'],
  4890. 'date' => '',
  4891. 'date' => '',
  4892. 'opinion' => '',
  4893. 'status' => '',
  4894. 'rolename' => $rolename ['name']
  4895. );
  4896. array_push ( $roleArray, $exp );
  4897. }
  4898. $roleArrayCopy [$v [0]] = $roleArray;
  4899. // $verifyList[$k]['roleArray']=$roleArray;
  4900. }
  4901. $verifyList [$k] ['date'] = "";
  4902. $verifyList [$k] ['opinion'] = "";
  4903. $verifyList [$k] ['status'] = "";
  4904. if (empty ( $verifyStaff )) {
  4905. $verifyList [$k] ['date'] = "";
  4906. $verifyList [$k] ['opinion'] = "";
  4907. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4908. $verifyList [$k] ['status'] = 4;
  4909. $flag = false;
  4910. }
  4911. } else {
  4912. foreach ( $verifyStaff as $m => $u ) {
  4913. if ($v [0] == $m) {
  4914. $verifyList [$k] ['date'] = $u ['date'];
  4915. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4916. $verifyList [$k] ['status'] = $u ['status'];
  4917. $flag = false;
  4918. break;
  4919. }
  4920. }
  4921. $endStaffArray = end ( $verifyStaff );
  4922. if (isset ( $endStaffArray ['ROLE'] )) {
  4923. } else {
  4924. // $endKey=key($verifyStaff);
  4925. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4926. // $button=4;
  4927. // $verifyList[$k]['status']=4;
  4928. // }
  4929. }
  4930. }
  4931. }
  4932. $FC = @$rolename ['name'];
  4933. $rolename ['name'] = '';
  4934. if (! empty ( $roleId )) {
  4935. Doo::loadModel ( 'role' );
  4936. $role = new role ();
  4937. $rolename = $role->getOne ( array (
  4938. 'where' => 'rid=' . $roleId,
  4939. 'asArray' => true
  4940. ) );
  4941. }
  4942. if (! empty ( $verifyStaff ))
  4943. $endStaffArray = end ( $verifyStaff );
  4944. $KOP = false;
  4945. foreach ( $roleArrayCopy as $P => $A ) {
  4946. foreach ( $A as $MKI => $AVL ) {
  4947. if (! empty ( $verifyStaff )) {
  4948. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4949. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4950. $button = 4;
  4951. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4952. }
  4953. foreach ( $verifyStaff as $m => $u ) {
  4954. $AVLFK = $AVL [0] . '_R';
  4955. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4956. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4957. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4958. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4959. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4960. break;
  4961. }
  4962. }
  4963. } else {
  4964. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4965. $button = 4;
  4966. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4967. }
  4968. }
  4969. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4970. $KOP = true;
  4971. }
  4972. }
  4973. foreach ( $roleArrayCopy as $k => $v ) {
  4974. foreach ( $verifyList as $m => $n ) {
  4975. if ($n [0] == $k) {
  4976. array_splice ( $verifyList, $m, 1, $v );
  4977. }
  4978. }
  4979. }
  4980. // 费用执行人相关数据
  4981. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4982. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4983. foreach ( $executeCopy as $k => $v ) {
  4984. $executeCopy [$k] ['date'] = '';
  4985. $executeCopy [$k] ['opinion'] = '';
  4986. $executeCopy [$k] ['status'] = '';
  4987. if (! empty ( $executeStaff ))
  4988. foreach ( $executeStaff as $m => $u ) {
  4989. if ($v [0] == $m) {
  4990. $executeCopy [$k] ['date'] = $u ['date'];
  4991. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4992. $executeCopy [$k] ['status'] = $u ['status'];
  4993. break;
  4994. }
  4995. }
  4996. }
  4997. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4998. // print_r($verifyList);
  4999. $receiptList [$key] ['verifyList'] = $verifyList;
  5000. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5001. 'where' => 'sid=' . $value ['staff'],
  5002. 'asArray' => true
  5003. ) );
  5004. $receiptList [$key] ['button'] = $button;
  5005. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5006. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5007. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5008. $receiptList [$key] ['relust'] = $relust;
  5009. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5010. }
  5011. // print_r($receiptList);
  5012. // 获取审批日志
  5013. Doo::loadModel ( 'receiptLog' );
  5014. $receiptLog = new receiptLog ();
  5015. $rlList = array ();
  5016. $rlInfo = $receiptLog->getOne ( array (
  5017. 'where' => 'rid=' . $rid . ' and status=4',
  5018. 'asArray' => true
  5019. ) );
  5020. // $tijdate = $receiptLog->getOne ( array (
  5021. // 'where' => 'rid=' . $rid . ' and status=2',
  5022. // 'asc' => 'rlid',
  5023. // 'asArray' => true
  5024. // ) );
  5025. if (! empty ( $rlInfo )) {
  5026. $rlList = $receiptLog->find ( array (
  5027. 'where' => 'rid=' . $rid,
  5028. 'asc' => 'rlid',
  5029. 'asArray' => true
  5030. ) );
  5031. }
  5032. $RN=array();
  5033. if (!empty( $rolename ['staff'])){
  5034. $RN = @json_decode ( $rolename ['staff'] );
  5035. }
  5036. //
  5037. foreach ( $rlList as $key => $value ) {
  5038. $rlList [$key] ['rolename'] = '';
  5039. foreach ( $RN as $k => $v ) {
  5040. $id = explode ( "_", $v );
  5041. if ($id [0] == $value ['uid']) {
  5042. $rlList [$key] ['rolename'] = $FC;
  5043. break;
  5044. }
  5045. }
  5046. }
  5047. Doo::loadModel ( 'enclosur' );
  5048. $enclosur = new enclosur ();
  5049. $enclosurList = $enclosur->find ( array (
  5050. 'where' => 'rid=' . $rid,
  5051. 'asArray' => true
  5052. ) );
  5053. $enclosurHtml = '';
  5054. foreach ( $enclosurList as $value ) {
  5055. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5056. }
  5057. $data ['enclosurHtml'] = $enclosurHtml;
  5058. $receiptList [0] ['rlList'] = $rlList;
  5059. $data ['receiptList'] = $receiptList;
  5060. $data ['receiptList'][0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  5061. // print_r($receiptList);
  5062. $data ['memu'] = "receipt";
  5063. $data ['staff'] = $this->staff;
  5064. $data ['receiptMemu'] = 'approvalExpenses';
  5065. $data ['verifyId'] = $this->verifyId;
  5066. $data ['executeId'] = $this->executeId;
  5067. return $data;
  5068. }
  5069. function expensesDoc() {
  5070. $data=$this->_expensesDoc();
  5071. if(!empty($data['receiptList'][0]['itinerary2'])){
  5072. $this->render ( "/receipt/feeTraveView", $data );
  5073. }else{
  5074. $this->render ( "/admin/expensesDoc", $data );
  5075. }
  5076. }
  5077. function expensesDocPrint(){
  5078. $data=$this->_expensesDoc();
  5079. $this->render ( "/receipt/expensesDocPrint", $data );
  5080. }
  5081. function expensesEdi() {
  5082. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5083. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5084. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5085. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5086. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5087. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5088. if (empty ( $status ))
  5089. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5090. $vidList = array ();
  5091. $button = 0;
  5092. Doo::loadModel ( 'verify' );
  5093. Doo::loadModel ( 'receipt' );
  5094. Doo::loadModel ( 'staff' );
  5095. $staff = new staff ();
  5096. $receipt = new receipt ();
  5097. $verify = new verify ();
  5098. Doo::loadModel ( 'L_category' );
  5099. $Lcategory = new L_category ();
  5100. Doo::loadModel ( 'enclosur' );
  5101. $enclosur = new enclosur ();
  5102. // user verify ID
  5103. $verifyDetail = $verify->find ( array (
  5104. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5105. 'asArray' => true
  5106. ) );
  5107. foreach ( $verifyDetail as $key => $value ) {
  5108. array_push ( $vidList, $value ['vid'] );
  5109. }
  5110. $vid = implode ( ",", $vidList );
  5111. if (empty ( $verifyDetail ))
  5112. $vid = 0;
  5113. $categoryList = $Lcategory->find ( array (
  5114. 'asArray' => true
  5115. ) );
  5116. $staffList = $staff->find ( array (
  5117. 'where' => 'cid=' . $cid,
  5118. 'asArray' => true
  5119. ) );
  5120. $ap = "";
  5121. if ($status == 4) {
  5122. $ap = 4;
  5123. $status = 2;
  5124. }
  5125. // get Receipt By verifyID status 2
  5126. $receiptList = $receipt->find ( array (
  5127. 'where' => 'rid =' . $rid . ' and status=2',
  5128. 'desc' => 'rid',
  5129. 'asArray' => true
  5130. ) );
  5131. if (empty ( $receiptList )) {
  5132. die ( 'illegal request' );
  5133. }
  5134. $Locate = 0;
  5135. $roleId = 0;
  5136. if ($ap == 4)
  5137. $status = 4;
  5138. foreach ( $receiptList as $key => $value ) {
  5139. $receiptList [$key] ['Locate'] = $Locate;
  5140. $Locate ++;
  5141. $receiptList [$key] ['reviseDetail'] = array ();
  5142. if (! empty ( $value ['reviseDetail'] ))
  5143. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5144. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5145. $categoryDetil = $Lcategory->getOne ( array (
  5146. 'where' => 'cid=' . $value ['cid'],
  5147. 'asArray' => true
  5148. ) );
  5149. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5150. // 检测编辑状态
  5151. $verifyList = $verify->getOne ( array (
  5152. 'where' => 'vid=' . $value ['verify'],
  5153. 'asArray' => true
  5154. ) );
  5155. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5156. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5157. Doo::loadModel ( 'role' );
  5158. $role = new role ();
  5159. // print_r($verifyList);
  5160. $flag = true;
  5161. $roleKey = 0;
  5162. $endStaffArray = array ();
  5163. $roleArrayCopy = array ();
  5164. foreach ( $verifyList as $k => $v ) {
  5165. // init verifyStaff
  5166. if ($v [1] == 'ROLE') {
  5167. if (! empty ( $verifyStaff )) {
  5168. $endStaffArray = end ( $verifyStaff );
  5169. if ($v [0] == $endStaffArray ['nextStaff']) {
  5170. $roleId = $v [0];
  5171. }
  5172. }
  5173. $roleVerify = json_decode ( $v [3], true );
  5174. $roleKey = $k;
  5175. $roleArray = array ();
  5176. $rolename = $role->getOne ( array (
  5177. 'where' => 'rid=' . $v [0],
  5178. 'asArray' => true
  5179. ) );
  5180. foreach ( $roleVerify as $o => $p ) {
  5181. $staffID = explode ( '_', $p );
  5182. $staffInfo = $staff->getOne ( array (
  5183. 'where' => 'sid=' . $staffID [0],
  5184. 'asArray' => true
  5185. ) );
  5186. // print_r($staffID);
  5187. $exp = array (
  5188. 0 => $staffInfo ['sid'],
  5189. 1 => $staffID [1],
  5190. 2 => $staffInfo ['avatar'],
  5191. 'date' => '',
  5192. 'date' => '',
  5193. 'opinion' => '',
  5194. 'status' => '',
  5195. 'rolename' => $rolename ['name']
  5196. );
  5197. array_push ( $roleArray, $exp );
  5198. }
  5199. $roleArrayCopy [$v [0]] = $roleArray;
  5200. // $verifyList[$k]['roleArray']=$roleArray;
  5201. }
  5202. // print_r($roleArray);
  5203. $verifyList [$k] ['date'] = "";
  5204. $verifyList [$k] ['opinion'] = "";
  5205. $verifyList [$k] ['status'] = "";
  5206. if (empty ( $verifyStaff )) {
  5207. $verifyList [$k] ['date'] = "";
  5208. $verifyList [$k] ['opinion'] = "";
  5209. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5210. $verifyList [$k] ['status'] = 4;
  5211. $button = 4;
  5212. $flag = false;
  5213. }
  5214. } else {
  5215. foreach ( $verifyStaff as $m => $u ) {
  5216. if ($v [0] == $m) {
  5217. $verifyList [$k] ['date'] = $u ['date'];
  5218. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5219. $verifyList [$k] ['status'] = $u ['status'];
  5220. $flag = false;
  5221. break;
  5222. }
  5223. }
  5224. $endStaffArray = end ( $verifyStaff );
  5225. if (isset ( $endStaffArray ['ROLE'] )) {
  5226. } else {
  5227. $endKey = key ( $verifyStaff );
  5228. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5229. $button = 4;
  5230. $verifyList [$k] ['status'] = 4;
  5231. }
  5232. }
  5233. }
  5234. }
  5235. $rolename ['name'] = '';
  5236. if (! empty ( $roleId )) {
  5237. Doo::loadModel ( 'role' );
  5238. $role = new role ();
  5239. $rolename = $role->getOne ( array (
  5240. 'where' => 'rid=' . $roleId,
  5241. 'asArray' => true
  5242. ) );
  5243. }
  5244. if (! empty ( $verifyStaff ))
  5245. $endStaffArray = end ( $verifyStaff );
  5246. $KOP = false;
  5247. foreach ( $roleArrayCopy as $P => $A ) {
  5248. foreach ( $A as $MKI => $AVL ) {
  5249. if (! empty ( $verifyStaff )) {
  5250. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5251. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5252. $button = 4;
  5253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5254. }
  5255. foreach ( $verifyStaff as $m => $u ) {
  5256. $AVLFK = $AVL [0] . '_R';
  5257. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5258. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5259. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5260. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5261. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5262. break;
  5263. }
  5264. }
  5265. } else {
  5266. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5267. $button = 4;
  5268. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5269. }
  5270. }
  5271. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5272. $KOP = true;
  5273. }
  5274. }
  5275. // print_r($roleArrayCopy);
  5276. // echo $roleKey;
  5277. foreach ( $roleArrayCopy as $k => $v ) {
  5278. foreach ( $verifyList as $m => $n ) {
  5279. if ($n [0] == $k) {
  5280. array_splice ( $verifyList, $m, 1, $v );
  5281. }
  5282. }
  5283. }
  5284. $receiptList [$key] ['verifyList'] = $verifyList;
  5285. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5286. 'where' => 'sid=' . $value ['staff'],
  5287. 'asArray' => true
  5288. ) );
  5289. $receiptList [$key] ['button'] = $button;
  5290. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5291. }
  5292. // $data['verifyDetail']=$verifyDetail;
  5293. $mothHtml = "";
  5294. for($i = 1; $i <= 12; $i ++) {
  5295. if ($month == $i)
  5296. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5297. else
  5298. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5299. }
  5300. // 获取审批日志
  5301. Doo::loadModel ( 'receiptLog' );
  5302. $receiptLog = new receiptLog ();
  5303. $rlList = array ();
  5304. $rlInfo = $receiptLog->getOne ( array (
  5305. 'where' => 'rid=' . $rid . ' and status=4',
  5306. 'asArray' => true
  5307. ) );
  5308. $tijdate = $receiptLog->getOne ( array (
  5309. 'where' => 'rid=' . $rid . ' and status=2',
  5310. 'asc' => 'rlid',
  5311. 'asArray' => true
  5312. ) );
  5313. if (! empty ( $rlInfo )) {
  5314. $rlList = $receiptLog->find ( array (
  5315. 'where' => 'rid=' . $rid,
  5316. 'asc' => 'rlid',
  5317. 'asArray' => true
  5318. ) );
  5319. }
  5320. $receiptList [0] ['rlList'] = $rlList;
  5321. $enclosurList = $enclosur->find ( array (
  5322. 'where' => 'rid=' . $rid,
  5323. 'asArray' => true
  5324. ) );
  5325. $enclosurHtml = '';
  5326. foreach ( $enclosurList as $value ) {
  5327. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5328. }
  5329. // print_r($receiptList);
  5330. $data ['rid'] = $rid;
  5331. $data ['enclosurHtml'] = $enclosurHtml;
  5332. $data ['rolename'] = $rolename ['name'];
  5333. $data ['datetij'] = $tijdate ['date'];
  5334. $data ['mothHtml'] = $mothHtml;
  5335. $data ['receiptList'] = $receiptList;
  5336. $data ['receiptApprovalCount'] = count ( $receiptList );
  5337. $data ['status'] = $status;
  5338. $data ['year'] = $year;
  5339. $data ['categoryList'] = $categoryList;
  5340. $data ['staffList'] = $staffList;
  5341. $data ['cid'] = $cid;
  5342. $data ['sid'] = $sid;
  5343. $data ['ap'] = $ap;
  5344. $data ['memu'] = "receipt";
  5345. $data ['staff'] = $this->staff;
  5346. $data ['receiptMemu'] = 'approvalExpenses';
  5347. $data ['verifyId'] = $this->verifyId;
  5348. $data ['executeId'] = $this->executeId;
  5349. $this->render ( "/admin/expensesEdi", $data );
  5350. }
  5351. function expensesDefray() {
  5352. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5353. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5354. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5355. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5356. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5357. if (! empty ( $rid )) {
  5358. Doo::loadModel ( "verify" );
  5359. $verify = new verify ();
  5360. Doo::loadModel ( "receiptDetail" );
  5361. $receiptDetailObj = new receiptDetail ();
  5362. Doo::loadModel ( "itemStatistics" );
  5363. Doo::loadModel ( "statistics" );
  5364. $statistics = new statistics ();
  5365. $itemStatistics = new itemStatistics ();
  5366. Doo::loadModel ( "receipt" );
  5367. $receipt = new receipt ();
  5368. Doo::loadModel ( "loanReceipt" );
  5369. $loanReceipt = new loanReceipt ();
  5370. $receiptDetail = $receipt->getOne ( array (
  5371. 'where' => 'rid=' . $rid . ' and status=2 ',
  5372. 'asArray' => true
  5373. ) );
  5374. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5375. $nsflag = true;
  5376. foreach ( $nslist as $value ) {
  5377. if ($value == $this->staff ['0'] ['sid']) {
  5378. $nsflag = false;
  5379. break;
  5380. }
  5381. }
  5382. // print_r($nslist);die;
  5383. if (empty ( $receiptDetail ) || $nsflag)
  5384. return "/approvalExpenses/pendApproval";
  5385. $verifyDetail = $verify->getOne ( array (
  5386. 'where' => ' vid =' . $receiptDetail ['verify'],
  5387. 'asArray' => true
  5388. ) );
  5389. $verifyString = $verifyDetail ['staff'];
  5390. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5391. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5392. if (empty ( $opinion )) {
  5393. if ($status == 3)
  5394. $opinion = "终止";
  5395. else
  5396. $opinion = "同意支付";
  5397. }
  5398. $nowStaff = 0;
  5399. $nowStaffList = array ();
  5400. if (empty ( $verifyStaff )) {
  5401. // 还需加入是否已经进入角色审批
  5402. if ($verifyDetail [0] [1] == 'ROLE') {
  5403. // print_r($verifyDetail);echo "ddd";
  5404. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5405. foreach ( $vStaffString as $key => $value ) {
  5406. $staffK = explode ( "_", $value );
  5407. if ($staffK [0] != $this->staff [0] ['sid'])
  5408. array_push ( $nowStaffList, $staffK [0] );
  5409. }
  5410. // print_r($verifyDetail);
  5411. // die;
  5412. if (! empty ( $nowStaffList )) {
  5413. $nowStaff = implode ( ',', $nowStaffList );
  5414. $verifyStaff = array (
  5415. $this->staff [0] ['sid'] . "_R" => array (
  5416. 'date' => date ( 'Y-m-d' ),
  5417. 'opinion' => $opinion,
  5418. 'status' => $status,
  5419. 'nextStaff' => $verifyDetail [0] [0],
  5420. 'ROLE' => 1
  5421. )
  5422. );
  5423. } else {
  5424. $nowStaff = $verifyDetail [1] [0];
  5425. $verifyStaff = array (
  5426. $this->staff [0] ['sid'] . "_R" => array (
  5427. 'date' => date ( 'Y-m-d' ),
  5428. 'opinion' => $opinion,
  5429. 'status' => $status,
  5430. 'nextStaff' => $verifyDetail [1] [0]
  5431. )
  5432. );
  5433. }
  5434. } else {
  5435. if ($verifyDetail [1] [1] == 'ROLE') {
  5436. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5437. // echo "dd";
  5438. foreach ( $vStaffString as $key => $value ) {
  5439. $staffK = explode ( "_", $value );
  5440. array_push ( $nowStaffList, $staffK [0] );
  5441. }
  5442. $nowStaff = implode ( ',', $nowStaffList );
  5443. $verifyStaff = array (
  5444. $this->staff [0] ['sid'] => array (
  5445. 'date' => date ( 'Y-m-d' ),
  5446. 'opinion' => $opinion,
  5447. 'status' => $status,
  5448. 'nextStaff' => $verifyDetail [1] [0],
  5449. 'ROLE' => 1
  5450. )
  5451. );
  5452. } else {
  5453. $nowStaff = $verifyDetail [1] [0];
  5454. $verifyStaff = array (
  5455. $this->staff [0] ['sid'] => array (
  5456. 'date' => date ( 'Y-m-d' ),
  5457. 'opinion' => $opinion,
  5458. 'status' => $status,
  5459. 'nextStaff' => $verifyDetail [1] [0]
  5460. )
  5461. );
  5462. }
  5463. }
  5464. if ($status == 3)
  5465. $verifyStaff = array (
  5466. 'final' => $status,
  5467. $this->staff [0] ['sid'] => array (
  5468. 'date' => date ( 'Y-m-d' ),
  5469. 'opinion' => $opinion,
  5470. 'status' => $status
  5471. )
  5472. );
  5473. $vStaffString = json_encode ( $verifyStaff );
  5474. $receipt->nowStaff = $nowStaff;
  5475. $receipt->verifyStaff = $vStaffString;
  5476. $loanReceipt->nowStaff = $nowStaff;
  5477. $loanReceipt->verifyStaff = $vStaffString;
  5478. } else {
  5479. $VS = end ( $verifyStaff );
  5480. // 非角色审批
  5481. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5482. $nextStaff = 0;
  5483. $roleSTF = false;
  5484. foreach ( $verifyDetail as $key => $value ) {
  5485. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5486. if (isset ( $verifyDetail [$key + 1] )) {
  5487. $nextStaff = $verifyDetail [$key + 1] [0];
  5488. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5489. $roleSTF = true;
  5490. }
  5491. break;
  5492. }
  5493. }
  5494. if (! $roleSTF) {
  5495. $nowStaff = $nextStaff;
  5496. $verifyStaff [$this->staff [0] ['sid']] = array (
  5497. 'date' => date ( 'Y-m-d' ),
  5498. 'opinion' => $opinion,
  5499. 'status' => $status,
  5500. 'nextStaff' => $nextStaff
  5501. );
  5502. } else {
  5503. // 获取角色下的所有用户ID
  5504. $nowStaffList = array ();
  5505. foreach ( $verifyDetail as $vfk ) {
  5506. if ($vfk [1] == 'ROLE') {
  5507. $vStaffString = json_decode ( $vfk [3] );
  5508. foreach ( $vStaffString as $key => $value ) {
  5509. $staffK = explode ( "_", $value );
  5510. array_push ( $nowStaffList, $staffK [0] );
  5511. }
  5512. }
  5513. }
  5514. $nowStaff = implode ( ',', $nowStaffList );
  5515. $verifyStaff [$this->staff [0] ['sid']] = array (
  5516. 'date' => date ( 'Y-m-d' ),
  5517. 'opinion' => $opinion,
  5518. 'status' => $status,
  5519. 'nextStaff' => $nextStaff,
  5520. 'ROLE' => 0
  5521. );
  5522. }
  5523. if ($status == 3) {
  5524. $verifyStaff ['final'] = $status;
  5525. $verifyStaff [$this->staff [0] ['sid']] = array (
  5526. 'date' => date ( 'Y-m-d' ),
  5527. 'opinion' => $opinion,
  5528. 'status' => $status
  5529. );
  5530. }
  5531. $vStaffString = json_encode ( $verifyStaff );
  5532. $receipt->nowStaff = $nowStaff;
  5533. $receipt->verifyStaff = $vStaffString;
  5534. $loanReceipt->nowStaff = $nowStaff;
  5535. $loanReceipt->verifyStaff = $vStaffString;
  5536. }
  5537. // 角色审批
  5538. if (isset ( $VS ['ROLE'] )) {
  5539. // 找出角色人 当前审批角色组
  5540. $verifyJSStaff = array ();
  5541. $nowStaffList2 = array ();
  5542. foreach ( $verifyDetail as $key => $value ) {
  5543. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5544. $verifyJSStaff = json_decode ( $value [3] );
  5545. foreach ( $verifyJSStaff as $m ) {
  5546. $staffK = explode ( "_", $m );
  5547. array_push ( $nowStaffList2, $staffK [0] );
  5548. }
  5549. // print_r($nowStaffList2);
  5550. }
  5551. }
  5552. $RoleVerifyStaff = array ();
  5553. foreach ( $verifyStaff as $key => $value ) {
  5554. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5555. foreach ( $nowStaffList2 as $m ) {
  5556. if ($key == $m . "_R")
  5557. $RoleVerifyStaff [$key] = $value;
  5558. }
  5559. }
  5560. }
  5561. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5562. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5563. // 下一个审批人ID
  5564. $nextStaff = 0;
  5565. $falg = false;
  5566. foreach ( $verifyDetail as $key => $value ) {
  5567. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5568. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5569. $falg = true;
  5570. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5571. $nowStaffList = array ();
  5572. foreach ( $vStaffString as $v ) {
  5573. $staffK = explode ( "_", $v );
  5574. array_push ( $nowStaffList, $staffK [0] );
  5575. }
  5576. $nowStaff = implode ( ',', $nowStaffList );
  5577. $nextStaff = $verifyDetail [$key + 1] [0];
  5578. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5579. $nextStaff = $verifyDetail [$key + 1] [0];
  5580. $nowStaff = $nextStaff;
  5581. } else
  5582. $nowStaff = '';
  5583. break;
  5584. }
  5585. }
  5586. if ($falg)
  5587. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5588. 'date' => date ( 'Y-m-d' ),
  5589. 'opinion' => $opinion,
  5590. 'status' => $status,
  5591. 'nextStaff' => $nextStaff,
  5592. 'ROLE' => 1
  5593. );
  5594. else
  5595. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5596. 'date' => date ( 'Y-m-d' ),
  5597. 'opinion' => $opinion,
  5598. 'status' => $status,
  5599. 'nextStaff' => $nextStaff
  5600. );
  5601. // print_r($verifyStaff);
  5602. // echo $nowStaff;die;
  5603. } else { // 进入下一个角色或者审批人
  5604. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5605. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5606. 'date' => date ( 'Y-m-d' ),
  5607. 'opinion' => $opinion,
  5608. 'status' => $status,
  5609. 'nextStaff' => $VS ['nextStaff'],
  5610. 'ROLE' => 1
  5611. );
  5612. }
  5613. if ($status == 3) {
  5614. $verifyStaff ['final'] = $status;
  5615. $verifyStaff [$this->staff [0] ['sid']] = array (
  5616. 'date' => date ( 'Y-m-d' ),
  5617. 'opinion' => $opinion,
  5618. 'status' => $status
  5619. );
  5620. }
  5621. $vStaffString = json_encode ( $verifyStaff );
  5622. $receipt->verifyStaff = $vStaffString;
  5623. $receipt->nowStaff = $nowStaff;
  5624. $loanReceipt->nowStaff = $nowStaff;
  5625. $loanReceipt->verifyStaff = $vStaffString;
  5626. }
  5627. // print_r($verifyStaff);die;
  5628. }
  5629. $roleKey = 0;
  5630. $roleId = 0;
  5631. $verifyDetailCopy = array ();
  5632. foreach ( $verifyDetail as $k => $v ) {
  5633. if ($v [1] == 'ROLE') {
  5634. $roleId = $v [0];
  5635. $roleVerify = json_decode ( $v [3], true );
  5636. $roleKey = $k;
  5637. $roleArray = array ();
  5638. foreach ( $roleVerify as $o => $p ) {
  5639. $staffID = explode ( '_', $p );
  5640. $exp = array (
  5641. 0 => $staffID [0],
  5642. 1 => $staffID [1]
  5643. );
  5644. array_push ( $roleArray, $exp );
  5645. }
  5646. $verifyDetailCopy [$v [0]] = $roleArray;
  5647. }
  5648. }
  5649. // print_r($verifyDetail);
  5650. foreach ( $verifyDetailCopy as $k => $v ) {
  5651. foreach ( $verifyDetail as $m => $n ) {
  5652. if ($n [0] == $k) {
  5653. array_splice ( $verifyDetail, $m, 1, $v );
  5654. }
  5655. }
  5656. }
  5657. // 审批日志
  5658. if (! isset ( $verifyStaff ['final'] )) {
  5659. Doo::loadModel ( "receiptLog" );
  5660. $receiptLog = new receiptLog ();
  5661. if (! empty ( $roleId )) {
  5662. Doo::loadModel ( "role" );
  5663. $role = new role ();
  5664. $roleInfo = $role->getOne ( array (
  5665. 'where' => 'rid=' . $roleId,
  5666. 'asArray' => true
  5667. ) );
  5668. $receiptLog->rolename = $roleInfo ['name'];
  5669. }
  5670. $receiptLog->username = $this->staff [0] ['username'];
  5671. $receiptLog->uid = $this->staff [0] ['sid'];
  5672. $receiptLog->date = date ( "Y-m-d" );
  5673. $receiptLog->opinion = $opinion;
  5674. $receiptLog->img = $this->staff [0] ['avatar'];
  5675. $receiptLog->status = 1;
  5676. $receiptLog->rid = $rid;
  5677. $receiptLog->insert ();
  5678. }
  5679. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5680. $receipt->status = 3;
  5681. $receipt->verifyBreakup = $verifyString;
  5682. $receiptDetailObj->status = 3;
  5683. $receiptDetailObj->update ( array (
  5684. 'where' => 'rid=' . $rid
  5685. ) );
  5686. // 微信企业号通知
  5687. $this->setWXMsg ( $rid, 3 );
  5688. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5689. $receipt->status = 6;
  5690. $receipt->pastDate = date ( "Y-m-d" );
  5691. $receipt->isBK = 1;
  5692. $loanReceipt->verifyBreakup = $verifyString;
  5693. $loanReceipt->status = 1;
  5694. $loanReceipt->pastDate = date ( "Y-m-d" );
  5695. //生成流水后 不更新汇款金额
  5696. Doo::loadModel ( 'wasteBook' );
  5697. $wasteBook = new wasteBook ();
  5698. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5699. if (empty($wbDetail)){
  5700. $loanReceipt->amount = $receiptDetail ['amount'];
  5701. }
  5702. $loanReceipt->update ( array (
  5703. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5704. ) );
  5705. // 微信企业号通知
  5706. $this->setWXMsg ( $rid, 1 );
  5707. }
  5708. $receipt->amount = $receiptDetail['sum'];
  5709. $receipt->update ( array (
  5710. 'where' => ' rid = ' . $rid
  5711. ) );
  5712. // 进入下一条审批费用新加需求
  5713. $vidList = array ();
  5714. $verifyDetail = $verify->find ( array (
  5715. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5716. 'asArray' => true
  5717. ) );
  5718. foreach ( $verifyDetail as $key => $value ) {
  5719. array_push ( $vidList, $value ['vid'] );
  5720. }
  5721. $vid = implode ( ",", $vidList );
  5722. if (empty ( $verifyDetail ))
  5723. $vid = 0;
  5724. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5725. $receipt = new receipt ();
  5726. $rd = $receipt->getOne ( array (
  5727. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5728. 'asc' => 'rid',
  5729. 'asArray' => true
  5730. ) );
  5731. if (empty ( $rd )) {
  5732. return '/approvalExpenses/pendApproval';
  5733. }
  5734. if ($rd ['Rtype'] == 1) {
  5735. if ($rd ['isBK'] == 1) {
  5736. return '/receiptburEdi/' . $rd ['rid'];
  5737. } else {
  5738. return '/expensesEdi/' . $rd ['rid'];
  5739. }
  5740. } elseif ($rd ['Rtype'] == 2) {
  5741. return '/remitApproval/' . $rd ['rid'];
  5742. } else {
  5743. return '/receiptburEdi/' . $rd ['rid'];
  5744. }
  5745. // return "/approvalExpenses/pendApproval";
  5746. }
  5747. }
  5748. function ajaxExamineExe() {
  5749. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5750. Doo::loadModel ( 'receipt' );
  5751. $receipt = new receipt ();
  5752. Doo::loadClass ( 'XDeode' );
  5753. $XDeode = new XDeode ( 5 );
  5754. if (! empty ( $rid )) {
  5755. $rLRes = $receipt->find ( array (
  5756. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5757. 'asArray' => true
  5758. ) );
  5759. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5760. echo json_encode ( array (
  5761. 'status' => 1,
  5762. 'receipt' => $rLRes [0]
  5763. ) );
  5764. die ();
  5765. }
  5766. echo json_encode ( array (
  5767. 'status' => 0,
  5768. 'receipt' => array ()
  5769. ) );
  5770. die ();
  5771. }
  5772. function implement() {
  5773. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5774. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5775. Doo::loadClass ( 'XDeode' );
  5776. $XDeode = new XDeode ( 5 );
  5777. Doo::loadModel ( 'receipt' );
  5778. $receipt = new receipt ();
  5779. Doo::loadModel ( 'L_category' );
  5780. $Lcategory = new L_category ();
  5781. Doo::loadModel ( 'verify' );
  5782. $verify = new verify ();
  5783. Doo::loadModel ( 'staff' );
  5784. $staff = new staff ();
  5785. Doo::loadModel ( "execute" );
  5786. $execute = new execute ();
  5787. $rid = $XDeode->decode ( $rid );
  5788. $receiptList = $receipt->find ( array (
  5789. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5790. 'desc' => 'rid',
  5791. 'asArray' => true
  5792. ) );
  5793. Doo::loadModel ( 'loanReceipt' );
  5794. $loanReceipt = new loanReceipt ();
  5795. // print_r($receiptList);
  5796. $loanList = array ();
  5797. if (! isset ( $receiptList ))
  5798. $loanList = $loanReceipt->find ( array (
  5799. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5800. 'desc' => 'rid',
  5801. 'asArray' => true
  5802. ) );
  5803. $Locate = 0;
  5804. $roleId = 0;
  5805. $button = 0;
  5806. foreach ( $loanList as $key => $value ) {
  5807. $loanList [$key] ['Locate'] = $Locate;
  5808. $Locate ++;
  5809. $loanList [$key] ['reviseDetail'] = array ();
  5810. if (! empty ( $value ['reviseDetail'] ))
  5811. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5812. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5813. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5814. $categoryDetil = $Lcategory->getOne ( array (
  5815. 'where' => 'cid=' . $value ['cid'],
  5816. 'asArray' => true
  5817. ) );
  5818. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5819. // 检测编辑状态
  5820. $verifyList = $verify->getOne ( array (
  5821. 'where' => 'vid=' . $value ['verify'],
  5822. 'asArray' => true
  5823. ) );
  5824. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5825. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5826. Doo::loadModel ( 'role' );
  5827. $role = new role ();
  5828. $flag = true;
  5829. $roleKey = 0;
  5830. $endStaffArray = array ();
  5831. $roleArrayCopy = array ();
  5832. foreach ( $verifyList as $k => $v ) {
  5833. // init verifyStaff
  5834. if ($v [1] == 'ROLE') {
  5835. if (! empty ( $verifyStaff )) {
  5836. $endStaffArray = end ( $verifyStaff );
  5837. // if ($v[0]==$endStaffArray['nextStaff']){
  5838. // $roleId=$v[0];
  5839. // }
  5840. }
  5841. $roleVerify = json_decode ( $v [3], true );
  5842. $roleKey = $k;
  5843. $roleArray = array ();
  5844. $rolename = $role->getOne ( array (
  5845. 'where' => 'rid=' . $v [0],
  5846. 'asArray' => true
  5847. ) );
  5848. foreach ( $roleVerify as $o => $p ) {
  5849. $staffID = explode ( '_', $p );
  5850. $staffInfo = $staff->getOne ( array (
  5851. 'where' => 'sid=' . $staffID [0],
  5852. 'asArray' => true
  5853. ) );
  5854. // print_r($staffID);
  5855. $exp = array (
  5856. 0 => $staffInfo ['sid'],
  5857. 1 => $staffID [1],
  5858. 2 => $staffInfo ['avatar'],
  5859. 'date' => '',
  5860. 'date' => '',
  5861. 'opinion' => '',
  5862. 'status' => '',
  5863. 'rolename' => $rolename ['name']
  5864. );
  5865. array_push ( $roleArray, $exp );
  5866. }
  5867. $roleArrayCopy [$v [0]] = $roleArray;
  5868. // $verifyList[$k]['roleArray']=$roleArray;
  5869. }
  5870. $verifyList [$k] ['date'] = "";
  5871. $verifyList [$k] ['opinion'] = "";
  5872. $verifyList [$k] ['status'] = "";
  5873. if (empty ( $verifyStaff )) {
  5874. $verifyList [$k] ['date'] = "";
  5875. $verifyList [$k] ['opinion'] = "";
  5876. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5877. $verifyList [$k] ['status'] = 4;
  5878. $flag = false;
  5879. }
  5880. } else {
  5881. foreach ( $verifyStaff as $m => $u ) {
  5882. if ($v [0] == $m) {
  5883. $verifyList [$k] ['date'] = $u ['date'];
  5884. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5885. $verifyList [$k] ['status'] = $u ['status'];
  5886. $flag = false;
  5887. break;
  5888. }
  5889. }
  5890. $endStaffArray = end ( $verifyStaff );
  5891. if (isset ( $endStaffArray ['ROLE'] )) {
  5892. } else {
  5893. // $endKey=key($verifyStaff);
  5894. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5895. // $button=4;
  5896. // $verifyList[$k]['status']=4;
  5897. // }
  5898. }
  5899. }
  5900. }
  5901. $rolename ['name'] = '';
  5902. if (! empty ( $roleId )) {
  5903. Doo::loadModel ( 'role' );
  5904. $role = new role ();
  5905. $rolename = $role->getOne ( array (
  5906. 'where' => 'rid=' . $roleId,
  5907. 'asArray' => true
  5908. ) );
  5909. }
  5910. if (! empty ( $verifyStaff ))
  5911. $endStaffArray = end ( $verifyStaff );
  5912. $KOP = false;
  5913. foreach ( $roleArrayCopy as $P => $A ) {
  5914. foreach ( $A as $MKI => $AVL ) {
  5915. if (! empty ( $verifyStaff )) {
  5916. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5917. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5918. $button = 4;
  5919. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5920. }
  5921. foreach ( $verifyStaff as $m => $u ) {
  5922. $AVLFK = $AVL [0] . '_R';
  5923. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5924. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5925. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5926. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5927. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5928. break;
  5929. }
  5930. }
  5931. } else {
  5932. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5933. $button = 4;
  5934. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5935. }
  5936. }
  5937. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5938. $KOP = true;
  5939. }
  5940. }
  5941. foreach ( $roleArrayCopy as $k => $v ) {
  5942. foreach ( $verifyList as $m => $n ) {
  5943. if ($n [0] == $k) {
  5944. array_splice ( $verifyList, $m, 1, $v );
  5945. }
  5946. }
  5947. }
  5948. $loanList [$key] ['verifyList'] = $verifyList;
  5949. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5950. 'where' => 'sid=' . $value ['staff'],
  5951. 'asArray' => true
  5952. ) );
  5953. }
  5954. $data ['loanList'] = $loanList;
  5955. $Locate = 0;
  5956. $roleId = 0;
  5957. $button = 0;
  5958. Doo::loadClass ( 'XDeode' );
  5959. $XDeode = new XDeode ( 5 );
  5960. foreach ( $receiptList as $key => $value ) {
  5961. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5962. $button2 = 0;
  5963. $receiptList [$key] ['Locate'] = $Locate;
  5964. $Locate ++;
  5965. $receiptList [$key] ['reviseDetail'] = array ();
  5966. if (! empty ( $value ['reviseDetail'] ))
  5967. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5968. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5969. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5970. $categoryDetil = $Lcategory->getOne ( array (
  5971. 'where' => 'cid=' . $value ['cid'],
  5972. 'asArray' => true
  5973. ) );
  5974. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5975. $executeList = json_decode ( $value ['executeCopy'], true );
  5976. $executeStaff = array ();
  5977. if (! empty ( $value ['executeStaff'] ))
  5978. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5979. if (isset ( $executeList )) {
  5980. foreach ( $executeList as $op => $lo ) {
  5981. $executeList [$op] ['date'] = "";
  5982. $executeList [$op] ['opinion'] = "";
  5983. $executeList [$op] ['status'] = "";
  5984. foreach ( $executeStaff as $m => $u ) {
  5985. if ($lo [0] == $m) {
  5986. $executeList [$op] ['date'] = $u ['date'];
  5987. $executeList [$op] ['opinion'] = $u ['opinion'];
  5988. $executeList [$op] ['status'] = $u ['status'];
  5989. break;
  5990. }
  5991. }
  5992. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5993. $button2 = 1;
  5994. $executeList [$op] ['status'] = 4;
  5995. }
  5996. }
  5997. }
  5998. // 检测编辑状态
  5999. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6000. $verifyList ['staff'] = $value ['verifyBreakup'];
  6001. } else
  6002. $verifyList = $verify->getOne ( array (
  6003. 'where' => 'vid=' . $value ['verify'],
  6004. 'asArray' => true
  6005. ) );
  6006. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6007. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6008. Doo::loadModel ( 'role' );
  6009. $role = new role ();
  6010. if ($verifyList == NULL)
  6011. $verifyList = array ();
  6012. $flag = true;
  6013. $roleKey = 0;
  6014. $endStaffArray = array ();
  6015. $roleArrayCopy = array ();
  6016. foreach ( $verifyList as $k => $v ) {
  6017. // init verifyStaff
  6018. if ($v [1] == 'ROLE') {
  6019. if (! empty ( $verifyStaff )) {
  6020. $endStaffArray = end ( $verifyStaff );
  6021. // if ($v[0]==$endStaffArray['nextStaff']){
  6022. // $roleId=$v[0];
  6023. // }
  6024. }
  6025. $roleVerify = json_decode ( $v [3], true );
  6026. $roleKey = $k;
  6027. $roleArray = array ();
  6028. $rolename = $role->getOne ( array (
  6029. 'where' => 'rid=' . $v [0],
  6030. 'asArray' => true
  6031. ) );
  6032. foreach ( $roleVerify as $o => $p ) {
  6033. $staffID = explode ( '_', $p );
  6034. $staffInfo = $staff->getOne ( array (
  6035. 'where' => 'sid=' . $staffID [0],
  6036. 'asArray' => true
  6037. ) );
  6038. // print_r($staffID);
  6039. $exp = array (
  6040. 0 => $staffInfo ['sid'],
  6041. 1 => $staffID [1],
  6042. 2 => $staffInfo ['avatar'],
  6043. 'date' => '',
  6044. 'date' => '',
  6045. 'opinion' => '',
  6046. 'status' => '',
  6047. 'rolename' => $rolename ['name']
  6048. );
  6049. array_push ( $roleArray, $exp );
  6050. }
  6051. $roleArrayCopy [$v [0]] = $roleArray;
  6052. // $verifyList[$k]['roleArray']=$roleArray;
  6053. }
  6054. $verifyList [$k] ['date'] = "";
  6055. $verifyList [$k] ['opinion'] = "";
  6056. $verifyList [$k] ['status'] = "";
  6057. if (empty ( $verifyStaff )) {
  6058. $verifyList [$k] ['date'] = "";
  6059. $verifyList [$k] ['opinion'] = "";
  6060. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6061. $verifyList [$k] ['status'] = 4;
  6062. $flag = false;
  6063. }
  6064. } else {
  6065. foreach ( $verifyStaff as $m => $u ) {
  6066. if ($v [0] == $m) {
  6067. $verifyList [$k] ['date'] = $u ['date'];
  6068. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6069. $verifyList [$k] ['status'] = $u ['status'];
  6070. $flag = false;
  6071. break;
  6072. }
  6073. }
  6074. $endStaffArray = end ( $verifyStaff );
  6075. if (isset ( $endStaffArray ['ROLE'] )) {
  6076. } else {
  6077. // $endKey=key($verifyStaff);
  6078. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6079. // $button=4;
  6080. // $verifyList[$k]['status']=4;
  6081. // }
  6082. }
  6083. }
  6084. }
  6085. $rolename ['name'] = '';
  6086. if (! empty ( $roleId )) {
  6087. Doo::loadModel ( 'role' );
  6088. $role = new role ();
  6089. $rolename = $role->getOne ( array (
  6090. 'where' => 'rid=' . $roleId,
  6091. 'asArray' => true
  6092. ) );
  6093. }
  6094. if (! empty ( $verifyStaff ))
  6095. $endStaffArray = end ( $verifyStaff );
  6096. $KOP = false;
  6097. foreach ( $roleArrayCopy as $P => $A ) {
  6098. foreach ( $A as $MKI => $AVL ) {
  6099. if (! empty ( $verifyStaff )) {
  6100. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6101. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6102. $button = 4;
  6103. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6104. }
  6105. foreach ( $verifyStaff as $m => $u ) {
  6106. $AVLFK = $AVL [0] . '_R';
  6107. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6108. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6109. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6110. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6111. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6112. break;
  6113. }
  6114. }
  6115. } else {
  6116. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6117. $button = 4;
  6118. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6119. }
  6120. }
  6121. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6122. $KOP = true;
  6123. }
  6124. }
  6125. foreach ( $roleArrayCopy as $k => $v ) {
  6126. foreach ( $verifyList as $m => $n ) {
  6127. if ($n [0] == $k) {
  6128. array_splice ( $verifyList, $m, 1, $v );
  6129. }
  6130. }
  6131. }
  6132. $receiptList [$key] ['verifyList'] = $verifyList;
  6133. $receiptList [$key] ['executeList'] = $executeList;
  6134. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6135. 'where' => 'sid=' . $value ['staff'],
  6136. 'asArray' => true
  6137. ) );
  6138. $receiptList [$key] ['button2'] = $button2;
  6139. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6140. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6141. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6142. $receiptList [$key] ['relust'] = $relust;
  6143. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6144. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6145. }
  6146. //执行人是否是最后一位
  6147. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6148. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6149. $executePrimary=count($executeCopy)-1;
  6150. $lastOne=true;
  6151. if($executePrimary!=count($executeStaff)){
  6152. $lastOne=false;
  6153. }
  6154. $data['lastOne']=$lastOne;
  6155. // 是否写入过流水
  6156. $accountType = 0;
  6157. if ($receiptList [0] ['Rtype'] == 0) {
  6158. $accountType = 3;
  6159. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6160. if (!empty($receiptList [0]['accountItem']) )
  6161. $accountType = 2;
  6162. else
  6163. $accountType = 1;
  6164. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6165. $accountType = 4;
  6166. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6167. $accountType = 12;
  6168. }
  6169. Doo::loadModel ( 'wasteBook' );
  6170. $wasteBook = new wasteBook ();
  6171. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6172. $data ['wbDetail'] = $wbDetail;
  6173. $wbDetailLoan=array();
  6174. if ($accountType==2){
  6175. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6176. }
  6177. $data ['wbDetailLoan'] = $wbDetailLoan;
  6178. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6179. //print_r($wbDetail);
  6180. $data ['receiptList'] = $receiptList;
  6181. $data ['memu'] = "receipt";
  6182. $data ['staff'] = $this->staff;
  6183. $data ['receiptMemu'] = 'implement';
  6184. $data ['verifyId'] = $this->verifyId;
  6185. $data ['executeId'] = $this->executeId;
  6186. if ($Rtype=="loan"){
  6187. $this->render ( "/receipt/receiptImplementLoan", $data );
  6188. }elseif($Rtype=="receipt"){
  6189. if($receiptList[0]['receiptClass']==2){
  6190. //TODO 费用执行行程单2.0
  6191. if(!empty($receiptList[0]['itinerary2'])){
  6192. $this->render ( "/receipt/receiptImplementTrave2", $data );
  6193. }else{
  6194. $this->render ( "/receipt/receiptImplementTrave", $data );
  6195. }
  6196. }else{
  6197. $this->render ( "/receipt/receiptImplement", $data );
  6198. }
  6199. }elseif($Rtype=="public"){
  6200. $this->render ( "/receipt/receiptImplementPublic", $data );
  6201. }else{
  6202. //$this->render ( "/admin/implement", $data );
  6203. }
  6204. }
  6205. function implementDo() {
  6206. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6207. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6208. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6209. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6210. // $ab = '';
  6211. // if ($accountBank == 'CGBDeposit')
  6212. // $ab = '纵横广发';
  6213. // elseif ($accountBank == 'ICBCDeposit')
  6214. // $ab = '纵横工行';
  6215. // elseif ($accountBank == 'HUADeposit')
  6216. // $ab = '华润银行';
  6217. // elseif ($accountBank == 'PersonalDeposit')
  6218. // $ab = '个人广发';
  6219. // if (empty ( $ab ))
  6220. // die ( 'illegal request--22' );
  6221. if (! empty ( $rid )) {
  6222. Doo::loadModel ( 'receipt' );
  6223. $receipt = new receipt ();
  6224. Doo::loadClass ( 'XDeode' );
  6225. $XDeode = new XDeode ( 5 );
  6226. $rid=$XDeode->decode($rid);
  6227. if (!is_numeric($rid)){
  6228. die;
  6229. }
  6230. // $rinfo = $receipt->getOne ( array (
  6231. // 'where' => 'rid=' . $rid,
  6232. // 'asArray' => true
  6233. // ) );
  6234. $rinfo = $receipt->getReceiptByRid ( $rid );
  6235. // $accountType = '';
  6236. // if ($rinfo ['Rtype'] == 1) {
  6237. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6238. // $accountType = 2;
  6239. // else
  6240. // $accountType = 1;
  6241. // } elseif ($rinfo ['Rtype'] == 2) {
  6242. // $accountType = 4;
  6243. // } elseif ($rinfo ['Rtype'] == 0)
  6244. // $accountType = 3;
  6245. // if (empty ( $accountType ))
  6246. // die ( 'illegal request' );
  6247. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6248. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6249. if (empty ( $executeStaff )) {
  6250. $executeStaff = array (
  6251. $this->staff [0] ['sid'] => array (
  6252. 'date' => date ( 'Y-m-d' ),
  6253. 'opinion' => $implementOpinions,
  6254. 'status' => 1
  6255. )
  6256. );
  6257. } else {
  6258. $executeStaff [$this->staff [0] ['sid']] = array (
  6259. 'date' => date ( 'Y-m-d' ),
  6260. 'opinion' => $implementOpinions,
  6261. 'status' => 1
  6262. );
  6263. }
  6264. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6265. $receipt->executeStaff = json_encode ( $executeStaff );
  6266. $receipt->status = 8;
  6267. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6268. $receipt->status = 9;
  6269. if ($rinfo ['status'] == 6) {
  6270. $receipt->loanDate = date ( "Y-m-d" );
  6271. }
  6272. $receipt->executeDate = date ( "Y-m-d" );
  6273. } else {
  6274. $receipt->executeStaff = json_encode ( $executeStaff );
  6275. }
  6276. //$receipt->amount = $amount;
  6277. $receipt->update ( array (
  6278. 'where' => 'rid=' . $rid
  6279. ) );
  6280. // 公司流水记录
  6281. // Doo::loadModel ( 'wasteBook' );
  6282. // $wasteBook = new wasteBook ();
  6283. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6284. // // 银行
  6285. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6286. // $item = array (
  6287. // 'dataID' => $rid,
  6288. // 'expensesType' => 2,
  6289. // 'accountType' => $accountType,
  6290. // 'accountPriceShow' => $amount,
  6291. // 'accountPrice' => - $amount,
  6292. // 'accountBank' => $accountBank,
  6293. // 'category' => $rinfo ['category'] [0] ['title'],
  6294. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6295. // 'name' => $rinfo ['staffDetail'] ['username'],
  6296. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6297. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6298. // );
  6299. // $wasteBook->setAccountBookStatistics ( $item );
  6300. // }
  6301. }
  6302. //$ridKey = $XDeode->encode ( $rid );
  6303. return "/hisImplement";
  6304. // return "/implement/" . $ridKey . ".html";
  6305. }
  6306. function receiptburEdi() {
  6307. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6308. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6309. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6310. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6311. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6312. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6313. if (empty ( $status ))
  6314. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6315. $vidList = array ();
  6316. $button = 0;
  6317. Doo::loadModel ( 'verify' );
  6318. Doo::loadModel ( 'receipt' );
  6319. Doo::loadModel ( 'staff' );
  6320. $staff = new staff ();
  6321. $receipt = new receipt ();
  6322. $verify = new verify ();
  6323. Doo::loadModel ( 'L_category' );
  6324. $Lcategory = new L_category ();
  6325. Doo::loadModel ( 'enclosur' );
  6326. $enclosur = new enclosur ();
  6327. Doo::loadModel ( 'loanReceipt' );
  6328. $loanReceipt = new loanReceipt ();
  6329. // user verify ID
  6330. $verifyDetail = $verify->find ( array (
  6331. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6332. 'asArray' => true
  6333. ) );
  6334. foreach ( $verifyDetail as $key => $value ) {
  6335. array_push ( $vidList, $value ['vid'] );
  6336. }
  6337. $vid = implode ( ",", $vidList );
  6338. if (empty ( $verifyDetail ))
  6339. $vid = 0;
  6340. $categoryList = $Lcategory->find ( array (
  6341. 'asArray' => true
  6342. ) );
  6343. $staffList = $staff->find ( array (
  6344. 'where' => 'cid=' . $cid,
  6345. 'asArray' => true
  6346. ) );
  6347. $ap = "";
  6348. if ($status == 4) {
  6349. $ap = 4;
  6350. $status = 2;
  6351. }
  6352. // get Receipt By verifyID status 2
  6353. $receiptList = $receipt->find ( array (
  6354. 'where' => 'rid =' . $rid . ' and status=2',
  6355. 'desc' => 'rid',
  6356. 'asArray' => true
  6357. ) );
  6358. if (empty ( $receiptList )) {
  6359. die ( 'illegal request' );
  6360. }
  6361. $loanList = $loanReceipt->find ( array (
  6362. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6363. 'desc' => 'rid',
  6364. 'asArray' => true
  6365. ) );
  6366. $data ['explanation'] = '';
  6367. if (! empty ( $loanList ))
  6368. $data ['explanation'] = $loanList [0] ['explanation'];
  6369. $Locate = 0;
  6370. $roleId = 0;
  6371. $button = 0;
  6372. foreach ( $loanList as $key => $value ) {
  6373. $loanList [$key] ['Locate'] = $Locate;
  6374. $Locate ++;
  6375. $loanList [$key] ['reviseDetail'] = array ();
  6376. if (! empty ( $value ['reviseDetail'] ))
  6377. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6378. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6379. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6380. $categoryDetil = $Lcategory->getOne ( array (
  6381. 'where' => 'cid=' . $value ['cid'],
  6382. 'asArray' => true
  6383. ) );
  6384. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6385. // 检测编辑状态
  6386. $verifyList = $verify->getOne ( array (
  6387. 'where' => 'vid=' . $value ['verify'],
  6388. 'asArray' => true
  6389. ) );
  6390. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6391. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6392. Doo::loadModel ( 'role' );
  6393. $role = new role ();
  6394. $flag = true;
  6395. $roleKey = 0;
  6396. $endStaffArray = array ();
  6397. $roleArrayCopy = array ();
  6398. foreach ( $verifyList as $k => $v ) {
  6399. // init verifyStaff
  6400. if ($v [1] == 'ROLE') {
  6401. if (! empty ( $verifyStaff )) {
  6402. $endStaffArray = end ( $verifyStaff );
  6403. }
  6404. $roleVerify = json_decode ( $v [3], true );
  6405. $roleKey = $k;
  6406. $roleArray = array ();
  6407. $rolename = $role->getOne ( array (
  6408. 'where' => 'rid=' . $v [0],
  6409. 'asArray' => true
  6410. ) );
  6411. foreach ( $roleVerify as $o => $p ) {
  6412. $staffID = explode ( '_', $p );
  6413. $staffInfo = $staff->getOne ( array (
  6414. 'where' => 'sid=' . $staffID [0],
  6415. 'asArray' => true
  6416. ) );
  6417. // print_r($staffID);
  6418. $exp = array (
  6419. 0 => $staffInfo ['sid'],
  6420. 1 => $staffID [1],
  6421. 2 => $staffInfo ['avatar'],
  6422. 'date' => '',
  6423. 'date' => '',
  6424. 'opinion' => '',
  6425. 'status' => '',
  6426. 'rolename' => $rolename ['name']
  6427. );
  6428. array_push ( $roleArray, $exp );
  6429. }
  6430. $roleArrayCopy [$v [0]] = $roleArray;
  6431. // $verifyList[$k]['roleArray']=$roleArray;
  6432. }
  6433. $verifyList [$k] ['date'] = "";
  6434. $verifyList [$k] ['opinion'] = "";
  6435. $verifyList [$k] ['status'] = "";
  6436. if (empty ( $verifyStaff )) {
  6437. $verifyList [$k] ['date'] = "";
  6438. $verifyList [$k] ['opinion'] = "";
  6439. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6440. $verifyList [$k] ['status'] = 4;
  6441. $flag = false;
  6442. }
  6443. } else {
  6444. foreach ( $verifyStaff as $m => $u ) {
  6445. if ($v [0] == $m) {
  6446. $verifyList [$k] ['date'] = $u ['date'];
  6447. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6448. $verifyList [$k] ['status'] = $u ['status'];
  6449. $flag = false;
  6450. break;
  6451. }
  6452. }
  6453. $endStaffArray = end ( $verifyStaff );
  6454. if (isset ( $endStaffArray ['ROLE'] )) {
  6455. } else {
  6456. }
  6457. }
  6458. }
  6459. $rolename ['name'] = '';
  6460. if (! empty ( $roleId )) {
  6461. Doo::loadModel ( 'role' );
  6462. $role = new role ();
  6463. $rolename = $role->getOne ( array (
  6464. 'where' => 'rid=' . $roleId,
  6465. 'asArray' => true
  6466. ) );
  6467. }
  6468. if (! empty ( $verifyStaff ))
  6469. $endStaffArray = end ( $verifyStaff );
  6470. $KOP = false;
  6471. foreach ( $roleArrayCopy as $P => $A ) {
  6472. foreach ( $A as $MKI => $AVL ) {
  6473. if (! empty ( $verifyStaff )) {
  6474. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6475. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6476. $button = 4;
  6477. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6478. }
  6479. foreach ( $verifyStaff as $m => $u ) {
  6480. $AVLFK = $AVL [0] . '_R';
  6481. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6482. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6483. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6484. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6485. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6486. break;
  6487. }
  6488. }
  6489. } else {
  6490. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6491. $button = 4;
  6492. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6493. }
  6494. }
  6495. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6496. $KOP = true;
  6497. }
  6498. }
  6499. foreach ( $roleArrayCopy as $k => $v ) {
  6500. foreach ( $verifyList as $m => $n ) {
  6501. if ($n [0] == $k) {
  6502. array_splice ( $verifyList, $m, 1, $v );
  6503. }
  6504. }
  6505. }
  6506. $loanList [$key] ['verifyList'] = $verifyList;
  6507. }
  6508. $htmlLoan = '';
  6509. $data ['loanReceiptDate'] = '';
  6510. if (isset ( $loanList [0] )) {
  6511. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6512. if ($value ['status'] == 1)
  6513. $htmlLoan .= '<li class="done" >';
  6514. elseif ($value ['status'] == 3)
  6515. $htmlLoan .= '<li class="undone" >';
  6516. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6517. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6518. if (isset ( $value ['rolename'] ))
  6519. $htmlLoan .= $value ['rolename'];
  6520. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6521. }
  6522. $data ['loanDate'] = $loanList [0] ['date'];
  6523. } else {
  6524. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6525. }
  6526. $data ['htmlLoan'] = $htmlLoan;
  6527. // $data ['LoanReceipt']=$loanList[0];
  6528. // print_r($loanList);
  6529. $Locate = 0;
  6530. $roleId = 0;
  6531. $button = 0;
  6532. if ($ap == 4)
  6533. $status = 4;
  6534. Doo::loadClass ( 'XDeode' );
  6535. $XDeode = new XDeode ( 5 );
  6536. foreach ( $receiptList as $key => $value ) {
  6537. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6538. $receiptList [$key] ['Locate'] = $Locate;
  6539. $Locate ++;
  6540. $receiptList [$key] ['reviseDetail'] = array ();
  6541. // 调整金额 代码调整
  6542. if (! empty ( $value ['reviseDetail'] )) {
  6543. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6544. foreach ( $reviseDetail as $ry => $re ) {
  6545. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6546. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6547. }
  6548. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6549. // print_r($reviseDetail);
  6550. }
  6551. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6552. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6553. $categoryDetil = $Lcategory->getOne ( array (
  6554. 'where' => 'cid=' . $value ['cid'],
  6555. 'asArray' => true
  6556. ) );
  6557. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6558. // 检测编辑状态
  6559. $verifyList = $verify->getOne ( array (
  6560. 'where' => 'vid=' . $value ['verify'],
  6561. 'asArray' => true
  6562. ) );
  6563. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6564. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6565. Doo::loadModel ( 'role' );
  6566. $role = new role ();
  6567. // print_r($verifyList);
  6568. $flag = true;
  6569. $roleKey = 0;
  6570. $endStaffArray = array ();
  6571. $roleArrayCopy = array ();
  6572. foreach ( $verifyList as $k => $v ) {
  6573. // init verifyStaff
  6574. if ($v [1] == 'ROLE') {
  6575. if (! empty ( $verifyStaff )) {
  6576. $endStaffArray = end ( $verifyStaff );
  6577. if ($v [0] == $endStaffArray ['nextStaff']) {
  6578. $roleId = $v [0];
  6579. }
  6580. }
  6581. $roleVerify = json_decode ( $v [3], true );
  6582. $roleKey = $k;
  6583. $roleArray = array ();
  6584. $rolename = $role->getOne ( array (
  6585. 'where' => 'rid=' . $v [0],
  6586. 'asArray' => true
  6587. ) );
  6588. foreach ( $roleVerify as $o => $p ) {
  6589. $staffID = explode ( '_', $p );
  6590. $staffInfo = $staff->getOne ( array (
  6591. 'where' => 'sid=' . $staffID [0],
  6592. 'asArray' => true
  6593. ) );
  6594. // print_r($staffID);
  6595. $exp = array (
  6596. 0 => $staffInfo ['sid'],
  6597. 1 => $staffID [1],
  6598. 2 => $staffInfo ['avatar'],
  6599. 'date' => '',
  6600. 'date' => '',
  6601. 'opinion' => '',
  6602. 'status' => '',
  6603. 'rolename' => $rolename ['name']
  6604. );
  6605. array_push ( $roleArray, $exp );
  6606. }
  6607. $roleArrayCopy [$v [0]] = $roleArray;
  6608. // $verifyList[$k]['roleArray']=$roleArray;
  6609. }
  6610. // print_r($roleArray);
  6611. $verifyList [$k] ['date'] = "";
  6612. $verifyList [$k] ['opinion'] = "";
  6613. $verifyList [$k] ['status'] = "";
  6614. if (empty ( $verifyStaff )) {
  6615. $verifyList [$k] ['date'] = "";
  6616. $verifyList [$k] ['opinion'] = "";
  6617. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6618. $verifyList [$k] ['status'] = 4;
  6619. $button = 4;
  6620. $flag = false;
  6621. }
  6622. } else {
  6623. foreach ( $verifyStaff as $m => $u ) {
  6624. if ($v [0] == $m) {
  6625. $verifyList [$k] ['date'] = $u ['date'];
  6626. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6627. $verifyList [$k] ['status'] = $u ['status'];
  6628. $flag = false;
  6629. break;
  6630. }
  6631. }
  6632. $endStaffArray = end ( $verifyStaff );
  6633. if (isset ( $endStaffArray ['ROLE'] )) {
  6634. } else {
  6635. $endKey = key ( $verifyStaff );
  6636. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6637. $button = 4;
  6638. $verifyList [$k] ['status'] = 4;
  6639. }
  6640. }
  6641. }
  6642. }
  6643. $rolename ['name'] = '';
  6644. if (! empty ( $roleId )) {
  6645. Doo::loadModel ( 'role' );
  6646. $role = new role ();
  6647. $rolename = $role->getOne ( array (
  6648. 'where' => 'rid=' . $roleId,
  6649. 'asArray' => true
  6650. ) );
  6651. }
  6652. if (! empty ( $verifyStaff ))
  6653. $endStaffArray = end ( $verifyStaff );
  6654. $KOP = false;
  6655. foreach ( $roleArrayCopy as $P => $A ) {
  6656. foreach ( $A as $MKI => $AVL ) {
  6657. if (! empty ( $verifyStaff )) {
  6658. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6659. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6660. $button = 4;
  6661. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6662. }
  6663. foreach ( $verifyStaff as $m => $u ) {
  6664. $AVLFK = $AVL [0] . '_R';
  6665. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6666. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6667. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6668. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6669. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6670. break;
  6671. }
  6672. }
  6673. } else {
  6674. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6675. $button = 4;
  6676. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6677. }
  6678. }
  6679. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6680. $KOP = true;
  6681. }
  6682. }
  6683. foreach ( $roleArrayCopy as $k => $v ) {
  6684. foreach ( $verifyList as $m => $n ) {
  6685. if ($n [0] == $k) {
  6686. array_splice ( $verifyList, $m, 1, $v );
  6687. }
  6688. }
  6689. }
  6690. // print_r($verifyList);
  6691. $receiptList [$key] ['verifyList'] = $verifyList;
  6692. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6693. 'where' => 'sid=' . $value ['staff'],
  6694. 'asArray' => true
  6695. ) );
  6696. $receiptList [$key] ['button'] = $button;
  6697. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6698. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6699. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6700. $receiptList [$key] ['relust'] = $relust;
  6701. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6702. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6703. }
  6704. //print_r($receiptList);die;
  6705. // $data['verifyDetail']=$verifyDetail;
  6706. $mothHtml = "";
  6707. for($i = 1; $i <= 12; $i ++) {
  6708. if ($month == $i)
  6709. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6710. else
  6711. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6712. }
  6713. // 获取审批日志
  6714. Doo::loadModel ( 'receiptLog' );
  6715. $receiptLog = new receiptLog ();
  6716. $rlList = array ();
  6717. $rlInfo = $receiptLog->getOne ( array (
  6718. 'where' => 'rid=' . $rid . ' and status=4',
  6719. 'asArray' => true
  6720. ) );
  6721. $tijdate = $receiptLog->getOne ( array (
  6722. 'where' => 'rid=' . $rid . ' and status=2',
  6723. 'asc' => 'rlid',
  6724. 'asArray' => true
  6725. ) );
  6726. if (! empty ( $rlInfo )) {
  6727. $rlList = $receiptLog->find ( array (
  6728. 'where' => 'rid=' . $rid,
  6729. 'asc' => 'rlid',
  6730. 'asArray' => true
  6731. ) );
  6732. }
  6733. // echo $rid;
  6734. // print_r($receiptList);
  6735. $receiptList [0] ['rlList'] = $rlList;
  6736. // print_r($receiptList);
  6737. $enclosurList = $enclosur->find ( array (
  6738. 'where' => 'rid=' . $rid,
  6739. 'asArray' => true
  6740. ) );
  6741. $enclosurHtml = '';
  6742. foreach ( $enclosurList as $value ) {
  6743. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6744. }
  6745. $data ['enclosurHtml'] = $enclosurHtml;
  6746. $data ['rolename'] = $rolename ['name'];
  6747. $data ['mothHtml'] = $mothHtml;
  6748. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  6749. $data ['rid'] = $rid;
  6750. $data ['tijdate'] = $tijdate ['date'];
  6751. $data ['receiptList'] = $receiptList;
  6752. $data ['receiptApprovalCount'] = count ( $receiptList );
  6753. $data ['status'] = $status;
  6754. $data ['year'] = $year;
  6755. $data ['categoryList'] = $categoryList;
  6756. $data ['staffList'] = $staffList;
  6757. $data ['cid'] = $cid;
  6758. $data ['sid'] = $sid;
  6759. $data ['ap'] = $ap;
  6760. $data ['memu'] = "receipt";
  6761. $data ['staff'] = $this->staff;
  6762. $data ['receiptMemu'] = 'approvalExpenses';
  6763. $data ['verifyId'] = $this->verifyId;
  6764. $data ['executeId'] = $this->executeId;
  6765. if($receiptList[0]['receiptClass']==1){
  6766. $this->render ( "/receipt/feeAgencyApproval", $data );
  6767. }elseif($receiptList[0]['receiptClass']==2){
  6768. //TODO 行程单2.0
  6769. if(!empty($receiptList[0]['itinerary2'])){
  6770. $this->render ( "/receipt/feeTraveApproval2", $data );
  6771. }else{
  6772. $this->render ( "/receipt/feeTraveApproval", $data );
  6773. }
  6774. }elseif($receiptList[0]['receiptClass']==3){
  6775. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6776. }else{
  6777. $this->render ( "/admin/receiptburEdi", $data );
  6778. }
  6779. }
  6780. function hisImplement() {
  6781. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6782. if (empty ( $item ))
  6783. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6784. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6785. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6786. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6787. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6788. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6789. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6790. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6791. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6792. Doo::loadClass ( 'XDeode' );
  6793. $XDeode = new XDeode ( 5 );
  6794. Doo::loadModel ( 'receipt' );
  6795. $receipt = new receipt ();
  6796. Doo::loadModel ( 'L_category' );
  6797. $Lcategory = new L_category ();
  6798. Doo::loadModel ( 'verify' );
  6799. Doo::loadModel ( 'statistics' );
  6800. $statistics = new statistics ();
  6801. $verify = new verify ();
  6802. Doo::loadModel ( 'staff' );
  6803. $staff = new staff ();
  6804. Doo::loadClass ( 'XDeode' );
  6805. $XDeode = new XDeode ( 5 );
  6806. $XDeode7 = new XDeode ( 7 );
  6807. $cid = $XDeode->decode ( $cidKey );
  6808. $condition = "";
  6809. if ($item == "expenses")
  6810. $condition = " and Rtype=1 ";
  6811. elseif ($item == "receipts")
  6812. $condition = " and Rtype=0 ";
  6813. elseif ($item == "remits")
  6814. $condition = " and Rtype=2 ";
  6815. elseif($item == "train")
  6816. $condition = " and Rtype=3 ";
  6817. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6818. $sopString = $cidString = "";
  6819. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6820. if (empty ( $rdate ))
  6821. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6822. else
  6823. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6824. if ($status == 'pendImplement') {
  6825. $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 ) ) ';
  6826. } elseif ($status == 'alerpts') {
  6827. $statusCon = '(status=8 or status=9 )';
  6828. if (empty ( $rdate )){
  6829. $dateCondition = " and Year(date) =" . $year;
  6830. }else{
  6831. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6832. }
  6833. }
  6834. if ($sop != 'SOP')
  6835. $sopString = " and staff=" . $sop;
  6836. if ($cidKey != 'ALL')
  6837. $cidString = " and cid=" . $cid;
  6838. //汇款信息需要提取出来
  6839. if(!empty($receiptOrder)){
  6840. $receiptList = $receipt->find ( array (
  6841. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6842. 'desc' => 'rid',
  6843. 'asArray' => true
  6844. ) );
  6845. // 员工筛选
  6846. $receiptList2 = $receipt->find ( array (
  6847. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6848. 'desc' => 'rid',
  6849. 'asArray' => true
  6850. ) );
  6851. }else{
  6852. $receiptList = $receipt->find ( array (
  6853. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6854. 'desc' => 'rid',
  6855. 'asArray' => true
  6856. ) );
  6857. // 员工筛选
  6858. $receiptList2 = $receipt->find ( array (
  6859. 'where' => $statusCon . $condition . $dateCondition,
  6860. 'desc' => 'rid',
  6861. 'asArray' => true
  6862. ) );
  6863. }
  6864. $sopStaff = array ();
  6865. foreach ( $receiptList2 as $key => $value ) {
  6866. $staffDetail = $staff->getOne ( array (
  6867. 'select' => 'username',
  6868. 'where' => 'sid=' . $value ['staff'],
  6869. 'asArray' => true
  6870. ) );
  6871. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6872. }
  6873. // 办事处筛选
  6874. $categoryScreen = array ();
  6875. $categorList = $Lcategory->getCategory ();
  6876. foreach ( $receiptList2 as $key => $value ) {
  6877. foreach ( $categorList as $k => $v ) {
  6878. if ($value ['cid'] == $v ['cid']) {
  6879. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6880. break;
  6881. }
  6882. }
  6883. }
  6884. $categoryScreenHtml = "";
  6885. foreach ( $categoryScreen as $key => $value ) {
  6886. if ($cidKey == $key)
  6887. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6888. else
  6889. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6890. }
  6891. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6892. $data ['cidKey'] = $cidKey;
  6893. $Locate = 0;
  6894. $roleId = 0;
  6895. $button = 0;
  6896. $staffBatchNumber = 100001;
  6897. $remittanceList = array ();
  6898. foreach ( $receiptList as $key => $value ) {
  6899. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6900. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6901. $receiptList [$key] ['Texe'] = 'false';
  6902. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6903. $receiptList [$key] ['Texe'] = 'true';
  6904. }
  6905. $receiptList [$key] ['TRexe'] = 'true';
  6906. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6907. $receiptList [$key] ['TRexe'] = 'false';
  6908. }
  6909. $receiptList [$key] ['Locate'] = $Locate;
  6910. $Locate ++;
  6911. $receiptList [$key] ['reviseDetail'] = array ();
  6912. if (! empty ( $value ['reviseDetail'] ))
  6913. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6914. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6915. $categoryDetil = $Lcategory->getOne ( array (
  6916. 'where' => 'cid=' . $value ['cid'],
  6917. 'asArray' => true
  6918. ) );
  6919. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6920. // 检测编辑状态
  6921. $verifyList = $verify->getOne ( array (
  6922. 'where' => 'vid=' . $value ['verify'],
  6923. 'asArray' => true
  6924. ) );
  6925. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6926. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6927. Doo::loadModel ( 'role' );
  6928. $role = new role ();
  6929. $flag = true;
  6930. $roleKey = 0;
  6931. $endStaffArray = array ();
  6932. $roleArrayCopy = array ();
  6933. foreach ( $verifyList as $k => $v ) {
  6934. // init verifyStaff
  6935. if ($v [1] == 'ROLE') {
  6936. if (! empty ( $verifyStaff )) {
  6937. $endStaffArray = end ( $verifyStaff );
  6938. }
  6939. $roleVerify = json_decode ( $v [3], true );
  6940. $roleKey = $k;
  6941. $roleArray = array ();
  6942. $rolename = $role->getOne ( array (
  6943. 'where' => 'rid=' . $v [0],
  6944. 'asArray' => true
  6945. ) );
  6946. foreach ( $roleVerify as $o => $p ) {
  6947. $staffID = explode ( '_', $p );
  6948. $staffInfo = $staff->getOne ( array (
  6949. 'where' => 'sid=' . $staffID [0],
  6950. 'asArray' => true
  6951. ) );
  6952. $exp = array (
  6953. 0 => $staffInfo ['sid'],
  6954. 1 => $staffID [1],
  6955. 2 => $staffInfo ['avatar'],
  6956. 'date' => '',
  6957. 'date' => '',
  6958. 'opinion' => '',
  6959. 'status' => '',
  6960. 'rolename' => $rolename ['name']
  6961. );
  6962. array_push ( $roleArray, $exp );
  6963. }
  6964. $roleArrayCopy [$v [0]] = $roleArray;
  6965. }
  6966. $verifyList [$k] ['date'] = "";
  6967. $verifyList [$k] ['opinion'] = "";
  6968. $verifyList [$k] ['status'] = "";
  6969. if (empty ( $verifyStaff )) {
  6970. $verifyList [$k] ['date'] = "";
  6971. $verifyList [$k] ['opinion'] = "";
  6972. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6973. $verifyList [$k] ['status'] = 4;
  6974. $flag = false;
  6975. }
  6976. } else {
  6977. foreach ( $verifyStaff as $m => $u ) {
  6978. if ($v [0] == $m) {
  6979. $verifyList [$k] ['date'] = $u ['date'];
  6980. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6981. $verifyList [$k] ['status'] = $u ['status'];
  6982. $flag = false;
  6983. break;
  6984. }
  6985. }
  6986. $endStaffArray = end ( $verifyStaff );
  6987. }
  6988. }
  6989. $rolename ['name'] = '';
  6990. if (! empty ( $roleId )) {
  6991. Doo::loadModel ( 'role' );
  6992. $role = new role ();
  6993. $rolename = $role->getOne ( array (
  6994. 'where' => 'rid=' . $roleId,
  6995. 'asArray' => true
  6996. ) );
  6997. }
  6998. if (! empty ( $verifyStaff ))
  6999. $endStaffArray = end ( $verifyStaff );
  7000. $KOP = false;
  7001. foreach ( $roleArrayCopy as $P => $A ) {
  7002. foreach ( $A as $MKI => $AVL ) {
  7003. if (! empty ( $verifyStaff )) {
  7004. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7005. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7006. $button = 4;
  7007. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7008. }
  7009. foreach ( $verifyStaff as $m => $u ) {
  7010. $AVLFK = $AVL [0] . '_R';
  7011. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7012. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7013. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7014. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7015. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7016. break;
  7017. }
  7018. }
  7019. } else {
  7020. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7021. $button = 4;
  7022. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7023. }
  7024. }
  7025. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7026. $KOP = true;
  7027. }
  7028. }
  7029. foreach ( $roleArrayCopy as $k => $v ) {
  7030. foreach ( $verifyList as $m => $n ) {
  7031. if ($n [0] == $k) {
  7032. array_splice ( $verifyList, $m, 1, $v );
  7033. }
  7034. }
  7035. }
  7036. $receiptList [$key] ['verifyList'] = $verifyList;
  7037. $staffDetail = $staff->getOne ( array (
  7038. 'where' => 'sid=' . $value ['staff'],
  7039. 'asArray' => true
  7040. ) );
  7041. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7042. $receiptList [$key] ['button'] = $button;
  7043. if ($value['Rtype']==1){
  7044. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7045. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  7046. }elseif($value['Rtype']==3){
  7047. // 收入合计
  7048. Doo::loadModel ( 'invoiceTraining' );
  7049. $invoiceTraining = new invoiceTraining ();
  7050. $invoiceTrainingDetail = array (
  7051. 'invoiceArriveAmount' => '0.00',
  7052. 'RIAmount' => '0.00',
  7053. 'invoiceTotalAmount' => '0.00',
  7054. 'invoiceCompanyAmount' => '0.00',
  7055. 'invoiceArriveAmountM'=>'0.00',
  7056. 'invoiceCompanyAmountM'=>'0.00'
  7057. );
  7058. if ($value ['invoiceTrainId'] != 0) {
  7059. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7060. }
  7061. $invoiceArriveAmount = $RIAmount = 0;
  7062. if (! empty ( $invoiceTrainingDetail )) {
  7063. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7064. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7065. }
  7066. // 备用金
  7067. $sum = 0;
  7068. if (! empty ( $value ['trainLoanRid'] )) {
  7069. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7070. foreach ($receiptLoanList as $kll=>$vll){
  7071. $sum+=$vll['sum'];
  7072. }
  7073. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7074. // $sum = $receiptLoanDetailBak ['sum'];
  7075. }
  7076. // 支出项金额详情
  7077. // 项目金额合计
  7078. Doo::loadModel ( 'RItem' );
  7079. $RItem = new RItem ();
  7080. Doo::loadModel ( 'accountItem' );
  7081. $accountItem = new accountItem ();
  7082. // 讲师获得
  7083. Doo::loadModel ( 'RILecturer' );
  7084. $RILecturer = new RILecturer ();
  7085. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7086. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7087. // 支出项金额详情
  7088. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7089. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7090. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7091. $receiptList [$key] ['payment'] =$payment;
  7092. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7093. }
  7094. // 设置导出汇款execl
  7095. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7096. $remittanceDetail = array (
  7097. $staffBatchNumber,
  7098. $value ['remittanceName'],
  7099. $value ['bankNumber'],
  7100. $value ['bankName'],
  7101. $value ['remittanceBankType'],
  7102. $value ['coupletNumber'],
  7103. $value ['sum']
  7104. );
  7105. array_push ( $remittanceList, $remittanceDetail );
  7106. $staffBatchNumber ++;
  7107. }
  7108. }
  7109. $data ['remittanceList'] = json_encode ( $remittanceList );
  7110. // print_r($receiptList);
  7111. $mothHtml = "";
  7112. for($i = 1; $i <= 12; $i ++) {
  7113. if ($moth == $i)
  7114. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7115. else
  7116. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7117. }
  7118. $dayHtml = "";
  7119. if ($day != "DAY" || $moth != "MONTH") {
  7120. for($i = 1; $i <= 31; $i ++) {
  7121. if ($day == $i)
  7122. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7123. else
  7124. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7125. }
  7126. }
  7127. $sopHtml = "";
  7128. foreach ( $sopStaff as $key => $value ) {
  7129. if ($sop == $key)
  7130. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7131. else
  7132. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7133. }
  7134. $data ['status'] = $status;
  7135. $data ['rdate'] = $rdate;
  7136. $data ['sopHtml'] = $sopHtml;
  7137. $data ['dayHtml'] = $dayHtml;
  7138. $data ['mothHtml'] = $mothHtml;
  7139. $data ['receiptList'] = $receiptList;
  7140. $data ['memu'] = "receipt";
  7141. $data ['staff'] = $this->staff;
  7142. $data ['receiptMemu'] = 'implement';
  7143. $data ['verifyId'] = $this->verifyId;
  7144. $data ['executeId'] = $this->executeId;
  7145. $data ['item'] = $item;
  7146. $data ['year'] = $year;
  7147. $data ['moth'] = $moth;
  7148. $data['receiptOrder']=$receiptOrder;
  7149. $data ['day'] = $day;
  7150. $data ['sop'] = $sop;
  7151. $this->render ( "/admin/hisImplement", $data );
  7152. }
  7153. /**
  7154. * 导出汇款信息的exelc
  7155. */
  7156. function exportRemittance() {
  7157. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7158. if (empty ( $remittanceInfo ))
  7159. die ( 'illegal request' );
  7160. $title = array (
  7161. '员工编号',
  7162. '姓名',
  7163. '员工账号',
  7164. '员工账户开户行',
  7165. '转账类型',
  7166. '联行号',
  7167. '金额'
  7168. );
  7169. $data = json_decode ( $remittanceInfo, true );
  7170. if (empty ( $data ))
  7171. die ( 'illegal request' );
  7172. Doo::loadClass ( 'receipt.func' );
  7173. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7174. header ( 'Content-Type:text/html;charset=utf-8' );
  7175. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7176. }
  7177. function ajaxExamine() {
  7178. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7179. Doo::loadModel ( 'receipt' );
  7180. $receipt = new receipt ();
  7181. if (! empty ( $rid )) {
  7182. $rLRes = $receipt->find ( array (
  7183. '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,
  7184. 'asArray' => true
  7185. ) );
  7186. if(!empty($rLRes)){
  7187. Doo::loadClass ( 'XDeode' );
  7188. $XDeode = new XDeode ( 7 );
  7189. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7190. echo json_encode ( array (
  7191. 'status' => 1,
  7192. 'receipt' => $rLRes [0]
  7193. ) );
  7194. die ();
  7195. }else{
  7196. echo json_encode ( array (
  7197. 'status' => 1,
  7198. 'receipt' => array ()
  7199. ) );
  7200. die ();
  7201. }
  7202. }
  7203. echo json_encode ( array (
  7204. 'status' => 0,
  7205. 'receipt' => array ()
  7206. ) );
  7207. die ();
  7208. }
  7209. /*
  7210. * 废弃
  7211. */
  7212. function myReceipt() {
  7213. // all approval past withdraw
  7214. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7215. if (empty ( $item ))
  7216. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7217. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7218. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7219. Doo::loadModel ( 'receipt' );
  7220. $receipt = new receipt ();
  7221. // pre-loaded
  7222. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7223. // have cache
  7224. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7225. if (! empty ( $moth )) // yearPage
  7226. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7227. $this->showCache ( $path );
  7228. }
  7229. Doo::loadModel ( 'L_category' );
  7230. $Lcategory = new L_category ();
  7231. Doo::loadModel ( 'verify' );
  7232. Doo::loadModel ( 'statistics' );
  7233. $statistics = new statistics ();
  7234. $verify = new verify ();
  7235. Doo::loadModel ( 'staff' );
  7236. $staff = new staff ();
  7237. $condition = " and status!=0 ";
  7238. if ($item == "approval")
  7239. $condition = " and status=2 ";
  7240. elseif ($item == "withdraw")
  7241. $condition = " and status=3 ";
  7242. elseif ($item == "past")
  7243. $condition = " and status=1 ";
  7244. elseif ($item == "whdw")
  7245. $condition = " and status=4 ";
  7246. $dateCondition = " and Year(date) =" . $year;
  7247. if (! empty ( $moth )) {
  7248. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7249. $stList = $statistics->getOne ( array (
  7250. 'select' => 'rePrice ,agPrice',
  7251. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7252. 'asArray' => true
  7253. ) );
  7254. } else
  7255. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7256. if (empty ( $stList ))
  7257. $stList = array (
  7258. 'rePrice' => 0,
  7259. 'agPrice' => 0
  7260. );
  7261. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7262. $data ['stList'] = array (
  7263. 'rePrice' => $stList ['rePrice'],
  7264. 'agPrice' => $stList ['agPrice'],
  7265. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7266. );
  7267. $receiptList = $receipt->find ( array (
  7268. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7269. 'desc' => 'rid',
  7270. 'asArray' => true
  7271. ) );
  7272. $Locate = 0;
  7273. $roleId = 0;
  7274. $button = 0;
  7275. foreach ( $receiptList as $key => $value ) {
  7276. $receiptList [$key] ['Locate'] = $Locate;
  7277. $Locate ++;
  7278. $receiptList [$key] ['reviseDetail'] = array ();
  7279. if (! empty ( $value ['reviseDetail'] ))
  7280. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7281. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7282. $categoryDetil = $Lcategory->getOne ( array (
  7283. 'where' => 'cid=' . $value ['cid'],
  7284. 'asArray' => true
  7285. ) );
  7286. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7287. // 检测编辑状态
  7288. $verifyList = $verify->getOne ( array (
  7289. 'where' => 'vid=' . $value ['verify'],
  7290. 'asArray' => true
  7291. ) );
  7292. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7293. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7294. Doo::loadModel ( 'role' );
  7295. $role = new role ();
  7296. $flag = true;
  7297. $roleKey = 0;
  7298. $endStaffArray = array ();
  7299. $roleArrayCopy = array ();
  7300. foreach ( $verifyList as $k => $v ) {
  7301. // init verifyStaff
  7302. if ($v [1] == 'ROLE') {
  7303. if (! empty ( $verifyStaff )) {
  7304. $endStaffArray = end ( $verifyStaff );
  7305. // if ($v[0]==$endStaffArray['nextStaff']){
  7306. // $roleId=$v[0];
  7307. // }
  7308. }
  7309. $roleVerify = json_decode ( $v [3], true );
  7310. $roleKey = $k;
  7311. $roleArray = array ();
  7312. $rolename = $role->getOne ( array (
  7313. 'where' => 'rid=' . $v [0],
  7314. 'asArray' => true
  7315. ) );
  7316. foreach ( $roleVerify as $o => $p ) {
  7317. $staffID = explode ( '_', $p );
  7318. $staffInfo = $staff->getOne ( array (
  7319. 'where' => 'sid=' . $staffID [0],
  7320. 'asArray' => true
  7321. ) );
  7322. // print_r($staffID);
  7323. $exp = array (
  7324. 0 => $staffInfo ['sid'],
  7325. 1 => $staffID [1],
  7326. 2 => $staffInfo ['avatar'],
  7327. 'date' => '',
  7328. 'date' => '',
  7329. 'opinion' => '',
  7330. 'status' => '',
  7331. 'rolename' => $rolename ['name']
  7332. );
  7333. array_push ( $roleArray, $exp );
  7334. }
  7335. $roleArrayCopy [$v [0]] = $roleArray;
  7336. // $verifyList[$k]['roleArray']=$roleArray;
  7337. }
  7338. $verifyList [$k] ['date'] = "";
  7339. $verifyList [$k] ['opinion'] = "";
  7340. $verifyList [$k] ['status'] = "";
  7341. if (empty ( $verifyStaff )) {
  7342. $verifyList [$k] ['date'] = "";
  7343. $verifyList [$k] ['opinion'] = "";
  7344. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7345. $verifyList [$k] ['status'] = 4;
  7346. $flag = false;
  7347. }
  7348. } else {
  7349. foreach ( $verifyStaff as $m => $u ) {
  7350. if ($v [0] == $m) {
  7351. $verifyList [$k] ['date'] = $u ['date'];
  7352. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7353. $verifyList [$k] ['status'] = $u ['status'];
  7354. $flag = false;
  7355. break;
  7356. }
  7357. }
  7358. $endStaffArray = end ( $verifyStaff );
  7359. if (isset ( $endStaffArray ['ROLE'] )) {
  7360. } else {
  7361. // $endKey=key($verifyStaff);
  7362. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7363. // $button=4;
  7364. // $verifyList[$k]['status']=4;
  7365. // }
  7366. }
  7367. }
  7368. }
  7369. $rolename ['name'] = '';
  7370. if (! empty ( $roleId )) {
  7371. Doo::loadModel ( 'role' );
  7372. $role = new role ();
  7373. $rolename = $role->getOne ( array (
  7374. 'where' => 'rid=' . $roleId,
  7375. 'asArray' => true
  7376. ) );
  7377. }
  7378. if (! empty ( $verifyStaff ))
  7379. $endStaffArray = end ( $verifyStaff );
  7380. $KOP = false;
  7381. foreach ( $roleArrayCopy as $P => $A ) {
  7382. foreach ( $A as $MKI => $AVL ) {
  7383. if (! empty ( $verifyStaff )) {
  7384. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7385. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7386. $button = 4;
  7387. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7388. }
  7389. foreach ( $verifyStaff as $m => $u ) {
  7390. $AVLFK = $AVL [0] . '_R';
  7391. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7392. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7393. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7394. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7395. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7396. break;
  7397. }
  7398. }
  7399. } else {
  7400. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7401. $button = 4;
  7402. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7403. }
  7404. }
  7405. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7406. $KOP = true;
  7407. }
  7408. }
  7409. foreach ( $roleArrayCopy as $k => $v ) {
  7410. foreach ( $verifyList as $m => $n ) {
  7411. if ($n [0] == $k) {
  7412. array_splice ( $verifyList, $m, 1, $v );
  7413. }
  7414. }
  7415. }
  7416. $receiptList [$key] ['verifyList'] = $verifyList;
  7417. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7418. 'where' => 'sid=' . $value ['staff'],
  7419. 'asArray' => true
  7420. ) );
  7421. $receiptList [$key] ['button'] = $button;
  7422. }
  7423. // print_r($receiptList);die;
  7424. $mothHtml = "";
  7425. for($i = 1; $i <= 12; $i ++) {
  7426. if ($moth == $i)
  7427. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7428. else
  7429. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7430. }
  7431. $data ['mothHtml'] = $mothHtml;
  7432. $data ['receiptList'] = $receiptList;
  7433. $data ['memu'] = "receipt";
  7434. $data ['staff'] = $this->staff;
  7435. $data ['receiptMemu'] = 'receipt';
  7436. $data ['verifyId'] = $this->verifyId;
  7437. $data ['executeId'] = $this->executeId;
  7438. $data ['item'] = $item;
  7439. $data ['year'] = $year;
  7440. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7441. // sufficient condition to generate cache
  7442. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7443. $receiptList = $receipt->find ( array (
  7444. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7445. 'asArray' => true
  7446. ) );
  7447. if (empty ( $receiptList )) { // generated files
  7448. ob_start ();
  7449. $this->render ( "/admin/saea_myList", $data );
  7450. $this->cacheFile ( $path );
  7451. die ();
  7452. // $content = ob_get_contents();
  7453. // $fp = fopen($path, "w");
  7454. // fwrite($fp, $content);
  7455. // fclose($fp);
  7456. }
  7457. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7458. $receiptList = $receipt->find ( array (
  7459. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7460. 'asArray' => true
  7461. ) );
  7462. if (empty ( $receiptList )) { // generated files
  7463. ob_start ();
  7464. $this->render ( "/admin/saea_myList", $data );
  7465. $this->cacheFile ( $path );
  7466. die ();
  7467. }
  7468. }
  7469. }
  7470. $this->render ( "/admin/saea_myList", $data );
  7471. }
  7472. function approvedReceipt() {
  7473. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7474. Doo::loadModel ( 'receipt' );
  7475. Doo::loadModel ( 'receiptDetail' );
  7476. $receipt = new receipt ();
  7477. $receiptDetail = new receiptDetail ();
  7478. Doo::loadModel ( 'statistics' );
  7479. Doo::loadModel ( 'itemStatistics' );
  7480. $statistics = new statistics ();
  7481. $itemStatistics = new itemStatistics ();
  7482. Doo::loadModel ( "verify" );
  7483. $verify = new verify ();
  7484. // 审批状态的判定
  7485. $receiptDetailList = $receipt->getOne ( array (
  7486. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7487. 'asArray' => true
  7488. ) );
  7489. if (empty ( $receiptDetailList ))
  7490. return "/saeaBorad";
  7491. $verifyDetail = $verify->getOne ( array (
  7492. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7493. 'asArray' => true
  7494. ) );
  7495. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7496. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7497. $nowStaff = "";
  7498. $nowStaffList = array ();
  7499. if ($verifyDetail [0] [1] == 'ROLE') {
  7500. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7501. foreach ( $vStaffString as $key => $value ) {
  7502. $staffK = explode ( "_", $value );
  7503. array_push ( $nowStaffList, $staffK [0] );
  7504. }
  7505. $nowStaff = implode ( ',', $nowStaffList );
  7506. } else {
  7507. $nowStaff = $verifyDetail [0] [0];
  7508. }
  7509. $receipt->nowStaff = $nowStaff;
  7510. }
  7511. // echo $nowStaff;
  7512. // print_r($verifyDetail);die;
  7513. $receipt->rid = $receiptDetailList ['rid'];
  7514. $receipt->date = date ( "Y-m-d" );
  7515. $receipt->status = 2;
  7516. $receipt->update ();
  7517. $receiptDetail->status = 2;
  7518. $receiptDetail->update ( array (
  7519. 'where' => 'rid=' . $receiptDetailList ['rid']
  7520. ) );
  7521. Doo::loadModel ( "receiptLog" );
  7522. $receiptLog = new receiptLog ();
  7523. Doo::loadModel ( "verify" );
  7524. $verify = new verify ();
  7525. $receiptInfo = $receipt->getOne ( array (
  7526. 'where' => 'rid=' . $rid,
  7527. 'asArray' => true
  7528. ) );
  7529. $vr = $verify->getOne ( array (
  7530. 'where' => 'vid=' . $receiptInfo ['verify'],
  7531. 'asArray' => true
  7532. ) );
  7533. $jd = json_decode ( $vr ['staff'] );
  7534. $roleId = 0;
  7535. foreach ( $jd as $key => $value ) {
  7536. if ($value [1] == 'ROLE') {
  7537. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7538. if ($pos !== false) {
  7539. $roleId = $value [0];
  7540. }
  7541. }
  7542. }
  7543. // 审批日志
  7544. // echo $roleId;die;
  7545. if (! empty ( $roleId )) {
  7546. Doo::loadModel ( "role" );
  7547. $role = new role ();
  7548. $roleInfo = $role->getOne ( array (
  7549. 'where' => 'rid=' . $roleId,
  7550. 'asArray' => true
  7551. ) );
  7552. // $receiptLog->rolename = $roleInfo ['name'];
  7553. }
  7554. $receiptLog->username = $this->staff [0] ['username'];
  7555. $receiptLog->uid = $this->staff [0] ['sid'];
  7556. $receiptLog->date = date ( "Y-m-d" );
  7557. $receiptLog->opinion = '提交审批';
  7558. $receiptLog->img = $this->staff [0] ['avatar'];
  7559. $receiptLog->status = 2;
  7560. $receiptLog->rid = $rid;
  7561. $receiptLog->insert ();
  7562. // statistics item
  7563. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7564. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7565. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7566. $stat = $statistics->getOne ( array (
  7567. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7568. 'asArray' => true
  7569. ) );
  7570. if (empty ( $stat )) {
  7571. $statistics->date = date ( "Y-m-d" );
  7572. $statistics->cid = $this->staff [0] ['cid'];
  7573. $statistics->staff = $this->staff [0] ['sid'];
  7574. $statistics->agPrice = 0;
  7575. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7576. $statistics->insert ();
  7577. } else {
  7578. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7579. $statistics->update ( array (
  7580. 'where' => 'sid=' . $stat ['sid']
  7581. ) );
  7582. }
  7583. return "/expenses";
  7584. }
  7585. function approval() {
  7586. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7587. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7588. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7589. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7590. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7591. if (empty ( $status ))
  7592. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7593. $vidList = array ();
  7594. $button = 0;
  7595. Doo::loadModel ( 'verify' );
  7596. $verify = new verify ();
  7597. Doo::loadModel ( 'receipt' );
  7598. $receipt = new receipt ();
  7599. Doo::loadModel ( 'staff' );
  7600. $staff = new staff ();
  7601. Doo::loadModel ( 'L_category' );
  7602. $Lcategory = new L_category ();
  7603. // user verify ID
  7604. $verifyDetail = $verify->find ( array (
  7605. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7606. 'asArray' => true
  7607. ) );
  7608. foreach ( $verifyDetail as $key => $value ) {
  7609. array_push ( $vidList, $value ['vid'] );
  7610. }
  7611. $vid = implode ( ",", $vidList );
  7612. if (empty ( $verifyDetail ))
  7613. $vid = 0;
  7614. /*
  7615. */
  7616. $dateCondition = " and Year(date) =" . $year;
  7617. if (! empty ( $month ))
  7618. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7619. $categoryList = $Lcategory->find ( array (
  7620. 'asArray' => true
  7621. ) );
  7622. $staffList = $staff->find ( array (
  7623. 'where' => 'cid=' . $cid,
  7624. 'asArray' => true
  7625. ) );
  7626. $cateCondition = "";
  7627. $staffCondition = "";
  7628. $approvalCondition = "";
  7629. if (! empty ( $cid ))
  7630. $cateCondition = ' and cid=' . $cid;
  7631. if (! empty ( $sid )) {
  7632. $staffCondition = ' and staff=' . $sid;
  7633. $cateCondition = "";
  7634. }
  7635. // elseif($status==1){
  7636. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7637. // }
  7638. if ($status == 2) {
  7639. // 查找角色审批人
  7640. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7641. }
  7642. $ap = "";
  7643. if ($status == 4) {
  7644. $ap = 4;
  7645. $status = 2;
  7646. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7647. }
  7648. if ($status == 5) {
  7649. $status = 4;
  7650. $ap = 5;
  7651. }
  7652. // echo $vid;
  7653. // get Receipt By verifyID status 2 .$approvalCondition
  7654. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7655. $receiptList = $receipt->find ( array (
  7656. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7657. 'desc' => 'rid',
  7658. 'asArray' => true
  7659. ) );
  7660. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7661. $Locate = 0;
  7662. if ($ap == 4)
  7663. $status = 4;
  7664. elseif ($ap == 5)
  7665. $status = 5;
  7666. foreach ( $receiptList as $key => $value ) {
  7667. $receiptList [$key] ['Locate'] = $Locate;
  7668. $Locate ++;
  7669. $receiptList [$key] ['reviseDetail'] = array ();
  7670. if (! empty ( $value ['reviseDetail'] ))
  7671. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7672. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7673. $categoryDetil = $Lcategory->getOne ( array (
  7674. 'where' => 'cid=' . $value ['cid'],
  7675. 'asArray' => true
  7676. ) );
  7677. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7678. $verifyList = $verify->getOne ( array (
  7679. 'where' => 'vid=' . $value ['verify'],
  7680. 'asArray' => true
  7681. ) );
  7682. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7683. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7684. foreach ( $verifyList as $k => $v ) {
  7685. // init verifyStaff
  7686. $verifyList [$k] ['date'] = "";
  7687. $verifyList [$k] ['opinion'] = "";
  7688. $verifyList [$k] ['status'] = "";
  7689. if (empty ( $verifyStaff )) {
  7690. $verifyList [$k] ['date'] = "";
  7691. $verifyList [$k] ['opinion'] = "";
  7692. if ($v [0] == $this->staff [0] ['sid']) {
  7693. $verifyList [$k] ['status'] = 4;
  7694. $button = 4;
  7695. }
  7696. } else {
  7697. $flag = true;
  7698. foreach ( $verifyStaff as $m => $u ) {
  7699. if ($v [0] == $m) {
  7700. $verifyList [$k] ['date'] = $u ['date'];
  7701. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7702. $verifyList [$k] ['status'] = $u ['status'];
  7703. $flag = false;
  7704. break;
  7705. }
  7706. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7707. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7708. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7709. }
  7710. if ($flag) { // 检测可编辑
  7711. if ($v [0] == $this->staff [0] ['sid']) {
  7712. $verifyList [$k] ['status'] = 4;
  7713. $button = 4;
  7714. }
  7715. }
  7716. }
  7717. }
  7718. $receiptList [$key] ['verifyList'] = $verifyList;
  7719. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7720. 'where' => 'sid=' . $value ['staff'],
  7721. 'asArray' => true
  7722. ) );
  7723. $receiptList [$key] ['button'] = $button;
  7724. }
  7725. // print_r($receiptList);die;
  7726. // $data['verifyDetail']=$verifyDetail;
  7727. $mothHtml = "";
  7728. for($i = 1; $i <= 12; $i ++) {
  7729. if ($month == $i)
  7730. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7731. else
  7732. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7733. }
  7734. $data ['mothHtml'] = $mothHtml;
  7735. $data ['receiptList'] = $receiptList;
  7736. $data ['receiptApprovalCount'] = count ( $receiptList );
  7737. $data ['status'] = $status;
  7738. $data ['year'] = $year;
  7739. $data ['categoryList'] = $categoryList;
  7740. $data ['staffList'] = $staffList;
  7741. $data ['cid'] = $cid;
  7742. $data ['sid'] = $sid;
  7743. $data ['ap'] = $ap;
  7744. $data ['memu'] = "receipt";
  7745. $data ['staff'] = $this->staff;
  7746. $data ['receiptMemu'] = 'approval';
  7747. $data ['verifyId'] = $this->verifyId;
  7748. $data ['executeId'] = $this->executeId;
  7749. $this->render ( "/admin/saea_reportList", $data );
  7750. }
  7751. function approvalDetails() {
  7752. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7753. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7754. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7755. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7756. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7757. Doo::loadModel ( 'verify' );
  7758. $verify = new verify ();
  7759. Doo::loadModel ( 'receipt' );
  7760. $receipt = new receipt ();
  7761. Doo::loadModel ( 'staff' );
  7762. $staff = new staff ();
  7763. Doo::loadModel ( 'L_category' );
  7764. $Lcategory = new L_category ();
  7765. Doo::loadModel ( 'enclosur' );
  7766. $enclosur = new enclosur ();
  7767. $vidList = array ();
  7768. $verifyDetail = $verify->find ( array (
  7769. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7770. 'asArray' => true
  7771. ) );
  7772. foreach ( $verifyDetail as $key => $value ) {
  7773. array_push ( $vidList, $value ['vid'] );
  7774. }
  7775. $vid = implode ( ",", $vidList );
  7776. if (empty ( $verifyDetail ))
  7777. $vid = 0;
  7778. $categoryList = $Lcategory->find ( array (
  7779. 'asArray' => true
  7780. ) );
  7781. $staffList = $staff->find ( array (
  7782. 'where' => 'cid=' . $cid,
  7783. 'asArray' => true
  7784. ) );
  7785. $ap = 0;
  7786. $receiptList = $receipt->find ( array (
  7787. 'where' => 'rid =' . $rid,
  7788. 'desc' => 'rid',
  7789. 'asArray' => true
  7790. ) );
  7791. $Locate = 0;
  7792. $roleId = 0;
  7793. $button = 0;
  7794. foreach ( $receiptList as $key => $value ) {
  7795. $receiptList [$key] ['Locate'] = $Locate;
  7796. $Locate ++;
  7797. $receiptList [$key] ['reviseDetail'] = array ();
  7798. if (! empty ( $value ['reviseDetail'] ))
  7799. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7800. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7801. $categoryDetil = $Lcategory->getOne ( array (
  7802. 'where' => 'cid=' . $value ['cid'],
  7803. 'asArray' => true
  7804. ) );
  7805. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7806. // 检测编辑状态
  7807. $verifyList = $verify->getOne ( array (
  7808. 'where' => 'vid=' . $value ['verify'],
  7809. 'asArray' => true
  7810. ) );
  7811. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7812. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7813. Doo::loadModel ( 'role' );
  7814. $role = new role ();
  7815. // print_r($verifyList);
  7816. $flag = true;
  7817. $roleKey = 0;
  7818. $endStaffArray = array ();
  7819. $roleArrayCopy = array ();
  7820. foreach ( $verifyList as $k => $v ) {
  7821. // init verifyStaff
  7822. if ($v [1] == 'ROLE') {
  7823. if (! empty ( $verifyStaff )) {
  7824. $endStaffArray = end ( $verifyStaff );
  7825. if ($v [0] == $endStaffArray ['nextStaff']) {
  7826. $roleId = $v [0];
  7827. }
  7828. }
  7829. $roleVerify = json_decode ( $v [3], true );
  7830. $roleKey = $k;
  7831. $roleArray = array ();
  7832. $rolename = $role->getOne ( array (
  7833. 'where' => 'rid=' . $v [0],
  7834. 'asArray' => true
  7835. ) );
  7836. foreach ( $roleVerify as $o => $p ) {
  7837. $staffID = explode ( '_', $p );
  7838. $staffInfo = $staff->getOne ( array (
  7839. 'where' => 'sid=' . $staffID [0],
  7840. 'asArray' => true
  7841. ) );
  7842. // print_r($staffID);
  7843. $exp = array (
  7844. 0 => $staffInfo ['sid'],
  7845. 1 => $staffID [1],
  7846. 2 => $staffInfo ['avatar'],
  7847. 'date' => '',
  7848. 'date' => '',
  7849. 'opinion' => '',
  7850. 'status' => '',
  7851. 'rolename' => $rolename ['name']
  7852. );
  7853. array_push ( $roleArray, $exp );
  7854. }
  7855. $roleArrayCopy [$v [0]] = $roleArray;
  7856. // $verifyList[$k]['roleArray']=$roleArray;
  7857. }
  7858. // print_r($roleArray);
  7859. $verifyList [$k] ['date'] = "";
  7860. $verifyList [$k] ['opinion'] = "";
  7861. $verifyList [$k] ['status'] = "";
  7862. if (empty ( $verifyStaff )) {
  7863. $verifyList [$k] ['date'] = "";
  7864. $verifyList [$k] ['opinion'] = "";
  7865. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7866. $verifyList [$k] ['status'] = 4;
  7867. $button = 4;
  7868. $flag = false;
  7869. }
  7870. } else {
  7871. foreach ( $verifyStaff as $m => $u ) {
  7872. if ($v [0] == $m) {
  7873. $verifyList [$k] ['date'] = $u ['date'];
  7874. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7875. $verifyList [$k] ['status'] = $u ['status'];
  7876. $flag = false;
  7877. break;
  7878. }
  7879. }
  7880. $endStaffArray = end ( $verifyStaff );
  7881. if (isset ( $endStaffArray ['ROLE'] )) {
  7882. } else {
  7883. $endKey = key ( $verifyStaff );
  7884. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7885. $button = 4;
  7886. $verifyList [$k] ['status'] = 4;
  7887. }
  7888. }
  7889. }
  7890. }
  7891. $rolename ['name'] = '';
  7892. if (! empty ( $roleId )) {
  7893. Doo::loadModel ( 'role' );
  7894. $role = new role ();
  7895. $rolename = $role->getOne ( array (
  7896. 'where' => 'rid=' . $roleId,
  7897. 'asArray' => true
  7898. ) );
  7899. }
  7900. if (! empty ( $verifyStaff ))
  7901. $endStaffArray = end ( $verifyStaff );
  7902. $KOP = false;
  7903. foreach ( $roleArrayCopy as $P => $A ) {
  7904. foreach ( $A as $MKI => $AVL ) {
  7905. if (! empty ( $verifyStaff )) {
  7906. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7907. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7908. $button = 4;
  7909. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7910. }
  7911. foreach ( $verifyStaff as $m => $u ) {
  7912. $AVLFK = $AVL [0] . '_R';
  7913. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7914. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7915. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7916. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7917. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7918. break;
  7919. }
  7920. }
  7921. } else {
  7922. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7923. $button = 4;
  7924. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7925. }
  7926. }
  7927. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7928. $KOP = true;
  7929. }
  7930. }
  7931. foreach ( $roleArrayCopy as $k => $v ) {
  7932. foreach ( $verifyList as $m => $n ) {
  7933. if ($n [0] == $k) {
  7934. array_splice ( $verifyList, $m, 1, $v );
  7935. }
  7936. }
  7937. }
  7938. $receiptList [$key] ['verifyList'] = $verifyList;
  7939. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7940. 'where' => 'sid=' . $value ['staff'],
  7941. 'asArray' => true
  7942. ) );
  7943. $receiptList [$key] ['button'] = $button;
  7944. }
  7945. $mothHtml = "";
  7946. for($i = 1; $i <= 12; $i ++) {
  7947. if ($month == $i)
  7948. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7949. else
  7950. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7951. }
  7952. // 获取审批日志
  7953. Doo::loadModel ( 'receiptLog' );
  7954. $receiptLog = new receiptLog ();
  7955. $rlList = array ();
  7956. $rlInfo = $receiptLog->getOne ( array (
  7957. 'where' => 'rid=' . $rid . ' and status=4',
  7958. 'asArray' => true
  7959. ) );
  7960. $tijdate = $receiptLog->getOne ( array (
  7961. 'where' => 'rid=' . $rid . ' and status=2',
  7962. 'asc' => 'rlid',
  7963. 'asArray' => true
  7964. ) );
  7965. if (! empty ( $rlInfo )) {
  7966. $rlList = $receiptLog->find ( array (
  7967. 'where' => 'rid=' . $rid,
  7968. 'asc' => 'rlid',
  7969. 'asArray' => true
  7970. ) );
  7971. }
  7972. $receiptList [0] ['rlList'] = $rlList;
  7973. $enclosurList = $enclosur->find ( array (
  7974. 'where' => 'rid=' . $rid,
  7975. 'asArray' => true
  7976. ) );
  7977. $enclosurHtml = '';
  7978. foreach ( $enclosurList as $value ) {
  7979. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7980. }
  7981. $data ['enclosurHtml'] = $enclosurHtml;
  7982. $data ['rolename'] = $rolename ['name'];
  7983. $data ['datetij'] = $tijdate ['date'];
  7984. $data ['mothHtml'] = $mothHtml;
  7985. $data ['receiptList'] = $receiptList;
  7986. $data ['receiptApprovalCount'] = count ( $receiptList );
  7987. $data ['year'] = $year;
  7988. $data ['categoryList'] = $categoryList;
  7989. $data ['staffList'] = $staffList;
  7990. $data ['cid'] = $cid;
  7991. $data ['sid'] = $sid;
  7992. $data ['status'] = 0;
  7993. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7994. $ap = 4;
  7995. } else
  7996. $data ['status'] = $receiptList [0] ['status'];
  7997. if ($receiptList [0] ['status'] == 4) {
  7998. $data ['status'] = 5;
  7999. $ap = 0;
  8000. }
  8001. $data ['ap'] = $ap;
  8002. $data ['memu'] = "receipt";
  8003. $data ['staff'] = $this->staff;
  8004. $data ['receiptMemu'] = 'approval';
  8005. $data ['verifyId'] = $this->verifyId;
  8006. $data ['executeId'] = $this->executeId;
  8007. $this->render ( "/admin/saeaReportListReport", $data );
  8008. }
  8009. function approvalEdi() {
  8010. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8011. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8012. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8013. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8014. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8015. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8016. if (empty ( $status ))
  8017. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8018. $vidList = array ();
  8019. $button = 0;
  8020. Doo::loadModel ( 'verify' );
  8021. Doo::loadModel ( 'receipt' );
  8022. Doo::loadModel ( 'staff' );
  8023. $staff = new staff ();
  8024. $receipt = new receipt ();
  8025. $verify = new verify ();
  8026. Doo::loadModel ( 'L_category' );
  8027. $Lcategory = new L_category ();
  8028. Doo::loadModel ( 'enclosur' );
  8029. $enclosur = new enclosur ();
  8030. // user verify ID
  8031. $verifyDetail = $verify->find ( array (
  8032. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8033. 'asArray' => true
  8034. ) );
  8035. foreach ( $verifyDetail as $key => $value ) {
  8036. array_push ( $vidList, $value ['vid'] );
  8037. }
  8038. $vid = implode ( ",", $vidList );
  8039. if (empty ( $verifyDetail ))
  8040. $vid = 0;
  8041. $categoryList = $Lcategory->find ( array (
  8042. 'asArray' => true
  8043. ) );
  8044. $staffList = $staff->find ( array (
  8045. 'where' => 'cid=' . $cid,
  8046. 'asArray' => true
  8047. ) );
  8048. $ap = "";
  8049. if ($status == 4) {
  8050. $ap = 4;
  8051. $status = 2;
  8052. }
  8053. // get Receipt By verifyID status 2
  8054. $receiptList = $receipt->find ( array (
  8055. 'where' => 'rid =' . $rid,
  8056. 'desc' => 'rid',
  8057. 'asArray' => true
  8058. ) );
  8059. $Locate = 0;
  8060. $roleId = 0;
  8061. if ($ap == 4)
  8062. $status = 4;
  8063. foreach ( $receiptList as $key => $value ) {
  8064. $receiptList [$key] ['Locate'] = $Locate;
  8065. $Locate ++;
  8066. $receiptList [$key] ['reviseDetail'] = array ();
  8067. if (! empty ( $value ['reviseDetail'] ))
  8068. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8069. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8070. $categoryDetil = $Lcategory->getOne ( array (
  8071. 'where' => 'cid=' . $value ['cid'],
  8072. 'asArray' => true
  8073. ) );
  8074. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8075. // 检测编辑状态
  8076. $verifyList = $verify->getOne ( array (
  8077. 'where' => 'vid=' . $value ['verify'],
  8078. 'asArray' => true
  8079. ) );
  8080. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8081. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8082. // print_r($verifyList);
  8083. //
  8084. // if (empty($verifyStaff)){
  8085. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8086. // $verifyList[0]['status']=4;$button=4;
  8087. // }
  8088. //
  8089. // }else{
  8090. //
  8091. // }
  8092. // die;
  8093. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8094. // echo array_search("green",$a);
  8095. //
  8096. Doo::loadModel ( 'role' );
  8097. $role = new role ();
  8098. // print_r($verifyList);
  8099. $flag = true;
  8100. $roleKey = 0;
  8101. $endStaffArray = array ();
  8102. $roleArrayCopy = array ();
  8103. foreach ( $verifyList as $k => $v ) {
  8104. // init verifyStaff
  8105. if ($v [1] == 'ROLE') {
  8106. if (! empty ( $verifyStaff )) {
  8107. $endStaffArray = end ( $verifyStaff );
  8108. if ($v [0] == $endStaffArray ['nextStaff']) {
  8109. $roleId = $v [0];
  8110. }
  8111. }
  8112. $roleVerify = json_decode ( $v [3], true );
  8113. $roleKey = $k;
  8114. $roleArray = array ();
  8115. $rolename = $role->getOne ( array (
  8116. 'where' => 'rid=' . $v [0],
  8117. 'asArray' => true
  8118. ) );
  8119. foreach ( $roleVerify as $o => $p ) {
  8120. $staffID = explode ( '_', $p );
  8121. $staffInfo = $staff->getOne ( array (
  8122. 'where' => 'sid=' . $staffID [0],
  8123. 'asArray' => true
  8124. ) );
  8125. // print_r($staffID);
  8126. $exp = array (
  8127. 0 => $staffInfo ['sid'],
  8128. 1 => $staffID [1],
  8129. 2 => $staffInfo ['avatar'],
  8130. 'date' => '',
  8131. 'date' => '',
  8132. 'opinion' => '',
  8133. 'status' => '',
  8134. 'rolename' => $rolename ['name']
  8135. );
  8136. array_push ( $roleArray, $exp );
  8137. }
  8138. $roleArrayCopy [$v [0]] = $roleArray;
  8139. // $verifyList[$k]['roleArray']=$roleArray;
  8140. }
  8141. // print_r($roleArray);
  8142. $verifyList [$k] ['date'] = "";
  8143. $verifyList [$k] ['opinion'] = "";
  8144. $verifyList [$k] ['status'] = "";
  8145. if (empty ( $verifyStaff )) {
  8146. $verifyList [$k] ['date'] = "";
  8147. $verifyList [$k] ['opinion'] = "";
  8148. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8149. $verifyList [$k] ['status'] = 4;
  8150. $button = 4;
  8151. $flag = false;
  8152. }
  8153. } else {
  8154. foreach ( $verifyStaff as $m => $u ) {
  8155. if ($v [0] == $m) {
  8156. $verifyList [$k] ['date'] = $u ['date'];
  8157. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8158. $verifyList [$k] ['status'] = $u ['status'];
  8159. $flag = false;
  8160. break;
  8161. }
  8162. }
  8163. $endStaffArray = end ( $verifyStaff );
  8164. if (isset ( $endStaffArray ['ROLE'] )) {
  8165. } else {
  8166. $endKey = key ( $verifyStaff );
  8167. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8168. $button = 4;
  8169. $verifyList [$k] ['status'] = 4;
  8170. }
  8171. }
  8172. // print_r($endStaffArray);die;
  8173. // if (empty($verifyStaff)){
  8174. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8175. // $verifyList[$k]['status']=4;$button=4;
  8176. // }
  8177. //
  8178. // }else{
  8179. //
  8180. // }
  8181. // if($flag){//检测可编辑
  8182. // if($v[0]==$this->staff[0]['sid']){
  8183. // $verifyList[$k]['status']=4;$button=4;
  8184. // }
  8185. // }
  8186. }
  8187. }
  8188. $rolename ['name'] = '';
  8189. if (! empty ( $roleId )) {
  8190. Doo::loadModel ( 'role' );
  8191. $role = new role ();
  8192. $rolename = $role->getOne ( array (
  8193. 'where' => 'rid=' . $roleId,
  8194. 'asArray' => true
  8195. ) );
  8196. }
  8197. if (! empty ( $verifyStaff ))
  8198. $endStaffArray = end ( $verifyStaff );
  8199. $KOP = false;
  8200. foreach ( $roleArrayCopy as $P => $A ) {
  8201. foreach ( $A as $MKI => $AVL ) {
  8202. if (! empty ( $verifyStaff )) {
  8203. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8204. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8205. $button = 4;
  8206. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8207. }
  8208. foreach ( $verifyStaff as $m => $u ) {
  8209. $AVLFK = $AVL [0] . '_R';
  8210. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8211. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8212. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8213. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8214. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8215. break;
  8216. }
  8217. }
  8218. } else {
  8219. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8220. $button = 4;
  8221. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8222. }
  8223. }
  8224. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8225. $KOP = true;
  8226. }
  8227. }
  8228. // print_r($roleArrayCopy);
  8229. // echo $roleKey;
  8230. foreach ( $roleArrayCopy as $k => $v ) {
  8231. foreach ( $verifyList as $m => $n ) {
  8232. if ($n [0] == $k) {
  8233. array_splice ( $verifyList, $m, 1, $v );
  8234. }
  8235. }
  8236. }
  8237. // if ($KOP)
  8238. // array_splice($verifyList,$roleKey,1,$roleArray);
  8239. // print_r($verifyList);
  8240. $receiptList [$key] ['verifyList'] = $verifyList;
  8241. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8242. 'where' => 'sid=' . $value ['staff'],
  8243. 'asArray' => true
  8244. ) );
  8245. $receiptList [$key] ['button'] = $button;
  8246. }
  8247. // $data['verifyDetail']=$verifyDetail;
  8248. $mothHtml = "";
  8249. for($i = 1; $i <= 12; $i ++) {
  8250. if ($month == $i)
  8251. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8252. else
  8253. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8254. }
  8255. // 获取审批日志
  8256. Doo::loadModel ( 'receiptLog' );
  8257. $receiptLog = new receiptLog ();
  8258. $rlList = array ();
  8259. $rlInfo = $receiptLog->getOne ( array (
  8260. 'where' => 'rid=' . $rid . ' and status=4',
  8261. 'asArray' => true
  8262. ) );
  8263. $tijdate = $receiptLog->getOne ( array (
  8264. 'where' => 'rid=' . $rid . ' and status=2',
  8265. 'asc' => 'rlid',
  8266. 'asArray' => true
  8267. ) );
  8268. if (! empty ( $rlInfo )) {
  8269. $rlList = $receiptLog->find ( array (
  8270. 'where' => 'rid=' . $rid,
  8271. 'asc' => 'rlid',
  8272. 'asArray' => true
  8273. ) );
  8274. }
  8275. $receiptList [0] ['rlList'] = $rlList;
  8276. $enclosurList = $enclosur->find ( array (
  8277. 'where' => 'rid=' . $rid,
  8278. 'asArray' => true
  8279. ) );
  8280. $enclosurHtml = '';
  8281. foreach ( $enclosurList as $value ) {
  8282. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8283. }
  8284. $data ['enclosurHtml'] = $enclosurHtml;
  8285. $data ['rolename'] = $rolename ['name'];
  8286. $data ['datetij'] = $tijdate ['date'];
  8287. $data ['mothHtml'] = $mothHtml;
  8288. $data ['receiptList'] = $receiptList;
  8289. $data ['receiptApprovalCount'] = count ( $receiptList );
  8290. $data ['status'] = $status;
  8291. $data ['year'] = $year;
  8292. $data ['categoryList'] = $categoryList;
  8293. $data ['staffList'] = $staffList;
  8294. $data ['cid'] = $cid;
  8295. $data ['sid'] = $sid;
  8296. $data ['ap'] = $ap;
  8297. $data ['memu'] = "receipt";
  8298. $data ['staff'] = $this->staff;
  8299. $data ['receiptMemu'] = 'approval';
  8300. $data ['verifyId'] = $this->verifyId;
  8301. $data ['executeId'] = $this->executeId;
  8302. $this->render ( "/admin/saeaReportListReport", $data );
  8303. }
  8304. function remittanceHky() {
  8305. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8306. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8307. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8308. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8309. $page_size = 15;
  8310. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8311. Doo::loadModel ( 'receipt' );
  8312. $receipt = new receipt ();
  8313. Doo::loadModel ( 'staff' );
  8314. $staff = new staff ();
  8315. $dateCondition = " and Year(executeDate) =" . $year;
  8316. if ($moth != 'MONTH')
  8317. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8318. if ($day != 'DAY' && $moth != 'MONTH')
  8319. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8320. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8321. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8322. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8323. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8324. $dayList = $receipt->find ( array (
  8325. 'select' => 'executeDate,sum(amount) as amount',
  8326. 'where' => $sql,
  8327. 'desc' => 'executeDate',
  8328. 'groupby' => 'executeDate',
  8329. 'limit' => $limit,
  8330. 'asArray' => true
  8331. ) );
  8332. // print_r($dayList);
  8333. foreach ( $dayList as $key => $value ) {
  8334. $remitString = "";
  8335. $receiptList = $receipt->find ( array (
  8336. 'select' => 'rid,executeDate,amount,staff,cid',
  8337. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8338. 'desc' => 'executeDate',
  8339. 'asArray' => true
  8340. ) );
  8341. foreach ( $receiptList as $k => $v ) {
  8342. $sinfo = $staff->getOne ( array (
  8343. 'select' => 'username,category',
  8344. 'where' => ' sid=' . $v ['staff'],
  8345. 'asArray' => true
  8346. ) );
  8347. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8348. }
  8349. $dayList [$key] ['staff'] = $remitString;
  8350. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8351. }
  8352. // print_r($dayList);
  8353. $mothHtml = "";
  8354. for($i = 1; $i <= 12; $i ++) {
  8355. if ($moth == $i)
  8356. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8357. else
  8358. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8359. }
  8360. $dayHtml = "";
  8361. if ($day != "DAY" || $moth != "MONTH") {
  8362. for($i = 1; $i <= 31; $i ++) {
  8363. if ($day == $i)
  8364. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8365. else
  8366. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8367. }
  8368. }
  8369. $dateHtml = "";
  8370. $now = date ( "Y" );
  8371. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8372. if ($YEARD <= $now) {
  8373. $dateHtml .= '<option ';
  8374. if ($year == $YEARD) {
  8375. $dateHtml .= 'selected ';
  8376. }
  8377. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8378. }
  8379. }
  8380. $data ['dateHtml'] = $dateHtml;
  8381. $data ['page'] = $pageinfo;
  8382. $data ['year'] = $year;
  8383. $data ['moth'] = $moth;
  8384. $data ['day'] = $day;
  8385. $data ['get'] = $get;
  8386. $data ['dayHtml'] = $dayHtml;
  8387. $data ['mothHtml'] = $mothHtml;
  8388. $data ['receiptList'] = $dayList;
  8389. $data ['memu'] = "receipt";
  8390. $data ['staff'] = $this->staff;
  8391. $data ['receiptMemu'] = 'remittanceHky';
  8392. $data ['verifyId'] = $this->verifyId;
  8393. $data ['executeId'] = $this->executeId;
  8394. $this->render ( "/admin/remittanceHky", $data );
  8395. }
  8396. function remittancep() {
  8397. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8398. Doo::loadModel ( 'receipt' );
  8399. $receipt = new receipt ();
  8400. Doo::loadModel ( 'staff' );
  8401. $staff = new staff ();
  8402. Doo::loadClass ( 'XDeode' );
  8403. $XDeode = new XDeode ( 5 );
  8404. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8405. $rplist = $receipt->find ( array (
  8406. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8407. 'asArray' => true
  8408. ) );
  8409. $dayList = $receipt->find ( array (
  8410. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8411. 'desc' => 'executeDate',
  8412. 'groupby' => 'staff',
  8413. 'asArray' => true
  8414. ) );
  8415. $html = '';
  8416. foreach ( $dayList as $key => $value ) {
  8417. $sinfo = $staff->getOne ( array (
  8418. 'select' => 'username,category',
  8419. 'where' => ' sid=' . $value ['staff'],
  8420. 'asArray' => true
  8421. ) );
  8422. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8423. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8424. $au = 0;
  8425. foreach ( $rplist as $k => $v ) {
  8426. if ($value ['staff'] == $v ['staff']) {
  8427. $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>';
  8428. $au += $v ['amount'];
  8429. }
  8430. }
  8431. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8432. }
  8433. $data ['html'] = $html;
  8434. $data ['memu'] = "receipt";
  8435. $data ['staff'] = $this->staff;
  8436. $data ['receiptMemu'] = 'remittanceHky';
  8437. $data ['verifyId'] = $this->verifyId;
  8438. $data ['executeId'] = $this->executeId;
  8439. $this->render ( "/admin/remittancep", $data );
  8440. }
  8441. function ajaxGetReceiptDetails() {
  8442. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8443. Doo::loadClass ( 'XDeode' );
  8444. $XDeode = new XDeode ( 5 );
  8445. $rid = $XDeode->decode ( $rid );
  8446. if (empty ( $rid )) {
  8447. echo json_encode ( array (
  8448. 'status' => 2,
  8449. 'msg' => 'illegal request'
  8450. ) );
  8451. die ();
  8452. }
  8453. Doo::loadModel ( 'receipt' );
  8454. $receipt = new receipt ();
  8455. Doo::loadModel ( 'staff' );
  8456. $staff = new staff ();
  8457. $rinfo = $receipt->getOne ( array (
  8458. 'where' => 'rid= ' . $rid,
  8459. 'asArray' => true
  8460. ) );
  8461. $sinfo = $staff->getOne ( array (
  8462. 'select' => 'username,category',
  8463. 'where' => ' sid=' . $rinfo ['staff'],
  8464. 'asArray' => true
  8465. ) );
  8466. $rinfo ['reviseDetail'] = array ();
  8467. if (! empty ( $rinfo ['reviseDetail'] ))
  8468. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8469. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8470. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8471. $rinfo ['category'] = $sinfo ['category'];
  8472. $verifyStaff = array ();
  8473. if (! empty ( $rinfo ['verifyStaff'] ))
  8474. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8475. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8476. $rinfo ['relust'] = $relust;
  8477. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8478. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8479. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8480. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8481. // 费用执行人相关数据
  8482. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8483. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8484. foreach ( $executeCopy as $k => $v ) {
  8485. $executeCopy [$k] ['date'] = '';
  8486. $executeCopy [$k] ['opinion'] = '';
  8487. $executeCopy [$k] ['status'] = '';
  8488. if (! empty ( $executeStaff ))
  8489. foreach ( $executeStaff as $m => $u ) {
  8490. if ($v [0] == $m) {
  8491. $executeCopy [$k] ['date'] = $u ['date'];
  8492. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8493. $executeCopy [$k] ['status'] = $u ['status'];
  8494. break;
  8495. }
  8496. }
  8497. }
  8498. $rinfo ['executeCopy'] = $executeCopy;
  8499. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8500. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8501. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8502. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8503. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8504. $html .= '<tr><th>' . $value ['name'] . '</th>
  8505. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8506. }
  8507. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8508. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8509. <tr><th class="taC" colspan="2">费用说明</th>
  8510. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8511. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8512. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8513. </tbody></table>';
  8514. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8515. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8516. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8517. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8518. $html .= '<tr><th>' . $value ['name'] . '</th>
  8519. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8520. }
  8521. $html .= '<tr><th class="taR">合计</th>
  8522. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8523. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8524. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8525. $html .= '<tr><th>' . $value ['name'] . '</th>
  8526. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8527. }
  8528. $html .= '<tr><th class="taR">合计</th>
  8529. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8530. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8531. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8532. $html .= '<tr><th>' . $value ['name'] . '</th>
  8533. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8534. }
  8535. $html .= '<tr><th class="taR">合计</th>
  8536. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8537. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8538. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8539. $html .= '<tr><th>' . $value ['name'] . '</th>
  8540. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8541. }
  8542. $html .= '<tr><th class="taR">合计</th>
  8543. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8544. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8545. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8546. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8547. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8548. }
  8549. $html .= '<tr><th class="taR">合计</th>
  8550. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8551. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8552. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8553. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8554. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8555. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8556. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8557. <tr';
  8558. if ($rinfo ['relust'] >= 0) {
  8559. $html .= 'class="success"';
  8560. } else {
  8561. $html .= 'class="error"';
  8562. }
  8563. $html .= '><td class="taR"><b>借款结余</b></td>
  8564. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8565. </tbody></table>
  8566. ';
  8567. }
  8568. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8569. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8570. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8571. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8572. $html .= '<tr><th>' . $value ['name'] . '</th>
  8573. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8574. }
  8575. $html .= '<tr><th class="taR">合计</th>
  8576. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8577. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8578. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8579. <tr><th class="taC" colspan="2">费用说明</th>
  8580. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8581. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8582. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8583. </tbody></table>';
  8584. } else {
  8585. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8586. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8587. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8588. $html .= '<tr><th>' . $value ['name'] . '</th>
  8589. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8590. }
  8591. $html .= '<tr><th class="taR">合计</th>
  8592. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8593. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8594. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8595. $html .= '<tr><th>' . $value ['name'] . '</th>
  8596. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8597. }
  8598. $html .= '<tr><th class="taR">合计</th>
  8599. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8600. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8601. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8602. $html .= '<tr><th>' . $value ['name'] . '</th>
  8603. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8604. }
  8605. $html .= '<tr><th class="taR">合计</th>
  8606. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8607. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8608. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8609. $html .= '<tr><th>' . $value ['name'] . '</th>
  8610. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8611. }
  8612. $html .= '<tr><th class="taR">合计</th>
  8613. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8614. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8615. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8616. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8617. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8618. }
  8619. $html .= '<tr><th class="taR">合计</th>
  8620. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8621. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8622. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8623. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8624. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8625. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8626. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8627. $html .= '</tbody></table>';
  8628. /*
  8629. * <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>
  8630. */
  8631. }
  8632. // print_r($verifyStaff);die;
  8633. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8634. foreach ( $verifyStaff as $key => $value ) {
  8635. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8636. $sinfo = $staff->getOne ( array (
  8637. 'select' => 'username',
  8638. 'where' => ' sid=' . $key,
  8639. 'asArray' => true
  8640. ) );
  8641. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8642. }
  8643. $html .= '</tbody></table>';
  8644. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8645. foreach ( $rinfo ['executeCopy'] as $value ) {
  8646. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8647. }
  8648. $html .= '</tbody></table>';
  8649. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8650. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8651. </tr></table>';
  8652. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8653. echo json_encode ( array (
  8654. 'status' => 1,
  8655. 'html' => $html
  8656. ) );
  8657. die ();
  8658. }
  8659. /**
  8660. * 删除附件
  8661. */
  8662. function ajaxRemEnclousur() {
  8663. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8664. if (empty ( $key ))
  8665. echo json_encode ( array (
  8666. 'status' => 2
  8667. ) );
  8668. Doo::loadModel ( 'enclosur' );
  8669. $enclosur = new enclosur ();
  8670. $enclosur->delEnclosurByEid ( $key );
  8671. echo json_encode ( array (
  8672. 'status' => 1
  8673. ) );
  8674. }
  8675. function remittance() {
  8676. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8677. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8678. Doo::loadModel ( 'receipt' );
  8679. $receipt = new receipt ();
  8680. Doo::loadModel ( 'staff' );
  8681. $staff = new staff ();
  8682. $dateCondition = " and Year(pastDate) =" . $year;
  8683. if (! empty ( $month ))
  8684. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8685. // get Receipt By verifyID status 1
  8686. $receiptList = $receipt->find ( array (
  8687. 'select' => 'sum(sum) as sum,staff,pastDate',
  8688. 'where' => ' status=1' . $dateCondition,
  8689. 'desc' => 'pastDate',
  8690. 'groupby' => 'staff,pastDate',
  8691. 'asArray' => true
  8692. ) );
  8693. $dateList = $receipt->find ( array (
  8694. 'select' => 'pastDate,verifyStaff',
  8695. 'where' => ' status=1' . $dateCondition,
  8696. 'desc' => 'pastDate',
  8697. 'groupby' => 'pastDate',
  8698. 'asArray' => true
  8699. ) );
  8700. $dataList = array ();
  8701. foreach ( $dateList as $d => $a ) {
  8702. $dataList [$a ['pastDate']] = array ();
  8703. $daySum = 0;
  8704. foreach ( $receiptList as $key => $value ) {
  8705. if ($a ['pastDate'] == $value ['pastDate']) {
  8706. $oderList = $receipt->find ( array (
  8707. 'select' => 'receiptOrder',
  8708. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8709. 'asArray' => true
  8710. ) );
  8711. $list = array ();
  8712. $html = "";
  8713. foreach ( $oderList as $v ) {
  8714. array_push ( $list, $v ['receiptOrder'] );
  8715. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8716. }
  8717. $receiptList [$key] ['receiptOrder'] = $html;
  8718. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8719. $sinfo = $staff->getOne ( array (
  8720. 'select' => 'username ',
  8721. 'where' => ' sid=' . $value ['staff'],
  8722. 'asArray' => true
  8723. ) );
  8724. $receiptList [$key] ['username'] = $sinfo ['username'];
  8725. $daySum += $value ['sum'];
  8726. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8727. }
  8728. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8729. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8730. }
  8731. }
  8732. // print_r($dataList);
  8733. $data ['dataList'] = $dataList;
  8734. $mothHtml = "";
  8735. for($i = 1; $i <= 12; $i ++) {
  8736. if ($month == $i)
  8737. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8738. else
  8739. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8740. }
  8741. $data ['year'] = $year;
  8742. $data ['mothHtml'] = $mothHtml;
  8743. $data ['memu'] = "receipt";
  8744. $data ['staff'] = $this->staff;
  8745. $data ['receiptMemu'] = 'approval';
  8746. $data ['verifyId'] = $this->verifyId;
  8747. $data ['executeId'] = $this->executeId;
  8748. $this->render ( "/admin/saeaReportListPay", $data );
  8749. }
  8750. /**
  8751. * 金额调整,提高稳定性
  8752. * @return string
  8753. */
  8754. function revocationAdjustment() {
  8755. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8756. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8757. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8758. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8759. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8760. Doo::loadClass ( 'XDeode' );
  8761. $XDeode = new XDeode ( 5 );
  8762. Doo::loadModel ( 'receipt' );
  8763. $receipt = new receipt ();
  8764. $sid = $XDeode->decode ( $sidKey );
  8765. $rid = $XDeode->decode ( $ridKey );
  8766. $reviseKey = $XDeode->decode ( $reviseKey );
  8767. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8768. die ( 'illegal request' );
  8769. $receiptDetail = $receipt->getOne ( array (
  8770. 'where' => 'rid=' . $rid,
  8771. 'asArray' => true
  8772. ) );
  8773. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8774. die ( 'illegal request' );
  8775. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8776. if (! isset ( $reviseDetail [$reviseKey] ))
  8777. die ( 'illegal request' );
  8778. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8779. unset ( $reviseDetail [$reviseKey] );
  8780. $revisePrice = 0;
  8781. foreach ( $reviseDetail as $key => $value ) {
  8782. $revisePrice += $value ['price'];
  8783. }
  8784. $reviseDetailString = json_encode ( $reviseDetail );
  8785. $receipt->reviseDetail = $reviseDetailString;
  8786. $receipt->sum = $receiptDetail ['sum'] - $price;
  8787. $receipt->revisePrice = $revisePrice;
  8788. $receipt->update ( array (
  8789. 'where' => 'rid=' . $rid
  8790. ) );
  8791. return '/receiptburEdi/' . $rid;
  8792. } else
  8793. die ( 'illegal request2' );
  8794. }
  8795. function updateApprovalReceipt() {
  8796. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8797. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8798. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8799. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8800. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8801. if (! empty ( $rid )) {
  8802. Doo::loadModel ( "verify" );
  8803. $verify = new verify ();
  8804. Doo::loadModel ( "receiptDetail" );
  8805. $receiptDetailObj = new receiptDetail ();
  8806. Doo::loadModel ( "itemStatistics" );
  8807. Doo::loadModel ( "statistics" );
  8808. $statistics = new statistics ();
  8809. $itemStatistics = new itemStatistics ();
  8810. Doo::loadModel ( "receipt" );
  8811. $receipt = new receipt ();
  8812. $receiptDetail = $receipt->getOne ( array (
  8813. 'where' => 'rid=' . $rid . ' and status=2 ',
  8814. 'asArray' => true
  8815. ) );
  8816. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8817. $nsflag = true;
  8818. foreach ( $nslist as $value ) {
  8819. if ($value == $this->staff ['0'] ['sid']) {
  8820. $nsflag = false;
  8821. break;
  8822. }
  8823. }
  8824. if (empty ( $receiptDetail ) || $nsflag)
  8825. return "/approvalExpenses/pendApproval";
  8826. $verifyDetail = $verify->getOne ( array (
  8827. 'where' => ' vid =' . $receiptDetail ['verify'],
  8828. 'asArray' => true
  8829. ) );
  8830. $verifyString = $verifyDetail ['staff'];
  8831. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8832. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8833. if (empty ( $opinion )) {
  8834. if ($status == 3)
  8835. $opinion = "终止";
  8836. else
  8837. $opinion = "同意支付";
  8838. }
  8839. $nowStaff = 0;
  8840. $nowStaffList = array ();
  8841. if (empty ( $verifyStaff )) {
  8842. // 还需加入是否已经进入角色审批
  8843. if ($verifyDetail [0] [1] == 'ROLE') {
  8844. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8845. foreach ( $vStaffString as $key => $value ) {
  8846. $staffK = explode ( "_", $value );
  8847. if ($staffK [0] != $this->staff [0] ['sid'])
  8848. array_push ( $nowStaffList, $staffK [0] );
  8849. }
  8850. // print_r($verifyDetail);
  8851. // die;
  8852. if (! empty ( $nowStaffList )) {
  8853. $nowStaff = implode ( ',', $nowStaffList );
  8854. $verifyStaff = array (
  8855. $this->staff [0] ['sid'] . "_R" => array (
  8856. 'date' => date ( 'Y-m-d' ),
  8857. 'opinion' => $opinion,
  8858. 'status' => $status,
  8859. 'nextStaff' => $verifyDetail [0] [0],
  8860. 'ROLE' => 1
  8861. )
  8862. );
  8863. } else {
  8864. $nowStaff = $verifyDetail [1] [0];
  8865. $verifyStaff = array (
  8866. $this->staff [0] ['sid'] . "_R" => array (
  8867. 'date' => date ( 'Y-m-d' ),
  8868. 'opinion' => $opinion,
  8869. 'status' => $status,
  8870. 'nextStaff' => $verifyDetail [1] [0]
  8871. )
  8872. );
  8873. }
  8874. } else {
  8875. if ($verifyDetail [1] [1] == 'ROLE') {
  8876. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8877. // echo "dd";
  8878. foreach ( $vStaffString as $key => $value ) {
  8879. $staffK = explode ( "_", $value );
  8880. array_push ( $nowStaffList, $staffK [0] );
  8881. }
  8882. $nowStaff = implode ( ',', $nowStaffList );
  8883. $verifyStaff = array (
  8884. $this->staff [0] ['sid'] => array (
  8885. 'date' => date ( 'Y-m-d' ),
  8886. 'opinion' => $opinion,
  8887. 'status' => $status,
  8888. 'nextStaff' => $verifyDetail [1] [0],
  8889. 'ROLE' => 1
  8890. )
  8891. );
  8892. } else {
  8893. $nowStaff = $verifyDetail [1] [0];
  8894. $verifyStaff = array (
  8895. $this->staff [0] ['sid'] => array (
  8896. 'date' => date ( 'Y-m-d' ),
  8897. 'opinion' => $opinion,
  8898. 'status' => $status,
  8899. 'nextStaff' => $verifyDetail [1] [0]
  8900. )
  8901. );
  8902. }
  8903. }
  8904. if ($status == 3)
  8905. $verifyStaff = array (
  8906. 'final' => $status,
  8907. $this->staff [0] ['sid'] => array (
  8908. 'date' => date ( 'Y-m-d' ),
  8909. 'opinion' => $opinion,
  8910. 'status' => $status
  8911. )
  8912. );
  8913. $vStaffString = json_encode ( $verifyStaff );
  8914. $receipt->nowStaff = $nowStaff;
  8915. $receipt->verifyStaff = $vStaffString;
  8916. } else {
  8917. $VS = end ( $verifyStaff );
  8918. // 非角色审批
  8919. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8920. $nextStaff = 0;
  8921. $roleSTF = false;
  8922. foreach ( $verifyDetail as $key => $value ) {
  8923. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8924. if (isset ( $verifyDetail [$key + 1] )) {
  8925. $nextStaff = $verifyDetail [$key + 1] [0];
  8926. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8927. $roleSTF = true;
  8928. }
  8929. break;
  8930. }
  8931. }
  8932. if (! $roleSTF) {
  8933. $nowStaff = $nextStaff;
  8934. $verifyStaff [$this->staff [0] ['sid']] = array (
  8935. 'date' => date ( 'Y-m-d' ),
  8936. 'opinion' => $opinion,
  8937. 'status' => $status,
  8938. 'nextStaff' => $nextStaff
  8939. );
  8940. } else {
  8941. // 获取角色下的所有用户ID
  8942. $nowStaffList = array ();
  8943. foreach ( $verifyDetail as $vfk ) {
  8944. if ($vfk [1] == 'ROLE') {
  8945. $vStaffString = json_decode ( $vfk [3] );
  8946. foreach ( $vStaffString as $key => $value ) {
  8947. $staffK = explode ( "_", $value );
  8948. array_push ( $nowStaffList, $staffK [0] );
  8949. }
  8950. }
  8951. }
  8952. $nowStaff = implode ( ',', $nowStaffList );
  8953. $verifyStaff [$this->staff [0] ['sid']] = array (
  8954. 'date' => date ( 'Y-m-d' ),
  8955. 'opinion' => $opinion,
  8956. 'status' => $status,
  8957. 'nextStaff' => $nextStaff,
  8958. 'ROLE' => 0
  8959. );
  8960. }
  8961. if ($status == 3) {
  8962. $verifyStaff ['final'] = $status;
  8963. $verifyStaff [$this->staff [0] ['sid']] = array (
  8964. 'date' => date ( 'Y-m-d' ),
  8965. 'opinion' => $opinion,
  8966. 'status' => $status
  8967. );
  8968. }
  8969. $vStaffString = json_encode ( $verifyStaff );
  8970. $receipt->nowStaff = $nowStaff;
  8971. $receipt->verifyStaff = $vStaffString;
  8972. }
  8973. // 角色审批
  8974. if (isset ( $VS ['ROLE'] )) {
  8975. // 找出角色人 当前审批角色组
  8976. $verifyJSStaff = array ();
  8977. $nowStaffList2 = array ();
  8978. foreach ( $verifyDetail as $key => $value ) {
  8979. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8980. $verifyJSStaff = json_decode ( $value [3] );
  8981. foreach ( $verifyJSStaff as $m ) {
  8982. $staffK = explode ( "_", $m );
  8983. array_push ( $nowStaffList2, $staffK [0] );
  8984. }
  8985. // print_r($nowStaffList2);
  8986. }
  8987. }
  8988. $RoleVerifyStaff = array ();
  8989. foreach ( $verifyStaff as $key => $value ) {
  8990. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8991. foreach ( $nowStaffList2 as $m ) {
  8992. if ($key == $m . "_R")
  8993. $RoleVerifyStaff [$key] = $value;
  8994. }
  8995. }
  8996. }
  8997. // print_r($verifyStaff);
  8998. // print_r($nowStaffList2);
  8999. // print_r($RoleVerifyStaff);
  9000. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9001. // print_r($verifyJSStaff);
  9002. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9003. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9004. // 下一个审批人ID
  9005. $nextStaff = 0;
  9006. $falg = false;
  9007. foreach ( $verifyDetail as $key => $value ) {
  9008. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9009. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9010. $falg = true;
  9011. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9012. $nowStaffList = array ();
  9013. foreach ( $vStaffString as $v ) {
  9014. $staffK = explode ( "_", $v );
  9015. array_push ( $nowStaffList, $staffK [0] );
  9016. }
  9017. $nowStaff = implode ( ',', $nowStaffList );
  9018. $nextStaff = $verifyDetail [$key + 1] [0];
  9019. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9020. $nextStaff = $verifyDetail [$key + 1] [0];
  9021. $nowStaff = $nextStaff;
  9022. } else
  9023. $nowStaff = '';
  9024. break;
  9025. }
  9026. }
  9027. if ($falg)
  9028. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9029. 'date' => date ( 'Y-m-d' ),
  9030. 'opinion' => $opinion,
  9031. 'status' => $status,
  9032. 'nextStaff' => $nextStaff,
  9033. 'ROLE' => 1
  9034. );
  9035. else
  9036. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9037. 'date' => date ( 'Y-m-d' ),
  9038. 'opinion' => $opinion,
  9039. 'status' => $status,
  9040. 'nextStaff' => $nextStaff
  9041. );
  9042. // print_r($verifyStaff);
  9043. // echo $nowStaff;die;
  9044. } else { // 进入下一个角色或者审批人
  9045. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9046. //
  9047. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9048. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9049. 'date' => date ( 'Y-m-d' ),
  9050. 'opinion' => $opinion,
  9051. 'status' => $status,
  9052. 'nextStaff' => $VS ['nextStaff'],
  9053. 'ROLE' => 1
  9054. );
  9055. // print_r($verifyStaff);
  9056. // die;
  9057. }
  9058. if ($status == 3) {
  9059. $verifyStaff ['final'] = $status;
  9060. $verifyStaff [$this->staff [0] ['sid']] = array (
  9061. 'date' => date ( 'Y-m-d' ),
  9062. 'opinion' => $opinion,
  9063. 'status' => $status
  9064. );
  9065. }
  9066. $vStaffString = json_encode ( $verifyStaff );
  9067. $receipt->verifyStaff = $vStaffString;
  9068. $receipt->nowStaff = $nowStaff;
  9069. // die;
  9070. // }
  9071. // print_r($verifyStaff);
  9072. // die;
  9073. }
  9074. // print_r($verifyStaff);die;
  9075. }
  9076. // print_r($verifyDetail);
  9077. $roleKey = 0;
  9078. $roleId = 0;
  9079. $verifyDetailCopy = array ();
  9080. foreach ( $verifyDetail as $k => $v ) {
  9081. if ($v [1] == 'ROLE') {
  9082. $roleId = $v [0];
  9083. $roleVerify = json_decode ( $v [3], true );
  9084. $roleKey = $k;
  9085. $roleArray = array ();
  9086. foreach ( $roleVerify as $o => $p ) {
  9087. $staffID = explode ( '_', $p );
  9088. $exp = array (
  9089. 0 => $staffID [0],
  9090. 1 => $staffID [1]
  9091. );
  9092. array_push ( $roleArray, $exp );
  9093. }
  9094. $verifyDetailCopy [$v [0]] = $roleArray;
  9095. }
  9096. }
  9097. // print_r($verifyDetail);
  9098. foreach ( $verifyDetailCopy as $k => $v ) {
  9099. foreach ( $verifyDetail as $m => $n ) {
  9100. if ($n [0] == $k) {
  9101. array_splice ( $verifyDetail, $m, 1, $v );
  9102. }
  9103. }
  9104. }
  9105. // die;
  9106. // if (!empty($roleArray))
  9107. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9108. // echo $roleId;
  9109. // print_r($verifyStaff);
  9110. // print_r($verifyDetail);
  9111. // die;
  9112. Doo::loadModel ( "receiptLog" );
  9113. $receiptLog = new receiptLog ();
  9114. // 审批日志
  9115. if (! isset ( $verifyStaff ['final'] )) {
  9116. if (! empty ( $roleId )) {
  9117. Doo::loadModel ( "role" );
  9118. $role = new role ();
  9119. $roleInfo = $role->getOne ( array (
  9120. 'where' => 'rid=' . $roleId,
  9121. 'asArray' => true
  9122. ) );
  9123. $receiptLog->rolename = $roleInfo ['name'];
  9124. }
  9125. $receiptLog->username = $this->staff [0] ['username'];
  9126. $receiptLog->uid = $this->staff [0] ['sid'];
  9127. $receiptLog->date = date ( "Y-m-d" );
  9128. $receiptLog->opinion = $opinion;
  9129. $receiptLog->img = $this->staff [0] ['avatar'];
  9130. $receiptLog->status = 1;
  9131. $receiptLog->rid = $rid;
  9132. $receiptLog->insert ();
  9133. }
  9134. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9135. $receipt->verifyBreakup = $verifyString;
  9136. $receipt->status = 3;
  9137. $receiptDetailObj->status = 3;
  9138. $receiptDetailObj->update ( array (
  9139. 'where' => 'rid=' . $rid
  9140. ) );
  9141. if (! empty ( $roleId )) {
  9142. Doo::loadModel ( "role" );
  9143. $role = new role ();
  9144. $roleInfo = $role->getOne ( array (
  9145. 'where' => 'rid=' . $roleId,
  9146. 'asArray' => true
  9147. ) );
  9148. $receiptLog->rolename = $roleInfo ['name'];
  9149. }
  9150. $receiptLog->username = $this->staff [0] ['username'];
  9151. $receiptLog->uid = $this->staff [0] ['sid'];
  9152. $receiptLog->date = date ( "Y-m-d" );
  9153. $receiptLog->opinion = $opinion;
  9154. $receiptLog->img = $this->staff [0] ['avatar'];
  9155. $receiptLog->status = 3;
  9156. $receiptLog->rid = $rid;
  9157. $receiptLog->insert ();
  9158. //删除行程单
  9159. Doo::loadModel ( 'itinerary' );
  9160. $itinerary = new itinerary ();
  9161. $itinerary->delete ( array (
  9162. 'where' => 'rid="' . $rid . '"'
  9163. ) );
  9164. // 微信企业号通知
  9165. $this->setWXMsg ( $rid, 3 );
  9166. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9167. $receipt->status = 1;
  9168. $reviseSum = 0;
  9169. $receipt->verifyBreakup = $verifyString;
  9170. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9171. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9172. foreach ( $reviseDetail as $key => $value ) {
  9173. $receiptDetailObj = new receiptDetail ();
  9174. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9175. $receiptDetailObj->item = $value ['description'];
  9176. $receiptDetailObj->itemCategory = "报销金额调整";
  9177. $receiptDetailObj->price = $value ['price'];
  9178. $receiptDetailObj->date = $receiptDetail ['date'];
  9179. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9180. $receiptDetailObj->rid = $rid;
  9181. $receiptDetailObj->status = 1;
  9182. $receiptDetailObj->insert ();
  9183. $reviseSum += $value ['price'];
  9184. }
  9185. $itemStatistics = new itemStatistics ();
  9186. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9187. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9188. $itemStatistics->price = $reviseSum;
  9189. $itemStatistics->itemCategory = "报销金额调整";
  9190. $itemStatistics->date = $receiptDetail ['date'];
  9191. $itemStatistics->insert ();
  9192. }
  9193. $receiptDetailObj = new receiptDetail ();
  9194. $receiptDetailObj->status = 1;
  9195. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9196. $receiptDetailObj->update ( array (
  9197. 'where' => 'rid=' . $rid
  9198. ) );
  9199. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9200. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9201. $stat = $statistics->getOne ( array (
  9202. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9203. 'asArray' => true
  9204. ) );
  9205. if (empty ( $stat )) {
  9206. $statistics->date = $receiptDetail ['date'];
  9207. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9208. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9209. $statistics->agPrice = $receiptDetail ['sum'];
  9210. $statistics->rePrice = $reviseSum;
  9211. $statistics->insert ();
  9212. } else {
  9213. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9214. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9215. $statistics->update ( array (
  9216. 'where' => 'sid=' . $stat ['sid']
  9217. ) );
  9218. }
  9219. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9220. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9221. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9222. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9223. if ($key == "agencySum") {
  9224. $iStatistics = $itemStatistics->getOne ( array (
  9225. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9226. 'asArray' => true
  9227. ) );
  9228. if (empty ( $iStatistics )) {
  9229. $itemStatistics->cid = $receiptDetail ['cid'];
  9230. ;
  9231. $itemStatistics->staff = $receiptDetail ['staff'];
  9232. $itemStatistics->price = $value;
  9233. $itemStatistics->itemCategory = $this->AGENCY;
  9234. $itemStatistics->date = $receiptDetail ['date'];
  9235. $itemStatistics->insert ();
  9236. } else {
  9237. if (! empty ( $value )) {
  9238. $itemStatistics->price = $value + $iStatistics ['price'];
  9239. $itemStatistics->update ( array (
  9240. 'where' => 'sid=' . $iStatistics ['sid']
  9241. ) );
  9242. }
  9243. }
  9244. } elseif ($key == "travelSum") {
  9245. $iStatistics = $itemStatistics->getOne ( array (
  9246. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9247. 'asArray' => true
  9248. ) );
  9249. if (empty ( $iStatistics )) {
  9250. $itemStatistics->cid = $receiptDetail ['cid'];
  9251. $itemStatistics->staff = $receiptDetail ['staff'];
  9252. $itemStatistics->price = $value;
  9253. $itemStatistics->itemCategory = $this->TRAVEL;
  9254. $itemStatistics->date = $receiptDetail ['date'];
  9255. $itemStatistics->insert ();
  9256. } else {
  9257. if (! empty ( $value )) {
  9258. $itemStatistics->price = $value + $iStatistics ['price'];
  9259. $itemStatistics->update ( array (
  9260. 'where' => 'sid=' . $iStatistics ['sid']
  9261. ) );
  9262. }
  9263. }
  9264. } elseif ($key == "trainSum") {
  9265. $iStatistics = $itemStatistics->getOne ( array (
  9266. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9267. 'asArray' => true
  9268. ) );
  9269. if (empty ( $iStatistics )) {
  9270. $itemStatistics->cid = $receiptDetail ['cid'];
  9271. $itemStatistics->staff = $receiptDetail ['staff'];
  9272. $itemStatistics->price = $value;
  9273. $itemStatistics->itemCategory = $this->TRAIN;
  9274. $itemStatistics->date = $receiptDetail ['date'];
  9275. $itemStatistics->insert ();
  9276. } else {
  9277. if (! empty ( $value )) {
  9278. $itemStatistics->price = $value + $iStatistics ['price'];
  9279. $itemStatistics->update ( array (
  9280. 'where' => 'sid=' . $iStatistics ['sid']
  9281. ) );
  9282. }
  9283. }
  9284. } elseif ($key == "otherSum") {
  9285. $iStatistics = $itemStatistics->getOne ( array (
  9286. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9287. 'asArray' => true
  9288. ) );
  9289. if (empty ( $iStatistics )) {
  9290. $itemStatistics->cid = $receiptDetail ['cid'];
  9291. $itemStatistics->staff = $receiptDetail ['staff'];
  9292. $itemStatistics->price = $value;
  9293. $itemStatistics->itemCategory = $this->OTHER;
  9294. $itemStatistics->date = $receiptDetail ['date'];
  9295. $itemStatistics->insert ();
  9296. } else {
  9297. if (! empty ( $value )) {
  9298. $itemStatistics->price = $value + $iStatistics ['price'];
  9299. $itemStatistics->update ( array (
  9300. 'where' => 'sid=' . $iStatistics ['sid']
  9301. ) );
  9302. }
  9303. }
  9304. }
  9305. }
  9306. $receipt->pastDate = date ( "Y-m-d" );
  9307. // 微信企业号通知
  9308. $this->setWXMsg ( $rid, 1 );
  9309. }
  9310. //是否有流水
  9311. Doo::loadModel ( 'wasteBook' );
  9312. $wasteBook = new wasteBook ();
  9313. $accountType=3;
  9314. if ($receiptDetail['Rtype']==1){
  9315. $accountType=2;
  9316. }elseif($receiptDetail['Rtype']==2){
  9317. $accountType=4;
  9318. }
  9319. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9320. if (empty($wbDetail)){
  9321. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9322. $receipt->amount = $rsum;//$amount;
  9323. }
  9324. $receipt->update ( array (
  9325. 'where' => ' rid = ' . $rid
  9326. ) );
  9327. // 进入下一条审批费用新加需求
  9328. $vidList = array ();
  9329. $verifyDetail = $verify->find ( array (
  9330. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9331. 'asArray' => true
  9332. ) );
  9333. foreach ( $verifyDetail as $key => $value ) {
  9334. array_push ( $vidList, $value ['vid'] );
  9335. }
  9336. $vid = implode ( ",", $vidList );
  9337. if (empty ( $verifyDetail ))
  9338. $vid = 0;
  9339. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9340. $receipt = new receipt ();
  9341. $rd = $receipt->getOne ( array (
  9342. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9343. 'asc' => 'rid',
  9344. 'asArray' => true
  9345. ) );
  9346. if (empty ( $rd )) {
  9347. return '/approvalExpenses/pendApproval';
  9348. }
  9349. if ($rd ['Rtype'] == 1) {
  9350. if ($rd ['isBK'] == 1) {
  9351. return '/receiptburEdi/' . $rd ['rid'];
  9352. } else {
  9353. return '/expensesEdi/' . $rd ['rid'];
  9354. }
  9355. } elseif ($rd ['Rtype'] == 2) {
  9356. return '/remitApproval/' . $rd ['rid'];
  9357. } else {
  9358. return '/receiptburEdi/' . $rd ['rid'];
  9359. }
  9360. // return "/approvalExpenses/pendApproval";
  9361. }
  9362. }
  9363. function expensesRetreats() {
  9364. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9365. if (! empty ( $rid )) {
  9366. // 操作记录
  9367. Doo::loadModel ( "receipt" );
  9368. $receipt = new receipt ();
  9369. Doo::loadModel ( "receiptLog" );
  9370. $receiptLog = new receiptLog ();
  9371. Doo::loadModel ( "verify" );
  9372. $verify = new verify ();
  9373. $receiptInfo = $receipt->getOne ( array (
  9374. 'where' => 'rid=' . $rid,
  9375. 'asArray' => true
  9376. ) );
  9377. $vr = $verify->getOne ( array (
  9378. 'where' => 'vid=' . $receiptInfo ['verify'],
  9379. 'asArray' => true
  9380. ) );
  9381. $jd = json_decode ( $vr ['staff'] );
  9382. $roleId = 0;
  9383. foreach ( $jd as $key => $value ) {
  9384. if ($value [1] == 'ROLE') {
  9385. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9386. if ($pos !== false) {
  9387. $roleId = $value [0];
  9388. }
  9389. }
  9390. }
  9391. // 审批日志
  9392. // echo $roleId;die;
  9393. if (! empty ( $roleId )) {
  9394. Doo::loadModel ( "role" );
  9395. $role = new role ();
  9396. $roleInfo = $role->getOne ( array (
  9397. 'where' => 'rid=' . $roleId,
  9398. 'asArray' => true
  9399. ) );
  9400. $receiptLog->rolename = $roleInfo ['name'];
  9401. }
  9402. $receiptLog->username = $this->staff [0] ['username'];
  9403. $receiptLog->uid = $this->staff [0] ['sid'];
  9404. $receiptLog->date = date ( "Y-m-d" );
  9405. $receiptLog->opinion = '撤回';
  9406. $receiptLog->img = $this->staff [0] ['avatar'];
  9407. $receiptLog->status = 4;
  9408. $receiptLog->rid = $rid;
  9409. $receiptLog->insert ();
  9410. $receipt->status = 4;
  9411. $receipt->update ( array (
  9412. 'where' => 'rid=' . $rid
  9413. ) );
  9414. // 微信企业号通知
  9415. $this->setWXMsg ( $rid, 2 );
  9416. }
  9417. // echo "ddd";
  9418. return '/approvalExpenses/pendApproval';
  9419. }
  9420. function updateCheReceipt() {
  9421. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9422. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9423. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9424. if (! empty ( $rid )) {
  9425. // 操作记录
  9426. Doo::loadModel ( "receipt" );
  9427. $receipt = new receipt ();
  9428. Doo::loadModel ( "receiptLog" );
  9429. $receiptLog = new receiptLog ();
  9430. Doo::loadModel ( "verify" );
  9431. $verify = new verify ();
  9432. $receiptInfo = $receipt->getOne ( array (
  9433. 'where' => 'rid=' . $rid . ' and status=2',
  9434. 'asArray' => true
  9435. ) );
  9436. if (empty ( $receiptInfo )) {
  9437. echo json_encode ( array (
  9438. 'status' => 2
  9439. ) );
  9440. die ();
  9441. }
  9442. $vr = $verify->getOne ( array (
  9443. 'where' => 'vid=' . $receiptInfo ['verify'],
  9444. 'asArray' => true
  9445. ) );
  9446. $jd = json_decode ( $vr ['staff'] );
  9447. $roleId = 0;
  9448. foreach ( $jd as $key => $value ) {
  9449. if ($value [1] == 'ROLE') {
  9450. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9451. if ($pos !== false) {
  9452. $roleId = $value [0];
  9453. }
  9454. }
  9455. }
  9456. // 审批日志
  9457. // echo $roleId;die;
  9458. if (! empty ( $roleId )) {
  9459. Doo::loadModel ( "role" );
  9460. $role = new role ();
  9461. $roleInfo = $role->getOne ( array (
  9462. 'where' => 'rid=' . $roleId,
  9463. 'asArray' => true
  9464. ) );
  9465. $receiptLog->rolename = $roleInfo ['name'];
  9466. }
  9467. $receiptLog->username = $this->staff [0] ['username'];
  9468. $receiptLog->uid = $this->staff [0] ['sid'];
  9469. $receiptLog->date = date ( "Y-m-d" );
  9470. $receiptLog->opinion = $opinion;
  9471. $receiptLog->img = $this->staff [0] ['avatar'];
  9472. $receiptLog->status = 4;
  9473. $receiptLog->rid = $rid;
  9474. $receiptLog->insert ();
  9475. $receipt->status = 4;
  9476. $receipt->update ( array (
  9477. 'where' => 'rid=' . $rid
  9478. ) );
  9479. // 微信企业号通知
  9480. $this->setWXMsg ( $rid, 2 );
  9481. echo json_encode ( array (
  9482. 'status' => 1
  9483. ) );
  9484. // Header("HTTP/1.1 303 See Other");
  9485. // Header("Location: /approvalExpenses/pendApproval");
  9486. die ();
  9487. }
  9488. echo json_encode ( array (
  9489. 'status' => 2
  9490. ) );
  9491. die ();
  9492. // echo "ddd";
  9493. // return '/saeaBorad';
  9494. }
  9495. function revisePrice() {
  9496. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9497. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9498. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9499. // echo $price;die;
  9500. if (! empty ( $rid )) {
  9501. Doo::loadModel ( "receipt" );
  9502. $receipt = new receipt ();
  9503. $receiptDetail = $receipt->getOne ( array (
  9504. 'where' => 'rid=' . $rid . ' and status=2 ',
  9505. 'asArray' => true
  9506. ) );
  9507. if (empty ( $receiptDetail ))
  9508. die ( 'illegal request' );
  9509. $reviseDetail = array ();
  9510. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9511. array_push ( $reviseDetail, array (
  9512. 'sid' => $this->staff [0] ['sid'],
  9513. 'name' => $this->staff [0] ['username'],
  9514. 'description' => $description,
  9515. 'price' => $price
  9516. ) );
  9517. $reviseDetailString = json_encode ( $reviseDetail );
  9518. $receipt->reviseDetail = $reviseDetailString;
  9519. $receipt->revisePrice = $price;
  9520. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9521. } else {
  9522. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9523. array_push ( $reviseDetail, array (
  9524. 'sid' => $this->staff [0] ['sid'],
  9525. 'name' => $this->staff [0] ['username'],
  9526. 'description' => $description,
  9527. 'price' => $price
  9528. ) );
  9529. $reviseDetailString = json_encode ( $reviseDetail );
  9530. $receipt->reviseDetail = $reviseDetailString;
  9531. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9532. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9533. }
  9534. $receipt->update ( array (
  9535. 'where' => 'rid=' . $rid
  9536. ) );
  9537. if ($receiptDetail ['Rtype'] == 1) {
  9538. if ($receiptDetail ['isBK'] == 1) {
  9539. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9540. }
  9541. } elseif ($receiptDetail ['Rtype'] == 2) {
  9542. } else {
  9543. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9544. }
  9545. }
  9546. die ( 'illegal request' );
  9547. }
  9548. function personalCollect() {
  9549. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9550. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9551. $this->showCache ( $path );
  9552. Doo::loadModel ( "receiptDetail" );
  9553. Doo::loadModel ( "itemStatistics" );
  9554. Doo::loadModel ( 'statistics' );
  9555. $statistics = new statistics ();
  9556. $itemStatistics = new itemStatistics ();
  9557. $receiptDetail = new receiptDetail ();
  9558. $receiptCollectList = $receiptDetail->find ( array (
  9559. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9560. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9561. 'groupby' => 'itemCategory,Month(date)',
  9562. 'asArray' => true
  9563. ) );
  9564. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9565. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9566. 'asArray' => true
  9567. ) );
  9568. // create collect html
  9569. $collectArray = array (
  9570. '日常相关费用' => array (),
  9571. '差旅相关费用' => array (),
  9572. '培训班费用' => array (),
  9573. '其他' => array ()
  9574. );
  9575. $adjustment = array ();
  9576. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9577. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9578. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9579. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9580. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9581. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9582. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9583. array_push ( $collectArray ['其他'], $collectHtml );
  9584. $data ['collectArray'] = $collectArray;
  9585. // statistics html
  9586. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9587. if (empty ( $stList ))
  9588. $stList = array (
  9589. 'rePrice' => 0,
  9590. 'agPrice' => 0
  9591. );
  9592. $data ['stList'] = array (
  9593. 'rePrice' => $stList ['rePrice'],
  9594. 'agPrice' => $stList ['agPrice'],
  9595. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9596. );
  9597. // Adjustment price html
  9598. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9599. array_push ( $adjustment, $collectHtml );
  9600. $data ['adjustment'] = $adjustment;
  9601. // total price html
  9602. $collectHtml = "";
  9603. $total = 0;
  9604. for($i = 1; $i <= 12; $i ++) {
  9605. $sumPrice = 0;
  9606. foreach ( $receiptCollectList as $key => $value ) {
  9607. if ($value ['month'] == $i) {
  9608. $sumPrice += $value ['price'];
  9609. }
  9610. }
  9611. if ($sumPrice == 0)
  9612. $collectHtml .= '<td class="taR">-</td>';
  9613. else
  9614. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9615. $total += $sumPrice;
  9616. }
  9617. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9618. $data ['totalPrice'] = $collectHtml;
  9619. $dateHtml = "";
  9620. $now = date ( "Y" );
  9621. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9622. if ($YEARD <= $now) {
  9623. $dateHtml .= '<option ';
  9624. if ($year == $YEARD) {
  9625. $dateHtml .= 'selected ';
  9626. }
  9627. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9628. }
  9629. }
  9630. $data ['dateHtml'] = $dateHtml;
  9631. $data ['year'] = $year;
  9632. $data ['totalYear'] = $total;
  9633. $data ['memu'] = "receipt";
  9634. $data ['staff'] = $this->staff;
  9635. $data ['receiptMemu'] = 'personalCollect';
  9636. $data ['verifyId'] = $this->verifyId;
  9637. $data ['executeId'] = $this->executeId;
  9638. // year staff status 2,4
  9639. if ($year < date ( "Y" )) {
  9640. Doo::loadModel ( 'receipt' );
  9641. $receipt = new receipt ();
  9642. $receiptList = $receipt->find ( array (
  9643. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9644. 'asArray' => true
  9645. ) );
  9646. if (empty ( $receiptList )) {
  9647. ob_start ();
  9648. $this->render ( "/admin/saea_slist_collect", $data );
  9649. $this->cacheFile ( $path );
  9650. die ();
  9651. }
  9652. }
  9653. $this->render ( "/admin/saea_slist_collect", $data );
  9654. }
  9655. function personalCollectDetail() {
  9656. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9657. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9658. $this->showCache ( $path );
  9659. Doo::loadModel ( "receiptDetail" );
  9660. Doo::loadModel ( "itemStatistics" );
  9661. Doo::loadModel ( 'statistics' );
  9662. Doo::loadModel ( 'accountItem' );
  9663. $accountItem = new accountItem ();
  9664. $statistics = new statistics ();
  9665. $itemStatistics = new itemStatistics ();
  9666. $receiptDetail = new receiptDetail ();
  9667. $receiptCollectList = $receiptDetail->find ( array (
  9668. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9669. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9670. 'groupby' => 'item,Month(date)',
  9671. 'asArray' => true
  9672. ) );
  9673. $accountList = $accountItem->find ( array (
  9674. 'asArray' => true
  9675. ) );
  9676. // create CollectDetail HTML
  9677. $collectHtml = array ();
  9678. foreach ( $accountList as $key => $value ) {
  9679. $html = "";
  9680. $asum = 0;
  9681. for($i = 1; $i <= 12; $i ++) {
  9682. $falg = true;
  9683. foreach ( $receiptCollectList as $v ) {
  9684. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9685. $asum += $v ['price'];
  9686. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9687. $falg = false;
  9688. break;
  9689. }
  9690. }
  9691. if ($falg)
  9692. $html .= '<td class="taR">-</td>';
  9693. }
  9694. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9695. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9696. }
  9697. $data ['collectHtml'] = $collectHtml;
  9698. // create Adjustment price html
  9699. $receiptCollectList = $receiptDetail->find ( array (
  9700. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9701. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9702. 'groupby' => 'itemCategory,Month(date)',
  9703. 'asArray' => true
  9704. ) );
  9705. $adjustment = array ();
  9706. $collectArray = array (
  9707. '日常相关费用' => array (),
  9708. '差旅相关费用' => array (),
  9709. '培训班费用' => array (),
  9710. '其他' => array ()
  9711. );
  9712. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9713. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9714. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9715. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9716. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9717. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9718. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9719. array_push ( $collectArray ['其他'], $collectHtml );
  9720. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9721. array_push ( $adjustment, $collectHtml );
  9722. // total price html
  9723. $collectHtml = "";
  9724. $total = 0;
  9725. for($i = 1; $i <= 12; $i ++) {
  9726. $sumPrice = 0;
  9727. foreach ( $receiptCollectList as $key => $value ) {
  9728. if ($value ['month'] == $i) {
  9729. $sumPrice += $value ['price'];
  9730. }
  9731. }
  9732. if ($sumPrice == 0)
  9733. $collectHtml .= '<td class="taR">-</td>';
  9734. else
  9735. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9736. $total += $sumPrice;
  9737. }
  9738. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9739. // statistics html
  9740. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9741. if (empty ( $stList ))
  9742. $stList = array (
  9743. 'rePrice' => 0,
  9744. 'agPrice' => 0
  9745. );
  9746. $data ['stList'] = array (
  9747. 'rePrice' => $stList ['rePrice'],
  9748. 'agPrice' => $stList ['agPrice'],
  9749. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9750. );
  9751. $data ['collectArray'] = $collectArray;
  9752. $data ['adjustment'] = $adjustment;
  9753. $data ['totalPrice'] = $collectHtml;
  9754. $data ['totalYear'] = $total;
  9755. $data ['year'] = $year;
  9756. $dateHtml = "";
  9757. $now = date ( "Y" );
  9758. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9759. if ($YEARD <= $now) {
  9760. $dateHtml .= '<option ';
  9761. if ($year == $YEARD) {
  9762. $dateHtml .= 'selected ';
  9763. }
  9764. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9765. }
  9766. }
  9767. $data ['dateHtml'] = $dateHtml;
  9768. $data ['memu'] = "receipt";
  9769. $data ['staff'] = $this->staff;
  9770. $data ['receiptMemu'] = 'personalCollect';
  9771. $data ['verifyId'] = $this->verifyId;
  9772. $data ['executeId'] = $this->executeId;
  9773. // year staff status 2,4
  9774. if ($year < date ( "Y" )) {
  9775. Doo::loadModel ( 'receipt' );
  9776. $receipt = new receipt ();
  9777. $receiptList = $receipt->find ( array (
  9778. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9779. 'asArray' => true
  9780. ) );
  9781. if (empty ( $receiptList )) {
  9782. ob_start ();
  9783. $this->render ( "/admin/saeaCollectArticles", $data );
  9784. $this->cacheFile ( $path );
  9785. die ();
  9786. }
  9787. }
  9788. $this->render ( "/admin/saeaCollectArticles", $data );
  9789. }
  9790. function companyCategoryCollect() {
  9791. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9792. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9793. $this->showCache ( $path );
  9794. Doo::loadModel ( 'L_category' );
  9795. Doo::loadModel ( 'itemStatistics' );
  9796. Doo::loadModel ( 'statistics' );
  9797. $statistics = new statistics ();
  9798. $Lcategory = new L_category ();
  9799. $itemStatistics = new itemStatistics ();
  9800. Doo::loadModel ( "receiptAuthorityManage" );
  9801. $receiptAuthorityManage = new receiptAuthorityManage ();
  9802. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9803. $cidList = array ();
  9804. foreach ( $imcStaff as $key => $value ) {
  9805. array_push ( $cidList, $value ['cid'] );
  9806. }
  9807. $cidString = implode ( ',', $cidList );
  9808. $LcategoryList = $Lcategory->find ( array (
  9809. 'where' => ' cid in (' . $cidString . ')',
  9810. 'asArray' => true
  9811. ) ); // 'staff='.$this->staff[0]['sid']." and
  9812. $itemStatisticsList = $itemStatistics->find ( array (
  9813. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9814. 'where' => " Year(date)=" . $year,
  9815. 'groupby' => 'cid,Month(date)',
  9816. 'asArray' => true
  9817. ) );
  9818. // ceatre companyCollectHtml
  9819. foreach ( $LcategoryList as $value ) {
  9820. $html = "";
  9821. $asum = 0;
  9822. for($i = 1; $i <= 12; $i ++) {
  9823. $falg = true;
  9824. foreach ( $itemStatisticsList as $v ) {
  9825. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9826. $asum += $v ['price'];
  9827. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9828. $falg = false;
  9829. break;
  9830. }
  9831. }
  9832. if ($falg)
  9833. $html .= '<td class="taR">-</td>';
  9834. }
  9835. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9836. $collectHtml [$value ['title']] = array (
  9837. 'html' => $html,
  9838. 'cid' => $value ['cid']
  9839. );
  9840. }
  9841. $data ['companyHtml'] = $collectHtml;
  9842. // total price html
  9843. $collectHtml = "";
  9844. $total = 0;
  9845. for($i = 1; $i <= 12; $i ++) {
  9846. $sumPrice = 0;
  9847. foreach ( $itemStatisticsList as $key => $value ) {
  9848. if ($value ['month'] == $i) {
  9849. $sumPrice += $value ['price'];
  9850. }
  9851. }
  9852. if ($sumPrice == 0)
  9853. $collectHtml .= '<td class="taR">-</td>';
  9854. else
  9855. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9856. $total += $sumPrice;
  9857. }
  9858. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9859. $data ['companyTotalHtml'] = $collectHtml;
  9860. $data ['total'] = $total;
  9861. // statistics html
  9862. // echo $cidString;
  9863. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9864. if (empty ( $stList ))
  9865. $stList = array (
  9866. 'rePrice' => 0,
  9867. 'agPrice' => 0
  9868. );
  9869. $data ['stList'] = array (
  9870. 'rePrice' => $stList ['rePrice'],
  9871. 'agPrice' => $stList ['agPrice'],
  9872. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9873. );
  9874. $data ['year'] = $year;
  9875. $data ['memu'] = "receipt";
  9876. $data ['staff'] = $this->staff;
  9877. $data ['receiptMemu'] = 'companyCategoryCollect';
  9878. $data ['verifyId'] = $this->verifyId;
  9879. $data ['executeId'] = $this->executeId;
  9880. $dateHtml = "";
  9881. $now = date ( "Y" );
  9882. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9883. if ($YEARD <= $now) {
  9884. $dateHtml .= '<option ';
  9885. if ($year == $YEARD) {
  9886. $dateHtml .= 'selected ';
  9887. }
  9888. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9889. }
  9890. }
  9891. $data ['dateHtml'] = $dateHtml;
  9892. // year staff status 2,4
  9893. if ($year < date ( "Y" )) {
  9894. Doo::loadModel ( 'receipt' );
  9895. $receipt = new receipt ();
  9896. $receiptList = $receipt->find ( array (
  9897. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9898. 'asArray' => true
  9899. ) );
  9900. if (empty ( $receiptList )) {
  9901. ob_start ();
  9902. $this->render ( "/admin/saeaCompanyCollect", $data );
  9903. $this->cacheFile ( $path );
  9904. die ();
  9905. }
  9906. }
  9907. $this->render ( "/admin/saeaCompanyCollect", $data );
  9908. }
  9909. function categoryCollectDetail() {
  9910. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9911. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9912. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9913. $this->showCache ( $path ); */
  9914. Doo::loadModel ( 'statistics' );
  9915. $statistics = new statistics ();
  9916. Doo::loadModel ( "receiptDetail" );
  9917. $receiptDetail = new receiptDetail ();
  9918. Doo::loadModel ( 'L_category' );
  9919. $Lcategory = new L_category ();
  9920. Doo::loadModel ( 'accountItem' );
  9921. $accountItem = new accountItem ();
  9922. Doo::loadModel ( "receiptAuthorityManage" );
  9923. $receiptAuthorityManage = new receiptAuthorityManage ();
  9924. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9925. $cidList = array ();
  9926. foreach ( $imcStaff as $key => $value ) {
  9927. array_push ( $cidList, $value ['cid'] );
  9928. }
  9929. $cidString = implode ( ',', $cidList );
  9930. $LcategoryList = $Lcategory->find ( array (
  9931. 'where' => 'cid in (' . $cidString . ')',
  9932. 'asArray' => true
  9933. ) );
  9934. if ($cid == 0) {
  9935. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9936. if ($cid == 0)
  9937. $cid = $LcategoryList [0] ['cid'];
  9938. }
  9939. $data ['LcategoryList'] = $LcategoryList;
  9940. $receiptCollectList = $receiptDetail->find ( array (
  9941. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9942. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9943. 'groupby' => 'item,Month(pastDate)',
  9944. 'asArray' => true
  9945. ) );
  9946. $accountList = $accountItem->find ( array (
  9947. 'asArray' => true
  9948. ) );
  9949. // create CollectDetail HTML
  9950. $collectHtml = array ();
  9951. foreach ( $accountList as $key => $value ) {
  9952. $html = "";
  9953. $asum = 0;
  9954. for($i = 1; $i <= 12; $i ++) {
  9955. $falg = true;
  9956. foreach ( $receiptCollectList as $v ) {
  9957. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9958. $asum += $v ['price'];
  9959. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9960. $falg = false;
  9961. break;
  9962. }
  9963. }
  9964. if ($falg)
  9965. $html .= '<td class="taR">-</td>';
  9966. }
  9967. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9968. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9969. }
  9970. $data ['collectHtml'] = $collectHtml;
  9971. // create Adjustment price html
  9972. $receiptCollectList = $receiptDetail->find ( array (
  9973. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9974. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9975. 'groupby' => 'itemCategory,Month(pastDate)',
  9976. 'asArray' => true
  9977. ) );
  9978. $adjustment = array ();
  9979. $collectArray = array (
  9980. '日常相关费用' => array (),
  9981. '差旅相关费用' => array (),
  9982. '培训班费用' => array (),
  9983. '内部培训费用'=>array(),
  9984. '其他' => array ()
  9985. );
  9986. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9987. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9988. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9989. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9990. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9991. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9992. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9993. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9994. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9995. array_push ( $collectArray ['其他'], $collectHtml );
  9996. $data ['collectArray'] = $collectArray;
  9997. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9998. array_push ( $adjustment, $collectHtml );
  9999. $data ['adjustment'] = $adjustment;
  10000. // total price html
  10001. $collectHtml = "";
  10002. $total = 0;
  10003. for($i = 1; $i <= 12; $i ++) {
  10004. $sumPrice = 0;
  10005. foreach ( $receiptCollectList as $key => $value ) {
  10006. if ($value ['month'] == $i) {
  10007. $sumPrice += $value ['price'];
  10008. }
  10009. }
  10010. if ($sumPrice == 0)
  10011. $collectHtml .= '<td class="taR">-</td>';
  10012. else
  10013. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10014. $total += $sumPrice;
  10015. }
  10016. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10017. // statistics html
  10018. $stList = $statistics->statisticsByCid ( $year, $cid );
  10019. if (empty ( $stList ))
  10020. $stList = array (
  10021. 'rePrice' => 0,
  10022. 'agPrice' => 0
  10023. );
  10024. $data ['stList'] = array (
  10025. 'rePrice' => $stList ['rePrice'],
  10026. 'agPrice' => $stList ['agPrice'],
  10027. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10028. );
  10029. $data ['totalYear'] = $total;
  10030. $data ['year'] = $year;
  10031. $data ['cid'] = $cid;
  10032. $data ['memu'] = "receipt";
  10033. $data ['staff'] = $this->staff;
  10034. $data ['receiptMemu'] = 'companyCategoryCollect';
  10035. $data ['verifyId'] = $this->verifyId;
  10036. $data ['executeId'] = $this->executeId;
  10037. // year staff status 2,4
  10038. /* if ($year < date ( "Y" )) {
  10039. Doo::loadModel ( 'receipt' );
  10040. $receipt = new receipt ();
  10041. $receiptList = $receipt->find ( array (
  10042. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10043. 'asArray' => true
  10044. ) );
  10045. if (empty ( $receiptList )) {
  10046. ob_start ();
  10047. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10048. $this->cacheFile ( $path );
  10049. die ();
  10050. }
  10051. } */
  10052. $dateHtml = "";
  10053. $now = date ( "Y" );
  10054. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10055. if ($YEARD <= $now) {
  10056. $dateHtml .= '<option ';
  10057. if ($year == $YEARD) {
  10058. $dateHtml .= 'selected ';
  10059. }
  10060. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10061. }
  10062. }
  10063. $data ['dateHtml'] = $dateHtml;
  10064. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10065. }
  10066. function staffCollect() {
  10067. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10068. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10069. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10070. // $this->showCache($path);
  10071. Doo::loadModel ( 'statistics' );
  10072. $statistics = new statistics ();
  10073. Doo::loadModel ( "receiptDetail" );
  10074. $receiptDetail = new receiptDetail ();
  10075. Doo::loadModel ( 'L_category' );
  10076. $Lcategory = new L_category ();
  10077. Doo::loadModel ( 'accountItem' );
  10078. $accountItem = new accountItem ();
  10079. Doo::loadModel ( 'staff' );
  10080. $staff = new staff ();
  10081. Doo::loadModel ( 'itemStatistics' );
  10082. $itemStatistics = new itemStatistics ();
  10083. Doo::loadModel ( "receiptAuthorityManage" );
  10084. $receiptAuthorityManage = new receiptAuthorityManage ();
  10085. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10086. $cidList = array ();
  10087. foreach ( $imcStaff as $key => $value ) {
  10088. array_push ( $cidList, $value ['cid'] );
  10089. }
  10090. $cidString = implode ( ',', $cidList );
  10091. $naturecon='';
  10092. if ($nature=='ONJOB'){
  10093. $naturecon=' and (nature!=4 )';
  10094. }elseif($nature=='LEAVEJOB'){
  10095. $naturecon=' and (nature=4 )';
  10096. }else{
  10097. die ( 'illegal request--nature' );
  10098. }
  10099. // statistics html
  10100. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10101. if (empty ( $stList ))
  10102. $stList = array (
  10103. 'rePrice' => 0,
  10104. 'agPrice' => 0
  10105. );
  10106. $data ['stList'] = array (
  10107. 'rePrice' => $stList ['rePrice'],
  10108. 'agPrice' => $stList ['agPrice'],
  10109. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10110. );
  10111. // ---
  10112. $staffList = $staff->find ( array (
  10113. 'where' => 'username !="admin" '.$naturecon,
  10114. 'asArray' => true
  10115. ) );
  10116. $LcategoryList = $Lcategory->find ( array (
  10117. 'asArray' => true
  10118. ) ); // 'staff='.$this->staff[0]['sid']." and
  10119. $itemStatisticsList = $itemStatistics->find ( array (
  10120. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10121. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10122. 'groupby' => 'staff,Month(date)',
  10123. 'asArray' => true
  10124. ) );
  10125. $categoryList = $staff->find ( array (
  10126. 'select' => 'COUNT(*) as count,cid,category',
  10127. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10128. 'groupby' => 'cid',
  10129. 'asArray' => true
  10130. ) );
  10131. // print_r($itemStatisticsList);die;
  10132. // ceatre companyCollectHtml
  10133. foreach ( $categoryList as $vlu ) {
  10134. $count = $vlu ['count'] + 1;
  10135. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10136. $m1 = 0;
  10137. $m2 = 0;
  10138. $m3 = 0;
  10139. $m4 = 0;
  10140. $m5 = 0;
  10141. $m6 = 0;
  10142. $m7 = 0;
  10143. $m8 = 0;
  10144. $m9 = 0;
  10145. $m10 = 0;
  10146. $m11 = 0;
  10147. $m12 = 0;
  10148. $m13 = 0;
  10149. foreach ( $staffList as $value ) {
  10150. if ($vlu ['cid'] == $value ['cid']) {
  10151. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10152. $asum = 0;
  10153. for($i = 1; $i <= 12; $i ++) {
  10154. $falg = true;
  10155. foreach ( $itemStatisticsList as $v ) {
  10156. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10157. if ($v ['month'] == 1)
  10158. $m1 += $v ['price'];
  10159. if ($v ['month'] == 2)
  10160. $m2 += $v ['price'];
  10161. if ($v ['month'] == 3)
  10162. $m3 += $v ['price'];
  10163. if ($v ['month'] == 4)
  10164. $m4 += $v ['price'];
  10165. if ($v ['month'] == 5)
  10166. $m5 += $v ['price'];
  10167. if ($v ['month'] == 6)
  10168. $m6 += $v ['price'];
  10169. if ($v ['month'] == 7)
  10170. $m7 += $v ['price'];
  10171. if ($v ['month'] == 8)
  10172. $m8 += $v ['price'];
  10173. if ($v ['month'] == 9)
  10174. $m9 += $v ['price'];
  10175. if ($v ['month'] == 10)
  10176. $m10 += $v ['price'];
  10177. if ($v ['month'] == 11)
  10178. $m11 += $v ['price'];
  10179. if ($v ['month'] == 12)
  10180. $m12 += $v ['price'];
  10181. $asum += $v ['price'];
  10182. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10183. $falg = false;
  10184. break;
  10185. }
  10186. }
  10187. if ($falg)
  10188. $html .= '<td class="taR">-</td>';
  10189. }
  10190. $m13 += $asum;
  10191. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10192. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10193. 'html' => $html,
  10194. 'sid' => $value ['sid']
  10195. );
  10196. $html = "";
  10197. }
  10198. }
  10199. $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>
  10200. <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>
  10201. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10202. $collectHtml [$vlu ['cid']] = array (
  10203. 'html' => $hl,
  10204. 'sid' => ''
  10205. );
  10206. }
  10207. $data ['companyHtml'] = $collectHtml;
  10208. // total price html
  10209. $collectHtml = "";
  10210. $total = 0;
  10211. for($i = 1; $i <= 12; $i ++) {
  10212. $sumPrice = 0;
  10213. foreach ( $itemStatisticsList as $key => $value ) {
  10214. if ($value ['month'] == $i) {
  10215. $sumPrice += $value ['price'];
  10216. }
  10217. }
  10218. if ($sumPrice == 0)
  10219. $collectHtml .= '<td class="taR">-</td>';
  10220. else
  10221. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10222. $total += $sumPrice;
  10223. }
  10224. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10225. $data ['companyTotalHtml'] = $collectHtml;
  10226. $data ['total'] = $total;
  10227. $data ['nature'] =$nature;
  10228. $data ['year'] = $year;
  10229. $data ['memu'] = "receipt";
  10230. $data ['staff'] = $this->staff;
  10231. $data ['receiptMemu'] = 'companyCategoryCollect';
  10232. $data ['verifyId'] = $this->verifyId;
  10233. $data ['executeId'] = $this->executeId;
  10234. if ($year <= date ( "Y" )) {
  10235. Doo::loadModel ( 'receipt' );
  10236. $receipt = new receipt ();
  10237. $receiptList = $receipt->find ( array (
  10238. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10239. 'asArray' => true
  10240. ) );
  10241. if (empty ( $receiptList )) { // generated files
  10242. ob_start ();
  10243. $this->render ( "/admin/saeaStaffCollectB", $data );
  10244. $this->cacheFile ( $path );
  10245. die ();
  10246. }
  10247. }
  10248. $this->render ( "/admin/saeaStaffCollectB", $data );
  10249. }
  10250. function staffCollectBak() {
  10251. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10252. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10253. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10254. $this->showCache ( $path );
  10255. Doo::loadModel ( 'statistics' );
  10256. $statistics = new statistics ();
  10257. Doo::loadModel ( "receiptDetail" );
  10258. $receiptDetail = new receiptDetail ();
  10259. Doo::loadModel ( 'L_category' );
  10260. $Lcategory = new L_category ();
  10261. Doo::loadModel ( 'accountItem' );
  10262. $accountItem = new accountItem ();
  10263. Doo::loadModel ( 'staff' );
  10264. $staff = new staff ();
  10265. Doo::loadModel ( 'itemStatistics' );
  10266. $itemStatistics = new itemStatistics ();
  10267. $itemStatisticsList = $itemStatistics->find ( array (
  10268. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10269. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10270. 'groupby' => 'staff,itemCategory,Month(date)',
  10271. 'asArray' => true
  10272. ) );
  10273. $itemCategoryList = $itemStatistics->find ( array (
  10274. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10275. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10276. 'groupby' => 'cid,itemCategory,Month(date)',
  10277. 'asArray' => true
  10278. ) );
  10279. $LcategoryList = $Lcategory->find ( array (
  10280. 'asArray' => true
  10281. ) );
  10282. $staffList = $staff->find ( array (
  10283. 'asArray' => true
  10284. ) );
  10285. $htmlArray = array ();
  10286. foreach ( $LcategoryList as $value ) {
  10287. $htmlArray [$value ['title']] = array ();
  10288. foreach ( $staffList as $v ) {
  10289. if ($value ['cid'] == $v ['cid']) {
  10290. $html = "";
  10291. $falg = true;
  10292. $staffSumPrice = 0;
  10293. foreach ( $itemStatisticsList as $a ) {
  10294. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10295. if (empty ( $a ['price'] )) {
  10296. $html .= '<td class="taR">-</td>';
  10297. $falg = false;
  10298. break;
  10299. } else {
  10300. $staffSumPrice += $a ['price'];
  10301. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10302. $falg = false;
  10303. break;
  10304. }
  10305. }
  10306. }
  10307. if ($falg) {
  10308. $html .= '<td class="taR">-</td>';
  10309. $falg = true;
  10310. }
  10311. $falg = true;
  10312. foreach ( $itemStatisticsList as $a ) {
  10313. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10314. if (empty ( $a ['price'] )) {
  10315. $html .= '<td class="taR">-</td>';
  10316. $falg = false;
  10317. break;
  10318. } else {
  10319. $staffSumPrice += $a ['price'];
  10320. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10321. $falg = false;
  10322. break;
  10323. }
  10324. }
  10325. }
  10326. if ($falg) {
  10327. $html .= '<td class="taR">-</td>';
  10328. $falg = true;
  10329. }
  10330. $falg = true;
  10331. foreach ( $itemStatisticsList as $a ) {
  10332. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10333. if (empty ( $a ['price'] )) {
  10334. $html .= '<td class="taR">-</td>';
  10335. $falg = false;
  10336. break;
  10337. } else {
  10338. $staffSumPrice += $a ['price'];
  10339. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10340. $falg = false;
  10341. break;
  10342. }
  10343. }
  10344. }
  10345. if ($falg) {
  10346. $html .= '<td class="taR">-</td>';
  10347. $falg = true;
  10348. }
  10349. $falg = true;
  10350. foreach ( $itemStatisticsList as $a ) {
  10351. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10352. if (! empty ( $a ['price'] )) {
  10353. $staffSumPrice += $a ['price'];
  10354. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10355. $falg = false;
  10356. break;
  10357. } else {
  10358. $html .= '<td class="taR">-</td>';
  10359. $falg = false;
  10360. break;
  10361. }
  10362. }
  10363. }
  10364. if ($falg) {
  10365. $html .= '<td class="taR">-</td>';
  10366. $falg = true;
  10367. }
  10368. $falg = true;
  10369. foreach ( $itemStatisticsList as $a ) {
  10370. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10371. if (! empty ( $a ['price'] )) {
  10372. $staffSumPrice += $a ['price'];
  10373. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10374. $falg = false;
  10375. break;
  10376. } else {
  10377. $html .= '<td class="taR">-</td>';
  10378. $falg = false;
  10379. break;
  10380. }
  10381. }
  10382. }
  10383. if ($falg) {
  10384. $html .= '<td class="taR">-</td>';
  10385. $falg = true;
  10386. }
  10387. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10388. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10389. }
  10390. }
  10391. /* -- --- */
  10392. // 合计费用
  10393. $cateHtml = "";
  10394. $catePrice = 0;
  10395. $cateFalg = true;
  10396. foreach ( $itemCategoryList as $l ) {
  10397. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10398. if (empty ( $l ['price'] )) {
  10399. $cateHtml .= '<td class="colGreen taR">-</td>';
  10400. $cateFalg = false;
  10401. break;
  10402. } else {
  10403. $catePrice += $l ['price'];
  10404. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10405. $cateFalg = false;
  10406. break;
  10407. }
  10408. }
  10409. }
  10410. if ($cateFalg) {
  10411. $cateHtml .= '<td class="colGreen taR">-</td>';
  10412. $cateFalg = true;
  10413. }
  10414. $cateFalg = true;
  10415. foreach ( $itemCategoryList as $l ) {
  10416. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10417. if (empty ( $l ['price'] )) {
  10418. $cateHtml .= '<td class="colGreen taR">-</td>';
  10419. $cateFalg = false;
  10420. break;
  10421. } else {
  10422. $catePrice += $l ['price'];
  10423. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10424. $cateFalg = false;
  10425. break;
  10426. }
  10427. }
  10428. }
  10429. if ($cateFalg) {
  10430. $cateHtml .= '<td class="colGreen taR">-</td>';
  10431. $cateFalg = true;
  10432. }
  10433. $cateFalg = true;
  10434. foreach ( $itemCategoryList as $l ) {
  10435. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10436. if (empty ( $l ['price'] )) {
  10437. $cateHtml .= '<td class="colGreen taR">-</td>';
  10438. $cateFalg = false;
  10439. break;
  10440. } else {
  10441. $catePrice += $l ['price'];
  10442. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10443. $cateFalg = false;
  10444. break;
  10445. }
  10446. }
  10447. }
  10448. if ($cateFalg) {
  10449. $cateHtml .= '<td class="colGreen taR">-</td>';
  10450. $cateFalg = true;
  10451. }
  10452. $cateFalg = true;
  10453. foreach ( $itemCategoryList as $l ) {
  10454. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10455. if (empty ( $l ['price'] )) {
  10456. $cateHtml .= '<td class="colGreen taR">-</td>';
  10457. $cateFalg = false;
  10458. break;
  10459. } else {
  10460. $catePrice += $l ['price'];
  10461. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10462. $cateFalg = false;
  10463. break;
  10464. }
  10465. }
  10466. }
  10467. if ($cateFalg) {
  10468. $cateHtml .= '<td class="colGreen taR">-</td>';
  10469. $cateFalg = true;
  10470. }
  10471. $cateFalg = true;
  10472. foreach ( $itemCategoryList as $l ) {
  10473. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10474. if (empty ( $l ['price'] )) {
  10475. $cateHtml .= '<td class="colGreen taR">-</td>';
  10476. $cateFalg = false;
  10477. break;
  10478. } else {
  10479. $catePrice += $l ['price'];
  10480. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10481. $cateFalg = false;
  10482. break;
  10483. }
  10484. }
  10485. }
  10486. if ($cateFalg) {
  10487. $cateHtml .= '<td class="colGreen taR">-</td>';
  10488. $cateFalg = true;
  10489. }
  10490. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10491. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10492. /* -- --- */
  10493. }
  10494. // print_r($htmlArray);die;
  10495. $data ['htmlArray'] = $htmlArray;
  10496. // statistics html
  10497. $stList = $statistics->getOne ( array (
  10498. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10499. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10500. 'groupby' => 'Month(date)',
  10501. 'asArray' => true
  10502. ) );
  10503. if (empty ( $stList ))
  10504. $stList = array (
  10505. 'rePrice' => 0,
  10506. 'agPrice' => 0
  10507. );
  10508. $data ['stList'] = array (
  10509. 'rePrice' => $stList ['rePrice'],
  10510. 'agPrice' => $stList ['agPrice'],
  10511. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10512. );
  10513. $monthHtml = "";
  10514. for($i = 1; $i <= 12; $i ++) {
  10515. if ($i == $month)
  10516. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10517. else
  10518. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10519. }
  10520. $data ['monthHtml'] = $monthHtml;
  10521. $data ['year'] = $year;
  10522. $data ['month'] = $month;
  10523. $data ['memu'] = "receipt";
  10524. $data ['staff'] = $this->staff;
  10525. $data ['receiptMemu'] = 'companyCategoryCollect';
  10526. $data ['verifyId'] = $this->verifyId;
  10527. $data ['executeId'] = $this->executeId;
  10528. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10529. Doo::loadModel ( 'receipt' );
  10530. $receipt = new receipt ();
  10531. $receiptList = $receipt->find ( array (
  10532. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10533. 'asArray' => true
  10534. ) );
  10535. if (empty ( $receiptList )) { // generated files
  10536. ob_start ();
  10537. $this->render ( "/admin/saeaStaffCollect", $data );
  10538. $this->cacheFile ( $path );
  10539. die ();
  10540. }
  10541. }
  10542. $this->render ( "/admin/saeaStaffCollect", $data );
  10543. }
  10544. /**
  10545. * 日常收支
  10546. */
  10547. function payments() {
  10548. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10549. Doo::loadModel ( "execute" );
  10550. $execute = new execute ();
  10551. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10552. die ( 'illegal request' );
  10553. }
  10554. Doo::loadModel ( "accountBook" );
  10555. $accountBook = new accountBook ();
  10556. Doo::loadModel ( "accountBookStatistics" );
  10557. $accountBookStatistics = new accountBookStatistics ();
  10558. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10559. $list = $accountBook->getAccountBookByLimit ( 10 );
  10560. $data ['date'] = date ( "Y-m-d" );
  10561. $data ['statisticsList'] = $statisticsList;
  10562. $data ['list'] = $list;
  10563. $data ['memu'] = "receipt";
  10564. $data ['staff'] = $this->staff;
  10565. $data ['receiptMemu'] = 'payments';
  10566. $data ['verifyId'] = $this->verifyId;
  10567. $data ['executeId'] = $this->executeId;
  10568. $this->render ( "/expenses/payments", $data );
  10569. }
  10570. function paymentsIncomeDo() {
  10571. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10572. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10573. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10574. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10575. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10576. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10577. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10578. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10579. Doo::loadClass ( 'XDeode' );
  10580. $XDeode = new XDeode ( 5 );
  10581. Doo::loadModel ( "accountBook" );
  10582. Doo::loadModel ( "accountBookStatistics" );
  10583. Doo::loadModel ( 'wasteBook' );
  10584. // 记录流水时银行的转换
  10585. $accountBank = '';
  10586. if ($receivedBank == '纵横广发') {
  10587. $accountBank = 'CGBDeposit';
  10588. } elseif ($receivedBank == '纵横工行') {
  10589. $accountBank = 'ICBCDeposit';
  10590. } elseif ($receivedBank == '华润银行') {
  10591. $accountBank = 'HUADeposit';
  10592. } elseif ($receivedBank == '个人广发') {
  10593. $accountBank = 'PersonalDeposit';
  10594. }
  10595. if (empty ( $accountBank ))
  10596. die ( 'illegal request-bank' );
  10597. //TODO -存款功能 提取
  10598. if($accountType == 11 || $accountType == 12){
  10599. if($accountType == 11){
  10600. $receivedBank = '纵横广发';
  10601. }elseif($accountType == 12){
  10602. $receivedBank = '纵横工行';
  10603. }
  10604. // 添加一条收入
  10605. $accountBook = new accountBook ();
  10606. $accountBook->accountType = $accountType;
  10607. $accountBook->accountMsg = $accountMsg;
  10608. $accountBook->receivedPrice = $receivedPrice;
  10609. $accountBook->receivedMsg = $receivedMsg;
  10610. $accountBook->receivedBank = $receivedBank;
  10611. $accountBook->receivedDate = $receivedDate;
  10612. $accountBook->remarks = $remarks;
  10613. $accountBook->expensesType = 1;
  10614. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10615. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10616. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10617. $inComeId = $accountBook->insert ();
  10618. // 收支汇总-添加一条收入日常汇总
  10619. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10620. $accountBookStatistics = new accountBookStatistics ();
  10621. $item = array (
  10622. 'date' => date ( "Y-m-d" ),
  10623. 'accountType' => $abDetail ['accountType'],
  10624. 'accountMsg' => $abDetail ['accountMsg'],
  10625. 'aid' => $abDetail ['aid'],
  10626. 'inComePrice' => $abDetail ['receivedPrice'],
  10627. 'expensesType' => $abDetail ['expensesType']
  10628. );
  10629. $accountBookStatistics->setAccountBookStatistics ( $item );
  10630. // 添加收入流水
  10631. if($accountType == 11){
  10632. $accountBank = 'CGBDeposit';
  10633. }elseif($accountType == 12){
  10634. $accountBank = 'ICBCDeposit';
  10635. }
  10636. $wasteBook = new wasteBook ();
  10637. $itemWaste = array (
  10638. 'accountPriceShow' => $receivedPrice,
  10639. 'accountPrice' => $receivedPrice,
  10640. 'expensesType' => 1,
  10641. 'accountType' => 6, // 流水类型
  10642. 'dataID' => $inComeId,
  10643. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10644. 'accountBank' => $accountBank,
  10645. 'category' => $this->staff [0] ['category'],
  10646. 'cid' => $this->staff [0] ['cid'],
  10647. 'name' => $this->staff [0] ['username'],
  10648. 'sid' => $this->staff [0] ['sid'],
  10649. 'inputDate' => $receivedDate,
  10650. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10651. 'synPaymentDate'=>1,
  10652. );
  10653. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10654. //TODO --移除理财相关
  10655. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10656. // if ($receivedBank == '个人广发') {
  10657. // die ( '个人广发 illegal request' );
  10658. // }
  10659. // 添加一条收入
  10660. $accountBook = new accountBook ();
  10661. $accountBook->accountType = 10;
  10662. $accountBook->accountMsg = $accountMsg;
  10663. $accountBook->receivedPrice = $receivedPrice;
  10664. $accountBook->receivedMsg = $receivedMsg;
  10665. $accountBook->receivedBank = $receivedBank;
  10666. $accountBook->receivedDate = $receivedDate;
  10667. $accountBook->remarks = $remarks;
  10668. $accountBook->expensesType = 1;
  10669. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10670. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10671. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10672. $inComeId = $accountBook->insert ();
  10673. // 收支汇总-添加一条收入日常汇总
  10674. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10675. $accountBookStatistics = new accountBookStatistics ();
  10676. $item = array (
  10677. 'date' => date ( "Y-m-d" ),
  10678. 'accountType' => $abDetail ['accountType'],
  10679. 'accountMsg' => $abDetail ['accountMsg'],
  10680. 'aid' => $abDetail ['aid'],
  10681. 'inComePrice' => $abDetail ['receivedPrice'],
  10682. 'expensesType' => $abDetail ['expensesType']
  10683. );
  10684. $accountBookStatistics->setAccountBookStatistics ( $item );
  10685. // 添加收入流水
  10686. $wasteBook = new wasteBook ();
  10687. $itemWaste = array (
  10688. 'accountPriceShow' => $receivedPrice,
  10689. 'accountPrice' => $receivedPrice,
  10690. 'expensesType' => 1,
  10691. 'accountType' => 6, // 流水类型
  10692. 'dataID' => $inComeId,
  10693. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10694. 'accountBank' => $accountBank,
  10695. 'category' => $this->staff [0] ['category'],
  10696. 'cid' => $this->staff [0] ['cid'],
  10697. 'name' => $this->staff [0] ['username'],
  10698. 'sid' => $this->staff [0] ['sid'],
  10699. 'inputDate' => date ( "Y-m-d H:i:s" )
  10700. );
  10701. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10702. // 添加一条理财支出
  10703. $accountBank = 'CGBDeposit';
  10704. $expenditureBank = '纵横广发';
  10705. $dailyExpenditureType = 4;
  10706. if ($accountType == 9) {
  10707. $accountBank = 'ICBCDeposit';
  10708. $expenditureBank = '纵横工行';
  10709. $dailyExpenditureType = 6;
  10710. }
  10711. $accountBook = new accountBook ();
  10712. $accountBook->expensesType = 2;
  10713. $accountBook->expenditureType = $dailyExpenditureType;
  10714. $accountBook->expenditureMsg = $accountMsg;
  10715. $accountBook->expenditurePrice = $receivedPrice;
  10716. $accountBook->expenditureBank = $expenditureBank;
  10717. $accountBook->expenditureDate = $receivedDate;
  10718. $accountBook->remarks = $remarks;
  10719. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10720. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10721. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10722. $id = $accountBook->insert ();
  10723. // 收支汇总-添加一条理财支出汇总
  10724. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10725. $accountBookStatistics = new accountBookStatistics ();
  10726. $item = array (
  10727. 'date' => date ( "Y-m-d" ),
  10728. 'accountType' => $abDetail ['accountType'],
  10729. 'accountMsg' => $abDetail ['accountMsg'],
  10730. 'aid' => $abDetail ['aid'],
  10731. 'financingPrice' => - $receivedPrice,
  10732. 'expensesType' => 3
  10733. );
  10734. $accountBookStatistics->setAccountBookStatistics ( $item );
  10735. // 添加一条支出理财流水
  10736. $accountTypeWaste = 5;
  10737. if ($accountMsg == '公司固定') {
  10738. $accountTypeWaste = 9;
  10739. } elseif ($accountMsg == '公司活期') {
  10740. $accountTypeWaste = 10;
  10741. } elseif ($accountMsg == '个人(GR)') {
  10742. $accountBank = 'PersonalDeposit';
  10743. }
  10744. $itemWaste = array (
  10745. 'expensesType' => 2,
  10746. 'accountType' => $accountTypeWaste,
  10747. 'accountPriceShow' => $receivedPrice,
  10748. 'accountPrice' => - $receivedPrice,
  10749. 'dataID' => $id,
  10750. 'dailyExpenditureType' => $dailyExpenditureType,
  10751. 'accountBank' => $accountBank,
  10752. 'category' => $this->staff [0] ['category'],
  10753. 'cid' => $this->staff [0] ['cid'],
  10754. 'name' => $this->staff [0] ['username'],
  10755. 'sid' => $this->staff [0] ['sid'],
  10756. 'inputDate' => date ( "Y-m-d H:i:s" )
  10757. );
  10758. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10759. } elseif ($accountType == 1) {
  10760. // if ($receivedBank == '个人广发')
  10761. // die ( 'illegal request--no man' );
  10762. // 添加一条收入
  10763. $accountBook = new accountBook ();
  10764. $accountBook->accountType = $accountType;
  10765. $accountBook->accountMsg = $accountMsg;
  10766. $accountBook->receivedPrice = $receivedPrice;
  10767. $accountBook->receivedMsg = $receivedMsg;
  10768. $accountBook->receivedBank = $receivedBank;
  10769. $accountBook->receivedDate = $receivedDate;
  10770. $accountBook->remarks = $remarks;
  10771. $accountBook->expensesType = 1;
  10772. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10773. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10774. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10775. $id = $accountBook->insert ();
  10776. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10777. // 收支汇总-添加一条收入日常汇总
  10778. $accountBookStatistics = new accountBookStatistics ();
  10779. $item = array (
  10780. 'date' => date ( "Y-m-d" ),
  10781. 'accountType' => $abDetail ['accountType'],
  10782. 'accountMsg' => $abDetail ['accountMsg'],
  10783. 'aid' => $abDetail ['aid'],
  10784. 'expensesType' => $abDetail ['expensesType']
  10785. );
  10786. if ($abDetail ['accountType'] == 8) {
  10787. $item += array (
  10788. 'inComePrice' => $abDetail ['receivedPrice']
  10789. );
  10790. } else {
  10791. $item += array (
  10792. 'inComePrice' => $abDetail ['receivedPrice']
  10793. );
  10794. }
  10795. $accountBookStatistics->setAccountBookStatistics ( $item );
  10796. // 流水存储方向
  10797. $itemWaste = array (
  10798. 'accountType' => 6
  10799. ); // 流水类型
  10800. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10801. // }else
  10802. if ($accountMsg == '活期理财收益') {
  10803. $itemWaste = array (
  10804. 'accountType' => 10
  10805. ); // 流水类型
  10806. }
  10807. // 添加收入流水
  10808. $wasteBook = new wasteBook ();
  10809. $itemWaste += array (
  10810. 'accountPrice' => $receivedPrice,
  10811. 'accountPriceShow' => $receivedPrice,
  10812. 'expensesType' => 1,
  10813. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10814. 'dataID' => $id,
  10815. 'accountBank' => $accountBank,
  10816. 'category' => $this->staff [0] ['category'],
  10817. 'cid' => $this->staff [0] ['cid'],
  10818. 'name' => $this->staff [0] ['username'],
  10819. 'sid' => $this->staff [0] ['sid'],
  10820. 'inputDate' => $receivedDate,
  10821. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10822. 'synPaymentDate'=>1,
  10823. );
  10824. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10825. } else { // 普通日常收入处理
  10826. // 添加一条收入
  10827. $accountBook = new accountBook ();
  10828. $accountBook->accountType = $accountType;
  10829. $accountBook->accountMsg = $accountMsg;
  10830. $accountBook->receivedPrice = $receivedPrice;
  10831. $accountBook->receivedMsg = $receivedMsg;
  10832. $accountBook->receivedBank = $receivedBank;
  10833. $accountBook->receivedDate = $receivedDate;
  10834. $accountBook->remarks = $remarks;
  10835. $accountBook->expensesType = 1;
  10836. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10837. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10838. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10839. $id = $accountBook->insert ();
  10840. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10841. // 收支汇总-添加一条收入日常汇总
  10842. $accountBookStatistics = new accountBookStatistics ();
  10843. $item = array (
  10844. 'date' => date ( "Y-m-d" ),
  10845. 'accountType' => $abDetail ['accountType'],
  10846. 'accountMsg' => $abDetail ['accountMsg'],
  10847. 'aid' => $abDetail ['aid'],
  10848. 'expensesType' => $abDetail ['expensesType']
  10849. );
  10850. if ($abDetail ['accountType'] == 8) {
  10851. $item += array (
  10852. 'inComePrice' => $abDetail ['receivedPrice']
  10853. );
  10854. } else {
  10855. $item += array (
  10856. 'inComePrice' => $abDetail ['receivedPrice']
  10857. );
  10858. }
  10859. $accountBookStatistics->setAccountBookStatistics ( $item );
  10860. // 添加收入流水
  10861. $itemWaste = array (
  10862. 'accountPrice' => $receivedPrice
  10863. );
  10864. if ($receivedBank == '个人广发') {
  10865. $itemWaste = array (
  10866. 'accountPrice' => - $receivedPrice
  10867. );
  10868. }
  10869. $wasteBook = new wasteBook ();
  10870. $itemWaste += array (
  10871. 'accountPriceShow' => $receivedPrice,
  10872. 'expensesType' => 1,
  10873. 'accountType' => 6, // 流水类型
  10874. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10875. 'dataID' => $id,
  10876. 'accountBank' => $accountBank,
  10877. 'category' => $this->staff [0] ['category'],
  10878. 'cid' => $this->staff [0] ['cid'],
  10879. 'name' => $this->staff [0] ['username'],
  10880. 'sid' => $this->staff [0] ['sid'],
  10881. 'inputDate' => $receivedDate,
  10882. 'createAt'=>date ( "Y-m-d H:i:s" ),
  10883. 'synPaymentDate'=>1,
  10884. );
  10885. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10886. }
  10887. }
  10888. return '/payments';
  10889. }
  10890. function paymentsExpenditureDo() {
  10891. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10892. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10893. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10894. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10895. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10896. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10897. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10898. // 理财支出特殊处理
  10899. Doo::loadModel ( "accountBook" );
  10900. Doo::loadModel ( "accountBookStatistics" );
  10901. Doo::loadModel ( 'wasteBook' );
  10902. $accountBank = '';
  10903. if ($expenditureBank == '纵横广发') {
  10904. $accountBank = 'CGBDeposit';
  10905. } elseif ($expenditureBank == '纵横工行') {
  10906. $accountBank = 'ICBCDeposit';
  10907. } elseif ($expenditureBank == '华润银行') {
  10908. $accountBank = 'HUADeposit';
  10909. } elseif ($expenditureBank == '个人广发') {
  10910. $accountBank = 'PersonalDeposit';
  10911. }
  10912. if (empty ( $accountBank ))
  10913. die ( 'illegal request' );
  10914. if($expenditureType == 8 || $expenditureType == 9){
  10915. if($expenditureType == 8 ){
  10916. $expenditureBank='纵横广发';
  10917. }elseif($expenditureType == 9){
  10918. $expenditureBank='纵横工行';
  10919. }
  10920. // 添加一笔日常支出
  10921. $accountBook = new accountBook ();
  10922. $accountBook->expensesType = 2;
  10923. $accountBook->expenditureType = $expenditureType;
  10924. $accountBook->expenditureMsg = $expenditureMsg;
  10925. $accountBook->expenditurePrice = $expenditurePrice;
  10926. $accountBook->expenditureBank = $expenditureBank;
  10927. $accountBook->expenditureDate = $expenditureDate;
  10928. $accountBook->remarks = $remarks;
  10929. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10930. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10931. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10932. $expenditureId = $accountBook->insert ();
  10933. // 添加日常支出汇总
  10934. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10935. $accountBookStatistics = new accountBookStatistics ();
  10936. $item = array (
  10937. 'date' => date ( "Y-m-d" ),
  10938. 'expenditureType' => $abDetail ['expenditureType'],
  10939. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10940. 'aid' => $abDetail ['aid'],
  10941. 'payPrice' => $abDetail ['expenditurePrice'],
  10942. 'expensesType' => $abDetail ['expensesType']
  10943. );
  10944. $accountBookStatistics->setAccountBookStatistics ( $item );
  10945. // 公司日常支出流水
  10946. if($expenditureType == 8 ){
  10947. $accountBank = 'CGBDeposit';
  10948. }elseif($expenditureType == 9){
  10949. $accountBank = 'ICBCDeposit';
  10950. }
  10951. if($accountBank=='CGBDeposit'){
  10952. $dailyExpenditureType='8';
  10953. }elseif($accountBank=='ICBCDeposit'){
  10954. $dailyExpenditureType='9';
  10955. }elseif($accountBank=='PersonalDeposit'){
  10956. $dailyExpenditureType='10';
  10957. }elseif($accountBank=='HUADeposit'){
  10958. $dailyExpenditureType='11';
  10959. }
  10960. $wasteBook = new wasteBook ();
  10961. $itemWaste = array (
  10962. 'expensesType' => 2,
  10963. 'accountType' => 5,
  10964. 'dailyExpenditureType' => $dailyExpenditureType,
  10965. 'accountPriceShow' => $expenditurePrice,
  10966. 'accountPrice' => - $expenditurePrice,
  10967. 'dataID' => $expenditureId,
  10968. 'accountBank' => $accountBank,
  10969. 'category' => $this->staff [0] ['category'],
  10970. 'cid' => $this->staff [0] ['cid'],
  10971. 'name' => $this->staff [0] ['username'],
  10972. 'sid' => $this->staff [0] ['sid'],
  10973. 'inputDate' => date ( "Y-m-d H:i:s" )
  10974. );
  10975. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10976. // 添加一笔收入流水
  10977. // if($expenditureType==8){
  10978. // $dailyIncomeType='11';
  10979. // }elseif($expenditureType==9){
  10980. // $dailyIncomeType='12';
  10981. // }
  10982. // $wasteBook = new wasteBook ();
  10983. // $itemWaste = array (
  10984. // 'expensesType' => 1,
  10985. // 'accountType' => 6,
  10986. // 'accountPriceShow' => $expenditurePrice,
  10987. // 'accountPrice' => $expenditurePrice,
  10988. // 'dataID' => $expenditureId,
  10989. //
  10990. // 'dailyIncomeType' => $dailyIncomeType,
  10991. // 'accountBank' => $accountBank,
  10992. // 'category' => $this->staff [0] ['category'],
  10993. // 'cid' => $this->staff [0] ['cid'],
  10994. // 'name' => $this->staff [0] ['username'],
  10995. // 'sid' => $this->staff [0] ['sid'],
  10996. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10997. // );
  10998. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10999. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11000. if ($expenditureBank == '个人广发') {
  11001. die ( '个人广发 illegal request' );
  11002. }
  11003. // 添加一笔日常支出
  11004. $accountBook = new accountBook ();
  11005. $accountBook->expensesType = 2;
  11006. $accountBook->expenditureType = 7;
  11007. $accountBook->expenditureMsg = $expenditureMsg;
  11008. $accountBook->expenditurePrice = $expenditurePrice;
  11009. $accountBook->expenditureBank = $expenditureBank;
  11010. $accountBook->expenditureDate = $expenditureDate;
  11011. $accountBook->remarks = $remarks;
  11012. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11013. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11014. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11015. $expenditureId = $accountBook->insert ();
  11016. // 添加日常支出汇总
  11017. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11018. $accountBookStatistics = new accountBookStatistics ();
  11019. $item = array (
  11020. 'date' => date ( "Y-m-d" ),
  11021. 'expenditureType' => $abDetail ['expenditureType'],
  11022. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11023. 'aid' => $abDetail ['aid'],
  11024. 'payPrice' => $abDetail ['expenditurePrice'],
  11025. 'expensesType' => $abDetail ['expensesType']
  11026. );
  11027. $accountBookStatistics->setAccountBookStatistics ( $item );
  11028. // 公司日常支出流水
  11029. $wasteBook = new wasteBook ();
  11030. $itemWaste = array (
  11031. 'accountPrice' => - $expenditurePrice
  11032. );
  11033. if ($expenditureBank == '个人广发') {
  11034. $itemWaste = array (
  11035. 'accountPrice' => $expenditurePrice
  11036. );
  11037. }
  11038. $itemWaste += array (
  11039. 'expensesType' => 2,
  11040. 'accountType' => 5,
  11041. 'dailyExpenditureType' => $expenditureType,
  11042. 'accountPriceShow' => $expenditurePrice,
  11043. 'accountPrice' => - $expenditurePrice,
  11044. 'dataID' => $expenditureId,
  11045. 'accountBank' => $accountBank,
  11046. 'category' => $this->staff [0] ['category'],
  11047. 'cid' => $this->staff [0] ['cid'],
  11048. 'name' => $this->staff [0] ['username'],
  11049. 'sid' => $this->staff [0] ['sid'],
  11050. 'inputDate' => date ( "Y-m-d H:i:s" )
  11051. );
  11052. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11053. // 添加一笔理财收入
  11054. $accountBank = 'CGBDeposit';
  11055. $dailyIncomeType = 7;
  11056. $receivedBank = '纵横广发';
  11057. if ($expenditureType == 6) {
  11058. $accountBank = 'ICBCDeposit';
  11059. $receivedBank = '纵横工行';
  11060. $dailyIncomeType = 9;
  11061. }
  11062. $accountBook = new accountBook ();
  11063. $accountBook->expensesType = 1;
  11064. $accountBook->accountType = $dailyIncomeType;
  11065. $accountBook->accountMsg = $expenditureMsg;
  11066. $accountBook->receivedPrice = $expenditurePrice;
  11067. $accountBook->receivedBank = $receivedBank;
  11068. $accountBook->receivedDate = $expenditureDate;
  11069. $accountBook->remarks = $remarks;
  11070. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11071. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11072. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11073. $id = $accountBook->insert ();
  11074. // 添加日常理财收入汇总
  11075. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11076. $accountBookStatistics = new accountBookStatistics ();
  11077. $item = array (
  11078. 'date' => date ( "Y-m-d" ),
  11079. 'expenditureType' => $abDetail ['expenditureType'],
  11080. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11081. 'aid' => $abDetail ['aid'],
  11082. 'financingPrice' => $expenditurePrice,
  11083. 'expensesType' => 3
  11084. );
  11085. $accountBookStatistics->setAccountBookStatistics ( $item );
  11086. // 添加一笔收入流水
  11087. if ($expenditureMsg == '公司固定') {
  11088. $accountTypeWaste = 9;
  11089. } elseif ($expenditureMsg == '公司活期') {
  11090. $accountTypeWaste = 10;
  11091. } elseif ($expenditureMsg == '个人(GR)') {
  11092. $accountBank = 'PersonalDeposit';
  11093. }
  11094. $itemWaste = array (
  11095. 'expensesType' => 1,
  11096. 'accountType' => $accountTypeWaste,
  11097. 'accountPriceShow' => $expenditurePrice,
  11098. 'accountPrice' => $expenditurePrice,
  11099. 'dataID' => $id,
  11100. 'dailyIncomeType' => $dailyIncomeType,
  11101. 'accountBank' => $accountBank,
  11102. 'category' => $this->staff [0] ['category'],
  11103. 'cid' => $this->staff [0] ['cid'],
  11104. 'name' => $this->staff [0] ['username'],
  11105. 'sid' => $this->staff [0] ['sid'],
  11106. 'inputDate' => date ( "Y-m-d H:i:s" )
  11107. );
  11108. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11109. } else {
  11110. // 添加一笔日常支出
  11111. $accountBook = new accountBook ();
  11112. $accountBook->expensesType = 2;
  11113. $accountBook->expenditureType = $expenditureType;
  11114. $accountBook->expenditureMsg = $expenditureMsg;
  11115. $accountBook->expenditurePrice = $expenditurePrice;
  11116. $accountBook->expenditureBank = $expenditureBank;
  11117. $accountBook->expenditureDate = $expenditureDate;
  11118. $accountBook->remarks = $remarks;
  11119. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11120. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11121. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11122. $id = $accountBook->insert ();
  11123. // 添加日常支出汇总
  11124. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11125. $accountBookStatistics = new accountBookStatistics ();
  11126. $item = array (
  11127. 'date' => date ( "Y-m-d" ),
  11128. 'expenditureType' => $abDetail ['expenditureType'],
  11129. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11130. 'aid' => $abDetail ['aid'],
  11131. 'expensesType' => $abDetail ['expensesType']
  11132. );
  11133. if ($expenditureType == 5) {
  11134. $item += array (
  11135. 'payPrice' => - $abDetail ['expenditurePrice']
  11136. );
  11137. } else {
  11138. $item += array (
  11139. 'payPrice' => $abDetail ['expenditurePrice']
  11140. );
  11141. }
  11142. $accountBookStatistics->setAccountBookStatistics ( $item );
  11143. // 公司日常支出流水
  11144. $wasteBook = new wasteBook ();
  11145. $itemWaste = array (
  11146. 'accountPrice' => - $expenditurePrice
  11147. );
  11148. if ($expenditureBank == '个人广发') {
  11149. $itemWaste = array (
  11150. 'accountPrice' => $expenditurePrice
  11151. );
  11152. }
  11153. $itemWaste += array (
  11154. 'expensesType' => 2,
  11155. 'accountType' => 5,
  11156. 'accountPriceShow' => $expenditurePrice,
  11157. 'dataID' => $id,
  11158. 'dailyExpenditureType' => $expenditureType,
  11159. 'accountBank' => $accountBank,
  11160. 'category' => $this->staff [0] ['category'],
  11161. 'cid' => $this->staff [0] ['cid'],
  11162. 'name' => $this->staff [0] ['username'],
  11163. 'sid' => $this->staff [0] ['sid'],
  11164. 'inputDate' => date ( "Y-m-d H:i:s" )
  11165. );
  11166. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11167. }
  11168. }
  11169. return '/payments';
  11170. }
  11171. /**
  11172. * 添加支出
  11173. */
  11174. function paymentsExpenditureDo_() {
  11175. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11176. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11177. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11178. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11179. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11180. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11181. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11182. $dailyExpenditureType = '';
  11183. $accountTypeWaste = 5;
  11184. $accountBank = '';
  11185. if ($expenditureBank == '纵横广发') {
  11186. $accountBank = 'CGBDeposit';
  11187. } elseif ($expenditureBank == '纵横工行') {
  11188. $accountBank = 'ICBCDeposit';
  11189. } elseif ($expenditureBank == '华润银行') {
  11190. $accountBank = 'HUADeposit';
  11191. } elseif ($expenditureBank == '个人广发') {
  11192. $accountBank = 'PersonalDeposit';
  11193. }
  11194. if (empty ( $accountBank ))
  11195. die ( 'illegal request' );
  11196. $itemWaste = array (
  11197. 'accountPrice' => - $expenditurePrice
  11198. );
  11199. if ($expenditureBank == '个人广发') {
  11200. $itemWaste = array (
  11201. 'accountPrice' => $expenditurePrice
  11202. );
  11203. }
  11204. if ($expenditureType == 4 || $expenditureType == 6) {
  11205. $dailyExpenditureType = 4;
  11206. if ($expenditureMsg == '公司固定') {
  11207. $accountTypeWaste = 9;
  11208. } elseif ($expenditureMsg == '公司活期') {
  11209. $accountTypeWaste = 10;
  11210. } elseif ($expenditureMsg == '个人(GR)') {
  11211. $accountBank = 'PersonalDeposit';
  11212. }
  11213. $itemWaste = array (
  11214. 'accountPrice' => $expenditurePrice
  11215. );
  11216. } elseif ($expenditureType == 1) {
  11217. $dailyExpenditureType = 1;
  11218. } elseif ($expenditureType == 2) {
  11219. $dailyExpenditureType = 2;
  11220. } elseif ($expenditureType == 3) {
  11221. $dailyExpenditureType = 3;
  11222. } elseif ($expenditureType == 5) {
  11223. $dailyExpenditureType = 5;
  11224. }
  11225. if (empty ( $dailyExpenditureType ))
  11226. die ( 'illegal request' );
  11227. Doo::loadModel ( "accountBook" );
  11228. $accountBook = new accountBook ();
  11229. $accountBook->expenditureType = $expenditureType;
  11230. $accountBook->expenditureMsg = $expenditureMsg;
  11231. $accountBook->expenditurePrice = $expenditurePrice;
  11232. $accountBook->expenditureBank = $expenditureBank;
  11233. $accountBook->expenditureDate = $expenditureDate;
  11234. $accountBook->remarks = $remarks;
  11235. $accountBook->expensesType = 2;
  11236. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11237. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11238. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11239. $id = $accountBook->insert ();
  11240. //
  11241. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11242. Doo::loadModel ( "accountBookStatistics" );
  11243. $accountBookStatistics = new accountBookStatistics ();
  11244. $item = array (
  11245. 'date' => date ( "Y-m-d" ),
  11246. 'expenditureType' => $abDetail ['expenditureType'],
  11247. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11248. 'aid' => $abDetail ['aid']
  11249. );
  11250. if ($abDetail ['expensesType'] == 2) {
  11251. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11252. $item += array (
  11253. 'financingPrice' => $expenditurePrice,
  11254. 'expensesType' => 3
  11255. );
  11256. } elseif ($abDetail ['expenditureType'] == 5) {
  11257. $item += array (
  11258. 'payPrice' => $abDetail ['expenditurePrice'],
  11259. 'expensesType' => $abDetail ['expensesType']
  11260. );
  11261. } else {
  11262. $item += array (
  11263. 'payPrice' => $abDetail ['expenditurePrice'],
  11264. 'expensesType' => $abDetail ['expensesType']
  11265. );
  11266. }
  11267. }
  11268. $accountBookStatistics->setAccountBookStatistics ( $item );
  11269. // 公司流水记录
  11270. Doo::loadModel ( 'wasteBook' );
  11271. $wasteBook = new wasteBook ();
  11272. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11273. // 银行
  11274. if (empty ( $abDetail )) {
  11275. $itemWaste += array (
  11276. 'accountPriceShow' => $expenditurePrice,
  11277. 'dataID' => $id,
  11278. 'expensesType' => 2,
  11279. 'accountType' => $accountTypeWaste,
  11280. 'dailyExpenditureType' => $expenditureType,
  11281. 'accountBank' => $accountBank,
  11282. 'category' => $this->staff [0] ['category'],
  11283. 'cid' => $this->staff [0] ['cid'],
  11284. 'name' => $this->staff [0] ['username'],
  11285. 'sid' => $this->staff [0] ['sid'],
  11286. 'inputDate' => date ( "Y-m-d H:i:s" )
  11287. );
  11288. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11289. }
  11290. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11291. if ($expenditureType == 4 || $expenditureType == 6) {
  11292. $accountBank = 'CGBDeposit';
  11293. $dailyIncomeType = 7;
  11294. $receivedBank = '纵横广发';
  11295. if ($expenditureType == 6) {
  11296. $accountBank = 'ICBCDeposit';
  11297. $receivedBank = '纵横工行';
  11298. $dailyIncomeType = 9;
  11299. }
  11300. // 添加一笔收入
  11301. $accountBook = new accountBook ();
  11302. $accountBook->accountType = $dailyIncomeType;
  11303. $accountBook->accountMsg = $expenditureMsg;
  11304. $accountBook->receivedPrice = $expenditurePrice;
  11305. $accountBook->receivedBank = $receivedBank;
  11306. $accountBook->receivedDate = $expenditureDate;
  11307. $accountBook->remarks = $remarks;
  11308. $accountBook->expensesType = 1;
  11309. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11310. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11311. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11312. $id = $accountBook->insert ();
  11313. // 添加一笔收入流水
  11314. $itemWaste = array (
  11315. 'accountPriceShow' => $expenditurePrice,
  11316. 'accountPrice' => - $expenditurePrice,
  11317. 'dataID' => $id,
  11318. 'expensesType' => 1,
  11319. 'accountType' => $accountTypeWaste,
  11320. 'dailyIncomeType' => $dailyIncomeType,
  11321. 'accountBank' => $accountBank,
  11322. 'category' => $this->staff [0] ['category'],
  11323. 'cid' => $this->staff [0] ['cid'],
  11324. 'name' => $this->staff [0] ['username'],
  11325. 'sid' => $this->staff [0] ['sid'],
  11326. 'inputDate' => date ( "Y-m-d H:i:s" )
  11327. );
  11328. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11329. }
  11330. }
  11331. return '/payments';
  11332. }
  11333. /**
  11334. * 所有收支
  11335. */
  11336. function paymentsAchieve() {
  11337. $page_size = 12;
  11338. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11339. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11340. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11341. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11342. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11343. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11344. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11345. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11346. Doo::loadModel ( "accountBookStatistics" );
  11347. $accountBookStatistics = new accountBookStatistics ();
  11348. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11349. $data ['statisticsList'] = $statisticsList;
  11350. Doo::loadModel ( "accountBook" );
  11351. $accountBook = new accountBook ();
  11352. $con = '';
  11353. if ($expensesType == 'INCOME')
  11354. $con = ' and expensesType=1 ';
  11355. elseif ($expensesType == 'PAY')
  11356. $con = ' and expensesType=2 ';
  11357. $dateArr = explode ( ':', $date );
  11358. $D1 = $dateString = '';
  11359. $D2 = '';
  11360. if (! empty ( $date )) {
  11361. $D1 = $dateArr [0];
  11362. if (isset ( $dateArr [1] ))
  11363. $D2 = $dateArr [1];
  11364. else
  11365. $D2 = '';
  11366. $dateString = $D1 . " : " . $D2;
  11367. }
  11368. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11369. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11370. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11371. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11372. if (! empty ( $price ))
  11373. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11374. if ($submitType == 1) {
  11375. if ($accountType != '') {
  11376. $expenditureType = '';
  11377. $con .= ' and accountType=' . $accountType;
  11378. if (! empty ( $accountMsg ))
  11379. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11380. }
  11381. } elseif ($submitType == 2) {
  11382. if ($expenditureType != '') {
  11383. $accountType = $accountMsg = '';
  11384. $con .= ' and expenditureType=' . $expenditureType;
  11385. }
  11386. } else {
  11387. $accountType = $accountMsg = $expenditureType = '';
  11388. }
  11389. $sql = "" . $con;
  11390. $action = "paymentsAchieve";
  11391. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11392. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11393. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11394. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11395. $data ['expenditureType'] = $expenditureType;
  11396. $data ['accountMsg'] = $accountMsg;
  11397. $data ['accountType'] = $accountType;
  11398. $data ['inputDate'] = $date;
  11399. $data ['price'] = $price;
  11400. $data ['expensesType'] = $expensesType;
  11401. $data ['page'] = $pageinfo;
  11402. $data ['list'] = $list;
  11403. $data ['memu'] = "receipt";
  11404. $data ['staff'] = $this->staff;
  11405. $data ['receiptMemu'] = 'payments';
  11406. $data ['verifyId'] = $this->verifyId;
  11407. $data ['executeId'] = $this->executeId;
  11408. $this->render ( "/expenses/paymentsAchieve", $data );
  11409. }
  11410. function paymentsIncomeUpdateDo() {
  11411. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11412. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11413. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11414. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11415. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11416. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11417. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11418. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11419. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11420. Doo::loadClass ( 'XDeode' );
  11421. $XDeode = new XDeode ( 5 );
  11422. $aid = $XDeode->decode ( $aidKey );
  11423. Doo::loadModel ( "accountBook" );
  11424. $accountBook = new accountBook ();
  11425. //
  11426. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11427. $price = $receivedPrice - $abDetail [inComePrice];
  11428. Doo::loadModel ( "accountBookStatistics" );
  11429. $accountBookStatistics = new accountBookStatistics ();
  11430. if ($abDetail ['accountType'] == 7) {
  11431. $item += array (
  11432. 'date' => date ( "Y-m-d" ),
  11433. 'financingPrice' => - $price,
  11434. 'expensesType' => 3,
  11435. 'aid' => $abDetail ['aid']
  11436. );
  11437. } elseif ($abDetail ['accountType'] == 8) {
  11438. $item += array (
  11439. 'date' => date ( "Y-m-d" ),
  11440. 'expensesType' => $abDetail ['expensesType'],
  11441. 'inComePrice' => - $price,
  11442. 'aid' => $abDetail ['aid']
  11443. );
  11444. } else {
  11445. $item = array (
  11446. 'date' => date ( "Y-m-d" ),
  11447. 'expensesType' => $abDetail ['expensesType'],
  11448. 'inComePrice' => $price,
  11449. 'aid' => $abDetail ['aid']
  11450. );
  11451. }
  11452. $accountBookStatistics->setAccountBookStatistics ( $item );
  11453. $accountBook->accountType = $accountType;
  11454. $accountBook->accountMsg = $accountMsg;
  11455. $accountBook->receivedPrice = $receivedPrice;
  11456. $accountBook->receivedMsg = $receivedMsg;
  11457. $accountBook->receivedBank = $receivedBank;
  11458. $accountBook->receivedDate = $receivedDate;
  11459. $accountBook->remarks = $remarks;
  11460. $accountBook->aid = $aid;
  11461. $accountBook->update ();
  11462. }
  11463. return '/paymentsAchieve';
  11464. }
  11465. function paymentsExpenditureEdiDo() {
  11466. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11467. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11468. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11469. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11470. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11471. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11472. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11473. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11474. Doo::loadClass ( 'XDeode' );
  11475. $XDeode = new XDeode ( 5 );
  11476. $aid = $XDeode->decode ( $aidKey );
  11477. Doo::loadModel ( "accountBook" );
  11478. $accountBook = new accountBook ();
  11479. // 汇总信息
  11480. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11481. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11482. Doo::loadModel ( "accountBookStatistics" );
  11483. $accountBookStatistics = new accountBookStatistics ();
  11484. if ($abDetail ['expenditureType'] == 4) {
  11485. $item += array (
  11486. 'date' => date ( "Y-m-d" ),
  11487. 'financingPrice' => $price,
  11488. 'expensesType' => 3,
  11489. 'aid' => $abDetail ['aid']
  11490. );
  11491. } elseif ($abDetail ['expenditureType'] == 5) {
  11492. $item += array (
  11493. 'date' => date ( "Y-m-d" ),
  11494. 'expensesType' => $abDetail ['expensesType'],
  11495. 'payPrice' => $price,
  11496. 'aid' => $abDetail ['aid']
  11497. );
  11498. } else {
  11499. $item = array (
  11500. 'date' => date ( "Y-m-d" ),
  11501. 'expensesType' => $abDetail ['expensesType'],
  11502. 'payPrice' => $price,
  11503. 'aid' => $abDetail ['aid']
  11504. );
  11505. }
  11506. $accountBookStatistics->setAccountBookStatistics ( $item );
  11507. //
  11508. $accountBook->expenditureType = $expenditureType;
  11509. $accountBook->expenditureMsg = $expenditureMsg;
  11510. $accountBook->expenditurePrice = $expenditurePrice;
  11511. $accountBook->expenditureBank = $expenditureBank;
  11512. $accountBook->remarks = $remarks;
  11513. $accountBook->expenditureDate = $expenditureDate;
  11514. $accountBook->aid = $aid;
  11515. $id = $accountBook->update ();
  11516. }
  11517. return '/paymentsAchieve';
  11518. }
  11519. function paymentsDelDo() {
  11520. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11521. if (! empty ( $aidKey )) {
  11522. Doo::loadClass ( 'XDeode' );
  11523. $XDeode = new XDeode ( 5 );
  11524. $aid = $XDeode->decode ( $aidKey );
  11525. Doo::loadModel ( "accountBook" );
  11526. $accountBook = new accountBook ();
  11527. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11528. if (empty ( $abDetail ))
  11529. die ( 'illegal request' );
  11530. // 删除收支
  11531. Doo::loadModel ( "accountBookStatistics" );
  11532. $accountBookStatistics = new accountBookStatistics ();
  11533. $item = array (
  11534. 'date' => date ( "Y-m-d" ),
  11535. 'aid' => $abDetail ['aid']
  11536. );
  11537. $accountType = '';
  11538. if ($abDetail ['expensesType'] == 1) {
  11539. $accountType = 6;
  11540. if ($abDetail ['accountType'] != 7) {
  11541. $item += array (
  11542. 'expensesType' => $abDetail ['expensesType'],
  11543. 'inComePrice' => - $abDetail ['receivedPrice']
  11544. );
  11545. } else {
  11546. $item += array (
  11547. 'financingPrice' => $abDetail ['receivedPrice'],
  11548. 'expensesType' => 3
  11549. );
  11550. }
  11551. } elseif ($abDetail ['expensesType'] == 2) {
  11552. $accountType = 5;
  11553. if ($abDetail ['accountType'] != 7) {
  11554. $item += array (
  11555. 'expensesType' => $abDetail ['expensesType'],
  11556. 'payPrice' => - $abDetail ['expenditurePrice']
  11557. );
  11558. } else {
  11559. $item += array (
  11560. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11561. 'expensesType' => 3
  11562. );
  11563. }
  11564. }
  11565. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11566. if ($abDetail ['expenditureMsg'] == '公司固定')
  11567. $accountType = 9;
  11568. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11569. $accountType = 10;
  11570. }
  11571. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11572. if ($abDetail ['accountMsg'] == '公司固定')
  11573. $accountType = 9;
  11574. elseif ($abDetail ['accountMsg'] == '公司活期')
  11575. $accountType = 10;
  11576. }
  11577. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11578. $accountType = 10;
  11579. }
  11580. $accountBookStatistics->setAccountBookStatistics ( $item );
  11581. $accountBook->delete ( array (
  11582. 'where' => 'aid=' . $aid,
  11583. 'limit' => 1
  11584. ) );
  11585. // 删除收入流水
  11586. if (! empty ( $accountType )) {
  11587. Doo::loadModel ( 'wasteBook' );
  11588. $wasteBook = new wasteBook ();
  11589. $wasteBook->delete ( array (
  11590. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11591. 'limit' => 1
  11592. ) );
  11593. }
  11594. }
  11595. return '/paymentsAchieve';
  11596. }
  11597. function paymentsCollect() {
  11598. Doo::loadModel ( "execute" );
  11599. $execute = new execute ();
  11600. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11601. die ( 'illegal request' );
  11602. }
  11603. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11604. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11605. Doo::loadModel ( "accountBookStatistics" );
  11606. $accountBookStatistics = new accountBookStatistics ();
  11607. Doo::loadClass ( 'receipt.func' );
  11608. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11609. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11610. $data ['html'] = $html ['html'];
  11611. $data ['inSum'] = $html ['sum'];
  11612. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11613. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11614. $data ['payHtml'] = $html ['html'];
  11615. $data ['paySum'] = $html ['sum'];
  11616. // 余额统计
  11617. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11618. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11619. include './protected/config/wasteBook.conf.php';
  11620. Doo::loadModel ( 'wasteBook' );
  11621. $wasteBook = new wasteBook ();
  11622. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11623. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11624. // 获得年份之前所有金额
  11625. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11626. // print_r($detail);
  11627. // $waste['total'];
  11628. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11629. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11630. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11631. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11632. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11633. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11634. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11635. if (date ( 'Y' ) > $year) {
  11636. $limitMonth = 12;
  11637. }
  11638. for($i = 1; $i <= 12; $i ++) {
  11639. $inComeA = $payB = 0;
  11640. $falg = true;
  11641. foreach ( $inComePay as $key => $value ) {
  11642. if ($value ['month'] == $i) {
  11643. $falg = false;
  11644. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11645. $inSum += $value ['accountPrice'];
  11646. $showInSum += $value ['accountPriceShow'];
  11647. $inComeA = $value ['accountPrice'];
  11648. break;
  11649. }
  11650. }
  11651. if ($falg)
  11652. $inComeHtml .= '<td class="taR">-</td>';
  11653. $payFalg = true;
  11654. foreach ( $pay as $key => $value ) {
  11655. if ($value ['month'] == $i) {
  11656. $payFalg = false;
  11657. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11658. $paySum += $value ['accountPrice'];
  11659. $showPaySum += $value ['accountPriceShow'];
  11660. $payB = $value ['accountPrice'];
  11661. break;
  11662. }
  11663. }
  11664. if ($payFalg)
  11665. $payHtml .= '<td class="taR">-</td>';
  11666. if (empty ( $balanceC ) || $limitMonth < $i)
  11667. $lastBalanceHtml .= '<td class="taR">-</td>';
  11668. else
  11669. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11670. $balanceC = $balanceC + $inComeA + $payB;
  11671. $balanceSum += $balanceC;
  11672. if (empty ( $balanceC ) || $limitMonth < $i)
  11673. $BalanceHtml .= '<td class="taR">-</td>';
  11674. else
  11675. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11676. // 余额统计
  11677. }
  11678. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11679. $data ['inComeHtml'] = $inComeHtml;
  11680. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11681. $data ['payBalanceHtml'] = $payHtml;
  11682. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11683. $data ['BalanceHtml'] = $BalanceHtml;
  11684. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11685. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11686. $mothHtml = "";
  11687. for($i = 1; $i <= 12; $i ++) {
  11688. if ($moth == $i)
  11689. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11690. else
  11691. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11692. }
  11693. $data ['mothHtml'] = $mothHtml;
  11694. $dateHtml = "";
  11695. $now = date ( "Y" );
  11696. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11697. if ($YEARD <= $now) {
  11698. $dateHtml .= '<option ';
  11699. if ($year == $YEARD) {
  11700. $dateHtml .= 'selected ';
  11701. }
  11702. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11703. }
  11704. }
  11705. $data ['dateHtml'] = $dateHtml;
  11706. $data ['year'] = $year;
  11707. $data ['memu'] = "receipt";
  11708. $data ['staff'] = $this->staff;
  11709. $data ['receiptMemu'] = 'paymentsCollect';
  11710. $data ['verifyId'] = $this->verifyId;
  11711. $data ['executeId'] = $this->executeId;
  11712. $this->render ( "/expenses/paymentsCollect", $data );
  11713. }
  11714. function paymentsCollectDay() {
  11715. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11716. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11717. if (empty ( $moth ))
  11718. return 'paymentsCollect';
  11719. Doo::loadModel ( "accountBookStatistics" );
  11720. $accountBookStatistics = new accountBookStatistics ();
  11721. $i = 2;
  11722. $y = 2013;
  11723. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11724. Doo::loadClass ( 'receipt.func' );
  11725. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11726. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11727. $data ['html'] = $html ['html'];
  11728. $data ['inSum'] = $html ['sum'];
  11729. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11730. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11731. $data ['payHtml'] = $html ['html'];
  11732. $data ['paySum'] = $html ['sum'];
  11733. $mothHtml = "";
  11734. for($i = 1; $i <= 12; $i ++) {
  11735. if ($moth == $i)
  11736. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11737. else
  11738. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11739. }
  11740. $data ['mothHtml'] = $mothHtml;
  11741. $data ['year'] = $year;
  11742. // 余额
  11743. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11744. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11745. include './protected/config/wasteBook.conf.php';
  11746. Doo::loadModel ( 'wasteBook' );
  11747. $wasteBook = new wasteBook ();
  11748. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11749. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11750. // 获得年份之前所有金额
  11751. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11752. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11753. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11754. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11755. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11756. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11757. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11758. // $balanceC = 0;
  11759. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11760. $limitDay = date ( 'd' );
  11761. $monthLK = ( int ) date ( 'm' );
  11762. if (date ( 'Y' ) > $year) {
  11763. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11764. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11765. $limitDay = 0;
  11766. }
  11767. for($i = 1; $i <= $day; $i ++) {
  11768. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11769. $inComeA = $payB = 0;
  11770. $falg = true;
  11771. foreach ( $inComePay as $key => $value ) {
  11772. if ($value ['day'] == $i) {
  11773. $falg = false;
  11774. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11775. $inSum += $value ['accountPrice'];
  11776. $showInSum += $value ['accountPriceShow'];
  11777. $inComeA = $value ['accountPrice'];
  11778. break;
  11779. }
  11780. }
  11781. if ($falg)
  11782. $inComeHtml .= '<td class="taR">-</td>';
  11783. $payFalg = true;
  11784. foreach ( $pay as $key => $value ) {
  11785. if ($value ['day'] == $i) {
  11786. $payFalg = false;
  11787. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11788. $paySum += $value ['accountPrice'];
  11789. $showPaySum += $value ['accountPriceShow'];
  11790. $payB = $value ['accountPrice'];
  11791. break;
  11792. }
  11793. }
  11794. if ($payFalg)
  11795. $payHtml .= '<td class="taR">-</td>';
  11796. if (empty ( $balanceC ) || $limitDay < $i)
  11797. $lastBalanceHtml .= '<td class="taR">-</td>';
  11798. else
  11799. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11800. $balanceC = $balanceC + $inComeA + $payB;
  11801. $balanceSum += $balanceC;
  11802. if (empty ( $balanceC ) || $limitDay < $i)
  11803. $BalanceHtml .= '<td class="taR">-</td>';
  11804. else
  11805. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11806. }
  11807. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11808. $data ['inComeHtml'] = $inComeHtml;
  11809. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11810. $data ['payBalanceHtml'] = $payHtml;
  11811. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11812. $data ['BalanceHtml'] = $BalanceHtml;
  11813. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11814. $data ['dayHtml'] = $dayHtml;
  11815. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11816. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11817. $dateHtml = "";
  11818. $now = date ( "Y" );
  11819. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11820. if ($YEARD <= $now) {
  11821. $dateHtml .= '<option ';
  11822. if ($year == $YEARD) {
  11823. $dateHtml .= 'selected ';
  11824. }
  11825. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11826. }
  11827. }
  11828. $data ['dateHtml'] = $dateHtml;
  11829. $data ['memu'] = "receipt";
  11830. $data ['staff'] = $this->staff;
  11831. $data ['receiptMemu'] = 'paymentsCollect';
  11832. $data ['verifyId'] = $this->verifyId;
  11833. $data ['executeId'] = $this->executeId;
  11834. $this->render ( "/expenses/paymentsCollectDay", $data );
  11835. }
  11836. // 公司流水
  11837. function wasteBook() {
  11838. Doo::loadModel ( "execute" );
  11839. $execute = new execute ();
  11840. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11841. die ( 'illegal request' );
  11842. }
  11843. include './protected/config/wasteBook.conf.php';
  11844. Doo::loadModel ( 'wasteBook' );
  11845. $wasteBook = new wasteBook ();
  11846. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11847. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11848. //
  11849. $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'];
  11850. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  11851. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  11852. // print_r($waste);
  11853. $data ['waste'] = $waste;
  11854. $data ['total'] = $total;
  11855. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  11856. $data['cashBalance']= $CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  11857. // 月流水数据结构
  11858. $monthStatistics = array ();
  11859. $incomeMothStatistics = array ();
  11860. $expenditureMothStatistics = array ();
  11861. for($i = 1; $i <= 12; $i ++) {
  11862. $month = date ( 'Y' ) . '-' . $i;
  11863. if ($i < 10)
  11864. $month = date ( 'Y' ) . '-0' . $i;
  11865. array_push ( $monthStatistics, $month );
  11866. }
  11867. foreach ( $monthStatistics as $value ) {
  11868. $falg = true;
  11869. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11870. if ($value == $v ['inputDate']) {
  11871. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11872. $falg = false;
  11873. }
  11874. }
  11875. if ($falg) {
  11876. array_push ( $incomeMothStatistics, '' );
  11877. }
  11878. $falgEx = true;
  11879. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11880. if ($value == $v ['inputDate']) {
  11881. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11882. $falg = false;
  11883. }
  11884. }
  11885. if ($falgEx) {
  11886. array_push ( $expenditureMothStatistics, '' );
  11887. }
  11888. }
  11889. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11890. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11891. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11892. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11893. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11894. // print_r($incomeList);
  11895. $data ['expenditureList'] = $expenditureList;
  11896. $data ['incomeList'] = $incomeList;
  11897. $data ['memu'] = "receipt";
  11898. $data ['staff'] = $this->staff;
  11899. $data ['receiptMemu'] = 'wasteBook';
  11900. $data ['verifyId'] = $this->verifyId;
  11901. $data ['executeId'] = $this->executeId;
  11902. $this->render ( "/expenses/wasteBook", $data );
  11903. }
  11904. function wasteBookIncome() {
  11905. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11906. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11907. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11908. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11909. $data ['dailyIncomeType'] = $dailyIncomeType;
  11910. Doo::loadModel ( 'wasteBook' );
  11911. $wasteBook = new wasteBook ();
  11912. Doo::loadModel ( 'L_category' );
  11913. $L_category = new L_category ();
  11914. Doo::loadClass ( 'XDeode' );
  11915. $XDeode = new XDeode ( 5 );
  11916. $year=date("Y");
  11917. $theDay=date("Y-m-d");
  11918. $dateArr = explode ( ':', $date );
  11919. $D1 = '';
  11920. $D2 = '';
  11921. $con = '';
  11922. if (! empty ( $date )) {
  11923. $D1 = $dateArr [0];
  11924. $D2 = $dateArr [1];
  11925. }
  11926. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11927. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11928. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11929. $con = ' and inputDate = "' . $D1 . '"';
  11930. else{
  11931. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11932. }
  11933. if ($cid != 'ALL') {
  11934. $cid = $XDeode->decode ( $cid );
  11935. $con .= ' and cid = "' . $cid . '"';
  11936. }
  11937. if ($accountType != 'ALL') {
  11938. if ($accountType == 'INVOICE') {
  11939. $con .= ' and (accountType = 7 or accountType = 8)';
  11940. } elseif ($accountType == 'PAYMENTS') {
  11941. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11942. if ($dailyIncomeType != 'ALL') {
  11943. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11944. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11945. }
  11946. }
  11947. }
  11948. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11949. foreach ($incomeList as $key=>$value){
  11950. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  11951. $wasteBook = new wasteBook ();
  11952. $wasteBook->wid = $value['wid'];
  11953. $wasteBook->synPaymentDate = 1;
  11954. $wasteBook->inputDate = $value['data']['receivedDate'];
  11955. $wasteBook->update();
  11956. }
  11957. }
  11958. $sum = 0;$thsDaySum=0;
  11959. foreach ( $incomeList as $key => $value ) {
  11960. $sum += $value ['accountPrice'];
  11961. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11962. $thsDaySum+=$value ['accountPrice'];
  11963. }
  11964. }
  11965. // print_r($incomeList);
  11966. // 获得办事和部门
  11967. $categoryList = $L_category->getCategory ();
  11968. $data ['accountType'] = $accountType;
  11969. $data ['cid'] = $cid;
  11970. $data ['categoryList'] = $categoryList;
  11971. $data ['sum'] = $sum;
  11972. $data ['incomeList'] = $incomeList;
  11973. $data ['inputDate'] = $date;
  11974. $data['year']=$year;
  11975. $data ['thsDay'] =$theDay;
  11976. $data ['thsDaySum'] =$thsDaySum;
  11977. $data ['memu'] = "receipt";
  11978. $data ['staff'] = $this->staff;
  11979. $data ['receiptMemu'] = 'wasteBook';
  11980. $data ['verifyId'] = $this->verifyId;
  11981. $data ['executeId'] = $this->executeId;
  11982. $this->render ( "/expenses/wasteBookIncome", $data );
  11983. }
  11984. /**
  11985. * 所有支出
  11986. */
  11987. function wasteBookExpenditure() {
  11988. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11989. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11990. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11991. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11992. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11993. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11994. $data ['receiptType'] = $receiptType;
  11995. Doo::loadModel ( 'wasteBook' );
  11996. $wasteBook = new wasteBook ();
  11997. Doo::loadModel ( 'L_category' );
  11998. $L_category = new L_category ();
  11999. Doo::loadClass ( 'XDeode' );
  12000. $XDeode = new XDeode ( 5 );
  12001. $year=date("Y");
  12002. $theDay=date("Y-m-d");
  12003. $dateArr = explode ( ':', $date );
  12004. $D1 = '';
  12005. $D2 = '';
  12006. $con = '';
  12007. if (! empty ( $date )) {
  12008. $D1 = $dateArr [0];
  12009. $D2 = $dateArr [1];
  12010. }
  12011. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12012. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12013. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12014. $con = ' and inputDate = "' . $D1 . '"';
  12015. else{
  12016. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12017. }
  12018. if ($cid != 'ALL') {
  12019. $cid = $XDeode->decode ( $cid );
  12020. $con .= ' and cid = "' . $cid . '"';
  12021. }
  12022. if ($accountType != 'ALL') {
  12023. if ($accountType == 'INVOICE') {
  12024. $con .= ' and accountType = 11';
  12025. } elseif ($accountType == 'PAYMENTS') {
  12026. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12027. if ($dailyExpenditureType != 'ALL') {
  12028. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12029. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12030. }
  12031. } elseif ($accountType == 'RECEIPT') {
  12032. if ($receiptType == 'ALL') {
  12033. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12034. } else {
  12035. $receiptType = $XDeode->decode ( $receiptType );
  12036. echo $receiptType;
  12037. if ($receiptType == 1) {
  12038. $con .= ' and (accountType = 1 or accountType=2)';
  12039. } else {
  12040. $con .= ' and accountType = ' . $receiptType;
  12041. }
  12042. }
  12043. }
  12044. }
  12045. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12046. foreach ($incomeList as $key=>$value){
  12047. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12048. $wasteBook = new wasteBook ();
  12049. $wasteBook->wid = $value['wid'];
  12050. $wasteBook->synPaymentDate = 1;
  12051. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12052. $wasteBook->update();
  12053. }
  12054. }
  12055. $sum = 0;$thsDaySum=0;
  12056. foreach ( $incomeList as $key => $value ) {
  12057. $sum += $value ['accountPriceShow'];
  12058. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12059. $thsDaySum+=$value ['accountPriceShow'];
  12060. }
  12061. }
  12062. // print_r($incomeList);
  12063. // 获得办事和部门
  12064. $categoryList = $L_category->getCategory ();
  12065. $data ['accountType'] = $accountType;
  12066. $data ['cid'] = $cid;
  12067. $data ['categoryList'] = $categoryList;
  12068. $data ['sum'] = $sum;
  12069. $data ['incomeList'] = $incomeList;
  12070. $data ['inputDate'] = $date;
  12071. $data['year']=$year;
  12072. $data ['thsDay'] =$theDay;
  12073. $data ['thsDaySum'] =$thsDaySum;
  12074. $data ['memu'] = "receipt";
  12075. $data ['staff'] = $this->staff;
  12076. $data ['receiptMemu'] = 'wasteBook';
  12077. $data ['verifyId'] = $this->verifyId;
  12078. $data ['executeId'] = $this->executeId;
  12079. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12080. }
  12081. function ajaxGetWasteinvoiceReceivables() {
  12082. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12083. Doo::loadClass ( 'XDeode' );
  12084. $XDeode = new XDeode ( 5 );
  12085. $irid = $XDeode->decode ( $serial );
  12086. Doo::loadModel ( 'invoiceReceivables' );
  12087. $invoiceReceivables = new invoiceReceivables ();
  12088. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12089. echo json_encode ( array (
  12090. 'status' => 1,
  12091. 'detail' => $detail
  12092. ) );
  12093. }
  12094. function ajaxGetPaymentsByAid() {
  12095. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12096. Doo::loadModel ( "accountBook" );
  12097. $accountBook = new accountBook ();
  12098. $detail = $accountBook->getAccountBookByAid ( $serial );
  12099. echo json_encode ( array (
  12100. 'status' => 1,
  12101. 'detail' => $detail
  12102. ) );
  12103. }
  12104. function ajaxGetWasteInvoice() {
  12105. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12106. Doo::loadModel ( 'invoice' );
  12107. $invoice = new invoice ();
  12108. Doo::loadModel ( 'invoiceReceivables' );
  12109. $invoiceReceivables = new invoiceReceivables ();
  12110. $detail = $invoice->getInvoiceByIid ( $serial );
  12111. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12112. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12113. echo json_encode ( array (
  12114. 'status' => 1,
  12115. 'detail' => $detail
  12116. ) );
  12117. }
  12118. /**
  12119. */
  12120. function ajaxGetWasteReceipt() {
  12121. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12122. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12123. Doo::loadModel ( 'receipt' );
  12124. $receipt = new receipt ();
  12125. Doo::loadClass ( 'XDeode' );
  12126. $XDeode = new XDeode ( 5 );
  12127. $rid = $XDeode->decode ( $serial );
  12128. $accountType= $XDeode->decode ( $accountTypeKey );
  12129. // 获得个数据
  12130. $detail = $receipt->getReceiptByRid ( $rid );
  12131. // 初始化
  12132. $detail ['reviseDetail'] = array ();
  12133. if (! empty ( $value ['reviseDetail'] ))
  12134. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12135. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12136. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12137. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12138. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12139. // 获得费用html
  12140. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12141. // 获得费用审批人数据
  12142. $detail = $this->getReceiptApproverHtml ( $detail );
  12143. // 审批执行
  12144. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12145. <th class="taC" width="90">审批人</th>
  12146. <th class="taC">审批意见</th></tr>';
  12147. foreach ( $detail ['verifyList'] as $key => $value ) {
  12148. $html .= '<tr>
  12149. <td>' . $value [1] . '</td>
  12150. <td>' . $value ['opinion'] . '</td>
  12151. </tr>
  12152. ';
  12153. }
  12154. $html .= ' </tbody></table>';
  12155. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12156. <th class="taC" width="90">执行人</th>
  12157. <th class="taC">执行意见</th></tr>';
  12158. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12159. $html .= '<tr>
  12160. <td>' . $value [1] . '</td>
  12161. <td>' . $value ['opinion'] . '</td>
  12162. </tr>
  12163. ';
  12164. }
  12165. $html .= ' </tbody></table>';
  12166. if($accountType==1){
  12167. Doo::loadModel ( 'loanReceipt' );
  12168. $loanReceipt = new loanReceipt ();
  12169. $loanList = $loanReceipt->getOne ( array (
  12170. 'where' => 'rid=' . $detail ['loanRid'],
  12171. 'desc' => 'rid',
  12172. 'asArray' => true
  12173. ) );
  12174. $html .= '<table class="table table-bordered table-condensed">
  12175. <tr class="warning">
  12176. <td class="taR"><b>汇款金额</b></td>
  12177. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12178. </tr>
  12179. </table>';
  12180. }else{
  12181. $html .= '<table class="table table-bordered table-condensed">
  12182. <tr class="warning">
  12183. <td class="taR"><b>汇款金额</b></td>
  12184. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12185. </tr>
  12186. </table>';
  12187. }
  12188. // print_r($detail['verifyList']);
  12189. // header ( 'Content-Type:text/html;charset=utf-8' );
  12190. // echo $html;
  12191. echo json_encode ( array (
  12192. 'status' => 1,
  12193. 'html' => $html,
  12194. 'detail' => $detail
  12195. ) );
  12196. }
  12197. function getReceiptApproverHtml($detail = array()) {
  12198. Doo::loadModel ( 'loanReceipt' );
  12199. $loanReceipt = new loanReceipt ();
  12200. Doo::loadModel ( 'verify' );
  12201. $verify = new verify ();
  12202. Doo::loadModel ( 'staff' );
  12203. $staff = new staff ();
  12204. if (empty ( $detail ))
  12205. return array ();
  12206. $loanList = $loanReceipt->getOne ( array (
  12207. 'where' => 'rid=' . $detail ['loanRid'],
  12208. 'desc' => 'rid',
  12209. 'asArray' => true
  12210. ) );
  12211. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12212. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12213. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12214. else
  12215. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12216. } else
  12217. $verifyList = $verify->getOne ( array (
  12218. 'where' => 'vid=' . $detail ['verify'],
  12219. 'asArray' => true
  12220. ) );
  12221. $verifyList = json_decode ( $verifyList ['staff'], true );
  12222. Doo::loadModel ( 'role' );
  12223. $role = new role ();
  12224. $roleId = 0;
  12225. $flag = true;
  12226. $roleKey = 0;
  12227. $endStaffArray = array ();
  12228. $roleArrayCopy = array ();
  12229. foreach ( $verifyList as $k => $v ) {
  12230. // init verifyStaff
  12231. if ($v [1] == 'ROLE') {
  12232. if (! empty ( $verifyStaff )) {
  12233. $endStaffArray = end ( $verifyStaff );
  12234. }
  12235. $roleVerify = json_decode ( $v [3], true );
  12236. $roleKey = $k;
  12237. $roleArray = array ();
  12238. $rolename = $role->getOne ( array (
  12239. 'where' => 'rid=' . $v [0],
  12240. 'asArray' => true
  12241. ) );
  12242. foreach ( $roleVerify as $o => $p ) {
  12243. $staffID = explode ( '_', $p );
  12244. $staffInfo = $staff->getOne ( array (
  12245. 'where' => 'sid=' . $staffID [0],
  12246. 'asArray' => true
  12247. ) );
  12248. // print_r($staffID);
  12249. $exp = array (
  12250. 0 => $staffInfo ['sid'],
  12251. 1 => $staffID [1],
  12252. 2 => $staffInfo ['avatar'],
  12253. 'date' => '',
  12254. 'date' => '',
  12255. 'opinion' => '',
  12256. 'status' => '',
  12257. 'rolename' => $rolename ['name']
  12258. );
  12259. array_push ( $roleArray, $exp );
  12260. }
  12261. $roleArrayCopy [$v [0]] = $roleArray;
  12262. // $verifyList[$k]['roleArray']=$roleArray;
  12263. }
  12264. $verifyList [$k] ['date'] = "";
  12265. $verifyList [$k] ['opinion'] = "";
  12266. $verifyList [$k] ['status'] = "";
  12267. if (empty ( $verifyStaff )) {
  12268. $verifyList [$k] ['date'] = "";
  12269. $verifyList [$k] ['opinion'] = "";
  12270. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12271. $verifyList [$k] ['status'] = 4;
  12272. $flag = false;
  12273. }
  12274. } else {
  12275. foreach ( $verifyStaff as $m => $u ) {
  12276. if ($v [0] == $m) {
  12277. $verifyList [$k] ['date'] = $u ['date'];
  12278. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12279. $verifyList [$k] ['status'] = $u ['status'];
  12280. $flag = false;
  12281. break;
  12282. }
  12283. }
  12284. $endStaffArray = end ( $verifyStaff );
  12285. }
  12286. }
  12287. $rolename ['name'] = '';
  12288. if (! empty ( $roleId )) {
  12289. Doo::loadModel ( 'role' );
  12290. $role = new role ();
  12291. $rolename = $role->getOne ( array (
  12292. 'where' => 'rid=' . $roleId,
  12293. 'asArray' => true
  12294. ) );
  12295. }
  12296. if (! empty ( $verifyStaff ))
  12297. $endStaffArray = end ( $verifyStaff );
  12298. $KOP = false;
  12299. foreach ( $roleArrayCopy as $P => $A ) {
  12300. foreach ( $A as $MKI => $AVL ) {
  12301. if (! empty ( $verifyStaff )) {
  12302. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12303. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12304. $button = 4;
  12305. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12306. }
  12307. foreach ( $verifyStaff as $m => $u ) {
  12308. $AVLFK = $AVL [0] . '_R';
  12309. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12310. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12311. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12312. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12313. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12314. break;
  12315. }
  12316. }
  12317. } else {
  12318. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12319. $button = 4;
  12320. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12321. }
  12322. }
  12323. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12324. $KOP = true;
  12325. }
  12326. }
  12327. foreach ( $roleArrayCopy as $k => $v ) {
  12328. foreach ( $verifyList as $m => $n ) {
  12329. if ($n [0] == $k) {
  12330. array_splice ( $verifyList, $m, 1, $v );
  12331. }
  12332. }
  12333. }
  12334. // 费用执行人相关数据
  12335. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12336. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12337. foreach ( $executeCopy as $k => $v ) {
  12338. $executeCopy [$k] ['date'] = '';
  12339. $executeCopy [$k] ['opinion'] = '';
  12340. $executeCopy [$k] ['status'] = '';
  12341. if (! empty ( $executeStaff ))
  12342. foreach ( $executeStaff as $m => $u ) {
  12343. if ($v [0] == $m) {
  12344. $executeCopy [$k] ['date'] = $u ['date'];
  12345. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12346. $executeCopy [$k] ['status'] = $u ['status'];
  12347. break;
  12348. }
  12349. }
  12350. }
  12351. $detail ['executeCopy'] = $executeCopy;
  12352. $detail ['verifyList'] = $verifyList;
  12353. return $detail;
  12354. }
  12355. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12356. if (empty ( $detail ))
  12357. return '';
  12358. $html = '';
  12359. if ($detail ['Rtype'] == 0) { // 报销单
  12360. $html .= '<table class="table table-bordered table-condensed">
  12361. <tbody>
  12362. <tr>
  12363. <th colspan="2" class="taC">日常相关费用</th>
  12364. </tr>';
  12365. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12366. $html .= '
  12367. <tr>
  12368. <th>' . $value ['name'] . '</th>
  12369. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12370. </tr>';
  12371. }
  12372. $html .= '
  12373. <tr>
  12374. <th class="taR">合计</th>
  12375. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12376. </tr>';
  12377. $html .= '<tr>
  12378. <th colspan="2" class="taC">差旅相关费用</th>
  12379. </tr>';
  12380. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12381. $html .= '
  12382. <tr>
  12383. <th>' . $value ['name'] . '</th>
  12384. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12385. </tr>';
  12386. }
  12387. $html .= '
  12388. <tr>
  12389. <th class="taR">合计</th>
  12390. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12391. </tr>';
  12392. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12393. $html .= '<tr>
  12394. <th colspan="2" class="taC">内部培训费用</th>
  12395. </tr>';
  12396. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12397. $html .= '
  12398. <tr>
  12399. <th>' . $value ['name'] . '</th>
  12400. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12401. </tr>';
  12402. }
  12403. $html .= '
  12404. <tr>
  12405. <th class="taR">合计</th>
  12406. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12407. </tr>';
  12408. }
  12409. $html .= '<tr>
  12410. <th colspan="2" class="taC">其他</th>
  12411. </tr>';
  12412. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12413. $html .= '
  12414. <tr>
  12415. <th>' . $value ['name'] . '</th>
  12416. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12417. </tr>';
  12418. }
  12419. $html .= '
  12420. <tr>
  12421. <th class="taR">合计</th>
  12422. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12423. </tr>';
  12424. $html .= '<tr>
  12425. <th colspan="2" class="taC">报销金额调整</th>
  12426. </tr>';
  12427. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12428. $html .= '
  12429. <tr>
  12430. <th>' . $value ['name'] . '</th>
  12431. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12432. </tr>';
  12433. }
  12434. $html .= '
  12435. <tr>
  12436. <th class="taR">合计</th>
  12437. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12438. </tr>';
  12439. $html .= '
  12440. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12441. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12442. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12443. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12444. <tr class="warning">
  12445. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12446. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12447. </tr>
  12448. </tbody>
  12449. </table>';
  12450. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12451. $html .= '
  12452. <table class="table table-bordered table-condensed">
  12453. <tbody>
  12454. <tr>
  12455. <th colspan="2" class="taC">办事处相关费用</th>
  12456. </tr>';
  12457. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12458. $html .= '
  12459. <tr>
  12460. <th>' . $value ['name'] . '</th>
  12461. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12462. </tr>';
  12463. }
  12464. $html .= '
  12465. <tr>
  12466. <th class="taR">合计</th>
  12467. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12468. </tr>';
  12469. $html .= '
  12470. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12471. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12472. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12473. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12474. <tr class="warning">
  12475. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12476. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12477. </tr>
  12478. </tbody>
  12479. </table>';
  12480. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12481. Doo::loadModel ( 'loanReceipt' );
  12482. $loanReceipt = new loanReceipt ();
  12483. $loanList = $loanReceipt->getOne ( array (
  12484. 'where' => 'rid=' . $detail ['loanRid'],
  12485. 'desc' => 'rid',
  12486. 'asArray' => true
  12487. ) );
  12488. // print_r($loanList);
  12489. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12490. $html .= '<table class="table table-bordered table-condensed">
  12491. <tbody>
  12492. <tr>
  12493. <th colspan="2" class="taC">借款费用</th>
  12494. </tr>';
  12495. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12496. $html .= '<tr>
  12497. <th>' . $value ['name'] . '</th>
  12498. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12499. </tr>';
  12500. }
  12501. $html .= '<tr>
  12502. <th class="taC" colspan="2">产生费用所在办事处</th>
  12503. </tr>
  12504. <tr>
  12505. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12506. </tr>
  12507. <tr>
  12508. <th class="taC" colspan="2">费用说明</th>
  12509. </tr>
  12510. <tr>
  12511. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12512. </tr>
  12513. <tr class="warning">
  12514. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12515. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12516. </tr>
  12517. </tbody>
  12518. </table>
  12519. ';
  12520. if ( $accountType==2) {
  12521. $balance=$detail ['sum']-$loanList ['sum'];
  12522. $balanceCN=$this->num_to_rmb($balance);
  12523. $html .= '<table class="table table-bordered table-condensed">
  12524. <tbody>
  12525. <tr>
  12526. <th colspan="2" class="taC">日常相关费用</th>
  12527. </tr>';
  12528. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12529. $html .= '
  12530. <tr>
  12531. <th>' . $value ['name'] . '</th>
  12532. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12533. </tr>';
  12534. }
  12535. $html .= '
  12536. <tr>
  12537. <th class="taR">合计</th>
  12538. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12539. </tr>';
  12540. $html .= '<tr>
  12541. <th colspan="2" class="taC">差旅相关费用</th>
  12542. </tr>';
  12543. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12544. $html .= '
  12545. <tr>
  12546. <th>' . $value ['name'] . '</th>
  12547. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12548. </tr>';
  12549. }
  12550. $html .= '
  12551. <tr>
  12552. <th class="taR">合计</th>
  12553. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12554. </tr>';
  12555. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12556. $html .= '<tr>
  12557. <th colspan="2" class="taC">内部培训费用</th>
  12558. </tr>';
  12559. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12560. $html .= '
  12561. <tr>
  12562. <th>' . $value ['name'] . '</th>
  12563. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12564. </tr>';
  12565. }
  12566. $html .= '
  12567. <tr>
  12568. <th class="taR">合计</th>
  12569. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12570. </tr>';
  12571. }
  12572. $html .= '<tr>
  12573. <th colspan="2" class="taC">其他</th>
  12574. </tr>';
  12575. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12576. $html .= '
  12577. <tr>
  12578. <th>' . $value ['name'] . '</th>
  12579. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12580. </tr>';
  12581. }
  12582. $html .= '
  12583. <tr>
  12584. <th class="taR">合计</th>
  12585. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12586. </tr>';
  12587. $html .= '<tr>
  12588. <th colspan="2" class="taC">报销金额调整</th>
  12589. </tr>';
  12590. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12591. $html .= '
  12592. <tr>
  12593. <th>' . $value ['name'] . '</th>
  12594. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12595. </tr>';
  12596. }
  12597. $html .= '
  12598. <tr>
  12599. <th class="taR">合计</th>
  12600. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12601. </tr>';
  12602. $html .= '
  12603. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12604. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12605. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12606. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12607. <tr class="warning">
  12608. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12609. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12610. </tr>
  12611. <tr class="success">
  12612. <td class="taR"><b>借款结余</b></td>
  12613. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12614. </tr>
  12615. </tbody>
  12616. </table>';
  12617. }
  12618. }
  12619. return $html;
  12620. }
  12621. /**
  12622. * 计算流水
  12623. */
  12624. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12625. $bakWaste ['bank'] = array (
  12626. 'CGBDeposit' => 0,
  12627. 'ICBCDeposit' => 0,
  12628. 'HUADeposit' => 0,
  12629. 'PersonalDeposit' => 0
  12630. );
  12631. $bakWaste ['financial'] = array (
  12632. 'current' => array (
  12633. 'CGBDeposit' => 0,
  12634. 'ICBCDeposit' => 0
  12635. ),
  12636. 'fixed' => array (
  12637. 'CGBDeposit' => 0,
  12638. 'ICBCDeposit' => 0
  12639. )
  12640. );
  12641. // 存款
  12642. foreach ( $waste ['bank'] as $key => $value ) {
  12643. // 收入
  12644. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12645. // 广发
  12646. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12647. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12648. }
  12649. // 工商
  12650. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12651. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12652. }
  12653. // 华润
  12654. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12655. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12656. }
  12657. // 个人
  12658. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12659. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12660. }
  12661. }
  12662. }
  12663. foreach ( $waste ['bank'] as $key => $value ) {
  12664. // 支出
  12665. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12666. // 广发
  12667. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12668. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12669. }
  12670. // 工商
  12671. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12672. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12673. }
  12674. // 华润
  12675. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12676. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12677. }
  12678. // 个人
  12679. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12680. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12681. }
  12682. }
  12683. }
  12684. // 活期
  12685. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12686. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12687. // 广发
  12688. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12689. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12690. }
  12691. // 工商
  12692. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12693. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12694. }
  12695. // 个人
  12696. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12697. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12698. }
  12699. }
  12700. }
  12701. // print_r($inComeStatistics ['fixedStatistics']);
  12702. // 固期
  12703. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12704. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12705. // 广发
  12706. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12707. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12708. }
  12709. // 工商
  12710. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12711. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12712. }
  12713. // 个人
  12714. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12715. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12716. }
  12717. }
  12718. }
  12719. return $waste;
  12720. }
  12721. function lyt() {
  12722. Doo::loadModel ( "receiptDetail" );
  12723. $receiptDetail = new receiptDetail ();
  12724. $receiptCollectList = $receiptDetail->find ( array (
  12725. 'where' => 'status=1 ',
  12726. 'asArray' => true
  12727. ) );
  12728. foreach ( $receiptCollectList as $key => $value ) {
  12729. $receiptDetail = new receiptDetail ();
  12730. $receiptDetail->pastDate = $value ['date'];
  12731. $receiptDetail->update ( array (
  12732. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12733. ) );
  12734. }
  12735. }
  12736. function staffCollectMonthDetail() {
  12737. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12738. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12739. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12740. if (! $year)
  12741. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12742. if (! $month)
  12743. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12744. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12745. if (! $nature){
  12746. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12747. }
  12748. Doo::loadModel ( 'staff' );
  12749. $staff = new staff ();
  12750. Doo::loadModel ( "receiptDetail" );
  12751. $receiptDetail = new receiptDetail ();
  12752. Doo::loadModel ( 'accountItem' );
  12753. $accountItem = new accountItem ();
  12754. Doo::loadModel ( 'statistics' );
  12755. $statistics = new statistics ();
  12756. Doo::loadModel ( "receiptAuthorityManage" );
  12757. $receiptAuthorityManage = new receiptAuthorityManage ();
  12758. $aiList=$accountItem->getAccountItem();
  12759. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12760. $cidList = array ();
  12761. foreach ( $imcStaff as $key => $value ) {
  12762. array_push ( $cidList, $value ['cid'] );
  12763. }
  12764. $cidString = implode ( ',', $cidList );
  12765. $naturecon='';
  12766. if ($nature=='ONJOB'){
  12767. $naturecon=' and (nature!=4 )';
  12768. }elseif($nature=='LEAVEJOB'){
  12769. $naturecon=' and (nature=4 )';
  12770. }else{
  12771. die ( 'illegal request--nature' );
  12772. }
  12773. $staffList = $staff->find ( array (
  12774. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12775. 'asArray' => true
  12776. ) );
  12777. $categoryList = $staff->find ( array (
  12778. 'select' => 'COUNT(*) as count,cid,category',
  12779. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12780. 'groupby' => 'cid',
  12781. 'asArray' => true
  12782. ) );
  12783. $list = array ();
  12784. foreach($aiList as $key=>$value){
  12785. foreach ($value as $v){
  12786. $subtotal[$key][$v['name']]=0;
  12787. }
  12788. }
  12789. foreach ( $categoryList as $vlu ) {
  12790. $s1 = 0;
  12791. $m1 = 0;
  12792. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12793. foreach ( $staffList as $value ) {
  12794. if ($vlu ['cid'] == $value ['cid']) {
  12795. // pastDate
  12796. $receiptCollectList = $receiptDetail->find ( array (
  12797. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12798. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12799. 'groupby' => 'item,Month(pastDate),itemCategory',
  12800. 'asArray' => true
  12801. ) );
  12802. if (! empty ( $receiptCollectList )) {
  12803. $receiptL = array (
  12804. '日常相关费用' => array (),
  12805. '差旅相关费用' => array (),
  12806. '内部培训费用' => array (),
  12807. '培训班费用' => array (),
  12808. '其他' => array ()
  12809. );
  12810. $html = "";
  12811. $psum = 0;
  12812. foreach ( $aiList[$this->AGENCY] as $va ) {
  12813. $falg = true;
  12814. foreach ( $receiptCollectList as $v ) {
  12815. if ($v ['itemCategory'] == '日常相关费用') {
  12816. if ($v ['item'] == $va['name']) {
  12817. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12818. $psum += $v ['price'];
  12819. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12820. $falg = false;
  12821. break;
  12822. }
  12823. }
  12824. }
  12825. if ($falg)
  12826. $html .= '<td class="taR">-</td>';
  12827. }
  12828. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12829. if (! empty ( $psum ))
  12830. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12831. else
  12832. $psum = '<td class="colGreen taR">-</td>';
  12833. $receiptL ['日常相关费用'] = $psum . $html;
  12834. /* ----------------------------------- */
  12835. $html = "";
  12836. $psum = 0;
  12837. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12838. $falg = true;
  12839. foreach ( $receiptCollectList as $v ) {
  12840. if ($v ['itemCategory'] == '差旅相关费用') {
  12841. if ($v ['item'] == $va['name']) {
  12842. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12843. $psum += $v ['price'];
  12844. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12845. $falg = false;
  12846. break;
  12847. }
  12848. }
  12849. }
  12850. if ($falg)
  12851. $html .= '<td class="taR">-</td>';
  12852. }
  12853. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12854. if (! empty ( $psum ))
  12855. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12856. else
  12857. $psum = '<td class="colGreen taR">-</td>';
  12858. $receiptL ['差旅相关费用'] = $psum . $html;
  12859. /* ------------------------------------- */
  12860. $html = "";
  12861. $psum = 0;
  12862. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12863. $falg = true;
  12864. foreach ( $receiptCollectList as $v ) {
  12865. if ($v ['itemCategory'] == '内部培训费用') {
  12866. if ($v ['item'] == $va['name']) {
  12867. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12868. $psum += $v ['price'];
  12869. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12870. $falg = false;
  12871. break;
  12872. }
  12873. }
  12874. }
  12875. if ($falg)
  12876. $html .= '<td class="taR">-</td>';
  12877. }
  12878. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12879. if (! empty ( $psum ))
  12880. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12881. else
  12882. $psum = '<td class="colGreen taR">-</td>';
  12883. $receiptL ['内部培训费用'] = $psum . $html;
  12884. /* ----------------------------------- */
  12885. $html = "";
  12886. $psum = 0;
  12887. foreach ( $aiList[$this->TRAIN] as $va ) {
  12888. $falg = true;
  12889. foreach ( $receiptCollectList as $v ) {
  12890. if ($v ['itemCategory'] == '培训班费用') {
  12891. if ($v ['item'] == $va['name']) {
  12892. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12893. $psum += $v ['price'];
  12894. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12895. $falg = false;
  12896. break;
  12897. }
  12898. }
  12899. }
  12900. if ($falg)
  12901. $html .= '<td class="taR">-</td>';
  12902. }
  12903. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12904. if (! empty ( $psum ))
  12905. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12906. else
  12907. $psum = '<td class="colGreen taR">-</td>';
  12908. $receiptL ['培训班费用'] = $psum . $html;
  12909. /* ------------------------------------- */
  12910. $html = "";
  12911. $psum = 0;
  12912. foreach ( $aiList[$this->OTHER] as $va ) {
  12913. $falg = true;
  12914. foreach ( $receiptCollectList as $v ) {
  12915. if ($v ['itemCategory'] == '其他') {
  12916. if (trim ( $v ['item'] ) == $va['name']) {
  12917. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12918. $psum += $v ['price'];
  12919. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12920. $falg = false;
  12921. break;
  12922. }
  12923. }
  12924. }
  12925. if ($falg)
  12926. $html .= '<td class="taR">-</td>';
  12927. }
  12928. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12929. if (! empty ( $psum ))
  12930. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12931. else
  12932. $psum = '<td class="colGreen taR">-</td>';
  12933. $receiptL ['其他'] = $psum . $html;
  12934. /* ------------------------------------- */
  12935. $html = "";
  12936. $psum = 0;
  12937. foreach ( $receiptCollectList as $v ) {
  12938. if ($v ['itemCategory'] == '报销金额调整') {
  12939. if (! empty ( $v ['price'] )) {
  12940. $psum += $v ['price'];
  12941. }
  12942. }
  12943. }
  12944. $s1 += $psum;
  12945. if (! empty ( $psum ))
  12946. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12947. else
  12948. $psum = '<td class="taR colOrange">-</td>';
  12949. $receiptL ['报销金额调整'] = $psum . $html;
  12950. } else {
  12951. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12952. foreach ( $aiList[$this->AGENCY] as $va ) {
  12953. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12954. }
  12955. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12956. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12957. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12958. }
  12959. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12960. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12961. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12962. }
  12963. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12964. foreach ( $aiList[$this->TRAIN] as $va ) {
  12965. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12966. }
  12967. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12968. foreach ( $aiList[$this->OTHER] as $va ) {
  12969. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12970. }
  12971. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12972. }
  12973. $monthStaffPrice = $receiptDetail->find ( array (
  12974. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12975. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12976. 'groupby' => 'Month(pastDate)',
  12977. 'asArray' => true
  12978. ) );
  12979. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12980. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12981. $m1 += $monthStaffPrice [0] ['price'];
  12982. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12983. } else
  12984. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12985. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12986. $list [$value ['username']] = $receiptL;
  12987. }
  12988. }
  12989. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12990. foreach ( $aiList[$this->AGENCY] as $va ) {
  12991. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12992. $subtotal[$this->AGENCY][$va['name']]=0;
  12993. }
  12994. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12995. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12996. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12997. $subtotal[$this->TRAVEL][$va['name']]=0;
  12998. }
  12999. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13000. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13001. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13002. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13003. }
  13004. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13005. foreach ( $aiList[$this->TRAIN] as $va ) {
  13006. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13007. $subtotal[$this->TRAIN][$va['name']]=0;
  13008. }
  13009. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13010. foreach ( $aiList[$this->OTHER] as $va ) {
  13011. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13012. $subtotal[$this->OTHER][$va['name']]=0;
  13013. }
  13014. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13015. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13016. $receiptL ['usernameEn'] =false;
  13017. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13018. }
  13019. $data ['list'] = $list;
  13020. // print_r($list);
  13021. $receiptCollectList = $receiptDetail->find ( array (
  13022. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13023. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13024. 'groupby' => 'item,Month(pastDate),itemCategory',
  13025. 'asArray' => true
  13026. ) );
  13027. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13028. // statistics html
  13029. $stList = $statistics->getOne ( array (
  13030. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13031. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13032. 'groupby' => 'Month(date)',
  13033. 'asArray' => true
  13034. ) );
  13035. if (empty ( $stList ))
  13036. $stList = array (
  13037. 'rePrice' => 0,
  13038. 'agPrice' => 0
  13039. );
  13040. $data ['stList'] = array (
  13041. 'rePrice' => $stList ['rePrice'],
  13042. 'agPrice' => $stList ['agPrice'],
  13043. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13044. );
  13045. $monthHtml = "";
  13046. for($i = 1; $i <= 12; $i ++) {
  13047. if ($i == $month)
  13048. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13049. else
  13050. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13051. }
  13052. $data ['monthHtml'] = $monthHtml;
  13053. $data ['year'] = $year;
  13054. $data ['month'] = $month;
  13055. $data ['nature'] = $nature;
  13056. $data ['aiList'] = $aiList;
  13057. $data ['memu'] = "receipt";
  13058. $data ['staff'] = $this->staff;
  13059. $data ['receiptMemu'] = 'companyCategoryCollect';
  13060. $data ['verifyId'] = $this->verifyId;
  13061. $data ['executeId'] = $this->executeId;
  13062. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13063. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13064. }
  13065. function staffCollectMonthDetail2() {
  13066. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13067. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13068. if (! $year)
  13069. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13070. if (! $month)
  13071. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13072. Doo::loadModel ( 'staff' );
  13073. $staff = new staff ();
  13074. Doo::loadModel ( "receiptDetail" );
  13075. $receiptDetail = new receiptDetail ();
  13076. Doo::loadModel ( 'accountItem' );
  13077. $accountItem = new accountItem ();
  13078. Doo::loadModel ( 'statistics' );
  13079. $statistics = new statistics ();
  13080. Doo::loadModel ( 'L_category' );
  13081. $lCategory = new L_category ();
  13082. $staffList = $staff->find ( array (
  13083. 'where' => 'username!="admin"',
  13084. 'asArray' => true
  13085. ) );
  13086. $categoryList = $staff->find ( array (
  13087. 'select' => 'COUNT(*) as count,cid,category',
  13088. 'where' => 'username !="admin"',
  13089. 'groupby' => 'cid',
  13090. 'asArray' => true
  13091. ) );
  13092. $list = array ();
  13093. foreach ( $categoryList as $vlu ) {
  13094. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13095. $r1 = 0;
  13096. $r2 = 0;
  13097. $r3 = 0;
  13098. $r4 = 0;
  13099. $r5 = 0;
  13100. $r6 = 0;
  13101. $r7 = 0;
  13102. $r8 = 0;
  13103. $r9 = 0;
  13104. $r10 = 0;
  13105. $r11 = 0;
  13106. $r12 = 0;
  13107. $r13 = 0;
  13108. $r14 = 0;
  13109. $r15 = 0;
  13110. $c1 = 0;
  13111. $c2 = 0;
  13112. $c3 = 0;
  13113. $c4 = 0;
  13114. $c5 = 0;
  13115. $c6 = 0;
  13116. $p1 = 0;
  13117. $p2 = 0;
  13118. $p3 = 0;
  13119. $p4 = 0;
  13120. $p5 = 0;
  13121. $p6 = 0;
  13122. $p7 = 0;
  13123. $p8 = 0;
  13124. $p9 = 0;
  13125. $t1 = 0;
  13126. $t2 = 0;
  13127. $t3 = 0;
  13128. $t4 = 0;
  13129. $t5 = 0;
  13130. $s1 = 0;
  13131. $m1 = 0;
  13132. foreach ( $staffList as $value ) {
  13133. if ($vlu ['cid'] == $value ['cid']) {
  13134. $receiptCollectList = $receiptDetail->find ( array (
  13135. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13136. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13137. 'groupby' => 'item,Month(date),itemCategory',
  13138. 'asArray' => true
  13139. ) );
  13140. if (! empty ( $receiptCollectList )) {
  13141. $receiptL = array (
  13142. '日常相关费用' => array (),
  13143. '差旅相关费用' => array (),
  13144. '培训班费用' => array (),
  13145. '其他' => array ()
  13146. );
  13147. $html = "";
  13148. $psum = 0;
  13149. $item = array (
  13150. '市内交通费',
  13151. '市内出租费',
  13152. '办事处房租',
  13153. '电话费',
  13154. '水费',
  13155. '电费',
  13156. '办公费用',
  13157. '邮寄费',
  13158. '其他费用',
  13159. '车辆费用',
  13160. '广告费',
  13161. '团队建设费',
  13162. '物业管理费',
  13163. '宽带费'
  13164. );
  13165. foreach ( $item as $va ) {
  13166. $falg = true;
  13167. foreach ( $receiptCollectList as $v ) {
  13168. if ($v ['itemCategory'] == '日常相关费用') {
  13169. if ($v ['item'] == $va) {
  13170. if ($va == '市内交通费')
  13171. $r1 += $v ['price'];
  13172. if ($va == '市内出租费')
  13173. $r2 += $v ['price'];
  13174. if ($va == '办事处房租')
  13175. $r3 += $v ['price'];
  13176. if ($va == '电话费')
  13177. $r4 += $v ['price'];
  13178. if ($va == '水费')
  13179. $r5 += $v ['price'];
  13180. if ($va == '电费')
  13181. $r6 += $v ['price'];
  13182. if ($va == '办公费用')
  13183. $r7 += $v ['price'];
  13184. if ($va == '邮寄费')
  13185. $r8 += $v ['price'];
  13186. if ($va == '其他费用')
  13187. $r9 += $v ['price'];
  13188. if ($va == '车辆费用')
  13189. $r10 += $v ['price'];
  13190. if ($va == '广告费')
  13191. $r11 += $v ['price'];
  13192. if ($va == '团队建设费')
  13193. $r13 += $v ['price'];
  13194. if ($va == '物业管理费')
  13195. $r14 += $v ['price'];
  13196. if ($va == '宽带费')
  13197. $r15 += $v ['price'];
  13198. $psum += $v ['price'];
  13199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13200. $falg = false;
  13201. break;
  13202. }
  13203. }
  13204. }
  13205. if ($falg)
  13206. $html .= '<td class="taR">-</td>';
  13207. }
  13208. $r12 += $psum;
  13209. if (! empty ( $psum ))
  13210. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13211. else
  13212. $psum = '<td class="colGreen taR">-</td>';
  13213. $receiptL ['日常相关费用'] = $psum . $html;
  13214. /* ----------------------------------- */
  13215. $html = "";
  13216. $psum = 0;
  13217. $item = array (
  13218. '往来交通费',
  13219. '市内交通费',
  13220. '出差住宿费',
  13221. '出差补助',
  13222. '其他费用'
  13223. );
  13224. foreach ( $item as $va ) {
  13225. $falg = true;
  13226. foreach ( $receiptCollectList as $v ) {
  13227. if ($v ['itemCategory'] == '差旅相关费用') {
  13228. if ($v ['item'] == $va) {
  13229. if ($va == '往来交通费')
  13230. $c1 += $v ['price'];
  13231. if ($va == '市内交通费')
  13232. $c2 += $v ['price'];
  13233. if ($va == '出差住宿费')
  13234. $c3 += $v ['price'];
  13235. if ($va == '出差补助')
  13236. $c4 += $v ['price'];
  13237. if ($va == '其他费用')
  13238. $c5 += $v ['price'];
  13239. $psum += $v ['price'];
  13240. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13241. $falg = false;
  13242. break;
  13243. }
  13244. }
  13245. }
  13246. if ($falg)
  13247. $html .= '<td class="taR">-</td>';
  13248. }
  13249. $c6 += $psum;
  13250. if (! empty ( $psum ))
  13251. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13252. else
  13253. $psum = '<td class="colGreen taR">-</td>';
  13254. $receiptL ['差旅相关费用'] = $psum . $html;
  13255. /* ------------------------------------- */
  13256. $html = "";
  13257. $psum = 0;
  13258. $item = array (
  13259. '场租费',
  13260. '薪酬',
  13261. '住宿费',
  13262. '交通费',
  13263. '餐饮费',
  13264. '办公费',
  13265. '公关费',
  13266. '其他'
  13267. );
  13268. foreach ( $item as $va ) {
  13269. $falg = true;
  13270. foreach ( $receiptCollectList as $v ) {
  13271. if ($v ['itemCategory'] == '培训班费用') {
  13272. if ($v ['item'] == $va) {
  13273. if ($va == '场租费')
  13274. $p1 += $v ['price'];
  13275. if ($va == '薪酬')
  13276. $p2 += $v ['price'];
  13277. if ($va == '住宿费')
  13278. $p3 += $v ['price'];
  13279. if ($va == '交通费')
  13280. $p4 += $v ['price'];
  13281. if ($va == '餐饮费')
  13282. $p5 += $v ['price'];
  13283. if ($va == '办公费')
  13284. $p6 += $v ['price'];
  13285. if ($va == '公关费')
  13286. $p7 += $v ['price'];
  13287. if ($va == '其他')
  13288. $p8 += $v ['price'];
  13289. $psum += $v ['price'];
  13290. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13291. $falg = false;
  13292. break;
  13293. }
  13294. }
  13295. }
  13296. if ($falg)
  13297. $html .= '<td class="taR">-</td>';
  13298. }
  13299. $p9 += $psum;
  13300. if (! empty ( $psum ))
  13301. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13302. else
  13303. $psum = '<td class="colGreen taR">-</td>';
  13304. $receiptL ['培训班费用'] = $psum . $html;
  13305. /* ------------------------------------- */
  13306. $html = "";
  13307. $psum = 0;
  13308. $item = array (
  13309. '公关费',
  13310. '广告费',
  13311. '借款',
  13312. '可自加费用'
  13313. );
  13314. foreach ( $item as $va ) {
  13315. $falg = true;
  13316. foreach ( $receiptCollectList as $v ) {
  13317. if ($v ['itemCategory'] == '其他') {
  13318. if ($v ['item'] == $va) {
  13319. if ($va == '公关费')
  13320. $t1 += $v ['price'];
  13321. if ($va == '广告费')
  13322. $t2 += $v ['price'];
  13323. if ($va == '借款')
  13324. $t3 += $v ['price'];
  13325. if ($va == '可自加费用')
  13326. $t4 += $v ['price'];
  13327. $psum += $v ['price'];
  13328. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13329. $falg = false;
  13330. break;
  13331. }
  13332. }
  13333. }
  13334. if ($falg)
  13335. $html .= '<td class="taR">-</td>';
  13336. }
  13337. $t5 += $psum;
  13338. if (! empty ( $psum ))
  13339. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13340. else
  13341. $psum = '<td class="colGreen taR">-</td>';
  13342. $receiptL ['其他'] = $psum . $html;
  13343. /* ------------------------------------- */
  13344. $html = "";
  13345. $psum = 0;
  13346. foreach ( $receiptCollectList as $v ) {
  13347. if ($v ['itemCategory'] == '报销金额调整') {
  13348. if (! empty ( $v ['price'] )) {
  13349. $psum += $v ['price'];
  13350. }
  13351. }
  13352. }
  13353. $s1 += $psum;
  13354. if (! empty ( $psum ))
  13355. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13356. else
  13357. $psum = '<td class="taR colOrange">-</td>';
  13358. $receiptL ['报销金额调整'] = $psum . $html;
  13359. } else {
  13360. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13361. <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>';
  13362. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13363. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13364. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13365. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13366. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13367. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13368. }
  13369. $monthStaffPrice = $receiptDetail->find ( array (
  13370. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13371. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13372. 'asArray' => true
  13373. ) );
  13374. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13375. $m1 += $monthStaffPrice [0] ['price'];
  13376. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13377. } else
  13378. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13379. $list [$value ['username']] = $receiptL;
  13380. }
  13381. }
  13382. $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>
  13383. <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>
  13384. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13385. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13386. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13387. $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>
  13388. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13389. $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>';
  13390. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13391. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13392. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13393. }
  13394. $data ['list'] = $list;
  13395. $receiptCollectList = $receiptDetail->find ( array (
  13396. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13397. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13398. 'groupby' => 'item,Month(date),itemCategory',
  13399. 'asArray' => true
  13400. ) );
  13401. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13402. // statistics html
  13403. $stList = $statistics->getOne ( array (
  13404. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13405. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13406. 'groupby' => 'Month(date)',
  13407. 'asArray' => true
  13408. ) );
  13409. if (empty ( $stList ))
  13410. $stList = array (
  13411. 'rePrice' => 0,
  13412. 'agPrice' => 0
  13413. );
  13414. $data ['stList'] = array (
  13415. 'rePrice' => $stList ['rePrice'],
  13416. 'agPrice' => $stList ['agPrice'],
  13417. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13418. );
  13419. $monthHtml = "";
  13420. for($i = 1; $i <= 12; $i ++) {
  13421. if ($i == $month)
  13422. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13423. else
  13424. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13425. }
  13426. $data ['monthHtml'] = $monthHtml;
  13427. $data ['year'] = $year;
  13428. $data ['month'] = $month;
  13429. $data ['memu'] = "receipt";
  13430. $data ['staff'] = $this->staff;
  13431. $data ['receiptMemu'] = 'companyCategoryCollect';
  13432. $data ['verifyId'] = $this->verifyId;
  13433. $data ['executeId'] = $this->executeId;
  13434. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13435. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13436. }
  13437. /**
  13438. * 用户报销单列表
  13439. */
  13440. function receiptStatisticsStaffDetail() {
  13441. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13442. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13443. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13444. Doo::loadModel ( "receipt" );
  13445. $receipt = new receipt ();
  13446. Doo::loadModel ( "receiptDetail" );
  13447. $receiptDetail = new receiptDetail ();
  13448. Doo::loadModel ( 'staff' );
  13449. $staff = new staff ();
  13450. Doo::loadModel ( 'accountItem' );
  13451. $accountItem = new accountItem ();
  13452. Doo::loadModel ( 'statistics' );
  13453. $statistics = new statistics ();
  13454. if (! empty ( $username )) {
  13455. $username = addslashes ( urldecode ( $username ) );
  13456. $staffDetail = $staff->getStaffByName ( $username );
  13457. if (empty ( $staffDetail ))
  13458. die ( 'illegal request' );
  13459. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13460. $itemList = $accountItem->getAccountItem ();
  13461. $itemHtml = '';
  13462. $categoryHtml = '';
  13463. $itemKeyList = array_keys ( $itemList );
  13464. $revisePrice = 0;
  13465. // 报销单内容详情
  13466. foreach ( $list as $key => $value ) {
  13467. $accountItemList = json_decode ( $value ['accountItem'], true );
  13468. $list [$key] ['accountItemList'] = $accountItemList;
  13469. $receiptItemHtml = '';
  13470. foreach ( $itemKeyList as $v ) {
  13471. if ($v == '日常相关费用')
  13472. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13473. elseif ($v == '差旅相关费用')
  13474. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13475. elseif ($v == '培训班费用')
  13476. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13477. elseif ($v == '内部培训费用'){
  13478. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13479. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13480. }else{
  13481. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13482. }
  13483. }elseif ($v == '其他')
  13484. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13485. foreach ( $itemList [$v] as $ke => $va ) {
  13486. $falg = true;
  13487. if (! empty ( $accountItemList [$v] )) {
  13488. foreach ( $accountItemList [$v] as $ve ) {
  13489. if ($va ['name'] == $ve ['name']) {
  13490. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13491. $falg = false;
  13492. break;
  13493. }
  13494. }
  13495. }
  13496. if ($falg)
  13497. $receiptItemHtml .= '<td class="taR"></td>';
  13498. }
  13499. }
  13500. // 金额调整和费用查看
  13501. $revisePrice += $value ['revisePrice'];
  13502. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13503. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13504. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13505. }
  13506. // 报销单合计
  13507. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13508. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13509. $receiptTotalHtml = '';
  13510. // 报销单项目抬头
  13511. foreach ( $itemKeyList as $value ) {
  13512. $count = count ( $itemList [$value] ) + 1;
  13513. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13514. $categoryHtml .= '<th class="taC">合计</th>';
  13515. $sumfalg=true;
  13516. foreach ( $rtl as $rtlValue ) {
  13517. if ($rtlValue ['itemCategory'] == $value) {
  13518. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13519. $sumfalg=false;
  13520. break;
  13521. }
  13522. }
  13523. if ($sumfalg)
  13524. $receiptTotalHtml .= '<th></th>';
  13525. foreach ( $itemList [$value] as $k => $v ) {
  13526. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13527. // 合计
  13528. $falg = true;
  13529. foreach ( $receiptTotalList as $ve ) {
  13530. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13531. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13532. $falg = false;
  13533. break;
  13534. }
  13535. }
  13536. if ($falg)
  13537. $receiptTotalHtml .= '<th></th>';
  13538. }
  13539. }
  13540. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13541. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13542. if (empty ( $stList ))
  13543. $stList = array (
  13544. 'rePrice' => 0,
  13545. 'agPrice' => 0
  13546. );
  13547. $data ['stList'] = array (
  13548. 'rePrice' => $stList ['rePrice'],
  13549. 'agPrice' => $stList ['agPrice'],
  13550. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13551. );
  13552. $monthHtml = "";
  13553. for($i = 1; $i <= 12; $i ++) {
  13554. if ($i == $month)
  13555. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13556. else
  13557. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13558. }
  13559. $data ['username'] = urlencode ( $username );
  13560. $data ['usernameEN'] = $username;
  13561. $data ['monthHtml'] = $monthHtml;
  13562. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13563. $data ['list'] = $list;
  13564. $data ['categoryHtml'] = $categoryHtml;
  13565. $data ['itemHtml'] = $itemHtml;
  13566. $data ['itemList'] = $itemList;
  13567. $data ['year'] = $year;
  13568. $data ['month'] = $month;
  13569. $data ['memu'] = "receipt";
  13570. $data ['staff'] = $this->staff;
  13571. $data ['receiptMemu'] = 'companyCategoryCollect';
  13572. $data ['verifyId'] = $this->verifyId;
  13573. $data ['executeId'] = $this->executeId;
  13574. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13575. }
  13576. die ( 'illegal request' );
  13577. }
  13578. function companyMonthCollectDetail() {
  13579. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13580. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13581. if (! $year)
  13582. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13583. if (! $month)
  13584. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13585. Doo::loadModel ( 'staff' );
  13586. $staff = new staff ();
  13587. Doo::loadModel ( "receiptDetail" );
  13588. $receiptDetail = new receiptDetail ();
  13589. Doo::loadModel ( 'accountItem' );
  13590. $accountItem = new accountItem ();
  13591. Doo::loadModel ( 'statistics' );
  13592. $statistics = new statistics ();
  13593. Doo::loadModel ( 'L_category' );
  13594. $lCategory = new L_category ();
  13595. $staffList = $staff->find ( array (
  13596. 'where' => 'username!="admin"',
  13597. 'asArray' => true
  13598. ) );
  13599. $categoryList = $lCategory->find ( array (
  13600. 'asArray' => true
  13601. ) );
  13602. $aiList=$accountItem->getAccountItem();
  13603. $list = array ();
  13604. foreach ( $categoryList as $value ) {
  13605. $receiptCollectList = $receiptDetail->find ( array (
  13606. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13607. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13608. 'groupby' => 'item,Month(pastDate),itemCategory',
  13609. 'asArray' => true
  13610. ) );
  13611. if (! empty ( $receiptCollectList )) {
  13612. $receiptL = array (
  13613. '日常相关费用' => array (),
  13614. '差旅相关费用' => array (),
  13615. '内部培训费用' => array (),
  13616. '培训班费用' => array (),
  13617. '其他' => array ()
  13618. );
  13619. $html = "";
  13620. $psum = 0;
  13621. foreach ( $aiList[$this->AGENCY] as $va ) {
  13622. $falg = true;
  13623. foreach ( $receiptCollectList as $v ) {
  13624. if ($v ['itemCategory'] == $this->AGENCY) {
  13625. if ($v ['item'] == $va['name']) {
  13626. $psum += $v ['price'];
  13627. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13628. $falg = false;
  13629. break;
  13630. }
  13631. }
  13632. }
  13633. if ($falg)
  13634. $html .= '<td class="taR">-</td>';
  13635. }
  13636. if (! empty ( $psum ))
  13637. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13638. else
  13639. $psum = '<td class="colGreen taR">-</td>';
  13640. $receiptL [$this->AGENCY] = $psum . $html;
  13641. /* ----------------------------------- */
  13642. $html = "";
  13643. $psum = 0;
  13644. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13645. $falg = true;
  13646. foreach ( $receiptCollectList as $v ) {
  13647. if ($v ['itemCategory'] == $this->TRAVEL) {
  13648. if ($v ['item'] == $va['name']) {
  13649. $psum += $v ['price'];
  13650. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13651. $falg = false;
  13652. break;
  13653. }
  13654. }
  13655. }
  13656. if ($falg)
  13657. $html .= '<td class="taR">-</td>';
  13658. }
  13659. if (! empty ( $psum ))
  13660. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13661. else
  13662. $psum = '<td class="colGreen taR">-</td>';
  13663. $receiptL [$this->TRAVEL] = $psum . $html;
  13664. /* ------------------------------------- */
  13665. $html = "";
  13666. $psum = 0;
  13667. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13668. $falg = true;
  13669. foreach ( $receiptCollectList as $v ) {
  13670. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13671. if ($v ['item'] == $va['name']) {
  13672. $psum += $v ['price'];
  13673. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13674. $falg = false;
  13675. break;
  13676. }
  13677. }
  13678. }
  13679. if ($falg)
  13680. $html .= '<td class="taR">-</td>';
  13681. }
  13682. if (! empty ( $psum ))
  13683. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13684. else
  13685. $psum = '<td class="colGreen taR">-</td>';
  13686. $receiptL [$this->INTTRAIN] = $psum . $html;
  13687. /* ------------------------------------- */
  13688. $html = "";
  13689. $psum = 0;
  13690. foreach ( $aiList[$this->TRAIN] as $va ) {
  13691. $falg = true;
  13692. foreach ( $receiptCollectList as $v ) {
  13693. if ($v ['itemCategory'] == $this->TRAIN) {
  13694. if ($v ['item'] == $va['name']) {
  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. if (! empty ( $psum ))
  13706. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13707. else
  13708. $psum = '<td class="colGreen taR">-</td>';
  13709. $receiptL [$this->TRAIN] = $psum . $html;
  13710. /* ------------------------------------- */
  13711. $html = "";
  13712. $psum = 0;
  13713. foreach ( $aiList[$this->OTHER] as $va ) {
  13714. $falg = true;
  13715. foreach ( $receiptCollectList as $v ) {
  13716. if ($v ['itemCategory'] == $this->OTHER) {
  13717. if ($v ['item'] == $va['name']) {
  13718. $psum += $v ['price'];
  13719. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13720. $falg = false;
  13721. break;
  13722. }
  13723. }
  13724. }
  13725. if ($falg)
  13726. $html .= '<td class="taR">-</td>';
  13727. }
  13728. if (! empty ( $psum ))
  13729. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13730. else
  13731. $psum = '<td class="colGreen taR">-</td>';
  13732. $receiptL [$this->OTHER] = $psum . $html;
  13733. /* ------------------------------------- */
  13734. $html = "";
  13735. $psum = 0;
  13736. foreach ( $receiptCollectList as $v ) {
  13737. if ($v ['itemCategory'] == '报销金额调整') {
  13738. if (! empty ( $v ['price'] ))
  13739. $psum += $v ['price'];
  13740. }
  13741. }
  13742. if (! empty ( $psum ))
  13743. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13744. else
  13745. $psum = '<td class="taR colOrange">-</td>';
  13746. $receiptL ['报销金额调整'] = $psum . $html;
  13747. } else {
  13748. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13749. foreach ( $aiList[$this->AGENCY] as $va ) {
  13750. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13751. }
  13752. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13753. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13754. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13755. }
  13756. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13757. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13758. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13759. }
  13760. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13761. foreach ( $aiList[$this->TRAIN] as $va ) {
  13762. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13763. }
  13764. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13765. foreach ( $aiList[$this->OTHER] as $va ) {
  13766. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13767. }
  13768. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13769. }
  13770. $monthStaffPrice = $receiptDetail->find ( array (
  13771. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13772. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13773. 'asArray' => true
  13774. ) );
  13775. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13776. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13777. else
  13778. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13779. $list [$value ['title']] = $receiptL;
  13780. }
  13781. $data ['list'] = $list;
  13782. $receiptCollectList = $receiptDetail->find ( array (
  13783. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13784. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13785. 'groupby' => 'item,Month(pastDate),itemCategory',
  13786. 'asArray' => true
  13787. ) );
  13788. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13789. //print_r($data['monthPriceHtml']);
  13790. // foreach ($data['monthPriceHtml'] as $value){
  13791. // echo $value;
  13792. // }
  13793. // die;
  13794. // statistics html
  13795. $stList = $statistics->getOne ( array (
  13796. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13797. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13798. 'groupby' => 'Month(date)',
  13799. 'asArray' => true
  13800. ) );
  13801. if (empty ( $stList ))
  13802. $stList = array (
  13803. 'rePrice' => 0,
  13804. 'agPrice' => 0
  13805. );
  13806. $data ['stList'] = array (
  13807. 'rePrice' => $stList ['rePrice'],
  13808. 'agPrice' => $stList ['agPrice'],
  13809. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13810. );
  13811. $monthHtml = "";
  13812. for($i = 1; $i <= 12; $i ++) {
  13813. if ($i == $month)
  13814. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13815. else
  13816. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13817. }
  13818. $data ['aiList'] = $aiList;
  13819. $dateHtml = "";
  13820. $now = date ( "Y" );
  13821. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13822. if ($YEARD <= $now) {
  13823. $dateHtml .= '<option ';
  13824. if ($year == $YEARD) {
  13825. $dateHtml .= 'selected ';
  13826. }
  13827. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13828. }
  13829. }
  13830. $data ['dateHtml'] = $dateHtml;
  13831. $data ['monthHtml'] = $monthHtml;
  13832. $data ['year'] = $year;
  13833. $data ['month'] = $month;
  13834. $data ['memu'] = "receipt";
  13835. $data ['staff'] = $this->staff;
  13836. $data ['receiptMemu'] = 'companyCategoryCollect';
  13837. $data ['verifyId'] = $this->verifyId;
  13838. $data ['executeId'] = $this->executeId;
  13839. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13840. }
  13841. function staffCollectDetail() {
  13842. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13843. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13844. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13845. if (! $staffname) {
  13846. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13847. $staffname = urldecode ( $staffname );
  13848. }
  13849. Doo::loadModel ( 'staff' );
  13850. $staff = new staff ();
  13851. Doo::loadModel ( "receiptDetail" );
  13852. $receiptDetail = new receiptDetail ();
  13853. Doo::loadModel ( 'accountItem' );
  13854. $accountItem = new accountItem ();
  13855. Doo::loadModel ( 'statistics' );
  13856. $statistics = new statistics ();
  13857. Doo::loadModel ( 'L_category' );
  13858. $lCategory = new L_category ();
  13859. Doo::loadModel ( "receiptAuthorityManage" );
  13860. $receiptAuthorityManage = new receiptAuthorityManage ();
  13861. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13862. $cidList = array ();
  13863. foreach ( $imcStaff as $key => $value ) {
  13864. array_push ( $cidList, $value ['cid'] );
  13865. }
  13866. $cidString = implode ( ',', $cidList );
  13867. $staffList = $staff->find ( array (
  13868. 'where' => ' cid in (' . $cidString . ')',
  13869. 'asArray' => true
  13870. ) );
  13871. $stHtml = '';
  13872. $stTitle = "";
  13873. $staffId = 0;
  13874. $cid = 0;
  13875. $ocid = 0;
  13876. foreach ( $staffList as $value ) {
  13877. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13878. $stTitle = $value ['category'] . '-' . $value ['username'];
  13879. $staffId = $value ['sid'];
  13880. $cid = $value ['cid'];
  13881. $ocid = $value ['cid'];
  13882. if (! empty ( $value ['othercid'] ))
  13883. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13884. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13885. } elseif ($value ['username'] != 'admin')
  13886. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13887. }
  13888. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13889. 'where' => 'cid in(' . $cid . ')',
  13890. 'asArray' => true
  13891. ) );
  13892. if (empty ( $pcid ))
  13893. $pcid = $ocid;
  13894. $data ['ocid'] = $pcid;
  13895. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13896. $this->showCache ( $path );
  13897. //
  13898. $receiptCollectList = $receiptDetail->find ( array (
  13899. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13900. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13901. 'groupby' => 'item,Month(pastDate),itemCategory',
  13902. 'asArray' => true
  13903. ) );
  13904. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13905. // print_r($receiptCollectList);
  13906. $accountList = $accountItem->find ( array (
  13907. 'asArray' => true
  13908. ) );
  13909. // create CollectDetail HTML
  13910. $collectHtml = array ();
  13911. foreach ( $accountList as $key => $value ) {
  13912. $html = "";
  13913. $asum = 0;
  13914. for($i = 1; $i <= 12; $i ++) {
  13915. $falg = true;
  13916. foreach ( $receiptCollectList as $v ) {
  13917. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13918. if ($v ['item'] == '可自加费用') {
  13919. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13920. }
  13921. $asum += $v ['price'];
  13922. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13923. $falg = false;
  13924. break;
  13925. }
  13926. }
  13927. if ($falg)
  13928. $html .= '<td class="taR">-</td>';
  13929. }
  13930. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13931. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13932. }
  13933. $data ['collectHtml'] = $collectHtml;
  13934. // print_r($collectHtml);
  13935. // create Adjustment price html
  13936. $receiptCollectList = $receiptDetail->find ( array (
  13937. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13938. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13939. 'groupby' => 'itemCategory,Month(pastDate)',
  13940. 'asArray' => true
  13941. ) );
  13942. $adjustment = array ();
  13943. $collectArray = array (
  13944. '日常相关费用' => array (),
  13945. '差旅相关费用' => array (),
  13946. '培训班费用' => array (),
  13947. '内部培训费用'=>array(),
  13948. '其他' => array ()
  13949. );
  13950. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13951. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13952. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13953. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13954. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13955. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13956. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13957. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13958. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13959. array_push ( $collectArray ['其他'], $collectHtml );
  13960. $data ['collectArray'] = $collectArray;
  13961. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13962. array_push ( $adjustment, $collectHtml );
  13963. $data ['adjustment'] = $adjustment;
  13964. // total price html
  13965. $collectHtml = "";
  13966. $total = 0;
  13967. for($i = 1; $i <= 12; $i ++) {
  13968. $sumPrice = 0;
  13969. foreach ( $receiptCollectList as $key => $value ) {
  13970. if ($value ['month'] == $i) {
  13971. $sumPrice += $value ['price'];
  13972. }
  13973. }
  13974. if ($sumPrice == 0)
  13975. $collectHtml .= '<td class="taR">-</td>';
  13976. else
  13977. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13978. $total += $sumPrice;
  13979. }
  13980. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13981. // statistics html
  13982. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13983. if (empty ( $stList ))
  13984. $stList = array (
  13985. 'rePrice' => 0,
  13986. 'agPrice' => 0
  13987. );
  13988. $data ['stList'] = array (
  13989. 'rePrice' => $stList ['rePrice'],
  13990. 'agPrice' => $stList ['agPrice'],
  13991. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13992. );
  13993. $data ['totalPrice'] = $collectHtml;
  13994. $data ['totalYear'] = $total;
  13995. $data ['stHtml'] = $stHtml;
  13996. $data ['year'] = $year;
  13997. $data ['stTitle'] = $stTitle;
  13998. $data ['staffname'] = urlencode ( $staffname );
  13999. $data ['memu'] = "receipt";
  14000. $data ['staff'] = $this->staff;
  14001. $data ['receiptMemu'] = 'companyCategoryCollect';
  14002. $data ['verifyId'] = $this->verifyId;
  14003. $data ['executeId'] = $this->executeId;
  14004. if ($year < date ( "Y" )) {
  14005. Doo::loadModel ( 'receipt' );
  14006. $receipt = new receipt ();
  14007. $receiptList = $receipt->find ( array (
  14008. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14009. 'asArray' => true
  14010. ) );
  14011. if (empty ( $receiptList )) { // generated files
  14012. ob_start ();
  14013. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14014. $this->cacheFile ( $path );
  14015. die ();
  14016. }
  14017. }
  14018. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14019. }
  14020. function BUGFLAG() {
  14021. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14026. if (empty ( $status ))
  14027. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14028. $page_size = 12;
  14029. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14030. $vidList = array ();
  14031. $button = 0;
  14032. Doo::loadModel ( 'verify' );
  14033. $verify = new verify ();
  14034. Doo::loadModel ( 'receipt' );
  14035. $receipt = new receipt ();
  14036. Doo::loadModel ( 'staff' );
  14037. $staff = new staff ();
  14038. Doo::loadModel ( 'L_category' );
  14039. $Lcategory = new L_category ();
  14040. $dateCondition = " and Year(date) =" . $year;
  14041. if (! empty ( $month ))
  14042. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14043. $categoryList = $Lcategory->find ( array (
  14044. 'asArray' => true
  14045. ) );
  14046. $staffList = $staff->find ( array (
  14047. 'where' => 'cid=' . $cid,
  14048. 'asArray' => true
  14049. ) );
  14050. $cateCondition = "";
  14051. $staffCondition = "";
  14052. $approvalCondition = "";
  14053. if (! empty ( $cid ))
  14054. $cateCondition = ' and cid=' . $cid;
  14055. if (! empty ( $sid )) {
  14056. $staffCondition = ' and staff=' . $sid;
  14057. $cateCondition = "";
  14058. }
  14059. $approvalCondition = " and status=" . $status;
  14060. if ($status == 2) {
  14061. // 查找角色审批人
  14062. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14063. }
  14064. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14065. $approvalCondition = ' and status=2 ';
  14066. }
  14067. if ($status == 1) {
  14068. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14069. }
  14070. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14071. $pageinfo ['page'] = array (
  14072. 'previous' => ''
  14073. );
  14074. if ($status == 0) {
  14075. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14076. $receiptList = $receipt->find ( array (
  14077. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14078. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14079. 'desc' => 'rid',
  14080. 'asArray' => true
  14081. ) );
  14082. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14083. } else
  14084. $receiptList = $receipt->find ( array (
  14085. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14086. 'desc' => 'rid',
  14087. 'asArray' => true
  14088. ) );
  14089. $rLRes = $receipt->find ( array (
  14090. '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,
  14091. 'desc' => 'rid',
  14092. 'asArray' => true
  14093. ) );
  14094. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14095. // print_r($pageinfo);
  14096. $Locate = 0;
  14097. foreach ( $receiptList as $key => $value ) {
  14098. $receiptList [$key] ['Locate'] = $Locate;
  14099. $Locate ++;
  14100. $receiptList [$key] ['reviseDetail'] = array ();
  14101. if (! empty ( $value ['reviseDetail'] ))
  14102. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14103. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14104. $categoryDetil = $Lcategory->getOne ( array (
  14105. 'where' => 'cid=' . $value ['cid'],
  14106. 'asArray' => true
  14107. ) );
  14108. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14109. $verifyList = $verify->getOne ( array (
  14110. 'where' => 'vid=' . $value ['verify'],
  14111. 'asArray' => true
  14112. ) );
  14113. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14114. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14115. foreach ( $verifyList as $k => $v ) {
  14116. // init verifyStaff
  14117. $verifyList [$k] ['date'] = "";
  14118. $verifyList [$k] ['opinion'] = "";
  14119. $verifyList [$k] ['status'] = "";
  14120. if (empty ( $verifyStaff )) {
  14121. $verifyList [$k] ['date'] = "";
  14122. $verifyList [$k] ['opinion'] = "";
  14123. if ($v [0] == $this->staff [0] ['sid']) {
  14124. $verifyList [$k] ['status'] = 4;
  14125. $button = 4;
  14126. }
  14127. } else {
  14128. $flag = true;
  14129. foreach ( $verifyStaff as $m => $u ) {
  14130. if ($v [0] == $m) {
  14131. $verifyList [$k] ['date'] = $u ['date'];
  14132. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14133. $verifyList [$k] ['status'] = $u ['status'];
  14134. $flag = false;
  14135. break;
  14136. }
  14137. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14138. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14139. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14140. }
  14141. if ($flag) { // 检测可编辑
  14142. if ($v [0] == $this->staff [0] ['sid']) {
  14143. $verifyList [$k] ['status'] = 4;
  14144. $button = 4;
  14145. }
  14146. }
  14147. }
  14148. }
  14149. $receiptList [$key] ['verifyList'] = $verifyList;
  14150. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14151. 'where' => 'sid=' . $value ['staff'],
  14152. 'asArray' => true
  14153. ) );
  14154. $receiptList [$key] ['button'] = $button;
  14155. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14156. }
  14157. // print_r($receiptList);die;
  14158. // $data['verifyDetail']=$verifyDetail;
  14159. $mothHtml = "";
  14160. for($i = 1; $i <= 12; $i ++) {
  14161. if ($month == $i)
  14162. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14163. else
  14164. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14165. }
  14166. $data ['mothHtml'] = $mothHtml;
  14167. $data ['page'] = $pageinfo;
  14168. $data ['receiptList'] = $receiptList;
  14169. $data ['receiptApprovalCount'] = count ( $rLRes );
  14170. $data ['status'] = $status;
  14171. $data ['year'] = $year;
  14172. $data ['categoryList'] = $categoryList;
  14173. $data ['staffList'] = $staffList;
  14174. $data ['cid'] = $cid;
  14175. $data ['sid'] = $sid;
  14176. // print_r($receiptList);
  14177. $data ['memu'] = "receipt";
  14178. $data ['staff'] = $this->staff;
  14179. $data ['receiptMemu'] = 'approvalExpenses';
  14180. $data ['verifyId'] = $this->verifyId;
  14181. $data ['executeId'] = $this->executeId;
  14182. $this->render ( "/admin/FALG", $data );
  14183. }
  14184. function ajaxGetReceiptOrder() {
  14185. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14186. if (! empty ( $receiptOrder )) {
  14187. Doo::loadModel ( 'receipt' );
  14188. $receipt = new receipt ();
  14189. Doo::loadModel ( 'staff' );
  14190. $staff = new staff ();
  14191. $receiptInfo = $receipt->getOne ( array (
  14192. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14193. 'asArray' => true
  14194. ) );
  14195. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14196. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14197. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14198. </tbody></table><table class="table table table-bordered"><tbody>';
  14199. foreach ( $verifyStaff as $key => $value ) {
  14200. $staffInfo = $staff->getOne ( array (
  14201. 'select' => 'username',
  14202. 'where' => ' sid="' . $key . '"',
  14203. 'asArray' => true
  14204. ) );
  14205. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14206. }
  14207. $html .= '</tbody></table></div></div>';
  14208. echo json_encode ( array (
  14209. 'status' => 1,
  14210. 'receiptHtml' => $html
  14211. ) );
  14212. die ();
  14213. }
  14214. echo json_encode ( array (
  14215. 'status' => 2,
  14216. 'receiptHtml' => ''
  14217. ) );
  14218. die ();
  14219. }
  14220. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14221. if (! empty ( $receiptCollectList )) {
  14222. $receiptL = array (
  14223. '日常相关费用' => array (),
  14224. '差旅相关费用' => array (),
  14225. '内部培训费用'=>array(),
  14226. '培训班费用' => array (),
  14227. '其他' => array ()
  14228. );
  14229. $html = "";
  14230. $psum = 0;
  14231. foreach ( $aiList[$this->AGENCY] as $value ) {
  14232. $falg = true;
  14233. foreach ( $receiptCollectList as $v ) {
  14234. if ($v ['itemCategory'] == '日常相关费用') {
  14235. if ($v ['item'] == $value['name']) {
  14236. $psum += $v ['price'];
  14237. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14238. $falg = false;
  14239. break;
  14240. }
  14241. }
  14242. }
  14243. if ($falg)
  14244. $html .= '<td class="taR">-</td>';
  14245. }
  14246. if (! empty ( $psum ))
  14247. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14248. else
  14249. $psum = '<td class="colGreen taR">-</td>';
  14250. $receiptL ['日常相关费用'] = $psum . $html;
  14251. /* ----------------------------------- */
  14252. $html = "";
  14253. $psum = 0;
  14254. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14255. $falg = true;
  14256. foreach ( $receiptCollectList as $v ) {
  14257. if ($v ['itemCategory'] == '差旅相关费用') {
  14258. if ($v ['item'] == $value['name']) {
  14259. $psum += $v ['price'];
  14260. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14261. $falg = false;
  14262. break;
  14263. }
  14264. }
  14265. }
  14266. if ($falg)
  14267. $html .= '<td class="taR">-</td>';
  14268. }
  14269. if (! empty ( $psum ))
  14270. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14271. else
  14272. $psum = '<td class="colGreen taR">-</td>';
  14273. $receiptL ['差旅相关费用'] = $psum . $html;
  14274. /* ----------------------------------- */
  14275. $html = "";
  14276. $psum = 0;
  14277. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14278. $falg = true;
  14279. foreach ( $receiptCollectList as $v ) {
  14280. if ($v ['itemCategory'] == '内部培训费用') {
  14281. if ($v ['item'] == $value['name']) {
  14282. $psum += $v ['price'];
  14283. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14284. $falg = false;
  14285. break;
  14286. }
  14287. }
  14288. }
  14289. if ($falg)
  14290. $html .= '<td class="taR">-</td>';
  14291. }
  14292. if (! empty ( $psum ))
  14293. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14294. else
  14295. $psum = '<td class="colGreen taR">-</td>';
  14296. $receiptL ['内部培训费用'] = $psum . $html;
  14297. /* ------------------------------------- */
  14298. $html = "";
  14299. $psum = 0;
  14300. foreach ( $aiList[$this->TRAIN] as $value ) {
  14301. $falg = true;
  14302. foreach ( $receiptCollectList as $v ) {
  14303. if ($v ['itemCategory'] == '培训班费用') {
  14304. if ($v ['item'] == $value['name']) {
  14305. $psum += $v ['price'];
  14306. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14307. $falg = false;
  14308. break;
  14309. }
  14310. }
  14311. }
  14312. if ($falg)
  14313. $html .= '<td class="taR">-</td>';
  14314. }
  14315. if (! empty ( $psum ))
  14316. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14317. else
  14318. $psum = '<td class="colGreen taR">-</td>';
  14319. $receiptL ['培训班费用'] = $psum . $html;
  14320. /* ------------------------------------- */
  14321. $html = "";
  14322. $psum = 0;
  14323. foreach ( $aiList[$this->OTHER] as $value ) {
  14324. $falg = true;
  14325. foreach ( $receiptCollectList as $v ) {
  14326. if ($v ['itemCategory'] == '其他') {
  14327. if ($v ['item'] == $value['name']) {
  14328. $psum += $v ['price'];
  14329. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14330. $falg = false;
  14331. break;
  14332. }
  14333. }
  14334. }
  14335. if ($falg)
  14336. $html .= '<td class="taR">-</td>';
  14337. }
  14338. if (! empty ( $psum ))
  14339. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14340. else
  14341. $psum = '<td class="colGreen taR">-</td>';
  14342. $receiptL ['其他'] = $psum . $html;
  14343. /* ------------------------------------- */
  14344. $html = "";
  14345. $psum = 0;
  14346. foreach ( $receiptCollectList as $v ) {
  14347. if ($v ['itemCategory'] == '报销金额调整') {
  14348. if (! empty ( $v ['price'] ))
  14349. $psum += $v ['price'];
  14350. }
  14351. }
  14352. if (! empty ( $psum ))
  14353. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14354. else
  14355. $psum = '<td class="taR colOrange">-</td>';
  14356. $receiptL ['报销金额调整'] = $psum . $html;
  14357. } else {
  14358. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14359. foreach ( $aiList[$this->AGENCY] as $va ) {
  14360. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14361. }
  14362. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14363. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14364. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14365. }
  14366. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14367. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14368. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14369. }
  14370. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14371. foreach ( $aiList[$this->TRAIN] as $va ) {
  14372. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14373. }
  14374. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14375. foreach ( $aiList[$this->OTHER] as $va ) {
  14376. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14377. }
  14378. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14379. }
  14380. return $receiptL;
  14381. }
  14382. function eMail() {
  14383. Doo::loadModel ( 'staff' );
  14384. $staff = new staff ();
  14385. Doo::loadModel ( 'receipt' );
  14386. $receipt = new receipt ();
  14387. Doo::loadModel ( 'L_category' );
  14388. $Lcategory = new L_category ();
  14389. Doo::loadModel ( "verify" );
  14390. $verify = new verify ();
  14391. $staffList = $staff->find ( array (
  14392. 'asArray' => true
  14393. ) );
  14394. foreach ( $staffList as $key => $value ) {
  14395. if ($value ['username'] != 'admin') {
  14396. // 提交人
  14397. $receiptList = $receipt->find ( array (
  14398. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14399. 'asArray' => true
  14400. ) );
  14401. if (! empty ( $receiptList )) {
  14402. $html = '<br><div><style></style>
  14403. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14404. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14405. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14406. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14407. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14408. <tbody><tr>
  14409. <td style="padding: 0 40px;" align="left">
  14410. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14411. </td></tr><tr>
  14412. <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>
  14413. </tr>
  14414. </tbody> </table></td> </tr> <tr><td>
  14415. <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">
  14416. <tbody> <tr><td>
  14417. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14418. 以下报销单完成了审批,等着收款吧:</p>
  14419. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14420. foreach ( $receiptList as $k => $v ) {
  14421. $category = $Lcategory->getOne ( array (
  14422. 'where' => 'cid=' . $v ['cid'],
  14423. 'asArray' => true
  14424. ) );
  14425. $html .= '
  14426. <tr>
  14427. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14428. <td align="left">
  14429. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14430. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14431. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14432. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14433. </tr>';
  14434. }
  14435. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14436. <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>
  14437. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14438. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14439. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14440. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14441. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14442. $receipt = new receipt ();
  14443. $receipt->notice = 1;
  14444. $receipt->update ( array (
  14445. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14446. ) );
  14447. }
  14448. }
  14449. // 审批人
  14450. $verifyList = $verify->find ( array (
  14451. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14452. 'asArray' => true
  14453. ) );
  14454. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14455. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14456. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14457. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14458. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14459. <tbody><tr><td style="padding: 0 40px;" align="left">
  14460. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14461. </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>
  14462. </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">
  14463. <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>
  14464. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14465. foreach ( $verifyList as $k => $v ) {
  14466. $receiptList = $receipt->find ( array (
  14467. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14468. 'asArray' => true
  14469. ) );
  14470. foreach ( $receiptList as $r => $l ) {
  14471. $category = $Lcategory->getOne ( array (
  14472. 'where' => 'cid=' . $l ['cid'],
  14473. 'asArray' => true
  14474. ) );
  14475. $staffDetile = $staff->getOne ( array (
  14476. 'where' => 'sid=' . $l ['staff'],
  14477. 'asArray' => true
  14478. ) );
  14479. $html .= '
  14480. <tr>
  14481. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14482. <td align="left">
  14483. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14484. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14485. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14486. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14487. </tr>';
  14488. }
  14489. }
  14490. $html .= '
  14491. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14492. <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>
  14493. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14494. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14495. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14496. // $receipt=new receipt();
  14497. // $receipt->notice=1;
  14498. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14499. }
  14500. }
  14501. }
  14502. }
  14503. function setWXMsg($rid, $type) {
  14504. Doo::loadModel ( "receipt" );
  14505. $receipt = new receipt ();
  14506. $receiptDetail = $receipt->getOne ( array (
  14507. 'where' => 'rid=' . $rid,
  14508. 'asArray' => true
  14509. ) );
  14510. if (! empty ( $receiptDetail )) {
  14511. Doo::loadModel ( 'staff' );
  14512. $staff = new staff ();
  14513. $staffmsg = $staff->getOne ( array (
  14514. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14515. 'asArray' => TRUE
  14516. ) );
  14517. if (! empty ( $staffmsg ['wxid'] )) {
  14518. require_once (SITE_PATH . '/protected/class/client.php');
  14519. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14520. $user = $staffmsg ['wxid'];
  14521. $receiptName = '';
  14522. $msg = '';
  14523. switch ($receiptDetail ['Rtype']) {
  14524. case 0 :
  14525. $receiptName = '报销';
  14526. break;
  14527. case 1 :
  14528. $receiptName = '借款';
  14529. break;
  14530. case 2 :
  14531. $receiptName = '对公汇款';
  14532. break;
  14533. }
  14534. switch ($type) {
  14535. case 1 :
  14536. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14537. break;
  14538. case 2 :
  14539. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14540. break;
  14541. case 3 :
  14542. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14543. break;
  14544. }
  14545. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14546. }
  14547. }
  14548. }
  14549. // Email发送函数
  14550. function SMail($toemail, $subject, $contents) {
  14551. Doo::loadClass ( 'class.phpmailer' );
  14552. $mail = new PHPMailer ();
  14553. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14554. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14555. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14556. $mail->Password = "cDO1GjtY1seH"; // 密码
  14557. $mail->CharSet = "UTF8";
  14558. $mail->SMTPAuth = true;
  14559. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14560. $mail->Mailer = "smtp";
  14561. $mail->Port = 25;
  14562. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14563. $mail->MsgHTML ( $contents );
  14564. $mail->AddAddress ( $toemail );
  14565. $mail->CharSet = "UTF-8";
  14566. return $mail->Send ();
  14567. }
  14568. function h5Upload() {
  14569. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14570. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14571. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14572. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14573. header ( "HTTP/1.1 500 Internal Server Error" );
  14574. echo "POST exceeded maximum allowed size.";
  14575. exit ( 0 );
  14576. }
  14577. // Settings
  14578. $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)
  14579. $upload_name = "Filedata";
  14580. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14581. $extension_whitelist = array (
  14582. "doc",
  14583. "txt",
  14584. "jpg",
  14585. "gif",
  14586. "png"
  14587. ); // Allowed file extensions
  14588. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14589. // Other variables
  14590. $MAX_FILENAME_LENGTH = 260;
  14591. $file_name = "";
  14592. $file_extension = "";
  14593. $uploadErrors = array (
  14594. 0 => "文件上传成功",
  14595. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14596. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14597. 3 => "上传的文件仅为部分文件",
  14598. 4 => "没有文件上传",
  14599. 6 => "缺少临时文件夹"
  14600. );
  14601. $nk = time ();
  14602. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14603. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14604. echo "文件无法保存.";
  14605. exit ( 0 );
  14606. }
  14607. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14608. echo json_encode ( array (
  14609. 'filename' => $file_name,
  14610. 'id' => $nk
  14611. ) );
  14612. exit ( 0 );
  14613. }
  14614. function swfupload() {
  14615. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14616. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14617. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14618. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14619. header ( "HTTP/1.1 500 Internal Server Error" );
  14620. echo "POST exceeded maximum allowed size.";
  14621. exit ( 0 );
  14622. }
  14623. // Settings
  14624. $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)
  14625. $upload_name = "Filedata";
  14626. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14627. $extension_whitelist = array (
  14628. "doc",
  14629. "txt",
  14630. "jpg",
  14631. "gif",
  14632. "png"
  14633. ); // Allowed file extensions
  14634. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14635. // Other variables
  14636. $MAX_FILENAME_LENGTH = 260;
  14637. $file_name = "";
  14638. $file_extension = "";
  14639. $uploadErrors = array (
  14640. 0 => "文件上传成功",
  14641. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14642. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14643. 3 => "上传的文件仅为部分文件",
  14644. 4 => "没有文件上传",
  14645. 6 => "缺少临时文件夹"
  14646. );
  14647. $nk = time ();
  14648. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14649. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14650. echo "文件无法保存.";
  14651. exit ( 0 );
  14652. }
  14653. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14654. echo json_encode ( array (
  14655. 'filename' => $file_name,
  14656. 'id' => $nk
  14657. ) );
  14658. exit ( 0 );
  14659. }
  14660. function _GetFileEXT($filename) {
  14661. $pics = explode ( '.', $filename );
  14662. $num = count ( $pics );
  14663. return $pics [$num - 1];
  14664. }
  14665. /**
  14666. * 获取get或者POST值
  14667. * @param string $name 属性名称
  14668. * @return fixed 值
  14669. */
  14670. function get_args($name) {
  14671. if (isset ( $_GET [$name] )) {
  14672. if (is_array ( $_GET [$name] ))
  14673. return $_GET [$name];
  14674. else
  14675. return addslashes ( $_GET [$name] );
  14676. } elseif (isset ( $_POST [$name] )) {
  14677. if (is_array ( $_POST [$name] ))
  14678. return $_POST [$name];
  14679. else
  14680. return addslashes ( $_POST [$name] );
  14681. } else
  14682. return false;
  14683. }
  14684. function num_to_rmb($num) {
  14685. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14686. $c2 = "分角元拾佰仟万拾佰仟亿";
  14687. // 精确到分后面就不要了,所以只留两个小数位
  14688. $num = round ( $num, 2 );
  14689. // 将数字转化为整数
  14690. $num = $num * 100;
  14691. if (strlen ( $num ) > 10) {
  14692. return "金额太大,请检查";
  14693. }
  14694. $i = 0;
  14695. $c = "";
  14696. while ( 1 ) {
  14697. if ($i == 0) {
  14698. // 获取最后一位数字
  14699. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14700. } else {
  14701. $n = $num % 10;
  14702. }
  14703. // 每次将最后一位数字转化为中文
  14704. $p1 = substr ( $c1, 3 * $n, 3 );
  14705. $p2 = substr ( $c2, 3 * $i, 3 );
  14706. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14707. $c = $p1 . $p2 . $c;
  14708. } else {
  14709. $c = $p1 . $c;
  14710. }
  14711. $i = $i + 1;
  14712. // 去掉数字最后一位了
  14713. $num = $num / 10;
  14714. // echo $num.'</br>';
  14715. $num = ( int ) $num;
  14716. // $num =floor($num);
  14717. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14718. // echo $num.'</br>';
  14719. // 结束循环
  14720. if ($num == 0) {
  14721. break;
  14722. }
  14723. }
  14724. // echo $c.'</br>';
  14725. $j = 0;
  14726. $slen = strlen ( $c );
  14727. while ( $j < $slen ) {
  14728. // utf8一个汉字相当3个字符
  14729. $m = substr ( $c, $j, 6 );
  14730. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14731. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14732. $left = substr ( $c, 0, $j );
  14733. $right = substr ( $c, $j + 3 );
  14734. $c = $left . $right;
  14735. $j = $j - 3;
  14736. $slen = $slen - 3;
  14737. }
  14738. $j = $j + 3;
  14739. }
  14740. // 这个是为了去掉类似23.0中最后一个“零”字
  14741. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14742. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14743. }
  14744. // 将处理的汉字加上“整”
  14745. if (empty ( $c )) {
  14746. return "零元整";
  14747. } else {
  14748. return $c . "整";
  14749. }
  14750. }
  14751. /**
  14752. * 获得分页数据
  14753. * @param unknown_type $table
  14754. * @param unknown_type $condition
  14755. * @param unknown_type $on_page
  14756. * @param unknown_type $page_size
  14757. */
  14758. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14759. $page_c = "";
  14760. $page ['previous'] = $this->get_previous ( $on_page );
  14761. $page ['on_page'] = $on_page;
  14762. $total_count = $this->get_table_count ( $table, $condition );
  14763. $total = intval ( $total_count / $page_size );
  14764. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14765. $page ['total_data'] = $total_count;
  14766. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14767. $i = 1;
  14768. $page_max = 1;
  14769. $page_width = 3;
  14770. if ($on_page >= $page_width) {
  14771. $page_max = intval ( $on_page / $page_width ) + 1;
  14772. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14773. }
  14774. for(; $i <= $page ['total_page']; $i ++) {
  14775. if ($i == $on_page)
  14776. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14777. else
  14778. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14779. if ($i == ($page_width * $page_max))
  14780. break;
  14781. }
  14782. $page ['page'] = $page_c;
  14783. $page ['lower'] = (-- $on_page) * $page_size;
  14784. return $page;
  14785. }
  14786. /**
  14787. * 获取总页数
  14788. * @param unknown_type $table
  14789. * @param unknown_type $condition
  14790. */
  14791. public function get_table_count($table = "", $condition = "") {
  14792. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14793. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14794. // echo $sql;die;
  14795. $query = Doo::db ()->query ( $sql );
  14796. $result = $query->fetch ();
  14797. return $result ['count'];
  14798. }
  14799. /**
  14800. * 获取上一页
  14801. * @param unknown_type $on_page
  14802. */
  14803. function get_previous($on_page = 1) {
  14804. return $on_page != 0 ? $on_page - 1 : $on_page;
  14805. }
  14806. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14807. // 收入合计
  14808. Doo::loadModel ( 'invoiceTraining' );
  14809. $invoiceTraining = new invoiceTraining ();
  14810. Doo::loadModel ( 'receipt' );
  14811. $receipt = new receipt ();
  14812. $invoiceTrainingDetail = array (
  14813. 'invoiceArriveAmount' => '0.00',
  14814. 'RIAmount' => '0.00',
  14815. 'invoiceTotalAmount' => '0.00',
  14816. 'invoiceCompanyAmount' => '0.00',
  14817. 'invoiceArriveAmountM'=>'0.00',
  14818. 'invoiceCompanyAmountM'=>'0.00'
  14819. );
  14820. if ($invoiceTrainId != 0) {
  14821. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14822. }
  14823. $invoiceArriveAmount = $RIAmount = 0;
  14824. if (! empty ( $invoiceTrainingDetail )) {
  14825. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14826. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14827. }
  14828. // 备用金
  14829. $sum = 0;
  14830. if (! empty ( $trainLoanRid )) {
  14831. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14832. foreach ($receiptLoanList as $key=>$value){
  14833. $sum+=$value['sum'];
  14834. }
  14835. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14836. // $sum = $receiptLoanDetailBak ['sum'];
  14837. }
  14838. // 支出项金额详情
  14839. // 项目金额合计
  14840. Doo::loadModel ( 'RItem' );
  14841. $RItem = new RItem ();
  14842. Doo::loadModel ( 'accountItem' );
  14843. $accountItem = new accountItem ();
  14844. // 讲师获得
  14845. Doo::loadModel ( 'RILecturer' );
  14846. $RILecturer = new RILecturer ();
  14847. $RItemList = $RItem->getRItemByRid ($rid );
  14848. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14849. // 支出项金额详情
  14850. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14851. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14852. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14853. return $payment;
  14854. }
  14855. }
  14856. ?>