ReceiptController.php 570 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435
  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){
  323. Doo::loadModel ( 'itinerary' );
  324. $itineraryJson=json_decode($itinerary,true);
  325. $itinerary = new itinerary ();
  326. $itinerary->delete(array('where' => 'rid=' . $rid ));
  327. foreach ($itineraryJson as $key=>$value){
  328. if($key==0){
  329. $feeTraveItem=json_encode($value['feeTraveItem']);
  330. $itinerary = new itinerary ();
  331. $itinerary->rid=$rid;
  332. $itinerary->sid=$this->staff [0] ['sid'];
  333. $itinerary->itineraryDate=$value['departuredate'];
  334. $itinerary->itineraryCity=$value['departurecity'];
  335. $itinerary->feeTraveItem='';
  336. $itinerary->itineraryIndex=0;
  337. $itinerary->insert ();
  338. $itinerary = new itinerary ();
  339. $itinerary->rid=$rid;
  340. $itinerary->sid=$this->staff [0] ['sid'];
  341. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  342. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  343. $itinerary->feeTraveItem=$feeTraveItem;
  344. $itinerary->itineraryIndex=1;
  345. $itinerary->insert ();
  346. }else{
  347. $feeTraveItem=json_encode($value['feeTraveItem']);
  348. $itinerary = new itinerary ();
  349. $itinerary->rid=$rid;
  350. $itinerary->sid=$this->staff [0] ['sid'];
  351. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  352. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  353. $itinerary->feeTraveItem=$feeTraveItem;
  354. $itinerary->itineraryIndex=$key+1;
  355. $itinerary->insert ();
  356. }
  357. }
  358. }
  359. private function _verificationItinerary($itinerary){
  360. Doo::loadModel ( 'itinerary' );
  361. $itineraryObj = new itinerary ();
  362. if(empty($itinerary)){
  363. return false;
  364. }
  365. $itineraryJson=json_decode($itinerary,true);
  366. $itineraryDate=array();$sql=array();
  367. foreach ($itineraryJson as $key=>$value){
  368. if($key==0){
  369. array_push($itineraryDate, $value['departuredate']);
  370. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  371. array_push($sql,'?');array_push($sql,'?');
  372. }else{
  373. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  374. array_push($sql,'?');
  375. }
  376. }
  377. array_push($itineraryDate, $this->staff [0] ['sid']);
  378. $sql=implode(',',$sql);
  379. $qualification=array(
  380. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  381. 'param' => $itineraryDate,
  382. 'asArray' => TRUE);
  383. $itDateList=$itineraryObj->find($qualification);
  384. if(empty($itDateList)){
  385. return false;
  386. }else{
  387. return true;
  388. }
  389. }
  390. private function _buildFeeData($receiptClass=1,$itinerary=''){
  391. $agency = $this->get_args ( 'agency' );
  392. $travel = $this->get_args ( 'travel' );
  393. $train = $this->get_args ( 'train' );
  394. $other = $this->get_args ( 'other' );
  395. $inttrain = $this->get_args ( 'inttrain' );
  396. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  397. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  398. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  399. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  400. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  401. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  402. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  403. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  404. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  405. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  406. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  407. header ( 'Content-Type:text/html;charset=utf-8' );
  408. die ( '请填写联行号' );
  409. }
  410. if($receiptClass==2){
  411. if($this->_verificationItinerary($itinerary)){
  412. header ( 'Content-Type:text/html;charset=utf-8' );
  413. die ( '已申请过类此日期的行程' );
  414. }
  415. }
  416. Doo::loadModel ( 'receipt' );
  417. Doo::loadModel ( 'receiptDetail' );
  418. Doo::loadModel ( 'accountItem' );
  419. $accountItem = new accountItem ();
  420. $receipt = new receipt ();
  421. Doo::loadModel ( 'enclosur' );
  422. Doo::loadModel ( 'execute' );
  423. $execute = new execute ();
  424. $executeDetail = $execute->getOne ( array (
  425. 'where' => 'mold="报销单执行人"',
  426. 'asArray' => true
  427. ) );
  428. $aItem = $accountItem->find ( array (
  429. 'asArray' => true
  430. ) );
  431. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  432. $ag = $tr = $ta = $ot= $it = 0;
  433. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  434. foreach ( $aItem as $key => $value ) {
  435. if ($value ['category'] == $this->AGENCY) {
  436. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  437. array_push ( $accountJson [$this->AGENCY], array (
  438. 'aid' => $value ['aid'],
  439. 'name' => $value ['name'],
  440. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  441. ) );
  442. $sum += $agency [$ag];
  443. $agencySum += $agency [$ag];
  444. }
  445. $ag ++;
  446. }
  447. if ($value ['category'] == $this->TRAVEL) {
  448. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  449. array_push ( $accountJson [$this->TRAVEL], array (
  450. 'aid' => $value ['aid'],
  451. 'name' => $value ['name'],
  452. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  453. ) );
  454. $sum += $travel [$tr];
  455. $travelSum += $travel [$tr];
  456. }
  457. $tr ++;
  458. }
  459. if ($value ['category'] == $this->TRAIN) {
  460. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  461. array_push ( $accountJson [$this->TRAIN], array (
  462. 'aid' => $value ['aid'],
  463. 'name' => $value ['name'],
  464. 'price' => number_format ( $train [$ta], 2, '.', '' )
  465. ) );
  466. $sum += $train [$ta];
  467. $trainSum += $train [$ta];
  468. }
  469. $ta ++;
  470. }
  471. if ($value ['category'] == $this->INTTRAIN) {
  472. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  473. array_push ( $accountJson [$this->INTTRAIN], array (
  474. 'aid' => $value ['aid'],
  475. 'name' => $value ['name'],
  476. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  477. ) );
  478. $sum += $inttrain [$it];
  479. $inttrainSum += $inttrain [$it];
  480. }
  481. $it ++;
  482. }
  483. if ($value ['category'] == $this->OTHER) {
  484. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  485. array_push ( $accountJson [$this->OTHER], array (
  486. 'aid' => $value ['aid'],
  487. 'name' => $value ['name'],
  488. 'price' => number_format ( $other [$ot], 2, '.', '' )
  489. ) );
  490. $sum += $other [$ot];
  491. $otherSum += $other [$ot];
  492. }
  493. $ot ++;
  494. }
  495. }
  496. $accountJson ['cSum'] = array (
  497. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  498. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  499. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  500. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  501. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  502. );
  503. // 报销单
  504. $receipt->accountItem = json_encode ( $accountJson );
  505. $receipt->staff = $this->staff [0] ['sid'];
  506. $receipt->sum = number_format ( $sum, 2, '.', '' );
  507. $receipt->date = date ( "Y-m-d" );
  508. $receipt->cid = $cid;
  509. $receipt->status = 5;
  510. // 修改审批流程加入角色
  511. $receipt->verify = $verify;
  512. $receipt->executeCopy = $executeDetail ['staff'];
  513. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  514. $order = array (
  515. "\r\n",
  516. "\n",
  517. "\r"
  518. );
  519. $replace = '<br/>';
  520. $explanation = str_replace ( $order, $replace, $explanation );
  521. $receipt->explanation = $explanation;
  522. $receipt->receiptClass = $receiptClass;
  523. $receipt->itinerary=$itinerary;
  524. $receipt->remittanceName = $remittanceName;
  525. $receipt->bankName = $bankName;
  526. $receipt->bankNumber = $bankNumber;
  527. $receipt->remittanceBankType = $remittanceBankType;
  528. if ($remittanceBankType == 1) {
  529. $receipt->coupletNumber = $coupletNumber;
  530. }
  531. $rid = $receipt->insert ();
  532. //记录行程单
  533. $this->_storageItinerary($itinerary,$rid);
  534. // 附件
  535. if (! empty ( $enclosurName )) {
  536. $enclosurArray = explode ( '-', $enclosurName );
  537. foreach ( $enclosurArray as $value ) {
  538. $enclosur = new enclosur ();
  539. $enclosur->name = $value;
  540. $enclosur->rid = $rid;
  541. $enclosur->insert ();
  542. }
  543. }
  544. // 报销详情
  545. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  546. $receiptDetail = new receiptDetail ();
  547. $receiptDetail->staff = $this->staff [0] ['sid'];
  548. $receiptDetail->item = $value ['name'];
  549. $receiptDetail->itemCategory = $this->AGENCY;
  550. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  551. $receiptDetail->date = date ( "Y-m-d" );
  552. $receiptDetail->cid = $cid;
  553. $receiptDetail->rid = $rid;
  554. $receiptDetail->status = 4;
  555. $receiptDetail->insert ();
  556. }
  557. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  558. $receiptDetail = new receiptDetail ();
  559. $receiptDetail->staff = $this->staff [0] ['sid'];
  560. $receiptDetail->item = $value ['name'];
  561. $receiptDetail->itemCategory = $this->TRAVEL;
  562. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  563. $receiptDetail->date = date ( "Y-m-d" );
  564. $receiptDetail->cid = $cid;
  565. $receiptDetail->rid = $rid;
  566. $receiptDetail->status = 4;
  567. $receiptDetail->insert ();
  568. }
  569. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  570. $receiptDetail = new receiptDetail ();
  571. $receiptDetail->staff = $this->staff [0] ['sid'];
  572. $receiptDetail->item = $value ['name'];
  573. $receiptDetail->itemCategory = $this->TRAIN;
  574. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  575. $receiptDetail->date = date ( "Y-m-d" );
  576. $receiptDetail->cid = $cid;
  577. $receiptDetail->rid = $rid;
  578. $receiptDetail->status = 4;
  579. $receiptDetail->insert ();
  580. }
  581. // 内训
  582. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  583. $receiptDetail = new receiptDetail ();
  584. $receiptDetail->staff = $this->staff [0] ['sid'];
  585. $receiptDetail->item = $value ['name'];
  586. $receiptDetail->itemCategory = $this->INTTRAIN;
  587. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  588. $receiptDetail->date = date ( "Y-m-d" );
  589. $receiptDetail->cid = $cid;
  590. $receiptDetail->rid = $rid;
  591. $receiptDetail->status = 4;
  592. $receiptDetail->insert ();
  593. }
  594. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  595. $receiptDetail = new receiptDetail ();
  596. $receiptDetail->staff = $this->staff [0] ['sid'];
  597. $receiptDetail->item = $value ['name'];
  598. $receiptDetail->itemCategory = $this->OTHER;
  599. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  600. $receiptDetail->date = date ( "Y-m-d" );
  601. $receiptDetail->cid = $cid;
  602. $receiptDetail->rid = $rid;
  603. $receiptDetail->status = 4;
  604. $receiptDetail->insert ();
  605. }
  606. return true;
  607. } else
  608. return false;
  609. }
  610. function addReceipt() {
  611. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  612. if ($this->_buildFeeData(1)) {
  613. return "/saeaBorad";
  614. } else{
  615. die ( 'illegal request' );
  616. }
  617. }
  618. function addFeeTravel(){
  619. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  620. $itineraryList=json_decode($itinerary,true);
  621. foreach ($itineraryList as $key=>$value){
  622. if(empty($value['departuredate'])||empty($value['departurecity'])){
  623. header ( 'Content-Type:text/html;charset=utf-8' );
  624. die ( '请设置出发地和出发日期' );
  625. }
  626. }
  627. if ($this->_buildFeeData(2,$itinerary)) {
  628. return "/saeaBorad?travel=success";
  629. } else{
  630. die ( 'illegal request' );
  631. }
  632. }
  633. function addFeeInternalTrain(){
  634. if ($this->_buildFeeData(3)) {
  635. return "/saeaBorad";
  636. } else{
  637. die ( 'illegal request' );
  638. }
  639. }
  640. function referReceipt() {
  641. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  642. Doo::loadModel ( 'receipt' );
  643. Doo::loadModel ( 'verify' );
  644. $verify = new verify ();
  645. $receipt = new receipt ();
  646. Doo::loadModel ( 'L_category' );
  647. $lCategory = new L_category ();
  648. Doo::loadModel ( "role" );
  649. $role = new role ();
  650. $receiptDetail = $receipt->find ( array (
  651. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  652. 'asArray' => true
  653. ) );
  654. if (empty ( $receiptDetail ))
  655. return "/addReceipt";
  656. foreach ( $receiptDetail as $key => $value ) {
  657. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  658. $veList = $verify->getOne ( array (
  659. 'where' => 'vid=' . $value ['verify'],
  660. 'asArray' => true
  661. ) );
  662. $v = json_decode ( $veList ['staff'] );
  663. array_push ( $v [0], $veList ['description'] );
  664. foreach ( $v as $n => $m ) {
  665. if ($m ['1'] == 'ROLE') {
  666. $roleInfo = $role->getOne ( array (
  667. 'where' => 'rid=' . $m [0],
  668. 'asArray' => true
  669. ) );
  670. $v [$n] [1] = $roleInfo ['name'];
  671. }
  672. }
  673. $receiptDetail [$key] ['staff'] = $v;
  674. $category = $lCategory->getOne ( array (
  675. 'where' => 'cid=' . $value ['cid'],
  676. 'asArray' => true
  677. ) );
  678. $receiptDetail [$key] ['category'] = $category ['title'];
  679. }
  680. // print_r($receiptDetail);
  681. $data ['receiptDetail'] = $receiptDetail;
  682. $data ['memu'] = "receipt";
  683. $data ['staff'] = $this->staff;
  684. $data ['receiptMemu'] = 'saeaCreate';
  685. $data ['verifyId'] = $this->verifyId;
  686. $data ['executeId'] = $this->executeId;
  687. $this->render ( "/admin/saea_confirm", $data );
  688. }
  689. function editReceipt() {
  690. // edit status 4
  691. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  692. Doo::loadClass ( 'XDeode' );
  693. $XDeode = new XDeode ( 7 );
  694. $rid = $XDeode->decode ( $ridKey );
  695. if (empty ( $rid )) {
  696. die ( 'illegal request-id' );
  697. }
  698. // echo $rid.'sd';
  699. Doo::loadModel ( 'accountItem' );
  700. Doo::loadModel ( 'verify' );
  701. Doo::loadModel ( 'receipt' );
  702. $receipt = new receipt ();
  703. $verify = new verify ();
  704. $accountItem = new accountItem ();
  705. Doo::loadModel ( 'L_category' );
  706. $lCategory = new L_category ();
  707. Doo::loadModel ( "role" );
  708. $role = new role ();
  709. Doo::loadModel ( 'enclosur' );
  710. $enclosur = new enclosur ();
  711. $receiptDetail = $receipt->getOne ( array (
  712. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  713. 'asArray' => true
  714. ) );
  715. if (empty ( $receiptDetail )) {
  716. die ( 'illegal request-emptyData' );
  717. }
  718. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  719. $acItem = $accountItem->find ( array (
  720. 'asArray' => true
  721. ) );
  722. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  723. // 配置编辑信息
  724. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  725. foreach ( $acItem as $key => $value ) {
  726. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  727. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  728. $acItem [$key] ['price'] = $v ['price'];
  729. }
  730. }
  731. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  732. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  733. $acItem [$key] ['price'] = $v ['price'];
  734. }
  735. }
  736. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  737. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  738. $acItem [$key] ['price'] = $v ['price'];
  739. }
  740. }
  741. // 内训
  742. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  743. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  744. $acItem [$key] ['price'] = $v ['price'];
  745. }
  746. }
  747. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  748. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  749. $acItem [$key] ['price'] = $v ['price'];
  750. }
  751. }
  752. }
  753. $data ['category'] = $lCategory->find ( array (
  754. 'asArray' => true
  755. ) );
  756. $data ['cSum'] = $accountItemList ['cSum'];
  757. $data ['sum'] = $receiptDetail ['sum'];
  758. $data ['enclosurList'] = $enclosurList;
  759. $data ['receiptDetail'] = $receiptDetail;
  760. $data ['veList'] = $veList;
  761. $data ['acItem'] = $acItem;
  762. $data ['memu'] = "receipt";
  763. $data ['staff'] = $this->staff;
  764. $data ['receiptMemu'] = 'saeaBorad';
  765. $data ['verify'] = $receiptDetail ['verify'];
  766. $data ['verifyId'] = $this->verifyId;
  767. $data ['executeId'] = $this->executeId;
  768. $data ['rid'] = $ridKey;
  769. if($receiptDetail['receiptClass']==1){
  770. $this->render ( "/receipt/feeAgencyEdi", $data );
  771. }elseif($receiptDetail['receiptClass']==2){
  772. $this->render ( "/receipt/feeTravelEdi", $data );
  773. }elseif($receiptDetail['receiptClass']==3){
  774. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  775. }else{
  776. $this->render ( "/admin/saea_edit", $data );
  777. //die ( 'illegal request-renderHtml' );
  778. }
  779. }
  780. function updateReceipt() {
  781. $agency = $this->get_args ( 'agency' );
  782. $travel = $this->get_args ( 'travel' );
  783. $train = $this->get_args ( 'train' );
  784. $other = $this->get_args ( 'other' );
  785. $inttrain = $this->get_args ( 'inttrain' );
  786. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  787. $itinerary = $this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  788. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  789. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  790. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  791. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  792. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  793. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  794. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  795. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  796. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  797. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  798. Doo::loadClass ( 'XDeode' );
  799. $XDeode = new XDeode ( 7 );
  800. $rid = $XDeode->decode ( $ridKey );
  801. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  802. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  803. header ( 'Content-Type:text/html;charset=utf-8' );
  804. die ( '请填写联行号' );
  805. }
  806. Doo::loadModel ( 'receipt' );
  807. Doo::loadModel ( 'receiptDetail' );
  808. Doo::loadModel ( 'accountItem' );
  809. $accountItem = new accountItem ();
  810. $receipt = new receipt ();
  811. Doo::loadModel ( 'enclosur' );
  812. Doo::loadModel ( 'execute' );
  813. $execute = new execute ();
  814. $receiptDetail = $receipt->getOne ( array (
  815. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  816. 'asArray' => true
  817. ) );
  818. if (empty ( $receiptDetail )) {
  819. return "/saeaBorad";
  820. }
  821. //行程单
  822. $this->_storageItinerary($itinerary,$rid);
  823. if ($receiptDetail ['Rtype'] == 1) {
  824. $executeDetail = $execute->getOne ( array (
  825. 'where' => 'mold="借款费用执行人"',
  826. 'asArray' => true
  827. ) );
  828. } else {
  829. $executeDetail = $execute->getOne ( array (
  830. 'where' => 'mold="报销单执行人"',
  831. 'asArray' => true
  832. ) );
  833. }
  834. $aItem = $accountItem->find ( array (
  835. 'asArray' => true
  836. ) );
  837. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  838. $ag = $tr = $ta = $ot = $it = 0;
  839. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  840. foreach ( $aItem as $key => $value ) {
  841. if ($value ['category'] == $this->AGENCY) {
  842. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  843. array_push ( $accountJson [$this->AGENCY], array (
  844. 'aid' => $value ['aid'],
  845. 'name' => $value ['name'],
  846. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  847. ) );
  848. $sum += $agency [$ag];
  849. $agencySum += $agency [$ag];
  850. }
  851. $ag ++;
  852. }
  853. if ($value ['category'] == $this->TRAVEL) {
  854. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  855. array_push ( $accountJson [$this->TRAVEL], array (
  856. 'aid' => $value ['aid'],
  857. 'name' => $value ['name'],
  858. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  859. ) );
  860. $sum += $travel [$tr];
  861. $travelSum += $travel [$tr];
  862. }
  863. $tr ++;
  864. }
  865. if ($value ['category'] == $this->TRAIN) {
  866. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  867. array_push ( $accountJson [$this->TRAIN], array (
  868. 'aid' => $value ['aid'],
  869. 'name' => $value ['name'],
  870. 'price' => number_format ( $train [$ta], 2, '.', '' )
  871. ) );
  872. $sum += $train [$ta];
  873. $trainSum += $train [$ta];
  874. }
  875. $ta ++;
  876. }
  877. if ($value ['category'] == $this->INTTRAIN) {
  878. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  879. array_push ( $accountJson [$this->INTTRAIN], array (
  880. 'aid' => $value ['aid'],
  881. 'name' => $value ['name'],
  882. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  883. ) );
  884. $sum += $inttrain [$it];
  885. $inttrainSum += $inttrain [$it];
  886. }
  887. $it ++;
  888. }
  889. if ($value ['category'] == $this->OTHER) {
  890. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  891. array_push ( $accountJson [$this->OTHER], array (
  892. 'aid' => $value ['aid'],
  893. 'name' => $value ['name'],
  894. 'price' => number_format ( $other [$ot], 2, '.', '' )
  895. ) );
  896. $sum += $other [$ot];
  897. $otherSum += $other [$ot];
  898. }
  899. $ot ++;
  900. }
  901. }
  902. $accountJson ['cSum'] = array (
  903. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  904. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  905. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  906. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  907. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  908. );
  909. // 报销单
  910. $rid = $receipt->rid = $receiptDetail ['rid'];
  911. $receipt->accountItem = json_encode ( $accountJson );
  912. $receipt->staff = $this->staff [0] ['sid'];
  913. $receipt->sum = number_format ( $sum, 2, '.', '' );
  914. $receipt->date = date ( "Y-m-d" );
  915. $receipt->cid = $cid;
  916. if (($receiptDetail ['status'] != 4)) {
  917. if ($receiptDetail ['Rtype'] == 1) {
  918. $receipt->status = 7;
  919. } else {
  920. $receipt->status = 5;
  921. }
  922. }
  923. if ($receiptDetail != 4 && ! empty ( $verify ))
  924. $receipt->verify = $verify;
  925. $receipt->executeCopy = $executeDetail ['staff'];
  926. $order = array (
  927. "\r\n",
  928. "\n",
  929. "\r"
  930. );
  931. $replace = '<br/>';
  932. $explanation = str_replace ( $order, $replace, $explanation );
  933. $receipt->explanation = $explanation;
  934. if($receiptClass=='trave'){
  935. $receipt->itinerary=$itinerary;
  936. }
  937. $receipt->remittanceName = $remittanceName;
  938. $receipt->bankName = $bankName;
  939. $receipt->bankNumber = $bankNumber;
  940. $receipt->remittanceBankType = $remittanceBankType;
  941. if ($remittanceBankType == 1)
  942. $receipt->coupletNumber = $coupletNumber;
  943. $receipt->update ();
  944. $receiptDetail = new receiptDetail ();
  945. $receiptDetail->delete ( array (
  946. 'where' => 'rid=' . $rid
  947. ) );
  948. // 报销详情
  949. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  950. $receiptDetail = new receiptDetail ();
  951. $receiptDetail->staff = $this->staff [0] ['sid'];
  952. $receiptDetail->item = $value ['name'];
  953. $receiptDetail->itemCategory = $this->AGENCY;
  954. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  955. $receiptDetail->date = date ( "Y-m-d" );
  956. $receiptDetail->cid = $cid;
  957. $receiptDetail->rid = $rid;
  958. $receiptDetail->status = 4;
  959. $receiptDetail->insert ();
  960. }
  961. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  962. $receiptDetail = new receiptDetail ();
  963. $receiptDetail->staff = $this->staff [0] ['sid'];
  964. $receiptDetail->item = $value ['name'];
  965. $receiptDetail->itemCategory = $this->TRAVEL;
  966. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  967. $receiptDetail->date = date ( "Y-m-d" );
  968. $receiptDetail->cid = $cid;
  969. $receiptDetail->rid = $rid;
  970. $receiptDetail->status = 4;
  971. $receiptDetail->insert ();
  972. }
  973. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  974. $receiptDetail = new receiptDetail ();
  975. $receiptDetail->staff = $this->staff [0] ['sid'];
  976. $receiptDetail->item = $value ['name'];
  977. $receiptDetail->itemCategory = $this->TRAIN;
  978. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  979. $receiptDetail->date = date ( "Y-m-d" );
  980. $receiptDetail->cid = $cid;
  981. $receiptDetail->rid = $rid;
  982. $receiptDetail->status = 4;
  983. $receiptDetail->insert ();
  984. }
  985. // 内训
  986. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  987. $receiptDetail = new receiptDetail ();
  988. $receiptDetail->staff = $this->staff [0] ['sid'];
  989. $receiptDetail->item = $value ['name'];
  990. $receiptDetail->itemCategory = $this->INTTRAIN;
  991. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  992. $receiptDetail->date = date ( "Y-m-d" );
  993. $receiptDetail->cid = $cid;
  994. $receiptDetail->rid = $rid;
  995. $receiptDetail->status = 4;
  996. $receiptDetail->insert ();
  997. }
  998. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  999. $receiptDetail = new receiptDetail ();
  1000. $receiptDetail->staff = $this->staff [0] ['sid'];
  1001. $receiptDetail->item = $value ['name'];
  1002. $receiptDetail->itemCategory = $this->OTHER;
  1003. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1004. $receiptDetail->date = date ( "Y-m-d" );
  1005. $receiptDetail->cid = $cid;
  1006. $receiptDetail->rid = $rid;
  1007. $receiptDetail->status = 4;
  1008. $receiptDetail->insert ();
  1009. }
  1010. // 附件
  1011. if (! empty ( $enclosurName )) {
  1012. $enclosurArray = explode ( '-', $enclosurName );
  1013. foreach ( $enclosurArray as $value ) {
  1014. $enclosur = new enclosur ();
  1015. $enclosur->name = $value;
  1016. $enclosur->rid = $rid;
  1017. $enclosur->insert ();
  1018. }
  1019. }
  1020. // return "/referReceipt/".$rid;
  1021. }
  1022. return "/saeaBorad";
  1023. }
  1024. function remitAdd() {
  1025. Doo::loadModel ( 'accountItem' );
  1026. Doo::loadModel ( 'verify' );
  1027. Doo::loadModel ( 'receipt' );
  1028. Doo::loadModel ( 'L_category' );
  1029. $lCategory = new L_category ();
  1030. $receipt = new receipt ();
  1031. $verify = new verify ();
  1032. $accountItem = new accountItem ();
  1033. Doo::loadModel ( "role" );
  1034. $role = new role ();
  1035. $acItem = $accountItem->find ( array (
  1036. 'asArray' => true
  1037. ) );
  1038. $veList = $verify->getVerifyBySubordinate('REMIT');
  1039. $data ['category'] = $lCategory->find ( array (
  1040. 'asArray' => true
  1041. ) );
  1042. $data ['veList'] = $veList;
  1043. $data ['acItem'] = $acItem;
  1044. $data ['memu'] = "receipt";
  1045. $data ['staff'] = $this->staff;
  1046. $data ['receiptMemu'] = 'saeaBorad';
  1047. $data ['verifyId'] = $this->verifyId;
  1048. $data ['executeId'] = $this->executeId;
  1049. $this->render ( "/admin/remitAdd", $data );
  1050. }
  1051. function remitAddDo() {
  1052. $agency = $this->get_args ( 'agency' );
  1053. $travel = $this->get_args ( 'travel' );
  1054. $train = $this->get_args ( 'train' );
  1055. $other = $this->get_args ( 'other' );
  1056. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1057. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1058. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1059. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1060. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1061. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1062. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1063. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1064. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1065. // print_r($agency);die;
  1066. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1067. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1068. header ( 'Content-Type:text/html;charset=utf-8' );
  1069. die ( '请填写联行号' );
  1070. }
  1071. Doo::loadModel ( 'receipt' );
  1072. Doo::loadModel ( 'receiptDetail' );
  1073. Doo::loadModel ( 'accountItem' );
  1074. $accountItem = new accountItem ();
  1075. $receipt = new receipt ();
  1076. Doo::loadModel ( 'enclosur' );
  1077. Doo::loadModel ( 'execute' );
  1078. $execute = new execute ();
  1079. $executeDetail = $execute->getOne ( array (
  1080. 'where' => 'mold="对公汇款执行人"',
  1081. 'asArray' => true
  1082. ) );
  1083. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1084. $aItem = $accountItem->find ( array (
  1085. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1086. 'asArray' => true
  1087. ) );
  1088. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1089. $ag = $tr = $ta = $ot = 0;
  1090. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1091. print_r($aItem);
  1092. foreach ( $aItem as $key => $value ) {
  1093. if ($value ['category'] == $this->AGENCY) {
  1094. if (isset ( $agency [$ag] )) {
  1095. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1096. array_push ( $accountJson [$this->AGENCY], array (
  1097. 'aid' => $value ['aid'],
  1098. 'name' => $value ['name'],
  1099. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1100. ) );
  1101. $sum += $agency [$ag];
  1102. $agencySum += $agency [$ag];
  1103. }
  1104. }
  1105. $ag ++;
  1106. }
  1107. }
  1108. $accountJson ['cSum'] = array (
  1109. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1110. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1111. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1112. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1113. );
  1114. //die;
  1115. // 报销单
  1116. $receipt->accountItem = json_encode ( $accountJson );
  1117. $receipt->staff = $this->staff [0] ['sid'];
  1118. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1119. $receipt->date = date ( "Y-m-d" );
  1120. $receipt->cid = $cid;
  1121. $receipt->status = 5;
  1122. $receipt->Rtype = 2;
  1123. // 修改审批流程加入角色
  1124. $receipt->verify = $verify;
  1125. $receipt->executeCopy = $executeDetail ['staff'];
  1126. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1127. $order = array (
  1128. "\r\n",
  1129. "\n",
  1130. "\r"
  1131. );
  1132. $replace = '<br/>';
  1133. $explanation = str_replace ( $order, $replace, $explanation );
  1134. $receipt->explanation = $explanation;
  1135. $receipt->remittanceName = $remittanceName;
  1136. $receipt->bankName = $bankName;
  1137. $receipt->bankNumber = $bankNumber;
  1138. $receipt->remittanceBankType = $remittanceBankType;
  1139. if ($remittanceBankType == 1)
  1140. $receipt->coupletNumber = $coupletNumber;
  1141. $rid = $receipt->insert ();
  1142. // 附件
  1143. if (! empty ( $enclosurName )) {
  1144. $enclosurArray = explode ( '-', $enclosurName );
  1145. foreach ( $enclosurArray as $value ) {
  1146. $enclosur = new enclosur ();
  1147. $enclosur->name = $value;
  1148. $enclosur->rid = $rid;
  1149. $enclosur->insert ();
  1150. }
  1151. // print_r($enclosurArray);die;
  1152. }
  1153. // 报销详情
  1154. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1155. $receiptDetail = new receiptDetail ();
  1156. $receiptDetail->staff = $this->staff [0] ['sid'];
  1157. $receiptDetail->item = $value ['name'];
  1158. $receiptDetail->itemCategory = $this->AGENCY;
  1159. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1160. $receiptDetail->date = date ( "Y-m-d" );
  1161. $receiptDetail->cid = $cid;
  1162. $receiptDetail->rid = $rid;
  1163. $receiptDetail->status = 4;
  1164. $receiptDetail->insert ();
  1165. }
  1166. return "/saeaBorad";
  1167. } else
  1168. die ( 'illegal request' );
  1169. }
  1170. function remitEdit() {
  1171. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1172. Doo::loadClass ( 'XDeode' );
  1173. $XDeode = new XDeode ( 7 );
  1174. $rid = $XDeode->decode ( $ridKey );
  1175. if (! is_numeric ( $rid ))
  1176. die ( 'illegal request' );
  1177. Doo::loadModel ( 'accountItem' );
  1178. Doo::loadModel ( 'verify' );
  1179. Doo::loadModel ( 'receipt' );
  1180. $receipt = new receipt ();
  1181. $verify = new verify ();
  1182. $accountItem = new accountItem ();
  1183. Doo::loadModel ( 'L_category' );
  1184. $lCategory = new L_category ();
  1185. Doo::loadModel ( "role" );
  1186. $role = new role ();
  1187. Doo::loadModel ( 'enclosur' );
  1188. $enclosur = new enclosur ();
  1189. $receiptDetail = $receipt->getOne ( array (
  1190. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1191. 'asArray' => true
  1192. ) );
  1193. if (empty ( $receiptDetail ))
  1194. return "/saeaCreate";
  1195. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1196. $acItem = $accountItem->find ( array (
  1197. 'asArray' => true
  1198. ) );
  1199. $veList = $verify->getVerifyBySubordinate('REMIT');
  1200. // 配置编辑信息
  1201. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1202. foreach ( $acItem as $key => $value ) {
  1203. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1204. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1205. $acItem [$key] ['price'] = $v ['price'];
  1206. }
  1207. }
  1208. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1209. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1210. $acItem [$key] ['price'] = $v ['price'];
  1211. }
  1212. }
  1213. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1214. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1215. $acItem [$key] ['price'] = $v ['price'];
  1216. }
  1217. }
  1218. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1219. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1220. $acItem [$key] ['price'] = $v ['price'];
  1221. }
  1222. }
  1223. }
  1224. $data ['category'] = $lCategory->find ( array (
  1225. 'asArray' => true
  1226. ) );
  1227. $data ['enclosurList'] = $enclosurList;
  1228. $data ['cSum'] = $accountItemList ['cSum'];
  1229. $data ['sum'] = $receiptDetail ['sum'];
  1230. $data ['receiptDetail'] = $receiptDetail;
  1231. $data ['veList'] = $veList;
  1232. $data ['acItem'] = $acItem;
  1233. $data ['memu'] = "receipt";
  1234. $data ['staff'] = $this->staff;
  1235. $data ['receiptMemu'] = 'saeaBorad';
  1236. $data ['verify'] = $receiptDetail ['verify'];
  1237. $data ['verifyId'] = $this->verifyId;
  1238. $data ['executeId'] = $this->executeId;
  1239. $data ['rid'] = $rid;
  1240. $data ['ridKey'] = $ridKey;
  1241. $this->render ( "/admin/remitEdit", $data );
  1242. }
  1243. function remitEdiDo() {
  1244. $agency = $this->get_args ( 'agency' );
  1245. $travel = $this->get_args ( 'travel' );
  1246. $train = $this->get_args ( 'train' );
  1247. $other = $this->get_args ( 'other' );
  1248. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1249. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1250. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1251. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1252. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1253. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1254. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1255. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1256. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1257. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1258. Doo::loadClass ( 'XDeode' );
  1259. $XDeode = new XDeode ( 7 );
  1260. $rid = $XDeode->decode ( $ridKey );
  1261. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1262. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1263. header ( 'Content-Type:text/html;charset=utf-8' );
  1264. die ( '请填写联行号' );
  1265. }
  1266. Doo::loadModel ( 'receipt' );
  1267. Doo::loadModel ( 'receiptDetail' );
  1268. Doo::loadModel ( 'accountItem' );
  1269. $accountItem = new accountItem ();
  1270. $receipt = new receipt ();
  1271. Doo::loadModel ( 'enclosur' );
  1272. $enclosur = new enclosur ();
  1273. Doo::loadModel ( 'execute' );
  1274. $execute = new execute ();
  1275. $executeDetail = $execute->getOne ( array (
  1276. 'where' => 'mold="对公汇款执行人"',
  1277. 'asArray' => true
  1278. ) );
  1279. $receiptDetail = $receipt->getOne ( array (
  1280. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1281. 'asArray' => true
  1282. ) );
  1283. if (empty ( $receiptDetail ))
  1284. return "/saeaBorad";
  1285. $aItem = $accountItem->find ( array (
  1286. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1287. 'asArray' => true
  1288. ) );
  1289. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1290. $ag = $tr = $ta = $ot = 0;
  1291. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1292. foreach ( $aItem as $key => $value ) {
  1293. if ($value ['category'] == $this->AGENCY) {
  1294. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1295. array_push ( $accountJson [$this->AGENCY], array (
  1296. 'aid' => $value ['aid'],
  1297. 'name' => $value ['name'],
  1298. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1299. ) );
  1300. $sum += $agency [$ag];
  1301. $agencySum += $agency [$ag];
  1302. }
  1303. $ag ++;
  1304. }
  1305. }
  1306. $accountJson ['cSum'] = array (
  1307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1311. );
  1312. // 报销单
  1313. $rid = $receipt->rid = $receiptDetail ['rid'];
  1314. $receipt->accountItem = json_encode ( $accountJson );
  1315. $receipt->staff = $this->staff [0] ['sid'];
  1316. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1317. $receipt->date = date ( "Y-m-d" );
  1318. $receipt->cid = $cid;
  1319. if ($receiptDetail ['Rtype'] == 1)
  1320. $receipt->status = 7;
  1321. else
  1322. $receipt->status = 5;
  1323. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1324. $receipt->verify = $verify;
  1325. $receipt->executeCopy = $executeDetail ['staff'];
  1326. $order = array (
  1327. "\r\n",
  1328. "\n",
  1329. "\r"
  1330. );
  1331. $replace = '<br/>';
  1332. $explanation = str_replace ( $order, $replace, $explanation );
  1333. $receipt->explanation = $explanation;
  1334. $receipt->remittanceName = $remittanceName;
  1335. $receipt->bankName = $bankName;
  1336. $receipt->bankNumber = $bankNumber;
  1337. $receipt->remittanceBankType = $remittanceBankType;
  1338. if ($remittanceBankType == 1)
  1339. $receipt->coupletNumber = $coupletNumber;
  1340. $receipt->update ();
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->delete ( array (
  1343. 'where' => 'rid=' . $rid
  1344. ) );
  1345. // 报销详情
  1346. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1347. $receiptDetail = new receiptDetail ();
  1348. $receiptDetail->staff = $this->staff [0] ['sid'];
  1349. $receiptDetail->item = $value ['name'];
  1350. $receiptDetail->itemCategory = $this->AGENCY;
  1351. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1352. $receiptDetail->date = date ( "Y-m-d" );
  1353. $receiptDetail->cid = $cid;
  1354. $receiptDetail->rid = $rid;
  1355. $receiptDetail->status = 4;
  1356. $receiptDetail->insert ();
  1357. }
  1358. // 附件
  1359. if (! empty ( $enclosurName )) {
  1360. $enclosurArray = explode ( '-', $enclosurName );
  1361. foreach ( $enclosurArray as $value ) {
  1362. $enclosur = new enclosur ();
  1363. $enclosur->name = $value;
  1364. $enclosur->rid = $rid;
  1365. $enclosur->insert ();
  1366. }
  1367. }
  1368. }
  1369. return "/saeaBorad";
  1370. }
  1371. function remitApproval() {
  1372. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1373. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1374. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1375. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1376. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1377. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1378. if (empty ( $status ))
  1379. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1380. $vidList = array ();
  1381. $button = 0;
  1382. Doo::loadModel ( 'verify' );
  1383. Doo::loadModel ( 'receipt' );
  1384. Doo::loadModel ( 'staff' );
  1385. $staff = new staff ();
  1386. $receipt = new receipt ();
  1387. $verify = new verify ();
  1388. Doo::loadModel ( 'L_category' );
  1389. $Lcategory = new L_category ();
  1390. Doo::loadModel ( 'enclosur' );
  1391. $enclosur = new enclosur ();
  1392. // user verify ID
  1393. $verifyDetail = $verify->find ( array (
  1394. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1395. 'asArray' => true
  1396. ) );
  1397. foreach ( $verifyDetail as $key => $value ) {
  1398. array_push ( $vidList, $value ['vid'] );
  1399. }
  1400. $vid = implode ( ",", $vidList );
  1401. if (empty ( $verifyDetail ))
  1402. $vid = 0;
  1403. $categoryList = $Lcategory->find ( array (
  1404. 'asArray' => true
  1405. ) );
  1406. $staffList = $staff->find ( array (
  1407. 'where' => 'cid=' . $cid,
  1408. 'asArray' => true
  1409. ) );
  1410. $ap = "";
  1411. if ($status == 4) {
  1412. $ap = 4;
  1413. $status = 2;
  1414. }
  1415. // get Receipt By verifyID status 2
  1416. $receiptList = $receipt->find ( array (
  1417. 'where' => 'rid =' . $rid . ' and status=2',
  1418. 'desc' => 'rid',
  1419. 'asArray' => true
  1420. ) );
  1421. if (empty ( $receiptList )) {
  1422. die ( 'illegal request' );
  1423. }
  1424. $Locate = 0;
  1425. $roleId = 0;
  1426. if ($ap == 4)
  1427. $status = 4;
  1428. foreach ( $receiptList as $key => $value ) {
  1429. $receiptList [$key] ['Locate'] = $Locate;
  1430. $Locate ++;
  1431. $receiptList [$key] ['reviseDetail'] = array ();
  1432. if (! empty ( $value ['reviseDetail'] ))
  1433. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1434. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1435. $categoryDetil = $Lcategory->getOne ( array (
  1436. 'where' => 'cid=' . $value ['cid'],
  1437. 'asArray' => true
  1438. ) );
  1439. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1440. // 检测编辑状态
  1441. $verifyList = $verify->getOne ( array (
  1442. 'where' => 'vid=' . $value ['verify'],
  1443. 'asArray' => true
  1444. ) );
  1445. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1446. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1447. Doo::loadModel ( 'role' );
  1448. $role = new role ();
  1449. // print_r($verifyList);
  1450. $flag = true;
  1451. $roleKey = 0;
  1452. $endStaffArray = array ();
  1453. $roleArrayCopy = array ();
  1454. foreach ( $verifyList as $k => $v ) {
  1455. // init verifyStaff
  1456. if ($v [1] == 'ROLE') {
  1457. if (! empty ( $verifyStaff )) {
  1458. $endStaffArray = end ( $verifyStaff );
  1459. if ($v [0] == $endStaffArray ['nextStaff']) {
  1460. $roleId = $v [0];
  1461. }
  1462. }
  1463. $roleVerify = json_decode ( $v [3], true );
  1464. $roleKey = $k;
  1465. $roleArray = array ();
  1466. $rolename = $role->getOne ( array (
  1467. 'where' => 'rid=' . $v [0],
  1468. 'asArray' => true
  1469. ) );
  1470. foreach ( $roleVerify as $o => $p ) {
  1471. $staffID = explode ( '_', $p );
  1472. $staffInfo = $staff->getOne ( array (
  1473. 'where' => 'sid=' . $staffID [0],
  1474. 'asArray' => true
  1475. ) );
  1476. // print_r($staffID);
  1477. $exp = array (
  1478. 0 => $staffInfo ['sid'],
  1479. 1 => $staffID [1],
  1480. 2 => $staffInfo ['avatar'],
  1481. 'date' => '',
  1482. 'date' => '',
  1483. 'opinion' => '',
  1484. 'status' => '',
  1485. 'rolename' => $rolename ['name']
  1486. );
  1487. array_push ( $roleArray, $exp );
  1488. }
  1489. $roleArrayCopy [$v [0]] = $roleArray;
  1490. // $verifyList[$k]['roleArray']=$roleArray;
  1491. }
  1492. // print_r($roleArray);
  1493. $verifyList [$k] ['date'] = "";
  1494. $verifyList [$k] ['opinion'] = "";
  1495. $verifyList [$k] ['status'] = "";
  1496. if (empty ( $verifyStaff )) {
  1497. $verifyList [$k] ['date'] = "";
  1498. $verifyList [$k] ['opinion'] = "";
  1499. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1500. $verifyList [$k] ['status'] = 4;
  1501. $button = 4;
  1502. $flag = false;
  1503. }
  1504. } else {
  1505. foreach ( $verifyStaff as $m => $u ) {
  1506. if ($v [0] == $m) {
  1507. $verifyList [$k] ['date'] = $u ['date'];
  1508. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1509. $verifyList [$k] ['status'] = $u ['status'];
  1510. $flag = false;
  1511. break;
  1512. }
  1513. }
  1514. $endStaffArray = end ( $verifyStaff );
  1515. if (isset ( $endStaffArray ['ROLE'] )) {
  1516. } else {
  1517. $endKey = key ( $verifyStaff );
  1518. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1519. $button = 4;
  1520. $verifyList [$k] ['status'] = 4;
  1521. }
  1522. }
  1523. }
  1524. }
  1525. $rolename ['name'] = '';
  1526. if (! empty ( $roleId )) {
  1527. Doo::loadModel ( 'role' );
  1528. $role = new role ();
  1529. $rolename = $role->getOne ( array (
  1530. 'where' => 'rid=' . $roleId,
  1531. 'asArray' => true
  1532. ) );
  1533. }
  1534. if (! empty ( $verifyStaff ))
  1535. $endStaffArray = end ( $verifyStaff );
  1536. $KOP = false;
  1537. foreach ( $roleArrayCopy as $P => $A ) {
  1538. foreach ( $A as $MKI => $AVL ) {
  1539. if (! empty ( $verifyStaff )) {
  1540. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1541. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1542. $button = 4;
  1543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1544. }
  1545. foreach ( $verifyStaff as $m => $u ) {
  1546. $AVLFK = $AVL [0] . '_R';
  1547. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1548. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1549. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1550. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1552. break;
  1553. }
  1554. }
  1555. } else {
  1556. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1557. $button = 4;
  1558. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1559. }
  1560. }
  1561. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1562. $KOP = true;
  1563. }
  1564. }
  1565. foreach ( $roleArrayCopy as $k => $v ) {
  1566. foreach ( $verifyList as $m => $n ) {
  1567. if ($n [0] == $k) {
  1568. array_splice ( $verifyList, $m, 1, $v );
  1569. }
  1570. }
  1571. }
  1572. $receiptList [$key] ['verifyList'] = $verifyList;
  1573. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1574. 'where' => 'sid=' . $value ['staff'],
  1575. 'asArray' => true
  1576. ) );
  1577. $receiptList [$key] ['button'] = $button;
  1578. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1579. }
  1580. $mothHtml = "";
  1581. for($i = 1; $i <= 12; $i ++) {
  1582. if ($month == $i)
  1583. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1584. else
  1585. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1586. }
  1587. // 获取审批日志
  1588. Doo::loadModel ( 'receiptLog' );
  1589. $receiptLog = new receiptLog ();
  1590. $rlList = array ();
  1591. $rlInfo = $receiptLog->getOne ( array (
  1592. 'where' => 'rid=' . $rid . ' and status=4',
  1593. 'asArray' => true
  1594. ) );
  1595. $tijdate = $receiptLog->getOne ( array (
  1596. 'where' => 'rid=' . $rid . ' and status=2',
  1597. 'asc' => 'rlid',
  1598. 'asArray' => true
  1599. ) );
  1600. if (! empty ( $rlInfo )) {
  1601. $rlList = $receiptLog->find ( array (
  1602. 'where' => 'rid=' . $rid,
  1603. 'asc' => 'rlid',
  1604. 'asArray' => true
  1605. ) );
  1606. }
  1607. $receiptList [0] ['rlList'] = $rlList;
  1608. $enclosurList = $enclosur->find ( array (
  1609. 'where' => 'rid=' . $rid,
  1610. 'asArray' => true
  1611. ) );
  1612. $enclosurHtml = '';
  1613. foreach ( $enclosurList as $value ) {
  1614. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1615. }
  1616. // print_r($receiptList);
  1617. $data ['enclosurHtml'] = $enclosurHtml;
  1618. $data ['rolename'] = $rolename ['name'];
  1619. $data ['datetij'] = $tijdate ['date'];
  1620. $data ['mothHtml'] = $mothHtml;
  1621. $data ['rid'] = $rid;
  1622. $data ['receiptList'] = $receiptList;
  1623. $data ['receiptApprovalCount'] = count ( $receiptList );
  1624. $data ['status'] = $status;
  1625. $data ['year'] = $year;
  1626. $data ['categoryList'] = $categoryList;
  1627. $data ['staffList'] = $staffList;
  1628. $data ['cid'] = $cid;
  1629. $data ['sid'] = $sid;
  1630. $data ['ap'] = $ap;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'approvalExpenses';
  1634. $data ['verifyId'] = $this->verifyId;
  1635. $data ['executeId'] = $this->executeId;
  1636. $this->render ( "/admin/remitApproval", $data );
  1637. }
  1638. function saeaLoanAdd() {
  1639. Doo::loadModel ( 'verify' );
  1640. $verify = new verify ();
  1641. Doo::loadModel ( "role" );
  1642. $role = new role ();
  1643. Doo::loadModel ( 'L_category' );
  1644. $lCategory = new L_category ();
  1645. $veList = $verify->getVerifyBySubordinate('LOAN');
  1646. $data ['category'] = $lCategory->find ( array (
  1647. 'asArray' => true
  1648. ) );
  1649. $data ['veList'] = $veList;
  1650. $data ['memu'] = "receipt";
  1651. $data ['staff'] = $this->staff;
  1652. $data ['receiptMemu'] = 'saeaBorad';
  1653. $data ['verifyId'] = $this->verifyId;
  1654. $data ['executeId'] = $this->executeId;
  1655. $this->render ( "/admin/saeaLoanAdd", $data );
  1656. }
  1657. function saeaLoanAddDo() {
  1658. $agency = $this->get_args ( 'agency' );
  1659. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1660. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1661. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1662. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1663. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1664. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1665. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1666. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1667. // die;
  1668. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1669. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1670. header ( 'Content-Type:text/html;charset=utf-8' );
  1671. die ( '请填写联行号' );
  1672. }
  1673. Doo::loadModel ( 'receipt' );
  1674. Doo::loadModel ( 'receiptDetail' );
  1675. Doo::loadModel ( 'accountItem' );
  1676. $accountItem = new accountItem ();
  1677. $receipt = new receipt ();
  1678. Doo::loadModel ( 'loanReceipt' );
  1679. $loanReceipt = new loanReceipt ();
  1680. Doo::loadModel ( 'execute' );
  1681. $execute = new execute ();
  1682. Doo::loadModel ( 'enclosur' );
  1683. $executeDetail = $execute->getOne ( array (
  1684. 'where' => 'mold="借款执行人"',
  1685. 'asArray' => true
  1686. ) );
  1687. $aItem = $accountItem->find ( array (
  1688. 'asArray' => true
  1689. ) );
  1690. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1691. $ag = $tr = $ta = $ot = 0;
  1692. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1693. array_push ( $accountJson ['借款费用'], array (
  1694. 'aid' => 0,
  1695. 'name' => '申请金额',
  1696. 'price' => number_format ( $agency, 2, '.', '' )
  1697. ) );
  1698. $sum += $agency;
  1699. $agencySum += $agency;
  1700. $accountJson ['cSum'] = array (
  1701. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1702. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1703. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1704. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1705. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1706. );
  1707. // 借款数据备份
  1708. $loanReceipt->loanItem = json_encode ( $accountJson );
  1709. $loanReceipt->staff = $this->staff [0] ['sid'];
  1710. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1711. $loanReceipt->date = date ( "Y-m-d" );
  1712. $loanReceipt->cid = $cid;
  1713. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1714. $loanReceipt->status = 5;
  1715. $loanReceipt->Rtype = 1;
  1716. $loanReceipt->verify = $verify;
  1717. $receipt->receiptOrder = $receipt->receiptOrder;
  1718. // 添加HTML换行符
  1719. // var_dump($explanation);
  1720. $order = array (
  1721. "\r\n",
  1722. "\n",
  1723. "\r"
  1724. );
  1725. $replace = '<br/>';
  1726. $explanation = str_replace ( $order, $replace, $explanation );
  1727. // $explanation=str_replace('\r',"<br/>",$explanation);
  1728. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1729. $loanReceipt->explanation = $explanation;
  1730. $loanRid = $loanReceipt->insert ();
  1731. // 报销单
  1732. $receipt->loanItem = json_encode ( $accountJson );
  1733. $receipt->staff = $this->staff [0] ['sid'];
  1734. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1735. $receipt->date = date ( "Y-m-d" );
  1736. $receipt->cid = $cid;
  1737. // 特殊状态
  1738. $receipt->status = 5;
  1739. $receipt->Rtype = 1;
  1740. $receipt->loanRid = $loanRid;
  1741. // 修改审批流程加入角色
  1742. $receipt->verify = $verify;
  1743. $receipt->executeCopy = $executeDetail ['staff'];
  1744. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1745. $receipt->explanation = $explanation;
  1746. $receipt->remittanceName = $remittanceName;
  1747. $receipt->bankName = $bankName;
  1748. $receipt->bankNumber = $bankNumber;
  1749. $receipt->remittanceBankType = $remittanceBankType;
  1750. if ($remittanceBankType == 1)
  1751. $receipt->coupletNumber = $coupletNumber;
  1752. $rid = $receipt->insert ();
  1753. return "/saeaBorad";
  1754. } else
  1755. die ( 'illegal request' );
  1756. }
  1757. function saeaLoanEdi() {
  1758. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1759. Doo::loadClass ( 'XDeode' );
  1760. $XDeode = new XDeode ( 7 );
  1761. $rid = $XDeode->decode ( $ridKey );
  1762. if (! is_numeric ( $rid ))
  1763. die ( 'illegal request' );
  1764. Doo::loadModel ( 'verify' );
  1765. $verify = new verify ();
  1766. Doo::loadModel ( "role" );
  1767. $role = new role ();
  1768. Doo::loadModel ( 'L_category' );
  1769. $lCategory = new L_category ();
  1770. Doo::loadModel ( 'receipt' );
  1771. $receipt = new receipt ();
  1772. $receiptInfo = $receipt->getOne ( array (
  1773. 'where' => 'rid=' . $rid,
  1774. 'asArray' => true
  1775. ) );
  1776. $veList = $verify->find ( array (
  1777. 'where'=>'subordinate like "%LOAN%"',
  1778. 'asArray' => true
  1779. ) );
  1780. foreach ( $veList as $key => $value ) {
  1781. $v = json_decode ( $value ['staff'] );
  1782. $list = array ();
  1783. foreach ( $v as $n => $m ) {
  1784. if ($m ['1'] == 'ROLE') {
  1785. $roleInfo = $role->getOne ( array (
  1786. 'where' => 'rid=' . $m [0],
  1787. 'asArray' => true
  1788. ) );
  1789. $v [$n] [1] = $roleInfo ['name'];
  1790. array_push ( $list, $roleInfo ['name'] );
  1791. } else {
  1792. array_push ( $list, $v [$n] [1] );
  1793. }
  1794. }
  1795. $veList [$key] ['staff'] = implode ( '>', $list );
  1796. }
  1797. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1798. // print_r($receiptInfo);
  1799. $data ['receiptInfo'] = $receiptInfo;
  1800. $data ['category'] = $lCategory->find ( array (
  1801. 'asArray' => true
  1802. ) );
  1803. $data ['veList'] = $veList;
  1804. $data ['ridKey'] = $ridKey;
  1805. $data ['memu'] = "receipt";
  1806. $data ['staff'] = $this->staff;
  1807. $data ['receiptMemu'] = 'saeaBorad';
  1808. $data ['verifyId'] = $this->verifyId;
  1809. $data ['executeId'] = $this->executeId;
  1810. $this->render ( "/admin/saeaLoanEdi", $data );
  1811. }
  1812. function saeaLoanEdiDo() {
  1813. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1814. $agency = $this->get_args ( 'agency' );
  1815. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1816. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1817. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1818. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1819. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1820. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1821. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1822. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1823. // die;
  1824. Doo::loadClass ( 'XDeode' );
  1825. $XDeode = new XDeode ( 7 );
  1826. $rid = $XDeode->decode ( $ridKey );
  1827. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1828. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1829. header ( 'Content-Type:text/html;charset=utf-8' );
  1830. die ( '请填写联行号' );
  1831. }
  1832. Doo::loadModel ( 'receipt' );
  1833. Doo::loadModel ( 'receiptDetail' );
  1834. Doo::loadModel ( 'accountItem' );
  1835. $accountItem = new accountItem ();
  1836. $receipt = new receipt ();
  1837. Doo::loadModel ( 'loanReceipt' );
  1838. $loanReceipt = new loanReceipt ();
  1839. Doo::loadModel ( 'enclosur' );
  1840. Doo::loadModel ( 'execute' );
  1841. $execute = new execute ();
  1842. $executeDetail = $execute->getOne ( array (
  1843. 'where' => 'mold="借款执行人"',
  1844. 'asArray' => true
  1845. ) );
  1846. $receiptDetail = $receipt->getOne ( array (
  1847. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1848. 'asArray' => true
  1849. ) );
  1850. if (empty ( $receiptDetail ))
  1851. die ( '参数错误' );
  1852. $aItem = $accountItem->find ( array (
  1853. 'asArray' => true
  1854. ) );
  1855. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1856. $ag = $tr = $ta = $ot = 0;
  1857. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1858. array_push ( $accountJson ['借款费用'], array (
  1859. 'aid' => 0,
  1860. 'name' => '申请金额',
  1861. 'price' => number_format ( $agency, 2, '.', '' )
  1862. ) );
  1863. $sum += $agency;
  1864. $agencySum += $agency;
  1865. $accountJson ['cSum'] = array (
  1866. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1867. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1868. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1869. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1870. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1871. );
  1872. // 报销单
  1873. $receipt->loanItem = json_encode ( $accountJson );
  1874. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1875. $receipt->cid = $cid;
  1876. // 特殊状态
  1877. // 修改审批流程加入角色
  1878. if ($receiptDetail ['status'] != 4)
  1879. $receipt->verify = $verify;
  1880. $order = array (
  1881. "\r\n",
  1882. "\n",
  1883. "\r"
  1884. );
  1885. $replace = '<br/>';
  1886. $explanation = str_replace ( $order, $replace, $explanation );
  1887. $receipt->explanation = $explanation;
  1888. $receipt->remittanceName = $remittanceName;
  1889. $receipt->bankName = $bankName;
  1890. $receipt->bankNumber = $bankNumber;
  1891. $receipt->remittanceBankType = $remittanceBankType;
  1892. if ($remittanceBankType == 1)
  1893. $receipt->coupletNumber = $coupletNumber;
  1894. $receipt->update ( array (
  1895. 'where' => 'rid=' . $rid
  1896. ) );
  1897. // 借款数据更新
  1898. $loanReceipt->loanItem = json_encode ( $accountJson );
  1899. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1900. $loanReceipt->cid = $cid;
  1901. if ($receiptDetail ['status'] != 4)
  1902. $loanReceipt->verify = $verify;
  1903. $loanReceipt->explanation = $explanation;
  1904. $receipt->executeCopy = $executeDetail ['staff'];
  1905. $loanReceipt->update ( array (
  1906. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1907. ) );
  1908. }
  1909. return "/saeaBorad";
  1910. }
  1911. function saeaLoanReceiptAdd() {
  1912. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1913. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  1914. Doo::loadModel ( 'receipt' );
  1915. $receipt = new receipt ();
  1916. Doo::loadModel ( 'loanReceipt' );
  1917. $loanReceipt = new loanReceipt ();
  1918. Doo::loadModel ( 'L_category' );
  1919. $Lcategory = new L_category ();
  1920. Doo::loadModel ( 'verify' );
  1921. Doo::loadModel ( 'statistics' );
  1922. $statistics = new statistics ();
  1923. $verify = new verify ();
  1924. Doo::loadModel ( 'staff' );
  1925. $staff = new staff ();
  1926. $receiptDetail = $receipt->getOne ( array (
  1927. 'where' => 'rid=' . $rid,
  1928. 'desc' => 'rid',
  1929. 'asArray' => true
  1930. ) );
  1931. $receiptList = $loanReceipt->find ( array (
  1932. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1933. 'desc' => 'rid',
  1934. 'asArray' => true
  1935. ) );
  1936. $Locate = 0;
  1937. $roleId = 0;
  1938. $button = 0;
  1939. foreach ( $receiptList as $key => $value ) {
  1940. $receiptList [$key] ['Locate'] = $Locate;
  1941. $Locate ++;
  1942. $receiptList [$key] ['reviseDetail'] = array ();
  1943. if (! empty ( $value ['reviseDetail'] ))
  1944. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1945. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1946. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1947. $categoryDetil = $Lcategory->getOne ( array (
  1948. 'where' => 'cid=' . $value ['cid'],
  1949. 'asArray' => true
  1950. ) );
  1951. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1952. // 检测编辑状态
  1953. $verifyList = $verify->getOne ( array (
  1954. 'where' => 'vid=' . $value ['verify'],
  1955. 'asArray' => true
  1956. ) );
  1957. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1958. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1959. Doo::loadModel ( 'role' );
  1960. $role = new role ();
  1961. $flag = true;
  1962. $roleKey = 0;
  1963. $endStaffArray = array ();
  1964. $roleArrayCopy = array ();
  1965. foreach ( $verifyList as $k => $v ) {
  1966. // init verifyStaff
  1967. if ($v [1] == 'ROLE') {
  1968. if (! empty ( $verifyStaff )) {
  1969. $endStaffArray = end ( $verifyStaff );
  1970. // if ($v[0]==$endStaffArray['nextStaff']){
  1971. // $roleId=$v[0];
  1972. // }
  1973. }
  1974. $roleVerify = json_decode ( $v [3], true );
  1975. $roleKey = $k;
  1976. $roleArray = array ();
  1977. $rolename = $role->getOne ( array (
  1978. 'where' => 'rid=' . $v [0],
  1979. 'asArray' => true
  1980. ) );
  1981. foreach ( $roleVerify as $o => $p ) {
  1982. $staffID = explode ( '_', $p );
  1983. $staffInfo = $staff->getOne ( array (
  1984. 'where' => 'sid=' . $staffID [0],
  1985. 'asArray' => true
  1986. ) );
  1987. // print_r($staffID);
  1988. $exp = array (
  1989. 0 => $staffInfo ['sid'],
  1990. 1 => $staffID [1],
  1991. 2 => $staffInfo ['avatar'],
  1992. 'date' => '',
  1993. 'date' => '',
  1994. 'opinion' => '',
  1995. 'status' => '',
  1996. 'rolename' => $rolename ['name']
  1997. );
  1998. array_push ( $roleArray, $exp );
  1999. }
  2000. $roleArrayCopy [$v [0]] = $roleArray;
  2001. // $verifyList[$k]['roleArray']=$roleArray;
  2002. }
  2003. $verifyList [$k] ['date'] = "";
  2004. $verifyList [$k] ['opinion'] = "";
  2005. $verifyList [$k] ['status'] = "";
  2006. if (empty ( $verifyStaff )) {
  2007. $verifyList [$k] ['date'] = "";
  2008. $verifyList [$k] ['opinion'] = "";
  2009. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2010. $verifyList [$k] ['status'] = 4;
  2011. $flag = false;
  2012. }
  2013. } else {
  2014. foreach ( $verifyStaff as $m => $u ) {
  2015. if ($v [0] == $m) {
  2016. $verifyList [$k] ['date'] = $u ['date'];
  2017. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2018. $verifyList [$k] ['status'] = $u ['status'];
  2019. $flag = false;
  2020. break;
  2021. }
  2022. }
  2023. $endStaffArray = end ( $verifyStaff );
  2024. if (isset ( $endStaffArray ['ROLE'] )) {
  2025. } else {
  2026. // $endKey=key($verifyStaff);
  2027. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2028. // $button=4;
  2029. // $verifyList[$k]['status']=4;
  2030. // }
  2031. }
  2032. }
  2033. }
  2034. $rolename ['name'] = '';
  2035. if (! empty ( $roleId )) {
  2036. Doo::loadModel ( 'role' );
  2037. $role = new role ();
  2038. $rolename = $role->getOne ( array (
  2039. 'where' => 'rid=' . $roleId,
  2040. 'asArray' => true
  2041. ) );
  2042. }
  2043. if (! empty ( $verifyStaff ))
  2044. $endStaffArray = end ( $verifyStaff );
  2045. $KOP = false;
  2046. foreach ( $roleArrayCopy as $P => $A ) {
  2047. foreach ( $A as $MKI => $AVL ) {
  2048. if (! empty ( $verifyStaff )) {
  2049. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2050. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2051. $button = 4;
  2052. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2053. }
  2054. foreach ( $verifyStaff as $m => $u ) {
  2055. $AVLFK = $AVL [0] . '_R';
  2056. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2057. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2058. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2059. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2060. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2061. break;
  2062. }
  2063. }
  2064. } else {
  2065. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2066. $button = 4;
  2067. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2068. }
  2069. }
  2070. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2071. $KOP = true;
  2072. }
  2073. }
  2074. foreach ( $roleArrayCopy as $k => $v ) {
  2075. foreach ( $verifyList as $m => $n ) {
  2076. if ($n [0] == $k) {
  2077. array_splice ( $verifyList, $m, 1, $v );
  2078. }
  2079. }
  2080. }
  2081. $receiptList [$key] ['verifyList'] = $verifyList;
  2082. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2083. 'where' => 'sid=' . $value ['staff'],
  2084. 'asArray' => true
  2085. ) );
  2086. $receiptList [$key] ['button'] = $button;
  2087. //
  2088. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2089. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2090. }
  2091. $data ['receiptList'] = $receiptList;
  2092. $data ['receiptDetail'] = $receiptDetail;
  2093. Doo::loadModel ( 'L_category' );
  2094. $lCategory = new L_category ();
  2095. Doo::loadModel ( 'accountItem' );
  2096. $accountItem = new accountItem ();
  2097. $acItem = $accountItem->find ( array (
  2098. 'asArray' => true
  2099. ) );
  2100. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2101. $data ['rid'] = $rid;
  2102. $data ['category'] = $lCategory->find ( array (
  2103. 'asArray' => true
  2104. ) );
  2105. $data ['veList'] = $veList;
  2106. $data ['acItem'] = $acItem;
  2107. $data['itineraryDate']=$this->_itineraryDateMin();
  2108. $data ['memu'] = "receipt";
  2109. $data ['staff'] = $this->staff;
  2110. $data ['receiptMemu'] = 'saeaBorad';
  2111. $data ['verifyId'] = $this->verifyId;
  2112. $data ['executeId'] = $this->executeId;
  2113. $data['receiptClass']=$receiptClass;
  2114. if($receiptClass=='trave'){
  2115. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2116. }else{
  2117. $this->render ( "/receipt/feeLoanReceipt", $data );
  2118. }
  2119. }
  2120. function saeaLoanReceiptAddDo() {
  2121. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2122. $agency = $this->get_args ( 'agency' );
  2123. $travel = $this->get_args ( 'travel' );
  2124. $train = $this->get_args ( 'train' );
  2125. $other = $this->get_args ( 'other' );
  2126. $inttrain = $this->get_args ( 'inttrain' );
  2127. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2128. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2129. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2130. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2131. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2132. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2133. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2134. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2135. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2136. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2137. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2138. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2139. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2140. header ( 'Content-Type:text/html;charset=utf-8' );
  2141. die ( '请填写联行号' );
  2142. }
  2143. if($receiptClass=='agency'){
  2144. $receiptClass=1;
  2145. }elseif($receiptClass=='trave'){
  2146. $receiptClass=2;
  2147. if($this->_verificationItinerary($itinerary)){
  2148. header ( 'Content-Type:text/html;charset=utf-8' );
  2149. die ( '已申请过类此日期的行程' );
  2150. }
  2151. }elseif($receiptClass=='internalTrain'){
  2152. $receiptClass=3;
  2153. }else{
  2154. header ( 'Content-Type:text/html;charset=utf-8' );
  2155. die ( '借款报销单分类不正确' );
  2156. }
  2157. Doo::loadModel ( 'receipt' );
  2158. Doo::loadModel ( 'receiptDetail' );
  2159. Doo::loadModel ( 'accountItem' );
  2160. $accountItem = new accountItem ();
  2161. $receipt = new receipt ();
  2162. Doo::loadModel ( 'enclosur' );
  2163. Doo::loadModel ( 'execute' );
  2164. $execute = new execute ();
  2165. $executeDetail = $execute->getOne ( array (
  2166. 'where' => 'mold="借款费用执行人"',
  2167. 'asArray' => true
  2168. ) );
  2169. $receiptDet = $receipt->getOne ( array (
  2170. 'where' => 'rid=' . $rid,
  2171. 'asArray' => true
  2172. ) );
  2173. // if(!empty($receiptDetail))
  2174. // return "/referReceipt/".$receiptDetail['rid'];
  2175. $aItem = $accountItem->find ( array (
  2176. 'asArray' => true
  2177. ) );
  2178. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2179. $ag = $tr = $ta = $ot =$it = 0;
  2180. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2181. foreach ( $aItem as $key => $value ) {
  2182. if ($value ['category'] == $this->AGENCY) {
  2183. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2184. array_push ( $accountJson [$this->AGENCY], array (
  2185. 'aid' => $value ['aid'],
  2186. 'name' => $value ['name'],
  2187. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2188. ) );
  2189. $sum += $agency [$ag];
  2190. $agencySum += $agency [$ag];
  2191. }
  2192. $ag ++;
  2193. }
  2194. if ($value ['category'] == $this->TRAVEL) {
  2195. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2196. array_push ( $accountJson [$this->TRAVEL], array (
  2197. 'aid' => $value ['aid'],
  2198. 'name' => $value ['name'],
  2199. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2200. ) );
  2201. $sum += $travel [$tr];
  2202. $travelSum += $travel [$tr];
  2203. }
  2204. $tr ++;
  2205. }
  2206. if ($value ['category'] == $this->INTTRAIN) {
  2207. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2208. array_push ( $accountJson [$this->INTTRAIN], array (
  2209. 'aid' => $value ['aid'],
  2210. 'name' => $value ['name'],
  2211. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2212. ) );
  2213. $sum += $inttrain [$it];
  2214. $inttrainSum += $inttrain [$it];
  2215. }
  2216. $it ++;
  2217. }
  2218. if ($value ['category'] == $this->TRAIN) {
  2219. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2220. array_push ( $accountJson [$this->TRAIN], array (
  2221. 'aid' => $value ['aid'],
  2222. 'name' => $value ['name'],
  2223. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2224. ) );
  2225. $sum += $train [$ta];
  2226. $trainSum += $train [$ta];
  2227. }
  2228. $ta ++;
  2229. }
  2230. if ($value ['category'] == $this->OTHER) {
  2231. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2232. array_push ( $accountJson [$this->OTHER], array (
  2233. 'aid' => $value ['aid'],
  2234. 'name' => $value ['name'],
  2235. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2236. ) );
  2237. $sum += $other [$ot];
  2238. $otherSum += $other [$ot];
  2239. }
  2240. $ot ++;
  2241. }
  2242. }
  2243. $accountJson ['cSum'] = array (
  2244. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2245. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2246. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2247. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2248. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2249. );
  2250. // 报销单
  2251. $receipt->accountItem = json_encode ( $accountJson );
  2252. $receipt->staff = $this->staff [0] ['sid'];
  2253. $receipt->loanSum = $receiptDet ['sum'];
  2254. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2255. $receipt->date = date ( "Y-m-d" );
  2256. $receipt->pastDate = '0000-00-00';
  2257. $receipt->cid = $cid;
  2258. $receipt->status = 7;
  2259. $receipt->receiptClass=$receiptClass;
  2260. if($receiptClass==2){
  2261. $receipt->itinerary=$itinerary;
  2262. $this->_storageItinerary($itinerary, $rid);
  2263. }
  2264. // 修改审批流程加入角色
  2265. $receipt->verify = $verify;
  2266. $receipt->verifyStaff = '';
  2267. $receipt->executeStaff = '';
  2268. $receipt->executeCopy = $executeDetail ['staff'];
  2269. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2270. $receipt->explanation = $explanation;
  2271. $receipt->remittanceName = $remittanceName;
  2272. $receipt->bankName = $bankName;
  2273. $receipt->bankNumber = $bankNumber;
  2274. $receipt->remittanceBankType = $remittanceBankType;
  2275. if ($remittanceBankType == 1)
  2276. $receipt->coupletNumber = $coupletNumber;
  2277. $receipt->update ( array (
  2278. 'where' => 'rid=' . $rid
  2279. ) );
  2280. // 附件
  2281. if (! empty ( $enclosurName )) {
  2282. $enclosurArray = explode ( '-', $enclosurName );
  2283. foreach ( $enclosurArray as $value ) {
  2284. $enclosur = new enclosur ();
  2285. $enclosur->name = $value;
  2286. $enclosur->rid = $rid;
  2287. $enclosur->insert ();
  2288. }
  2289. // print_r($enclosurArray);die;
  2290. }
  2291. // 报销详情
  2292. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2293. $receiptDetail = new receiptDetail ();
  2294. $receiptDetail->staff = $this->staff [0] ['sid'];
  2295. $receiptDetail->item = $value ['name'];
  2296. $receiptDetail->itemCategory = $this->AGENCY;
  2297. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2298. $receiptDetail->date = date ( "Y-m-d" );
  2299. $receiptDetail->cid = $cid;
  2300. $receiptDetail->rid = $rid;
  2301. $receiptDetail->status = 4;
  2302. $receiptDetail->insert ();
  2303. }
  2304. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2305. $receiptDetail = new receiptDetail ();
  2306. $receiptDetail->staff = $this->staff [0] ['sid'];
  2307. $receiptDetail->item = $value ['name'];
  2308. $receiptDetail->itemCategory = $this->TRAVEL;
  2309. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2310. $receiptDetail->date = date ( "Y-m-d" );
  2311. $receiptDetail->cid = $cid;
  2312. $receiptDetail->rid = $rid;
  2313. $receiptDetail->status = 4;
  2314. $receiptDetail->insert ();
  2315. }
  2316. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2317. $receiptDetail = new receiptDetail ();
  2318. $receiptDetail->staff = $this->staff [0] ['sid'];
  2319. $receiptDetail->item = $value ['name'];
  2320. $receiptDetail->itemCategory = $this->TRAIN;
  2321. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2322. $receiptDetail->date = date ( "Y-m-d" );
  2323. $receiptDetail->cid = $cid;
  2324. $receiptDetail->rid = $rid;
  2325. $receiptDetail->status = 4;
  2326. $receiptDetail->insert ();
  2327. }
  2328. //内训
  2329. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2330. $receiptDetail = new receiptDetail ();
  2331. $receiptDetail->staff = $this->staff [0] ['sid'];
  2332. $receiptDetail->item = $value ['name'];
  2333. $receiptDetail->itemCategory = $this->INTTRAIN;
  2334. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2335. $receiptDetail->date = date ( "Y-m-d" );
  2336. $receiptDetail->cid = $cid;
  2337. $receiptDetail->rid = $rid;
  2338. $receiptDetail->status = 4;
  2339. $receiptDetail->insert ();
  2340. }
  2341. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2342. $receiptDetail = new receiptDetail ();
  2343. $receiptDetail->staff = $this->staff [0] ['sid'];
  2344. $receiptDetail->item = $value ['name'];
  2345. $receiptDetail->itemCategory = $this->OTHER;
  2346. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2347. $receiptDetail->date = date ( "Y-m-d" );
  2348. $receiptDetail->cid = $cid;
  2349. $receiptDetail->rid = $rid;
  2350. $receiptDetail->status = 4;
  2351. $receiptDetail->insert ();
  2352. }
  2353. return "/saeaBorad";
  2354. }
  2355. return "/saeaLoanReceiptAdd/" . $rid;
  2356. }
  2357. function saeaLoanReceiptEdi() {
  2358. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2359. Doo::loadClass ( 'XDeode' );
  2360. $XDeode = new XDeode ( 7 );
  2361. $rid = $XDeode->decode ( $ridKey );
  2362. if (! is_numeric ( $rid ))
  2363. die ( 'illegal request' );
  2364. Doo::loadModel ( 'accountItem' );
  2365. Doo::loadModel ( 'verify' );
  2366. Doo::loadModel ( 'receipt' );
  2367. $receipt = new receipt ();
  2368. $verify = new verify ();
  2369. $accountItem = new accountItem ();
  2370. Doo::loadModel ( 'L_category' );
  2371. $Lcategory = new L_category ();
  2372. Doo::loadModel ( "role" );
  2373. $role = new role ();
  2374. Doo::loadModel ( 'loanReceipt' );
  2375. $loanReceipt = new loanReceipt ();
  2376. Doo::loadModel ( 'staff' );
  2377. $staff = new staff ();
  2378. $receiptDetail = $receipt->getOne ( array (
  2379. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2380. 'asArray' => true
  2381. ) );
  2382. if (empty ( $receiptDetail ))
  2383. return "/saeaBorad";
  2384. $receiptList = $loanReceipt->find ( array (
  2385. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2386. 'desc' => 'rid',
  2387. 'asArray' => true
  2388. ) );
  2389. $Locate = 0;
  2390. $roleId = 0;
  2391. $button = 0;
  2392. foreach ( $receiptList as $key => $value ) {
  2393. $receiptList [$key] ['Locate'] = $Locate;
  2394. $Locate ++;
  2395. $receiptList [$key] ['reviseDetail'] = array ();
  2396. if (! empty ( $value ['reviseDetail'] ))
  2397. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2398. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2399. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2400. $categoryDetil = $Lcategory->getOne ( array (
  2401. 'where' => 'cid=' . $value ['cid'],
  2402. 'asArray' => true
  2403. ) );
  2404. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2405. // 检测编辑状态
  2406. $verifyList = $verify->getOne ( array (
  2407. 'where' => 'vid=' . $value ['verify'],
  2408. 'asArray' => true
  2409. ) );
  2410. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2411. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2412. Doo::loadModel ( 'role' );
  2413. $role = new role ();
  2414. $flag = true;
  2415. $roleKey = 0;
  2416. $endStaffArray = array ();
  2417. $roleArrayCopy = array ();
  2418. foreach ( $verifyList as $k => $v ) {
  2419. // init verifyStaff
  2420. if ($v [1] == 'ROLE') {
  2421. if (! empty ( $verifyStaff )) {
  2422. $endStaffArray = end ( $verifyStaff );
  2423. // if ($v[0]==$endStaffArray['nextStaff']){
  2424. // $roleId=$v[0];
  2425. // }
  2426. }
  2427. $roleVerify = json_decode ( $v [3], true );
  2428. $roleKey = $k;
  2429. $roleArray = array ();
  2430. $rolename = $role->getOne ( array (
  2431. 'where' => 'rid=' . $v [0],
  2432. 'asArray' => true
  2433. ) );
  2434. foreach ( $roleVerify as $o => $p ) {
  2435. $staffID = explode ( '_', $p );
  2436. $staffInfo = $staff->getOne ( array (
  2437. 'where' => 'sid=' . $staffID [0],
  2438. 'asArray' => true
  2439. ) );
  2440. // print_r($staffID);
  2441. $exp = array (
  2442. 0 => $staffInfo ['sid'],
  2443. 1 => $staffID [1],
  2444. 2 => $staffInfo ['avatar'],
  2445. 'date' => '',
  2446. 'date' => '',
  2447. 'opinion' => '',
  2448. 'status' => '',
  2449. 'rolename' => $rolename ['name']
  2450. );
  2451. array_push ( $roleArray, $exp );
  2452. }
  2453. $roleArrayCopy [$v [0]] = $roleArray;
  2454. // $verifyList[$k]['roleArray']=$roleArray;
  2455. }
  2456. $verifyList [$k] ['date'] = "";
  2457. $verifyList [$k] ['opinion'] = "";
  2458. $verifyList [$k] ['status'] = "";
  2459. if (empty ( $verifyStaff )) {
  2460. $verifyList [$k] ['date'] = "";
  2461. $verifyList [$k] ['opinion'] = "";
  2462. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2463. $verifyList [$k] ['status'] = 4;
  2464. $flag = false;
  2465. }
  2466. } else {
  2467. foreach ( $verifyStaff as $m => $u ) {
  2468. if ($v [0] == $m) {
  2469. $verifyList [$k] ['date'] = $u ['date'];
  2470. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2471. $verifyList [$k] ['status'] = $u ['status'];
  2472. $flag = false;
  2473. break;
  2474. }
  2475. }
  2476. $endStaffArray = end ( $verifyStaff );
  2477. if (isset ( $endStaffArray ['ROLE'] )) {
  2478. } else {
  2479. // $endKey=key($verifyStaff);
  2480. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2481. // $button=4;
  2482. // $verifyList[$k]['status']=4;
  2483. // }
  2484. }
  2485. }
  2486. }
  2487. $rolename ['name'] = '';
  2488. if (! empty ( $roleId )) {
  2489. Doo::loadModel ( 'role' );
  2490. $role = new role ();
  2491. $rolename = $role->getOne ( array (
  2492. 'where' => 'rid=' . $roleId,
  2493. 'asArray' => true
  2494. ) );
  2495. }
  2496. if (! empty ( $verifyStaff ))
  2497. $endStaffArray = end ( $verifyStaff );
  2498. $KOP = false;
  2499. foreach ( $roleArrayCopy as $P => $A ) {
  2500. foreach ( $A as $MKI => $AVL ) {
  2501. if (! empty ( $verifyStaff )) {
  2502. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2503. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2504. $button = 4;
  2505. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2506. }
  2507. foreach ( $verifyStaff as $m => $u ) {
  2508. $AVLFK = $AVL [0] . '_R';
  2509. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2510. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2511. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2512. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2513. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2514. break;
  2515. }
  2516. }
  2517. } else {
  2518. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2519. $button = 4;
  2520. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2521. }
  2522. }
  2523. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2524. $KOP = true;
  2525. }
  2526. }
  2527. foreach ( $roleArrayCopy as $k => $v ) {
  2528. foreach ( $verifyList as $m => $n ) {
  2529. if ($n [0] == $k) {
  2530. array_splice ( $verifyList, $m, 1, $v );
  2531. }
  2532. }
  2533. }
  2534. $receiptList [$key] ['verifyList'] = $verifyList;
  2535. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2536. 'where' => 'sid=' . $value ['staff'],
  2537. 'asArray' => true
  2538. ) );
  2539. $receiptList [$key] ['button'] = $button;
  2540. //
  2541. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2542. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2543. }
  2544. $data ['receiptList'] = $receiptList;
  2545. $acItem = $accountItem->find ( array (
  2546. 'asArray' => true
  2547. ) );
  2548. $veList = $verify->find ( array (
  2549. 'asArray' => true
  2550. ) );
  2551. foreach ( $veList as $key => $value ) {
  2552. $v = json_decode ( $value ['staff'] );
  2553. $list = array ();
  2554. foreach ( $v as $n => $m ) {
  2555. if ($m ['1'] == 'ROLE') {
  2556. $roleInfo = $role->getOne ( array (
  2557. 'where' => 'rid=' . $m [0],
  2558. 'asArray' => true
  2559. ) );
  2560. $v [$n] [1] = $roleInfo ['name'];
  2561. array_push ( $list, $roleInfo ['name'] );
  2562. } else {
  2563. array_push ( $list, $v [$n] [1] );
  2564. }
  2565. }
  2566. $veList [$key] ['staff'] = implode ( '>', $list );
  2567. }
  2568. // 配置编辑信息
  2569. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2570. foreach ( $acItem as $key => $value ) {
  2571. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2572. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2573. $acItem [$key] ['price'] = $v ['price'];
  2574. }
  2575. }
  2576. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2577. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2578. $acItem [$key] ['price'] = $v ['price'];
  2579. }
  2580. }
  2581. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2582. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2583. $acItem [$key] ['price'] = $v ['price'];
  2584. }
  2585. }
  2586. //内训
  2587. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2588. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2589. $acItem [$key] ['price'] = $v ['price'];
  2590. }
  2591. }
  2592. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2593. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2594. $acItem [$key] ['price'] = $v ['price'];
  2595. }
  2596. }
  2597. }
  2598. $data ['category'] = $Lcategory->find ( array (
  2599. 'asArray' => true
  2600. ) );
  2601. $data ['ridKey'] = $ridKey;
  2602. $data ['cSum'] = $accountItemList ['cSum'];
  2603. $data ['sum'] = $receiptDetail ['sum'];
  2604. $data ['receiptDetail'] = $receiptDetail;
  2605. $data ['veList'] = $veList;
  2606. $data ['acItem'] = $acItem;
  2607. $data ['memu'] = "receipt";
  2608. $data ['staff'] = $this->staff;
  2609. $data ['receiptMemu'] = 'saeaBorad';
  2610. $data ['verify'] = $receiptDetail ['verify'];
  2611. $data ['verifyId'] = $this->verifyId;
  2612. $data ['executeId'] = $this->executeId;
  2613. $data ['rid'] = $rid;
  2614. if($receiptDetail['receiptClass']==1){
  2615. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2616. }elseif($receiptDetail['receiptClass']==2){
  2617. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2618. }elseif($receiptDetail['receiptClass']==3){
  2619. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2620. }else{
  2621. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2622. }
  2623. }
  2624. /**
  2625. * 培训班结算
  2626. */
  2627. function receiptTrainAdd() {
  2628. Doo::loadModel ( 'accountItem' );
  2629. $accountItem = new accountItem ();
  2630. $acItem = $accountItem->find ( array (
  2631. 'asArray' => true
  2632. ) );
  2633. // 审批组
  2634. Doo::loadModel ( 'verify' );
  2635. $verify = new verify ();
  2636. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2637. // 办事处
  2638. Doo::loadModel ( 'L_category' );
  2639. $lCategory = new L_category ();
  2640. $data ['category'] = $lCategory->getCategory ();
  2641. $data ['veList'] = $veList;
  2642. $data ['memu'] = "receipt";
  2643. $data ['staff'] = $this->staff;
  2644. $data ['acItem'] = $acItem;
  2645. $data ['receiptMemu'] = 'saeaBorad';
  2646. $data ['verifyId'] = $this->verifyId;
  2647. $data ['executeId'] = $this->executeId;
  2648. $this->render ( "/receipt/receiptTrainAdd", $data );
  2649. }
  2650. /**
  2651. * 添加培训班结算
  2652. */
  2653. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2654. // 培训班信息
  2655. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2656. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2657. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2658. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2659. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2660. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2661. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2662. // 发票信息
  2663. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2664. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2665. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2666. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2667. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2668. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2669. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2670. //&&! empty ( $participants )
  2671. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2672. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2673. header ( 'Content-Type:text/html;charset=utf-8' );
  2674. die ( '请填写联行号' );
  2675. }
  2676. Doo::loadModel ( 'execute' );
  2677. $execute = new execute ();
  2678. $executeDetail = $execute->getOne ( array (
  2679. 'where' => 'mold="培训班结算"',
  2680. 'asArray' => true
  2681. ) );
  2682. if (empty ( $executeDetail )) {
  2683. header ( 'Content-Type:text/html;charset=utf-8' );
  2684. die ( '未设置执行人' );
  2685. }
  2686. Doo::loadClass ( 'XDeode' );
  2687. $XDeode = new XDeode ( 5 );
  2688. $cid = $XDeode->decode ( $cid );
  2689. Doo::loadModel ( 'receipt' );
  2690. $receipt = new receipt ();
  2691. Doo::loadModel ( 'receiptTraining' );
  2692. $receiptTraining = new receiptTraining ();
  2693. // 创建费用培训班
  2694. $item = array (
  2695. 'cid' => $this->staff [0] ['cid'],
  2696. 'categoryName' => $this->staff [0] ['category'],
  2697. 'trainName' => $trainName,
  2698. 'trainStartDate' => $trainStartDate,
  2699. 'trainEndDate' => $trainEndDate,
  2700. 'participants' => $participants,
  2701. 'freeParticipants'=>$freeParticipants,
  2702. 'trainAddress' => $trainAddress,
  2703. 'trainRemarks' => $trainRemarks,
  2704. 'creator' => $this->staff [0] ['sid'],
  2705. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2706. );
  2707. $irid = $receiptTraining->addReceiptTraining ( $item );
  2708. // 报销单
  2709. $receipt->status = 5;
  2710. $receipt->trainId = $irid;
  2711. $receipt->Rtype = 3;
  2712. $receipt->staff = $this->staff [0] ['sid'];
  2713. $receipt->cid = $cid;
  2714. $receipt->verify = $verify;
  2715. $receipt->date = date ( "Y-m-d" );
  2716. $receipt->executeCopy = $executeDetail ['staff'];
  2717. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2718. $receipt->remittanceName = $remittanceName;
  2719. $receipt->bankName = $bankName;
  2720. $receipt->bankNumber = $bankNumber;
  2721. $receipt->remittanceBankType = $remittanceBankType;
  2722. if ($remittanceBankType == 1)
  2723. $receipt->coupletNumber = $coupletNumber;
  2724. $rid = $receipt->insert ();
  2725. $XDeode = new XDeode ( 7 );
  2726. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2727. } else
  2728. die ( 'illegal request' );
  2729. }
  2730. /**
  2731. * 培训班编辑
  2732. */
  2733. function receiptTrainEdi() {
  2734. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2735. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2736. Doo::loadClass ( 'XDeode' );
  2737. $XDeode = new XDeode ( 7 );
  2738. $rid = $XDeode->decode ( $ridKey );
  2739. if (! is_numeric ( $rid ))
  2740. die ( 'illegal request' );
  2741. Doo::loadModel ( 'receipt' );
  2742. $receipt = new receipt ();
  2743. Doo::loadModel ( 'receiptTraining' );
  2744. $receiptTraining = new receiptTraining ();
  2745. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2746. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2747. die ('illegal request--status');
  2748. }
  2749. //如有已入账已收款的发票,自动取消办事处已收款
  2750. // Doo::loadModel ( 'RIExtend' );
  2751. // $RIExtend = new RIExtend ();
  2752. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2753. // if (!empty($RIExtendList)){
  2754. // foreach ($RIExtendList as $key=>$value){
  2755. // $RIExtend = new RIExtend ();
  2756. // $RIExtend->delete(array (
  2757. // 'where' => 'iid=' . $value['iid'],
  2758. // 'limit' => 1
  2759. // ));
  2760. // }
  2761. // }
  2762. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2763. // 汇总表合计
  2764. // 收入合计--加入开票合计
  2765. Doo::loadModel ( 'invoiceTraining' );
  2766. $invoiceTraining = new invoiceTraining ();
  2767. $invoiceTrainingDetail = array (
  2768. 'invoiceArriveAmount' => 0,
  2769. 'RIAmount' => 0,
  2770. 'invoiceTotalAmount' => 0,
  2771. 'invoiceCompanyAmount'=>0
  2772. );
  2773. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2774. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2775. }
  2776. // print_r($invoiceTrainingDetail);
  2777. $invoiceArriveAmount = $RIAmount = 0;
  2778. if (! empty ( $invoiceTrainingDetail )) {
  2779. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2780. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2781. }
  2782. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2783. //print_r($invoiceTrainingDetail);
  2784. // 支出项目
  2785. Doo::loadModel ( 'accountItem' );
  2786. $accountItem = new accountItem ();
  2787. // 项目金额合计
  2788. Doo::loadModel ( 'RItem' );
  2789. $RItem = new RItem ();
  2790. // 讲师获得
  2791. Doo::loadModel ( 'RILecturer' );
  2792. $RILecturer = new RILecturer ();
  2793. $RItemList = $RItem->getRItemByRid ( $rid );
  2794. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2795. // 支出项金额详情
  2796. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2797. // print_r($aiData);
  2798. // 利润
  2799. $profit=$invoiceArriveAmount - $aiData ['total'];
  2800. $companyProfit=$profit * 0.6;
  2801. $categoryProfit=$profit * 0.4;
  2802. $data ['profit'] = sprintf("%.2f",$profit);
  2803. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2804. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2805. //发票利润
  2806. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2807. //发票公司利润
  2808. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2809. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2810. //办事处利润
  2811. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2812. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2813. // print_r($aiData['dataList']);
  2814. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2815. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2816. // 备用金
  2817. $sum = 0;
  2818. $data ['receiptLoanDetail'] = array (
  2819. 'sum' => '0.00'
  2820. );
  2821. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2822. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2823. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2824. $sum=0;
  2825. foreach ($receiptLoanList as $key=>$value){
  2826. $sum+=$value['sum'];
  2827. }
  2828. $data ['receiptLoanDetail'] = array (
  2829. 'sum' => $sum
  2830. );
  2831. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2832. }
  2833. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2834. $data ['payment'] = sprintf("%.2f",$payment);
  2835. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2836. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2837. $data ['aiList'] = $aiData ['dataList'];
  2838. // 占比计算
  2839. if ($invoiceArriveAmount != 0) {
  2840. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2841. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2842. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2843. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2844. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2845. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2846. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2847. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2848. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2849. } else {
  2850. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2851. }
  2852. //发票金额占比计算
  2853. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2854. //支出
  2855. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2856. //利润
  2857. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2858. //公司利润
  2859. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2860. //办事处利润
  2861. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2862. //公司收款
  2863. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2864. //备用金
  2865. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2866. //办事处收款
  2867. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2868. //办事处实际支出
  2869. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2870. //付总部款
  2871. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2872. }else{
  2873. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2874. }
  2875. //讲师人数
  2876. Doo::loadModel ( 'RILecturer' );
  2877. $RILecturer = new RILecturer ();
  2878. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2879. $data['lectureCount']=count($RILecturerList);
  2880. // 审批组
  2881. Doo::loadModel ( 'verify' );
  2882. $verify = new verify ();
  2883. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2884. // 办事处
  2885. Doo::loadModel ( 'L_category' );
  2886. $lCategory = new L_category ();
  2887. $data ['category'] = $lCategory->getCategory ();
  2888. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2889. $data ['receiptDetail'] = $receiptDetail;
  2890. $data ['veList'] = $veList;
  2891. $data ['trainEdiType'] = $trainEdiType;
  2892. $data ['ridKey'] = $ridKey;
  2893. $data ['memu'] = "receipt";
  2894. $data ['staff'] = $this->staff;
  2895. $data ['receiptMemu'] = 'saeaBorad';
  2896. $data ['verifyId'] = $this->verifyId;
  2897. $data ['executeId'] = $this->executeId;
  2898. $this->render ( "/receipt/receiptTrainEdi", $data );
  2899. }
  2900. /**
  2901. * 培训班借款编辑
  2902. */
  2903. function receiptTrainLoanEdi() {
  2904. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2905. Doo::loadClass ( 'XDeode' );
  2906. $XDeode = new XDeode ( 7 );
  2907. $rid = $XDeode->decode ( $ridKey );
  2908. if (! is_numeric ( $rid ))
  2909. die ( 'illegal request' );
  2910. Doo::loadModel ( 'receipt' );
  2911. $receipt = new receipt ();
  2912. Doo::loadModel ( 'receiptTraining' );
  2913. $receiptTraining = new receiptTraining ();
  2914. Doo::loadModel ( 'verify' );
  2915. $verify = new verify ();
  2916. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2917. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2918. die ();
  2919. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2920. // 借款详情HTML
  2921. // 获得借款信息
  2922. $receiptLoanHtml = '';
  2923. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2924. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2925. foreach ($receiptLoanList as $key=>$value){
  2926. // 获得某费用单审批信息
  2927. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2928. Doo::loadClass ( 'receipt.func' );
  2929. $extendHtml = '<p><a class="button"
  2930. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2931. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2932. }
  2933. }
  2934. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2935. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2936. $data ['receiptDetail'] = $receiptDetail;
  2937. $data ['trainEdiType'] = "LOAN";
  2938. $data ['ridKey'] = $ridKey;
  2939. $data ['memu'] = "receipt";
  2940. $data ['staff'] = $this->staff;
  2941. $data ['receiptMemu'] = 'saeaBorad';
  2942. $data ['verifyId'] = $this->verifyId;
  2943. $data ['executeId'] = $this->executeId;
  2944. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2945. }
  2946. /**
  2947. * 更新培训班结算基本信息
  2948. */
  2949. function receiptTrainInfoEdiDo() {
  2950. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2951. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2952. // 培训班信息
  2953. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2954. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2955. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2956. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2957. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2958. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2959. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2960. // 发票信息
  2961. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2962. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2963. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2964. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2965. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2966. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2967. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2968. //&& ! empty ( $participants )
  2969. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2970. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2971. header ( 'Content-Type:text/html;charset=utf-8' );
  2972. die ( '请填写联行号' );
  2973. }
  2974. Doo::loadClass ( 'XDeode' );
  2975. $XDeode = new XDeode ( 5 );
  2976. $cid = $XDeode->decode ( $cid );
  2977. $rtid = $XDeode->decode ( $rtid );
  2978. $rid = $XDeode->decode ( $rid );
  2979. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2980. die ( 'illegal request-IdError' );
  2981. }
  2982. Doo::loadModel ( 'receipt' );
  2983. $receipt = new receipt ();
  2984. Doo::loadModel ( 'receiptTraining' );
  2985. $receiptTraining = new receiptTraining ();
  2986. // 更新费用培训班
  2987. $item = array (
  2988. 'rtid' => $rtid,
  2989. 'trainName' => $trainName,
  2990. 'trainStartDate' => $trainStartDate,
  2991. 'trainEndDate' => $trainEndDate,
  2992. 'participants' => $participants,
  2993. 'freeParticipants'=>$freeParticipants,
  2994. 'trainAddress' => $trainAddress,
  2995. 'trainRemarks' => $trainRemarks
  2996. );
  2997. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2998. // 报销单
  2999. $receipt->rid = $rid;
  3000. $receipt->cid = $cid;
  3001. $receipt->verify = $verify;
  3002. $receipt->remittanceName = $remittanceName;
  3003. $receipt->bankName = $bankName;
  3004. $receipt->bankNumber = $bankNumber;
  3005. $receipt->remittanceBankType = $remittanceBankType;
  3006. if ($remittanceBankType == 1)
  3007. $receipt->coupletNumber = $coupletNumber;
  3008. $receipt->update ();
  3009. $XDeode = new XDeode ( 7 );
  3010. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3011. } else
  3012. die ( 'illegal request' );
  3013. }
  3014. /**
  3015. * 编辑培训班结算---更新借款
  3016. */
  3017. function receiptTrainLoanEdiDo() {
  3018. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3019. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3020. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3021. Doo::loadModel ( 'receipt' );
  3022. $receipt = new receipt ();
  3023. Doo::loadClass ( 'XDeode' );
  3024. $XDeode = new XDeode ( 5 );
  3025. $rid = $XDeode->decode ( $ridKey );
  3026. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3027. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3028. die ( 'illegal request-ridError' );
  3029. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3030. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3031. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3032. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3033. die ( 'illegal request-receiptError' );
  3034. }
  3035. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3036. die ( 'illegal request-receipLoantError' );
  3037. }
  3038. // 培训班结算挂钩借款
  3039. $receipt = new receipt ();
  3040. $trainLoanRid=$ridLoan;
  3041. if (!empty($receiptDetail['trainLoanRid'])){
  3042. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3043. }
  3044. $item = array (
  3045. 'rid' => $rid,
  3046. 'trainLoanRid' => $trainLoanRid
  3047. );
  3048. $receipt->setReceiptByCondition ( $item );
  3049. // 更新借款状态变成已挂钩
  3050. $receipt = new receipt ();
  3051. $item = array (
  3052. 'rid' => $ridLoan,
  3053. 'status' => 10,
  3054. 'statusTrain' => 1
  3055. );
  3056. $receipt->setReceiptByCondition ( $item );
  3057. $XDeode = new XDeode ( 7 );
  3058. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3059. } else
  3060. die ( 'illegal request' );
  3061. }
  3062. /**
  3063. * 编辑培训班结算--移除借款
  3064. */
  3065. function receiptTrainLoanRemoveDo() {
  3066. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3067. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3068. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3069. Doo::loadModel ( 'receipt' );
  3070. $receipt = new receipt ();
  3071. Doo::loadClass ( 'XDeode' );
  3072. $XDeode = new XDeode ( 5 );
  3073. $rid = $XDeode->decode ( $ridKey );
  3074. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3075. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3076. die ( 'illegal request-ridError' );
  3077. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3078. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3079. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3080. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3081. die ( 'illegal request-receiptError' );
  3082. }
  3083. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3084. die ( 'illegal request-receipLoantError' );
  3085. }
  3086. // 培训班结算挂钩借款
  3087. $receipt = new receipt ();
  3088. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3089. foreach ($trainLoanRidArray as $key=>$value){
  3090. if($value==$ridLoan){
  3091. unset($trainLoanRidArray[$key]);
  3092. }
  3093. }
  3094. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3095. $item = array (
  3096. 'rid' => $rid,
  3097. 'trainLoanRid' => $trainLoanRidString
  3098. );
  3099. $receipt->setReceiptByCondition ( $item );
  3100. // 更新借款状态变成已挂钩
  3101. $receipt = new receipt ();
  3102. $item = array (
  3103. 'rid' => $ridLoan,
  3104. 'status' => 8,
  3105. 'statusTrain' => 0
  3106. );
  3107. $receipt->setReceiptByCondition ( $item );
  3108. $XDeode = new XDeode ( 7 );
  3109. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3110. } else
  3111. die ( 'illegal request' );
  3112. }
  3113. /**
  3114. * 编辑培训班结算 ---开票
  3115. */
  3116. function receiptTrainInvoiceEdi() {
  3117. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3118. Doo::loadClass ( 'XDeode' );
  3119. $XDeode = new XDeode ( 7 );
  3120. $rid = $XDeode->decode ( $ridKey );
  3121. if (! is_numeric ( $rid ))
  3122. die ( 'illegal request' );
  3123. Doo::loadModel ( 'receipt' );
  3124. $receipt = new receipt ();
  3125. Doo::loadModel ( 'receiptTraining' );
  3126. $receiptTraining = new receiptTraining ();
  3127. Doo::loadModel ( 'invoice' );
  3128. $invoice = new invoice ();
  3129. Doo::loadModel ( 'invoiceTraining' );
  3130. $invoiceTraining = new invoiceTraining ();
  3131. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3132. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3133. die ();
  3134. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3135. $invoiceList = $invoiceTrainingDetail = array ();
  3136. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3137. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3138. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3139. }
  3140. //print_r($invoiceList);
  3141. $data ['invoiceList'] = $invoiceList;
  3142. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3143. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3144. $data ['receiptDetail'] = $receiptDetail;
  3145. $data ['trainEdiType'] = "INVOICE";
  3146. $data ['ridKey'] = $ridKey;
  3147. $data ['memu'] = "receipt";
  3148. $data ['staff'] = $this->staff;
  3149. $data ['receiptMemu'] = 'saeaBorad';
  3150. $data ['verifyId'] = $this->verifyId;
  3151. $data ['executeId'] = $this->executeId;
  3152. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3153. }
  3154. /**
  3155. * 编辑培训班结算---更新开票
  3156. */
  3157. function receiptTrainInvoiceEdiDo() {
  3158. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3159. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3160. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3161. Doo::loadModel ( 'receipt' );
  3162. $receipt = new receipt ();
  3163. Doo::loadModel ( 'invoiceTraining' );
  3164. $invoiceTraining = new invoiceTraining ();
  3165. Doo::loadClass ( 'XDeode' );
  3166. $XDeode = new XDeode ( 5 );
  3167. $rid = $XDeode->decode ( $ridKey );
  3168. $itid = $XDeode->decode ( $itidKey );
  3169. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3170. die ( 'illegal request-idError' );
  3171. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3172. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3173. // 不合法的数据
  3174. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3175. die ( 'illegal request-receiptError' );
  3176. }
  3177. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3178. die ( 'illegal request-receipLoantError' );
  3179. }
  3180. // 培训班结算挂钩借款
  3181. $receipt = new receipt ();
  3182. $item = array (
  3183. 'rid' => $rid,
  3184. 'invoiceTrainId' => $itid
  3185. );
  3186. $receipt->setReceiptByCondition ( $item );
  3187. $invoiceTraining = new invoiceTraining ();
  3188. $item = array (
  3189. 'bindReceipt' => 1,
  3190. 'itid' => $itid
  3191. );
  3192. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3193. $XDeode = new XDeode ( 7 );
  3194. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3195. } else
  3196. die ( 'illegal request' );
  3197. }
  3198. /**
  3199. * 更新培训班结算 收款和取消收款
  3200. */
  3201. function receiptTrainReceivables() {
  3202. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3203. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3204. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3205. Doo::loadClass ( 'XDeode' );
  3206. $XDeode = new XDeode ( 5 );
  3207. $rid = $XDeode->decode ( $ridKey );
  3208. $iid = $XDeode->decode ( $iidKey );
  3209. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3210. die ( 'illegal request-iid' );
  3211. Doo::loadModel ( 'RIExtend' );
  3212. $RIExtend = new RIExtend ();
  3213. if ($doType == 'CONFIRM') {
  3214. $RIExtend->rid = $rid;
  3215. $RIExtend->iid = $iid;
  3216. $RIExtend->RIstatus = 1;
  3217. $RIExtend->insert ();
  3218. echo json_encode ( array (
  3219. 'status' => 1,
  3220. ) );
  3221. die ( );
  3222. } elseif ($doType == 'CANCEL') {
  3223. $RIExtend->delete ( array (
  3224. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3225. 'limit' => 1
  3226. ) );
  3227. echo json_encode ( array (
  3228. 'status' => 1,
  3229. ) );
  3230. die ( );
  3231. } else {
  3232. echo json_encode ( array (
  3233. 'status' => 2,
  3234. ) );
  3235. die ( );
  3236. }
  3237. }
  3238. /**
  3239. * 移除挂钩的培训班发票
  3240. */
  3241. function receiptTrainReceivablesDelDo() {
  3242. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3243. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3244. Doo::loadModel ( 'receipt' );
  3245. $receipt = new receipt ();
  3246. Doo::loadModel ( 'RIExtend' );
  3247. $RIExtend = new RIExtend ();
  3248. Doo::loadClass ( 'XDeode' );
  3249. $XDeode = new XDeode ( 5 );
  3250. $rid = $XDeode->decode ( $ridKey );
  3251. $itid = $XDeode->decode ( $itidKey );
  3252. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3253. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3254. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3255. die ( 'illegal request-status' );
  3256. }
  3257. $receipt = new receipt ();
  3258. $receipt->rid = $rid;
  3259. $receipt->invoiceTrainId = 0;
  3260. $receipt->update ();
  3261. Doo::loadModel ( 'invoiceTraining' );
  3262. $invoiceTraining = new invoiceTraining ();
  3263. $item = array (
  3264. 'bindReceipt' => 0,
  3265. 'itid' => $itid
  3266. );
  3267. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3268. $RIExtend->delete ( array (
  3269. 'where' => 'rid=' . $rid
  3270. ) );
  3271. $XDeode = new XDeode ( 7 );
  3272. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3273. } else
  3274. die ( 'illegal request-iid' );
  3275. }
  3276. /**
  3277. * 编辑培训班结算
  3278. */
  3279. function receiptTrainItemEdi() {
  3280. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3281. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3282. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3283. Doo::loadClass ( 'XDeode' );
  3284. $XDeode = new XDeode ( 7 );
  3285. $rid = $XDeode->decode ( $ridKey );
  3286. if (! is_numeric ( $rid ))
  3287. die ( 'illegal request' );
  3288. Doo::loadModel ( 'receipt' );
  3289. $receipt = new receipt ();
  3290. Doo::loadModel ( 'receiptTraining' );
  3291. $receiptTraining = new receiptTraining ();
  3292. Doo::loadModel ( 'RItem' );
  3293. $RItem = new RItem ();
  3294. Doo::loadModel ( 'accountItem' );
  3295. $accountItem = new accountItem ();
  3296. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3297. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3298. die ();
  3299. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3300. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3301. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3302. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3303. // if($value['name']=='税款'){
  3304. // unset($aiList[$key]);break;
  3305. // }
  3306. // }
  3307. //print_r($RItemList);
  3308. $data ['name'] = $name;
  3309. $data ['RItemList'] = $RItemList;
  3310. $data ['aiList'] = $aiList;
  3311. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3312. $data ['receiptDetail'] = $receiptDetail;
  3313. $data ['trainEdiType'] = "ITEM";
  3314. $data ['ridKey'] = $ridKey;
  3315. $data ['memu'] = "receipt";
  3316. $data ['staff'] = $this->staff;
  3317. $data ['receiptMemu'] = 'saeaBorad';
  3318. $data ['verifyId'] = $this->verifyId;
  3319. $data ['executeId'] = $this->executeId;
  3320. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3321. }
  3322. /**
  3323. * 添加支出项 需要修改 费用金额合计
  3324. */
  3325. function receiptTrainItemAddDo() {
  3326. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3327. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3328. // 支出项信息
  3329. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3330. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3331. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3332. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3333. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3334. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3335. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3336. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3337. Doo::loadClass ( 'XDeode' );
  3338. $XDeode = new XDeode ( 5 );
  3339. Doo::loadModel ( 'RItem' );
  3340. $RItem = new RItem ();
  3341. $rid = $XDeode->decode ( $ridKey );
  3342. $rtid= $XDeode->decode ( $rtidKey );
  3343. if (! is_numeric ( $rid )){
  3344. die ( 'illegal request' );
  3345. }
  3346. Doo::loadModel ( 'receiptDetail' );
  3347. $receiptDetail = new receiptDetail ();
  3348. Doo::loadModel ( 'receipt' );
  3349. $receipt = new receipt ();
  3350. Doo::loadModel ( 'receiptTraining' );
  3351. $receiptTraining = new receiptTraining ();
  3352. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3353. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3354. $order = array (
  3355. "\r\n",
  3356. "\n",
  3357. "\r"
  3358. );
  3359. $replace = '<br/>';
  3360. $describe = str_replace ( $order, $replace, $describe );
  3361. $itemData = array (
  3362. 'rid' => $rid,
  3363. 'item' => $item,
  3364. 'price' => $price,
  3365. 'date' => $date,
  3366. 'inputer' => $inputer,
  3367. 'describe' => $describe,
  3368. 'creater' => $this->staff['0']['username'],
  3369. 'createrId' => $this->staff['0']['sid'],
  3370. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3371. 'identifying'=>$identifyingTotal
  3372. );
  3373. if($payType=='company'){
  3374. $itemData += array (
  3375. 'payType' => 1
  3376. );
  3377. }
  3378. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3379. //更新支出项标识总数
  3380. $itemData = array (
  3381. 'rtid'=>$rtid,
  3382. 'identifyingTotal'=>$identifyingTotal
  3383. );
  3384. $receiptTraining->setReceiptTrainByCondition($itemData);
  3385. $XDeode = new XDeode ( 7 );
  3386. if($payType=='company'){
  3387. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3388. }else{
  3389. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3390. }
  3391. } else
  3392. die ( 'illegal request-dataError' );
  3393. }
  3394. /**
  3395. * 培训班结算-讲师
  3396. */
  3397. function receiptTrainLecturerEdi() {
  3398. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3399. Doo::loadClass ( 'XDeode' );
  3400. $XDeode = new XDeode ( 7 );
  3401. $rid = $XDeode->decode ( $ridKey );
  3402. if (! is_numeric ( $rid ))
  3403. die ( 'illegal request' );
  3404. Doo::loadModel ( 'receipt' );
  3405. $receipt = new receipt ();
  3406. Doo::loadModel ( 'receiptTraining' );
  3407. $receiptTraining = new receiptTraining ();
  3408. Doo::loadModel ( 'RILecturer' );
  3409. $RILecturer = new RILecturer ();
  3410. Doo::loadModel ( 'lecturer' );
  3411. $lecturer = new lecturer ();
  3412. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3413. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3414. die ();
  3415. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3416. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3417. $lecturerList = $lecturer->getLecturerAll ();
  3418. $INSIDEhtml = $OUTSIDEhtml = '';
  3419. foreach ( $lecturerList as $key => $value ) {
  3420. if ($value ['ltype'] == 'INSIDE') {
  3421. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3422. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3423. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3424. }
  3425. }
  3426. $data ['INSIDEhtml'] = $INSIDEhtml;
  3427. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3428. // print_r($RItemList);
  3429. $data ['RILecturerList'] = $RILecturerList;
  3430. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3431. $data ['receiptDetail'] = $receiptDetail;
  3432. $data ['trainEdiType'] = "LECTURER";
  3433. $data ['ridKey'] = $ridKey;
  3434. $data ['memu'] = "receipt";
  3435. $data ['staff'] = $this->staff;
  3436. $data ['receiptMemu'] = 'saeaBorad';
  3437. $data ['verifyId'] = $this->verifyId;
  3438. $data ['executeId'] = $this->executeId;
  3439. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3440. }
  3441. /**
  3442. * 添加讲师
  3443. */
  3444. function receiptTrainLecturerAddDo() {
  3445. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3446. // 支出项信息
  3447. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3448. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3449. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3450. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3451. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3452. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3453. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3454. Doo::loadClass ( 'XDeode' );
  3455. $XDeode = new XDeode ( 5 );
  3456. Doo::loadModel ( 'RILecturer' );
  3457. $RILecturer = new RILecturer ();
  3458. $rid = $XDeode->decode ( $ridKey );
  3459. if (! is_numeric ( $rid ))
  3460. die ( 'illegal request' );
  3461. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3462. die ( 'illegal request-taxationError' );
  3463. $RILecturer->rid = $rid;
  3464. $RILecturer->ltype = $ltype;
  3465. if ($ltype == 'OUTSIDE') {
  3466. if ($taxation == 'TAXATION') {
  3467. $RILecturer->taxation = 1;
  3468. } elseif ($taxation == 'NOTAXATION') {
  3469. $RILecturer->taxation = 0;
  3470. }
  3471. }
  3472. $RILecturer->lecturerName = $lecturerName;
  3473. $RILecturer->schoolDay = $schoolDay;
  3474. $RILecturer->price = $price;
  3475. $RILecturer->fees=$fees;
  3476. $RILecturer->insert ();
  3477. // 添加公司汇总
  3478. // 报销详情
  3479. Doo::loadModel ( 'receiptDetail' );
  3480. $receiptDetail = new receiptDetail ();
  3481. Doo::loadModel ( 'receipt' );
  3482. $receipt = new receipt ();
  3483. // 金额总计
  3484. $price = $price * $schoolDay;
  3485. $rInfo = $receipt->getReceiptByRid ( $rid );
  3486. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3487. if (empty ( $rdInfo )) {
  3488. $receiptDetail = new receiptDetail ();
  3489. $receiptDetail->staff = $rInfo ['staff'];
  3490. $receiptDetail->item = '讲课费';
  3491. $receiptDetail->itemCategory = '培训班费用';
  3492. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3493. $receiptDetail->date = date ( "Y-m-d" );
  3494. $receiptDetail->cid = $rInfo ['cid'];
  3495. $receiptDetail->rid = $rid;
  3496. $receiptDetail->status = 4;
  3497. $receiptDetail->insert ();
  3498. } else {
  3499. $receiptDetail = new receiptDetail ();
  3500. $rdInfo ['price'] += $fees;
  3501. $receiptDetail->price = $rdInfo ['price'];
  3502. $receiptDetail->update ( array (
  3503. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3504. ) );
  3505. }
  3506. $receipt = new receipt ();
  3507. $receipt->sum=$rInfo['sum']+$fees;
  3508. $receipt->update ( array (
  3509. 'where' => 'rid=' . $rid
  3510. ) );
  3511. $XDeode = new XDeode ( 7 );
  3512. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3513. } else
  3514. die ( 'illegal request' );
  3515. }
  3516. /**
  3517. * 移除讲师
  3518. */
  3519. function receiptTrainLecturerDelDo() {
  3520. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3521. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3522. Doo::loadModel ( 'receipt' );
  3523. $receipt = new receipt ();
  3524. Doo::loadModel ( 'RILecturer' );
  3525. $RILecturer = new RILecturer ();
  3526. Doo::loadClass ( 'XDeode' );
  3527. $XDeode = new XDeode ( 5 );
  3528. $rid = $XDeode->decode ( $ridKey );
  3529. $rlid = $XDeode->decode ( $rlidKey );
  3530. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3531. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3532. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3533. die ( 'illegal request-status' );
  3534. }
  3535. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3536. if (empty($detail)){
  3537. die ( 'illegal request-data' );
  3538. }
  3539. $RILecturer->delete ( array (
  3540. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3541. ) );
  3542. //更新费用合计金额
  3543. $rInfo = $receipt->getReceiptByRid ( $rid );
  3544. $receipt = new receipt ();
  3545. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3546. $receipt->update ( array (
  3547. 'where' => 'rid=' . $rid
  3548. ) );
  3549. Doo::loadModel ( 'receiptDetail' );
  3550. $receiptDetail = new receiptDetail ();
  3551. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3552. $receiptDetail = new receiptDetail ();
  3553. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3554. $receiptDetail->price = $rdInfo ['price'];
  3555. $receiptDetail->update ( array (
  3556. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3557. ) );
  3558. $XDeode = new XDeode ( 7 );
  3559. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3560. } else
  3561. die ( 'illegal request-iid' );
  3562. }
  3563. /**
  3564. * 培训班提交审批
  3565. */
  3566. function receiptTrainDo() {
  3567. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3568. Doo::loadClass ( 'XDeode' );
  3569. $XDeode = new XDeode ( 7 );
  3570. $rid = $XDeode->decode ( $ridKey );
  3571. Doo::loadModel ( 'receipt' );
  3572. $receipt = new receipt ();
  3573. Doo::loadModel ( 'receiptDetail' );
  3574. $receiptDetail = new receiptDetail ();
  3575. Doo::loadModel ( 'statistics' );
  3576. $statistics = new statistics ();
  3577. Doo::loadModel ( "verify" );
  3578. $verify = new verify ();
  3579. // 审批状态的判定
  3580. $receiptDetailList = $receipt->getOne ( array (
  3581. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3582. 'asArray' => true
  3583. ) );
  3584. if (empty ( $receiptDetailList ))
  3585. return "/saeaBorad";
  3586. $verifyDetail = $verify->getOne ( array (
  3587. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3588. 'asArray' => true
  3589. ) );
  3590. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3591. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3592. $nowStaff = "";
  3593. $nowStaffList = array ();
  3594. if ($verifyDetail [0] [1] == 'ROLE') {
  3595. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3596. foreach ( $vStaffString as $key => $value ) {
  3597. $staffK = explode ( "_", $value );
  3598. array_push ( $nowStaffList, $staffK [0] );
  3599. }
  3600. $nowStaff = implode ( ',', $nowStaffList );
  3601. } else {
  3602. $nowStaff = $verifyDetail [0] [0];
  3603. }
  3604. $receipt->nowStaff = $nowStaff;
  3605. }
  3606. // echo $nowStaff;
  3607. // print_r($verifyDetail);die;
  3608. $receipt->rid = $receiptDetailList ['rid'];
  3609. $receipt->date = date ( "Y-m-d" );
  3610. $receipt->status = 2;
  3611. $receipt->update ();
  3612. $receiptDetail->status = 2;
  3613. $receiptDetail->update ( array (
  3614. 'where' => 'rid=' . $receiptDetailList ['rid']
  3615. ) );
  3616. Doo::loadModel ( "receiptLog" );
  3617. $receiptLog = new receiptLog ();
  3618. Doo::loadModel ( "verify" );
  3619. $verify = new verify ();
  3620. $vr = $verify->getOne ( array (
  3621. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3622. 'asArray' => true
  3623. ) );
  3624. $jd = json_decode ( $vr ['staff'] );
  3625. $roleId = 0;
  3626. foreach ( $jd as $key => $value ) {
  3627. if ($value [1] == 'ROLE') {
  3628. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3629. if ($pos !== false) {
  3630. $roleId = $value [0];
  3631. }
  3632. }
  3633. }
  3634. // 审批日志
  3635. // echo $roleId;die;
  3636. if (! empty ( $roleId )) {
  3637. Doo::loadModel ( "role" );
  3638. $role = new role ();
  3639. $roleInfo = $role->getOne ( array (
  3640. 'where' => 'rid=' . $roleId,
  3641. 'asArray' => true
  3642. ) );
  3643. // $receiptLog->rolename = $roleInfo ['name'];
  3644. }
  3645. $receiptLog->username = $this->staff [0] ['username'];
  3646. $receiptLog->uid = $this->staff [0] ['sid'];
  3647. $receiptLog->date = date ( "Y-m-d" );
  3648. $receiptLog->opinion = '提交审批';
  3649. $receiptLog->img = $this->staff [0] ['avatar'];
  3650. $receiptLog->status = 2;
  3651. $receiptLog->rid = $rid;
  3652. $receiptLog->insert ();
  3653. // 写入列表项
  3654. Doo::loadModel ( 'accountItem' );
  3655. $accountItem = new accountItem ();
  3656. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3657. // 项目金额合计
  3658. Doo::loadModel ( 'RItem' );
  3659. $RItem = new RItem ();
  3660. // 讲师获得
  3661. Doo::loadModel ( 'RILecturer' );
  3662. $RILecturer = new RILecturer ();
  3663. $RItemList = $RItem->getRItemByRid ( $rid );
  3664. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3665. // 支出项金额详情
  3666. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3667. // print_r($aItem);
  3668. // print_r($aiData);
  3669. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3670. $ag = $tr = $ta = $ot = 0;
  3671. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3672. foreach ( $aItem as $key => $value ) {
  3673. if ($value ['category'] == $this->TRAIN) {
  3674. foreach ( $aiData ['dataList'] as $k => $v ) {
  3675. if ($value ['name'] == $v ['name']) {
  3676. array_push ( $accountJson [$this->TRAIN], array (
  3677. 'aid' => $value ['aid'],
  3678. 'name' => $value ['name'],
  3679. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3680. ) );
  3681. $sum += $v ['price'];
  3682. $trainSum += $v ['price'];
  3683. unset ( $aiData ['dataList'] [$k] );
  3684. break;
  3685. }
  3686. }
  3687. }
  3688. }
  3689. $accountJson ['cSum'] = array (
  3690. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3691. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3692. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3693. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3694. );
  3695. // 报销单
  3696. $receipt = new receipt ();
  3697. $receipt->accountItem = json_encode ( $accountJson );
  3698. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3699. $receipt->update ( array (
  3700. 'where' => 'rid=' . $rid
  3701. ) );
  3702. // print_r($accountJson);
  3703. // statistics item 统计写入
  3704. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3705. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3706. $accountItem = $accountJson;
  3707. $stat = $statistics->getOne ( array (
  3708. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3709. 'asArray' => true
  3710. ) );
  3711. if (empty ( $stat )) {
  3712. $statistics->date = date ( "Y-m-d" );
  3713. $statistics->cid = $this->staff [0] ['cid'];
  3714. $statistics->staff = $this->staff [0] ['sid'];
  3715. $statistics->agPrice = 0;
  3716. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3717. $statistics->insert ();
  3718. } else {
  3719. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3720. $statistics->update ( array (
  3721. 'where' => 'sid=' . $stat ['sid']
  3722. ) );
  3723. }
  3724. return "/saeaBorad";
  3725. }
  3726. function confirmation() {
  3727. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3728. Doo::loadModel ( 'receipt' );
  3729. Doo::loadModel ( 'receiptDetail' );
  3730. $receipt = new receipt ();
  3731. $receiptDetail = new receiptDetail ();
  3732. Doo::loadModel ( 'statistics' );
  3733. Doo::loadModel ( 'itemStatistics' );
  3734. $statistics = new statistics ();
  3735. $itemStatistics = new itemStatistics ();
  3736. Doo::loadModel ( "verify" );
  3737. $verify = new verify ();
  3738. $receiptDetailList = $receipt->getOne ( array (
  3739. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3740. 'asArray' => true
  3741. ) );
  3742. if (empty ( $receiptDetailList ))
  3743. return "/saeaBorad";
  3744. $verifyDetail = $verify->getOne ( array (
  3745. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3746. 'asArray' => true
  3747. ) );
  3748. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3749. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3750. $nowStaff = "";
  3751. $nowStaffList = array ();
  3752. if ($verifyDetail [0] [1] == 'ROLE') {
  3753. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3754. foreach ( $vStaffString as $key => $value ) {
  3755. $staffK = explode ( "_", $value );
  3756. array_push ( $nowStaffList, $staffK [0] );
  3757. }
  3758. $nowStaff = implode ( ',', $nowStaffList );
  3759. } else {
  3760. $nowStaff = $verifyDetail [0] [0];
  3761. }
  3762. $receipt->nowStaff = $nowStaff;
  3763. }
  3764. // echo $nowStaff;
  3765. // print_r($verifyDetail);die;
  3766. $receipt->rid = $receiptDetailList ['rid'];
  3767. $receipt->status = 2;
  3768. $receipt->update ();
  3769. // 操作日志
  3770. Doo::loadModel ( "receiptLog" );
  3771. $receiptLog = new receiptLog ();
  3772. $verify = new verify ();
  3773. $receiptInfo = $receipt->getOne ( array (
  3774. 'where' => 'rid=' . $rid,
  3775. 'asArray' => true
  3776. ) );
  3777. $vr = $verify->getOne ( array (
  3778. 'where' => 'vid=' . $receiptInfo ['verify'],
  3779. 'asArray' => true
  3780. ) );
  3781. $jd = json_decode ( $vr ['staff'] );
  3782. $roleId = 0;
  3783. foreach ( $jd as $key => $value ) {
  3784. if ($value [1] == 'ROLE') {
  3785. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3786. if ($pos !== false) {
  3787. $roleId = $value [0];
  3788. }
  3789. }
  3790. }
  3791. // 审批日志
  3792. // echo $roleId;die;
  3793. if (! empty ( $roleId )) {
  3794. Doo::loadModel ( "role" );
  3795. $role = new role ();
  3796. $roleInfo = $role->getOne ( array (
  3797. 'where' => 'rid=' . $roleId,
  3798. 'asArray' => true
  3799. ) );
  3800. // $receiptLog->rolename = $roleInfo ['name'];
  3801. }
  3802. $receiptLog->username = $this->staff [0] ['username'];
  3803. $receiptLog->uid = $this->staff [0] ['sid'];
  3804. $receiptLog->date = date ( "Y-m-d" );
  3805. $receiptLog->opinion = '提交审批';
  3806. $receiptLog->img = $this->staff [0] ['avatar'];
  3807. $receiptLog->status = 2;
  3808. $receiptLog->rid = $rid;
  3809. $receiptLog->insert ();
  3810. return "/expenses";
  3811. }
  3812. function expenses() {
  3813. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3814. if (empty ( $item ))
  3815. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3816. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3817. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3818. Doo::loadClass ( 'XDeode' );
  3819. $XDeode = new XDeode ( 7 );
  3820. Doo::loadModel ( 'receipt' );
  3821. $receipt = new receipt ();
  3822. Doo::loadModel ( 'L_category' );
  3823. $Lcategory = new L_category ();
  3824. Doo::loadModel ( 'verify' );
  3825. Doo::loadModel ( 'statistics' );
  3826. $statistics = new statistics ();
  3827. $verify = new verify ();
  3828. Doo::loadModel ( 'staff' );
  3829. $staff = new staff ();
  3830. $condition = "";
  3831. if ($item == "expenses")
  3832. $condition = " and Rtype=1 ";
  3833. elseif ($item == "receipts")
  3834. $condition = " and Rtype=0 ";
  3835. elseif ($item == "remits")
  3836. $condition = " and Rtype=2 ";
  3837. elseif ($item == "train")
  3838. $condition = " and Rtype=3 ";
  3839. $dateCondition = " and Year(date) =" . $year;
  3840. if (! empty ( $moth )) {
  3841. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3842. $stList = $statistics->getOne ( array (
  3843. 'select' => 'rePrice ,agPrice',
  3844. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3845. 'asArray' => true
  3846. ) );
  3847. } else
  3848. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3849. if (empty ( $stList ))
  3850. $stList = array (
  3851. 'rePrice' => 0,
  3852. 'agPrice' => 0
  3853. );
  3854. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3855. if (! isset ( $noPassSum ['sum'] ))
  3856. $noPassSum ['sum'] = 0;
  3857. $data ['stList'] = array (
  3858. 'rePrice' => $stList ['rePrice'],
  3859. 'agPrice' => $stList ['agPrice'],
  3860. 'skPrice' => ($noPassSum ['sum'])
  3861. );
  3862. $receiptList = $receipt->find ( array (
  3863. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3864. 'desc' => 'rid',
  3865. 'asArray' => true
  3866. ) );
  3867. $Locate = 0;
  3868. $roleId = 0;
  3869. $button = 0;
  3870. foreach ( $receiptList as $key => $value ) {
  3871. $receiptList[$key]['balance']='';
  3872. if($value['Rtype']==1){
  3873. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3874. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3875. }elseif($value['Rtype']==3){
  3876. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3877. $receiptList[$key]['payment']=$payment;
  3878. $receiptList[$key]['paymentABS']=abs($payment);
  3879. }
  3880. $receiptList [$key] ['Locate'] = $Locate;
  3881. $Locate ++;
  3882. $receiptList [$key] ['reviseDetail'] = array ();
  3883. if (! empty ( $value ['reviseDetail'] ))
  3884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3886. $categoryDetil = $Lcategory->getOne ( array (
  3887. 'where' => 'cid=' . $value ['cid'],
  3888. 'asArray' => true
  3889. ) );
  3890. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3891. // 检测编辑状态
  3892. $verifyList = $verify->getOne ( array (
  3893. 'where' => 'vid=' . $value ['verify'],
  3894. 'asArray' => true
  3895. ) );
  3896. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3897. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3898. Doo::loadModel ( 'role' );
  3899. $role = new role ();
  3900. $flag = true;
  3901. $roleKey = 0;
  3902. $endStaffArray = array ();
  3903. $roleArrayCopy = array ();
  3904. foreach ( $verifyList as $k => $v ) {
  3905. // init verifyStaff
  3906. if ($v [1] == 'ROLE') {
  3907. if (! empty ( $verifyStaff )) {
  3908. $endStaffArray = end ( $verifyStaff );
  3909. // if ($v[0]==$endStaffArray['nextStaff']){
  3910. // $roleId=$v[0];
  3911. // }
  3912. }
  3913. $roleVerify = json_decode ( $v [3], true );
  3914. $roleKey = $k;
  3915. $roleArray = array ();
  3916. $rolename = $role->getOne ( array (
  3917. 'where' => 'rid=' . $v [0],
  3918. 'asArray' => true
  3919. ) );
  3920. foreach ( $roleVerify as $o => $p ) {
  3921. $staffID = explode ( '_', $p );
  3922. $staffInfo = $staff->getOne ( array (
  3923. 'where' => 'sid=' . $staffID [0],
  3924. 'asArray' => true
  3925. ) );
  3926. // print_r($staffID);
  3927. $exp = array (
  3928. 0 => $staffInfo ['sid'],
  3929. 1 => $staffID [1],
  3930. 2 => $staffInfo ['avatar'],
  3931. 'date' => '',
  3932. 'date' => '',
  3933. 'opinion' => '',
  3934. 'status' => '',
  3935. 'rolename' => $rolename ['name']
  3936. );
  3937. array_push ( $roleArray, $exp );
  3938. }
  3939. $roleArrayCopy [$v [0]] = $roleArray;
  3940. // $verifyList[$k]['roleArray']=$roleArray;
  3941. }
  3942. $verifyList [$k] ['date'] = "";
  3943. $verifyList [$k] ['opinion'] = "";
  3944. $verifyList [$k] ['status'] = "";
  3945. if (empty ( $verifyStaff )) {
  3946. $verifyList [$k] ['date'] = "";
  3947. $verifyList [$k] ['opinion'] = "";
  3948. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3949. $verifyList [$k] ['status'] = 4;
  3950. $flag = false;
  3951. }
  3952. } else {
  3953. foreach ( $verifyStaff as $m => $u ) {
  3954. if ($v [0] == $m) {
  3955. $verifyList [$k] ['date'] = $u ['date'];
  3956. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3957. $verifyList [$k] ['status'] = $u ['status'];
  3958. $flag = false;
  3959. break;
  3960. }
  3961. }
  3962. $endStaffArray = end ( $verifyStaff );
  3963. if (isset ( $endStaffArray ['ROLE'] )) {
  3964. } else {
  3965. // $endKey=key($verifyStaff);
  3966. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3967. // $button=4;
  3968. // $verifyList[$k]['status']=4;
  3969. // }
  3970. }
  3971. }
  3972. }
  3973. $rolename ['name'] = '';
  3974. if (! empty ( $roleId )) {
  3975. Doo::loadModel ( 'role' );
  3976. $role = new role ();
  3977. $rolename = $role->getOne ( array (
  3978. 'where' => 'rid=' . $roleId,
  3979. 'asArray' => true
  3980. ) );
  3981. }
  3982. if (! empty ( $verifyStaff ))
  3983. $endStaffArray = end ( $verifyStaff );
  3984. $KOP = false;
  3985. foreach ( $roleArrayCopy as $P => $A ) {
  3986. foreach ( $A as $MKI => $AVL ) {
  3987. if (! empty ( $verifyStaff )) {
  3988. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3989. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3990. $button = 4;
  3991. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3992. }
  3993. foreach ( $verifyStaff as $m => $u ) {
  3994. $AVLFK = $AVL [0] . '_R';
  3995. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3996. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3997. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3998. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3999. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4000. break;
  4001. }
  4002. }
  4003. } else {
  4004. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4005. $button = 4;
  4006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4007. }
  4008. }
  4009. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4010. $KOP = true;
  4011. }
  4012. }
  4013. foreach ( $roleArrayCopy as $k => $v ) {
  4014. foreach ( $verifyList as $m => $n ) {
  4015. if ($n [0] == $k) {
  4016. array_splice ( $verifyList, $m, 1, $v );
  4017. }
  4018. }
  4019. }
  4020. $receiptList [$key] ['verifyList'] = $verifyList;
  4021. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4022. 'where' => 'sid=' . $value ['staff'],
  4023. 'asArray' => true
  4024. ) );
  4025. $receiptList [$key] ['button'] = $button;
  4026. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4027. }
  4028. // print_r($receiptList);die;
  4029. $mothHtml = "";
  4030. for($i = 1; $i <= 12; $i ++) {
  4031. if ($moth == $i)
  4032. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4033. else
  4034. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4035. }
  4036. $dateHtml = "";
  4037. $now = date ( "Y" );
  4038. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4039. if ($YEARD <= $now) {
  4040. $dateHtml .= '<option ';
  4041. if ($year == $YEARD) {
  4042. $dateHtml .= 'selected ';
  4043. }
  4044. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4045. }
  4046. }
  4047. $data ['dateHtml'] = $dateHtml;
  4048. $data ['mothHtml'] = $mothHtml;
  4049. $data ['receiptList'] = $receiptList;
  4050. $data ['memu'] = "receipt";
  4051. $data ['staff'] = $this->staff;
  4052. $data ['receiptMemu'] = 'expenses';
  4053. $data ['verifyId'] = $this->verifyId;
  4054. $data ['executeId'] = $this->executeId;
  4055. $data ['item'] = $item;
  4056. $data ['year'] = $year;
  4057. $this->render ( "/admin/expenses", $data );
  4058. }
  4059. function expensesCollect() {
  4060. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4061. Doo::loadModel ( 'receipt' );
  4062. $receipt = new receipt ();
  4063. Doo::loadModel ( 'L_category' );
  4064. $Lcategory = new L_category ();
  4065. Doo::loadModel ( 'verify' );
  4066. Doo::loadModel ( 'statistics' );
  4067. $statistics = new statistics ();
  4068. $verify = new verify ();
  4069. Doo::loadModel ( 'staff' );
  4070. $staff = new staff ();
  4071. Doo::loadModel ( 'loanReceipt' );
  4072. $loanReceipt = new loanReceipt ();
  4073. $receiptList = $receipt->find ( array (//去掉
  4074. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4075. 'desc' => 'rid',
  4076. 'asArray' => true
  4077. ) );
  4078. $loanList = $loanReceipt->find ( array (
  4079. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4080. 'desc' => 'rid',
  4081. 'asArray' => true
  4082. ) );
  4083. /*
  4084. * $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;
  4085. */
  4086. $data ['explanation'] = '';
  4087. if (! empty ( $loanList ))
  4088. $data ['explanation'] = $loanList [0] ['explanation'];
  4089. $Locate = 0;
  4090. $roleId = 0;
  4091. $button = 0;
  4092. foreach ( $receiptList as $key => $value ) {
  4093. $receiptList [$key] ['Locate'] = $Locate;
  4094. $Locate ++;
  4095. $receiptList [$key] ['reviseDetail'] = array ();
  4096. if (! empty ( $value ['reviseDetail'] ))
  4097. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4098. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4099. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4100. $categoryDetil = $Lcategory->getOne ( array (
  4101. 'where' => 'cid=' . $value ['cid'],
  4102. 'asArray' => true
  4103. ) );
  4104. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4105. // 检测编辑状态
  4106. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4107. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4108. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4109. else
  4110. $verifyList ['staff'] = $value ['verifyBreakup'];
  4111. } else
  4112. $verifyList = $verify->getOne ( array (
  4113. 'where' => 'vid=' . $value ['verify'],
  4114. 'asArray' => true
  4115. ) );
  4116. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4117. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4118. Doo::loadModel ( 'role' );
  4119. $role = new role ();
  4120. $flag = true;
  4121. $roleKey = 0;
  4122. $endStaffArray = array ();
  4123. $roleArrayCopy = array ();
  4124. foreach ( $verifyList as $k => $v ) {
  4125. // init verifyStaff
  4126. if ($v [1] == 'ROLE') {
  4127. if (! empty ( $verifyStaff )) {
  4128. $endStaffArray = end ( $verifyStaff );
  4129. // if ($v[0]==$endStaffArray['nextStaff']){
  4130. // $roleId=$v[0];
  4131. // }
  4132. }
  4133. $roleVerify = json_decode ( $v [3], true );
  4134. $roleKey = $k;
  4135. $roleArray = array ();
  4136. $rolename = $role->getOne ( array (
  4137. 'where' => 'rid=' . $v [0],
  4138. 'asArray' => true
  4139. ) );
  4140. foreach ( $roleVerify as $o => $p ) {
  4141. $staffID = explode ( '_', $p );
  4142. $staffInfo = $staff->getOne ( array (
  4143. 'where' => 'sid=' . $staffID [0],
  4144. 'asArray' => true
  4145. ) );
  4146. // print_r($staffID);
  4147. $exp = array (
  4148. 0 => $staffInfo ['sid'],
  4149. 1 => $staffID [1],
  4150. 2 => $staffInfo ['avatar'],
  4151. 'date' => '',
  4152. 'date' => '',
  4153. 'opinion' => '',
  4154. 'status' => '',
  4155. 'rolename' => $rolename ['name']
  4156. );
  4157. array_push ( $roleArray, $exp );
  4158. }
  4159. $roleArrayCopy [$v [0]] = $roleArray;
  4160. // $verifyList[$k]['roleArray']=$roleArray;
  4161. }
  4162. $verifyList [$k] ['date'] = "";
  4163. $verifyList [$k] ['opinion'] = "";
  4164. $verifyList [$k] ['status'] = "";
  4165. if (empty ( $verifyStaff )) {
  4166. $verifyList [$k] ['date'] = "";
  4167. $verifyList [$k] ['opinion'] = "";
  4168. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4169. $verifyList [$k] ['status'] = 4;
  4170. $flag = false;
  4171. }
  4172. } else {
  4173. foreach ( $verifyStaff as $m => $u ) {
  4174. if ($v [0] == $m) {
  4175. $verifyList [$k] ['date'] = $u ['date'];
  4176. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4177. $verifyList [$k] ['status'] = $u ['status'];
  4178. $flag = false;
  4179. break;
  4180. }
  4181. }
  4182. $endStaffArray = end ( $verifyStaff );
  4183. if (isset ( $endStaffArray ['ROLE'] )) {
  4184. } else {
  4185. // $endKey=key($verifyStaff);
  4186. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4187. // $button=4;
  4188. // $verifyList[$k]['status']=4;
  4189. // }
  4190. }
  4191. }
  4192. }
  4193. $rolename ['name'] = '';
  4194. if (! empty ( $roleId )) {
  4195. Doo::loadModel ( 'role' );
  4196. $role = new role ();
  4197. $rolename = $role->getOne ( array (
  4198. 'where' => 'rid=' . $roleId,
  4199. 'asArray' => true
  4200. ) );
  4201. }
  4202. if (! empty ( $verifyStaff ))
  4203. $endStaffArray = end ( $verifyStaff );
  4204. $KOP = false;
  4205. foreach ( $roleArrayCopy as $P => $A ) {
  4206. foreach ( $A as $MKI => $AVL ) {
  4207. if (! empty ( $verifyStaff )) {
  4208. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4209. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4210. $button = 4;
  4211. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4212. }
  4213. foreach ( $verifyStaff as $m => $u ) {
  4214. $AVLFK = $AVL [0] . '_R';
  4215. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4216. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4217. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4218. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4219. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4220. break;
  4221. }
  4222. }
  4223. } else {
  4224. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4225. $button = 4;
  4226. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4227. }
  4228. }
  4229. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4230. $KOP = true;
  4231. }
  4232. }
  4233. foreach ( $roleArrayCopy as $k => $v ) {
  4234. foreach ( $verifyList as $m => $n ) {
  4235. if ($n [0] == $k) {
  4236. array_splice ( $verifyList, $m, 1, $v );
  4237. }
  4238. }
  4239. }
  4240. // 费用执行人相关数据
  4241. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4242. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4243. foreach ( $executeCopy as $k => $v ) {
  4244. $executeCopy [$k] ['date'] = '';
  4245. $executeCopy [$k] ['opinion'] = '';
  4246. $executeCopy [$k] ['status'] = '';
  4247. if (! empty ( $executeStaff ))
  4248. foreach ( $executeStaff as $m => $u ) {
  4249. if ($v [0] == $m) {
  4250. $executeCopy [$k] ['date'] = $u ['date'];
  4251. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4252. $executeCopy [$k] ['status'] = $u ['status'];
  4253. break;
  4254. }
  4255. }
  4256. }
  4257. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4258. $receiptList [$key] ['verifyList'] = $verifyList;
  4259. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4260. 'where' => 'sid=' . $value ['staff'],
  4261. 'asArray' => true
  4262. ) );
  4263. $receiptList [$key] ['button'] = $button;
  4264. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4265. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4266. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4267. $receiptList [$key] ['relust'] = $relust;
  4268. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4269. }
  4270. Doo::loadModel ( 'enclosur' );
  4271. $enclosur = new enclosur ();
  4272. $enclosurList = $enclosur->find ( array (
  4273. 'where' => 'rid=' . $rid,
  4274. 'asArray' => true
  4275. ) );
  4276. $enclosurHtml = '';
  4277. foreach ( $enclosurList as $value ) {
  4278. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4279. }
  4280. $data ['enclosurHtml'] = $enclosurHtml;
  4281. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4282. $data ['receiptList'] = $receiptList;
  4283. $data ['memu'] = "receipt";
  4284. $data ['staff'] = $this->staff;
  4285. $data ['receiptMemu'] = 'expenses';
  4286. $data ['verifyId'] = $this->verifyId;
  4287. $data ['executeId'] = $this->executeId;
  4288. if($receiptList[0]['receiptClass']==2){
  4289. $this->render ( "/receipt/feeTraveDetail", $data );
  4290. //$this->render ( "/admin/expensesCollect", $data );
  4291. }else{
  4292. $this->render ( "/admin/expensesCollect", $data );
  4293. }
  4294. }
  4295. function approvalExpenses() {
  4296. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4297. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4298. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4299. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4300. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4301. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4302. // echo $rdate;
  4303. if (empty ( $status ))
  4304. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4305. $page_size = 8;
  4306. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4307. $vidList = array ();
  4308. $button = 0;
  4309. Doo::loadModel ( 'verify' );
  4310. $verify = new verify ();
  4311. Doo::loadModel ( 'receipt' );
  4312. $receipt = new receipt ();
  4313. Doo::loadModel ( 'staff' );
  4314. $staff = new staff ();
  4315. Doo::loadModel ( 'L_category' );
  4316. $Lcategory = new L_category ();
  4317. // user verify ID
  4318. $verifyDetail = $verify->find ( array (
  4319. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4320. 'asArray' => true
  4321. ) );
  4322. foreach ( $verifyDetail as $key => $value ) {
  4323. array_push ( $vidList, $value ['vid'] );
  4324. }
  4325. $vid = implode ( ",", $vidList );
  4326. if (empty ( $verifyDetail ))
  4327. $vid = 0;
  4328. // if ($status==0)
  4329. // $dateCondition="";
  4330. // else
  4331. $dateCondition = " ";
  4332. // if (! empty ( $month ))
  4333. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4334. if ($status == 'done' || $status == 'termination') {
  4335. if (! empty ( $year )) {
  4336. $dateCondition = " and Year(pastDate) =" . $year;
  4337. if (! empty ( $month ))
  4338. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4339. }
  4340. } elseif ($status == 'finish') {
  4341. if (! empty ( $year )) {
  4342. $dateCondition = " and Year(pastDate) =" . $year;
  4343. if (! empty ( $month ))
  4344. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4345. }
  4346. }
  4347. // date ( 'Y-m' )
  4348. // if (! empty ( $rdate ) && $status == 'done')
  4349. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4350. // elseif (! empty ( $rdate ))
  4351. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4352. $categoryList = $Lcategory->find ( array (
  4353. 'asArray' => true
  4354. ) );
  4355. $staffList = $staff->find ( array (
  4356. 'where' => 'cid=' . $cid,
  4357. 'asArray' => true
  4358. ) );
  4359. $cateCondition = "";
  4360. $staffCondition = "";
  4361. $approvalCondition = "";
  4362. if (! empty ( $cid )) {
  4363. $cateCondition = ' and cid=' . $cid;
  4364. }
  4365. if (! empty ( $sid )) {
  4366. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4367. $cateCondition = "";
  4368. }
  4369. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4370. if ($status == 'pendApproval') {
  4371. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4372. }
  4373. if ($status == 'ongoing') {
  4374. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4375. }
  4376. if ($status == 'done') {
  4377. $approvalCondition = ' and (status=8 or status=9 ) ';
  4378. }
  4379. if ($status == 'termination') {
  4380. $approvalCondition = " and status=3";
  4381. }
  4382. if ($status == 'finish') {
  4383. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4384. }
  4385. $pageinfo ['page'] = array (
  4386. 'previous' => ''
  4387. );
  4388. if(!empty($receiptOrder)){
  4389. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4390. $receiptList = $receipt->find ( array ( // $dateCondition
  4391. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4392. 'desc' => 'rid',
  4393. 'asArray' => true
  4394. ) );
  4395. }else{
  4396. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4397. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4398. $receiptList = $receipt->find ( array ( // $dateCondition.
  4399. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4400. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4401. 'desc' => 'rid',
  4402. 'asArray' => true
  4403. ) );
  4404. } else {
  4405. $receiptList = $receipt->find ( array ( // $dateCondition
  4406. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4407. 'desc' => 'rid',
  4408. 'asArray' => true
  4409. ) );
  4410. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4411. }
  4412. }
  4413. $rLRes = $receipt->find ( array (
  4414. '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 . ')',
  4415. 'desc' => 'rid',
  4416. 'asArray' => true
  4417. ) );
  4418. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4419. // print_r($receiptList);
  4420. Doo::loadClass ( 'XDeode' );
  4421. $XDeode = new XDeode ( 7 );
  4422. $Locate = 0;
  4423. //
  4424. $reportList = $reportCateList = array ();
  4425. foreach ( $receiptList as $key => $value ) {
  4426. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4427. $receiptList [$key] ['Locate'] = $Locate;
  4428. $Locate ++;
  4429. $receiptList [$key] ['reviseDetail'] = array ();
  4430. if (! empty ( $value ['reviseDetail'] ))
  4431. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4432. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4433. $categoryDetil = $Lcategory->getOne ( array (
  4434. 'where' => 'cid=' . $value ['cid'],
  4435. 'asArray' => true
  4436. ) );
  4437. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4438. $verifyList = $verify->getOne ( array (
  4439. 'where' => 'vid=' . $value ['verify'],
  4440. 'asArray' => true
  4441. ) );
  4442. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4443. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4444. foreach ( $verifyList as $k => $v ) {
  4445. // init verifyStaff
  4446. $verifyList [$k] ['date'] = "";
  4447. $verifyList [$k] ['opinion'] = "";
  4448. $verifyList [$k] ['status'] = "";
  4449. if (empty ( $verifyStaff )) {
  4450. $verifyList [$k] ['date'] = "";
  4451. $verifyList [$k] ['opinion'] = "";
  4452. if ($v [0] == $this->staff [0] ['sid']) {
  4453. $verifyList [$k] ['status'] = 4;
  4454. $button = 4;
  4455. }
  4456. } else {
  4457. $flag = true;
  4458. foreach ( $verifyStaff as $m => $u ) {
  4459. if ($v [0] == $m) {
  4460. $verifyList [$k] ['date'] = $u ['date'];
  4461. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4462. $verifyList [$k] ['status'] = $u ['status'];
  4463. $flag = false;
  4464. break;
  4465. }
  4466. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4467. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4468. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4469. }
  4470. if ($flag) { // 检测可编辑
  4471. if ($v [0] == $this->staff [0] ['sid']) {
  4472. $verifyList [$k] ['status'] = 4;
  4473. $button = 4;
  4474. }
  4475. }
  4476. }
  4477. }
  4478. $receiptList [$key] ['verifyList'] = $verifyList;
  4479. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4480. 'where' => 'sid=' . $value ['staff'],
  4481. 'asArray' => true
  4482. ) );
  4483. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4484. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4485. $receiptList [$key] ['button'] = $button;
  4486. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4487. //获得培训班结算RID 借款费用--已经锁定
  4488. if($value['status']==10){
  4489. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4490. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4491. }
  4492. }
  4493. $reportList = array_unique ( $reportList );
  4494. $reportHtml = '';
  4495. foreach ( $reportList as $key => $value ) {
  4496. $v = explode ( "-", $value );
  4497. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4498. }
  4499. // print_r($reportList)
  4500. $data ['reportHtml'] = $reportHtml;
  4501. $reportCateList = array_unique ( $reportCateList );
  4502. $reportCateHtml = '';
  4503. foreach ( $reportCateList as $key => $value ) {
  4504. $v = explode ( "-", $value );
  4505. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4506. }
  4507. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4508. $data ['reportCateHtml'] = $reportCateHtml;
  4509. // print_r($receiptList);die;
  4510. // $data['verifyDetail']=$verifyDetail;
  4511. $mothHtml = "";
  4512. for($i = 1; $i <= 12; $i ++) {
  4513. if ($month == $i)
  4514. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4515. else
  4516. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4517. }
  4518. $data ['mothHtml'] = $mothHtml;
  4519. $dateHtml = "";
  4520. $now = date ( "Y" );
  4521. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4522. if ($YEARD <= $now) {
  4523. $dateHtml .= '<option ';
  4524. if ($year == $YEARD) {
  4525. $dateHtml .= 'selected ';
  4526. }
  4527. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4528. }
  4529. }
  4530. $data ['dateHtml'] = $dateHtml;
  4531. $data ['page'] = $pageinfo;
  4532. $data ['receiptList'] = $receiptList;
  4533. $data ['receiptApprovalCount'] = count ( $rLRes );
  4534. $data ['status'] = $status;
  4535. $data ['year'] = $year;
  4536. $data ['month'] = $month;
  4537. $data ['categoryList'] = $categoryList;
  4538. $data ['staffList'] = $staffList;
  4539. $data ['cid'] = $cid;
  4540. $data ['sid'] = $sid;
  4541. // print_r($receiptList);
  4542. $data['receiptOrder']=$receiptOrder;
  4543. $data ['memu'] = "receipt";
  4544. $data ['staff'] = $this->staff;
  4545. $data ['receiptMemu'] = 'approvalExpenses';
  4546. $data ['verifyId'] = $this->verifyId;
  4547. $data ['executeId'] = $this->executeId;
  4548. $this->render ( "/admin/approvalExpenses", $data );
  4549. }
  4550. private function _expensesDoc(){
  4551. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4552. Doo::loadClass ( 'XDeode' );
  4553. $XDeode = new XDeode ( 5 );
  4554. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4555. $rid = $XDeode->decode ( $rid );
  4556. if (! is_numeric ( $rid ))
  4557. die ( 'illegal request' );
  4558. Doo::loadModel ( 'receipt' );
  4559. $receipt = new receipt ();
  4560. Doo::loadModel ( 'L_category' );
  4561. $Lcategory = new L_category ();
  4562. Doo::loadModel ( 'verify' );
  4563. Doo::loadModel ( 'statistics' );
  4564. $statistics = new statistics ();
  4565. $verify = new verify ();
  4566. Doo::loadModel ( 'staff' );
  4567. $staff = new staff ();
  4568. Doo::loadModel ( 'loanReceipt' );
  4569. $loanReceipt = new loanReceipt ();
  4570. $receiptList = $receipt->find ( array (
  4571. 'where' => ' rid=' . $rid,
  4572. 'desc' => 'rid',
  4573. 'asArray' => true
  4574. ) );
  4575. $loanList = array ();
  4576. if (! empty ( $receiptList ))
  4577. $loanList = $loanReceipt->find ( array (
  4578. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4579. 'desc' => 'rid',
  4580. 'asArray' => true
  4581. ) );
  4582. $Locate = 0;
  4583. $roleId = 0;
  4584. $button = 0;
  4585. foreach ( $loanList as $key => $value ) {
  4586. $loanList [$key] ['Locate'] = $Locate;
  4587. $Locate ++;
  4588. $loanList [$key] ['reviseDetail'] = array ();
  4589. if (! empty ( $value ['reviseDetail'] ))
  4590. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4591. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4592. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4593. $categoryDetil = $Lcategory->getOne ( array (
  4594. 'where' => 'cid=' . $value ['cid'],
  4595. 'asArray' => true
  4596. ) );
  4597. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4598. // 检测编辑状态
  4599. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4600. $verifyList ['staff'] = $value ['verifyBreakup'];
  4601. else
  4602. $verifyList = $verify->getOne ( array (
  4603. 'where' => 'vid=' . $value ['verify'],
  4604. 'asArray' => true
  4605. ) );
  4606. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4607. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4608. Doo::loadModel ( 'role' );
  4609. $role = new role ();
  4610. $flag = true;
  4611. $roleKey = 0;
  4612. $endStaffArray = array ();
  4613. $roleArrayCopy = array ();
  4614. foreach ( $verifyList as $k => $v ) {
  4615. // init verifyStaff
  4616. if ($v [1] == 'ROLE') {
  4617. if (! empty ( $verifyStaff )) {
  4618. $endStaffArray = end ( $verifyStaff );
  4619. // if ($v[0]==$endStaffArray['nextStaff']){
  4620. // $roleId=$v[0];
  4621. // }
  4622. }
  4623. $roleVerify = json_decode ( $v [3], true );
  4624. $roleKey = $k;
  4625. $roleArray = array ();
  4626. $rolename = $role->getOne ( array (
  4627. 'where' => 'rid=' . $v [0],
  4628. 'asArray' => true
  4629. ) );
  4630. foreach ( $roleVerify as $o => $p ) {
  4631. $staffID = explode ( '_', $p );
  4632. $staffInfo = $staff->getOne ( array (
  4633. 'where' => 'sid=' . $staffID [0],
  4634. 'asArray' => true
  4635. ) );
  4636. // print_r($staffID);
  4637. $exp = array (
  4638. 0 => $staffInfo ['sid'],
  4639. 1 => $staffID [1],
  4640. 2 => $staffInfo ['avatar'],
  4641. 'date' => '',
  4642. 'date' => '',
  4643. 'opinion' => '',
  4644. 'status' => '',
  4645. 'rolename' => $rolename ['name']
  4646. );
  4647. array_push ( $roleArray, $exp );
  4648. }
  4649. $roleArrayCopy [$v [0]] = $roleArray;
  4650. // $verifyList[$k]['roleArray']=$roleArray;
  4651. }
  4652. $verifyList [$k] ['date'] = "";
  4653. $verifyList [$k] ['opinion'] = "";
  4654. $verifyList [$k] ['status'] = "";
  4655. if (empty ( $verifyStaff )) {
  4656. $verifyList [$k] ['date'] = "";
  4657. $verifyList [$k] ['opinion'] = "";
  4658. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4659. $verifyList [$k] ['status'] = 4;
  4660. $flag = false;
  4661. }
  4662. } else {
  4663. foreach ( $verifyStaff as $m => $u ) {
  4664. if ($v [0] == $m) {
  4665. $verifyList [$k] ['date'] = $u ['date'];
  4666. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4667. $verifyList [$k] ['status'] = $u ['status'];
  4668. $flag = false;
  4669. break;
  4670. }
  4671. }
  4672. $endStaffArray = end ( $verifyStaff );
  4673. if (isset ( $endStaffArray ['ROLE'] )) {
  4674. } else {
  4675. // $endKey=key($verifyStaff);
  4676. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4677. // $button=4;
  4678. // $verifyList[$k]['status']=4;
  4679. // }
  4680. }
  4681. }
  4682. }
  4683. $rolename ['name'] = '';
  4684. if (! empty ( $roleId )) {
  4685. Doo::loadModel ( 'role' );
  4686. $role = new role ();
  4687. $rolename = $role->getOne ( array (
  4688. 'where' => 'rid=' . $roleId,
  4689. 'asArray' => true
  4690. ) );
  4691. }
  4692. if (! empty ( $verifyStaff ))
  4693. $endStaffArray = end ( $verifyStaff );
  4694. $KOP = false;
  4695. foreach ( $roleArrayCopy as $P => $A ) {
  4696. foreach ( $A as $MKI => $AVL ) {
  4697. if (! empty ( $verifyStaff )) {
  4698. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4699. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4700. $button = 4;
  4701. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4702. }
  4703. foreach ( $verifyStaff as $m => $u ) {
  4704. $AVLFK = $AVL [0] . '_R';
  4705. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4706. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4707. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4708. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4709. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4710. break;
  4711. }
  4712. }
  4713. } else {
  4714. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4715. $button = 4;
  4716. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4717. }
  4718. }
  4719. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4720. $KOP = true;
  4721. }
  4722. }
  4723. foreach ( $roleArrayCopy as $k => $v ) {
  4724. foreach ( $verifyList as $m => $n ) {
  4725. if ($n [0] == $k) {
  4726. array_splice ( $verifyList, $m, 1, $v );
  4727. }
  4728. }
  4729. }
  4730. $loanList [$key] ['verifyList'] = $verifyList;
  4731. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4732. 'where' => 'sid=' . $value ['staff'],
  4733. 'asArray' => true
  4734. ) );
  4735. $loanList [$key] ['button'] = $button;
  4736. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4737. }
  4738. $data ['loanList'] = $loanList;
  4739. //print_r($loanList);
  4740. $Locate = 0;
  4741. $roleId = 0;
  4742. $button = 0;
  4743. foreach ( $receiptList as $key => $value ) {
  4744. $receiptList [$key] ['Locate'] = $Locate;
  4745. $Locate ++;
  4746. $receiptList [$key] ['reviseDetail'] = array ();
  4747. if (! empty ( $value ['reviseDetail'] ))
  4748. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4749. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4750. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4751. $categoryDetil = $Lcategory->getOne ( array (
  4752. 'where' => 'cid=' . $value ['cid'],
  4753. 'asArray' => true
  4754. ) );
  4755. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4756. // 检测编辑状态
  4757. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4758. $verifyList ['staff'] = $value ['verifyBreakup'];
  4759. } else
  4760. $verifyList = $verify->getOne ( array (
  4761. 'where' => 'vid=' . $value ['verify'],
  4762. 'asArray' => true
  4763. ) );
  4764. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4765. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4766. Doo::loadModel ( 'role' );
  4767. $role = new role ();
  4768. if ($verifyList == NULL)
  4769. $verifyList = array ();
  4770. $flag = true;
  4771. $roleKey = 0;
  4772. $endStaffArray = array ();
  4773. $roleArrayCopy = array ();
  4774. foreach ( $verifyList as $k => $v ) {
  4775. // init verifyStaff
  4776. if ($v [1] == 'ROLE') {
  4777. if (! empty ( $verifyStaff )) {
  4778. $endStaffArray = end ( $verifyStaff );
  4779. // if ($v[0]==$endStaffArray['nextStaff']){
  4780. // $roleId=$v[0];
  4781. // }
  4782. }
  4783. $roleVerify = json_decode ( $v [3], true );
  4784. $roleKey = $k;
  4785. $roleArray = array ();
  4786. $rolename = $role->getOne ( array (
  4787. 'where' => 'rid=' . $v [0],
  4788. 'asArray' => true
  4789. ) );
  4790. foreach ( $roleVerify as $o => $p ) {
  4791. $staffID = explode ( '_', $p );
  4792. $staffInfo = $staff->getOne ( array (
  4793. 'where' => 'sid=' . $staffID [0],
  4794. 'asArray' => true
  4795. ) );
  4796. // print_r($staffID);
  4797. $exp = array (
  4798. 0 => $staffInfo ['sid'],
  4799. 1 => $staffID [1],
  4800. 2 => $staffInfo ['avatar'],
  4801. 'date' => '',
  4802. 'date' => '',
  4803. 'opinion' => '',
  4804. 'status' => '',
  4805. 'rolename' => $rolename ['name']
  4806. );
  4807. array_push ( $roleArray, $exp );
  4808. }
  4809. $roleArrayCopy [$v [0]] = $roleArray;
  4810. // $verifyList[$k]['roleArray']=$roleArray;
  4811. }
  4812. $verifyList [$k] ['date'] = "";
  4813. $verifyList [$k] ['opinion'] = "";
  4814. $verifyList [$k] ['status'] = "";
  4815. if (empty ( $verifyStaff )) {
  4816. $verifyList [$k] ['date'] = "";
  4817. $verifyList [$k] ['opinion'] = "";
  4818. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4819. $verifyList [$k] ['status'] = 4;
  4820. $flag = false;
  4821. }
  4822. } else {
  4823. foreach ( $verifyStaff as $m => $u ) {
  4824. if ($v [0] == $m) {
  4825. $verifyList [$k] ['date'] = $u ['date'];
  4826. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4827. $verifyList [$k] ['status'] = $u ['status'];
  4828. $flag = false;
  4829. break;
  4830. }
  4831. }
  4832. $endStaffArray = end ( $verifyStaff );
  4833. if (isset ( $endStaffArray ['ROLE'] )) {
  4834. } else {
  4835. // $endKey=key($verifyStaff);
  4836. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4837. // $button=4;
  4838. // $verifyList[$k]['status']=4;
  4839. // }
  4840. }
  4841. }
  4842. }
  4843. $FC = @$rolename ['name'];
  4844. $rolename ['name'] = '';
  4845. if (! empty ( $roleId )) {
  4846. Doo::loadModel ( 'role' );
  4847. $role = new role ();
  4848. $rolename = $role->getOne ( array (
  4849. 'where' => 'rid=' . $roleId,
  4850. 'asArray' => true
  4851. ) );
  4852. }
  4853. if (! empty ( $verifyStaff ))
  4854. $endStaffArray = end ( $verifyStaff );
  4855. $KOP = false;
  4856. foreach ( $roleArrayCopy as $P => $A ) {
  4857. foreach ( $A as $MKI => $AVL ) {
  4858. if (! empty ( $verifyStaff )) {
  4859. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4860. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4861. $button = 4;
  4862. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4863. }
  4864. foreach ( $verifyStaff as $m => $u ) {
  4865. $AVLFK = $AVL [0] . '_R';
  4866. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4867. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4868. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4869. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4870. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4871. break;
  4872. }
  4873. }
  4874. } else {
  4875. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4876. $button = 4;
  4877. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4878. }
  4879. }
  4880. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4881. $KOP = true;
  4882. }
  4883. }
  4884. foreach ( $roleArrayCopy as $k => $v ) {
  4885. foreach ( $verifyList as $m => $n ) {
  4886. if ($n [0] == $k) {
  4887. array_splice ( $verifyList, $m, 1, $v );
  4888. }
  4889. }
  4890. }
  4891. // 费用执行人相关数据
  4892. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4893. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4894. foreach ( $executeCopy as $k => $v ) {
  4895. $executeCopy [$k] ['date'] = '';
  4896. $executeCopy [$k] ['opinion'] = '';
  4897. $executeCopy [$k] ['status'] = '';
  4898. if (! empty ( $executeStaff ))
  4899. foreach ( $executeStaff as $m => $u ) {
  4900. if ($v [0] == $m) {
  4901. $executeCopy [$k] ['date'] = $u ['date'];
  4902. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4903. $executeCopy [$k] ['status'] = $u ['status'];
  4904. break;
  4905. }
  4906. }
  4907. }
  4908. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4909. // print_r($verifyList);
  4910. $receiptList [$key] ['verifyList'] = $verifyList;
  4911. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4912. 'where' => 'sid=' . $value ['staff'],
  4913. 'asArray' => true
  4914. ) );
  4915. $receiptList [$key] ['button'] = $button;
  4916. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4917. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4918. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4919. $receiptList [$key] ['relust'] = $relust;
  4920. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4921. }
  4922. // print_r($receiptList);
  4923. // 获取审批日志
  4924. Doo::loadModel ( 'receiptLog' );
  4925. $receiptLog = new receiptLog ();
  4926. $rlList = array ();
  4927. $rlInfo = $receiptLog->getOne ( array (
  4928. 'where' => 'rid=' . $rid . ' and status=4',
  4929. 'asArray' => true
  4930. ) );
  4931. // $tijdate = $receiptLog->getOne ( array (
  4932. // 'where' => 'rid=' . $rid . ' and status=2',
  4933. // 'asc' => 'rlid',
  4934. // 'asArray' => true
  4935. // ) );
  4936. if (! empty ( $rlInfo )) {
  4937. $rlList = $receiptLog->find ( array (
  4938. 'where' => 'rid=' . $rid,
  4939. 'asc' => 'rlid',
  4940. 'asArray' => true
  4941. ) );
  4942. }
  4943. $RN=array();
  4944. if (!empty( $rolename ['staff'])){
  4945. $RN = @json_decode ( $rolename ['staff'] );
  4946. }
  4947. //
  4948. foreach ( $rlList as $key => $value ) {
  4949. $rlList [$key] ['rolename'] = '';
  4950. foreach ( $RN as $k => $v ) {
  4951. $id = explode ( "_", $v );
  4952. if ($id [0] == $value ['uid']) {
  4953. $rlList [$key] ['rolename'] = $FC;
  4954. break;
  4955. }
  4956. }
  4957. }
  4958. Doo::loadModel ( 'enclosur' );
  4959. $enclosur = new enclosur ();
  4960. $enclosurList = $enclosur->find ( array (
  4961. 'where' => 'rid=' . $rid,
  4962. 'asArray' => true
  4963. ) );
  4964. $enclosurHtml = '';
  4965. foreach ( $enclosurList as $value ) {
  4966. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4967. }
  4968. $data ['enclosurHtml'] = $enclosurHtml;
  4969. $receiptList [0] ['rlList'] = $rlList;
  4970. $data ['receiptList'] = $receiptList;
  4971. // print_r($receiptList);
  4972. $data ['memu'] = "receipt";
  4973. $data ['staff'] = $this->staff;
  4974. $data ['receiptMemu'] = 'approvalExpenses';
  4975. $data ['verifyId'] = $this->verifyId;
  4976. $data ['executeId'] = $this->executeId;
  4977. return $data;
  4978. }
  4979. function expensesDoc() {
  4980. $data=$this->_expensesDoc();
  4981. // $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4982. // Doo::loadClass ( 'XDeode' );
  4983. // $XDeode = new XDeode ( 5 );
  4984. // if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4985. // $rid = $XDeode->decode ( $rid );
  4986. // if (! is_numeric ( $rid ))
  4987. // die ( 'illegal request' );
  4988. // Doo::loadModel ( 'receipt' );
  4989. // $receipt = new receipt ();
  4990. // Doo::loadModel ( 'L_category' );
  4991. // $Lcategory = new L_category ();
  4992. // Doo::loadModel ( 'verify' );
  4993. // Doo::loadModel ( 'statistics' );
  4994. // $statistics = new statistics ();
  4995. // $verify = new verify ();
  4996. // Doo::loadModel ( 'staff' );
  4997. // $staff = new staff ();
  4998. // Doo::loadModel ( 'loanReceipt' );
  4999. // $loanReceipt = new loanReceipt ();
  5000. // $receiptList = $receipt->find ( array (
  5001. // 'where' => ' rid=' . $rid,
  5002. // 'desc' => 'rid',
  5003. // 'asArray' => true
  5004. // ) );
  5005. // $loanList = array ();
  5006. // if (! empty ( $receiptList ))
  5007. // $loanList = $loanReceipt->find ( array (
  5008. // 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5009. // 'desc' => 'rid',
  5010. // 'asArray' => true
  5011. // ) );
  5012. // $Locate = 0;
  5013. // $roleId = 0;
  5014. // $button = 0;
  5015. // foreach ( $loanList as $key => $value ) {
  5016. // $loanList [$key] ['Locate'] = $Locate;
  5017. // $Locate ++;
  5018. // $loanList [$key] ['reviseDetail'] = array ();
  5019. // if (! empty ( $value ['reviseDetail'] ))
  5020. // $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5021. // $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5022. // $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5023. // $categoryDetil = $Lcategory->getOne ( array (
  5024. // 'where' => 'cid=' . $value ['cid'],
  5025. // 'asArray' => true
  5026. // ) );
  5027. // $loanList [$key] ['category'] = $categoryDetil ['title'];
  5028. // // 检测编辑状态
  5029. // if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  5030. // $verifyList ['staff'] = $value ['verifyBreakup'];
  5031. // else
  5032. // $verifyList = $verify->getOne ( array (
  5033. // 'where' => 'vid=' . $value ['verify'],
  5034. // 'asArray' => true
  5035. // ) );
  5036. // $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5037. // $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5038. // Doo::loadModel ( 'role' );
  5039. // $role = new role ();
  5040. // $flag = true;
  5041. // $roleKey = 0;
  5042. // $endStaffArray = array ();
  5043. // $roleArrayCopy = array ();
  5044. // foreach ( $verifyList as $k => $v ) {
  5045. // // init verifyStaff
  5046. // if ($v [1] == 'ROLE') {
  5047. // if (! empty ( $verifyStaff )) {
  5048. // $endStaffArray = end ( $verifyStaff );
  5049. // // if ($v[0]==$endStaffArray['nextStaff']){
  5050. // // $roleId=$v[0];
  5051. // // }
  5052. // }
  5053. // $roleVerify = json_decode ( $v [3], true );
  5054. // $roleKey = $k;
  5055. // $roleArray = array ();
  5056. // $rolename = $role->getOne ( array (
  5057. // 'where' => 'rid=' . $v [0],
  5058. // 'asArray' => true
  5059. // ) );
  5060. // foreach ( $roleVerify as $o => $p ) {
  5061. // $staffID = explode ( '_', $p );
  5062. // $staffInfo = $staff->getOne ( array (
  5063. // 'where' => 'sid=' . $staffID [0],
  5064. // 'asArray' => true
  5065. // ) );
  5066. // // print_r($staffID);
  5067. // $exp = array (
  5068. // 0 => $staffInfo ['sid'],
  5069. // 1 => $staffID [1],
  5070. // 2 => $staffInfo ['avatar'],
  5071. // 'date' => '',
  5072. // 'date' => '',
  5073. // 'opinion' => '',
  5074. // 'status' => '',
  5075. // 'rolename' => $rolename ['name']
  5076. // );
  5077. // array_push ( $roleArray, $exp );
  5078. // }
  5079. // $roleArrayCopy [$v [0]] = $roleArray;
  5080. // // $verifyList[$k]['roleArray']=$roleArray;
  5081. // }
  5082. // $verifyList [$k] ['date'] = "";
  5083. // $verifyList [$k] ['opinion'] = "";
  5084. // $verifyList [$k] ['status'] = "";
  5085. // if (empty ( $verifyStaff )) {
  5086. // $verifyList [$k] ['date'] = "";
  5087. // $verifyList [$k] ['opinion'] = "";
  5088. // if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5089. // $verifyList [$k] ['status'] = 4;
  5090. // $flag = false;
  5091. // }
  5092. // } else {
  5093. // foreach ( $verifyStaff as $m => $u ) {
  5094. // if ($v [0] == $m) {
  5095. // $verifyList [$k] ['date'] = $u ['date'];
  5096. // $verifyList [$k] ['opinion'] = $u ['opinion'];
  5097. // $verifyList [$k] ['status'] = $u ['status'];
  5098. // $flag = false;
  5099. // break;
  5100. // }
  5101. // }
  5102. // $endStaffArray = end ( $verifyStaff );
  5103. // if (isset ( $endStaffArray ['ROLE'] )) {
  5104. // } else {
  5105. // // $endKey=key($verifyStaff);
  5106. // // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5107. // // $button=4;
  5108. // // $verifyList[$k]['status']=4;
  5109. // // }
  5110. // }
  5111. // }
  5112. // }
  5113. // $rolename ['name'] = '';
  5114. // if (! empty ( $roleId )) {
  5115. // Doo::loadModel ( 'role' );
  5116. // $role = new role ();
  5117. // $rolename = $role->getOne ( array (
  5118. // 'where' => 'rid=' . $roleId,
  5119. // 'asArray' => true
  5120. // ) );
  5121. // }
  5122. // if (! empty ( $verifyStaff ))
  5123. // $endStaffArray = end ( $verifyStaff );
  5124. // $KOP = false;
  5125. // foreach ( $roleArrayCopy as $P => $A ) {
  5126. // foreach ( $A as $MKI => $AVL ) {
  5127. // if (! empty ( $verifyStaff )) {
  5128. // // &&$rolename['rid']==$endStaffArray['nextStaff']
  5129. // if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5130. // $button = 4;
  5131. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5132. // }
  5133. // foreach ( $verifyStaff as $m => $u ) {
  5134. // $AVLFK = $AVL [0] . '_R';
  5135. // // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5136. // if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5137. // $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5138. // $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5139. // $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5140. // break;
  5141. // }
  5142. // }
  5143. // } else {
  5144. // if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5145. // $button = 4;
  5146. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5147. // }
  5148. // }
  5149. // // $roleArray[$MKI]['rolename']=$rolename['name'];
  5150. // $KOP = true;
  5151. // }
  5152. // }
  5153. // foreach ( $roleArrayCopy as $k => $v ) {
  5154. // foreach ( $verifyList as $m => $n ) {
  5155. // if ($n [0] == $k) {
  5156. // array_splice ( $verifyList, $m, 1, $v );
  5157. // }
  5158. // }
  5159. // }
  5160. // $loanList [$key] ['verifyList'] = $verifyList;
  5161. // $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5162. // 'where' => 'sid=' . $value ['staff'],
  5163. // 'asArray' => true
  5164. // ) );
  5165. // $loanList [$key] ['button'] = $button;
  5166. // //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  5167. // }
  5168. // $data ['loanList'] = $loanList;
  5169. // //print_r($loanList);
  5170. // $Locate = 0;
  5171. // $roleId = 0;
  5172. // $button = 0;
  5173. // foreach ( $receiptList as $key => $value ) {
  5174. // $receiptList [$key] ['Locate'] = $Locate;
  5175. // $Locate ++;
  5176. // $receiptList [$key] ['reviseDetail'] = array ();
  5177. // if (! empty ( $value ['reviseDetail'] ))
  5178. // $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5179. // $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5180. // $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5181. // $categoryDetil = $Lcategory->getOne ( array (
  5182. // 'where' => 'cid=' . $value ['cid'],
  5183. // 'asArray' => true
  5184. // ) );
  5185. // $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5186. // // 检测编辑状态
  5187. // if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5188. // $verifyList ['staff'] = $value ['verifyBreakup'];
  5189. // } else
  5190. // $verifyList = $verify->getOne ( array (
  5191. // 'where' => 'vid=' . $value ['verify'],
  5192. // 'asArray' => true
  5193. // ) );
  5194. // $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5195. // $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5196. // Doo::loadModel ( 'role' );
  5197. // $role = new role ();
  5198. // if ($verifyList == NULL)
  5199. // $verifyList = array ();
  5200. // $flag = true;
  5201. // $roleKey = 0;
  5202. // $endStaffArray = array ();
  5203. // $roleArrayCopy = array ();
  5204. // foreach ( $verifyList as $k => $v ) {
  5205. // // init verifyStaff
  5206. // if ($v [1] == 'ROLE') {
  5207. // if (! empty ( $verifyStaff )) {
  5208. // $endStaffArray = end ( $verifyStaff );
  5209. // // if ($v[0]==$endStaffArray['nextStaff']){
  5210. // // $roleId=$v[0];
  5211. // // }
  5212. // }
  5213. // $roleVerify = json_decode ( $v [3], true );
  5214. // $roleKey = $k;
  5215. // $roleArray = array ();
  5216. // $rolename = $role->getOne ( array (
  5217. // 'where' => 'rid=' . $v [0],
  5218. // 'asArray' => true
  5219. // ) );
  5220. // foreach ( $roleVerify as $o => $p ) {
  5221. // $staffID = explode ( '_', $p );
  5222. // $staffInfo = $staff->getOne ( array (
  5223. // 'where' => 'sid=' . $staffID [0],
  5224. // 'asArray' => true
  5225. // ) );
  5226. // // print_r($staffID);
  5227. // $exp = array (
  5228. // 0 => $staffInfo ['sid'],
  5229. // 1 => $staffID [1],
  5230. // 2 => $staffInfo ['avatar'],
  5231. // 'date' => '',
  5232. // 'date' => '',
  5233. // 'opinion' => '',
  5234. // 'status' => '',
  5235. // 'rolename' => $rolename ['name']
  5236. // );
  5237. // array_push ( $roleArray, $exp );
  5238. // }
  5239. // $roleArrayCopy [$v [0]] = $roleArray;
  5240. // // $verifyList[$k]['roleArray']=$roleArray;
  5241. // }
  5242. // $verifyList [$k] ['date'] = "";
  5243. // $verifyList [$k] ['opinion'] = "";
  5244. // $verifyList [$k] ['status'] = "";
  5245. // if (empty ( $verifyStaff )) {
  5246. // $verifyList [$k] ['date'] = "";
  5247. // $verifyList [$k] ['opinion'] = "";
  5248. // if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5249. // $verifyList [$k] ['status'] = 4;
  5250. // $flag = false;
  5251. // }
  5252. // } else {
  5253. // foreach ( $verifyStaff as $m => $u ) {
  5254. // if ($v [0] == $m) {
  5255. // $verifyList [$k] ['date'] = $u ['date'];
  5256. // $verifyList [$k] ['opinion'] = $u ['opinion'];
  5257. // $verifyList [$k] ['status'] = $u ['status'];
  5258. // $flag = false;
  5259. // break;
  5260. // }
  5261. // }
  5262. // $endStaffArray = end ( $verifyStaff );
  5263. // if (isset ( $endStaffArray ['ROLE'] )) {
  5264. // } else {
  5265. // // $endKey=key($verifyStaff);
  5266. // // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5267. // // $button=4;
  5268. // // $verifyList[$k]['status']=4;
  5269. // // }
  5270. // }
  5271. // }
  5272. // }
  5273. // $FC = @$rolename ['name'];
  5274. // $rolename ['name'] = '';
  5275. // if (! empty ( $roleId )) {
  5276. // Doo::loadModel ( 'role' );
  5277. // $role = new role ();
  5278. // $rolename = $role->getOne ( array (
  5279. // 'where' => 'rid=' . $roleId,
  5280. // 'asArray' => true
  5281. // ) );
  5282. // }
  5283. // if (! empty ( $verifyStaff ))
  5284. // $endStaffArray = end ( $verifyStaff );
  5285. // $KOP = false;
  5286. // foreach ( $roleArrayCopy as $P => $A ) {
  5287. // foreach ( $A as $MKI => $AVL ) {
  5288. // if (! empty ( $verifyStaff )) {
  5289. // // &&$rolename['rid']==$endStaffArray['nextStaff']
  5290. // if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5291. // $button = 4;
  5292. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5293. // }
  5294. // foreach ( $verifyStaff as $m => $u ) {
  5295. // $AVLFK = $AVL [0] . '_R';
  5296. // // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5297. // if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5298. // $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5299. // $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5300. // $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5301. // break;
  5302. // }
  5303. // }
  5304. // } else {
  5305. // if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5306. // $button = 4;
  5307. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5308. // }
  5309. // }
  5310. // // $roleArray[$MKI]['rolename']=$rolename['name'];
  5311. // $KOP = true;
  5312. // }
  5313. // }
  5314. // foreach ( $roleArrayCopy as $k => $v ) {
  5315. // foreach ( $verifyList as $m => $n ) {
  5316. // if ($n [0] == $k) {
  5317. // array_splice ( $verifyList, $m, 1, $v );
  5318. // }
  5319. // }
  5320. // }
  5321. // // 费用执行人相关数据
  5322. // $executeCopy = json_decode ( $value ['executeCopy'], true );
  5323. // $executeStaff = json_decode ( $value ['executeStaff'], true );
  5324. // foreach ( $executeCopy as $k => $v ) {
  5325. // $executeCopy [$k] ['date'] = '';
  5326. // $executeCopy [$k] ['opinion'] = '';
  5327. // $executeCopy [$k] ['status'] = '';
  5328. // if (! empty ( $executeStaff ))
  5329. // foreach ( $executeStaff as $m => $u ) {
  5330. // if ($v [0] == $m) {
  5331. // $executeCopy [$k] ['date'] = $u ['date'];
  5332. // $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5333. // $executeCopy [$k] ['status'] = $u ['status'];
  5334. // break;
  5335. // }
  5336. // }
  5337. // }
  5338. // $receiptList [$key] ['executeCopy'] = $executeCopy;
  5339. // // print_r($verifyList);
  5340. // $receiptList [$key] ['verifyList'] = $verifyList;
  5341. // $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5342. // 'where' => 'sid=' . $value ['staff'],
  5343. // 'asArray' => true
  5344. // ) );
  5345. // $receiptList [$key] ['button'] = $button;
  5346. // $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5347. // $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5348. // $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5349. // $receiptList [$key] ['relust'] = $relust;
  5350. // $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5351. // }
  5352. // // print_r($receiptList);
  5353. // // 获取审批日志
  5354. // Doo::loadModel ( 'receiptLog' );
  5355. // $receiptLog = new receiptLog ();
  5356. // $rlList = array ();
  5357. // $rlInfo = $receiptLog->getOne ( array (
  5358. // 'where' => 'rid=' . $rid . ' and status=4',
  5359. // 'asArray' => true
  5360. // ) );
  5361. // // $tijdate = $receiptLog->getOne ( array (
  5362. // // 'where' => 'rid=' . $rid . ' and status=2',
  5363. // // 'asc' => 'rlid',
  5364. // // 'asArray' => true
  5365. // // ) );
  5366. // if (! empty ( $rlInfo )) {
  5367. // $rlList = $receiptLog->find ( array (
  5368. // 'where' => 'rid=' . $rid,
  5369. // 'asc' => 'rlid',
  5370. // 'asArray' => true
  5371. // ) );
  5372. // }
  5373. // $RN=array();
  5374. // if (!empty( $rolename ['staff'])){
  5375. // $RN = @json_decode ( $rolename ['staff'] );
  5376. // }
  5377. // //
  5378. // foreach ( $rlList as $key => $value ) {
  5379. // $rlList [$key] ['rolename'] = '';
  5380. // foreach ( $RN as $k => $v ) {
  5381. // $id = explode ( "_", $v );
  5382. // if ($id [0] == $value ['uid']) {
  5383. // $rlList [$key] ['rolename'] = $FC;
  5384. // break;
  5385. // }
  5386. // }
  5387. // }
  5388. // Doo::loadModel ( 'enclosur' );
  5389. // $enclosur = new enclosur ();
  5390. // $enclosurList = $enclosur->find ( array (
  5391. // 'where' => 'rid=' . $rid,
  5392. // 'asArray' => true
  5393. // ) );
  5394. // $enclosurHtml = '';
  5395. // foreach ( $enclosurList as $value ) {
  5396. // $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5397. // }
  5398. // $data ['enclosurHtml'] = $enclosurHtml;
  5399. // $receiptList [0] ['rlList'] = $rlList;
  5400. // $data ['receiptList'] = $receiptList;
  5401. // // print_r($receiptList);
  5402. // $data ['memu'] = "receipt";
  5403. // $data ['staff'] = $this->staff;
  5404. // $data ['receiptMemu'] = 'approvalExpenses';
  5405. // $data ['verifyId'] = $this->verifyId;
  5406. // $data ['executeId'] = $this->executeId;
  5407. $this->render ( "/admin/expensesDoc", $data );
  5408. }
  5409. function expensesDocPrint(){
  5410. $data=$this->_expensesDoc();
  5411. $this->render ( "/receipt/expensesDocPrint", $data );
  5412. }
  5413. function expensesEdi() {
  5414. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5415. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5416. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5417. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5418. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5419. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5420. if (empty ( $status ))
  5421. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5422. $vidList = array ();
  5423. $button = 0;
  5424. Doo::loadModel ( 'verify' );
  5425. Doo::loadModel ( 'receipt' );
  5426. Doo::loadModel ( 'staff' );
  5427. $staff = new staff ();
  5428. $receipt = new receipt ();
  5429. $verify = new verify ();
  5430. Doo::loadModel ( 'L_category' );
  5431. $Lcategory = new L_category ();
  5432. Doo::loadModel ( 'enclosur' );
  5433. $enclosur = new enclosur ();
  5434. // user verify ID
  5435. $verifyDetail = $verify->find ( array (
  5436. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5437. 'asArray' => true
  5438. ) );
  5439. foreach ( $verifyDetail as $key => $value ) {
  5440. array_push ( $vidList, $value ['vid'] );
  5441. }
  5442. $vid = implode ( ",", $vidList );
  5443. if (empty ( $verifyDetail ))
  5444. $vid = 0;
  5445. $categoryList = $Lcategory->find ( array (
  5446. 'asArray' => true
  5447. ) );
  5448. $staffList = $staff->find ( array (
  5449. 'where' => 'cid=' . $cid,
  5450. 'asArray' => true
  5451. ) );
  5452. $ap = "";
  5453. if ($status == 4) {
  5454. $ap = 4;
  5455. $status = 2;
  5456. }
  5457. // get Receipt By verifyID status 2
  5458. $receiptList = $receipt->find ( array (
  5459. 'where' => 'rid =' . $rid . ' and status=2',
  5460. 'desc' => 'rid',
  5461. 'asArray' => true
  5462. ) );
  5463. if (empty ( $receiptList )) {
  5464. die ( 'illegal request' );
  5465. }
  5466. $Locate = 0;
  5467. $roleId = 0;
  5468. if ($ap == 4)
  5469. $status = 4;
  5470. foreach ( $receiptList as $key => $value ) {
  5471. $receiptList [$key] ['Locate'] = $Locate;
  5472. $Locate ++;
  5473. $receiptList [$key] ['reviseDetail'] = array ();
  5474. if (! empty ( $value ['reviseDetail'] ))
  5475. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5476. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5477. $categoryDetil = $Lcategory->getOne ( array (
  5478. 'where' => 'cid=' . $value ['cid'],
  5479. 'asArray' => true
  5480. ) );
  5481. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5482. // 检测编辑状态
  5483. $verifyList = $verify->getOne ( array (
  5484. 'where' => 'vid=' . $value ['verify'],
  5485. 'asArray' => true
  5486. ) );
  5487. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5488. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5489. Doo::loadModel ( 'role' );
  5490. $role = new role ();
  5491. // print_r($verifyList);
  5492. $flag = true;
  5493. $roleKey = 0;
  5494. $endStaffArray = array ();
  5495. $roleArrayCopy = array ();
  5496. foreach ( $verifyList as $k => $v ) {
  5497. // init verifyStaff
  5498. if ($v [1] == 'ROLE') {
  5499. if (! empty ( $verifyStaff )) {
  5500. $endStaffArray = end ( $verifyStaff );
  5501. if ($v [0] == $endStaffArray ['nextStaff']) {
  5502. $roleId = $v [0];
  5503. }
  5504. }
  5505. $roleVerify = json_decode ( $v [3], true );
  5506. $roleKey = $k;
  5507. $roleArray = array ();
  5508. $rolename = $role->getOne ( array (
  5509. 'where' => 'rid=' . $v [0],
  5510. 'asArray' => true
  5511. ) );
  5512. foreach ( $roleVerify as $o => $p ) {
  5513. $staffID = explode ( '_', $p );
  5514. $staffInfo = $staff->getOne ( array (
  5515. 'where' => 'sid=' . $staffID [0],
  5516. 'asArray' => true
  5517. ) );
  5518. // print_r($staffID);
  5519. $exp = array (
  5520. 0 => $staffInfo ['sid'],
  5521. 1 => $staffID [1],
  5522. 2 => $staffInfo ['avatar'],
  5523. 'date' => '',
  5524. 'date' => '',
  5525. 'opinion' => '',
  5526. 'status' => '',
  5527. 'rolename' => $rolename ['name']
  5528. );
  5529. array_push ( $roleArray, $exp );
  5530. }
  5531. $roleArrayCopy [$v [0]] = $roleArray;
  5532. // $verifyList[$k]['roleArray']=$roleArray;
  5533. }
  5534. // print_r($roleArray);
  5535. $verifyList [$k] ['date'] = "";
  5536. $verifyList [$k] ['opinion'] = "";
  5537. $verifyList [$k] ['status'] = "";
  5538. if (empty ( $verifyStaff )) {
  5539. $verifyList [$k] ['date'] = "";
  5540. $verifyList [$k] ['opinion'] = "";
  5541. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5542. $verifyList [$k] ['status'] = 4;
  5543. $button = 4;
  5544. $flag = false;
  5545. }
  5546. } else {
  5547. foreach ( $verifyStaff as $m => $u ) {
  5548. if ($v [0] == $m) {
  5549. $verifyList [$k] ['date'] = $u ['date'];
  5550. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5551. $verifyList [$k] ['status'] = $u ['status'];
  5552. $flag = false;
  5553. break;
  5554. }
  5555. }
  5556. $endStaffArray = end ( $verifyStaff );
  5557. if (isset ( $endStaffArray ['ROLE'] )) {
  5558. } else {
  5559. $endKey = key ( $verifyStaff );
  5560. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5561. $button = 4;
  5562. $verifyList [$k] ['status'] = 4;
  5563. }
  5564. }
  5565. }
  5566. }
  5567. $rolename ['name'] = '';
  5568. if (! empty ( $roleId )) {
  5569. Doo::loadModel ( 'role' );
  5570. $role = new role ();
  5571. $rolename = $role->getOne ( array (
  5572. 'where' => 'rid=' . $roleId,
  5573. 'asArray' => true
  5574. ) );
  5575. }
  5576. if (! empty ( $verifyStaff ))
  5577. $endStaffArray = end ( $verifyStaff );
  5578. $KOP = false;
  5579. foreach ( $roleArrayCopy as $P => $A ) {
  5580. foreach ( $A as $MKI => $AVL ) {
  5581. if (! empty ( $verifyStaff )) {
  5582. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5583. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5584. $button = 4;
  5585. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5586. }
  5587. foreach ( $verifyStaff as $m => $u ) {
  5588. $AVLFK = $AVL [0] . '_R';
  5589. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5590. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5591. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5592. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5593. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5594. break;
  5595. }
  5596. }
  5597. } else {
  5598. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5599. $button = 4;
  5600. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5601. }
  5602. }
  5603. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5604. $KOP = true;
  5605. }
  5606. }
  5607. // print_r($roleArrayCopy);
  5608. // echo $roleKey;
  5609. foreach ( $roleArrayCopy as $k => $v ) {
  5610. foreach ( $verifyList as $m => $n ) {
  5611. if ($n [0] == $k) {
  5612. array_splice ( $verifyList, $m, 1, $v );
  5613. }
  5614. }
  5615. }
  5616. $receiptList [$key] ['verifyList'] = $verifyList;
  5617. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5618. 'where' => 'sid=' . $value ['staff'],
  5619. 'asArray' => true
  5620. ) );
  5621. $receiptList [$key] ['button'] = $button;
  5622. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5623. }
  5624. // $data['verifyDetail']=$verifyDetail;
  5625. $mothHtml = "";
  5626. for($i = 1; $i <= 12; $i ++) {
  5627. if ($month == $i)
  5628. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5629. else
  5630. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5631. }
  5632. // 获取审批日志
  5633. Doo::loadModel ( 'receiptLog' );
  5634. $receiptLog = new receiptLog ();
  5635. $rlList = array ();
  5636. $rlInfo = $receiptLog->getOne ( array (
  5637. 'where' => 'rid=' . $rid . ' and status=4',
  5638. 'asArray' => true
  5639. ) );
  5640. $tijdate = $receiptLog->getOne ( array (
  5641. 'where' => 'rid=' . $rid . ' and status=2',
  5642. 'asc' => 'rlid',
  5643. 'asArray' => true
  5644. ) );
  5645. if (! empty ( $rlInfo )) {
  5646. $rlList = $receiptLog->find ( array (
  5647. 'where' => 'rid=' . $rid,
  5648. 'asc' => 'rlid',
  5649. 'asArray' => true
  5650. ) );
  5651. }
  5652. $receiptList [0] ['rlList'] = $rlList;
  5653. $enclosurList = $enclosur->find ( array (
  5654. 'where' => 'rid=' . $rid,
  5655. 'asArray' => true
  5656. ) );
  5657. $enclosurHtml = '';
  5658. foreach ( $enclosurList as $value ) {
  5659. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5660. }
  5661. // print_r($receiptList);
  5662. $data ['rid'] = $rid;
  5663. $data ['enclosurHtml'] = $enclosurHtml;
  5664. $data ['rolename'] = $rolename ['name'];
  5665. $data ['datetij'] = $tijdate ['date'];
  5666. $data ['mothHtml'] = $mothHtml;
  5667. $data ['receiptList'] = $receiptList;
  5668. $data ['receiptApprovalCount'] = count ( $receiptList );
  5669. $data ['status'] = $status;
  5670. $data ['year'] = $year;
  5671. $data ['categoryList'] = $categoryList;
  5672. $data ['staffList'] = $staffList;
  5673. $data ['cid'] = $cid;
  5674. $data ['sid'] = $sid;
  5675. $data ['ap'] = $ap;
  5676. $data ['memu'] = "receipt";
  5677. $data ['staff'] = $this->staff;
  5678. $data ['receiptMemu'] = 'approvalExpenses';
  5679. $data ['verifyId'] = $this->verifyId;
  5680. $data ['executeId'] = $this->executeId;
  5681. $this->render ( "/admin/expensesEdi", $data );
  5682. }
  5683. function expensesDefray() {
  5684. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5685. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5686. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5687. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5688. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5689. if (! empty ( $rid )) {
  5690. Doo::loadModel ( "verify" );
  5691. $verify = new verify ();
  5692. Doo::loadModel ( "receiptDetail" );
  5693. $receiptDetailObj = new receiptDetail ();
  5694. Doo::loadModel ( "itemStatistics" );
  5695. Doo::loadModel ( "statistics" );
  5696. $statistics = new statistics ();
  5697. $itemStatistics = new itemStatistics ();
  5698. Doo::loadModel ( "receipt" );
  5699. $receipt = new receipt ();
  5700. Doo::loadModel ( "loanReceipt" );
  5701. $loanReceipt = new loanReceipt ();
  5702. $receiptDetail = $receipt->getOne ( array (
  5703. 'where' => 'rid=' . $rid . ' and status=2 ',
  5704. 'asArray' => true
  5705. ) );
  5706. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5707. $nsflag = true;
  5708. foreach ( $nslist as $value ) {
  5709. if ($value == $this->staff ['0'] ['sid']) {
  5710. $nsflag = false;
  5711. break;
  5712. }
  5713. }
  5714. // print_r($nslist);die;
  5715. if (empty ( $receiptDetail ) || $nsflag)
  5716. return "/approvalExpenses/pendApproval";
  5717. $verifyDetail = $verify->getOne ( array (
  5718. 'where' => ' vid =' . $receiptDetail ['verify'],
  5719. 'asArray' => true
  5720. ) );
  5721. $verifyString = $verifyDetail ['staff'];
  5722. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5723. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5724. if (empty ( $opinion )) {
  5725. if ($status == 3)
  5726. $opinion = "终止";
  5727. else
  5728. $opinion = "同意支付";
  5729. }
  5730. $nowStaff = 0;
  5731. $nowStaffList = array ();
  5732. if (empty ( $verifyStaff )) {
  5733. // 还需加入是否已经进入角色审批
  5734. if ($verifyDetail [0] [1] == 'ROLE') {
  5735. // print_r($verifyDetail);echo "ddd";
  5736. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5737. foreach ( $vStaffString as $key => $value ) {
  5738. $staffK = explode ( "_", $value );
  5739. if ($staffK [0] != $this->staff [0] ['sid'])
  5740. array_push ( $nowStaffList, $staffK [0] );
  5741. }
  5742. // print_r($verifyDetail);
  5743. // die;
  5744. if (! empty ( $nowStaffList )) {
  5745. $nowStaff = implode ( ',', $nowStaffList );
  5746. $verifyStaff = array (
  5747. $this->staff [0] ['sid'] . "_R" => array (
  5748. 'date' => date ( 'Y-m-d' ),
  5749. 'opinion' => $opinion,
  5750. 'status' => $status,
  5751. 'nextStaff' => $verifyDetail [0] [0],
  5752. 'ROLE' => 1
  5753. )
  5754. );
  5755. } else {
  5756. $nowStaff = $verifyDetail [1] [0];
  5757. $verifyStaff = array (
  5758. $this->staff [0] ['sid'] . "_R" => array (
  5759. 'date' => date ( 'Y-m-d' ),
  5760. 'opinion' => $opinion,
  5761. 'status' => $status,
  5762. 'nextStaff' => $verifyDetail [1] [0]
  5763. )
  5764. );
  5765. }
  5766. } else {
  5767. if ($verifyDetail [1] [1] == 'ROLE') {
  5768. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5769. // echo "dd";
  5770. foreach ( $vStaffString as $key => $value ) {
  5771. $staffK = explode ( "_", $value );
  5772. array_push ( $nowStaffList, $staffK [0] );
  5773. }
  5774. $nowStaff = implode ( ',', $nowStaffList );
  5775. $verifyStaff = array (
  5776. $this->staff [0] ['sid'] => array (
  5777. 'date' => date ( 'Y-m-d' ),
  5778. 'opinion' => $opinion,
  5779. 'status' => $status,
  5780. 'nextStaff' => $verifyDetail [1] [0],
  5781. 'ROLE' => 1
  5782. )
  5783. );
  5784. } else {
  5785. $nowStaff = $verifyDetail [1] [0];
  5786. $verifyStaff = array (
  5787. $this->staff [0] ['sid'] => array (
  5788. 'date' => date ( 'Y-m-d' ),
  5789. 'opinion' => $opinion,
  5790. 'status' => $status,
  5791. 'nextStaff' => $verifyDetail [1] [0]
  5792. )
  5793. );
  5794. }
  5795. }
  5796. if ($status == 3)
  5797. $verifyStaff = array (
  5798. 'final' => $status,
  5799. $this->staff [0] ['sid'] => array (
  5800. 'date' => date ( 'Y-m-d' ),
  5801. 'opinion' => $opinion,
  5802. 'status' => $status
  5803. )
  5804. );
  5805. $vStaffString = json_encode ( $verifyStaff );
  5806. $receipt->nowStaff = $nowStaff;
  5807. $receipt->verifyStaff = $vStaffString;
  5808. $loanReceipt->nowStaff = $nowStaff;
  5809. $loanReceipt->verifyStaff = $vStaffString;
  5810. } else {
  5811. $VS = end ( $verifyStaff );
  5812. // 非角色审批
  5813. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5814. $nextStaff = 0;
  5815. $roleSTF = false;
  5816. foreach ( $verifyDetail as $key => $value ) {
  5817. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5818. if (isset ( $verifyDetail [$key + 1] )) {
  5819. $nextStaff = $verifyDetail [$key + 1] [0];
  5820. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5821. $roleSTF = true;
  5822. }
  5823. break;
  5824. }
  5825. }
  5826. if (! $roleSTF) {
  5827. $nowStaff = $nextStaff;
  5828. $verifyStaff [$this->staff [0] ['sid']] = array (
  5829. 'date' => date ( 'Y-m-d' ),
  5830. 'opinion' => $opinion,
  5831. 'status' => $status,
  5832. 'nextStaff' => $nextStaff
  5833. );
  5834. } else {
  5835. // 获取角色下的所有用户ID
  5836. $nowStaffList = array ();
  5837. foreach ( $verifyDetail as $vfk ) {
  5838. if ($vfk [1] == 'ROLE') {
  5839. $vStaffString = json_decode ( $vfk [3] );
  5840. foreach ( $vStaffString as $key => $value ) {
  5841. $staffK = explode ( "_", $value );
  5842. array_push ( $nowStaffList, $staffK [0] );
  5843. }
  5844. }
  5845. }
  5846. $nowStaff = implode ( ',', $nowStaffList );
  5847. $verifyStaff [$this->staff [0] ['sid']] = array (
  5848. 'date' => date ( 'Y-m-d' ),
  5849. 'opinion' => $opinion,
  5850. 'status' => $status,
  5851. 'nextStaff' => $nextStaff,
  5852. 'ROLE' => 0
  5853. );
  5854. }
  5855. if ($status == 3) {
  5856. $verifyStaff ['final'] = $status;
  5857. $verifyStaff [$this->staff [0] ['sid']] = array (
  5858. 'date' => date ( 'Y-m-d' ),
  5859. 'opinion' => $opinion,
  5860. 'status' => $status
  5861. );
  5862. }
  5863. $vStaffString = json_encode ( $verifyStaff );
  5864. $receipt->nowStaff = $nowStaff;
  5865. $receipt->verifyStaff = $vStaffString;
  5866. $loanReceipt->nowStaff = $nowStaff;
  5867. $loanReceipt->verifyStaff = $vStaffString;
  5868. }
  5869. // 角色审批
  5870. if (isset ( $VS ['ROLE'] )) {
  5871. // 找出角色人 当前审批角色组
  5872. $verifyJSStaff = array ();
  5873. $nowStaffList2 = array ();
  5874. foreach ( $verifyDetail as $key => $value ) {
  5875. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5876. $verifyJSStaff = json_decode ( $value [3] );
  5877. foreach ( $verifyJSStaff as $m ) {
  5878. $staffK = explode ( "_", $m );
  5879. array_push ( $nowStaffList2, $staffK [0] );
  5880. }
  5881. // print_r($nowStaffList2);
  5882. }
  5883. }
  5884. $RoleVerifyStaff = array ();
  5885. foreach ( $verifyStaff as $key => $value ) {
  5886. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5887. foreach ( $nowStaffList2 as $m ) {
  5888. if ($key == $m . "_R")
  5889. $RoleVerifyStaff [$key] = $value;
  5890. }
  5891. }
  5892. }
  5893. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5894. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5895. // 下一个审批人ID
  5896. $nextStaff = 0;
  5897. $falg = false;
  5898. foreach ( $verifyDetail as $key => $value ) {
  5899. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5900. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5901. $falg = true;
  5902. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5903. $nowStaffList = array ();
  5904. foreach ( $vStaffString as $v ) {
  5905. $staffK = explode ( "_", $v );
  5906. array_push ( $nowStaffList, $staffK [0] );
  5907. }
  5908. $nowStaff = implode ( ',', $nowStaffList );
  5909. $nextStaff = $verifyDetail [$key + 1] [0];
  5910. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5911. $nextStaff = $verifyDetail [$key + 1] [0];
  5912. $nowStaff = $nextStaff;
  5913. } else
  5914. $nowStaff = '';
  5915. break;
  5916. }
  5917. }
  5918. if ($falg)
  5919. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5920. 'date' => date ( 'Y-m-d' ),
  5921. 'opinion' => $opinion,
  5922. 'status' => $status,
  5923. 'nextStaff' => $nextStaff,
  5924. 'ROLE' => 1
  5925. );
  5926. else
  5927. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5928. 'date' => date ( 'Y-m-d' ),
  5929. 'opinion' => $opinion,
  5930. 'status' => $status,
  5931. 'nextStaff' => $nextStaff
  5932. );
  5933. // print_r($verifyStaff);
  5934. // echo $nowStaff;die;
  5935. } else { // 进入下一个角色或者审批人
  5936. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5937. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5938. 'date' => date ( 'Y-m-d' ),
  5939. 'opinion' => $opinion,
  5940. 'status' => $status,
  5941. 'nextStaff' => $VS ['nextStaff'],
  5942. 'ROLE' => 1
  5943. );
  5944. }
  5945. if ($status == 3) {
  5946. $verifyStaff ['final'] = $status;
  5947. $verifyStaff [$this->staff [0] ['sid']] = array (
  5948. 'date' => date ( 'Y-m-d' ),
  5949. 'opinion' => $opinion,
  5950. 'status' => $status
  5951. );
  5952. }
  5953. $vStaffString = json_encode ( $verifyStaff );
  5954. $receipt->verifyStaff = $vStaffString;
  5955. $receipt->nowStaff = $nowStaff;
  5956. $loanReceipt->nowStaff = $nowStaff;
  5957. $loanReceipt->verifyStaff = $vStaffString;
  5958. }
  5959. // print_r($verifyStaff);die;
  5960. }
  5961. $roleKey = 0;
  5962. $roleId = 0;
  5963. $verifyDetailCopy = array ();
  5964. foreach ( $verifyDetail as $k => $v ) {
  5965. if ($v [1] == 'ROLE') {
  5966. $roleId = $v [0];
  5967. $roleVerify = json_decode ( $v [3], true );
  5968. $roleKey = $k;
  5969. $roleArray = array ();
  5970. foreach ( $roleVerify as $o => $p ) {
  5971. $staffID = explode ( '_', $p );
  5972. $exp = array (
  5973. 0 => $staffID [0],
  5974. 1 => $staffID [1]
  5975. );
  5976. array_push ( $roleArray, $exp );
  5977. }
  5978. $verifyDetailCopy [$v [0]] = $roleArray;
  5979. }
  5980. }
  5981. // print_r($verifyDetail);
  5982. foreach ( $verifyDetailCopy as $k => $v ) {
  5983. foreach ( $verifyDetail as $m => $n ) {
  5984. if ($n [0] == $k) {
  5985. array_splice ( $verifyDetail, $m, 1, $v );
  5986. }
  5987. }
  5988. }
  5989. // 审批日志
  5990. if (! isset ( $verifyStaff ['final'] )) {
  5991. Doo::loadModel ( "receiptLog" );
  5992. $receiptLog = new receiptLog ();
  5993. if (! empty ( $roleId )) {
  5994. Doo::loadModel ( "role" );
  5995. $role = new role ();
  5996. $roleInfo = $role->getOne ( array (
  5997. 'where' => 'rid=' . $roleId,
  5998. 'asArray' => true
  5999. ) );
  6000. $receiptLog->rolename = $roleInfo ['name'];
  6001. }
  6002. $receiptLog->username = $this->staff [0] ['username'];
  6003. $receiptLog->uid = $this->staff [0] ['sid'];
  6004. $receiptLog->date = date ( "Y-m-d" );
  6005. $receiptLog->opinion = $opinion;
  6006. $receiptLog->img = $this->staff [0] ['avatar'];
  6007. $receiptLog->status = 1;
  6008. $receiptLog->rid = $rid;
  6009. $receiptLog->insert ();
  6010. }
  6011. if (isset ( $verifyStaff ['final'] )) { // rDetail
  6012. $receipt->status = 3;
  6013. $receipt->verifyBreakup = $verifyString;
  6014. $receiptDetailObj->status = 3;
  6015. $receiptDetailObj->update ( array (
  6016. 'where' => 'rid=' . $rid
  6017. ) );
  6018. // 微信企业号通知
  6019. $this->setWXMsg ( $rid, 3 );
  6020. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  6021. $receipt->status = 6;
  6022. $receipt->pastDate = date ( "Y-m-d" );
  6023. $receipt->isBK = 1;
  6024. $loanReceipt->verifyBreakup = $verifyString;
  6025. $loanReceipt->status = 1;
  6026. $loanReceipt->pastDate = date ( "Y-m-d" );
  6027. //生成流水后 不更新汇款金额
  6028. Doo::loadModel ( 'wasteBook' );
  6029. $wasteBook = new wasteBook ();
  6030. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  6031. if (empty($wbDetail)){
  6032. $loanReceipt->amount = $receiptDetail ['amount'];
  6033. }
  6034. $loanReceipt->update ( array (
  6035. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  6036. ) );
  6037. // 微信企业号通知
  6038. $this->setWXMsg ( $rid, 1 );
  6039. }
  6040. $receipt->amount = $receiptDetail['sum'];
  6041. $receipt->update ( array (
  6042. 'where' => ' rid = ' . $rid
  6043. ) );
  6044. // 进入下一条审批费用新加需求
  6045. $vidList = array ();
  6046. $verifyDetail = $verify->find ( array (
  6047. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  6048. 'asArray' => true
  6049. ) );
  6050. foreach ( $verifyDetail as $key => $value ) {
  6051. array_push ( $vidList, $value ['vid'] );
  6052. }
  6053. $vid = implode ( ",", $vidList );
  6054. if (empty ( $verifyDetail ))
  6055. $vid = 0;
  6056. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  6057. $receipt = new receipt ();
  6058. $rd = $receipt->getOne ( array (
  6059. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  6060. 'asc' => 'rid',
  6061. 'asArray' => true
  6062. ) );
  6063. if (empty ( $rd )) {
  6064. return '/approvalExpenses/pendApproval';
  6065. }
  6066. if ($rd ['Rtype'] == 1) {
  6067. if ($rd ['isBK'] == 1) {
  6068. return '/receiptburEdi/' . $rd ['rid'];
  6069. } else {
  6070. return '/expensesEdi/' . $rd ['rid'];
  6071. }
  6072. } elseif ($rd ['Rtype'] == 2) {
  6073. return '/remitApproval/' . $rd ['rid'];
  6074. } else {
  6075. return '/receiptburEdi/' . $rd ['rid'];
  6076. }
  6077. // return "/approvalExpenses/pendApproval";
  6078. }
  6079. }
  6080. function ajaxExamineExe() {
  6081. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6082. Doo::loadModel ( 'receipt' );
  6083. $receipt = new receipt ();
  6084. Doo::loadClass ( 'XDeode' );
  6085. $XDeode = new XDeode ( 5 );
  6086. if (! empty ( $rid )) {
  6087. $rLRes = $receipt->find ( array (
  6088. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  6089. 'asArray' => true
  6090. ) );
  6091. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  6092. echo json_encode ( array (
  6093. 'status' => 1,
  6094. 'receipt' => $rLRes [0]
  6095. ) );
  6096. die ();
  6097. }
  6098. echo json_encode ( array (
  6099. 'status' => 0,
  6100. 'receipt' => array ()
  6101. ) );
  6102. die ();
  6103. }
  6104. function implement() {
  6105. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6106. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  6107. Doo::loadClass ( 'XDeode' );
  6108. $XDeode = new XDeode ( 5 );
  6109. Doo::loadModel ( 'receipt' );
  6110. $receipt = new receipt ();
  6111. Doo::loadModel ( 'L_category' );
  6112. $Lcategory = new L_category ();
  6113. Doo::loadModel ( 'verify' );
  6114. $verify = new verify ();
  6115. Doo::loadModel ( 'staff' );
  6116. $staff = new staff ();
  6117. Doo::loadModel ( "execute" );
  6118. $execute = new execute ();
  6119. $rid = $XDeode->decode ( $rid );
  6120. $receiptList = $receipt->find ( array (
  6121. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  6122. 'desc' => 'rid',
  6123. 'asArray' => true
  6124. ) );
  6125. Doo::loadModel ( 'loanReceipt' );
  6126. $loanReceipt = new loanReceipt ();
  6127. // print_r($receiptList);
  6128. $loanList = array ();
  6129. if (! isset ( $receiptList ))
  6130. $loanList = $loanReceipt->find ( array (
  6131. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6132. 'desc' => 'rid',
  6133. 'asArray' => true
  6134. ) );
  6135. $Locate = 0;
  6136. $roleId = 0;
  6137. $button = 0;
  6138. foreach ( $loanList as $key => $value ) {
  6139. $loanList [$key] ['Locate'] = $Locate;
  6140. $Locate ++;
  6141. $loanList [$key] ['reviseDetail'] = array ();
  6142. if (! empty ( $value ['reviseDetail'] ))
  6143. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6144. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6145. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6146. $categoryDetil = $Lcategory->getOne ( array (
  6147. 'where' => 'cid=' . $value ['cid'],
  6148. 'asArray' => true
  6149. ) );
  6150. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6151. // 检测编辑状态
  6152. $verifyList = $verify->getOne ( array (
  6153. 'where' => 'vid=' . $value ['verify'],
  6154. 'asArray' => true
  6155. ) );
  6156. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6157. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6158. Doo::loadModel ( 'role' );
  6159. $role = new role ();
  6160. $flag = true;
  6161. $roleKey = 0;
  6162. $endStaffArray = array ();
  6163. $roleArrayCopy = array ();
  6164. foreach ( $verifyList as $k => $v ) {
  6165. // init verifyStaff
  6166. if ($v [1] == 'ROLE') {
  6167. if (! empty ( $verifyStaff )) {
  6168. $endStaffArray = end ( $verifyStaff );
  6169. // if ($v[0]==$endStaffArray['nextStaff']){
  6170. // $roleId=$v[0];
  6171. // }
  6172. }
  6173. $roleVerify = json_decode ( $v [3], true );
  6174. $roleKey = $k;
  6175. $roleArray = array ();
  6176. $rolename = $role->getOne ( array (
  6177. 'where' => 'rid=' . $v [0],
  6178. 'asArray' => true
  6179. ) );
  6180. foreach ( $roleVerify as $o => $p ) {
  6181. $staffID = explode ( '_', $p );
  6182. $staffInfo = $staff->getOne ( array (
  6183. 'where' => 'sid=' . $staffID [0],
  6184. 'asArray' => true
  6185. ) );
  6186. // print_r($staffID);
  6187. $exp = array (
  6188. 0 => $staffInfo ['sid'],
  6189. 1 => $staffID [1],
  6190. 2 => $staffInfo ['avatar'],
  6191. 'date' => '',
  6192. 'date' => '',
  6193. 'opinion' => '',
  6194. 'status' => '',
  6195. 'rolename' => $rolename ['name']
  6196. );
  6197. array_push ( $roleArray, $exp );
  6198. }
  6199. $roleArrayCopy [$v [0]] = $roleArray;
  6200. // $verifyList[$k]['roleArray']=$roleArray;
  6201. }
  6202. $verifyList [$k] ['date'] = "";
  6203. $verifyList [$k] ['opinion'] = "";
  6204. $verifyList [$k] ['status'] = "";
  6205. if (empty ( $verifyStaff )) {
  6206. $verifyList [$k] ['date'] = "";
  6207. $verifyList [$k] ['opinion'] = "";
  6208. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6209. $verifyList [$k] ['status'] = 4;
  6210. $flag = false;
  6211. }
  6212. } else {
  6213. foreach ( $verifyStaff as $m => $u ) {
  6214. if ($v [0] == $m) {
  6215. $verifyList [$k] ['date'] = $u ['date'];
  6216. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6217. $verifyList [$k] ['status'] = $u ['status'];
  6218. $flag = false;
  6219. break;
  6220. }
  6221. }
  6222. $endStaffArray = end ( $verifyStaff );
  6223. if (isset ( $endStaffArray ['ROLE'] )) {
  6224. } else {
  6225. // $endKey=key($verifyStaff);
  6226. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6227. // $button=4;
  6228. // $verifyList[$k]['status']=4;
  6229. // }
  6230. }
  6231. }
  6232. }
  6233. $rolename ['name'] = '';
  6234. if (! empty ( $roleId )) {
  6235. Doo::loadModel ( 'role' );
  6236. $role = new role ();
  6237. $rolename = $role->getOne ( array (
  6238. 'where' => 'rid=' . $roleId,
  6239. 'asArray' => true
  6240. ) );
  6241. }
  6242. if (! empty ( $verifyStaff ))
  6243. $endStaffArray = end ( $verifyStaff );
  6244. $KOP = false;
  6245. foreach ( $roleArrayCopy as $P => $A ) {
  6246. foreach ( $A as $MKI => $AVL ) {
  6247. if (! empty ( $verifyStaff )) {
  6248. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6249. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6250. $button = 4;
  6251. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6252. }
  6253. foreach ( $verifyStaff as $m => $u ) {
  6254. $AVLFK = $AVL [0] . '_R';
  6255. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6256. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6257. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6258. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6259. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6260. break;
  6261. }
  6262. }
  6263. } else {
  6264. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6265. $button = 4;
  6266. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6267. }
  6268. }
  6269. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6270. $KOP = true;
  6271. }
  6272. }
  6273. foreach ( $roleArrayCopy as $k => $v ) {
  6274. foreach ( $verifyList as $m => $n ) {
  6275. if ($n [0] == $k) {
  6276. array_splice ( $verifyList, $m, 1, $v );
  6277. }
  6278. }
  6279. }
  6280. $loanList [$key] ['verifyList'] = $verifyList;
  6281. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6282. 'where' => 'sid=' . $value ['staff'],
  6283. 'asArray' => true
  6284. ) );
  6285. }
  6286. $data ['loanList'] = $loanList;
  6287. $Locate = 0;
  6288. $roleId = 0;
  6289. $button = 0;
  6290. Doo::loadClass ( 'XDeode' );
  6291. $XDeode = new XDeode ( 5 );
  6292. foreach ( $receiptList as $key => $value ) {
  6293. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6294. $button2 = 0;
  6295. $receiptList [$key] ['Locate'] = $Locate;
  6296. $Locate ++;
  6297. $receiptList [$key] ['reviseDetail'] = array ();
  6298. if (! empty ( $value ['reviseDetail'] ))
  6299. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6300. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6301. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6302. $categoryDetil = $Lcategory->getOne ( array (
  6303. 'where' => 'cid=' . $value ['cid'],
  6304. 'asArray' => true
  6305. ) );
  6306. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6307. $executeList = json_decode ( $value ['executeCopy'], true );
  6308. $executeStaff = array ();
  6309. if (! empty ( $value ['executeStaff'] ))
  6310. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6311. if (isset ( $executeList )) {
  6312. foreach ( $executeList as $op => $lo ) {
  6313. $executeList [$op] ['date'] = "";
  6314. $executeList [$op] ['opinion'] = "";
  6315. $executeList [$op] ['status'] = "";
  6316. foreach ( $executeStaff as $m => $u ) {
  6317. if ($lo [0] == $m) {
  6318. $executeList [$op] ['date'] = $u ['date'];
  6319. $executeList [$op] ['opinion'] = $u ['opinion'];
  6320. $executeList [$op] ['status'] = $u ['status'];
  6321. break;
  6322. }
  6323. }
  6324. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6325. $button2 = 1;
  6326. $executeList [$op] ['status'] = 4;
  6327. }
  6328. }
  6329. }
  6330. // 检测编辑状态
  6331. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6332. $verifyList ['staff'] = $value ['verifyBreakup'];
  6333. } else
  6334. $verifyList = $verify->getOne ( array (
  6335. 'where' => 'vid=' . $value ['verify'],
  6336. 'asArray' => true
  6337. ) );
  6338. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6339. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6340. Doo::loadModel ( 'role' );
  6341. $role = new role ();
  6342. if ($verifyList == NULL)
  6343. $verifyList = array ();
  6344. $flag = true;
  6345. $roleKey = 0;
  6346. $endStaffArray = array ();
  6347. $roleArrayCopy = array ();
  6348. foreach ( $verifyList as $k => $v ) {
  6349. // init verifyStaff
  6350. if ($v [1] == 'ROLE') {
  6351. if (! empty ( $verifyStaff )) {
  6352. $endStaffArray = end ( $verifyStaff );
  6353. // if ($v[0]==$endStaffArray['nextStaff']){
  6354. // $roleId=$v[0];
  6355. // }
  6356. }
  6357. $roleVerify = json_decode ( $v [3], true );
  6358. $roleKey = $k;
  6359. $roleArray = array ();
  6360. $rolename = $role->getOne ( array (
  6361. 'where' => 'rid=' . $v [0],
  6362. 'asArray' => true
  6363. ) );
  6364. foreach ( $roleVerify as $o => $p ) {
  6365. $staffID = explode ( '_', $p );
  6366. $staffInfo = $staff->getOne ( array (
  6367. 'where' => 'sid=' . $staffID [0],
  6368. 'asArray' => true
  6369. ) );
  6370. // print_r($staffID);
  6371. $exp = array (
  6372. 0 => $staffInfo ['sid'],
  6373. 1 => $staffID [1],
  6374. 2 => $staffInfo ['avatar'],
  6375. 'date' => '',
  6376. 'date' => '',
  6377. 'opinion' => '',
  6378. 'status' => '',
  6379. 'rolename' => $rolename ['name']
  6380. );
  6381. array_push ( $roleArray, $exp );
  6382. }
  6383. $roleArrayCopy [$v [0]] = $roleArray;
  6384. // $verifyList[$k]['roleArray']=$roleArray;
  6385. }
  6386. $verifyList [$k] ['date'] = "";
  6387. $verifyList [$k] ['opinion'] = "";
  6388. $verifyList [$k] ['status'] = "";
  6389. if (empty ( $verifyStaff )) {
  6390. $verifyList [$k] ['date'] = "";
  6391. $verifyList [$k] ['opinion'] = "";
  6392. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6393. $verifyList [$k] ['status'] = 4;
  6394. $flag = false;
  6395. }
  6396. } else {
  6397. foreach ( $verifyStaff as $m => $u ) {
  6398. if ($v [0] == $m) {
  6399. $verifyList [$k] ['date'] = $u ['date'];
  6400. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6401. $verifyList [$k] ['status'] = $u ['status'];
  6402. $flag = false;
  6403. break;
  6404. }
  6405. }
  6406. $endStaffArray = end ( $verifyStaff );
  6407. if (isset ( $endStaffArray ['ROLE'] )) {
  6408. } else {
  6409. // $endKey=key($verifyStaff);
  6410. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6411. // $button=4;
  6412. // $verifyList[$k]['status']=4;
  6413. // }
  6414. }
  6415. }
  6416. }
  6417. $rolename ['name'] = '';
  6418. if (! empty ( $roleId )) {
  6419. Doo::loadModel ( 'role' );
  6420. $role = new role ();
  6421. $rolename = $role->getOne ( array (
  6422. 'where' => 'rid=' . $roleId,
  6423. 'asArray' => true
  6424. ) );
  6425. }
  6426. if (! empty ( $verifyStaff ))
  6427. $endStaffArray = end ( $verifyStaff );
  6428. $KOP = false;
  6429. foreach ( $roleArrayCopy as $P => $A ) {
  6430. foreach ( $A as $MKI => $AVL ) {
  6431. if (! empty ( $verifyStaff )) {
  6432. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6433. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6434. $button = 4;
  6435. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6436. }
  6437. foreach ( $verifyStaff as $m => $u ) {
  6438. $AVLFK = $AVL [0] . '_R';
  6439. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6440. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6441. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6442. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6443. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6444. break;
  6445. }
  6446. }
  6447. } else {
  6448. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6449. $button = 4;
  6450. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6451. }
  6452. }
  6453. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6454. $KOP = true;
  6455. }
  6456. }
  6457. foreach ( $roleArrayCopy as $k => $v ) {
  6458. foreach ( $verifyList as $m => $n ) {
  6459. if ($n [0] == $k) {
  6460. array_splice ( $verifyList, $m, 1, $v );
  6461. }
  6462. }
  6463. }
  6464. $receiptList [$key] ['verifyList'] = $verifyList;
  6465. $receiptList [$key] ['executeList'] = $executeList;
  6466. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6467. 'where' => 'sid=' . $value ['staff'],
  6468. 'asArray' => true
  6469. ) );
  6470. $receiptList [$key] ['button2'] = $button2;
  6471. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6472. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6473. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6474. $receiptList [$key] ['relust'] = $relust;
  6475. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6476. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6477. }
  6478. //执行人是否是最后一位
  6479. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6480. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6481. $executePrimary=count($executeCopy)-1;
  6482. $lastOne=true;
  6483. if($executePrimary!=count($executeStaff)){
  6484. $lastOne=false;
  6485. }
  6486. $data['lastOne']=$lastOne;
  6487. // 是否写入过流水
  6488. $accountType = 0;
  6489. if ($receiptList [0] ['Rtype'] == 0) {
  6490. $accountType = 3;
  6491. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6492. if (!empty($receiptList [0]['accountItem']) )
  6493. $accountType = 2;
  6494. else
  6495. $accountType = 1;
  6496. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6497. $accountType = 4;
  6498. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6499. $accountType = 12;
  6500. }
  6501. Doo::loadModel ( 'wasteBook' );
  6502. $wasteBook = new wasteBook ();
  6503. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6504. $data ['wbDetail'] = $wbDetail;
  6505. $wbDetailLoan=array();
  6506. if ($accountType==2){
  6507. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6508. }
  6509. $data ['wbDetailLoan'] = $wbDetailLoan;
  6510. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6511. //print_r($wbDetail);
  6512. $data ['receiptList'] = $receiptList;
  6513. $data ['memu'] = "receipt";
  6514. $data ['staff'] = $this->staff;
  6515. $data ['receiptMemu'] = 'implement';
  6516. $data ['verifyId'] = $this->verifyId;
  6517. $data ['executeId'] = $this->executeId;
  6518. if ($Rtype=="loan"){
  6519. $this->render ( "/receipt/receiptImplementLoan", $data );
  6520. }elseif($Rtype=="receipt"){
  6521. if($receiptList[0]['receiptClass']==2){
  6522. $this->render ( "/receipt/receiptImplementTrave", $data );
  6523. }else{
  6524. $this->render ( "/receipt/receiptImplement", $data );
  6525. }
  6526. }elseif($Rtype=="public"){
  6527. $this->render ( "/receipt/receiptImplementPublic", $data );
  6528. }else{
  6529. //$this->render ( "/admin/implement", $data );
  6530. }
  6531. }
  6532. function implementDo() {
  6533. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6534. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6535. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6536. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6537. // $ab = '';
  6538. // if ($accountBank == 'CGBDeposit')
  6539. // $ab = '纵横广发';
  6540. // elseif ($accountBank == 'ICBCDeposit')
  6541. // $ab = '纵横工行';
  6542. // elseif ($accountBank == 'HUADeposit')
  6543. // $ab = '华润银行';
  6544. // elseif ($accountBank == 'PersonalDeposit')
  6545. // $ab = '个人广发';
  6546. // if (empty ( $ab ))
  6547. // die ( 'illegal request--22' );
  6548. if (! empty ( $rid )) {
  6549. Doo::loadModel ( 'receipt' );
  6550. $receipt = new receipt ();
  6551. Doo::loadClass ( 'XDeode' );
  6552. $XDeode = new XDeode ( 5 );
  6553. $rid=$XDeode->decode($rid);
  6554. if (!is_numeric($rid)){
  6555. die;
  6556. }
  6557. // $rinfo = $receipt->getOne ( array (
  6558. // 'where' => 'rid=' . $rid,
  6559. // 'asArray' => true
  6560. // ) );
  6561. $rinfo = $receipt->getReceiptByRid ( $rid );
  6562. // $accountType = '';
  6563. // if ($rinfo ['Rtype'] == 1) {
  6564. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6565. // $accountType = 2;
  6566. // else
  6567. // $accountType = 1;
  6568. // } elseif ($rinfo ['Rtype'] == 2) {
  6569. // $accountType = 4;
  6570. // } elseif ($rinfo ['Rtype'] == 0)
  6571. // $accountType = 3;
  6572. // if (empty ( $accountType ))
  6573. // die ( 'illegal request' );
  6574. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6575. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6576. if (empty ( $executeStaff )) {
  6577. $executeStaff = array (
  6578. $this->staff [0] ['sid'] => array (
  6579. 'date' => date ( 'Y-m-d' ),
  6580. 'opinion' => $implementOpinions,
  6581. 'status' => 1
  6582. )
  6583. );
  6584. } else {
  6585. $executeStaff [$this->staff [0] ['sid']] = array (
  6586. 'date' => date ( 'Y-m-d' ),
  6587. 'opinion' => $implementOpinions,
  6588. 'status' => 1
  6589. );
  6590. }
  6591. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6592. $receipt->executeStaff = json_encode ( $executeStaff );
  6593. $receipt->status = 8;
  6594. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6595. $receipt->status = 9;
  6596. if ($rinfo ['status'] == 6) {
  6597. $receipt->loanDate = date ( "Y-m-d" );
  6598. }
  6599. $receipt->executeDate = date ( "Y-m-d" );
  6600. } else {
  6601. $receipt->executeStaff = json_encode ( $executeStaff );
  6602. }
  6603. //$receipt->amount = $amount;
  6604. $receipt->update ( array (
  6605. 'where' => 'rid=' . $rid
  6606. ) );
  6607. // 公司流水记录
  6608. // Doo::loadModel ( 'wasteBook' );
  6609. // $wasteBook = new wasteBook ();
  6610. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6611. // // 银行
  6612. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6613. // $item = array (
  6614. // 'dataID' => $rid,
  6615. // 'expensesType' => 2,
  6616. // 'accountType' => $accountType,
  6617. // 'accountPriceShow' => $amount,
  6618. // 'accountPrice' => - $amount,
  6619. // 'accountBank' => $accountBank,
  6620. // 'category' => $rinfo ['category'] [0] ['title'],
  6621. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6622. // 'name' => $rinfo ['staffDetail'] ['username'],
  6623. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6624. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6625. // );
  6626. // $wasteBook->setAccountBookStatistics ( $item );
  6627. // }
  6628. }
  6629. //$ridKey = $XDeode->encode ( $rid );
  6630. return "/hisImplement";
  6631. // return "/implement/" . $ridKey . ".html";
  6632. }
  6633. function receiptburEdi() {
  6634. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6635. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6636. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6637. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6638. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6639. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6640. if (empty ( $status ))
  6641. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6642. $vidList = array ();
  6643. $button = 0;
  6644. Doo::loadModel ( 'verify' );
  6645. Doo::loadModel ( 'receipt' );
  6646. Doo::loadModel ( 'staff' );
  6647. $staff = new staff ();
  6648. $receipt = new receipt ();
  6649. $verify = new verify ();
  6650. Doo::loadModel ( 'L_category' );
  6651. $Lcategory = new L_category ();
  6652. Doo::loadModel ( 'enclosur' );
  6653. $enclosur = new enclosur ();
  6654. Doo::loadModel ( 'loanReceipt' );
  6655. $loanReceipt = new loanReceipt ();
  6656. // user verify ID
  6657. $verifyDetail = $verify->find ( array (
  6658. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6659. 'asArray' => true
  6660. ) );
  6661. foreach ( $verifyDetail as $key => $value ) {
  6662. array_push ( $vidList, $value ['vid'] );
  6663. }
  6664. $vid = implode ( ",", $vidList );
  6665. if (empty ( $verifyDetail ))
  6666. $vid = 0;
  6667. $categoryList = $Lcategory->find ( array (
  6668. 'asArray' => true
  6669. ) );
  6670. $staffList = $staff->find ( array (
  6671. 'where' => 'cid=' . $cid,
  6672. 'asArray' => true
  6673. ) );
  6674. $ap = "";
  6675. if ($status == 4) {
  6676. $ap = 4;
  6677. $status = 2;
  6678. }
  6679. // get Receipt By verifyID status 2
  6680. $receiptList = $receipt->find ( array (
  6681. 'where' => 'rid =' . $rid . ' and status=2',
  6682. 'desc' => 'rid',
  6683. 'asArray' => true
  6684. ) );
  6685. if (empty ( $receiptList )) {
  6686. die ( 'illegal request' );
  6687. }
  6688. $loanList = $loanReceipt->find ( array (
  6689. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6690. 'desc' => 'rid',
  6691. 'asArray' => true
  6692. ) );
  6693. $data ['explanation'] = '';
  6694. if (! empty ( $loanList ))
  6695. $data ['explanation'] = $loanList [0] ['explanation'];
  6696. $Locate = 0;
  6697. $roleId = 0;
  6698. $button = 0;
  6699. foreach ( $loanList as $key => $value ) {
  6700. $loanList [$key] ['Locate'] = $Locate;
  6701. $Locate ++;
  6702. $loanList [$key] ['reviseDetail'] = array ();
  6703. if (! empty ( $value ['reviseDetail'] ))
  6704. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6705. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6706. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6707. $categoryDetil = $Lcategory->getOne ( array (
  6708. 'where' => 'cid=' . $value ['cid'],
  6709. 'asArray' => true
  6710. ) );
  6711. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6712. // 检测编辑状态
  6713. $verifyList = $verify->getOne ( array (
  6714. 'where' => 'vid=' . $value ['verify'],
  6715. 'asArray' => true
  6716. ) );
  6717. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6718. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6719. Doo::loadModel ( 'role' );
  6720. $role = new role ();
  6721. $flag = true;
  6722. $roleKey = 0;
  6723. $endStaffArray = array ();
  6724. $roleArrayCopy = array ();
  6725. foreach ( $verifyList as $k => $v ) {
  6726. // init verifyStaff
  6727. if ($v [1] == 'ROLE') {
  6728. if (! empty ( $verifyStaff )) {
  6729. $endStaffArray = end ( $verifyStaff );
  6730. }
  6731. $roleVerify = json_decode ( $v [3], true );
  6732. $roleKey = $k;
  6733. $roleArray = array ();
  6734. $rolename = $role->getOne ( array (
  6735. 'where' => 'rid=' . $v [0],
  6736. 'asArray' => true
  6737. ) );
  6738. foreach ( $roleVerify as $o => $p ) {
  6739. $staffID = explode ( '_', $p );
  6740. $staffInfo = $staff->getOne ( array (
  6741. 'where' => 'sid=' . $staffID [0],
  6742. 'asArray' => true
  6743. ) );
  6744. // print_r($staffID);
  6745. $exp = array (
  6746. 0 => $staffInfo ['sid'],
  6747. 1 => $staffID [1],
  6748. 2 => $staffInfo ['avatar'],
  6749. 'date' => '',
  6750. 'date' => '',
  6751. 'opinion' => '',
  6752. 'status' => '',
  6753. 'rolename' => $rolename ['name']
  6754. );
  6755. array_push ( $roleArray, $exp );
  6756. }
  6757. $roleArrayCopy [$v [0]] = $roleArray;
  6758. // $verifyList[$k]['roleArray']=$roleArray;
  6759. }
  6760. $verifyList [$k] ['date'] = "";
  6761. $verifyList [$k] ['opinion'] = "";
  6762. $verifyList [$k] ['status'] = "";
  6763. if (empty ( $verifyStaff )) {
  6764. $verifyList [$k] ['date'] = "";
  6765. $verifyList [$k] ['opinion'] = "";
  6766. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6767. $verifyList [$k] ['status'] = 4;
  6768. $flag = false;
  6769. }
  6770. } else {
  6771. foreach ( $verifyStaff as $m => $u ) {
  6772. if ($v [0] == $m) {
  6773. $verifyList [$k] ['date'] = $u ['date'];
  6774. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6775. $verifyList [$k] ['status'] = $u ['status'];
  6776. $flag = false;
  6777. break;
  6778. }
  6779. }
  6780. $endStaffArray = end ( $verifyStaff );
  6781. if (isset ( $endStaffArray ['ROLE'] )) {
  6782. } else {
  6783. }
  6784. }
  6785. }
  6786. $rolename ['name'] = '';
  6787. if (! empty ( $roleId )) {
  6788. Doo::loadModel ( 'role' );
  6789. $role = new role ();
  6790. $rolename = $role->getOne ( array (
  6791. 'where' => 'rid=' . $roleId,
  6792. 'asArray' => true
  6793. ) );
  6794. }
  6795. if (! empty ( $verifyStaff ))
  6796. $endStaffArray = end ( $verifyStaff );
  6797. $KOP = false;
  6798. foreach ( $roleArrayCopy as $P => $A ) {
  6799. foreach ( $A as $MKI => $AVL ) {
  6800. if (! empty ( $verifyStaff )) {
  6801. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6802. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6803. $button = 4;
  6804. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6805. }
  6806. foreach ( $verifyStaff as $m => $u ) {
  6807. $AVLFK = $AVL [0] . '_R';
  6808. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6809. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6810. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6811. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6812. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6813. break;
  6814. }
  6815. }
  6816. } else {
  6817. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6818. $button = 4;
  6819. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6820. }
  6821. }
  6822. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6823. $KOP = true;
  6824. }
  6825. }
  6826. foreach ( $roleArrayCopy as $k => $v ) {
  6827. foreach ( $verifyList as $m => $n ) {
  6828. if ($n [0] == $k) {
  6829. array_splice ( $verifyList, $m, 1, $v );
  6830. }
  6831. }
  6832. }
  6833. $loanList [$key] ['verifyList'] = $verifyList;
  6834. }
  6835. $htmlLoan = '';
  6836. $data ['loanReceiptDate'] = '';
  6837. if (isset ( $loanList [0] )) {
  6838. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6839. if ($value ['status'] == 1)
  6840. $htmlLoan .= '<li class="done" >';
  6841. elseif ($value ['status'] == 3)
  6842. $htmlLoan .= '<li class="undone" >';
  6843. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6844. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6845. if (isset ( $value ['rolename'] ))
  6846. $htmlLoan .= $value ['rolename'];
  6847. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6848. }
  6849. $data ['loanDate'] = $loanList [0] ['date'];
  6850. } else {
  6851. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6852. }
  6853. $data ['htmlLoan'] = $htmlLoan;
  6854. // $data ['LoanReceipt']=$loanList[0];
  6855. // print_r($loanList);
  6856. $Locate = 0;
  6857. $roleId = 0;
  6858. $button = 0;
  6859. if ($ap == 4)
  6860. $status = 4;
  6861. Doo::loadClass ( 'XDeode' );
  6862. $XDeode = new XDeode ( 5 );
  6863. foreach ( $receiptList as $key => $value ) {
  6864. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6865. $receiptList [$key] ['Locate'] = $Locate;
  6866. $Locate ++;
  6867. $receiptList [$key] ['reviseDetail'] = array ();
  6868. // 调整金额 代码调整
  6869. if (! empty ( $value ['reviseDetail'] )) {
  6870. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6871. foreach ( $reviseDetail as $ry => $re ) {
  6872. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6873. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6874. }
  6875. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6876. // print_r($reviseDetail);
  6877. }
  6878. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6879. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6880. $categoryDetil = $Lcategory->getOne ( array (
  6881. 'where' => 'cid=' . $value ['cid'],
  6882. 'asArray' => true
  6883. ) );
  6884. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6885. // 检测编辑状态
  6886. $verifyList = $verify->getOne ( array (
  6887. 'where' => 'vid=' . $value ['verify'],
  6888. 'asArray' => true
  6889. ) );
  6890. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6891. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6892. Doo::loadModel ( 'role' );
  6893. $role = new role ();
  6894. // print_r($verifyList);
  6895. $flag = true;
  6896. $roleKey = 0;
  6897. $endStaffArray = array ();
  6898. $roleArrayCopy = array ();
  6899. foreach ( $verifyList as $k => $v ) {
  6900. // init verifyStaff
  6901. if ($v [1] == 'ROLE') {
  6902. if (! empty ( $verifyStaff )) {
  6903. $endStaffArray = end ( $verifyStaff );
  6904. if ($v [0] == $endStaffArray ['nextStaff']) {
  6905. $roleId = $v [0];
  6906. }
  6907. }
  6908. $roleVerify = json_decode ( $v [3], true );
  6909. $roleKey = $k;
  6910. $roleArray = array ();
  6911. $rolename = $role->getOne ( array (
  6912. 'where' => 'rid=' . $v [0],
  6913. 'asArray' => true
  6914. ) );
  6915. foreach ( $roleVerify as $o => $p ) {
  6916. $staffID = explode ( '_', $p );
  6917. $staffInfo = $staff->getOne ( array (
  6918. 'where' => 'sid=' . $staffID [0],
  6919. 'asArray' => true
  6920. ) );
  6921. // print_r($staffID);
  6922. $exp = array (
  6923. 0 => $staffInfo ['sid'],
  6924. 1 => $staffID [1],
  6925. 2 => $staffInfo ['avatar'],
  6926. 'date' => '',
  6927. 'date' => '',
  6928. 'opinion' => '',
  6929. 'status' => '',
  6930. 'rolename' => $rolename ['name']
  6931. );
  6932. array_push ( $roleArray, $exp );
  6933. }
  6934. $roleArrayCopy [$v [0]] = $roleArray;
  6935. // $verifyList[$k]['roleArray']=$roleArray;
  6936. }
  6937. // print_r($roleArray);
  6938. $verifyList [$k] ['date'] = "";
  6939. $verifyList [$k] ['opinion'] = "";
  6940. $verifyList [$k] ['status'] = "";
  6941. if (empty ( $verifyStaff )) {
  6942. $verifyList [$k] ['date'] = "";
  6943. $verifyList [$k] ['opinion'] = "";
  6944. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6945. $verifyList [$k] ['status'] = 4;
  6946. $button = 4;
  6947. $flag = false;
  6948. }
  6949. } else {
  6950. foreach ( $verifyStaff as $m => $u ) {
  6951. if ($v [0] == $m) {
  6952. $verifyList [$k] ['date'] = $u ['date'];
  6953. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6954. $verifyList [$k] ['status'] = $u ['status'];
  6955. $flag = false;
  6956. break;
  6957. }
  6958. }
  6959. $endStaffArray = end ( $verifyStaff );
  6960. if (isset ( $endStaffArray ['ROLE'] )) {
  6961. } else {
  6962. $endKey = key ( $verifyStaff );
  6963. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6964. $button = 4;
  6965. $verifyList [$k] ['status'] = 4;
  6966. }
  6967. }
  6968. }
  6969. }
  6970. $rolename ['name'] = '';
  6971. if (! empty ( $roleId )) {
  6972. Doo::loadModel ( 'role' );
  6973. $role = new role ();
  6974. $rolename = $role->getOne ( array (
  6975. 'where' => 'rid=' . $roleId,
  6976. 'asArray' => true
  6977. ) );
  6978. }
  6979. if (! empty ( $verifyStaff ))
  6980. $endStaffArray = end ( $verifyStaff );
  6981. $KOP = false;
  6982. foreach ( $roleArrayCopy as $P => $A ) {
  6983. foreach ( $A as $MKI => $AVL ) {
  6984. if (! empty ( $verifyStaff )) {
  6985. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6986. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6987. $button = 4;
  6988. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6989. }
  6990. foreach ( $verifyStaff as $m => $u ) {
  6991. $AVLFK = $AVL [0] . '_R';
  6992. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6993. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6994. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6995. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6996. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6997. break;
  6998. }
  6999. }
  7000. } else {
  7001. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7002. $button = 4;
  7003. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7004. }
  7005. }
  7006. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7007. $KOP = true;
  7008. }
  7009. }
  7010. foreach ( $roleArrayCopy as $k => $v ) {
  7011. foreach ( $verifyList as $m => $n ) {
  7012. if ($n [0] == $k) {
  7013. array_splice ( $verifyList, $m, 1, $v );
  7014. }
  7015. }
  7016. }
  7017. // print_r($verifyList);
  7018. $receiptList [$key] ['verifyList'] = $verifyList;
  7019. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7020. 'where' => 'sid=' . $value ['staff'],
  7021. 'asArray' => true
  7022. ) );
  7023. $receiptList [$key] ['button'] = $button;
  7024. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  7025. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  7026. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  7027. $receiptList [$key] ['relust'] = $relust;
  7028. $receiptList [$key] ['relustABS'] = abs ( $relust );
  7029. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  7030. }
  7031. //print_r($receiptList);die;
  7032. // $data['verifyDetail']=$verifyDetail;
  7033. $mothHtml = "";
  7034. for($i = 1; $i <= 12; $i ++) {
  7035. if ($month == $i)
  7036. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7037. else
  7038. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7039. }
  7040. // 获取审批日志
  7041. Doo::loadModel ( 'receiptLog' );
  7042. $receiptLog = new receiptLog ();
  7043. $rlList = array ();
  7044. $rlInfo = $receiptLog->getOne ( array (
  7045. 'where' => 'rid=' . $rid . ' and status=4',
  7046. 'asArray' => true
  7047. ) );
  7048. $tijdate = $receiptLog->getOne ( array (
  7049. 'where' => 'rid=' . $rid . ' and status=2',
  7050. 'asc' => 'rlid',
  7051. 'asArray' => true
  7052. ) );
  7053. if (! empty ( $rlInfo )) {
  7054. $rlList = $receiptLog->find ( array (
  7055. 'where' => 'rid=' . $rid,
  7056. 'asc' => 'rlid',
  7057. 'asArray' => true
  7058. ) );
  7059. }
  7060. // echo $rid;
  7061. // print_r($receiptList);
  7062. $receiptList [0] ['rlList'] = $rlList;
  7063. // print_r($receiptList);
  7064. $enclosurList = $enclosur->find ( array (
  7065. 'where' => 'rid=' . $rid,
  7066. 'asArray' => true
  7067. ) );
  7068. $enclosurHtml = '';
  7069. foreach ( $enclosurList as $value ) {
  7070. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7071. }
  7072. $data ['enclosurHtml'] = $enclosurHtml;
  7073. $data ['rolename'] = $rolename ['name'];
  7074. $data ['mothHtml'] = $mothHtml;
  7075. $receiptList[0]['itinerary']=str_replace('\n','<br/>',$receiptList[0]['itinerary']);
  7076. $data ['rid'] = $rid;
  7077. $data ['tijdate'] = $tijdate ['date'];
  7078. $data ['receiptList'] = $receiptList;
  7079. $data ['receiptApprovalCount'] = count ( $receiptList );
  7080. $data ['status'] = $status;
  7081. $data ['year'] = $year;
  7082. $data ['categoryList'] = $categoryList;
  7083. $data ['staffList'] = $staffList;
  7084. $data ['cid'] = $cid;
  7085. $data ['sid'] = $sid;
  7086. $data ['ap'] = $ap;
  7087. $data ['memu'] = "receipt";
  7088. $data ['staff'] = $this->staff;
  7089. $data ['receiptMemu'] = 'approvalExpenses';
  7090. $data ['verifyId'] = $this->verifyId;
  7091. $data ['executeId'] = $this->executeId;
  7092. if($receiptList[0]['receiptClass']==1){
  7093. $this->render ( "/receipt/feeAgencyApproval", $data );
  7094. }elseif($receiptList[0]['receiptClass']==2){
  7095. //$this->render ( "/admin/receiptburEdi", $data );
  7096. $this->render ( "/receipt/feeTraveApproval", $data );
  7097. }elseif($receiptList[0]['receiptClass']==3){
  7098. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  7099. }else{
  7100. $this->render ( "/admin/receiptburEdi", $data );
  7101. }
  7102. }
  7103. function hisImplement() {
  7104. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7105. if (empty ( $item ))
  7106. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  7107. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  7108. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7109. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  7110. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7111. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  7112. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  7113. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  7114. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  7115. Doo::loadClass ( 'XDeode' );
  7116. $XDeode = new XDeode ( 5 );
  7117. Doo::loadModel ( 'receipt' );
  7118. $receipt = new receipt ();
  7119. Doo::loadModel ( 'L_category' );
  7120. $Lcategory = new L_category ();
  7121. Doo::loadModel ( 'verify' );
  7122. Doo::loadModel ( 'statistics' );
  7123. $statistics = new statistics ();
  7124. $verify = new verify ();
  7125. Doo::loadModel ( 'staff' );
  7126. $staff = new staff ();
  7127. Doo::loadClass ( 'XDeode' );
  7128. $XDeode = new XDeode ( 5 );
  7129. $XDeode7 = new XDeode ( 7 );
  7130. $cid = $XDeode->decode ( $cidKey );
  7131. $condition = "";
  7132. if ($item == "expenses")
  7133. $condition = " and Rtype=1 ";
  7134. elseif ($item == "receipts")
  7135. $condition = " and Rtype=0 ";
  7136. elseif ($item == "remits")
  7137. $condition = " and Rtype=2 ";
  7138. elseif($item == "train")
  7139. $condition = " and Rtype=3 ";
  7140. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  7141. $sopString = $cidString = "";
  7142. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  7143. if (empty ( $rdate ))
  7144. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  7145. else
  7146. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  7147. if ($status == 'pendImplement') {
  7148. $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 ) ) ';
  7149. } elseif ($status == 'alerpts') {
  7150. $statusCon = '(status=8 or status=9 )';
  7151. if (empty ( $rdate )){
  7152. $dateCondition = " and Year(date) =" . $year;
  7153. }else{
  7154. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  7155. }
  7156. }
  7157. if ($sop != 'SOP')
  7158. $sopString = " and staff=" . $sop;
  7159. if ($cidKey != 'ALL')
  7160. $cidString = " and cid=" . $cid;
  7161. //汇款信息需要提取出来
  7162. if(!empty($receiptOrder)){
  7163. $receiptList = $receipt->find ( array (
  7164. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  7165. 'desc' => 'rid',
  7166. 'asArray' => true
  7167. ) );
  7168. // 员工筛选
  7169. $receiptList2 = $receipt->find ( array (
  7170. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  7171. 'desc' => 'rid',
  7172. 'asArray' => true
  7173. ) );
  7174. }else{
  7175. $receiptList = $receipt->find ( array (
  7176. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  7177. 'desc' => 'rid',
  7178. 'asArray' => true
  7179. ) );
  7180. // 员工筛选
  7181. $receiptList2 = $receipt->find ( array (
  7182. 'where' => $statusCon . $condition . $dateCondition,
  7183. 'desc' => 'rid',
  7184. 'asArray' => true
  7185. ) );
  7186. }
  7187. $sopStaff = array ();
  7188. foreach ( $receiptList2 as $key => $value ) {
  7189. $staffDetail = $staff->getOne ( array (
  7190. 'select' => 'username',
  7191. 'where' => 'sid=' . $value ['staff'],
  7192. 'asArray' => true
  7193. ) );
  7194. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  7195. }
  7196. // 办事处筛选
  7197. $categoryScreen = array ();
  7198. $categorList = $Lcategory->getCategory ();
  7199. foreach ( $receiptList2 as $key => $value ) {
  7200. foreach ( $categorList as $k => $v ) {
  7201. if ($value ['cid'] == $v ['cid']) {
  7202. $categoryScreen [$v ['cidKey']] = $v ['title'];
  7203. break;
  7204. }
  7205. }
  7206. }
  7207. $categoryScreenHtml = "";
  7208. foreach ( $categoryScreen as $key => $value ) {
  7209. if ($cidKey == $key)
  7210. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7211. else
  7212. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7213. }
  7214. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  7215. $data ['cidKey'] = $cidKey;
  7216. $Locate = 0;
  7217. $roleId = 0;
  7218. $button = 0;
  7219. $staffBatchNumber = 100001;
  7220. $remittanceList = array ();
  7221. foreach ( $receiptList as $key => $value ) {
  7222. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  7223. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  7224. $receiptList [$key] ['Texe'] = 'false';
  7225. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  7226. $receiptList [$key] ['Texe'] = 'true';
  7227. }
  7228. $receiptList [$key] ['TRexe'] = 'true';
  7229. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  7230. $receiptList [$key] ['TRexe'] = 'false';
  7231. }
  7232. $receiptList [$key] ['Locate'] = $Locate;
  7233. $Locate ++;
  7234. $receiptList [$key] ['reviseDetail'] = array ();
  7235. if (! empty ( $value ['reviseDetail'] ))
  7236. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7237. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7238. $categoryDetil = $Lcategory->getOne ( array (
  7239. 'where' => 'cid=' . $value ['cid'],
  7240. 'asArray' => true
  7241. ) );
  7242. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7243. // 检测编辑状态
  7244. $verifyList = $verify->getOne ( array (
  7245. 'where' => 'vid=' . $value ['verify'],
  7246. 'asArray' => true
  7247. ) );
  7248. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7249. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7250. Doo::loadModel ( 'role' );
  7251. $role = new role ();
  7252. $flag = true;
  7253. $roleKey = 0;
  7254. $endStaffArray = array ();
  7255. $roleArrayCopy = array ();
  7256. foreach ( $verifyList as $k => $v ) {
  7257. // init verifyStaff
  7258. if ($v [1] == 'ROLE') {
  7259. if (! empty ( $verifyStaff )) {
  7260. $endStaffArray = end ( $verifyStaff );
  7261. }
  7262. $roleVerify = json_decode ( $v [3], true );
  7263. $roleKey = $k;
  7264. $roleArray = array ();
  7265. $rolename = $role->getOne ( array (
  7266. 'where' => 'rid=' . $v [0],
  7267. 'asArray' => true
  7268. ) );
  7269. foreach ( $roleVerify as $o => $p ) {
  7270. $staffID = explode ( '_', $p );
  7271. $staffInfo = $staff->getOne ( array (
  7272. 'where' => 'sid=' . $staffID [0],
  7273. 'asArray' => true
  7274. ) );
  7275. $exp = array (
  7276. 0 => $staffInfo ['sid'],
  7277. 1 => $staffID [1],
  7278. 2 => $staffInfo ['avatar'],
  7279. 'date' => '',
  7280. 'date' => '',
  7281. 'opinion' => '',
  7282. 'status' => '',
  7283. 'rolename' => $rolename ['name']
  7284. );
  7285. array_push ( $roleArray, $exp );
  7286. }
  7287. $roleArrayCopy [$v [0]] = $roleArray;
  7288. }
  7289. $verifyList [$k] ['date'] = "";
  7290. $verifyList [$k] ['opinion'] = "";
  7291. $verifyList [$k] ['status'] = "";
  7292. if (empty ( $verifyStaff )) {
  7293. $verifyList [$k] ['date'] = "";
  7294. $verifyList [$k] ['opinion'] = "";
  7295. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7296. $verifyList [$k] ['status'] = 4;
  7297. $flag = false;
  7298. }
  7299. } else {
  7300. foreach ( $verifyStaff as $m => $u ) {
  7301. if ($v [0] == $m) {
  7302. $verifyList [$k] ['date'] = $u ['date'];
  7303. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7304. $verifyList [$k] ['status'] = $u ['status'];
  7305. $flag = false;
  7306. break;
  7307. }
  7308. }
  7309. $endStaffArray = end ( $verifyStaff );
  7310. }
  7311. }
  7312. $rolename ['name'] = '';
  7313. if (! empty ( $roleId )) {
  7314. Doo::loadModel ( 'role' );
  7315. $role = new role ();
  7316. $rolename = $role->getOne ( array (
  7317. 'where' => 'rid=' . $roleId,
  7318. 'asArray' => true
  7319. ) );
  7320. }
  7321. if (! empty ( $verifyStaff ))
  7322. $endStaffArray = end ( $verifyStaff );
  7323. $KOP = false;
  7324. foreach ( $roleArrayCopy as $P => $A ) {
  7325. foreach ( $A as $MKI => $AVL ) {
  7326. if (! empty ( $verifyStaff )) {
  7327. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7328. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7329. $button = 4;
  7330. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7331. }
  7332. foreach ( $verifyStaff as $m => $u ) {
  7333. $AVLFK = $AVL [0] . '_R';
  7334. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7335. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7336. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7337. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7338. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7339. break;
  7340. }
  7341. }
  7342. } else {
  7343. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7344. $button = 4;
  7345. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7346. }
  7347. }
  7348. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7349. $KOP = true;
  7350. }
  7351. }
  7352. foreach ( $roleArrayCopy as $k => $v ) {
  7353. foreach ( $verifyList as $m => $n ) {
  7354. if ($n [0] == $k) {
  7355. array_splice ( $verifyList, $m, 1, $v );
  7356. }
  7357. }
  7358. }
  7359. $receiptList [$key] ['verifyList'] = $verifyList;
  7360. $staffDetail = $staff->getOne ( array (
  7361. 'where' => 'sid=' . $value ['staff'],
  7362. 'asArray' => true
  7363. ) );
  7364. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7365. $receiptList [$key] ['button'] = $button;
  7366. if ($value['Rtype']==1){
  7367. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7368. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  7369. }elseif($value['Rtype']==3){
  7370. // 收入合计
  7371. Doo::loadModel ( 'invoiceTraining' );
  7372. $invoiceTraining = new invoiceTraining ();
  7373. $invoiceTrainingDetail = array (
  7374. 'invoiceArriveAmount' => '0.00',
  7375. 'RIAmount' => '0.00',
  7376. 'invoiceTotalAmount' => '0.00',
  7377. 'invoiceCompanyAmount' => '0.00',
  7378. 'invoiceArriveAmountM'=>'0.00',
  7379. 'invoiceCompanyAmountM'=>'0.00'
  7380. );
  7381. if ($value ['invoiceTrainId'] != 0) {
  7382. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7383. }
  7384. $invoiceArriveAmount = $RIAmount = 0;
  7385. if (! empty ( $invoiceTrainingDetail )) {
  7386. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7387. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7388. }
  7389. // 备用金
  7390. $sum = 0;
  7391. if (! empty ( $value ['trainLoanRid'] )) {
  7392. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7393. foreach ($receiptLoanList as $kll=>$vll){
  7394. $sum+=$vll['sum'];
  7395. }
  7396. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7397. // $sum = $receiptLoanDetailBak ['sum'];
  7398. }
  7399. // 支出项金额详情
  7400. // 项目金额合计
  7401. Doo::loadModel ( 'RItem' );
  7402. $RItem = new RItem ();
  7403. Doo::loadModel ( 'accountItem' );
  7404. $accountItem = new accountItem ();
  7405. // 讲师获得
  7406. Doo::loadModel ( 'RILecturer' );
  7407. $RILecturer = new RILecturer ();
  7408. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7409. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7410. // 支出项金额详情
  7411. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7412. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7413. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7414. $receiptList [$key] ['payment'] =$payment;
  7415. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7416. }
  7417. // 设置导出汇款execl
  7418. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7419. $remittanceDetail = array (
  7420. $staffBatchNumber,
  7421. $value ['remittanceName'],
  7422. $value ['bankNumber'],
  7423. $value ['bankName'],
  7424. $value ['remittanceBankType'],
  7425. $value ['coupletNumber'],
  7426. $value ['sum']
  7427. );
  7428. array_push ( $remittanceList, $remittanceDetail );
  7429. $staffBatchNumber ++;
  7430. }
  7431. }
  7432. $data ['remittanceList'] = json_encode ( $remittanceList );
  7433. // print_r($receiptList);
  7434. $mothHtml = "";
  7435. for($i = 1; $i <= 12; $i ++) {
  7436. if ($moth == $i)
  7437. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7438. else
  7439. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7440. }
  7441. $dayHtml = "";
  7442. if ($day != "DAY" || $moth != "MONTH") {
  7443. for($i = 1; $i <= 31; $i ++) {
  7444. if ($day == $i)
  7445. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7446. else
  7447. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7448. }
  7449. }
  7450. $sopHtml = "";
  7451. foreach ( $sopStaff as $key => $value ) {
  7452. if ($sop == $key)
  7453. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7454. else
  7455. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7456. }
  7457. $data ['status'] = $status;
  7458. $data ['rdate'] = $rdate;
  7459. $data ['sopHtml'] = $sopHtml;
  7460. $data ['dayHtml'] = $dayHtml;
  7461. $data ['mothHtml'] = $mothHtml;
  7462. $data ['receiptList'] = $receiptList;
  7463. $data ['memu'] = "receipt";
  7464. $data ['staff'] = $this->staff;
  7465. $data ['receiptMemu'] = 'implement';
  7466. $data ['verifyId'] = $this->verifyId;
  7467. $data ['executeId'] = $this->executeId;
  7468. $data ['item'] = $item;
  7469. $data ['year'] = $year;
  7470. $data ['moth'] = $moth;
  7471. $data['receiptOrder']=$receiptOrder;
  7472. $data ['day'] = $day;
  7473. $data ['sop'] = $sop;
  7474. $this->render ( "/admin/hisImplement", $data );
  7475. }
  7476. /**
  7477. * 导出汇款信息的exelc
  7478. */
  7479. function exportRemittance() {
  7480. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7481. if (empty ( $remittanceInfo ))
  7482. die ( 'illegal request' );
  7483. $title = array (
  7484. '员工编号',
  7485. '姓名',
  7486. '员工账号',
  7487. '员工账户开户行',
  7488. '转账类型',
  7489. '联行号',
  7490. '金额'
  7491. );
  7492. $data = json_decode ( $remittanceInfo, true );
  7493. if (empty ( $data ))
  7494. die ( 'illegal request' );
  7495. Doo::loadClass ( 'receipt.func' );
  7496. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7497. header ( 'Content-Type:text/html;charset=utf-8' );
  7498. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7499. }
  7500. function ajaxExamine() {
  7501. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7502. Doo::loadModel ( 'receipt' );
  7503. $receipt = new receipt ();
  7504. if (! empty ( $rid )) {
  7505. $rLRes = $receipt->find ( array (
  7506. '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,
  7507. 'asArray' => true
  7508. ) );
  7509. if(!empty($rLRes)){
  7510. Doo::loadClass ( 'XDeode' );
  7511. $XDeode = new XDeode ( 7 );
  7512. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7513. echo json_encode ( array (
  7514. 'status' => 1,
  7515. 'receipt' => $rLRes [0]
  7516. ) );
  7517. die ();
  7518. }else{
  7519. echo json_encode ( array (
  7520. 'status' => 1,
  7521. 'receipt' => array ()
  7522. ) );
  7523. die ();
  7524. }
  7525. }
  7526. echo json_encode ( array (
  7527. 'status' => 0,
  7528. 'receipt' => array ()
  7529. ) );
  7530. die ();
  7531. }
  7532. /*
  7533. * 废弃
  7534. */
  7535. function myReceipt() {
  7536. // all approval past withdraw
  7537. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7538. if (empty ( $item ))
  7539. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7540. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7541. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7542. Doo::loadModel ( 'receipt' );
  7543. $receipt = new receipt ();
  7544. // pre-loaded
  7545. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7546. // have cache
  7547. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7548. if (! empty ( $moth )) // yearPage
  7549. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7550. $this->showCache ( $path );
  7551. }
  7552. Doo::loadModel ( 'L_category' );
  7553. $Lcategory = new L_category ();
  7554. Doo::loadModel ( 'verify' );
  7555. Doo::loadModel ( 'statistics' );
  7556. $statistics = new statistics ();
  7557. $verify = new verify ();
  7558. Doo::loadModel ( 'staff' );
  7559. $staff = new staff ();
  7560. $condition = " and status!=0 ";
  7561. if ($item == "approval")
  7562. $condition = " and status=2 ";
  7563. elseif ($item == "withdraw")
  7564. $condition = " and status=3 ";
  7565. elseif ($item == "past")
  7566. $condition = " and status=1 ";
  7567. elseif ($item == "whdw")
  7568. $condition = " and status=4 ";
  7569. $dateCondition = " and Year(date) =" . $year;
  7570. if (! empty ( $moth )) {
  7571. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7572. $stList = $statistics->getOne ( array (
  7573. 'select' => 'rePrice ,agPrice',
  7574. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7575. 'asArray' => true
  7576. ) );
  7577. } else
  7578. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7579. if (empty ( $stList ))
  7580. $stList = array (
  7581. 'rePrice' => 0,
  7582. 'agPrice' => 0
  7583. );
  7584. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7585. $data ['stList'] = array (
  7586. 'rePrice' => $stList ['rePrice'],
  7587. 'agPrice' => $stList ['agPrice'],
  7588. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7589. );
  7590. $receiptList = $receipt->find ( array (
  7591. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7592. 'desc' => 'rid',
  7593. 'asArray' => true
  7594. ) );
  7595. $Locate = 0;
  7596. $roleId = 0;
  7597. $button = 0;
  7598. foreach ( $receiptList as $key => $value ) {
  7599. $receiptList [$key] ['Locate'] = $Locate;
  7600. $Locate ++;
  7601. $receiptList [$key] ['reviseDetail'] = array ();
  7602. if (! empty ( $value ['reviseDetail'] ))
  7603. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7604. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7605. $categoryDetil = $Lcategory->getOne ( array (
  7606. 'where' => 'cid=' . $value ['cid'],
  7607. 'asArray' => true
  7608. ) );
  7609. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7610. // 检测编辑状态
  7611. $verifyList = $verify->getOne ( array (
  7612. 'where' => 'vid=' . $value ['verify'],
  7613. 'asArray' => true
  7614. ) );
  7615. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7616. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7617. Doo::loadModel ( 'role' );
  7618. $role = new role ();
  7619. $flag = true;
  7620. $roleKey = 0;
  7621. $endStaffArray = array ();
  7622. $roleArrayCopy = array ();
  7623. foreach ( $verifyList as $k => $v ) {
  7624. // init verifyStaff
  7625. if ($v [1] == 'ROLE') {
  7626. if (! empty ( $verifyStaff )) {
  7627. $endStaffArray = end ( $verifyStaff );
  7628. // if ($v[0]==$endStaffArray['nextStaff']){
  7629. // $roleId=$v[0];
  7630. // }
  7631. }
  7632. $roleVerify = json_decode ( $v [3], true );
  7633. $roleKey = $k;
  7634. $roleArray = array ();
  7635. $rolename = $role->getOne ( array (
  7636. 'where' => 'rid=' . $v [0],
  7637. 'asArray' => true
  7638. ) );
  7639. foreach ( $roleVerify as $o => $p ) {
  7640. $staffID = explode ( '_', $p );
  7641. $staffInfo = $staff->getOne ( array (
  7642. 'where' => 'sid=' . $staffID [0],
  7643. 'asArray' => true
  7644. ) );
  7645. // print_r($staffID);
  7646. $exp = array (
  7647. 0 => $staffInfo ['sid'],
  7648. 1 => $staffID [1],
  7649. 2 => $staffInfo ['avatar'],
  7650. 'date' => '',
  7651. 'date' => '',
  7652. 'opinion' => '',
  7653. 'status' => '',
  7654. 'rolename' => $rolename ['name']
  7655. );
  7656. array_push ( $roleArray, $exp );
  7657. }
  7658. $roleArrayCopy [$v [0]] = $roleArray;
  7659. // $verifyList[$k]['roleArray']=$roleArray;
  7660. }
  7661. $verifyList [$k] ['date'] = "";
  7662. $verifyList [$k] ['opinion'] = "";
  7663. $verifyList [$k] ['status'] = "";
  7664. if (empty ( $verifyStaff )) {
  7665. $verifyList [$k] ['date'] = "";
  7666. $verifyList [$k] ['opinion'] = "";
  7667. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7668. $verifyList [$k] ['status'] = 4;
  7669. $flag = false;
  7670. }
  7671. } else {
  7672. foreach ( $verifyStaff as $m => $u ) {
  7673. if ($v [0] == $m) {
  7674. $verifyList [$k] ['date'] = $u ['date'];
  7675. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7676. $verifyList [$k] ['status'] = $u ['status'];
  7677. $flag = false;
  7678. break;
  7679. }
  7680. }
  7681. $endStaffArray = end ( $verifyStaff );
  7682. if (isset ( $endStaffArray ['ROLE'] )) {
  7683. } else {
  7684. // $endKey=key($verifyStaff);
  7685. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7686. // $button=4;
  7687. // $verifyList[$k]['status']=4;
  7688. // }
  7689. }
  7690. }
  7691. }
  7692. $rolename ['name'] = '';
  7693. if (! empty ( $roleId )) {
  7694. Doo::loadModel ( 'role' );
  7695. $role = new role ();
  7696. $rolename = $role->getOne ( array (
  7697. 'where' => 'rid=' . $roleId,
  7698. 'asArray' => true
  7699. ) );
  7700. }
  7701. if (! empty ( $verifyStaff ))
  7702. $endStaffArray = end ( $verifyStaff );
  7703. $KOP = false;
  7704. foreach ( $roleArrayCopy as $P => $A ) {
  7705. foreach ( $A as $MKI => $AVL ) {
  7706. if (! empty ( $verifyStaff )) {
  7707. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7708. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7709. $button = 4;
  7710. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7711. }
  7712. foreach ( $verifyStaff as $m => $u ) {
  7713. $AVLFK = $AVL [0] . '_R';
  7714. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7715. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7716. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7717. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7718. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7719. break;
  7720. }
  7721. }
  7722. } else {
  7723. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7724. $button = 4;
  7725. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7726. }
  7727. }
  7728. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7729. $KOP = true;
  7730. }
  7731. }
  7732. foreach ( $roleArrayCopy as $k => $v ) {
  7733. foreach ( $verifyList as $m => $n ) {
  7734. if ($n [0] == $k) {
  7735. array_splice ( $verifyList, $m, 1, $v );
  7736. }
  7737. }
  7738. }
  7739. $receiptList [$key] ['verifyList'] = $verifyList;
  7740. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7741. 'where' => 'sid=' . $value ['staff'],
  7742. 'asArray' => true
  7743. ) );
  7744. $receiptList [$key] ['button'] = $button;
  7745. }
  7746. // print_r($receiptList);die;
  7747. $mothHtml = "";
  7748. for($i = 1; $i <= 12; $i ++) {
  7749. if ($moth == $i)
  7750. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7751. else
  7752. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7753. }
  7754. $data ['mothHtml'] = $mothHtml;
  7755. $data ['receiptList'] = $receiptList;
  7756. $data ['memu'] = "receipt";
  7757. $data ['staff'] = $this->staff;
  7758. $data ['receiptMemu'] = 'receipt';
  7759. $data ['verifyId'] = $this->verifyId;
  7760. $data ['executeId'] = $this->executeId;
  7761. $data ['item'] = $item;
  7762. $data ['year'] = $year;
  7763. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7764. // sufficient condition to generate cache
  7765. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7766. $receiptList = $receipt->find ( array (
  7767. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7768. 'asArray' => true
  7769. ) );
  7770. if (empty ( $receiptList )) { // generated files
  7771. ob_start ();
  7772. $this->render ( "/admin/saea_myList", $data );
  7773. $this->cacheFile ( $path );
  7774. die ();
  7775. // $content = ob_get_contents();
  7776. // $fp = fopen($path, "w");
  7777. // fwrite($fp, $content);
  7778. // fclose($fp);
  7779. }
  7780. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7781. $receiptList = $receipt->find ( array (
  7782. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7783. 'asArray' => true
  7784. ) );
  7785. if (empty ( $receiptList )) { // generated files
  7786. ob_start ();
  7787. $this->render ( "/admin/saea_myList", $data );
  7788. $this->cacheFile ( $path );
  7789. die ();
  7790. }
  7791. }
  7792. }
  7793. $this->render ( "/admin/saea_myList", $data );
  7794. }
  7795. function approvedReceipt() {
  7796. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7797. Doo::loadModel ( 'receipt' );
  7798. Doo::loadModel ( 'receiptDetail' );
  7799. $receipt = new receipt ();
  7800. $receiptDetail = new receiptDetail ();
  7801. Doo::loadModel ( 'statistics' );
  7802. Doo::loadModel ( 'itemStatistics' );
  7803. $statistics = new statistics ();
  7804. $itemStatistics = new itemStatistics ();
  7805. Doo::loadModel ( "verify" );
  7806. $verify = new verify ();
  7807. // 审批状态的判定
  7808. $receiptDetailList = $receipt->getOne ( array (
  7809. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7810. 'asArray' => true
  7811. ) );
  7812. if (empty ( $receiptDetailList ))
  7813. return "/saeaBorad";
  7814. $verifyDetail = $verify->getOne ( array (
  7815. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7816. 'asArray' => true
  7817. ) );
  7818. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7819. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7820. $nowStaff = "";
  7821. $nowStaffList = array ();
  7822. if ($verifyDetail [0] [1] == 'ROLE') {
  7823. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7824. foreach ( $vStaffString as $key => $value ) {
  7825. $staffK = explode ( "_", $value );
  7826. array_push ( $nowStaffList, $staffK [0] );
  7827. }
  7828. $nowStaff = implode ( ',', $nowStaffList );
  7829. } else {
  7830. $nowStaff = $verifyDetail [0] [0];
  7831. }
  7832. $receipt->nowStaff = $nowStaff;
  7833. }
  7834. // echo $nowStaff;
  7835. // print_r($verifyDetail);die;
  7836. $receipt->rid = $receiptDetailList ['rid'];
  7837. $receipt->date = date ( "Y-m-d" );
  7838. $receipt->status = 2;
  7839. $receipt->update ();
  7840. $receiptDetail->status = 2;
  7841. $receiptDetail->update ( array (
  7842. 'where' => 'rid=' . $receiptDetailList ['rid']
  7843. ) );
  7844. Doo::loadModel ( "receiptLog" );
  7845. $receiptLog = new receiptLog ();
  7846. Doo::loadModel ( "verify" );
  7847. $verify = new verify ();
  7848. $receiptInfo = $receipt->getOne ( array (
  7849. 'where' => 'rid=' . $rid,
  7850. 'asArray' => true
  7851. ) );
  7852. $vr = $verify->getOne ( array (
  7853. 'where' => 'vid=' . $receiptInfo ['verify'],
  7854. 'asArray' => true
  7855. ) );
  7856. $jd = json_decode ( $vr ['staff'] );
  7857. $roleId = 0;
  7858. foreach ( $jd as $key => $value ) {
  7859. if ($value [1] == 'ROLE') {
  7860. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7861. if ($pos !== false) {
  7862. $roleId = $value [0];
  7863. }
  7864. }
  7865. }
  7866. // 审批日志
  7867. // echo $roleId;die;
  7868. if (! empty ( $roleId )) {
  7869. Doo::loadModel ( "role" );
  7870. $role = new role ();
  7871. $roleInfo = $role->getOne ( array (
  7872. 'where' => 'rid=' . $roleId,
  7873. 'asArray' => true
  7874. ) );
  7875. // $receiptLog->rolename = $roleInfo ['name'];
  7876. }
  7877. $receiptLog->username = $this->staff [0] ['username'];
  7878. $receiptLog->uid = $this->staff [0] ['sid'];
  7879. $receiptLog->date = date ( "Y-m-d" );
  7880. $receiptLog->opinion = '提交审批';
  7881. $receiptLog->img = $this->staff [0] ['avatar'];
  7882. $receiptLog->status = 2;
  7883. $receiptLog->rid = $rid;
  7884. $receiptLog->insert ();
  7885. // statistics item
  7886. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7887. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7888. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7889. $stat = $statistics->getOne ( array (
  7890. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7891. 'asArray' => true
  7892. ) );
  7893. if (empty ( $stat )) {
  7894. $statistics->date = date ( "Y-m-d" );
  7895. $statistics->cid = $this->staff [0] ['cid'];
  7896. $statistics->staff = $this->staff [0] ['sid'];
  7897. $statistics->agPrice = 0;
  7898. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7899. $statistics->insert ();
  7900. } else {
  7901. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7902. $statistics->update ( array (
  7903. 'where' => 'sid=' . $stat ['sid']
  7904. ) );
  7905. }
  7906. return "/expenses";
  7907. }
  7908. function approval() {
  7909. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7910. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7911. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7912. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7913. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7914. if (empty ( $status ))
  7915. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7916. $vidList = array ();
  7917. $button = 0;
  7918. Doo::loadModel ( 'verify' );
  7919. $verify = new verify ();
  7920. Doo::loadModel ( 'receipt' );
  7921. $receipt = new receipt ();
  7922. Doo::loadModel ( 'staff' );
  7923. $staff = new staff ();
  7924. Doo::loadModel ( 'L_category' );
  7925. $Lcategory = new L_category ();
  7926. // user verify ID
  7927. $verifyDetail = $verify->find ( array (
  7928. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7929. 'asArray' => true
  7930. ) );
  7931. foreach ( $verifyDetail as $key => $value ) {
  7932. array_push ( $vidList, $value ['vid'] );
  7933. }
  7934. $vid = implode ( ",", $vidList );
  7935. if (empty ( $verifyDetail ))
  7936. $vid = 0;
  7937. /*
  7938. */
  7939. $dateCondition = " and Year(date) =" . $year;
  7940. if (! empty ( $month ))
  7941. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7942. $categoryList = $Lcategory->find ( array (
  7943. 'asArray' => true
  7944. ) );
  7945. $staffList = $staff->find ( array (
  7946. 'where' => 'cid=' . $cid,
  7947. 'asArray' => true
  7948. ) );
  7949. $cateCondition = "";
  7950. $staffCondition = "";
  7951. $approvalCondition = "";
  7952. if (! empty ( $cid ))
  7953. $cateCondition = ' and cid=' . $cid;
  7954. if (! empty ( $sid )) {
  7955. $staffCondition = ' and staff=' . $sid;
  7956. $cateCondition = "";
  7957. }
  7958. // elseif($status==1){
  7959. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7960. // }
  7961. if ($status == 2) {
  7962. // 查找角色审批人
  7963. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7964. }
  7965. $ap = "";
  7966. if ($status == 4) {
  7967. $ap = 4;
  7968. $status = 2;
  7969. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7970. }
  7971. if ($status == 5) {
  7972. $status = 4;
  7973. $ap = 5;
  7974. }
  7975. // echo $vid;
  7976. // get Receipt By verifyID status 2 .$approvalCondition
  7977. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7978. $receiptList = $receipt->find ( array (
  7979. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7980. 'desc' => 'rid',
  7981. 'asArray' => true
  7982. ) );
  7983. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7984. $Locate = 0;
  7985. if ($ap == 4)
  7986. $status = 4;
  7987. elseif ($ap == 5)
  7988. $status = 5;
  7989. foreach ( $receiptList as $key => $value ) {
  7990. $receiptList [$key] ['Locate'] = $Locate;
  7991. $Locate ++;
  7992. $receiptList [$key] ['reviseDetail'] = array ();
  7993. if (! empty ( $value ['reviseDetail'] ))
  7994. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7995. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7996. $categoryDetil = $Lcategory->getOne ( array (
  7997. 'where' => 'cid=' . $value ['cid'],
  7998. 'asArray' => true
  7999. ) );
  8000. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8001. $verifyList = $verify->getOne ( array (
  8002. 'where' => 'vid=' . $value ['verify'],
  8003. 'asArray' => true
  8004. ) );
  8005. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8006. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8007. foreach ( $verifyList as $k => $v ) {
  8008. // init verifyStaff
  8009. $verifyList [$k] ['date'] = "";
  8010. $verifyList [$k] ['opinion'] = "";
  8011. $verifyList [$k] ['status'] = "";
  8012. if (empty ( $verifyStaff )) {
  8013. $verifyList [$k] ['date'] = "";
  8014. $verifyList [$k] ['opinion'] = "";
  8015. if ($v [0] == $this->staff [0] ['sid']) {
  8016. $verifyList [$k] ['status'] = 4;
  8017. $button = 4;
  8018. }
  8019. } else {
  8020. $flag = true;
  8021. foreach ( $verifyStaff as $m => $u ) {
  8022. if ($v [0] == $m) {
  8023. $verifyList [$k] ['date'] = $u ['date'];
  8024. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8025. $verifyList [$k] ['status'] = $u ['status'];
  8026. $flag = false;
  8027. break;
  8028. }
  8029. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  8030. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  8031. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  8032. }
  8033. if ($flag) { // 检测可编辑
  8034. if ($v [0] == $this->staff [0] ['sid']) {
  8035. $verifyList [$k] ['status'] = 4;
  8036. $button = 4;
  8037. }
  8038. }
  8039. }
  8040. }
  8041. $receiptList [$key] ['verifyList'] = $verifyList;
  8042. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8043. 'where' => 'sid=' . $value ['staff'],
  8044. 'asArray' => true
  8045. ) );
  8046. $receiptList [$key] ['button'] = $button;
  8047. }
  8048. // print_r($receiptList);die;
  8049. // $data['verifyDetail']=$verifyDetail;
  8050. $mothHtml = "";
  8051. for($i = 1; $i <= 12; $i ++) {
  8052. if ($month == $i)
  8053. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8054. else
  8055. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8056. }
  8057. $data ['mothHtml'] = $mothHtml;
  8058. $data ['receiptList'] = $receiptList;
  8059. $data ['receiptApprovalCount'] = count ( $receiptList );
  8060. $data ['status'] = $status;
  8061. $data ['year'] = $year;
  8062. $data ['categoryList'] = $categoryList;
  8063. $data ['staffList'] = $staffList;
  8064. $data ['cid'] = $cid;
  8065. $data ['sid'] = $sid;
  8066. $data ['ap'] = $ap;
  8067. $data ['memu'] = "receipt";
  8068. $data ['staff'] = $this->staff;
  8069. $data ['receiptMemu'] = 'approval';
  8070. $data ['verifyId'] = $this->verifyId;
  8071. $data ['executeId'] = $this->executeId;
  8072. $this->render ( "/admin/saea_reportList", $data );
  8073. }
  8074. function approvalDetails() {
  8075. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8076. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8077. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8078. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8079. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8080. Doo::loadModel ( 'verify' );
  8081. $verify = new verify ();
  8082. Doo::loadModel ( 'receipt' );
  8083. $receipt = new receipt ();
  8084. Doo::loadModel ( 'staff' );
  8085. $staff = new staff ();
  8086. Doo::loadModel ( 'L_category' );
  8087. $Lcategory = new L_category ();
  8088. Doo::loadModel ( 'enclosur' );
  8089. $enclosur = new enclosur ();
  8090. $vidList = array ();
  8091. $verifyDetail = $verify->find ( array (
  8092. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8093. 'asArray' => true
  8094. ) );
  8095. foreach ( $verifyDetail as $key => $value ) {
  8096. array_push ( $vidList, $value ['vid'] );
  8097. }
  8098. $vid = implode ( ",", $vidList );
  8099. if (empty ( $verifyDetail ))
  8100. $vid = 0;
  8101. $categoryList = $Lcategory->find ( array (
  8102. 'asArray' => true
  8103. ) );
  8104. $staffList = $staff->find ( array (
  8105. 'where' => 'cid=' . $cid,
  8106. 'asArray' => true
  8107. ) );
  8108. $ap = 0;
  8109. $receiptList = $receipt->find ( array (
  8110. 'where' => 'rid =' . $rid,
  8111. 'desc' => 'rid',
  8112. 'asArray' => true
  8113. ) );
  8114. $Locate = 0;
  8115. $roleId = 0;
  8116. $button = 0;
  8117. foreach ( $receiptList as $key => $value ) {
  8118. $receiptList [$key] ['Locate'] = $Locate;
  8119. $Locate ++;
  8120. $receiptList [$key] ['reviseDetail'] = array ();
  8121. if (! empty ( $value ['reviseDetail'] ))
  8122. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8123. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8124. $categoryDetil = $Lcategory->getOne ( array (
  8125. 'where' => 'cid=' . $value ['cid'],
  8126. 'asArray' => true
  8127. ) );
  8128. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8129. // 检测编辑状态
  8130. $verifyList = $verify->getOne ( array (
  8131. 'where' => 'vid=' . $value ['verify'],
  8132. 'asArray' => true
  8133. ) );
  8134. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8135. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8136. Doo::loadModel ( 'role' );
  8137. $role = new role ();
  8138. // print_r($verifyList);
  8139. $flag = true;
  8140. $roleKey = 0;
  8141. $endStaffArray = array ();
  8142. $roleArrayCopy = array ();
  8143. foreach ( $verifyList as $k => $v ) {
  8144. // init verifyStaff
  8145. if ($v [1] == 'ROLE') {
  8146. if (! empty ( $verifyStaff )) {
  8147. $endStaffArray = end ( $verifyStaff );
  8148. if ($v [0] == $endStaffArray ['nextStaff']) {
  8149. $roleId = $v [0];
  8150. }
  8151. }
  8152. $roleVerify = json_decode ( $v [3], true );
  8153. $roleKey = $k;
  8154. $roleArray = array ();
  8155. $rolename = $role->getOne ( array (
  8156. 'where' => 'rid=' . $v [0],
  8157. 'asArray' => true
  8158. ) );
  8159. foreach ( $roleVerify as $o => $p ) {
  8160. $staffID = explode ( '_', $p );
  8161. $staffInfo = $staff->getOne ( array (
  8162. 'where' => 'sid=' . $staffID [0],
  8163. 'asArray' => true
  8164. ) );
  8165. // print_r($staffID);
  8166. $exp = array (
  8167. 0 => $staffInfo ['sid'],
  8168. 1 => $staffID [1],
  8169. 2 => $staffInfo ['avatar'],
  8170. 'date' => '',
  8171. 'date' => '',
  8172. 'opinion' => '',
  8173. 'status' => '',
  8174. 'rolename' => $rolename ['name']
  8175. );
  8176. array_push ( $roleArray, $exp );
  8177. }
  8178. $roleArrayCopy [$v [0]] = $roleArray;
  8179. // $verifyList[$k]['roleArray']=$roleArray;
  8180. }
  8181. // print_r($roleArray);
  8182. $verifyList [$k] ['date'] = "";
  8183. $verifyList [$k] ['opinion'] = "";
  8184. $verifyList [$k] ['status'] = "";
  8185. if (empty ( $verifyStaff )) {
  8186. $verifyList [$k] ['date'] = "";
  8187. $verifyList [$k] ['opinion'] = "";
  8188. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8189. $verifyList [$k] ['status'] = 4;
  8190. $button = 4;
  8191. $flag = false;
  8192. }
  8193. } else {
  8194. foreach ( $verifyStaff as $m => $u ) {
  8195. if ($v [0] == $m) {
  8196. $verifyList [$k] ['date'] = $u ['date'];
  8197. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8198. $verifyList [$k] ['status'] = $u ['status'];
  8199. $flag = false;
  8200. break;
  8201. }
  8202. }
  8203. $endStaffArray = end ( $verifyStaff );
  8204. if (isset ( $endStaffArray ['ROLE'] )) {
  8205. } else {
  8206. $endKey = key ( $verifyStaff );
  8207. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8208. $button = 4;
  8209. $verifyList [$k] ['status'] = 4;
  8210. }
  8211. }
  8212. }
  8213. }
  8214. $rolename ['name'] = '';
  8215. if (! empty ( $roleId )) {
  8216. Doo::loadModel ( 'role' );
  8217. $role = new role ();
  8218. $rolename = $role->getOne ( array (
  8219. 'where' => 'rid=' . $roleId,
  8220. 'asArray' => true
  8221. ) );
  8222. }
  8223. if (! empty ( $verifyStaff ))
  8224. $endStaffArray = end ( $verifyStaff );
  8225. $KOP = false;
  8226. foreach ( $roleArrayCopy as $P => $A ) {
  8227. foreach ( $A as $MKI => $AVL ) {
  8228. if (! empty ( $verifyStaff )) {
  8229. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8230. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8231. $button = 4;
  8232. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8233. }
  8234. foreach ( $verifyStaff as $m => $u ) {
  8235. $AVLFK = $AVL [0] . '_R';
  8236. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8237. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8238. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8239. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8240. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8241. break;
  8242. }
  8243. }
  8244. } else {
  8245. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8246. $button = 4;
  8247. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8248. }
  8249. }
  8250. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8251. $KOP = true;
  8252. }
  8253. }
  8254. foreach ( $roleArrayCopy as $k => $v ) {
  8255. foreach ( $verifyList as $m => $n ) {
  8256. if ($n [0] == $k) {
  8257. array_splice ( $verifyList, $m, 1, $v );
  8258. }
  8259. }
  8260. }
  8261. $receiptList [$key] ['verifyList'] = $verifyList;
  8262. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8263. 'where' => 'sid=' . $value ['staff'],
  8264. 'asArray' => true
  8265. ) );
  8266. $receiptList [$key] ['button'] = $button;
  8267. }
  8268. $mothHtml = "";
  8269. for($i = 1; $i <= 12; $i ++) {
  8270. if ($month == $i)
  8271. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8272. else
  8273. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8274. }
  8275. // 获取审批日志
  8276. Doo::loadModel ( 'receiptLog' );
  8277. $receiptLog = new receiptLog ();
  8278. $rlList = array ();
  8279. $rlInfo = $receiptLog->getOne ( array (
  8280. 'where' => 'rid=' . $rid . ' and status=4',
  8281. 'asArray' => true
  8282. ) );
  8283. $tijdate = $receiptLog->getOne ( array (
  8284. 'where' => 'rid=' . $rid . ' and status=2',
  8285. 'asc' => 'rlid',
  8286. 'asArray' => true
  8287. ) );
  8288. if (! empty ( $rlInfo )) {
  8289. $rlList = $receiptLog->find ( array (
  8290. 'where' => 'rid=' . $rid,
  8291. 'asc' => 'rlid',
  8292. 'asArray' => true
  8293. ) );
  8294. }
  8295. $receiptList [0] ['rlList'] = $rlList;
  8296. $enclosurList = $enclosur->find ( array (
  8297. 'where' => 'rid=' . $rid,
  8298. 'asArray' => true
  8299. ) );
  8300. $enclosurHtml = '';
  8301. foreach ( $enclosurList as $value ) {
  8302. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8303. }
  8304. $data ['enclosurHtml'] = $enclosurHtml;
  8305. $data ['rolename'] = $rolename ['name'];
  8306. $data ['datetij'] = $tijdate ['date'];
  8307. $data ['mothHtml'] = $mothHtml;
  8308. $data ['receiptList'] = $receiptList;
  8309. $data ['receiptApprovalCount'] = count ( $receiptList );
  8310. $data ['year'] = $year;
  8311. $data ['categoryList'] = $categoryList;
  8312. $data ['staffList'] = $staffList;
  8313. $data ['cid'] = $cid;
  8314. $data ['sid'] = $sid;
  8315. $data ['status'] = 0;
  8316. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8317. $ap = 4;
  8318. } else
  8319. $data ['status'] = $receiptList [0] ['status'];
  8320. if ($receiptList [0] ['status'] == 4) {
  8321. $data ['status'] = 5;
  8322. $ap = 0;
  8323. }
  8324. $data ['ap'] = $ap;
  8325. $data ['memu'] = "receipt";
  8326. $data ['staff'] = $this->staff;
  8327. $data ['receiptMemu'] = 'approval';
  8328. $data ['verifyId'] = $this->verifyId;
  8329. $data ['executeId'] = $this->executeId;
  8330. $this->render ( "/admin/saeaReportListReport", $data );
  8331. }
  8332. function approvalEdi() {
  8333. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8334. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8335. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8336. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8337. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8338. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8339. if (empty ( $status ))
  8340. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8341. $vidList = array ();
  8342. $button = 0;
  8343. Doo::loadModel ( 'verify' );
  8344. Doo::loadModel ( 'receipt' );
  8345. Doo::loadModel ( 'staff' );
  8346. $staff = new staff ();
  8347. $receipt = new receipt ();
  8348. $verify = new verify ();
  8349. Doo::loadModel ( 'L_category' );
  8350. $Lcategory = new L_category ();
  8351. Doo::loadModel ( 'enclosur' );
  8352. $enclosur = new enclosur ();
  8353. // user verify ID
  8354. $verifyDetail = $verify->find ( array (
  8355. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8356. 'asArray' => true
  8357. ) );
  8358. foreach ( $verifyDetail as $key => $value ) {
  8359. array_push ( $vidList, $value ['vid'] );
  8360. }
  8361. $vid = implode ( ",", $vidList );
  8362. if (empty ( $verifyDetail ))
  8363. $vid = 0;
  8364. $categoryList = $Lcategory->find ( array (
  8365. 'asArray' => true
  8366. ) );
  8367. $staffList = $staff->find ( array (
  8368. 'where' => 'cid=' . $cid,
  8369. 'asArray' => true
  8370. ) );
  8371. $ap = "";
  8372. if ($status == 4) {
  8373. $ap = 4;
  8374. $status = 2;
  8375. }
  8376. // get Receipt By verifyID status 2
  8377. $receiptList = $receipt->find ( array (
  8378. 'where' => 'rid =' . $rid,
  8379. 'desc' => 'rid',
  8380. 'asArray' => true
  8381. ) );
  8382. $Locate = 0;
  8383. $roleId = 0;
  8384. if ($ap == 4)
  8385. $status = 4;
  8386. foreach ( $receiptList as $key => $value ) {
  8387. $receiptList [$key] ['Locate'] = $Locate;
  8388. $Locate ++;
  8389. $receiptList [$key] ['reviseDetail'] = array ();
  8390. if (! empty ( $value ['reviseDetail'] ))
  8391. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8392. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8393. $categoryDetil = $Lcategory->getOne ( array (
  8394. 'where' => 'cid=' . $value ['cid'],
  8395. 'asArray' => true
  8396. ) );
  8397. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8398. // 检测编辑状态
  8399. $verifyList = $verify->getOne ( array (
  8400. 'where' => 'vid=' . $value ['verify'],
  8401. 'asArray' => true
  8402. ) );
  8403. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8404. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8405. // print_r($verifyList);
  8406. //
  8407. // if (empty($verifyStaff)){
  8408. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8409. // $verifyList[0]['status']=4;$button=4;
  8410. // }
  8411. //
  8412. // }else{
  8413. //
  8414. // }
  8415. // die;
  8416. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8417. // echo array_search("green",$a);
  8418. //
  8419. Doo::loadModel ( 'role' );
  8420. $role = new role ();
  8421. // print_r($verifyList);
  8422. $flag = true;
  8423. $roleKey = 0;
  8424. $endStaffArray = array ();
  8425. $roleArrayCopy = array ();
  8426. foreach ( $verifyList as $k => $v ) {
  8427. // init verifyStaff
  8428. if ($v [1] == 'ROLE') {
  8429. if (! empty ( $verifyStaff )) {
  8430. $endStaffArray = end ( $verifyStaff );
  8431. if ($v [0] == $endStaffArray ['nextStaff']) {
  8432. $roleId = $v [0];
  8433. }
  8434. }
  8435. $roleVerify = json_decode ( $v [3], true );
  8436. $roleKey = $k;
  8437. $roleArray = array ();
  8438. $rolename = $role->getOne ( array (
  8439. 'where' => 'rid=' . $v [0],
  8440. 'asArray' => true
  8441. ) );
  8442. foreach ( $roleVerify as $o => $p ) {
  8443. $staffID = explode ( '_', $p );
  8444. $staffInfo = $staff->getOne ( array (
  8445. 'where' => 'sid=' . $staffID [0],
  8446. 'asArray' => true
  8447. ) );
  8448. // print_r($staffID);
  8449. $exp = array (
  8450. 0 => $staffInfo ['sid'],
  8451. 1 => $staffID [1],
  8452. 2 => $staffInfo ['avatar'],
  8453. 'date' => '',
  8454. 'date' => '',
  8455. 'opinion' => '',
  8456. 'status' => '',
  8457. 'rolename' => $rolename ['name']
  8458. );
  8459. array_push ( $roleArray, $exp );
  8460. }
  8461. $roleArrayCopy [$v [0]] = $roleArray;
  8462. // $verifyList[$k]['roleArray']=$roleArray;
  8463. }
  8464. // print_r($roleArray);
  8465. $verifyList [$k] ['date'] = "";
  8466. $verifyList [$k] ['opinion'] = "";
  8467. $verifyList [$k] ['status'] = "";
  8468. if (empty ( $verifyStaff )) {
  8469. $verifyList [$k] ['date'] = "";
  8470. $verifyList [$k] ['opinion'] = "";
  8471. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8472. $verifyList [$k] ['status'] = 4;
  8473. $button = 4;
  8474. $flag = false;
  8475. }
  8476. } else {
  8477. foreach ( $verifyStaff as $m => $u ) {
  8478. if ($v [0] == $m) {
  8479. $verifyList [$k] ['date'] = $u ['date'];
  8480. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8481. $verifyList [$k] ['status'] = $u ['status'];
  8482. $flag = false;
  8483. break;
  8484. }
  8485. }
  8486. $endStaffArray = end ( $verifyStaff );
  8487. if (isset ( $endStaffArray ['ROLE'] )) {
  8488. } else {
  8489. $endKey = key ( $verifyStaff );
  8490. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8491. $button = 4;
  8492. $verifyList [$k] ['status'] = 4;
  8493. }
  8494. }
  8495. // print_r($endStaffArray);die;
  8496. // if (empty($verifyStaff)){
  8497. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8498. // $verifyList[$k]['status']=4;$button=4;
  8499. // }
  8500. //
  8501. // }else{
  8502. //
  8503. // }
  8504. // if($flag){//检测可编辑
  8505. // if($v[0]==$this->staff[0]['sid']){
  8506. // $verifyList[$k]['status']=4;$button=4;
  8507. // }
  8508. // }
  8509. }
  8510. }
  8511. $rolename ['name'] = '';
  8512. if (! empty ( $roleId )) {
  8513. Doo::loadModel ( 'role' );
  8514. $role = new role ();
  8515. $rolename = $role->getOne ( array (
  8516. 'where' => 'rid=' . $roleId,
  8517. 'asArray' => true
  8518. ) );
  8519. }
  8520. if (! empty ( $verifyStaff ))
  8521. $endStaffArray = end ( $verifyStaff );
  8522. $KOP = false;
  8523. foreach ( $roleArrayCopy as $P => $A ) {
  8524. foreach ( $A as $MKI => $AVL ) {
  8525. if (! empty ( $verifyStaff )) {
  8526. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8527. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8528. $button = 4;
  8529. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8530. }
  8531. foreach ( $verifyStaff as $m => $u ) {
  8532. $AVLFK = $AVL [0] . '_R';
  8533. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8534. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8535. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8536. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8537. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8538. break;
  8539. }
  8540. }
  8541. } else {
  8542. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8543. $button = 4;
  8544. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8545. }
  8546. }
  8547. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8548. $KOP = true;
  8549. }
  8550. }
  8551. // print_r($roleArrayCopy);
  8552. // echo $roleKey;
  8553. foreach ( $roleArrayCopy as $k => $v ) {
  8554. foreach ( $verifyList as $m => $n ) {
  8555. if ($n [0] == $k) {
  8556. array_splice ( $verifyList, $m, 1, $v );
  8557. }
  8558. }
  8559. }
  8560. // if ($KOP)
  8561. // array_splice($verifyList,$roleKey,1,$roleArray);
  8562. // print_r($verifyList);
  8563. $receiptList [$key] ['verifyList'] = $verifyList;
  8564. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8565. 'where' => 'sid=' . $value ['staff'],
  8566. 'asArray' => true
  8567. ) );
  8568. $receiptList [$key] ['button'] = $button;
  8569. }
  8570. // $data['verifyDetail']=$verifyDetail;
  8571. $mothHtml = "";
  8572. for($i = 1; $i <= 12; $i ++) {
  8573. if ($month == $i)
  8574. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8575. else
  8576. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8577. }
  8578. // 获取审批日志
  8579. Doo::loadModel ( 'receiptLog' );
  8580. $receiptLog = new receiptLog ();
  8581. $rlList = array ();
  8582. $rlInfo = $receiptLog->getOne ( array (
  8583. 'where' => 'rid=' . $rid . ' and status=4',
  8584. 'asArray' => true
  8585. ) );
  8586. $tijdate = $receiptLog->getOne ( array (
  8587. 'where' => 'rid=' . $rid . ' and status=2',
  8588. 'asc' => 'rlid',
  8589. 'asArray' => true
  8590. ) );
  8591. if (! empty ( $rlInfo )) {
  8592. $rlList = $receiptLog->find ( array (
  8593. 'where' => 'rid=' . $rid,
  8594. 'asc' => 'rlid',
  8595. 'asArray' => true
  8596. ) );
  8597. }
  8598. $receiptList [0] ['rlList'] = $rlList;
  8599. $enclosurList = $enclosur->find ( array (
  8600. 'where' => 'rid=' . $rid,
  8601. 'asArray' => true
  8602. ) );
  8603. $enclosurHtml = '';
  8604. foreach ( $enclosurList as $value ) {
  8605. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8606. }
  8607. $data ['enclosurHtml'] = $enclosurHtml;
  8608. $data ['rolename'] = $rolename ['name'];
  8609. $data ['datetij'] = $tijdate ['date'];
  8610. $data ['mothHtml'] = $mothHtml;
  8611. $data ['receiptList'] = $receiptList;
  8612. $data ['receiptApprovalCount'] = count ( $receiptList );
  8613. $data ['status'] = $status;
  8614. $data ['year'] = $year;
  8615. $data ['categoryList'] = $categoryList;
  8616. $data ['staffList'] = $staffList;
  8617. $data ['cid'] = $cid;
  8618. $data ['sid'] = $sid;
  8619. $data ['ap'] = $ap;
  8620. $data ['memu'] = "receipt";
  8621. $data ['staff'] = $this->staff;
  8622. $data ['receiptMemu'] = 'approval';
  8623. $data ['verifyId'] = $this->verifyId;
  8624. $data ['executeId'] = $this->executeId;
  8625. $this->render ( "/admin/saeaReportListReport", $data );
  8626. }
  8627. function remittanceHky() {
  8628. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8629. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8630. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8631. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8632. $page_size = 15;
  8633. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8634. Doo::loadModel ( 'receipt' );
  8635. $receipt = new receipt ();
  8636. Doo::loadModel ( 'staff' );
  8637. $staff = new staff ();
  8638. $dateCondition = " and Year(executeDate) =" . $year;
  8639. if ($moth != 'MONTH')
  8640. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8641. if ($day != 'DAY' && $moth != 'MONTH')
  8642. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8643. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8644. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8645. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8646. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8647. $dayList = $receipt->find ( array (
  8648. 'select' => 'executeDate,sum(amount) as amount',
  8649. 'where' => $sql,
  8650. 'desc' => 'executeDate',
  8651. 'groupby' => 'executeDate',
  8652. 'limit' => $limit,
  8653. 'asArray' => true
  8654. ) );
  8655. // print_r($dayList);
  8656. foreach ( $dayList as $key => $value ) {
  8657. $remitString = "";
  8658. $receiptList = $receipt->find ( array (
  8659. 'select' => 'rid,executeDate,amount,staff,cid',
  8660. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8661. 'desc' => 'executeDate',
  8662. 'asArray' => true
  8663. ) );
  8664. foreach ( $receiptList as $k => $v ) {
  8665. $sinfo = $staff->getOne ( array (
  8666. 'select' => 'username,category',
  8667. 'where' => ' sid=' . $v ['staff'],
  8668. 'asArray' => true
  8669. ) );
  8670. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8671. }
  8672. $dayList [$key] ['staff'] = $remitString;
  8673. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8674. }
  8675. // print_r($dayList);
  8676. $mothHtml = "";
  8677. for($i = 1; $i <= 12; $i ++) {
  8678. if ($moth == $i)
  8679. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8680. else
  8681. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8682. }
  8683. $dayHtml = "";
  8684. if ($day != "DAY" || $moth != "MONTH") {
  8685. for($i = 1; $i <= 31; $i ++) {
  8686. if ($day == $i)
  8687. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8688. else
  8689. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8690. }
  8691. }
  8692. $dateHtml = "";
  8693. $now = date ( "Y" );
  8694. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8695. if ($YEARD <= $now) {
  8696. $dateHtml .= '<option ';
  8697. if ($year == $YEARD) {
  8698. $dateHtml .= 'selected ';
  8699. }
  8700. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8701. }
  8702. }
  8703. $data ['dateHtml'] = $dateHtml;
  8704. $data ['page'] = $pageinfo;
  8705. $data ['year'] = $year;
  8706. $data ['moth'] = $moth;
  8707. $data ['day'] = $day;
  8708. $data ['get'] = $get;
  8709. $data ['dayHtml'] = $dayHtml;
  8710. $data ['mothHtml'] = $mothHtml;
  8711. $data ['receiptList'] = $dayList;
  8712. $data ['memu'] = "receipt";
  8713. $data ['staff'] = $this->staff;
  8714. $data ['receiptMemu'] = 'remittanceHky';
  8715. $data ['verifyId'] = $this->verifyId;
  8716. $data ['executeId'] = $this->executeId;
  8717. $this->render ( "/admin/remittanceHky", $data );
  8718. }
  8719. function remittancep() {
  8720. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8721. Doo::loadModel ( 'receipt' );
  8722. $receipt = new receipt ();
  8723. Doo::loadModel ( 'staff' );
  8724. $staff = new staff ();
  8725. Doo::loadClass ( 'XDeode' );
  8726. $XDeode = new XDeode ( 5 );
  8727. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8728. $rplist = $receipt->find ( array (
  8729. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8730. 'asArray' => true
  8731. ) );
  8732. $dayList = $receipt->find ( array (
  8733. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8734. 'desc' => 'executeDate',
  8735. 'groupby' => 'staff',
  8736. 'asArray' => true
  8737. ) );
  8738. $html = '';
  8739. foreach ( $dayList as $key => $value ) {
  8740. $sinfo = $staff->getOne ( array (
  8741. 'select' => 'username,category',
  8742. 'where' => ' sid=' . $value ['staff'],
  8743. 'asArray' => true
  8744. ) );
  8745. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8746. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8747. $au = 0;
  8748. foreach ( $rplist as $k => $v ) {
  8749. if ($value ['staff'] == $v ['staff']) {
  8750. $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>';
  8751. $au += $v ['amount'];
  8752. }
  8753. }
  8754. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8755. }
  8756. $data ['html'] = $html;
  8757. $data ['memu'] = "receipt";
  8758. $data ['staff'] = $this->staff;
  8759. $data ['receiptMemu'] = 'remittanceHky';
  8760. $data ['verifyId'] = $this->verifyId;
  8761. $data ['executeId'] = $this->executeId;
  8762. $this->render ( "/admin/remittancep", $data );
  8763. }
  8764. function ajaxGetReceiptDetails() {
  8765. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8766. Doo::loadClass ( 'XDeode' );
  8767. $XDeode = new XDeode ( 5 );
  8768. $rid = $XDeode->decode ( $rid );
  8769. if (empty ( $rid )) {
  8770. echo json_encode ( array (
  8771. 'status' => 2,
  8772. 'msg' => 'illegal request'
  8773. ) );
  8774. die ();
  8775. }
  8776. Doo::loadModel ( 'receipt' );
  8777. $receipt = new receipt ();
  8778. Doo::loadModel ( 'staff' );
  8779. $staff = new staff ();
  8780. $rinfo = $receipt->getOne ( array (
  8781. 'where' => 'rid= ' . $rid,
  8782. 'asArray' => true
  8783. ) );
  8784. $sinfo = $staff->getOne ( array (
  8785. 'select' => 'username,category',
  8786. 'where' => ' sid=' . $rinfo ['staff'],
  8787. 'asArray' => true
  8788. ) );
  8789. $rinfo ['reviseDetail'] = array ();
  8790. if (! empty ( $rinfo ['reviseDetail'] ))
  8791. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8792. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8793. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8794. $rinfo ['category'] = $sinfo ['category'];
  8795. $verifyStaff = array ();
  8796. if (! empty ( $rinfo ['verifyStaff'] ))
  8797. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8798. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8799. $rinfo ['relust'] = $relust;
  8800. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8801. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8802. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8803. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8804. // 费用执行人相关数据
  8805. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8806. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8807. foreach ( $executeCopy as $k => $v ) {
  8808. $executeCopy [$k] ['date'] = '';
  8809. $executeCopy [$k] ['opinion'] = '';
  8810. $executeCopy [$k] ['status'] = '';
  8811. if (! empty ( $executeStaff ))
  8812. foreach ( $executeStaff as $m => $u ) {
  8813. if ($v [0] == $m) {
  8814. $executeCopy [$k] ['date'] = $u ['date'];
  8815. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8816. $executeCopy [$k] ['status'] = $u ['status'];
  8817. break;
  8818. }
  8819. }
  8820. }
  8821. $rinfo ['executeCopy'] = $executeCopy;
  8822. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8823. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8824. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8825. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8826. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8827. $html .= '<tr><th>' . $value ['name'] . '</th>
  8828. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8829. }
  8830. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8831. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8832. <tr><th class="taC" colspan="2">费用说明</th>
  8833. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8834. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8835. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8836. </tbody></table>';
  8837. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8838. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8839. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8840. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8841. $html .= '<tr><th>' . $value ['name'] . '</th>
  8842. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8843. }
  8844. $html .= '<tr><th class="taR">合计</th>
  8845. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8846. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8847. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8848. $html .= '<tr><th>' . $value ['name'] . '</th>
  8849. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8850. }
  8851. $html .= '<tr><th class="taR">合计</th>
  8852. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8853. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8854. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8855. $html .= '<tr><th>' . $value ['name'] . '</th>
  8856. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8857. }
  8858. $html .= '<tr><th class="taR">合计</th>
  8859. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8860. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8861. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8862. $html .= '<tr><th>' . $value ['name'] . '</th>
  8863. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8864. }
  8865. $html .= '<tr><th class="taR">合计</th>
  8866. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8867. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8868. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8869. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8870. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8871. }
  8872. $html .= '<tr><th class="taR">合计</th>
  8873. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8874. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8875. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8876. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8877. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8878. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8879. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8880. <tr';
  8881. if ($rinfo ['relust'] >= 0) {
  8882. $html .= 'class="success"';
  8883. } else {
  8884. $html .= 'class="error"';
  8885. }
  8886. $html .= '><td class="taR"><b>借款结余</b></td>
  8887. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8888. </tbody></table>
  8889. ';
  8890. }
  8891. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8892. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8893. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8894. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8895. $html .= '<tr><th>' . $value ['name'] . '</th>
  8896. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8897. }
  8898. $html .= '<tr><th class="taR">合计</th>
  8899. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8900. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8901. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8902. <tr><th class="taC" colspan="2">费用说明</th>
  8903. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8904. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8905. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8906. </tbody></table>';
  8907. } else {
  8908. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8909. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8910. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8911. $html .= '<tr><th>' . $value ['name'] . '</th>
  8912. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8913. }
  8914. $html .= '<tr><th class="taR">合计</th>
  8915. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8916. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8917. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8918. $html .= '<tr><th>' . $value ['name'] . '</th>
  8919. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8920. }
  8921. $html .= '<tr><th class="taR">合计</th>
  8922. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8923. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8924. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8925. $html .= '<tr><th>' . $value ['name'] . '</th>
  8926. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8927. }
  8928. $html .= '<tr><th class="taR">合计</th>
  8929. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8930. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8931. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8932. $html .= '<tr><th>' . $value ['name'] . '</th>
  8933. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8934. }
  8935. $html .= '<tr><th class="taR">合计</th>
  8936. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8937. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8938. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8939. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8940. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8941. }
  8942. $html .= '<tr><th class="taR">合计</th>
  8943. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8944. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8945. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8946. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8947. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8948. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8949. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8950. $html .= '</tbody></table>';
  8951. /*
  8952. * <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>
  8953. */
  8954. }
  8955. // print_r($verifyStaff);die;
  8956. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8957. foreach ( $verifyStaff as $key => $value ) {
  8958. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8959. $sinfo = $staff->getOne ( array (
  8960. 'select' => 'username',
  8961. 'where' => ' sid=' . $key,
  8962. 'asArray' => true
  8963. ) );
  8964. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8965. }
  8966. $html .= '</tbody></table>';
  8967. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8968. foreach ( $rinfo ['executeCopy'] as $value ) {
  8969. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8970. }
  8971. $html .= '</tbody></table>';
  8972. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8973. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8974. </tr></table>';
  8975. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8976. echo json_encode ( array (
  8977. 'status' => 1,
  8978. 'html' => $html
  8979. ) );
  8980. die ();
  8981. }
  8982. /**
  8983. * 删除附件
  8984. */
  8985. function ajaxRemEnclousur() {
  8986. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8987. if (empty ( $key ))
  8988. echo json_encode ( array (
  8989. 'status' => 2
  8990. ) );
  8991. Doo::loadModel ( 'enclosur' );
  8992. $enclosur = new enclosur ();
  8993. $enclosur->delEnclosurByEid ( $key );
  8994. echo json_encode ( array (
  8995. 'status' => 1
  8996. ) );
  8997. }
  8998. function remittance() {
  8999. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9000. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9001. Doo::loadModel ( 'receipt' );
  9002. $receipt = new receipt ();
  9003. Doo::loadModel ( 'staff' );
  9004. $staff = new staff ();
  9005. $dateCondition = " and Year(pastDate) =" . $year;
  9006. if (! empty ( $month ))
  9007. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  9008. // get Receipt By verifyID status 1
  9009. $receiptList = $receipt->find ( array (
  9010. 'select' => 'sum(sum) as sum,staff,pastDate',
  9011. 'where' => ' status=1' . $dateCondition,
  9012. 'desc' => 'pastDate',
  9013. 'groupby' => 'staff,pastDate',
  9014. 'asArray' => true
  9015. ) );
  9016. $dateList = $receipt->find ( array (
  9017. 'select' => 'pastDate,verifyStaff',
  9018. 'where' => ' status=1' . $dateCondition,
  9019. 'desc' => 'pastDate',
  9020. 'groupby' => 'pastDate',
  9021. 'asArray' => true
  9022. ) );
  9023. $dataList = array ();
  9024. foreach ( $dateList as $d => $a ) {
  9025. $dataList [$a ['pastDate']] = array ();
  9026. $daySum = 0;
  9027. foreach ( $receiptList as $key => $value ) {
  9028. if ($a ['pastDate'] == $value ['pastDate']) {
  9029. $oderList = $receipt->find ( array (
  9030. 'select' => 'receiptOrder',
  9031. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  9032. 'asArray' => true
  9033. ) );
  9034. $list = array ();
  9035. $html = "";
  9036. foreach ( $oderList as $v ) {
  9037. array_push ( $list, $v ['receiptOrder'] );
  9038. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  9039. }
  9040. $receiptList [$key] ['receiptOrder'] = $html;
  9041. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  9042. $sinfo = $staff->getOne ( array (
  9043. 'select' => 'username ',
  9044. 'where' => ' sid=' . $value ['staff'],
  9045. 'asArray' => true
  9046. ) );
  9047. $receiptList [$key] ['username'] = $sinfo ['username'];
  9048. $daySum += $value ['sum'];
  9049. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  9050. }
  9051. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  9052. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  9053. }
  9054. }
  9055. // print_r($dataList);
  9056. $data ['dataList'] = $dataList;
  9057. $mothHtml = "";
  9058. for($i = 1; $i <= 12; $i ++) {
  9059. if ($month == $i)
  9060. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9061. else
  9062. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9063. }
  9064. $data ['year'] = $year;
  9065. $data ['mothHtml'] = $mothHtml;
  9066. $data ['memu'] = "receipt";
  9067. $data ['staff'] = $this->staff;
  9068. $data ['receiptMemu'] = 'approval';
  9069. $data ['verifyId'] = $this->verifyId;
  9070. $data ['executeId'] = $this->executeId;
  9071. $this->render ( "/admin/saeaReportListPay", $data );
  9072. }
  9073. /**
  9074. * 金额调整,提高稳定性
  9075. * @return string
  9076. */
  9077. function revocationAdjustment() {
  9078. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  9079. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  9080. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  9081. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  9082. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  9083. Doo::loadClass ( 'XDeode' );
  9084. $XDeode = new XDeode ( 5 );
  9085. Doo::loadModel ( 'receipt' );
  9086. $receipt = new receipt ();
  9087. $sid = $XDeode->decode ( $sidKey );
  9088. $rid = $XDeode->decode ( $ridKey );
  9089. $reviseKey = $XDeode->decode ( $reviseKey );
  9090. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  9091. die ( 'illegal request' );
  9092. $receiptDetail = $receipt->getOne ( array (
  9093. 'where' => 'rid=' . $rid,
  9094. 'asArray' => true
  9095. ) );
  9096. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  9097. die ( 'illegal request' );
  9098. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9099. if (! isset ( $reviseDetail [$reviseKey] ))
  9100. die ( 'illegal request' );
  9101. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  9102. unset ( $reviseDetail [$reviseKey] );
  9103. $revisePrice = 0;
  9104. foreach ( $reviseDetail as $key => $value ) {
  9105. $revisePrice += $value ['price'];
  9106. }
  9107. $reviseDetailString = json_encode ( $reviseDetail );
  9108. $receipt->reviseDetail = $reviseDetailString;
  9109. $receipt->sum = $receiptDetail ['sum'] - $price;
  9110. $receipt->revisePrice = $revisePrice;
  9111. $receipt->update ( array (
  9112. 'where' => 'rid=' . $rid
  9113. ) );
  9114. return '/receiptburEdi/' . $rid;
  9115. } else
  9116. die ( 'illegal request2' );
  9117. }
  9118. function updateApprovalReceipt() {
  9119. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9120. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9121. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9122. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  9123. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  9124. if (! empty ( $rid )) {
  9125. Doo::loadModel ( "verify" );
  9126. $verify = new verify ();
  9127. Doo::loadModel ( "receiptDetail" );
  9128. $receiptDetailObj = new receiptDetail ();
  9129. Doo::loadModel ( "itemStatistics" );
  9130. Doo::loadModel ( "statistics" );
  9131. $statistics = new statistics ();
  9132. $itemStatistics = new itemStatistics ();
  9133. Doo::loadModel ( "receipt" );
  9134. $receipt = new receipt ();
  9135. $receiptDetail = $receipt->getOne ( array (
  9136. 'where' => 'rid=' . $rid . ' and status=2 ',
  9137. 'asArray' => true
  9138. ) );
  9139. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  9140. $nsflag = true;
  9141. foreach ( $nslist as $value ) {
  9142. if ($value == $this->staff ['0'] ['sid']) {
  9143. $nsflag = false;
  9144. break;
  9145. }
  9146. }
  9147. if (empty ( $receiptDetail ) || $nsflag)
  9148. return "/approvalExpenses/pendApproval";
  9149. $verifyDetail = $verify->getOne ( array (
  9150. 'where' => ' vid =' . $receiptDetail ['verify'],
  9151. 'asArray' => true
  9152. ) );
  9153. $verifyString = $verifyDetail ['staff'];
  9154. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  9155. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  9156. if (empty ( $opinion )) {
  9157. if ($status == 3)
  9158. $opinion = "终止";
  9159. else
  9160. $opinion = "同意支付";
  9161. }
  9162. $nowStaff = 0;
  9163. $nowStaffList = array ();
  9164. if (empty ( $verifyStaff )) {
  9165. // 还需加入是否已经进入角色审批
  9166. if ($verifyDetail [0] [1] == 'ROLE') {
  9167. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  9168. foreach ( $vStaffString as $key => $value ) {
  9169. $staffK = explode ( "_", $value );
  9170. if ($staffK [0] != $this->staff [0] ['sid'])
  9171. array_push ( $nowStaffList, $staffK [0] );
  9172. }
  9173. // print_r($verifyDetail);
  9174. // die;
  9175. if (! empty ( $nowStaffList )) {
  9176. $nowStaff = implode ( ',', $nowStaffList );
  9177. $verifyStaff = array (
  9178. $this->staff [0] ['sid'] . "_R" => array (
  9179. 'date' => date ( 'Y-m-d' ),
  9180. 'opinion' => $opinion,
  9181. 'status' => $status,
  9182. 'nextStaff' => $verifyDetail [0] [0],
  9183. 'ROLE' => 1
  9184. )
  9185. );
  9186. } else {
  9187. $nowStaff = $verifyDetail [1] [0];
  9188. $verifyStaff = array (
  9189. $this->staff [0] ['sid'] . "_R" => array (
  9190. 'date' => date ( 'Y-m-d' ),
  9191. 'opinion' => $opinion,
  9192. 'status' => $status,
  9193. 'nextStaff' => $verifyDetail [1] [0]
  9194. )
  9195. );
  9196. }
  9197. } else {
  9198. if ($verifyDetail [1] [1] == 'ROLE') {
  9199. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  9200. // echo "dd";
  9201. foreach ( $vStaffString as $key => $value ) {
  9202. $staffK = explode ( "_", $value );
  9203. array_push ( $nowStaffList, $staffK [0] );
  9204. }
  9205. $nowStaff = implode ( ',', $nowStaffList );
  9206. $verifyStaff = array (
  9207. $this->staff [0] ['sid'] => array (
  9208. 'date' => date ( 'Y-m-d' ),
  9209. 'opinion' => $opinion,
  9210. 'status' => $status,
  9211. 'nextStaff' => $verifyDetail [1] [0],
  9212. 'ROLE' => 1
  9213. )
  9214. );
  9215. } else {
  9216. $nowStaff = $verifyDetail [1] [0];
  9217. $verifyStaff = array (
  9218. $this->staff [0] ['sid'] => array (
  9219. 'date' => date ( 'Y-m-d' ),
  9220. 'opinion' => $opinion,
  9221. 'status' => $status,
  9222. 'nextStaff' => $verifyDetail [1] [0]
  9223. )
  9224. );
  9225. }
  9226. }
  9227. if ($status == 3)
  9228. $verifyStaff = array (
  9229. 'final' => $status,
  9230. $this->staff [0] ['sid'] => array (
  9231. 'date' => date ( 'Y-m-d' ),
  9232. 'opinion' => $opinion,
  9233. 'status' => $status
  9234. )
  9235. );
  9236. $vStaffString = json_encode ( $verifyStaff );
  9237. $receipt->nowStaff = $nowStaff;
  9238. $receipt->verifyStaff = $vStaffString;
  9239. } else {
  9240. $VS = end ( $verifyStaff );
  9241. // 非角色审批
  9242. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9243. $nextStaff = 0;
  9244. $roleSTF = false;
  9245. foreach ( $verifyDetail as $key => $value ) {
  9246. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9247. if (isset ( $verifyDetail [$key + 1] )) {
  9248. $nextStaff = $verifyDetail [$key + 1] [0];
  9249. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9250. $roleSTF = true;
  9251. }
  9252. break;
  9253. }
  9254. }
  9255. if (! $roleSTF) {
  9256. $nowStaff = $nextStaff;
  9257. $verifyStaff [$this->staff [0] ['sid']] = array (
  9258. 'date' => date ( 'Y-m-d' ),
  9259. 'opinion' => $opinion,
  9260. 'status' => $status,
  9261. 'nextStaff' => $nextStaff
  9262. );
  9263. } else {
  9264. // 获取角色下的所有用户ID
  9265. $nowStaffList = array ();
  9266. foreach ( $verifyDetail as $vfk ) {
  9267. if ($vfk [1] == 'ROLE') {
  9268. $vStaffString = json_decode ( $vfk [3] );
  9269. foreach ( $vStaffString as $key => $value ) {
  9270. $staffK = explode ( "_", $value );
  9271. array_push ( $nowStaffList, $staffK [0] );
  9272. }
  9273. }
  9274. }
  9275. $nowStaff = implode ( ',', $nowStaffList );
  9276. $verifyStaff [$this->staff [0] ['sid']] = array (
  9277. 'date' => date ( 'Y-m-d' ),
  9278. 'opinion' => $opinion,
  9279. 'status' => $status,
  9280. 'nextStaff' => $nextStaff,
  9281. 'ROLE' => 0
  9282. );
  9283. }
  9284. if ($status == 3) {
  9285. $verifyStaff ['final'] = $status;
  9286. $verifyStaff [$this->staff [0] ['sid']] = array (
  9287. 'date' => date ( 'Y-m-d' ),
  9288. 'opinion' => $opinion,
  9289. 'status' => $status
  9290. );
  9291. }
  9292. $vStaffString = json_encode ( $verifyStaff );
  9293. $receipt->nowStaff = $nowStaff;
  9294. $receipt->verifyStaff = $vStaffString;
  9295. }
  9296. // 角色审批
  9297. if (isset ( $VS ['ROLE'] )) {
  9298. // 找出角色人 当前审批角色组
  9299. $verifyJSStaff = array ();
  9300. $nowStaffList2 = array ();
  9301. foreach ( $verifyDetail as $key => $value ) {
  9302. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9303. $verifyJSStaff = json_decode ( $value [3] );
  9304. foreach ( $verifyJSStaff as $m ) {
  9305. $staffK = explode ( "_", $m );
  9306. array_push ( $nowStaffList2, $staffK [0] );
  9307. }
  9308. // print_r($nowStaffList2);
  9309. }
  9310. }
  9311. $RoleVerifyStaff = array ();
  9312. foreach ( $verifyStaff as $key => $value ) {
  9313. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9314. foreach ( $nowStaffList2 as $m ) {
  9315. if ($key == $m . "_R")
  9316. $RoleVerifyStaff [$key] = $value;
  9317. }
  9318. }
  9319. }
  9320. // print_r($verifyStaff);
  9321. // print_r($nowStaffList2);
  9322. // print_r($RoleVerifyStaff);
  9323. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9324. // print_r($verifyJSStaff);
  9325. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9326. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9327. // 下一个审批人ID
  9328. $nextStaff = 0;
  9329. $falg = false;
  9330. foreach ( $verifyDetail as $key => $value ) {
  9331. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9332. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9333. $falg = true;
  9334. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9335. $nowStaffList = array ();
  9336. foreach ( $vStaffString as $v ) {
  9337. $staffK = explode ( "_", $v );
  9338. array_push ( $nowStaffList, $staffK [0] );
  9339. }
  9340. $nowStaff = implode ( ',', $nowStaffList );
  9341. $nextStaff = $verifyDetail [$key + 1] [0];
  9342. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9343. $nextStaff = $verifyDetail [$key + 1] [0];
  9344. $nowStaff = $nextStaff;
  9345. } else
  9346. $nowStaff = '';
  9347. break;
  9348. }
  9349. }
  9350. if ($falg)
  9351. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9352. 'date' => date ( 'Y-m-d' ),
  9353. 'opinion' => $opinion,
  9354. 'status' => $status,
  9355. 'nextStaff' => $nextStaff,
  9356. 'ROLE' => 1
  9357. );
  9358. else
  9359. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9360. 'date' => date ( 'Y-m-d' ),
  9361. 'opinion' => $opinion,
  9362. 'status' => $status,
  9363. 'nextStaff' => $nextStaff
  9364. );
  9365. // print_r($verifyStaff);
  9366. // echo $nowStaff;die;
  9367. } else { // 进入下一个角色或者审批人
  9368. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9369. //
  9370. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9371. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9372. 'date' => date ( 'Y-m-d' ),
  9373. 'opinion' => $opinion,
  9374. 'status' => $status,
  9375. 'nextStaff' => $VS ['nextStaff'],
  9376. 'ROLE' => 1
  9377. );
  9378. // print_r($verifyStaff);
  9379. // die;
  9380. }
  9381. if ($status == 3) {
  9382. $verifyStaff ['final'] = $status;
  9383. $verifyStaff [$this->staff [0] ['sid']] = array (
  9384. 'date' => date ( 'Y-m-d' ),
  9385. 'opinion' => $opinion,
  9386. 'status' => $status
  9387. );
  9388. }
  9389. $vStaffString = json_encode ( $verifyStaff );
  9390. $receipt->verifyStaff = $vStaffString;
  9391. $receipt->nowStaff = $nowStaff;
  9392. // die;
  9393. // }
  9394. // print_r($verifyStaff);
  9395. // die;
  9396. }
  9397. // print_r($verifyStaff);die;
  9398. }
  9399. // print_r($verifyDetail);
  9400. $roleKey = 0;
  9401. $roleId = 0;
  9402. $verifyDetailCopy = array ();
  9403. foreach ( $verifyDetail as $k => $v ) {
  9404. if ($v [1] == 'ROLE') {
  9405. $roleId = $v [0];
  9406. $roleVerify = json_decode ( $v [3], true );
  9407. $roleKey = $k;
  9408. $roleArray = array ();
  9409. foreach ( $roleVerify as $o => $p ) {
  9410. $staffID = explode ( '_', $p );
  9411. $exp = array (
  9412. 0 => $staffID [0],
  9413. 1 => $staffID [1]
  9414. );
  9415. array_push ( $roleArray, $exp );
  9416. }
  9417. $verifyDetailCopy [$v [0]] = $roleArray;
  9418. }
  9419. }
  9420. // print_r($verifyDetail);
  9421. foreach ( $verifyDetailCopy as $k => $v ) {
  9422. foreach ( $verifyDetail as $m => $n ) {
  9423. if ($n [0] == $k) {
  9424. array_splice ( $verifyDetail, $m, 1, $v );
  9425. }
  9426. }
  9427. }
  9428. // die;
  9429. // if (!empty($roleArray))
  9430. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9431. // echo $roleId;
  9432. // print_r($verifyStaff);
  9433. // print_r($verifyDetail);
  9434. // die;
  9435. Doo::loadModel ( "receiptLog" );
  9436. $receiptLog = new receiptLog ();
  9437. // 审批日志
  9438. if (! isset ( $verifyStaff ['final'] )) {
  9439. if (! empty ( $roleId )) {
  9440. Doo::loadModel ( "role" );
  9441. $role = new role ();
  9442. $roleInfo = $role->getOne ( array (
  9443. 'where' => 'rid=' . $roleId,
  9444. 'asArray' => true
  9445. ) );
  9446. $receiptLog->rolename = $roleInfo ['name'];
  9447. }
  9448. $receiptLog->username = $this->staff [0] ['username'];
  9449. $receiptLog->uid = $this->staff [0] ['sid'];
  9450. $receiptLog->date = date ( "Y-m-d" );
  9451. $receiptLog->opinion = $opinion;
  9452. $receiptLog->img = $this->staff [0] ['avatar'];
  9453. $receiptLog->status = 1;
  9454. $receiptLog->rid = $rid;
  9455. $receiptLog->insert ();
  9456. }
  9457. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9458. $receipt->verifyBreakup = $verifyString;
  9459. $receipt->status = 3;
  9460. $receiptDetailObj->status = 3;
  9461. $receiptDetailObj->update ( array (
  9462. 'where' => 'rid=' . $rid
  9463. ) );
  9464. if (! empty ( $roleId )) {
  9465. Doo::loadModel ( "role" );
  9466. $role = new role ();
  9467. $roleInfo = $role->getOne ( array (
  9468. 'where' => 'rid=' . $roleId,
  9469. 'asArray' => true
  9470. ) );
  9471. $receiptLog->rolename = $roleInfo ['name'];
  9472. }
  9473. $receiptLog->username = $this->staff [0] ['username'];
  9474. $receiptLog->uid = $this->staff [0] ['sid'];
  9475. $receiptLog->date = date ( "Y-m-d" );
  9476. $receiptLog->opinion = $opinion;
  9477. $receiptLog->img = $this->staff [0] ['avatar'];
  9478. $receiptLog->status = 3;
  9479. $receiptLog->rid = $rid;
  9480. $receiptLog->insert ();
  9481. //删除行程单
  9482. Doo::loadModel ( 'itinerary' );
  9483. $itinerary = new itinerary ();
  9484. $itinerary->delete ( array (
  9485. 'where' => 'rid="' . $rid . '"'
  9486. ) );
  9487. // 微信企业号通知
  9488. $this->setWXMsg ( $rid, 3 );
  9489. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9490. $receipt->status = 1;
  9491. $reviseSum = 0;
  9492. $receipt->verifyBreakup = $verifyString;
  9493. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9494. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9495. foreach ( $reviseDetail as $key => $value ) {
  9496. $receiptDetailObj = new receiptDetail ();
  9497. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9498. $receiptDetailObj->item = $value ['description'];
  9499. $receiptDetailObj->itemCategory = "报销金额调整";
  9500. $receiptDetailObj->price = $value ['price'];
  9501. $receiptDetailObj->date = $receiptDetail ['date'];
  9502. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9503. $receiptDetailObj->rid = $rid;
  9504. $receiptDetailObj->status = 1;
  9505. $receiptDetailObj->insert ();
  9506. $reviseSum += $value ['price'];
  9507. }
  9508. $itemStatistics = new itemStatistics ();
  9509. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9510. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9511. $itemStatistics->price = $reviseSum;
  9512. $itemStatistics->itemCategory = "报销金额调整";
  9513. $itemStatistics->date = $receiptDetail ['date'];
  9514. $itemStatistics->insert ();
  9515. }
  9516. $receiptDetailObj = new receiptDetail ();
  9517. $receiptDetailObj->status = 1;
  9518. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9519. $receiptDetailObj->update ( array (
  9520. 'where' => 'rid=' . $rid
  9521. ) );
  9522. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9523. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9524. $stat = $statistics->getOne ( array (
  9525. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9526. 'asArray' => true
  9527. ) );
  9528. if (empty ( $stat )) {
  9529. $statistics->date = $receiptDetail ['date'];
  9530. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9531. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9532. $statistics->agPrice = $receiptDetail ['sum'];
  9533. $statistics->rePrice = $reviseSum;
  9534. $statistics->insert ();
  9535. } else {
  9536. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9537. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9538. $statistics->update ( array (
  9539. 'where' => 'sid=' . $stat ['sid']
  9540. ) );
  9541. }
  9542. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9543. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9544. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9545. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9546. if ($key == "agencySum") {
  9547. $iStatistics = $itemStatistics->getOne ( array (
  9548. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9549. 'asArray' => true
  9550. ) );
  9551. if (empty ( $iStatistics )) {
  9552. $itemStatistics->cid = $receiptDetail ['cid'];
  9553. ;
  9554. $itemStatistics->staff = $receiptDetail ['staff'];
  9555. $itemStatistics->price = $value;
  9556. $itemStatistics->itemCategory = $this->AGENCY;
  9557. $itemStatistics->date = $receiptDetail ['date'];
  9558. $itemStatistics->insert ();
  9559. } else {
  9560. if (! empty ( $value )) {
  9561. $itemStatistics->price = $value + $iStatistics ['price'];
  9562. $itemStatistics->update ( array (
  9563. 'where' => 'sid=' . $iStatistics ['sid']
  9564. ) );
  9565. }
  9566. }
  9567. } elseif ($key == "travelSum") {
  9568. $iStatistics = $itemStatistics->getOne ( array (
  9569. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9570. 'asArray' => true
  9571. ) );
  9572. if (empty ( $iStatistics )) {
  9573. $itemStatistics->cid = $receiptDetail ['cid'];
  9574. $itemStatistics->staff = $receiptDetail ['staff'];
  9575. $itemStatistics->price = $value;
  9576. $itemStatistics->itemCategory = $this->TRAVEL;
  9577. $itemStatistics->date = $receiptDetail ['date'];
  9578. $itemStatistics->insert ();
  9579. } else {
  9580. if (! empty ( $value )) {
  9581. $itemStatistics->price = $value + $iStatistics ['price'];
  9582. $itemStatistics->update ( array (
  9583. 'where' => 'sid=' . $iStatistics ['sid']
  9584. ) );
  9585. }
  9586. }
  9587. } elseif ($key == "trainSum") {
  9588. $iStatistics = $itemStatistics->getOne ( array (
  9589. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9590. 'asArray' => true
  9591. ) );
  9592. if (empty ( $iStatistics )) {
  9593. $itemStatistics->cid = $receiptDetail ['cid'];
  9594. $itemStatistics->staff = $receiptDetail ['staff'];
  9595. $itemStatistics->price = $value;
  9596. $itemStatistics->itemCategory = $this->TRAIN;
  9597. $itemStatistics->date = $receiptDetail ['date'];
  9598. $itemStatistics->insert ();
  9599. } else {
  9600. if (! empty ( $value )) {
  9601. $itemStatistics->price = $value + $iStatistics ['price'];
  9602. $itemStatistics->update ( array (
  9603. 'where' => 'sid=' . $iStatistics ['sid']
  9604. ) );
  9605. }
  9606. }
  9607. } elseif ($key == "otherSum") {
  9608. $iStatistics = $itemStatistics->getOne ( array (
  9609. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9610. 'asArray' => true
  9611. ) );
  9612. if (empty ( $iStatistics )) {
  9613. $itemStatistics->cid = $receiptDetail ['cid'];
  9614. $itemStatistics->staff = $receiptDetail ['staff'];
  9615. $itemStatistics->price = $value;
  9616. $itemStatistics->itemCategory = $this->OTHER;
  9617. $itemStatistics->date = $receiptDetail ['date'];
  9618. $itemStatistics->insert ();
  9619. } else {
  9620. if (! empty ( $value )) {
  9621. $itemStatistics->price = $value + $iStatistics ['price'];
  9622. $itemStatistics->update ( array (
  9623. 'where' => 'sid=' . $iStatistics ['sid']
  9624. ) );
  9625. }
  9626. }
  9627. }
  9628. }
  9629. $receipt->pastDate = date ( "Y-m-d" );
  9630. // 微信企业号通知
  9631. $this->setWXMsg ( $rid, 1 );
  9632. }
  9633. //是否有流水
  9634. Doo::loadModel ( 'wasteBook' );
  9635. $wasteBook = new wasteBook ();
  9636. $accountType=3;
  9637. if ($receiptDetail['Rtype']==1){
  9638. $accountType=2;
  9639. }elseif($receiptDetail['Rtype']==2){
  9640. $accountType=4;
  9641. }
  9642. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9643. if (empty($wbDetail)){
  9644. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9645. $receipt->amount = $rsum;//$amount;
  9646. }
  9647. $receipt->update ( array (
  9648. 'where' => ' rid = ' . $rid
  9649. ) );
  9650. // 进入下一条审批费用新加需求
  9651. $vidList = array ();
  9652. $verifyDetail = $verify->find ( array (
  9653. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9654. 'asArray' => true
  9655. ) );
  9656. foreach ( $verifyDetail as $key => $value ) {
  9657. array_push ( $vidList, $value ['vid'] );
  9658. }
  9659. $vid = implode ( ",", $vidList );
  9660. if (empty ( $verifyDetail ))
  9661. $vid = 0;
  9662. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9663. $receipt = new receipt ();
  9664. $rd = $receipt->getOne ( array (
  9665. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9666. 'asc' => 'rid',
  9667. 'asArray' => true
  9668. ) );
  9669. if (empty ( $rd )) {
  9670. return '/approvalExpenses/pendApproval';
  9671. }
  9672. if ($rd ['Rtype'] == 1) {
  9673. if ($rd ['isBK'] == 1) {
  9674. return '/receiptburEdi/' . $rd ['rid'];
  9675. } else {
  9676. return '/expensesEdi/' . $rd ['rid'];
  9677. }
  9678. } elseif ($rd ['Rtype'] == 2) {
  9679. return '/remitApproval/' . $rd ['rid'];
  9680. } else {
  9681. return '/receiptburEdi/' . $rd ['rid'];
  9682. }
  9683. // return "/approvalExpenses/pendApproval";
  9684. }
  9685. }
  9686. function expensesRetreats() {
  9687. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9688. if (! empty ( $rid )) {
  9689. // 操作记录
  9690. Doo::loadModel ( "receipt" );
  9691. $receipt = new receipt ();
  9692. Doo::loadModel ( "receiptLog" );
  9693. $receiptLog = new receiptLog ();
  9694. Doo::loadModel ( "verify" );
  9695. $verify = new verify ();
  9696. $receiptInfo = $receipt->getOne ( array (
  9697. 'where' => 'rid=' . $rid,
  9698. 'asArray' => true
  9699. ) );
  9700. $vr = $verify->getOne ( array (
  9701. 'where' => 'vid=' . $receiptInfo ['verify'],
  9702. 'asArray' => true
  9703. ) );
  9704. $jd = json_decode ( $vr ['staff'] );
  9705. $roleId = 0;
  9706. foreach ( $jd as $key => $value ) {
  9707. if ($value [1] == 'ROLE') {
  9708. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9709. if ($pos !== false) {
  9710. $roleId = $value [0];
  9711. }
  9712. }
  9713. }
  9714. // 审批日志
  9715. // echo $roleId;die;
  9716. if (! empty ( $roleId )) {
  9717. Doo::loadModel ( "role" );
  9718. $role = new role ();
  9719. $roleInfo = $role->getOne ( array (
  9720. 'where' => 'rid=' . $roleId,
  9721. 'asArray' => true
  9722. ) );
  9723. $receiptLog->rolename = $roleInfo ['name'];
  9724. }
  9725. $receiptLog->username = $this->staff [0] ['username'];
  9726. $receiptLog->uid = $this->staff [0] ['sid'];
  9727. $receiptLog->date = date ( "Y-m-d" );
  9728. $receiptLog->opinion = '撤回';
  9729. $receiptLog->img = $this->staff [0] ['avatar'];
  9730. $receiptLog->status = 4;
  9731. $receiptLog->rid = $rid;
  9732. $receiptLog->insert ();
  9733. $receipt->status = 4;
  9734. $receipt->update ( array (
  9735. 'where' => 'rid=' . $rid
  9736. ) );
  9737. // 微信企业号通知
  9738. $this->setWXMsg ( $rid, 2 );
  9739. }
  9740. // echo "ddd";
  9741. return '/approvalExpenses/pendApproval';
  9742. }
  9743. function updateCheReceipt() {
  9744. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9745. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9746. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9747. if (! empty ( $rid )) {
  9748. // 操作记录
  9749. Doo::loadModel ( "receipt" );
  9750. $receipt = new receipt ();
  9751. Doo::loadModel ( "receiptLog" );
  9752. $receiptLog = new receiptLog ();
  9753. Doo::loadModel ( "verify" );
  9754. $verify = new verify ();
  9755. $receiptInfo = $receipt->getOne ( array (
  9756. 'where' => 'rid=' . $rid . ' and status=2',
  9757. 'asArray' => true
  9758. ) );
  9759. if (empty ( $receiptInfo )) {
  9760. echo json_encode ( array (
  9761. 'status' => 2
  9762. ) );
  9763. die ();
  9764. }
  9765. $vr = $verify->getOne ( array (
  9766. 'where' => 'vid=' . $receiptInfo ['verify'],
  9767. 'asArray' => true
  9768. ) );
  9769. $jd = json_decode ( $vr ['staff'] );
  9770. $roleId = 0;
  9771. foreach ( $jd as $key => $value ) {
  9772. if ($value [1] == 'ROLE') {
  9773. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9774. if ($pos !== false) {
  9775. $roleId = $value [0];
  9776. }
  9777. }
  9778. }
  9779. // 审批日志
  9780. // echo $roleId;die;
  9781. if (! empty ( $roleId )) {
  9782. Doo::loadModel ( "role" );
  9783. $role = new role ();
  9784. $roleInfo = $role->getOne ( array (
  9785. 'where' => 'rid=' . $roleId,
  9786. 'asArray' => true
  9787. ) );
  9788. $receiptLog->rolename = $roleInfo ['name'];
  9789. }
  9790. $receiptLog->username = $this->staff [0] ['username'];
  9791. $receiptLog->uid = $this->staff [0] ['sid'];
  9792. $receiptLog->date = date ( "Y-m-d" );
  9793. $receiptLog->opinion = $opinion;
  9794. $receiptLog->img = $this->staff [0] ['avatar'];
  9795. $receiptLog->status = 4;
  9796. $receiptLog->rid = $rid;
  9797. $receiptLog->insert ();
  9798. $receipt->status = 4;
  9799. $receipt->update ( array (
  9800. 'where' => 'rid=' . $rid
  9801. ) );
  9802. // 微信企业号通知
  9803. $this->setWXMsg ( $rid, 2 );
  9804. echo json_encode ( array (
  9805. 'status' => 1
  9806. ) );
  9807. // Header("HTTP/1.1 303 See Other");
  9808. // Header("Location: /approvalExpenses/pendApproval");
  9809. die ();
  9810. }
  9811. echo json_encode ( array (
  9812. 'status' => 2
  9813. ) );
  9814. die ();
  9815. // echo "ddd";
  9816. // return '/saeaBorad';
  9817. }
  9818. function revisePrice() {
  9819. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9820. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9821. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9822. // echo $price;die;
  9823. if (! empty ( $rid )) {
  9824. Doo::loadModel ( "receipt" );
  9825. $receipt = new receipt ();
  9826. $receiptDetail = $receipt->getOne ( array (
  9827. 'where' => 'rid=' . $rid . ' and status=2 ',
  9828. 'asArray' => true
  9829. ) );
  9830. if (empty ( $receiptDetail ))
  9831. die ( 'illegal request' );
  9832. $reviseDetail = array ();
  9833. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9834. array_push ( $reviseDetail, array (
  9835. 'sid' => $this->staff [0] ['sid'],
  9836. 'name' => $this->staff [0] ['username'],
  9837. 'description' => $description,
  9838. 'price' => $price
  9839. ) );
  9840. $reviseDetailString = json_encode ( $reviseDetail );
  9841. $receipt->reviseDetail = $reviseDetailString;
  9842. $receipt->revisePrice = $price;
  9843. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9844. } else {
  9845. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9846. array_push ( $reviseDetail, array (
  9847. 'sid' => $this->staff [0] ['sid'],
  9848. 'name' => $this->staff [0] ['username'],
  9849. 'description' => $description,
  9850. 'price' => $price
  9851. ) );
  9852. $reviseDetailString = json_encode ( $reviseDetail );
  9853. $receipt->reviseDetail = $reviseDetailString;
  9854. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9855. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9856. }
  9857. $receipt->update ( array (
  9858. 'where' => 'rid=' . $rid
  9859. ) );
  9860. if ($receiptDetail ['Rtype'] == 1) {
  9861. if ($receiptDetail ['isBK'] == 1) {
  9862. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9863. }
  9864. } elseif ($receiptDetail ['Rtype'] == 2) {
  9865. } else {
  9866. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9867. }
  9868. }
  9869. die ( 'illegal request' );
  9870. }
  9871. function personalCollect() {
  9872. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9873. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9874. $this->showCache ( $path );
  9875. Doo::loadModel ( "receiptDetail" );
  9876. Doo::loadModel ( "itemStatistics" );
  9877. Doo::loadModel ( 'statistics' );
  9878. $statistics = new statistics ();
  9879. $itemStatistics = new itemStatistics ();
  9880. $receiptDetail = new receiptDetail ();
  9881. $receiptCollectList = $receiptDetail->find ( array (
  9882. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9883. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9884. 'groupby' => 'itemCategory,Month(date)',
  9885. 'asArray' => true
  9886. ) );
  9887. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9888. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9889. 'asArray' => true
  9890. ) );
  9891. // create collect html
  9892. $collectArray = array (
  9893. '日常相关费用' => array (),
  9894. '差旅相关费用' => array (),
  9895. '培训班费用' => array (),
  9896. '其他' => array ()
  9897. );
  9898. $adjustment = array ();
  9899. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9900. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9901. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9902. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9903. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9904. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9905. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9906. array_push ( $collectArray ['其他'], $collectHtml );
  9907. $data ['collectArray'] = $collectArray;
  9908. // statistics html
  9909. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9910. if (empty ( $stList ))
  9911. $stList = array (
  9912. 'rePrice' => 0,
  9913. 'agPrice' => 0
  9914. );
  9915. $data ['stList'] = array (
  9916. 'rePrice' => $stList ['rePrice'],
  9917. 'agPrice' => $stList ['agPrice'],
  9918. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9919. );
  9920. // Adjustment price html
  9921. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9922. array_push ( $adjustment, $collectHtml );
  9923. $data ['adjustment'] = $adjustment;
  9924. // total price html
  9925. $collectHtml = "";
  9926. $total = 0;
  9927. for($i = 1; $i <= 12; $i ++) {
  9928. $sumPrice = 0;
  9929. foreach ( $receiptCollectList as $key => $value ) {
  9930. if ($value ['month'] == $i) {
  9931. $sumPrice += $value ['price'];
  9932. }
  9933. }
  9934. if ($sumPrice == 0)
  9935. $collectHtml .= '<td class="taR">-</td>';
  9936. else
  9937. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9938. $total += $sumPrice;
  9939. }
  9940. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9941. $data ['totalPrice'] = $collectHtml;
  9942. $dateHtml = "";
  9943. $now = date ( "Y" );
  9944. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9945. if ($YEARD <= $now) {
  9946. $dateHtml .= '<option ';
  9947. if ($year == $YEARD) {
  9948. $dateHtml .= 'selected ';
  9949. }
  9950. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9951. }
  9952. }
  9953. $data ['dateHtml'] = $dateHtml;
  9954. $data ['year'] = $year;
  9955. $data ['totalYear'] = $total;
  9956. $data ['memu'] = "receipt";
  9957. $data ['staff'] = $this->staff;
  9958. $data ['receiptMemu'] = 'personalCollect';
  9959. $data ['verifyId'] = $this->verifyId;
  9960. $data ['executeId'] = $this->executeId;
  9961. // year staff status 2,4
  9962. if ($year < date ( "Y" )) {
  9963. Doo::loadModel ( 'receipt' );
  9964. $receipt = new receipt ();
  9965. $receiptList = $receipt->find ( array (
  9966. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9967. 'asArray' => true
  9968. ) );
  9969. if (empty ( $receiptList )) {
  9970. ob_start ();
  9971. $this->render ( "/admin/saea_slist_collect", $data );
  9972. $this->cacheFile ( $path );
  9973. die ();
  9974. }
  9975. }
  9976. $this->render ( "/admin/saea_slist_collect", $data );
  9977. }
  9978. function personalCollectDetail() {
  9979. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9980. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9981. $this->showCache ( $path );
  9982. Doo::loadModel ( "receiptDetail" );
  9983. Doo::loadModel ( "itemStatistics" );
  9984. Doo::loadModel ( 'statistics' );
  9985. Doo::loadModel ( 'accountItem' );
  9986. $accountItem = new accountItem ();
  9987. $statistics = new statistics ();
  9988. $itemStatistics = new itemStatistics ();
  9989. $receiptDetail = new receiptDetail ();
  9990. $receiptCollectList = $receiptDetail->find ( array (
  9991. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9992. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9993. 'groupby' => 'item,Month(date)',
  9994. 'asArray' => true
  9995. ) );
  9996. $accountList = $accountItem->find ( array (
  9997. 'asArray' => true
  9998. ) );
  9999. // create CollectDetail HTML
  10000. $collectHtml = array ();
  10001. foreach ( $accountList as $key => $value ) {
  10002. $html = "";
  10003. $asum = 0;
  10004. for($i = 1; $i <= 12; $i ++) {
  10005. $falg = true;
  10006. foreach ( $receiptCollectList as $v ) {
  10007. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10008. $asum += $v ['price'];
  10009. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10010. $falg = false;
  10011. break;
  10012. }
  10013. }
  10014. if ($falg)
  10015. $html .= '<td class="taR">-</td>';
  10016. }
  10017. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10018. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10019. }
  10020. $data ['collectHtml'] = $collectHtml;
  10021. // create Adjustment price html
  10022. $receiptCollectList = $receiptDetail->find ( array (
  10023. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  10024. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  10025. 'groupby' => 'itemCategory,Month(date)',
  10026. 'asArray' => true
  10027. ) );
  10028. $adjustment = array ();
  10029. $collectArray = array (
  10030. '日常相关费用' => array (),
  10031. '差旅相关费用' => array (),
  10032. '培训班费用' => array (),
  10033. '其他' => array ()
  10034. );
  10035. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10036. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10037. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10038. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10039. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10040. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10041. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10042. array_push ( $collectArray ['其他'], $collectHtml );
  10043. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10044. array_push ( $adjustment, $collectHtml );
  10045. // total price html
  10046. $collectHtml = "";
  10047. $total = 0;
  10048. for($i = 1; $i <= 12; $i ++) {
  10049. $sumPrice = 0;
  10050. foreach ( $receiptCollectList as $key => $value ) {
  10051. if ($value ['month'] == $i) {
  10052. $sumPrice += $value ['price'];
  10053. }
  10054. }
  10055. if ($sumPrice == 0)
  10056. $collectHtml .= '<td class="taR">-</td>';
  10057. else
  10058. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10059. $total += $sumPrice;
  10060. }
  10061. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10062. // statistics html
  10063. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  10064. if (empty ( $stList ))
  10065. $stList = array (
  10066. 'rePrice' => 0,
  10067. 'agPrice' => 0
  10068. );
  10069. $data ['stList'] = array (
  10070. 'rePrice' => $stList ['rePrice'],
  10071. 'agPrice' => $stList ['agPrice'],
  10072. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10073. );
  10074. $data ['collectArray'] = $collectArray;
  10075. $data ['adjustment'] = $adjustment;
  10076. $data ['totalPrice'] = $collectHtml;
  10077. $data ['totalYear'] = $total;
  10078. $data ['year'] = $year;
  10079. $dateHtml = "";
  10080. $now = date ( "Y" );
  10081. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10082. if ($YEARD <= $now) {
  10083. $dateHtml .= '<option ';
  10084. if ($year == $YEARD) {
  10085. $dateHtml .= 'selected ';
  10086. }
  10087. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10088. }
  10089. }
  10090. $data ['dateHtml'] = $dateHtml;
  10091. $data ['memu'] = "receipt";
  10092. $data ['staff'] = $this->staff;
  10093. $data ['receiptMemu'] = 'personalCollect';
  10094. $data ['verifyId'] = $this->verifyId;
  10095. $data ['executeId'] = $this->executeId;
  10096. // year staff status 2,4
  10097. if ($year < date ( "Y" )) {
  10098. Doo::loadModel ( 'receipt' );
  10099. $receipt = new receipt ();
  10100. $receiptList = $receipt->find ( array (
  10101. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  10102. 'asArray' => true
  10103. ) );
  10104. if (empty ( $receiptList )) {
  10105. ob_start ();
  10106. $this->render ( "/admin/saeaCollectArticles", $data );
  10107. $this->cacheFile ( $path );
  10108. die ();
  10109. }
  10110. }
  10111. $this->render ( "/admin/saeaCollectArticles", $data );
  10112. }
  10113. function companyCategoryCollect() {
  10114. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10115. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  10116. $this->showCache ( $path );
  10117. Doo::loadModel ( 'L_category' );
  10118. Doo::loadModel ( 'itemStatistics' );
  10119. Doo::loadModel ( 'statistics' );
  10120. $statistics = new statistics ();
  10121. $Lcategory = new L_category ();
  10122. $itemStatistics = new itemStatistics ();
  10123. Doo::loadModel ( "receiptAuthorityManage" );
  10124. $receiptAuthorityManage = new receiptAuthorityManage ();
  10125. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10126. $cidList = array ();
  10127. foreach ( $imcStaff as $key => $value ) {
  10128. array_push ( $cidList, $value ['cid'] );
  10129. }
  10130. $cidString = implode ( ',', $cidList );
  10131. $LcategoryList = $Lcategory->find ( array (
  10132. 'where' => ' cid in (' . $cidString . ')',
  10133. 'asArray' => true
  10134. ) ); // 'staff='.$this->staff[0]['sid']." and
  10135. $itemStatisticsList = $itemStatistics->find ( array (
  10136. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10137. 'where' => " Year(date)=" . $year,
  10138. 'groupby' => 'cid,Month(date)',
  10139. 'asArray' => true
  10140. ) );
  10141. // ceatre companyCollectHtml
  10142. foreach ( $LcategoryList as $value ) {
  10143. $html = "";
  10144. $asum = 0;
  10145. for($i = 1; $i <= 12; $i ++) {
  10146. $falg = true;
  10147. foreach ( $itemStatisticsList as $v ) {
  10148. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  10149. $asum += $v ['price'];
  10150. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10151. $falg = false;
  10152. break;
  10153. }
  10154. }
  10155. if ($falg)
  10156. $html .= '<td class="taR">-</td>';
  10157. }
  10158. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10159. $collectHtml [$value ['title']] = array (
  10160. 'html' => $html,
  10161. 'cid' => $value ['cid']
  10162. );
  10163. }
  10164. $data ['companyHtml'] = $collectHtml;
  10165. // total price html
  10166. $collectHtml = "";
  10167. $total = 0;
  10168. for($i = 1; $i <= 12; $i ++) {
  10169. $sumPrice = 0;
  10170. foreach ( $itemStatisticsList as $key => $value ) {
  10171. if ($value ['month'] == $i) {
  10172. $sumPrice += $value ['price'];
  10173. }
  10174. }
  10175. if ($sumPrice == 0)
  10176. $collectHtml .= '<td class="taR">-</td>';
  10177. else
  10178. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10179. $total += $sumPrice;
  10180. }
  10181. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10182. $data ['companyTotalHtml'] = $collectHtml;
  10183. $data ['total'] = $total;
  10184. // statistics html
  10185. // echo $cidString;
  10186. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10187. if (empty ( $stList ))
  10188. $stList = array (
  10189. 'rePrice' => 0,
  10190. 'agPrice' => 0
  10191. );
  10192. $data ['stList'] = array (
  10193. 'rePrice' => $stList ['rePrice'],
  10194. 'agPrice' => $stList ['agPrice'],
  10195. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10196. );
  10197. $data ['year'] = $year;
  10198. $data ['memu'] = "receipt";
  10199. $data ['staff'] = $this->staff;
  10200. $data ['receiptMemu'] = 'companyCategoryCollect';
  10201. $data ['verifyId'] = $this->verifyId;
  10202. $data ['executeId'] = $this->executeId;
  10203. $dateHtml = "";
  10204. $now = date ( "Y" );
  10205. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10206. if ($YEARD <= $now) {
  10207. $dateHtml .= '<option ';
  10208. if ($year == $YEARD) {
  10209. $dateHtml .= 'selected ';
  10210. }
  10211. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10212. }
  10213. }
  10214. $data ['dateHtml'] = $dateHtml;
  10215. // year staff status 2,4
  10216. if ($year < date ( "Y" )) {
  10217. Doo::loadModel ( 'receipt' );
  10218. $receipt = new receipt ();
  10219. $receiptList = $receipt->find ( array (
  10220. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10221. 'asArray' => true
  10222. ) );
  10223. if (empty ( $receiptList )) {
  10224. ob_start ();
  10225. $this->render ( "/admin/saeaCompanyCollect", $data );
  10226. $this->cacheFile ( $path );
  10227. die ();
  10228. }
  10229. }
  10230. $this->render ( "/admin/saeaCompanyCollect", $data );
  10231. }
  10232. function categoryCollectDetail() {
  10233. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10234. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10235. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10236. $this->showCache ( $path ); */
  10237. Doo::loadModel ( 'statistics' );
  10238. $statistics = new statistics ();
  10239. Doo::loadModel ( "receiptDetail" );
  10240. $receiptDetail = new receiptDetail ();
  10241. Doo::loadModel ( 'L_category' );
  10242. $Lcategory = new L_category ();
  10243. Doo::loadModel ( 'accountItem' );
  10244. $accountItem = new accountItem ();
  10245. Doo::loadModel ( "receiptAuthorityManage" );
  10246. $receiptAuthorityManage = new receiptAuthorityManage ();
  10247. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10248. $cidList = array ();
  10249. foreach ( $imcStaff as $key => $value ) {
  10250. array_push ( $cidList, $value ['cid'] );
  10251. }
  10252. $cidString = implode ( ',', $cidList );
  10253. $LcategoryList = $Lcategory->find ( array (
  10254. 'where' => 'cid in (' . $cidString . ')',
  10255. 'asArray' => true
  10256. ) );
  10257. if ($cid == 0) {
  10258. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10259. if ($cid == 0)
  10260. $cid = $LcategoryList [0] ['cid'];
  10261. }
  10262. $data ['LcategoryList'] = $LcategoryList;
  10263. $receiptCollectList = $receiptDetail->find ( array (
  10264. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10265. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10266. 'groupby' => 'item,Month(pastDate)',
  10267. 'asArray' => true
  10268. ) );
  10269. $accountList = $accountItem->find ( array (
  10270. 'asArray' => true
  10271. ) );
  10272. // create CollectDetail HTML
  10273. $collectHtml = array ();
  10274. foreach ( $accountList as $key => $value ) {
  10275. $html = "";
  10276. $asum = 0;
  10277. for($i = 1; $i <= 12; $i ++) {
  10278. $falg = true;
  10279. foreach ( $receiptCollectList as $v ) {
  10280. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10281. $asum += $v ['price'];
  10282. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10283. $falg = false;
  10284. break;
  10285. }
  10286. }
  10287. if ($falg)
  10288. $html .= '<td class="taR">-</td>';
  10289. }
  10290. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10291. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10292. }
  10293. $data ['collectHtml'] = $collectHtml;
  10294. // create Adjustment price html
  10295. $receiptCollectList = $receiptDetail->find ( array (
  10296. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10297. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10298. 'groupby' => 'itemCategory,Month(pastDate)',
  10299. 'asArray' => true
  10300. ) );
  10301. $adjustment = array ();
  10302. $collectArray = array (
  10303. '日常相关费用' => array (),
  10304. '差旅相关费用' => array (),
  10305. '培训班费用' => array (),
  10306. '内部培训费用'=>array(),
  10307. '其他' => array ()
  10308. );
  10309. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10310. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10311. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10312. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10313. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10314. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10315. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10316. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10317. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10318. array_push ( $collectArray ['其他'], $collectHtml );
  10319. $data ['collectArray'] = $collectArray;
  10320. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10321. array_push ( $adjustment, $collectHtml );
  10322. $data ['adjustment'] = $adjustment;
  10323. // total price html
  10324. $collectHtml = "";
  10325. $total = 0;
  10326. for($i = 1; $i <= 12; $i ++) {
  10327. $sumPrice = 0;
  10328. foreach ( $receiptCollectList as $key => $value ) {
  10329. if ($value ['month'] == $i) {
  10330. $sumPrice += $value ['price'];
  10331. }
  10332. }
  10333. if ($sumPrice == 0)
  10334. $collectHtml .= '<td class="taR">-</td>';
  10335. else
  10336. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10337. $total += $sumPrice;
  10338. }
  10339. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10340. // statistics html
  10341. $stList = $statistics->statisticsByCid ( $year, $cid );
  10342. if (empty ( $stList ))
  10343. $stList = array (
  10344. 'rePrice' => 0,
  10345. 'agPrice' => 0
  10346. );
  10347. $data ['stList'] = array (
  10348. 'rePrice' => $stList ['rePrice'],
  10349. 'agPrice' => $stList ['agPrice'],
  10350. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10351. );
  10352. $data ['totalYear'] = $total;
  10353. $data ['year'] = $year;
  10354. $data ['cid'] = $cid;
  10355. $data ['memu'] = "receipt";
  10356. $data ['staff'] = $this->staff;
  10357. $data ['receiptMemu'] = 'companyCategoryCollect';
  10358. $data ['verifyId'] = $this->verifyId;
  10359. $data ['executeId'] = $this->executeId;
  10360. // year staff status 2,4
  10361. /* if ($year < date ( "Y" )) {
  10362. Doo::loadModel ( 'receipt' );
  10363. $receipt = new receipt ();
  10364. $receiptList = $receipt->find ( array (
  10365. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10366. 'asArray' => true
  10367. ) );
  10368. if (empty ( $receiptList )) {
  10369. ob_start ();
  10370. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10371. $this->cacheFile ( $path );
  10372. die ();
  10373. }
  10374. } */
  10375. $dateHtml = "";
  10376. $now = date ( "Y" );
  10377. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10378. if ($YEARD <= $now) {
  10379. $dateHtml .= '<option ';
  10380. if ($year == $YEARD) {
  10381. $dateHtml .= 'selected ';
  10382. }
  10383. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10384. }
  10385. }
  10386. $data ['dateHtml'] = $dateHtml;
  10387. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10388. }
  10389. function staffCollect() {
  10390. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10391. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10392. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10393. // $this->showCache($path);
  10394. Doo::loadModel ( 'statistics' );
  10395. $statistics = new statistics ();
  10396. Doo::loadModel ( "receiptDetail" );
  10397. $receiptDetail = new receiptDetail ();
  10398. Doo::loadModel ( 'L_category' );
  10399. $Lcategory = new L_category ();
  10400. Doo::loadModel ( 'accountItem' );
  10401. $accountItem = new accountItem ();
  10402. Doo::loadModel ( 'staff' );
  10403. $staff = new staff ();
  10404. Doo::loadModel ( 'itemStatistics' );
  10405. $itemStatistics = new itemStatistics ();
  10406. Doo::loadModel ( "receiptAuthorityManage" );
  10407. $receiptAuthorityManage = new receiptAuthorityManage ();
  10408. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10409. $cidList = array ();
  10410. foreach ( $imcStaff as $key => $value ) {
  10411. array_push ( $cidList, $value ['cid'] );
  10412. }
  10413. $cidString = implode ( ',', $cidList );
  10414. $naturecon='';
  10415. if ($nature=='ONJOB'){
  10416. $naturecon=' and (nature!=4 )';
  10417. }elseif($nature=='LEAVEJOB'){
  10418. $naturecon=' and (nature=4 )';
  10419. }else{
  10420. die ( 'illegal request--nature' );
  10421. }
  10422. // statistics html
  10423. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10424. if (empty ( $stList ))
  10425. $stList = array (
  10426. 'rePrice' => 0,
  10427. 'agPrice' => 0
  10428. );
  10429. $data ['stList'] = array (
  10430. 'rePrice' => $stList ['rePrice'],
  10431. 'agPrice' => $stList ['agPrice'],
  10432. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10433. );
  10434. // ---
  10435. $staffList = $staff->find ( array (
  10436. 'where' => 'username !="admin" '.$naturecon,
  10437. 'asArray' => true
  10438. ) );
  10439. $LcategoryList = $Lcategory->find ( array (
  10440. 'asArray' => true
  10441. ) ); // 'staff='.$this->staff[0]['sid']." and
  10442. $itemStatisticsList = $itemStatistics->find ( array (
  10443. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10444. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10445. 'groupby' => 'staff,Month(date)',
  10446. 'asArray' => true
  10447. ) );
  10448. $categoryList = $staff->find ( array (
  10449. 'select' => 'COUNT(*) as count,cid,category',
  10450. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10451. 'groupby' => 'cid',
  10452. 'asArray' => true
  10453. ) );
  10454. // print_r($itemStatisticsList);die;
  10455. // ceatre companyCollectHtml
  10456. foreach ( $categoryList as $vlu ) {
  10457. $count = $vlu ['count'] + 1;
  10458. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10459. $m1 = 0;
  10460. $m2 = 0;
  10461. $m3 = 0;
  10462. $m4 = 0;
  10463. $m5 = 0;
  10464. $m6 = 0;
  10465. $m7 = 0;
  10466. $m8 = 0;
  10467. $m9 = 0;
  10468. $m10 = 0;
  10469. $m11 = 0;
  10470. $m12 = 0;
  10471. $m13 = 0;
  10472. foreach ( $staffList as $value ) {
  10473. if ($vlu ['cid'] == $value ['cid']) {
  10474. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10475. $asum = 0;
  10476. for($i = 1; $i <= 12; $i ++) {
  10477. $falg = true;
  10478. foreach ( $itemStatisticsList as $v ) {
  10479. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10480. if ($v ['month'] == 1)
  10481. $m1 += $v ['price'];
  10482. if ($v ['month'] == 2)
  10483. $m2 += $v ['price'];
  10484. if ($v ['month'] == 3)
  10485. $m3 += $v ['price'];
  10486. if ($v ['month'] == 4)
  10487. $m4 += $v ['price'];
  10488. if ($v ['month'] == 5)
  10489. $m5 += $v ['price'];
  10490. if ($v ['month'] == 6)
  10491. $m6 += $v ['price'];
  10492. if ($v ['month'] == 7)
  10493. $m7 += $v ['price'];
  10494. if ($v ['month'] == 8)
  10495. $m8 += $v ['price'];
  10496. if ($v ['month'] == 9)
  10497. $m9 += $v ['price'];
  10498. if ($v ['month'] == 10)
  10499. $m10 += $v ['price'];
  10500. if ($v ['month'] == 11)
  10501. $m11 += $v ['price'];
  10502. if ($v ['month'] == 12)
  10503. $m12 += $v ['price'];
  10504. $asum += $v ['price'];
  10505. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10506. $falg = false;
  10507. break;
  10508. }
  10509. }
  10510. if ($falg)
  10511. $html .= '<td class="taR">-</td>';
  10512. }
  10513. $m13 += $asum;
  10514. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10515. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10516. 'html' => $html,
  10517. 'sid' => $value ['sid']
  10518. );
  10519. $html = "";
  10520. }
  10521. }
  10522. $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>
  10523. <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>
  10524. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10525. $collectHtml [$vlu ['cid']] = array (
  10526. 'html' => $hl,
  10527. 'sid' => ''
  10528. );
  10529. }
  10530. $data ['companyHtml'] = $collectHtml;
  10531. // total price html
  10532. $collectHtml = "";
  10533. $total = 0;
  10534. for($i = 1; $i <= 12; $i ++) {
  10535. $sumPrice = 0;
  10536. foreach ( $itemStatisticsList as $key => $value ) {
  10537. if ($value ['month'] == $i) {
  10538. $sumPrice += $value ['price'];
  10539. }
  10540. }
  10541. if ($sumPrice == 0)
  10542. $collectHtml .= '<td class="taR">-</td>';
  10543. else
  10544. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10545. $total += $sumPrice;
  10546. }
  10547. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10548. $data ['companyTotalHtml'] = $collectHtml;
  10549. $data ['total'] = $total;
  10550. $data ['nature'] =$nature;
  10551. $data ['year'] = $year;
  10552. $data ['memu'] = "receipt";
  10553. $data ['staff'] = $this->staff;
  10554. $data ['receiptMemu'] = 'companyCategoryCollect';
  10555. $data ['verifyId'] = $this->verifyId;
  10556. $data ['executeId'] = $this->executeId;
  10557. if ($year <= date ( "Y" )) {
  10558. Doo::loadModel ( 'receipt' );
  10559. $receipt = new receipt ();
  10560. $receiptList = $receipt->find ( array (
  10561. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10562. 'asArray' => true
  10563. ) );
  10564. if (empty ( $receiptList )) { // generated files
  10565. ob_start ();
  10566. $this->render ( "/admin/saeaStaffCollectB", $data );
  10567. $this->cacheFile ( $path );
  10568. die ();
  10569. }
  10570. }
  10571. $this->render ( "/admin/saeaStaffCollectB", $data );
  10572. }
  10573. function staffCollectBak() {
  10574. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10575. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10576. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10577. $this->showCache ( $path );
  10578. Doo::loadModel ( 'statistics' );
  10579. $statistics = new statistics ();
  10580. Doo::loadModel ( "receiptDetail" );
  10581. $receiptDetail = new receiptDetail ();
  10582. Doo::loadModel ( 'L_category' );
  10583. $Lcategory = new L_category ();
  10584. Doo::loadModel ( 'accountItem' );
  10585. $accountItem = new accountItem ();
  10586. Doo::loadModel ( 'staff' );
  10587. $staff = new staff ();
  10588. Doo::loadModel ( 'itemStatistics' );
  10589. $itemStatistics = new itemStatistics ();
  10590. $itemStatisticsList = $itemStatistics->find ( array (
  10591. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10592. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10593. 'groupby' => 'staff,itemCategory,Month(date)',
  10594. 'asArray' => true
  10595. ) );
  10596. $itemCategoryList = $itemStatistics->find ( array (
  10597. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10598. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10599. 'groupby' => 'cid,itemCategory,Month(date)',
  10600. 'asArray' => true
  10601. ) );
  10602. $LcategoryList = $Lcategory->find ( array (
  10603. 'asArray' => true
  10604. ) );
  10605. $staffList = $staff->find ( array (
  10606. 'asArray' => true
  10607. ) );
  10608. $htmlArray = array ();
  10609. foreach ( $LcategoryList as $value ) {
  10610. $htmlArray [$value ['title']] = array ();
  10611. foreach ( $staffList as $v ) {
  10612. if ($value ['cid'] == $v ['cid']) {
  10613. $html = "";
  10614. $falg = true;
  10615. $staffSumPrice = 0;
  10616. foreach ( $itemStatisticsList as $a ) {
  10617. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10618. if (empty ( $a ['price'] )) {
  10619. $html .= '<td class="taR">-</td>';
  10620. $falg = false;
  10621. break;
  10622. } else {
  10623. $staffSumPrice += $a ['price'];
  10624. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10625. $falg = false;
  10626. break;
  10627. }
  10628. }
  10629. }
  10630. if ($falg) {
  10631. $html .= '<td class="taR">-</td>';
  10632. $falg = true;
  10633. }
  10634. $falg = true;
  10635. foreach ( $itemStatisticsList as $a ) {
  10636. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10637. if (empty ( $a ['price'] )) {
  10638. $html .= '<td class="taR">-</td>';
  10639. $falg = false;
  10640. break;
  10641. } else {
  10642. $staffSumPrice += $a ['price'];
  10643. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10644. $falg = false;
  10645. break;
  10646. }
  10647. }
  10648. }
  10649. if ($falg) {
  10650. $html .= '<td class="taR">-</td>';
  10651. $falg = true;
  10652. }
  10653. $falg = true;
  10654. foreach ( $itemStatisticsList as $a ) {
  10655. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10656. if (empty ( $a ['price'] )) {
  10657. $html .= '<td class="taR">-</td>';
  10658. $falg = false;
  10659. break;
  10660. } else {
  10661. $staffSumPrice += $a ['price'];
  10662. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10663. $falg = false;
  10664. break;
  10665. }
  10666. }
  10667. }
  10668. if ($falg) {
  10669. $html .= '<td class="taR">-</td>';
  10670. $falg = true;
  10671. }
  10672. $falg = true;
  10673. foreach ( $itemStatisticsList as $a ) {
  10674. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10675. if (! empty ( $a ['price'] )) {
  10676. $staffSumPrice += $a ['price'];
  10677. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10678. $falg = false;
  10679. break;
  10680. } else {
  10681. $html .= '<td class="taR">-</td>';
  10682. $falg = false;
  10683. break;
  10684. }
  10685. }
  10686. }
  10687. if ($falg) {
  10688. $html .= '<td class="taR">-</td>';
  10689. $falg = true;
  10690. }
  10691. $falg = true;
  10692. foreach ( $itemStatisticsList as $a ) {
  10693. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10694. if (! empty ( $a ['price'] )) {
  10695. $staffSumPrice += $a ['price'];
  10696. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10697. $falg = false;
  10698. break;
  10699. } else {
  10700. $html .= '<td class="taR">-</td>';
  10701. $falg = false;
  10702. break;
  10703. }
  10704. }
  10705. }
  10706. if ($falg) {
  10707. $html .= '<td class="taR">-</td>';
  10708. $falg = true;
  10709. }
  10710. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10711. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10712. }
  10713. }
  10714. /* -- --- */
  10715. // 合计费用
  10716. $cateHtml = "";
  10717. $catePrice = 0;
  10718. $cateFalg = true;
  10719. foreach ( $itemCategoryList as $l ) {
  10720. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10721. if (empty ( $l ['price'] )) {
  10722. $cateHtml .= '<td class="colGreen taR">-</td>';
  10723. $cateFalg = false;
  10724. break;
  10725. } else {
  10726. $catePrice += $l ['price'];
  10727. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10728. $cateFalg = false;
  10729. break;
  10730. }
  10731. }
  10732. }
  10733. if ($cateFalg) {
  10734. $cateHtml .= '<td class="colGreen taR">-</td>';
  10735. $cateFalg = true;
  10736. }
  10737. $cateFalg = true;
  10738. foreach ( $itemCategoryList as $l ) {
  10739. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10740. if (empty ( $l ['price'] )) {
  10741. $cateHtml .= '<td class="colGreen taR">-</td>';
  10742. $cateFalg = false;
  10743. break;
  10744. } else {
  10745. $catePrice += $l ['price'];
  10746. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10747. $cateFalg = false;
  10748. break;
  10749. }
  10750. }
  10751. }
  10752. if ($cateFalg) {
  10753. $cateHtml .= '<td class="colGreen taR">-</td>';
  10754. $cateFalg = true;
  10755. }
  10756. $cateFalg = true;
  10757. foreach ( $itemCategoryList as $l ) {
  10758. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10759. if (empty ( $l ['price'] )) {
  10760. $cateHtml .= '<td class="colGreen taR">-</td>';
  10761. $cateFalg = false;
  10762. break;
  10763. } else {
  10764. $catePrice += $l ['price'];
  10765. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10766. $cateFalg = false;
  10767. break;
  10768. }
  10769. }
  10770. }
  10771. if ($cateFalg) {
  10772. $cateHtml .= '<td class="colGreen taR">-</td>';
  10773. $cateFalg = true;
  10774. }
  10775. $cateFalg = true;
  10776. foreach ( $itemCategoryList as $l ) {
  10777. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10778. if (empty ( $l ['price'] )) {
  10779. $cateHtml .= '<td class="colGreen taR">-</td>';
  10780. $cateFalg = false;
  10781. break;
  10782. } else {
  10783. $catePrice += $l ['price'];
  10784. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10785. $cateFalg = false;
  10786. break;
  10787. }
  10788. }
  10789. }
  10790. if ($cateFalg) {
  10791. $cateHtml .= '<td class="colGreen taR">-</td>';
  10792. $cateFalg = true;
  10793. }
  10794. $cateFalg = true;
  10795. foreach ( $itemCategoryList as $l ) {
  10796. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10797. if (empty ( $l ['price'] )) {
  10798. $cateHtml .= '<td class="colGreen taR">-</td>';
  10799. $cateFalg = false;
  10800. break;
  10801. } else {
  10802. $catePrice += $l ['price'];
  10803. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10804. $cateFalg = false;
  10805. break;
  10806. }
  10807. }
  10808. }
  10809. if ($cateFalg) {
  10810. $cateHtml .= '<td class="colGreen taR">-</td>';
  10811. $cateFalg = true;
  10812. }
  10813. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10814. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10815. /* -- --- */
  10816. }
  10817. // print_r($htmlArray);die;
  10818. $data ['htmlArray'] = $htmlArray;
  10819. // statistics html
  10820. $stList = $statistics->getOne ( array (
  10821. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10822. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10823. 'groupby' => 'Month(date)',
  10824. 'asArray' => true
  10825. ) );
  10826. if (empty ( $stList ))
  10827. $stList = array (
  10828. 'rePrice' => 0,
  10829. 'agPrice' => 0
  10830. );
  10831. $data ['stList'] = array (
  10832. 'rePrice' => $stList ['rePrice'],
  10833. 'agPrice' => $stList ['agPrice'],
  10834. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10835. );
  10836. $monthHtml = "";
  10837. for($i = 1; $i <= 12; $i ++) {
  10838. if ($i == $month)
  10839. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10840. else
  10841. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10842. }
  10843. $data ['monthHtml'] = $monthHtml;
  10844. $data ['year'] = $year;
  10845. $data ['month'] = $month;
  10846. $data ['memu'] = "receipt";
  10847. $data ['staff'] = $this->staff;
  10848. $data ['receiptMemu'] = 'companyCategoryCollect';
  10849. $data ['verifyId'] = $this->verifyId;
  10850. $data ['executeId'] = $this->executeId;
  10851. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10852. Doo::loadModel ( 'receipt' );
  10853. $receipt = new receipt ();
  10854. $receiptList = $receipt->find ( array (
  10855. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10856. 'asArray' => true
  10857. ) );
  10858. if (empty ( $receiptList )) { // generated files
  10859. ob_start ();
  10860. $this->render ( "/admin/saeaStaffCollect", $data );
  10861. $this->cacheFile ( $path );
  10862. die ();
  10863. }
  10864. }
  10865. $this->render ( "/admin/saeaStaffCollect", $data );
  10866. }
  10867. /**
  10868. * 日常收支
  10869. */
  10870. function payments() {
  10871. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10872. Doo::loadModel ( "execute" );
  10873. $execute = new execute ();
  10874. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10875. die ( 'illegal request' );
  10876. }
  10877. Doo::loadModel ( "accountBook" );
  10878. $accountBook = new accountBook ();
  10879. Doo::loadModel ( "accountBookStatistics" );
  10880. $accountBookStatistics = new accountBookStatistics ();
  10881. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10882. $list = $accountBook->getAccountBookByLimit ( 10 );
  10883. $data ['date'] = date ( "Y-m-d" );
  10884. $data ['statisticsList'] = $statisticsList;
  10885. $data ['list'] = $list;
  10886. $data ['memu'] = "receipt";
  10887. $data ['staff'] = $this->staff;
  10888. $data ['receiptMemu'] = 'payments';
  10889. $data ['verifyId'] = $this->verifyId;
  10890. $data ['executeId'] = $this->executeId;
  10891. $this->render ( "/expenses/payments", $data );
  10892. }
  10893. function paymentsIncomeDo() {
  10894. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10895. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10896. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10897. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10898. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10899. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10900. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10901. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10902. Doo::loadClass ( 'XDeode' );
  10903. $XDeode = new XDeode ( 5 );
  10904. Doo::loadModel ( "accountBook" );
  10905. Doo::loadModel ( "accountBookStatistics" );
  10906. Doo::loadModel ( 'wasteBook' );
  10907. // 记录流水时银行的转换
  10908. $accountBank = '';
  10909. if ($receivedBank == '纵横广发') {
  10910. $accountBank = 'CGBDeposit';
  10911. } elseif ($receivedBank == '纵横工行') {
  10912. $accountBank = 'ICBCDeposit';
  10913. } elseif ($receivedBank == '华润银行') {
  10914. $accountBank = 'HUADeposit';
  10915. } elseif ($receivedBank == '个人广发') {
  10916. $accountBank = 'PersonalDeposit';
  10917. }
  10918. if (empty ( $accountBank ))
  10919. die ( 'illegal request-bank' );
  10920. if($accountType == 11 || $accountType == 12){
  10921. if($accountType == 11){
  10922. $receivedBank = '纵横广发';
  10923. }elseif($accountType == 12){
  10924. $receivedBank = '纵横工行';
  10925. }
  10926. // 添加一条收入
  10927. $accountBook = new accountBook ();
  10928. $accountBook->accountType = $accountType;
  10929. $accountBook->accountMsg = $accountMsg;
  10930. $accountBook->receivedPrice = $receivedPrice;
  10931. $accountBook->receivedMsg = $receivedMsg;
  10932. $accountBook->receivedBank = $receivedBank;
  10933. $accountBook->receivedDate = $receivedDate;
  10934. $accountBook->remarks = $remarks;
  10935. $accountBook->expensesType = 1;
  10936. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10937. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10938. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10939. $inComeId = $accountBook->insert ();
  10940. // 收支汇总-添加一条收入日常汇总
  10941. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10942. $accountBookStatistics = new accountBookStatistics ();
  10943. $item = array (
  10944. 'date' => date ( "Y-m-d" ),
  10945. 'accountType' => $abDetail ['accountType'],
  10946. 'accountMsg' => $abDetail ['accountMsg'],
  10947. 'aid' => $abDetail ['aid'],
  10948. 'inComePrice' => $abDetail ['receivedPrice'],
  10949. 'expensesType' => $abDetail ['expensesType']
  10950. );
  10951. $accountBookStatistics->setAccountBookStatistics ( $item );
  10952. //流水支出
  10953. // if($accountBank=='CGBDeposit'){
  10954. // $dailyExpenditureType='8';
  10955. // }elseif($accountBank=='ICBCDeposit'){
  10956. // $dailyExpenditureType='9';
  10957. // }elseif($accountBank=='PersonalDeposit'){
  10958. // $dailyExpenditureType='10';
  10959. // }elseif($accountBank=='HUADeposit'){
  10960. // $dailyExpenditureType='11';
  10961. // }
  10962. //
  10963. // $wasteBook = new wasteBook ();
  10964. // $itemWaste = array (
  10965. // 'expensesType' => 2,
  10966. // 'accountType' => 5,
  10967. // 'accountPriceShow' => $receivedPrice,
  10968. // 'accountPrice' => - $receivedPrice,
  10969. // 'dataID' => $inComeId,
  10970. // 'dailyExpenditureType' => $dailyExpenditureType,
  10971. // 'accountBank' => $accountBank,
  10972. // 'category' => $this->staff [0] ['category'],
  10973. // 'cid' => $this->staff [0] ['cid'],
  10974. // 'name' => $this->staff [0] ['username'],
  10975. // 'sid' => $this->staff [0] ['sid'],
  10976. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10977. // );
  10978. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10979. // 添加收入流水
  10980. if($accountType == 11){
  10981. $accountBank = 'CGBDeposit';
  10982. }elseif($accountType == 12){
  10983. $accountBank = 'ICBCDeposit';
  10984. }
  10985. $wasteBook = new wasteBook ();
  10986. $itemWaste = array (
  10987. 'accountPriceShow' => $receivedPrice,
  10988. 'accountPrice' => $receivedPrice,
  10989. 'expensesType' => 1,
  10990. 'accountType' => 6, // 流水类型
  10991. 'dataID' => $inComeId,
  10992. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10993. 'accountBank' => $accountBank,
  10994. 'category' => $this->staff [0] ['category'],
  10995. 'cid' => $this->staff [0] ['cid'],
  10996. 'name' => $this->staff [0] ['username'],
  10997. 'sid' => $this->staff [0] ['sid'],
  10998. 'inputDate' => date ( "Y-m-d H:i:s" )
  10999. );
  11000. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11001. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  11002. if ($receivedBank == '个人广发') {
  11003. die ( '个人广发 illegal request' );
  11004. }
  11005. // 添加一条收入
  11006. $accountBook = new accountBook ();
  11007. $accountBook->accountType = 10;
  11008. $accountBook->accountMsg = $accountMsg;
  11009. $accountBook->receivedPrice = $receivedPrice;
  11010. $accountBook->receivedMsg = $receivedMsg;
  11011. $accountBook->receivedBank = $receivedBank;
  11012. $accountBook->receivedDate = $receivedDate;
  11013. $accountBook->remarks = $remarks;
  11014. $accountBook->expensesType = 1;
  11015. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11016. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11017. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11018. $inComeId = $accountBook->insert ();
  11019. // 收支汇总-添加一条收入日常汇总
  11020. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  11021. $accountBookStatistics = new accountBookStatistics ();
  11022. $item = array (
  11023. 'date' => date ( "Y-m-d" ),
  11024. 'accountType' => $abDetail ['accountType'],
  11025. 'accountMsg' => $abDetail ['accountMsg'],
  11026. 'aid' => $abDetail ['aid'],
  11027. 'inComePrice' => $abDetail ['receivedPrice'],
  11028. 'expensesType' => $abDetail ['expensesType']
  11029. );
  11030. $accountBookStatistics->setAccountBookStatistics ( $item );
  11031. // 添加收入流水
  11032. $wasteBook = new wasteBook ();
  11033. $itemWaste = array (
  11034. 'accountPriceShow' => $receivedPrice,
  11035. 'accountPrice' => $receivedPrice,
  11036. 'expensesType' => 1,
  11037. 'accountType' => 6, // 流水类型
  11038. 'dataID' => $inComeId,
  11039. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11040. 'accountBank' => $accountBank,
  11041. 'category' => $this->staff [0] ['category'],
  11042. 'cid' => $this->staff [0] ['cid'],
  11043. 'name' => $this->staff [0] ['username'],
  11044. 'sid' => $this->staff [0] ['sid'],
  11045. 'inputDate' => date ( "Y-m-d H:i:s" )
  11046. );
  11047. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11048. // 添加一条理财支出
  11049. $accountBank = 'CGBDeposit';
  11050. $expenditureBank = '纵横广发';
  11051. $dailyExpenditureType = 4;
  11052. if ($accountType == 9) {
  11053. $accountBank = 'ICBCDeposit';
  11054. $expenditureBank = '纵横工行';
  11055. $dailyExpenditureType = 6;
  11056. }
  11057. $accountBook = new accountBook ();
  11058. $accountBook->expensesType = 2;
  11059. $accountBook->expenditureType = $dailyExpenditureType;
  11060. $accountBook->expenditureMsg = $accountMsg;
  11061. $accountBook->expenditurePrice = $receivedPrice;
  11062. $accountBook->expenditureBank = $expenditureBank;
  11063. $accountBook->expenditureDate = $receivedDate;
  11064. $accountBook->remarks = $remarks;
  11065. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11066. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11067. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11068. $id = $accountBook->insert ();
  11069. // 收支汇总-添加一条理财支出汇总
  11070. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11071. $accountBookStatistics = new accountBookStatistics ();
  11072. $item = array (
  11073. 'date' => date ( "Y-m-d" ),
  11074. 'accountType' => $abDetail ['accountType'],
  11075. 'accountMsg' => $abDetail ['accountMsg'],
  11076. 'aid' => $abDetail ['aid'],
  11077. 'financingPrice' => - $receivedPrice,
  11078. 'expensesType' => 3
  11079. );
  11080. $accountBookStatistics->setAccountBookStatistics ( $item );
  11081. // 添加一条支出理财流水
  11082. $accountTypeWaste = 5;
  11083. if ($accountMsg == '公司固定') {
  11084. $accountTypeWaste = 9;
  11085. } elseif ($accountMsg == '公司活期') {
  11086. $accountTypeWaste = 10;
  11087. } elseif ($accountMsg == '个人(GR)') {
  11088. $accountBank = 'PersonalDeposit';
  11089. }
  11090. $itemWaste = array (
  11091. 'expensesType' => 2,
  11092. 'accountType' => $accountTypeWaste,
  11093. 'accountPriceShow' => $receivedPrice,
  11094. 'accountPrice' => - $receivedPrice,
  11095. 'dataID' => $id,
  11096. 'dailyExpenditureType' => $dailyExpenditureType,
  11097. 'accountBank' => $accountBank,
  11098. 'category' => $this->staff [0] ['category'],
  11099. 'cid' => $this->staff [0] ['cid'],
  11100. 'name' => $this->staff [0] ['username'],
  11101. 'sid' => $this->staff [0] ['sid'],
  11102. 'inputDate' => date ( "Y-m-d H:i:s" )
  11103. );
  11104. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11105. } elseif ($accountType == 1) {
  11106. // if ($receivedBank == '个人广发')
  11107. // die ( 'illegal request--no man' );
  11108. // 添加一条收入
  11109. $accountBook = new accountBook ();
  11110. $accountBook->accountType = $accountType;
  11111. $accountBook->accountMsg = $accountMsg;
  11112. $accountBook->receivedPrice = $receivedPrice;
  11113. $accountBook->receivedMsg = $receivedMsg;
  11114. $accountBook->receivedBank = $receivedBank;
  11115. $accountBook->receivedDate = $receivedDate;
  11116. $accountBook->remarks = $remarks;
  11117. $accountBook->expensesType = 1;
  11118. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11119. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11120. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11121. $id = $accountBook->insert ();
  11122. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11123. // 收支汇总-添加一条收入日常汇总
  11124. $accountBookStatistics = new accountBookStatistics ();
  11125. $item = array (
  11126. 'date' => date ( "Y-m-d" ),
  11127. 'accountType' => $abDetail ['accountType'],
  11128. 'accountMsg' => $abDetail ['accountMsg'],
  11129. 'aid' => $abDetail ['aid'],
  11130. 'expensesType' => $abDetail ['expensesType']
  11131. );
  11132. if ($abDetail ['accountType'] == 8) {
  11133. $item += array (
  11134. 'inComePrice' => $abDetail ['receivedPrice']
  11135. );
  11136. } else {
  11137. $item += array (
  11138. 'inComePrice' => $abDetail ['receivedPrice']
  11139. );
  11140. }
  11141. $accountBookStatistics->setAccountBookStatistics ( $item );
  11142. // 流水存储方向
  11143. $itemWaste = array (
  11144. 'accountType' => 6
  11145. ); // 流水类型
  11146. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  11147. // }else
  11148. if ($accountMsg == '活期理财收益') {
  11149. $itemWaste = array (
  11150. 'accountType' => 10
  11151. ); // 流水类型
  11152. }
  11153. // 添加收入流水
  11154. $wasteBook = new wasteBook ();
  11155. $itemWaste += array (
  11156. 'accountPrice' => $receivedPrice,
  11157. 'accountPriceShow' => $receivedPrice,
  11158. 'expensesType' => 1,
  11159. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11160. 'dataID' => $id,
  11161. 'accountBank' => $accountBank,
  11162. 'category' => $this->staff [0] ['category'],
  11163. 'cid' => $this->staff [0] ['cid'],
  11164. 'name' => $this->staff [0] ['username'],
  11165. 'sid' => $this->staff [0] ['sid'],
  11166. 'inputDate' => date ( "Y-m-d H:i:s" )
  11167. );
  11168. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11169. } else { // 普通日常收入处理
  11170. // 添加一条收入
  11171. $accountBook = new accountBook ();
  11172. $accountBook->accountType = $accountType;
  11173. $accountBook->accountMsg = $accountMsg;
  11174. $accountBook->receivedPrice = $receivedPrice;
  11175. $accountBook->receivedMsg = $receivedMsg;
  11176. $accountBook->receivedBank = $receivedBank;
  11177. $accountBook->receivedDate = $receivedDate;
  11178. $accountBook->remarks = $remarks;
  11179. $accountBook->expensesType = 1;
  11180. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11181. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11182. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11183. $id = $accountBook->insert ();
  11184. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11185. // 收支汇总-添加一条收入日常汇总
  11186. $accountBookStatistics = new accountBookStatistics ();
  11187. $item = array (
  11188. 'date' => date ( "Y-m-d" ),
  11189. 'accountType' => $abDetail ['accountType'],
  11190. 'accountMsg' => $abDetail ['accountMsg'],
  11191. 'aid' => $abDetail ['aid'],
  11192. 'expensesType' => $abDetail ['expensesType']
  11193. );
  11194. if ($abDetail ['accountType'] == 8) {
  11195. $item += array (
  11196. 'inComePrice' => $abDetail ['receivedPrice']
  11197. );
  11198. } else {
  11199. $item += array (
  11200. 'inComePrice' => $abDetail ['receivedPrice']
  11201. );
  11202. }
  11203. $accountBookStatistics->setAccountBookStatistics ( $item );
  11204. // 添加收入流水
  11205. $itemWaste = array (
  11206. 'accountPrice' => $receivedPrice
  11207. );
  11208. if ($receivedBank == '个人广发') {
  11209. $itemWaste = array (
  11210. 'accountPrice' => - $receivedPrice
  11211. );
  11212. }
  11213. $wasteBook = new wasteBook ();
  11214. $itemWaste += array (
  11215. 'accountPriceShow' => $receivedPrice,
  11216. 'expensesType' => 1,
  11217. 'accountType' => 6, // 流水类型
  11218. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11219. 'dataID' => $id,
  11220. 'accountBank' => $accountBank,
  11221. 'category' => $this->staff [0] ['category'],
  11222. 'cid' => $this->staff [0] ['cid'],
  11223. 'name' => $this->staff [0] ['username'],
  11224. 'sid' => $this->staff [0] ['sid'],
  11225. 'inputDate' => date ( "Y-m-d H:i:s" )
  11226. );
  11227. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11228. }
  11229. }
  11230. return '/payments';
  11231. }
  11232. function paymentsExpenditureDo() {
  11233. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11234. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11235. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11236. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11237. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11238. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11239. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11240. // 理财支出特殊处理
  11241. Doo::loadModel ( "accountBook" );
  11242. Doo::loadModel ( "accountBookStatistics" );
  11243. Doo::loadModel ( 'wasteBook' );
  11244. $accountBank = '';
  11245. if ($expenditureBank == '纵横广发') {
  11246. $accountBank = 'CGBDeposit';
  11247. } elseif ($expenditureBank == '纵横工行') {
  11248. $accountBank = 'ICBCDeposit';
  11249. } elseif ($expenditureBank == '华润银行') {
  11250. $accountBank = 'HUADeposit';
  11251. } elseif ($expenditureBank == '个人广发') {
  11252. $accountBank = 'PersonalDeposit';
  11253. }
  11254. if (empty ( $accountBank ))
  11255. die ( 'illegal request' );
  11256. if($expenditureType == 8 || $expenditureType == 9){
  11257. if($expenditureType == 8 ){
  11258. $expenditureBank='纵横广发';
  11259. }elseif($expenditureType == 9){
  11260. $expenditureBank='纵横工行';
  11261. }
  11262. // 添加一笔日常支出
  11263. $accountBook = new accountBook ();
  11264. $accountBook->expensesType = 2;
  11265. $accountBook->expenditureType = $expenditureType;
  11266. $accountBook->expenditureMsg = $expenditureMsg;
  11267. $accountBook->expenditurePrice = $expenditurePrice;
  11268. $accountBook->expenditureBank = $expenditureBank;
  11269. $accountBook->expenditureDate = $expenditureDate;
  11270. $accountBook->remarks = $remarks;
  11271. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11272. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11273. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11274. $expenditureId = $accountBook->insert ();
  11275. // 添加日常支出汇总
  11276. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11277. $accountBookStatistics = new accountBookStatistics ();
  11278. $item = array (
  11279. 'date' => date ( "Y-m-d" ),
  11280. 'expenditureType' => $abDetail ['expenditureType'],
  11281. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11282. 'aid' => $abDetail ['aid'],
  11283. 'payPrice' => $abDetail ['expenditurePrice'],
  11284. 'expensesType' => $abDetail ['expensesType']
  11285. );
  11286. $accountBookStatistics->setAccountBookStatistics ( $item );
  11287. // 公司日常支出流水
  11288. if($expenditureType == 8 ){
  11289. $accountBank = 'CGBDeposit';
  11290. }elseif($expenditureType == 9){
  11291. $accountBank = 'ICBCDeposit';
  11292. }
  11293. if($accountBank=='CGBDeposit'){
  11294. $dailyExpenditureType='8';
  11295. }elseif($accountBank=='ICBCDeposit'){
  11296. $dailyExpenditureType='9';
  11297. }elseif($accountBank=='PersonalDeposit'){
  11298. $dailyExpenditureType='10';
  11299. }elseif($accountBank=='HUADeposit'){
  11300. $dailyExpenditureType='11';
  11301. }
  11302. $wasteBook = new wasteBook ();
  11303. $itemWaste = array (
  11304. 'expensesType' => 2,
  11305. 'accountType' => 5,
  11306. 'dailyExpenditureType' => $dailyExpenditureType,
  11307. 'accountPriceShow' => $expenditurePrice,
  11308. 'accountPrice' => - $expenditurePrice,
  11309. 'dataID' => $expenditureId,
  11310. 'accountBank' => $accountBank,
  11311. 'category' => $this->staff [0] ['category'],
  11312. 'cid' => $this->staff [0] ['cid'],
  11313. 'name' => $this->staff [0] ['username'],
  11314. 'sid' => $this->staff [0] ['sid'],
  11315. 'inputDate' => date ( "Y-m-d H:i:s" )
  11316. );
  11317. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11318. // 添加一笔收入流水
  11319. // if($expenditureType==8){
  11320. // $dailyIncomeType='11';
  11321. // }elseif($expenditureType==9){
  11322. // $dailyIncomeType='12';
  11323. // }
  11324. // $wasteBook = new wasteBook ();
  11325. // $itemWaste = array (
  11326. // 'expensesType' => 1,
  11327. // 'accountType' => 6,
  11328. // 'accountPriceShow' => $expenditurePrice,
  11329. // 'accountPrice' => $expenditurePrice,
  11330. // 'dataID' => $expenditureId,
  11331. //
  11332. // 'dailyIncomeType' => $dailyIncomeType,
  11333. // 'accountBank' => $accountBank,
  11334. // 'category' => $this->staff [0] ['category'],
  11335. // 'cid' => $this->staff [0] ['cid'],
  11336. // 'name' => $this->staff [0] ['username'],
  11337. // 'sid' => $this->staff [0] ['sid'],
  11338. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11339. // );
  11340. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11341. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11342. if ($expenditureBank == '个人广发') {
  11343. die ( '个人广发 illegal request' );
  11344. }
  11345. // 添加一笔日常支出
  11346. $accountBook = new accountBook ();
  11347. $accountBook->expensesType = 2;
  11348. $accountBook->expenditureType = 7;
  11349. $accountBook->expenditureMsg = $expenditureMsg;
  11350. $accountBook->expenditurePrice = $expenditurePrice;
  11351. $accountBook->expenditureBank = $expenditureBank;
  11352. $accountBook->expenditureDate = $expenditureDate;
  11353. $accountBook->remarks = $remarks;
  11354. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11355. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11356. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11357. $expenditureId = $accountBook->insert ();
  11358. // 添加日常支出汇总
  11359. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11360. $accountBookStatistics = new accountBookStatistics ();
  11361. $item = array (
  11362. 'date' => date ( "Y-m-d" ),
  11363. 'expenditureType' => $abDetail ['expenditureType'],
  11364. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11365. 'aid' => $abDetail ['aid'],
  11366. 'payPrice' => $abDetail ['expenditurePrice'],
  11367. 'expensesType' => $abDetail ['expensesType']
  11368. );
  11369. $accountBookStatistics->setAccountBookStatistics ( $item );
  11370. // 公司日常支出流水
  11371. $wasteBook = new wasteBook ();
  11372. $itemWaste = array (
  11373. 'accountPrice' => - $expenditurePrice
  11374. );
  11375. if ($expenditureBank == '个人广发') {
  11376. $itemWaste = array (
  11377. 'accountPrice' => $expenditurePrice
  11378. );
  11379. }
  11380. $itemWaste += array (
  11381. 'expensesType' => 2,
  11382. 'accountType' => 5,
  11383. 'dailyExpenditureType' => $expenditureType,
  11384. 'accountPriceShow' => $expenditurePrice,
  11385. 'accountPrice' => - $expenditurePrice,
  11386. 'dataID' => $expenditureId,
  11387. 'accountBank' => $accountBank,
  11388. 'category' => $this->staff [0] ['category'],
  11389. 'cid' => $this->staff [0] ['cid'],
  11390. 'name' => $this->staff [0] ['username'],
  11391. 'sid' => $this->staff [0] ['sid'],
  11392. 'inputDate' => date ( "Y-m-d H:i:s" )
  11393. );
  11394. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11395. // 添加一笔理财收入
  11396. $accountBank = 'CGBDeposit';
  11397. $dailyIncomeType = 7;
  11398. $receivedBank = '纵横广发';
  11399. if ($expenditureType == 6) {
  11400. $accountBank = 'ICBCDeposit';
  11401. $receivedBank = '纵横工行';
  11402. $dailyIncomeType = 9;
  11403. }
  11404. $accountBook = new accountBook ();
  11405. $accountBook->expensesType = 1;
  11406. $accountBook->accountType = $dailyIncomeType;
  11407. $accountBook->accountMsg = $expenditureMsg;
  11408. $accountBook->receivedPrice = $expenditurePrice;
  11409. $accountBook->receivedBank = $receivedBank;
  11410. $accountBook->receivedDate = $expenditureDate;
  11411. $accountBook->remarks = $remarks;
  11412. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11413. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11414. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11415. $id = $accountBook->insert ();
  11416. // 添加日常理财收入汇总
  11417. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11418. $accountBookStatistics = new accountBookStatistics ();
  11419. $item = array (
  11420. 'date' => date ( "Y-m-d" ),
  11421. 'expenditureType' => $abDetail ['expenditureType'],
  11422. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11423. 'aid' => $abDetail ['aid'],
  11424. 'financingPrice' => $expenditurePrice,
  11425. 'expensesType' => 3
  11426. );
  11427. $accountBookStatistics->setAccountBookStatistics ( $item );
  11428. // 添加一笔收入流水
  11429. if ($expenditureMsg == '公司固定') {
  11430. $accountTypeWaste = 9;
  11431. } elseif ($expenditureMsg == '公司活期') {
  11432. $accountTypeWaste = 10;
  11433. } elseif ($expenditureMsg == '个人(GR)') {
  11434. $accountBank = 'PersonalDeposit';
  11435. }
  11436. $itemWaste = array (
  11437. 'expensesType' => 1,
  11438. 'accountType' => $accountTypeWaste,
  11439. 'accountPriceShow' => $expenditurePrice,
  11440. 'accountPrice' => $expenditurePrice,
  11441. 'dataID' => $id,
  11442. 'dailyIncomeType' => $dailyIncomeType,
  11443. 'accountBank' => $accountBank,
  11444. 'category' => $this->staff [0] ['category'],
  11445. 'cid' => $this->staff [0] ['cid'],
  11446. 'name' => $this->staff [0] ['username'],
  11447. 'sid' => $this->staff [0] ['sid'],
  11448. 'inputDate' => date ( "Y-m-d H:i:s" )
  11449. );
  11450. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11451. } else {
  11452. // 添加一笔日常支出
  11453. $accountBook = new accountBook ();
  11454. $accountBook->expensesType = 2;
  11455. $accountBook->expenditureType = $expenditureType;
  11456. $accountBook->expenditureMsg = $expenditureMsg;
  11457. $accountBook->expenditurePrice = $expenditurePrice;
  11458. $accountBook->expenditureBank = $expenditureBank;
  11459. $accountBook->expenditureDate = $expenditureDate;
  11460. $accountBook->remarks = $remarks;
  11461. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11462. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11463. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11464. $id = $accountBook->insert ();
  11465. // 添加日常支出汇总
  11466. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11467. $accountBookStatistics = new accountBookStatistics ();
  11468. $item = array (
  11469. 'date' => date ( "Y-m-d" ),
  11470. 'expenditureType' => $abDetail ['expenditureType'],
  11471. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11472. 'aid' => $abDetail ['aid'],
  11473. 'expensesType' => $abDetail ['expensesType']
  11474. );
  11475. if ($expenditureType == 5) {
  11476. $item += array (
  11477. 'payPrice' => - $abDetail ['expenditurePrice']
  11478. );
  11479. } else {
  11480. $item += array (
  11481. 'payPrice' => $abDetail ['expenditurePrice']
  11482. );
  11483. }
  11484. $accountBookStatistics->setAccountBookStatistics ( $item );
  11485. // 公司日常支出流水
  11486. $wasteBook = new wasteBook ();
  11487. $itemWaste = array (
  11488. 'accountPrice' => - $expenditurePrice
  11489. );
  11490. if ($expenditureBank == '个人广发') {
  11491. $itemWaste = array (
  11492. 'accountPrice' => $expenditurePrice
  11493. );
  11494. }
  11495. $itemWaste += array (
  11496. 'expensesType' => 2,
  11497. 'accountType' => 5,
  11498. 'accountPriceShow' => $expenditurePrice,
  11499. 'dataID' => $id,
  11500. 'dailyExpenditureType' => $expenditureType,
  11501. 'accountBank' => $accountBank,
  11502. 'category' => $this->staff [0] ['category'],
  11503. 'cid' => $this->staff [0] ['cid'],
  11504. 'name' => $this->staff [0] ['username'],
  11505. 'sid' => $this->staff [0] ['sid'],
  11506. 'inputDate' => date ( "Y-m-d H:i:s" )
  11507. );
  11508. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11509. }
  11510. }
  11511. return '/payments';
  11512. }
  11513. /**
  11514. * 添加支出
  11515. */
  11516. function paymentsExpenditureDo_() {
  11517. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11518. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11519. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11520. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11521. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11522. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11523. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11524. $dailyExpenditureType = '';
  11525. $accountTypeWaste = 5;
  11526. $accountBank = '';
  11527. if ($expenditureBank == '纵横广发') {
  11528. $accountBank = 'CGBDeposit';
  11529. } elseif ($expenditureBank == '纵横工行') {
  11530. $accountBank = 'ICBCDeposit';
  11531. } elseif ($expenditureBank == '华润银行') {
  11532. $accountBank = 'HUADeposit';
  11533. } elseif ($expenditureBank == '个人广发') {
  11534. $accountBank = 'PersonalDeposit';
  11535. }
  11536. if (empty ( $accountBank ))
  11537. die ( 'illegal request' );
  11538. $itemWaste = array (
  11539. 'accountPrice' => - $expenditurePrice
  11540. );
  11541. if ($expenditureBank == '个人广发') {
  11542. $itemWaste = array (
  11543. 'accountPrice' => $expenditurePrice
  11544. );
  11545. }
  11546. if ($expenditureType == 4 || $expenditureType == 6) {
  11547. $dailyExpenditureType = 4;
  11548. if ($expenditureMsg == '公司固定') {
  11549. $accountTypeWaste = 9;
  11550. } elseif ($expenditureMsg == '公司活期') {
  11551. $accountTypeWaste = 10;
  11552. } elseif ($expenditureMsg == '个人(GR)') {
  11553. $accountBank = 'PersonalDeposit';
  11554. }
  11555. $itemWaste = array (
  11556. 'accountPrice' => $expenditurePrice
  11557. );
  11558. } elseif ($expenditureType == 1) {
  11559. $dailyExpenditureType = 1;
  11560. } elseif ($expenditureType == 2) {
  11561. $dailyExpenditureType = 2;
  11562. } elseif ($expenditureType == 3) {
  11563. $dailyExpenditureType = 3;
  11564. } elseif ($expenditureType == 5) {
  11565. $dailyExpenditureType = 5;
  11566. }
  11567. if (empty ( $dailyExpenditureType ))
  11568. die ( 'illegal request' );
  11569. Doo::loadModel ( "accountBook" );
  11570. $accountBook = new accountBook ();
  11571. $accountBook->expenditureType = $expenditureType;
  11572. $accountBook->expenditureMsg = $expenditureMsg;
  11573. $accountBook->expenditurePrice = $expenditurePrice;
  11574. $accountBook->expenditureBank = $expenditureBank;
  11575. $accountBook->expenditureDate = $expenditureDate;
  11576. $accountBook->remarks = $remarks;
  11577. $accountBook->expensesType = 2;
  11578. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11579. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11580. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11581. $id = $accountBook->insert ();
  11582. //
  11583. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11584. Doo::loadModel ( "accountBookStatistics" );
  11585. $accountBookStatistics = new accountBookStatistics ();
  11586. $item = array (
  11587. 'date' => date ( "Y-m-d" ),
  11588. 'expenditureType' => $abDetail ['expenditureType'],
  11589. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11590. 'aid' => $abDetail ['aid']
  11591. );
  11592. if ($abDetail ['expensesType'] == 2) {
  11593. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11594. $item += array (
  11595. 'financingPrice' => $expenditurePrice,
  11596. 'expensesType' => 3
  11597. );
  11598. } elseif ($abDetail ['expenditureType'] == 5) {
  11599. $item += array (
  11600. 'payPrice' => $abDetail ['expenditurePrice'],
  11601. 'expensesType' => $abDetail ['expensesType']
  11602. );
  11603. } else {
  11604. $item += array (
  11605. 'payPrice' => $abDetail ['expenditurePrice'],
  11606. 'expensesType' => $abDetail ['expensesType']
  11607. );
  11608. }
  11609. }
  11610. $accountBookStatistics->setAccountBookStatistics ( $item );
  11611. // 公司流水记录
  11612. Doo::loadModel ( 'wasteBook' );
  11613. $wasteBook = new wasteBook ();
  11614. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11615. // 银行
  11616. if (empty ( $abDetail )) {
  11617. $itemWaste += array (
  11618. 'accountPriceShow' => $expenditurePrice,
  11619. 'dataID' => $id,
  11620. 'expensesType' => 2,
  11621. 'accountType' => $accountTypeWaste,
  11622. 'dailyExpenditureType' => $expenditureType,
  11623. 'accountBank' => $accountBank,
  11624. 'category' => $this->staff [0] ['category'],
  11625. 'cid' => $this->staff [0] ['cid'],
  11626. 'name' => $this->staff [0] ['username'],
  11627. 'sid' => $this->staff [0] ['sid'],
  11628. 'inputDate' => date ( "Y-m-d H:i:s" )
  11629. );
  11630. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11631. }
  11632. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11633. if ($expenditureType == 4 || $expenditureType == 6) {
  11634. $accountBank = 'CGBDeposit';
  11635. $dailyIncomeType = 7;
  11636. $receivedBank = '纵横广发';
  11637. if ($expenditureType == 6) {
  11638. $accountBank = 'ICBCDeposit';
  11639. $receivedBank = '纵横工行';
  11640. $dailyIncomeType = 9;
  11641. }
  11642. // 添加一笔收入
  11643. $accountBook = new accountBook ();
  11644. $accountBook->accountType = $dailyIncomeType;
  11645. $accountBook->accountMsg = $expenditureMsg;
  11646. $accountBook->receivedPrice = $expenditurePrice;
  11647. $accountBook->receivedBank = $receivedBank;
  11648. $accountBook->receivedDate = $expenditureDate;
  11649. $accountBook->remarks = $remarks;
  11650. $accountBook->expensesType = 1;
  11651. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11652. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11653. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11654. $id = $accountBook->insert ();
  11655. // 添加一笔收入流水
  11656. $itemWaste = array (
  11657. 'accountPriceShow' => $expenditurePrice,
  11658. 'accountPrice' => - $expenditurePrice,
  11659. 'dataID' => $id,
  11660. 'expensesType' => 1,
  11661. 'accountType' => $accountTypeWaste,
  11662. 'dailyIncomeType' => $dailyIncomeType,
  11663. 'accountBank' => $accountBank,
  11664. 'category' => $this->staff [0] ['category'],
  11665. 'cid' => $this->staff [0] ['cid'],
  11666. 'name' => $this->staff [0] ['username'],
  11667. 'sid' => $this->staff [0] ['sid'],
  11668. 'inputDate' => date ( "Y-m-d H:i:s" )
  11669. );
  11670. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11671. }
  11672. }
  11673. return '/payments';
  11674. }
  11675. /**
  11676. * 所有收支
  11677. */
  11678. function paymentsAchieve() {
  11679. $page_size = 12;
  11680. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11681. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11682. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11683. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11684. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11685. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11686. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11687. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11688. Doo::loadModel ( "accountBookStatistics" );
  11689. $accountBookStatistics = new accountBookStatistics ();
  11690. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11691. $data ['statisticsList'] = $statisticsList;
  11692. Doo::loadModel ( "accountBook" );
  11693. $accountBook = new accountBook ();
  11694. $con = '';
  11695. if ($expensesType == 'INCOME')
  11696. $con = ' and expensesType=1 ';
  11697. elseif ($expensesType == 'PAY')
  11698. $con = ' and expensesType=2 ';
  11699. $dateArr = explode ( ':', $date );
  11700. $D1 = $dateString = '';
  11701. $D2 = '';
  11702. if (! empty ( $date )) {
  11703. $D1 = $dateArr [0];
  11704. if (isset ( $dateArr [1] ))
  11705. $D2 = $dateArr [1];
  11706. else
  11707. $D2 = '';
  11708. $dateString = $D1 . " : " . $D2;
  11709. }
  11710. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11711. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11712. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11713. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11714. if (! empty ( $price ))
  11715. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11716. if ($submitType == 1) {
  11717. if ($accountType != '') {
  11718. $expenditureType = '';
  11719. $con .= ' and accountType=' . $accountType;
  11720. if (! empty ( $accountMsg ))
  11721. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11722. }
  11723. } elseif ($submitType == 2) {
  11724. if ($expenditureType != '') {
  11725. $accountType = $accountMsg = '';
  11726. $con .= ' and expenditureType=' . $expenditureType;
  11727. }
  11728. } else {
  11729. $accountType = $accountMsg = $expenditureType = '';
  11730. }
  11731. $sql = "" . $con;
  11732. $action = "paymentsAchieve";
  11733. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11734. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11735. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11736. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11737. $data ['expenditureType'] = $expenditureType;
  11738. $data ['accountMsg'] = $accountMsg;
  11739. $data ['accountType'] = $accountType;
  11740. $data ['inputDate'] = $date;
  11741. $data ['price'] = $price;
  11742. $data ['expensesType'] = $expensesType;
  11743. $data ['page'] = $pageinfo;
  11744. $data ['list'] = $list;
  11745. $data ['memu'] = "receipt";
  11746. $data ['staff'] = $this->staff;
  11747. $data ['receiptMemu'] = 'payments';
  11748. $data ['verifyId'] = $this->verifyId;
  11749. $data ['executeId'] = $this->executeId;
  11750. $this->render ( "/expenses/paymentsAchieve", $data );
  11751. }
  11752. function paymentsIncomeUpdateDo() {
  11753. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11754. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11755. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11756. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11757. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11758. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11759. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11760. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11761. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11762. Doo::loadClass ( 'XDeode' );
  11763. $XDeode = new XDeode ( 5 );
  11764. $aid = $XDeode->decode ( $aidKey );
  11765. Doo::loadModel ( "accountBook" );
  11766. $accountBook = new accountBook ();
  11767. //
  11768. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11769. $price = $receivedPrice - $abDetail [inComePrice];
  11770. Doo::loadModel ( "accountBookStatistics" );
  11771. $accountBookStatistics = new accountBookStatistics ();
  11772. if ($abDetail ['accountType'] == 7) {
  11773. $item += array (
  11774. 'date' => date ( "Y-m-d" ),
  11775. 'financingPrice' => - $price,
  11776. 'expensesType' => 3,
  11777. 'aid' => $abDetail ['aid']
  11778. );
  11779. } elseif ($abDetail ['accountType'] == 8) {
  11780. $item += array (
  11781. 'date' => date ( "Y-m-d" ),
  11782. 'expensesType' => $abDetail ['expensesType'],
  11783. 'inComePrice' => - $price,
  11784. 'aid' => $abDetail ['aid']
  11785. );
  11786. } else {
  11787. $item = array (
  11788. 'date' => date ( "Y-m-d" ),
  11789. 'expensesType' => $abDetail ['expensesType'],
  11790. 'inComePrice' => $price,
  11791. 'aid' => $abDetail ['aid']
  11792. );
  11793. }
  11794. $accountBookStatistics->setAccountBookStatistics ( $item );
  11795. $accountBook->accountType = $accountType;
  11796. $accountBook->accountMsg = $accountMsg;
  11797. $accountBook->receivedPrice = $receivedPrice;
  11798. $accountBook->receivedMsg = $receivedMsg;
  11799. $accountBook->receivedBank = $receivedBank;
  11800. $accountBook->receivedDate = $receivedDate;
  11801. $accountBook->remarks = $remarks;
  11802. $accountBook->aid = $aid;
  11803. $accountBook->update ();
  11804. }
  11805. return '/paymentsAchieve';
  11806. }
  11807. function paymentsExpenditureEdiDo() {
  11808. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11809. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11810. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11811. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11812. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11813. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11814. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11815. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11816. Doo::loadClass ( 'XDeode' );
  11817. $XDeode = new XDeode ( 5 );
  11818. $aid = $XDeode->decode ( $aidKey );
  11819. Doo::loadModel ( "accountBook" );
  11820. $accountBook = new accountBook ();
  11821. // 汇总信息
  11822. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11823. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11824. Doo::loadModel ( "accountBookStatistics" );
  11825. $accountBookStatistics = new accountBookStatistics ();
  11826. if ($abDetail ['expenditureType'] == 4) {
  11827. $item += array (
  11828. 'date' => date ( "Y-m-d" ),
  11829. 'financingPrice' => $price,
  11830. 'expensesType' => 3,
  11831. 'aid' => $abDetail ['aid']
  11832. );
  11833. } elseif ($abDetail ['expenditureType'] == 5) {
  11834. $item += array (
  11835. 'date' => date ( "Y-m-d" ),
  11836. 'expensesType' => $abDetail ['expensesType'],
  11837. 'payPrice' => $price,
  11838. 'aid' => $abDetail ['aid']
  11839. );
  11840. } else {
  11841. $item = array (
  11842. 'date' => date ( "Y-m-d" ),
  11843. 'expensesType' => $abDetail ['expensesType'],
  11844. 'payPrice' => $price,
  11845. 'aid' => $abDetail ['aid']
  11846. );
  11847. }
  11848. $accountBookStatistics->setAccountBookStatistics ( $item );
  11849. //
  11850. $accountBook->expenditureType = $expenditureType;
  11851. $accountBook->expenditureMsg = $expenditureMsg;
  11852. $accountBook->expenditurePrice = $expenditurePrice;
  11853. $accountBook->expenditureBank = $expenditureBank;
  11854. $accountBook->remarks = $remarks;
  11855. $accountBook->expenditureDate = $expenditureDate;
  11856. $accountBook->aid = $aid;
  11857. $id = $accountBook->update ();
  11858. }
  11859. return '/paymentsAchieve';
  11860. }
  11861. function paymentsDelDo() {
  11862. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11863. if (! empty ( $aidKey )) {
  11864. Doo::loadClass ( 'XDeode' );
  11865. $XDeode = new XDeode ( 5 );
  11866. $aid = $XDeode->decode ( $aidKey );
  11867. Doo::loadModel ( "accountBook" );
  11868. $accountBook = new accountBook ();
  11869. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11870. if (empty ( $abDetail ))
  11871. die ( 'illegal request' );
  11872. // 删除收支
  11873. Doo::loadModel ( "accountBookStatistics" );
  11874. $accountBookStatistics = new accountBookStatistics ();
  11875. $item = array (
  11876. 'date' => date ( "Y-m-d" ),
  11877. 'aid' => $abDetail ['aid']
  11878. );
  11879. $accountType = '';
  11880. if ($abDetail ['expensesType'] == 1) {
  11881. $accountType = 6;
  11882. if ($abDetail ['accountType'] != 7) {
  11883. $item += array (
  11884. 'expensesType' => $abDetail ['expensesType'],
  11885. 'inComePrice' => - $abDetail ['receivedPrice']
  11886. );
  11887. } else {
  11888. $item += array (
  11889. 'financingPrice' => $abDetail ['receivedPrice'],
  11890. 'expensesType' => 3
  11891. );
  11892. }
  11893. } elseif ($abDetail ['expensesType'] == 2) {
  11894. $accountType = 5;
  11895. if ($abDetail ['accountType'] != 7) {
  11896. $item += array (
  11897. 'expensesType' => $abDetail ['expensesType'],
  11898. 'payPrice' => - $abDetail ['expenditurePrice']
  11899. );
  11900. } else {
  11901. $item += array (
  11902. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11903. 'expensesType' => 3
  11904. );
  11905. }
  11906. }
  11907. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11908. if ($abDetail ['expenditureMsg'] == '公司固定')
  11909. $accountType = 9;
  11910. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11911. $accountType = 10;
  11912. }
  11913. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11914. if ($abDetail ['accountMsg'] == '公司固定')
  11915. $accountType = 9;
  11916. elseif ($abDetail ['accountMsg'] == '公司活期')
  11917. $accountType = 10;
  11918. }
  11919. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11920. $accountType = 10;
  11921. }
  11922. $accountBookStatistics->setAccountBookStatistics ( $item );
  11923. $accountBook->delete ( array (
  11924. 'where' => 'aid=' . $aid,
  11925. 'limit' => 1
  11926. ) );
  11927. // 删除收入流水
  11928. if (! empty ( $accountType )) {
  11929. Doo::loadModel ( 'wasteBook' );
  11930. $wasteBook = new wasteBook ();
  11931. $wasteBook->delete ( array (
  11932. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11933. 'limit' => 1
  11934. ) );
  11935. }
  11936. }
  11937. return '/paymentsAchieve';
  11938. }
  11939. function paymentsCollect() {
  11940. Doo::loadModel ( "execute" );
  11941. $execute = new execute ();
  11942. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11943. die ( 'illegal request' );
  11944. }
  11945. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11946. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11947. Doo::loadModel ( "accountBookStatistics" );
  11948. $accountBookStatistics = new accountBookStatistics ();
  11949. Doo::loadClass ( 'receipt.func' );
  11950. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11951. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11952. $data ['html'] = $html ['html'];
  11953. $data ['inSum'] = $html ['sum'];
  11954. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11955. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11956. $data ['payHtml'] = $html ['html'];
  11957. $data ['paySum'] = $html ['sum'];
  11958. // 余额统计
  11959. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11960. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11961. include './protected/config/wasteBook.conf.php';
  11962. Doo::loadModel ( 'wasteBook' );
  11963. $wasteBook = new wasteBook ();
  11964. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11965. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11966. // 获得年份之前所有金额
  11967. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11968. // print_r($detail);
  11969. // $waste['total'];
  11970. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11971. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11972. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11973. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11974. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11975. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11976. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11977. if (date ( 'Y' ) > $year) {
  11978. $limitMonth = 12;
  11979. }
  11980. for($i = 1; $i <= 12; $i ++) {
  11981. $inComeA = $payB = 0;
  11982. $falg = true;
  11983. foreach ( $inComePay as $key => $value ) {
  11984. if ($value ['month'] == $i) {
  11985. $falg = false;
  11986. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11987. $inSum += $value ['accountPrice'];
  11988. $showInSum += $value ['accountPriceShow'];
  11989. $inComeA = $value ['accountPrice'];
  11990. break;
  11991. }
  11992. }
  11993. if ($falg)
  11994. $inComeHtml .= '<td class="taR">-</td>';
  11995. $payFalg = true;
  11996. foreach ( $pay as $key => $value ) {
  11997. if ($value ['month'] == $i) {
  11998. $payFalg = false;
  11999. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12000. $paySum += $value ['accountPrice'];
  12001. $showPaySum += $value ['accountPriceShow'];
  12002. $payB = $value ['accountPrice'];
  12003. break;
  12004. }
  12005. }
  12006. if ($payFalg)
  12007. $payHtml .= '<td class="taR">-</td>';
  12008. if (empty ( $balanceC ) || $limitMonth < $i)
  12009. $lastBalanceHtml .= '<td class="taR">-</td>';
  12010. else
  12011. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12012. $balanceC = $balanceC + $inComeA + $payB;
  12013. $balanceSum += $balanceC;
  12014. if (empty ( $balanceC ) || $limitMonth < $i)
  12015. $BalanceHtml .= '<td class="taR">-</td>';
  12016. else
  12017. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12018. // 余额统计
  12019. }
  12020. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12021. $data ['inComeHtml'] = $inComeHtml;
  12022. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12023. $data ['payBalanceHtml'] = $payHtml;
  12024. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12025. $data ['BalanceHtml'] = $BalanceHtml;
  12026. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12027. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12028. $mothHtml = "";
  12029. for($i = 1; $i <= 12; $i ++) {
  12030. if ($moth == $i)
  12031. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12032. else
  12033. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12034. }
  12035. $data ['mothHtml'] = $mothHtml;
  12036. $dateHtml = "";
  12037. $now = date ( "Y" );
  12038. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12039. if ($YEARD <= $now) {
  12040. $dateHtml .= '<option ';
  12041. if ($year == $YEARD) {
  12042. $dateHtml .= 'selected ';
  12043. }
  12044. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12045. }
  12046. }
  12047. $data ['dateHtml'] = $dateHtml;
  12048. $data ['year'] = $year;
  12049. $data ['memu'] = "receipt";
  12050. $data ['staff'] = $this->staff;
  12051. $data ['receiptMemu'] = 'paymentsCollect';
  12052. $data ['verifyId'] = $this->verifyId;
  12053. $data ['executeId'] = $this->executeId;
  12054. $this->render ( "/expenses/paymentsCollect", $data );
  12055. }
  12056. function paymentsCollectDay() {
  12057. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12058. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  12059. if (empty ( $moth ))
  12060. return 'paymentsCollect';
  12061. Doo::loadModel ( "accountBookStatistics" );
  12062. $accountBookStatistics = new accountBookStatistics ();
  12063. $i = 2;
  12064. $y = 2013;
  12065. $day = date ( "t", strtotime ( "$year-$moth" ) );
  12066. Doo::loadClass ( 'receipt.func' );
  12067. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  12068. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  12069. $data ['html'] = $html ['html'];
  12070. $data ['inSum'] = $html ['sum'];
  12071. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  12072. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  12073. $data ['payHtml'] = $html ['html'];
  12074. $data ['paySum'] = $html ['sum'];
  12075. $mothHtml = "";
  12076. for($i = 1; $i <= 12; $i ++) {
  12077. if ($moth == $i)
  12078. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12079. else
  12080. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12081. }
  12082. $data ['mothHtml'] = $mothHtml;
  12083. $data ['year'] = $year;
  12084. // 余额
  12085. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  12086. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  12087. include './protected/config/wasteBook.conf.php';
  12088. Doo::loadModel ( 'wasteBook' );
  12089. $wasteBook = new wasteBook ();
  12090. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  12091. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  12092. // 获得年份之前所有金额
  12093. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  12094. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  12095. $inComeHtml = '<tr><th colspan="2">收入</th>';
  12096. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  12097. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  12098. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  12099. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  12100. // $balanceC = 0;
  12101. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  12102. $limitDay = date ( 'd' );
  12103. $monthLK = ( int ) date ( 'm' );
  12104. if (date ( 'Y' ) > $year) {
  12105. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  12106. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  12107. $limitDay = 0;
  12108. }
  12109. for($i = 1; $i <= $day; $i ++) {
  12110. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  12111. $inComeA = $payB = 0;
  12112. $falg = true;
  12113. foreach ( $inComePay as $key => $value ) {
  12114. if ($value ['day'] == $i) {
  12115. $falg = false;
  12116. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12117. $inSum += $value ['accountPrice'];
  12118. $showInSum += $value ['accountPriceShow'];
  12119. $inComeA = $value ['accountPrice'];
  12120. break;
  12121. }
  12122. }
  12123. if ($falg)
  12124. $inComeHtml .= '<td class="taR">-</td>';
  12125. $payFalg = true;
  12126. foreach ( $pay as $key => $value ) {
  12127. if ($value ['day'] == $i) {
  12128. $payFalg = false;
  12129. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12130. $paySum += $value ['accountPrice'];
  12131. $showPaySum += $value ['accountPriceShow'];
  12132. $payB = $value ['accountPrice'];
  12133. break;
  12134. }
  12135. }
  12136. if ($payFalg)
  12137. $payHtml .= '<td class="taR">-</td>';
  12138. if (empty ( $balanceC ) || $limitDay < $i)
  12139. $lastBalanceHtml .= '<td class="taR">-</td>';
  12140. else
  12141. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12142. $balanceC = $balanceC + $inComeA + $payB;
  12143. $balanceSum += $balanceC;
  12144. if (empty ( $balanceC ) || $limitDay < $i)
  12145. $BalanceHtml .= '<td class="taR">-</td>';
  12146. else
  12147. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12148. }
  12149. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12150. $data ['inComeHtml'] = $inComeHtml;
  12151. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12152. $data ['payBalanceHtml'] = $payHtml;
  12153. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12154. $data ['BalanceHtml'] = $BalanceHtml;
  12155. $dayHtml .= '<td class="taR ">总计</td></tr>';
  12156. $data ['dayHtml'] = $dayHtml;
  12157. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12158. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12159. $dateHtml = "";
  12160. $now = date ( "Y" );
  12161. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12162. if ($YEARD <= $now) {
  12163. $dateHtml .= '<option ';
  12164. if ($year == $YEARD) {
  12165. $dateHtml .= 'selected ';
  12166. }
  12167. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12168. }
  12169. }
  12170. $data ['dateHtml'] = $dateHtml;
  12171. $data ['memu'] = "receipt";
  12172. $data ['staff'] = $this->staff;
  12173. $data ['receiptMemu'] = 'paymentsCollect';
  12174. $data ['verifyId'] = $this->verifyId;
  12175. $data ['executeId'] = $this->executeId;
  12176. $this->render ( "/expenses/paymentsCollectDay", $data );
  12177. }
  12178. // 公司流水
  12179. function wasteBook() {
  12180. Doo::loadModel ( "execute" );
  12181. $execute = new execute ();
  12182. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  12183. die ( 'illegal request' );
  12184. }
  12185. include './protected/config/wasteBook.conf.php';
  12186. Doo::loadModel ( 'wasteBook' );
  12187. $wasteBook = new wasteBook ();
  12188. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  12189. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  12190. //
  12191. $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'];
  12192. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12193. //$waste ['bank'] ['ICBCDeposit']=sprintf("%.2f", round($waste ['bank'] ['ICBCDeposit'], 2));
  12194. // print_r($waste);
  12195. $data ['waste'] = $waste;
  12196. $data ['total'] = $total;
  12197. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  12198. $data['cashBalance']= $CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12199. // 月流水数据结构
  12200. $monthStatistics = array ();
  12201. $incomeMothStatistics = array ();
  12202. $expenditureMothStatistics = array ();
  12203. for($i = 1; $i <= 12; $i ++) {
  12204. $month = date ( 'Y' ) . '-' . $i;
  12205. if ($i < 10)
  12206. $month = date ( 'Y' ) . '-0' . $i;
  12207. array_push ( $monthStatistics, $month );
  12208. }
  12209. foreach ( $monthStatistics as $value ) {
  12210. $falg = true;
  12211. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12212. if ($value == $v ['inputDate']) {
  12213. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12214. $falg = false;
  12215. }
  12216. }
  12217. if ($falg) {
  12218. array_push ( $incomeMothStatistics, '' );
  12219. }
  12220. $falgEx = true;
  12221. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12222. if ($value == $v ['inputDate']) {
  12223. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12224. $falg = false;
  12225. }
  12226. }
  12227. if ($falgEx) {
  12228. array_push ( $expenditureMothStatistics, '' );
  12229. }
  12230. }
  12231. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12232. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12233. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12234. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12235. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12236. // print_r($incomeList);
  12237. $data ['expenditureList'] = $expenditureList;
  12238. $data ['incomeList'] = $incomeList;
  12239. $data ['memu'] = "receipt";
  12240. $data ['staff'] = $this->staff;
  12241. $data ['receiptMemu'] = 'wasteBook';
  12242. $data ['verifyId'] = $this->verifyId;
  12243. $data ['executeId'] = $this->executeId;
  12244. $this->render ( "/expenses/wasteBook", $data );
  12245. }
  12246. function wasteBookIncome() {
  12247. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12248. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12249. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12250. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12251. $data ['dailyIncomeType'] = $dailyIncomeType;
  12252. Doo::loadModel ( 'wasteBook' );
  12253. $wasteBook = new wasteBook ();
  12254. Doo::loadModel ( 'L_category' );
  12255. $L_category = new L_category ();
  12256. Doo::loadClass ( 'XDeode' );
  12257. $XDeode = new XDeode ( 5 );
  12258. $year=date("Y");
  12259. $theDay=date("Y-m-d");
  12260. $dateArr = explode ( ':', $date );
  12261. $D1 = '';
  12262. $D2 = '';
  12263. $con = '';
  12264. if (! empty ( $date )) {
  12265. $D1 = $dateArr [0];
  12266. $D2 = $dateArr [1];
  12267. }
  12268. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12269. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12270. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12271. $con = ' and inputDate = "' . $D1 . '"';
  12272. else{
  12273. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12274. }
  12275. if ($cid != 'ALL') {
  12276. $cid = $XDeode->decode ( $cid );
  12277. $con .= ' and cid = "' . $cid . '"';
  12278. }
  12279. if ($accountType != 'ALL') {
  12280. if ($accountType == 'INVOICE') {
  12281. $con .= ' and (accountType = 7 or accountType = 8)';
  12282. } elseif ($accountType == 'PAYMENTS') {
  12283. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12284. if ($dailyIncomeType != 'ALL') {
  12285. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12286. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12287. }
  12288. }
  12289. }
  12290. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12291. foreach ($incomeList as $key=>$value){
  12292. if(($value['accountType']==6||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12293. $wasteBook = new wasteBook ();
  12294. $wasteBook->wid = $value['wid'];
  12295. $wasteBook->synPaymentDate = 1;
  12296. $wasteBook->inputDate = $value['data']['receivedDate'];
  12297. $wasteBook->update();
  12298. }
  12299. }
  12300. $sum = 0;$thsDaySum=0;
  12301. foreach ( $incomeList as $key => $value ) {
  12302. $sum += $value ['accountPrice'];
  12303. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12304. $thsDaySum+=$value ['accountPrice'];
  12305. }
  12306. }
  12307. // print_r($incomeList);
  12308. // 获得办事和部门
  12309. $categoryList = $L_category->getCategory ();
  12310. $data ['accountType'] = $accountType;
  12311. $data ['cid'] = $cid;
  12312. $data ['categoryList'] = $categoryList;
  12313. $data ['sum'] = $sum;
  12314. $data ['incomeList'] = $incomeList;
  12315. $data ['inputDate'] = $date;
  12316. $data['year']=$year;
  12317. $data ['thsDay'] =$theDay;
  12318. $data ['thsDaySum'] =$thsDaySum;
  12319. $data ['memu'] = "receipt";
  12320. $data ['staff'] = $this->staff;
  12321. $data ['receiptMemu'] = 'wasteBook';
  12322. $data ['verifyId'] = $this->verifyId;
  12323. $data ['executeId'] = $this->executeId;
  12324. $this->render ( "/expenses/wasteBookIncome", $data );
  12325. }
  12326. /**
  12327. * 所有支出
  12328. */
  12329. function wasteBookExpenditure() {
  12330. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12331. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12332. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12333. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12334. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12335. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12336. $data ['receiptType'] = $receiptType;
  12337. Doo::loadModel ( 'wasteBook' );
  12338. $wasteBook = new wasteBook ();
  12339. Doo::loadModel ( 'L_category' );
  12340. $L_category = new L_category ();
  12341. Doo::loadClass ( 'XDeode' );
  12342. $XDeode = new XDeode ( 5 );
  12343. $year=date("Y");
  12344. $theDay=date("Y-m-d");
  12345. $dateArr = explode ( ':', $date );
  12346. $D1 = '';
  12347. $D2 = '';
  12348. $con = '';
  12349. if (! empty ( $date )) {
  12350. $D1 = $dateArr [0];
  12351. $D2 = $dateArr [1];
  12352. }
  12353. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12354. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12355. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12356. $con = ' and inputDate = "' . $D1 . '"';
  12357. else{
  12358. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12359. }
  12360. if ($cid != 'ALL') {
  12361. $cid = $XDeode->decode ( $cid );
  12362. $con .= ' and cid = "' . $cid . '"';
  12363. }
  12364. if ($accountType != 'ALL') {
  12365. if ($accountType == 'INVOICE') {
  12366. $con .= ' and accountType = 11';
  12367. } elseif ($accountType == 'PAYMENTS') {
  12368. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12369. if ($dailyExpenditureType != 'ALL') {
  12370. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12371. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12372. }
  12373. } elseif ($accountType == 'RECEIPT') {
  12374. if ($receiptType == 'ALL') {
  12375. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12376. } else {
  12377. $receiptType = $XDeode->decode ( $receiptType );
  12378. echo $receiptType;
  12379. if ($receiptType == 1) {
  12380. $con .= ' and (accountType = 1 or accountType=2)';
  12381. } else {
  12382. $con .= ' and accountType = ' . $receiptType;
  12383. }
  12384. }
  12385. }
  12386. }
  12387. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12388. foreach ($incomeList as $key=>$value){
  12389. if(($value['accountType']==5||$value['accountType']==9||$value['accountType']==10)&&$value['synPaymentDate']==0){
  12390. $wasteBook = new wasteBook ();
  12391. $wasteBook->wid = $value['wid'];
  12392. $wasteBook->synPaymentDate = 1;
  12393. $wasteBook->inputDate = $value['data']['expenditureDate'];
  12394. $wasteBook->update();
  12395. }
  12396. }
  12397. $sum = 0;$thsDaySum=0;
  12398. foreach ( $incomeList as $key => $value ) {
  12399. $sum += $value ['accountPriceShow'];
  12400. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12401. $thsDaySum+=$value ['accountPriceShow'];
  12402. }
  12403. }
  12404. // print_r($incomeList);
  12405. // 获得办事和部门
  12406. $categoryList = $L_category->getCategory ();
  12407. $data ['accountType'] = $accountType;
  12408. $data ['cid'] = $cid;
  12409. $data ['categoryList'] = $categoryList;
  12410. $data ['sum'] = $sum;
  12411. $data ['incomeList'] = $incomeList;
  12412. $data ['inputDate'] = $date;
  12413. $data['year']=$year;
  12414. $data ['thsDay'] =$theDay;
  12415. $data ['thsDaySum'] =$thsDaySum;
  12416. $data ['memu'] = "receipt";
  12417. $data ['staff'] = $this->staff;
  12418. $data ['receiptMemu'] = 'wasteBook';
  12419. $data ['verifyId'] = $this->verifyId;
  12420. $data ['executeId'] = $this->executeId;
  12421. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12422. }
  12423. function ajaxGetWasteinvoiceReceivables() {
  12424. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12425. Doo::loadClass ( 'XDeode' );
  12426. $XDeode = new XDeode ( 5 );
  12427. $irid = $XDeode->decode ( $serial );
  12428. Doo::loadModel ( 'invoiceReceivables' );
  12429. $invoiceReceivables = new invoiceReceivables ();
  12430. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12431. echo json_encode ( array (
  12432. 'status' => 1,
  12433. 'detail' => $detail
  12434. ) );
  12435. }
  12436. function ajaxGetPaymentsByAid() {
  12437. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12438. Doo::loadModel ( "accountBook" );
  12439. $accountBook = new accountBook ();
  12440. $detail = $accountBook->getAccountBookByAid ( $serial );
  12441. echo json_encode ( array (
  12442. 'status' => 1,
  12443. 'detail' => $detail
  12444. ) );
  12445. }
  12446. function ajaxGetWasteInvoice() {
  12447. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12448. Doo::loadModel ( 'invoice' );
  12449. $invoice = new invoice ();
  12450. Doo::loadModel ( 'invoiceReceivables' );
  12451. $invoiceReceivables = new invoiceReceivables ();
  12452. $detail = $invoice->getInvoiceByIid ( $serial );
  12453. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12454. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12455. echo json_encode ( array (
  12456. 'status' => 1,
  12457. 'detail' => $detail
  12458. ) );
  12459. }
  12460. /**
  12461. */
  12462. function ajaxGetWasteReceipt() {
  12463. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12464. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12465. Doo::loadModel ( 'receipt' );
  12466. $receipt = new receipt ();
  12467. Doo::loadClass ( 'XDeode' );
  12468. $XDeode = new XDeode ( 5 );
  12469. $rid = $XDeode->decode ( $serial );
  12470. $accountType= $XDeode->decode ( $accountTypeKey );
  12471. // 获得个数据
  12472. $detail = $receipt->getReceiptByRid ( $rid );
  12473. // 初始化
  12474. $detail ['reviseDetail'] = array ();
  12475. if (! empty ( $value ['reviseDetail'] ))
  12476. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12477. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12478. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12479. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12480. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12481. // 获得费用html
  12482. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12483. // 获得费用审批人数据
  12484. $detail = $this->getReceiptApproverHtml ( $detail );
  12485. // 审批执行
  12486. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12487. <th class="taC" width="90">审批人</th>
  12488. <th class="taC">审批意见</th></tr>';
  12489. foreach ( $detail ['verifyList'] as $key => $value ) {
  12490. $html .= '<tr>
  12491. <td>' . $value [1] . '</td>
  12492. <td>' . $value ['opinion'] . '</td>
  12493. </tr>
  12494. ';
  12495. }
  12496. $html .= ' </tbody></table>';
  12497. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12498. <th class="taC" width="90">执行人</th>
  12499. <th class="taC">执行意见</th></tr>';
  12500. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12501. $html .= '<tr>
  12502. <td>' . $value [1] . '</td>
  12503. <td>' . $value ['opinion'] . '</td>
  12504. </tr>
  12505. ';
  12506. }
  12507. $html .= ' </tbody></table>';
  12508. if($accountType==1){
  12509. Doo::loadModel ( 'loanReceipt' );
  12510. $loanReceipt = new loanReceipt ();
  12511. $loanList = $loanReceipt->getOne ( array (
  12512. 'where' => 'rid=' . $detail ['loanRid'],
  12513. 'desc' => 'rid',
  12514. 'asArray' => true
  12515. ) );
  12516. $html .= '<table class="table table-bordered table-condensed">
  12517. <tr class="warning">
  12518. <td class="taR"><b>汇款金额</b></td>
  12519. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12520. </tr>
  12521. </table>';
  12522. }else{
  12523. $html .= '<table class="table table-bordered table-condensed">
  12524. <tr class="warning">
  12525. <td class="taR"><b>汇款金额</b></td>
  12526. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12527. </tr>
  12528. </table>';
  12529. }
  12530. // print_r($detail['verifyList']);
  12531. // header ( 'Content-Type:text/html;charset=utf-8' );
  12532. // echo $html;
  12533. echo json_encode ( array (
  12534. 'status' => 1,
  12535. 'html' => $html,
  12536. 'detail' => $detail
  12537. ) );
  12538. }
  12539. function getReceiptApproverHtml($detail = array()) {
  12540. Doo::loadModel ( 'loanReceipt' );
  12541. $loanReceipt = new loanReceipt ();
  12542. Doo::loadModel ( 'verify' );
  12543. $verify = new verify ();
  12544. Doo::loadModel ( 'staff' );
  12545. $staff = new staff ();
  12546. if (empty ( $detail ))
  12547. return array ();
  12548. $loanList = $loanReceipt->getOne ( array (
  12549. 'where' => 'rid=' . $detail ['loanRid'],
  12550. 'desc' => 'rid',
  12551. 'asArray' => true
  12552. ) );
  12553. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12554. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12555. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12556. else
  12557. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12558. } else
  12559. $verifyList = $verify->getOne ( array (
  12560. 'where' => 'vid=' . $detail ['verify'],
  12561. 'asArray' => true
  12562. ) );
  12563. $verifyList = json_decode ( $verifyList ['staff'], true );
  12564. Doo::loadModel ( 'role' );
  12565. $role = new role ();
  12566. $roleId = 0;
  12567. $flag = true;
  12568. $roleKey = 0;
  12569. $endStaffArray = array ();
  12570. $roleArrayCopy = array ();
  12571. foreach ( $verifyList as $k => $v ) {
  12572. // init verifyStaff
  12573. if ($v [1] == 'ROLE') {
  12574. if (! empty ( $verifyStaff )) {
  12575. $endStaffArray = end ( $verifyStaff );
  12576. }
  12577. $roleVerify = json_decode ( $v [3], true );
  12578. $roleKey = $k;
  12579. $roleArray = array ();
  12580. $rolename = $role->getOne ( array (
  12581. 'where' => 'rid=' . $v [0],
  12582. 'asArray' => true
  12583. ) );
  12584. foreach ( $roleVerify as $o => $p ) {
  12585. $staffID = explode ( '_', $p );
  12586. $staffInfo = $staff->getOne ( array (
  12587. 'where' => 'sid=' . $staffID [0],
  12588. 'asArray' => true
  12589. ) );
  12590. // print_r($staffID);
  12591. $exp = array (
  12592. 0 => $staffInfo ['sid'],
  12593. 1 => $staffID [1],
  12594. 2 => $staffInfo ['avatar'],
  12595. 'date' => '',
  12596. 'date' => '',
  12597. 'opinion' => '',
  12598. 'status' => '',
  12599. 'rolename' => $rolename ['name']
  12600. );
  12601. array_push ( $roleArray, $exp );
  12602. }
  12603. $roleArrayCopy [$v [0]] = $roleArray;
  12604. // $verifyList[$k]['roleArray']=$roleArray;
  12605. }
  12606. $verifyList [$k] ['date'] = "";
  12607. $verifyList [$k] ['opinion'] = "";
  12608. $verifyList [$k] ['status'] = "";
  12609. if (empty ( $verifyStaff )) {
  12610. $verifyList [$k] ['date'] = "";
  12611. $verifyList [$k] ['opinion'] = "";
  12612. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12613. $verifyList [$k] ['status'] = 4;
  12614. $flag = false;
  12615. }
  12616. } else {
  12617. foreach ( $verifyStaff as $m => $u ) {
  12618. if ($v [0] == $m) {
  12619. $verifyList [$k] ['date'] = $u ['date'];
  12620. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12621. $verifyList [$k] ['status'] = $u ['status'];
  12622. $flag = false;
  12623. break;
  12624. }
  12625. }
  12626. $endStaffArray = end ( $verifyStaff );
  12627. }
  12628. }
  12629. $rolename ['name'] = '';
  12630. if (! empty ( $roleId )) {
  12631. Doo::loadModel ( 'role' );
  12632. $role = new role ();
  12633. $rolename = $role->getOne ( array (
  12634. 'where' => 'rid=' . $roleId,
  12635. 'asArray' => true
  12636. ) );
  12637. }
  12638. if (! empty ( $verifyStaff ))
  12639. $endStaffArray = end ( $verifyStaff );
  12640. $KOP = false;
  12641. foreach ( $roleArrayCopy as $P => $A ) {
  12642. foreach ( $A as $MKI => $AVL ) {
  12643. if (! empty ( $verifyStaff )) {
  12644. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12645. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12646. $button = 4;
  12647. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12648. }
  12649. foreach ( $verifyStaff as $m => $u ) {
  12650. $AVLFK = $AVL [0] . '_R';
  12651. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12652. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12653. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12654. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12655. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12656. break;
  12657. }
  12658. }
  12659. } else {
  12660. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12661. $button = 4;
  12662. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12663. }
  12664. }
  12665. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12666. $KOP = true;
  12667. }
  12668. }
  12669. foreach ( $roleArrayCopy as $k => $v ) {
  12670. foreach ( $verifyList as $m => $n ) {
  12671. if ($n [0] == $k) {
  12672. array_splice ( $verifyList, $m, 1, $v );
  12673. }
  12674. }
  12675. }
  12676. // 费用执行人相关数据
  12677. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12678. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12679. foreach ( $executeCopy as $k => $v ) {
  12680. $executeCopy [$k] ['date'] = '';
  12681. $executeCopy [$k] ['opinion'] = '';
  12682. $executeCopy [$k] ['status'] = '';
  12683. if (! empty ( $executeStaff ))
  12684. foreach ( $executeStaff as $m => $u ) {
  12685. if ($v [0] == $m) {
  12686. $executeCopy [$k] ['date'] = $u ['date'];
  12687. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12688. $executeCopy [$k] ['status'] = $u ['status'];
  12689. break;
  12690. }
  12691. }
  12692. }
  12693. $detail ['executeCopy'] = $executeCopy;
  12694. $detail ['verifyList'] = $verifyList;
  12695. return $detail;
  12696. }
  12697. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12698. if (empty ( $detail ))
  12699. return '';
  12700. $html = '';
  12701. if ($detail ['Rtype'] == 0) { // 报销单
  12702. $html .= '<table class="table table-bordered table-condensed">
  12703. <tbody>
  12704. <tr>
  12705. <th colspan="2" class="taC">日常相关费用</th>
  12706. </tr>';
  12707. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12708. $html .= '
  12709. <tr>
  12710. <th>' . $value ['name'] . '</th>
  12711. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12712. </tr>';
  12713. }
  12714. $html .= '
  12715. <tr>
  12716. <th class="taR">合计</th>
  12717. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12718. </tr>';
  12719. $html .= '<tr>
  12720. <th colspan="2" class="taC">差旅相关费用</th>
  12721. </tr>';
  12722. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12723. $html .= '
  12724. <tr>
  12725. <th>' . $value ['name'] . '</th>
  12726. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12727. </tr>';
  12728. }
  12729. $html .= '
  12730. <tr>
  12731. <th class="taR">合计</th>
  12732. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12733. </tr>';
  12734. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12735. $html .= '<tr>
  12736. <th colspan="2" class="taC">内部培训费用</th>
  12737. </tr>';
  12738. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12739. $html .= '
  12740. <tr>
  12741. <th>' . $value ['name'] . '</th>
  12742. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12743. </tr>';
  12744. }
  12745. $html .= '
  12746. <tr>
  12747. <th class="taR">合计</th>
  12748. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12749. </tr>';
  12750. }
  12751. $html .= '<tr>
  12752. <th colspan="2" class="taC">其他</th>
  12753. </tr>';
  12754. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12755. $html .= '
  12756. <tr>
  12757. <th>' . $value ['name'] . '</th>
  12758. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12759. </tr>';
  12760. }
  12761. $html .= '
  12762. <tr>
  12763. <th class="taR">合计</th>
  12764. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12765. </tr>';
  12766. $html .= '<tr>
  12767. <th colspan="2" class="taC">报销金额调整</th>
  12768. </tr>';
  12769. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12770. $html .= '
  12771. <tr>
  12772. <th>' . $value ['name'] . '</th>
  12773. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12774. </tr>';
  12775. }
  12776. $html .= '
  12777. <tr>
  12778. <th class="taR">合计</th>
  12779. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12780. </tr>';
  12781. $html .= '
  12782. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12783. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12784. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12785. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12786. <tr class="warning">
  12787. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12788. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12789. </tr>
  12790. </tbody>
  12791. </table>';
  12792. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12793. $html .= '
  12794. <table class="table table-bordered table-condensed">
  12795. <tbody>
  12796. <tr>
  12797. <th colspan="2" class="taC">办事处相关费用</th>
  12798. </tr>';
  12799. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12800. $html .= '
  12801. <tr>
  12802. <th>' . $value ['name'] . '</th>
  12803. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12804. </tr>';
  12805. }
  12806. $html .= '
  12807. <tr>
  12808. <th class="taR">合计</th>
  12809. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12810. </tr>';
  12811. $html .= '
  12812. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12813. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12814. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12815. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12816. <tr class="warning">
  12817. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12818. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12819. </tr>
  12820. </tbody>
  12821. </table>';
  12822. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12823. Doo::loadModel ( 'loanReceipt' );
  12824. $loanReceipt = new loanReceipt ();
  12825. $loanList = $loanReceipt->getOne ( array (
  12826. 'where' => 'rid=' . $detail ['loanRid'],
  12827. 'desc' => 'rid',
  12828. 'asArray' => true
  12829. ) );
  12830. // print_r($loanList);
  12831. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12832. $html .= '<table class="table table-bordered table-condensed">
  12833. <tbody>
  12834. <tr>
  12835. <th colspan="2" class="taC">借款费用</th>
  12836. </tr>';
  12837. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12838. $html .= '<tr>
  12839. <th>' . $value ['name'] . '</th>
  12840. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12841. </tr>';
  12842. }
  12843. $html .= '<tr>
  12844. <th class="taC" colspan="2">产生费用所在办事处</th>
  12845. </tr>
  12846. <tr>
  12847. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12848. </tr>
  12849. <tr>
  12850. <th class="taC" colspan="2">费用说明</th>
  12851. </tr>
  12852. <tr>
  12853. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12854. </tr>
  12855. <tr class="warning">
  12856. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12857. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12858. </tr>
  12859. </tbody>
  12860. </table>
  12861. ';
  12862. if ( $accountType==2) {
  12863. $balance=$detail ['sum']-$loanList ['sum'];
  12864. $balanceCN=$this->num_to_rmb($balance);
  12865. $html .= '<table class="table table-bordered table-condensed">
  12866. <tbody>
  12867. <tr>
  12868. <th colspan="2" class="taC">日常相关费用</th>
  12869. </tr>';
  12870. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12871. $html .= '
  12872. <tr>
  12873. <th>' . $value ['name'] . '</th>
  12874. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12875. </tr>';
  12876. }
  12877. $html .= '
  12878. <tr>
  12879. <th class="taR">合计</th>
  12880. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12881. </tr>';
  12882. $html .= '<tr>
  12883. <th colspan="2" class="taC">差旅相关费用</th>
  12884. </tr>';
  12885. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12886. $html .= '
  12887. <tr>
  12888. <th>' . $value ['name'] . '</th>
  12889. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12890. </tr>';
  12891. }
  12892. $html .= '
  12893. <tr>
  12894. <th class="taR">合计</th>
  12895. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12896. </tr>';
  12897. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12898. $html .= '<tr>
  12899. <th colspan="2" class="taC">内部培训费用</th>
  12900. </tr>';
  12901. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12902. $html .= '
  12903. <tr>
  12904. <th>' . $value ['name'] . '</th>
  12905. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12906. </tr>';
  12907. }
  12908. $html .= '
  12909. <tr>
  12910. <th class="taR">合计</th>
  12911. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12912. </tr>';
  12913. }
  12914. $html .= '<tr>
  12915. <th colspan="2" class="taC">其他</th>
  12916. </tr>';
  12917. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12918. $html .= '
  12919. <tr>
  12920. <th>' . $value ['name'] . '</th>
  12921. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12922. </tr>';
  12923. }
  12924. $html .= '
  12925. <tr>
  12926. <th class="taR">合计</th>
  12927. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12928. </tr>';
  12929. $html .= '<tr>
  12930. <th colspan="2" class="taC">报销金额调整</th>
  12931. </tr>';
  12932. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12933. $html .= '
  12934. <tr>
  12935. <th>' . $value ['name'] . '</th>
  12936. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12937. </tr>';
  12938. }
  12939. $html .= '
  12940. <tr>
  12941. <th class="taR">合计</th>
  12942. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12943. </tr>';
  12944. $html .= '
  12945. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12946. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12947. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12948. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12949. <tr class="warning">
  12950. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12951. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12952. </tr>
  12953. <tr class="success">
  12954. <td class="taR"><b>借款结余</b></td>
  12955. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12956. </tr>
  12957. </tbody>
  12958. </table>';
  12959. }
  12960. }
  12961. return $html;
  12962. }
  12963. /**
  12964. * 计算流水
  12965. */
  12966. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12967. $bakWaste ['bank'] = array (
  12968. 'CGBDeposit' => 0,
  12969. 'ICBCDeposit' => 0,
  12970. 'HUADeposit' => 0,
  12971. 'PersonalDeposit' => 0
  12972. );
  12973. $bakWaste ['financial'] = array (
  12974. 'current' => array (
  12975. 'CGBDeposit' => 0,
  12976. 'ICBCDeposit' => 0
  12977. ),
  12978. 'fixed' => array (
  12979. 'CGBDeposit' => 0,
  12980. 'ICBCDeposit' => 0
  12981. )
  12982. );
  12983. // 存款
  12984. foreach ( $waste ['bank'] as $key => $value ) {
  12985. // 收入
  12986. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12987. // 广发
  12988. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12989. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12990. }
  12991. // 工商
  12992. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12993. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12994. }
  12995. // 华润
  12996. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12997. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12998. }
  12999. // 个人
  13000. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13001. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13002. }
  13003. }
  13004. }
  13005. foreach ( $waste ['bank'] as $key => $value ) {
  13006. // 支出
  13007. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  13008. // 广发
  13009. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13010. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13011. }
  13012. // 工商
  13013. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13014. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13015. }
  13016. // 华润
  13017. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13018. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13019. }
  13020. // 个人
  13021. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13022. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13023. }
  13024. }
  13025. }
  13026. // 活期
  13027. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13028. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13029. // 广发
  13030. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13031. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13032. }
  13033. // 工商
  13034. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13035. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13036. }
  13037. // 个人
  13038. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13039. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13040. }
  13041. }
  13042. }
  13043. // print_r($inComeStatistics ['fixedStatistics']);
  13044. // 固期
  13045. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13046. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13047. // 广发
  13048. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13049. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13050. }
  13051. // 工商
  13052. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13053. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13054. }
  13055. // 个人
  13056. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13057. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13058. }
  13059. }
  13060. }
  13061. return $waste;
  13062. }
  13063. function lyt() {
  13064. Doo::loadModel ( "receiptDetail" );
  13065. $receiptDetail = new receiptDetail ();
  13066. $receiptCollectList = $receiptDetail->find ( array (
  13067. 'where' => 'status=1 ',
  13068. 'asArray' => true
  13069. ) );
  13070. foreach ( $receiptCollectList as $key => $value ) {
  13071. $receiptDetail = new receiptDetail ();
  13072. $receiptDetail->pastDate = $value ['date'];
  13073. $receiptDetail->update ( array (
  13074. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13075. ) );
  13076. }
  13077. }
  13078. function staffCollectMonthDetail() {
  13079. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13080. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13081. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13082. if (! $year)
  13083. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13084. if (! $month)
  13085. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13086. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13087. if (! $nature){
  13088. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13089. }
  13090. Doo::loadModel ( 'staff' );
  13091. $staff = new staff ();
  13092. Doo::loadModel ( "receiptDetail" );
  13093. $receiptDetail = new receiptDetail ();
  13094. Doo::loadModel ( 'accountItem' );
  13095. $accountItem = new accountItem ();
  13096. Doo::loadModel ( 'statistics' );
  13097. $statistics = new statistics ();
  13098. Doo::loadModel ( "receiptAuthorityManage" );
  13099. $receiptAuthorityManage = new receiptAuthorityManage ();
  13100. $aiList=$accountItem->getAccountItem();
  13101. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13102. $cidList = array ();
  13103. foreach ( $imcStaff as $key => $value ) {
  13104. array_push ( $cidList, $value ['cid'] );
  13105. }
  13106. $cidString = implode ( ',', $cidList );
  13107. $naturecon='';
  13108. if ($nature=='ONJOB'){
  13109. $naturecon=' and (nature!=4 )';
  13110. }elseif($nature=='LEAVEJOB'){
  13111. $naturecon=' and (nature=4 )';
  13112. }else{
  13113. die ( 'illegal request--nature' );
  13114. }
  13115. $staffList = $staff->find ( array (
  13116. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13117. 'asArray' => true
  13118. ) );
  13119. $categoryList = $staff->find ( array (
  13120. 'select' => 'COUNT(*) as count,cid,category',
  13121. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13122. 'groupby' => 'cid',
  13123. 'asArray' => true
  13124. ) );
  13125. $list = array ();
  13126. foreach($aiList as $key=>$value){
  13127. foreach ($value as $v){
  13128. $subtotal[$key][$v['name']]=0;
  13129. }
  13130. }
  13131. foreach ( $categoryList as $vlu ) {
  13132. $s1 = 0;
  13133. $m1 = 0;
  13134. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13135. foreach ( $staffList as $value ) {
  13136. if ($vlu ['cid'] == $value ['cid']) {
  13137. // pastDate
  13138. $receiptCollectList = $receiptDetail->find ( array (
  13139. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13140. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13141. 'groupby' => 'item,Month(pastDate),itemCategory',
  13142. 'asArray' => true
  13143. ) );
  13144. if (! empty ( $receiptCollectList )) {
  13145. $receiptL = array (
  13146. '日常相关费用' => array (),
  13147. '差旅相关费用' => array (),
  13148. '内部培训费用' => array (),
  13149. '培训班费用' => array (),
  13150. '其他' => array ()
  13151. );
  13152. $html = "";
  13153. $psum = 0;
  13154. foreach ( $aiList[$this->AGENCY] as $va ) {
  13155. $falg = true;
  13156. foreach ( $receiptCollectList as $v ) {
  13157. if ($v ['itemCategory'] == '日常相关费用') {
  13158. if ($v ['item'] == $va['name']) {
  13159. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13160. $psum += $v ['price'];
  13161. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13162. $falg = false;
  13163. break;
  13164. }
  13165. }
  13166. }
  13167. if ($falg)
  13168. $html .= '<td class="taR">-</td>';
  13169. }
  13170. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13171. if (! empty ( $psum ))
  13172. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13173. else
  13174. $psum = '<td class="colGreen taR">-</td>';
  13175. $receiptL ['日常相关费用'] = $psum . $html;
  13176. /* ----------------------------------- */
  13177. $html = "";
  13178. $psum = 0;
  13179. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13180. $falg = true;
  13181. foreach ( $receiptCollectList as $v ) {
  13182. if ($v ['itemCategory'] == '差旅相关费用') {
  13183. if ($v ['item'] == $va['name']) {
  13184. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13185. $psum += $v ['price'];
  13186. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13187. $falg = false;
  13188. break;
  13189. }
  13190. }
  13191. }
  13192. if ($falg)
  13193. $html .= '<td class="taR">-</td>';
  13194. }
  13195. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13196. if (! empty ( $psum ))
  13197. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13198. else
  13199. $psum = '<td class="colGreen taR">-</td>';
  13200. $receiptL ['差旅相关费用'] = $psum . $html;
  13201. /* ------------------------------------- */
  13202. $html = "";
  13203. $psum = 0;
  13204. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13205. $falg = true;
  13206. foreach ( $receiptCollectList as $v ) {
  13207. if ($v ['itemCategory'] == '内部培训费用') {
  13208. if ($v ['item'] == $va['name']) {
  13209. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13210. $psum += $v ['price'];
  13211. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13212. $falg = false;
  13213. break;
  13214. }
  13215. }
  13216. }
  13217. if ($falg)
  13218. $html .= '<td class="taR">-</td>';
  13219. }
  13220. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13221. if (! empty ( $psum ))
  13222. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13223. else
  13224. $psum = '<td class="colGreen taR">-</td>';
  13225. $receiptL ['内部培训费用'] = $psum . $html;
  13226. /* ----------------------------------- */
  13227. $html = "";
  13228. $psum = 0;
  13229. foreach ( $aiList[$this->TRAIN] as $va ) {
  13230. $falg = true;
  13231. foreach ( $receiptCollectList as $v ) {
  13232. if ($v ['itemCategory'] == '培训班费用') {
  13233. if ($v ['item'] == $va['name']) {
  13234. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13235. $psum += $v ['price'];
  13236. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13237. $falg = false;
  13238. break;
  13239. }
  13240. }
  13241. }
  13242. if ($falg)
  13243. $html .= '<td class="taR">-</td>';
  13244. }
  13245. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13246. if (! empty ( $psum ))
  13247. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13248. else
  13249. $psum = '<td class="colGreen taR">-</td>';
  13250. $receiptL ['培训班费用'] = $psum . $html;
  13251. /* ------------------------------------- */
  13252. $html = "";
  13253. $psum = 0;
  13254. foreach ( $aiList[$this->OTHER] as $va ) {
  13255. $falg = true;
  13256. foreach ( $receiptCollectList as $v ) {
  13257. if ($v ['itemCategory'] == '其他') {
  13258. if (trim ( $v ['item'] ) == $va['name']) {
  13259. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13260. $psum += $v ['price'];
  13261. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13262. $falg = false;
  13263. break;
  13264. }
  13265. }
  13266. }
  13267. if ($falg)
  13268. $html .= '<td class="taR">-</td>';
  13269. }
  13270. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13271. if (! empty ( $psum ))
  13272. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13273. else
  13274. $psum = '<td class="colGreen taR">-</td>';
  13275. $receiptL ['其他'] = $psum . $html;
  13276. /* ------------------------------------- */
  13277. $html = "";
  13278. $psum = 0;
  13279. foreach ( $receiptCollectList as $v ) {
  13280. if ($v ['itemCategory'] == '报销金额调整') {
  13281. if (! empty ( $v ['price'] )) {
  13282. $psum += $v ['price'];
  13283. }
  13284. }
  13285. }
  13286. $s1 += $psum;
  13287. if (! empty ( $psum ))
  13288. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13289. else
  13290. $psum = '<td class="taR colOrange">-</td>';
  13291. $receiptL ['报销金额调整'] = $psum . $html;
  13292. } else {
  13293. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13294. foreach ( $aiList[$this->AGENCY] as $va ) {
  13295. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13296. }
  13297. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13298. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13299. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13300. }
  13301. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13302. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13303. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13304. }
  13305. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13306. foreach ( $aiList[$this->TRAIN] as $va ) {
  13307. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13308. }
  13309. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13310. foreach ( $aiList[$this->OTHER] as $va ) {
  13311. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13312. }
  13313. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13314. }
  13315. $monthStaffPrice = $receiptDetail->find ( array (
  13316. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13317. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13318. 'groupby' => 'Month(pastDate)',
  13319. 'asArray' => true
  13320. ) );
  13321. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13322. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13323. $m1 += $monthStaffPrice [0] ['price'];
  13324. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13325. } else
  13326. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13327. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13328. $list [$value ['username']] = $receiptL;
  13329. }
  13330. }
  13331. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13332. foreach ( $aiList[$this->AGENCY] as $va ) {
  13333. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13334. $subtotal[$this->AGENCY][$va['name']]=0;
  13335. }
  13336. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13337. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13338. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13339. $subtotal[$this->TRAVEL][$va['name']]=0;
  13340. }
  13341. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13342. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13343. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13344. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13345. }
  13346. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13347. foreach ( $aiList[$this->TRAIN] as $va ) {
  13348. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13349. $subtotal[$this->TRAIN][$va['name']]=0;
  13350. }
  13351. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13352. foreach ( $aiList[$this->OTHER] as $va ) {
  13353. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13354. $subtotal[$this->OTHER][$va['name']]=0;
  13355. }
  13356. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13357. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13358. $receiptL ['usernameEn'] =false;
  13359. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13360. }
  13361. $data ['list'] = $list;
  13362. // print_r($list);
  13363. $receiptCollectList = $receiptDetail->find ( array (
  13364. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13365. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13366. 'groupby' => 'item,Month(pastDate),itemCategory',
  13367. 'asArray' => true
  13368. ) );
  13369. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13370. // statistics html
  13371. $stList = $statistics->getOne ( array (
  13372. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13373. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13374. 'groupby' => 'Month(date)',
  13375. 'asArray' => true
  13376. ) );
  13377. if (empty ( $stList ))
  13378. $stList = array (
  13379. 'rePrice' => 0,
  13380. 'agPrice' => 0
  13381. );
  13382. $data ['stList'] = array (
  13383. 'rePrice' => $stList ['rePrice'],
  13384. 'agPrice' => $stList ['agPrice'],
  13385. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13386. );
  13387. $monthHtml = "";
  13388. for($i = 1; $i <= 12; $i ++) {
  13389. if ($i == $month)
  13390. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13391. else
  13392. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13393. }
  13394. $data ['monthHtml'] = $monthHtml;
  13395. $data ['year'] = $year;
  13396. $data ['month'] = $month;
  13397. $data ['nature'] = $nature;
  13398. $data ['aiList'] = $aiList;
  13399. $data ['memu'] = "receipt";
  13400. $data ['staff'] = $this->staff;
  13401. $data ['receiptMemu'] = 'companyCategoryCollect';
  13402. $data ['verifyId'] = $this->verifyId;
  13403. $data ['executeId'] = $this->executeId;
  13404. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13405. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13406. }
  13407. function staffCollectMonthDetail2() {
  13408. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13409. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13410. if (! $year)
  13411. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13412. if (! $month)
  13413. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13414. Doo::loadModel ( 'staff' );
  13415. $staff = new staff ();
  13416. Doo::loadModel ( "receiptDetail" );
  13417. $receiptDetail = new receiptDetail ();
  13418. Doo::loadModel ( 'accountItem' );
  13419. $accountItem = new accountItem ();
  13420. Doo::loadModel ( 'statistics' );
  13421. $statistics = new statistics ();
  13422. Doo::loadModel ( 'L_category' );
  13423. $lCategory = new L_category ();
  13424. $staffList = $staff->find ( array (
  13425. 'where' => 'username!="admin"',
  13426. 'asArray' => true
  13427. ) );
  13428. $categoryList = $staff->find ( array (
  13429. 'select' => 'COUNT(*) as count,cid,category',
  13430. 'where' => 'username !="admin"',
  13431. 'groupby' => 'cid',
  13432. 'asArray' => true
  13433. ) );
  13434. $list = array ();
  13435. foreach ( $categoryList as $vlu ) {
  13436. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13437. $r1 = 0;
  13438. $r2 = 0;
  13439. $r3 = 0;
  13440. $r4 = 0;
  13441. $r5 = 0;
  13442. $r6 = 0;
  13443. $r7 = 0;
  13444. $r8 = 0;
  13445. $r9 = 0;
  13446. $r10 = 0;
  13447. $r11 = 0;
  13448. $r12 = 0;
  13449. $r13 = 0;
  13450. $r14 = 0;
  13451. $r15 = 0;
  13452. $c1 = 0;
  13453. $c2 = 0;
  13454. $c3 = 0;
  13455. $c4 = 0;
  13456. $c5 = 0;
  13457. $c6 = 0;
  13458. $p1 = 0;
  13459. $p2 = 0;
  13460. $p3 = 0;
  13461. $p4 = 0;
  13462. $p5 = 0;
  13463. $p6 = 0;
  13464. $p7 = 0;
  13465. $p8 = 0;
  13466. $p9 = 0;
  13467. $t1 = 0;
  13468. $t2 = 0;
  13469. $t3 = 0;
  13470. $t4 = 0;
  13471. $t5 = 0;
  13472. $s1 = 0;
  13473. $m1 = 0;
  13474. foreach ( $staffList as $value ) {
  13475. if ($vlu ['cid'] == $value ['cid']) {
  13476. $receiptCollectList = $receiptDetail->find ( array (
  13477. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13478. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13479. 'groupby' => 'item,Month(date),itemCategory',
  13480. 'asArray' => true
  13481. ) );
  13482. if (! empty ( $receiptCollectList )) {
  13483. $receiptL = array (
  13484. '日常相关费用' => array (),
  13485. '差旅相关费用' => array (),
  13486. '培训班费用' => array (),
  13487. '其他' => array ()
  13488. );
  13489. $html = "";
  13490. $psum = 0;
  13491. $item = array (
  13492. '市内交通费',
  13493. '市内出租费',
  13494. '办事处房租',
  13495. '电话费',
  13496. '水费',
  13497. '电费',
  13498. '办公费用',
  13499. '邮寄费',
  13500. '其他费用',
  13501. '车辆费用',
  13502. '广告费',
  13503. '团队建设费',
  13504. '物业管理费',
  13505. '宽带费'
  13506. );
  13507. foreach ( $item as $va ) {
  13508. $falg = true;
  13509. foreach ( $receiptCollectList as $v ) {
  13510. if ($v ['itemCategory'] == '日常相关费用') {
  13511. if ($v ['item'] == $va) {
  13512. if ($va == '市内交通费')
  13513. $r1 += $v ['price'];
  13514. if ($va == '市内出租费')
  13515. $r2 += $v ['price'];
  13516. if ($va == '办事处房租')
  13517. $r3 += $v ['price'];
  13518. if ($va == '电话费')
  13519. $r4 += $v ['price'];
  13520. if ($va == '水费')
  13521. $r5 += $v ['price'];
  13522. if ($va == '电费')
  13523. $r6 += $v ['price'];
  13524. if ($va == '办公费用')
  13525. $r7 += $v ['price'];
  13526. if ($va == '邮寄费')
  13527. $r8 += $v ['price'];
  13528. if ($va == '其他费用')
  13529. $r9 += $v ['price'];
  13530. if ($va == '车辆费用')
  13531. $r10 += $v ['price'];
  13532. if ($va == '广告费')
  13533. $r11 += $v ['price'];
  13534. if ($va == '团队建设费')
  13535. $r13 += $v ['price'];
  13536. if ($va == '物业管理费')
  13537. $r14 += $v ['price'];
  13538. if ($va == '宽带费')
  13539. $r15 += $v ['price'];
  13540. $psum += $v ['price'];
  13541. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13542. $falg = false;
  13543. break;
  13544. }
  13545. }
  13546. }
  13547. if ($falg)
  13548. $html .= '<td class="taR">-</td>';
  13549. }
  13550. $r12 += $psum;
  13551. if (! empty ( $psum ))
  13552. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13553. else
  13554. $psum = '<td class="colGreen taR">-</td>';
  13555. $receiptL ['日常相关费用'] = $psum . $html;
  13556. /* ----------------------------------- */
  13557. $html = "";
  13558. $psum = 0;
  13559. $item = array (
  13560. '往来交通费',
  13561. '市内交通费',
  13562. '出差住宿费',
  13563. '出差补助',
  13564. '其他费用'
  13565. );
  13566. foreach ( $item as $va ) {
  13567. $falg = true;
  13568. foreach ( $receiptCollectList as $v ) {
  13569. if ($v ['itemCategory'] == '差旅相关费用') {
  13570. if ($v ['item'] == $va) {
  13571. if ($va == '往来交通费')
  13572. $c1 += $v ['price'];
  13573. if ($va == '市内交通费')
  13574. $c2 += $v ['price'];
  13575. if ($va == '出差住宿费')
  13576. $c3 += $v ['price'];
  13577. if ($va == '出差补助')
  13578. $c4 += $v ['price'];
  13579. if ($va == '其他费用')
  13580. $c5 += $v ['price'];
  13581. $psum += $v ['price'];
  13582. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13583. $falg = false;
  13584. break;
  13585. }
  13586. }
  13587. }
  13588. if ($falg)
  13589. $html .= '<td class="taR">-</td>';
  13590. }
  13591. $c6 += $psum;
  13592. if (! empty ( $psum ))
  13593. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13594. else
  13595. $psum = '<td class="colGreen taR">-</td>';
  13596. $receiptL ['差旅相关费用'] = $psum . $html;
  13597. /* ------------------------------------- */
  13598. $html = "";
  13599. $psum = 0;
  13600. $item = array (
  13601. '场租费',
  13602. '薪酬',
  13603. '住宿费',
  13604. '交通费',
  13605. '餐饮费',
  13606. '办公费',
  13607. '公关费',
  13608. '其他'
  13609. );
  13610. foreach ( $item as $va ) {
  13611. $falg = true;
  13612. foreach ( $receiptCollectList as $v ) {
  13613. if ($v ['itemCategory'] == '培训班费用') {
  13614. if ($v ['item'] == $va) {
  13615. if ($va == '场租费')
  13616. $p1 += $v ['price'];
  13617. if ($va == '薪酬')
  13618. $p2 += $v ['price'];
  13619. if ($va == '住宿费')
  13620. $p3 += $v ['price'];
  13621. if ($va == '交通费')
  13622. $p4 += $v ['price'];
  13623. if ($va == '餐饮费')
  13624. $p5 += $v ['price'];
  13625. if ($va == '办公费')
  13626. $p6 += $v ['price'];
  13627. if ($va == '公关费')
  13628. $p7 += $v ['price'];
  13629. if ($va == '其他')
  13630. $p8 += $v ['price'];
  13631. $psum += $v ['price'];
  13632. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13633. $falg = false;
  13634. break;
  13635. }
  13636. }
  13637. }
  13638. if ($falg)
  13639. $html .= '<td class="taR">-</td>';
  13640. }
  13641. $p9 += $psum;
  13642. if (! empty ( $psum ))
  13643. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13644. else
  13645. $psum = '<td class="colGreen taR">-</td>';
  13646. $receiptL ['培训班费用'] = $psum . $html;
  13647. /* ------------------------------------- */
  13648. $html = "";
  13649. $psum = 0;
  13650. $item = array (
  13651. '公关费',
  13652. '广告费',
  13653. '借款',
  13654. '可自加费用'
  13655. );
  13656. foreach ( $item as $va ) {
  13657. $falg = true;
  13658. foreach ( $receiptCollectList as $v ) {
  13659. if ($v ['itemCategory'] == '其他') {
  13660. if ($v ['item'] == $va) {
  13661. if ($va == '公关费')
  13662. $t1 += $v ['price'];
  13663. if ($va == '广告费')
  13664. $t2 += $v ['price'];
  13665. if ($va == '借款')
  13666. $t3 += $v ['price'];
  13667. if ($va == '可自加费用')
  13668. $t4 += $v ['price'];
  13669. $psum += $v ['price'];
  13670. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13671. $falg = false;
  13672. break;
  13673. }
  13674. }
  13675. }
  13676. if ($falg)
  13677. $html .= '<td class="taR">-</td>';
  13678. }
  13679. $t5 += $psum;
  13680. if (! empty ( $psum ))
  13681. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13682. else
  13683. $psum = '<td class="colGreen taR">-</td>';
  13684. $receiptL ['其他'] = $psum . $html;
  13685. /* ------------------------------------- */
  13686. $html = "";
  13687. $psum = 0;
  13688. foreach ( $receiptCollectList as $v ) {
  13689. if ($v ['itemCategory'] == '报销金额调整') {
  13690. if (! empty ( $v ['price'] )) {
  13691. $psum += $v ['price'];
  13692. }
  13693. }
  13694. }
  13695. $s1 += $psum;
  13696. if (! empty ( $psum ))
  13697. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13698. else
  13699. $psum = '<td class="taR colOrange">-</td>';
  13700. $receiptL ['报销金额调整'] = $psum . $html;
  13701. } else {
  13702. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13703. <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>';
  13704. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13705. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13706. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13707. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13708. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13709. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13710. }
  13711. $monthStaffPrice = $receiptDetail->find ( array (
  13712. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13713. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13714. 'asArray' => true
  13715. ) );
  13716. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13717. $m1 += $monthStaffPrice [0] ['price'];
  13718. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13719. } else
  13720. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13721. $list [$value ['username']] = $receiptL;
  13722. }
  13723. }
  13724. $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>
  13725. <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>
  13726. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13727. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13728. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13729. $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>
  13730. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13731. $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>';
  13732. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13733. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13734. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13735. }
  13736. $data ['list'] = $list;
  13737. $receiptCollectList = $receiptDetail->find ( array (
  13738. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13739. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13740. 'groupby' => 'item,Month(date),itemCategory',
  13741. 'asArray' => true
  13742. ) );
  13743. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13744. // statistics html
  13745. $stList = $statistics->getOne ( array (
  13746. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13747. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13748. 'groupby' => 'Month(date)',
  13749. 'asArray' => true
  13750. ) );
  13751. if (empty ( $stList ))
  13752. $stList = array (
  13753. 'rePrice' => 0,
  13754. 'agPrice' => 0
  13755. );
  13756. $data ['stList'] = array (
  13757. 'rePrice' => $stList ['rePrice'],
  13758. 'agPrice' => $stList ['agPrice'],
  13759. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13760. );
  13761. $monthHtml = "";
  13762. for($i = 1; $i <= 12; $i ++) {
  13763. if ($i == $month)
  13764. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13765. else
  13766. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13767. }
  13768. $data ['monthHtml'] = $monthHtml;
  13769. $data ['year'] = $year;
  13770. $data ['month'] = $month;
  13771. $data ['memu'] = "receipt";
  13772. $data ['staff'] = $this->staff;
  13773. $data ['receiptMemu'] = 'companyCategoryCollect';
  13774. $data ['verifyId'] = $this->verifyId;
  13775. $data ['executeId'] = $this->executeId;
  13776. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13777. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13778. }
  13779. /**
  13780. * 用户报销单列表
  13781. */
  13782. function receiptStatisticsStaffDetail() {
  13783. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13784. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13785. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13786. Doo::loadModel ( "receipt" );
  13787. $receipt = new receipt ();
  13788. Doo::loadModel ( "receiptDetail" );
  13789. $receiptDetail = new receiptDetail ();
  13790. Doo::loadModel ( 'staff' );
  13791. $staff = new staff ();
  13792. Doo::loadModel ( 'accountItem' );
  13793. $accountItem = new accountItem ();
  13794. Doo::loadModel ( 'statistics' );
  13795. $statistics = new statistics ();
  13796. if (! empty ( $username )) {
  13797. $username = addslashes ( urldecode ( $username ) );
  13798. $staffDetail = $staff->getStaffByName ( $username );
  13799. if (empty ( $staffDetail ))
  13800. die ( 'illegal request' );
  13801. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13802. $itemList = $accountItem->getAccountItem ();
  13803. $itemHtml = '';
  13804. $categoryHtml = '';
  13805. $itemKeyList = array_keys ( $itemList );
  13806. $revisePrice = 0;
  13807. // 报销单内容详情
  13808. foreach ( $list as $key => $value ) {
  13809. $accountItemList = json_decode ( $value ['accountItem'], true );
  13810. $list [$key] ['accountItemList'] = $accountItemList;
  13811. $receiptItemHtml = '';
  13812. foreach ( $itemKeyList as $v ) {
  13813. if ($v == '日常相关费用')
  13814. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13815. elseif ($v == '差旅相关费用')
  13816. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13817. elseif ($v == '培训班费用')
  13818. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13819. elseif ($v == '内部培训费用'){
  13820. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13821. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13822. }else{
  13823. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13824. }
  13825. }elseif ($v == '其他')
  13826. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13827. foreach ( $itemList [$v] as $ke => $va ) {
  13828. $falg = true;
  13829. if (! empty ( $accountItemList [$v] )) {
  13830. foreach ( $accountItemList [$v] as $ve ) {
  13831. if ($va ['name'] == $ve ['name']) {
  13832. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13833. $falg = false;
  13834. break;
  13835. }
  13836. }
  13837. }
  13838. if ($falg)
  13839. $receiptItemHtml .= '<td class="taR"></td>';
  13840. }
  13841. }
  13842. // 金额调整和费用查看
  13843. $revisePrice += $value ['revisePrice'];
  13844. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13845. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13846. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13847. }
  13848. // 报销单合计
  13849. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13850. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13851. $receiptTotalHtml = '';
  13852. // 报销单项目抬头
  13853. foreach ( $itemKeyList as $value ) {
  13854. $count = count ( $itemList [$value] ) + 1;
  13855. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13856. $categoryHtml .= '<th class="taC">合计</th>';
  13857. $sumfalg=true;
  13858. foreach ( $rtl as $rtlValue ) {
  13859. if ($rtlValue ['itemCategory'] == $value) {
  13860. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13861. $sumfalg=false;
  13862. break;
  13863. }
  13864. }
  13865. if ($sumfalg)
  13866. $receiptTotalHtml .= '<th></th>';
  13867. foreach ( $itemList [$value] as $k => $v ) {
  13868. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13869. // 合计
  13870. $falg = true;
  13871. foreach ( $receiptTotalList as $ve ) {
  13872. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13873. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13874. $falg = false;
  13875. break;
  13876. }
  13877. }
  13878. if ($falg)
  13879. $receiptTotalHtml .= '<th></th>';
  13880. }
  13881. }
  13882. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13883. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13884. if (empty ( $stList ))
  13885. $stList = array (
  13886. 'rePrice' => 0,
  13887. 'agPrice' => 0
  13888. );
  13889. $data ['stList'] = array (
  13890. 'rePrice' => $stList ['rePrice'],
  13891. 'agPrice' => $stList ['agPrice'],
  13892. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13893. );
  13894. $monthHtml = "";
  13895. for($i = 1; $i <= 12; $i ++) {
  13896. if ($i == $month)
  13897. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13898. else
  13899. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13900. }
  13901. $data ['username'] = urlencode ( $username );
  13902. $data ['usernameEN'] = $username;
  13903. $data ['monthHtml'] = $monthHtml;
  13904. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13905. $data ['list'] = $list;
  13906. $data ['categoryHtml'] = $categoryHtml;
  13907. $data ['itemHtml'] = $itemHtml;
  13908. $data ['itemList'] = $itemList;
  13909. $data ['year'] = $year;
  13910. $data ['month'] = $month;
  13911. $data ['memu'] = "receipt";
  13912. $data ['staff'] = $this->staff;
  13913. $data ['receiptMemu'] = 'companyCategoryCollect';
  13914. $data ['verifyId'] = $this->verifyId;
  13915. $data ['executeId'] = $this->executeId;
  13916. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13917. }
  13918. die ( 'illegal request' );
  13919. }
  13920. function companyMonthCollectDetail() {
  13921. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13922. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13923. if (! $year)
  13924. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13925. if (! $month)
  13926. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13927. Doo::loadModel ( 'staff' );
  13928. $staff = new staff ();
  13929. Doo::loadModel ( "receiptDetail" );
  13930. $receiptDetail = new receiptDetail ();
  13931. Doo::loadModel ( 'accountItem' );
  13932. $accountItem = new accountItem ();
  13933. Doo::loadModel ( 'statistics' );
  13934. $statistics = new statistics ();
  13935. Doo::loadModel ( 'L_category' );
  13936. $lCategory = new L_category ();
  13937. $staffList = $staff->find ( array (
  13938. 'where' => 'username!="admin"',
  13939. 'asArray' => true
  13940. ) );
  13941. $categoryList = $lCategory->find ( array (
  13942. 'asArray' => true
  13943. ) );
  13944. $aiList=$accountItem->getAccountItem();
  13945. $list = array ();
  13946. foreach ( $categoryList as $value ) {
  13947. $receiptCollectList = $receiptDetail->find ( array (
  13948. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13949. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13950. 'groupby' => 'item,Month(pastDate),itemCategory',
  13951. 'asArray' => true
  13952. ) );
  13953. if (! empty ( $receiptCollectList )) {
  13954. $receiptL = array (
  13955. '日常相关费用' => array (),
  13956. '差旅相关费用' => array (),
  13957. '内部培训费用' => array (),
  13958. '培训班费用' => array (),
  13959. '其他' => array ()
  13960. );
  13961. $html = "";
  13962. $psum = 0;
  13963. foreach ( $aiList[$this->AGENCY] as $va ) {
  13964. $falg = true;
  13965. foreach ( $receiptCollectList as $v ) {
  13966. if ($v ['itemCategory'] == $this->AGENCY) {
  13967. if ($v ['item'] == $va['name']) {
  13968. $psum += $v ['price'];
  13969. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13970. $falg = false;
  13971. break;
  13972. }
  13973. }
  13974. }
  13975. if ($falg)
  13976. $html .= '<td class="taR">-</td>';
  13977. }
  13978. if (! empty ( $psum ))
  13979. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13980. else
  13981. $psum = '<td class="colGreen taR">-</td>';
  13982. $receiptL [$this->AGENCY] = $psum . $html;
  13983. /* ----------------------------------- */
  13984. $html = "";
  13985. $psum = 0;
  13986. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13987. $falg = true;
  13988. foreach ( $receiptCollectList as $v ) {
  13989. if ($v ['itemCategory'] == $this->TRAVEL) {
  13990. if ($v ['item'] == $va['name']) {
  13991. $psum += $v ['price'];
  13992. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13993. $falg = false;
  13994. break;
  13995. }
  13996. }
  13997. }
  13998. if ($falg)
  13999. $html .= '<td class="taR">-</td>';
  14000. }
  14001. if (! empty ( $psum ))
  14002. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14003. else
  14004. $psum = '<td class="colGreen taR">-</td>';
  14005. $receiptL [$this->TRAVEL] = $psum . $html;
  14006. /* ------------------------------------- */
  14007. $html = "";
  14008. $psum = 0;
  14009. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14010. $falg = true;
  14011. foreach ( $receiptCollectList as $v ) {
  14012. if ($v ['itemCategory'] == $this->INTTRAIN) {
  14013. if ($v ['item'] == $va['name']) {
  14014. $psum += $v ['price'];
  14015. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14016. $falg = false;
  14017. break;
  14018. }
  14019. }
  14020. }
  14021. if ($falg)
  14022. $html .= '<td class="taR">-</td>';
  14023. }
  14024. if (! empty ( $psum ))
  14025. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14026. else
  14027. $psum = '<td class="colGreen taR">-</td>';
  14028. $receiptL [$this->INTTRAIN] = $psum . $html;
  14029. /* ------------------------------------- */
  14030. $html = "";
  14031. $psum = 0;
  14032. foreach ( $aiList[$this->TRAIN] as $va ) {
  14033. $falg = true;
  14034. foreach ( $receiptCollectList as $v ) {
  14035. if ($v ['itemCategory'] == $this->TRAIN) {
  14036. if ($v ['item'] == $va['name']) {
  14037. $psum += $v ['price'];
  14038. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14039. $falg = false;
  14040. break;
  14041. }
  14042. }
  14043. }
  14044. if ($falg)
  14045. $html .= '<td class="taR">-</td>';
  14046. }
  14047. if (! empty ( $psum ))
  14048. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14049. else
  14050. $psum = '<td class="colGreen taR">-</td>';
  14051. $receiptL [$this->TRAIN] = $psum . $html;
  14052. /* ------------------------------------- */
  14053. $html = "";
  14054. $psum = 0;
  14055. foreach ( $aiList[$this->OTHER] as $va ) {
  14056. $falg = true;
  14057. foreach ( $receiptCollectList as $v ) {
  14058. if ($v ['itemCategory'] == $this->OTHER) {
  14059. if ($v ['item'] == $va['name']) {
  14060. $psum += $v ['price'];
  14061. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14062. $falg = false;
  14063. break;
  14064. }
  14065. }
  14066. }
  14067. if ($falg)
  14068. $html .= '<td class="taR">-</td>';
  14069. }
  14070. if (! empty ( $psum ))
  14071. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14072. else
  14073. $psum = '<td class="colGreen taR">-</td>';
  14074. $receiptL [$this->OTHER] = $psum . $html;
  14075. /* ------------------------------------- */
  14076. $html = "";
  14077. $psum = 0;
  14078. foreach ( $receiptCollectList as $v ) {
  14079. if ($v ['itemCategory'] == '报销金额调整') {
  14080. if (! empty ( $v ['price'] ))
  14081. $psum += $v ['price'];
  14082. }
  14083. }
  14084. if (! empty ( $psum ))
  14085. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14086. else
  14087. $psum = '<td class="taR colOrange">-</td>';
  14088. $receiptL ['报销金额调整'] = $psum . $html;
  14089. } else {
  14090. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14091. foreach ( $aiList[$this->AGENCY] as $va ) {
  14092. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14093. }
  14094. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14095. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14096. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14097. }
  14098. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14099. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14100. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14101. }
  14102. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14103. foreach ( $aiList[$this->TRAIN] as $va ) {
  14104. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14105. }
  14106. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14107. foreach ( $aiList[$this->OTHER] as $va ) {
  14108. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14109. }
  14110. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14111. }
  14112. $monthStaffPrice = $receiptDetail->find ( array (
  14113. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14114. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14115. 'asArray' => true
  14116. ) );
  14117. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14118. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14119. else
  14120. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14121. $list [$value ['title']] = $receiptL;
  14122. }
  14123. $data ['list'] = $list;
  14124. $receiptCollectList = $receiptDetail->find ( array (
  14125. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14126. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14127. 'groupby' => 'item,Month(pastDate),itemCategory',
  14128. 'asArray' => true
  14129. ) );
  14130. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14131. //print_r($data['monthPriceHtml']);
  14132. // foreach ($data['monthPriceHtml'] as $value){
  14133. // echo $value;
  14134. // }
  14135. // die;
  14136. // statistics html
  14137. $stList = $statistics->getOne ( array (
  14138. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14139. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14140. 'groupby' => 'Month(date)',
  14141. 'asArray' => true
  14142. ) );
  14143. if (empty ( $stList ))
  14144. $stList = array (
  14145. 'rePrice' => 0,
  14146. 'agPrice' => 0
  14147. );
  14148. $data ['stList'] = array (
  14149. 'rePrice' => $stList ['rePrice'],
  14150. 'agPrice' => $stList ['agPrice'],
  14151. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14152. );
  14153. $monthHtml = "";
  14154. for($i = 1; $i <= 12; $i ++) {
  14155. if ($i == $month)
  14156. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14157. else
  14158. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14159. }
  14160. $data ['aiList'] = $aiList;
  14161. $dateHtml = "";
  14162. $now = date ( "Y" );
  14163. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14164. if ($YEARD <= $now) {
  14165. $dateHtml .= '<option ';
  14166. if ($year == $YEARD) {
  14167. $dateHtml .= 'selected ';
  14168. }
  14169. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14170. }
  14171. }
  14172. $data ['dateHtml'] = $dateHtml;
  14173. $data ['monthHtml'] = $monthHtml;
  14174. $data ['year'] = $year;
  14175. $data ['month'] = $month;
  14176. $data ['memu'] = "receipt";
  14177. $data ['staff'] = $this->staff;
  14178. $data ['receiptMemu'] = 'companyCategoryCollect';
  14179. $data ['verifyId'] = $this->verifyId;
  14180. $data ['executeId'] = $this->executeId;
  14181. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14182. }
  14183. function staffCollectDetail() {
  14184. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14185. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14186. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14187. if (! $staffname) {
  14188. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14189. $staffname = urldecode ( $staffname );
  14190. }
  14191. Doo::loadModel ( 'staff' );
  14192. $staff = new staff ();
  14193. Doo::loadModel ( "receiptDetail" );
  14194. $receiptDetail = new receiptDetail ();
  14195. Doo::loadModel ( 'accountItem' );
  14196. $accountItem = new accountItem ();
  14197. Doo::loadModel ( 'statistics' );
  14198. $statistics = new statistics ();
  14199. Doo::loadModel ( 'L_category' );
  14200. $lCategory = new L_category ();
  14201. Doo::loadModel ( "receiptAuthorityManage" );
  14202. $receiptAuthorityManage = new receiptAuthorityManage ();
  14203. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14204. $cidList = array ();
  14205. foreach ( $imcStaff as $key => $value ) {
  14206. array_push ( $cidList, $value ['cid'] );
  14207. }
  14208. $cidString = implode ( ',', $cidList );
  14209. $staffList = $staff->find ( array (
  14210. 'where' => ' cid in (' . $cidString . ')',
  14211. 'asArray' => true
  14212. ) );
  14213. $stHtml = '';
  14214. $stTitle = "";
  14215. $staffId = 0;
  14216. $cid = 0;
  14217. $ocid = 0;
  14218. foreach ( $staffList as $value ) {
  14219. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14220. $stTitle = $value ['category'] . '-' . $value ['username'];
  14221. $staffId = $value ['sid'];
  14222. $cid = $value ['cid'];
  14223. $ocid = $value ['cid'];
  14224. if (! empty ( $value ['othercid'] ))
  14225. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14226. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14227. } elseif ($value ['username'] != 'admin')
  14228. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14229. }
  14230. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14231. 'where' => 'cid in(' . $cid . ')',
  14232. 'asArray' => true
  14233. ) );
  14234. if (empty ( $pcid ))
  14235. $pcid = $ocid;
  14236. $data ['ocid'] = $pcid;
  14237. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14238. $this->showCache ( $path );
  14239. //
  14240. $receiptCollectList = $receiptDetail->find ( array (
  14241. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14242. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14243. 'groupby' => 'item,Month(pastDate),itemCategory',
  14244. 'asArray' => true
  14245. ) );
  14246. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14247. // print_r($receiptCollectList);
  14248. $accountList = $accountItem->find ( array (
  14249. 'asArray' => true
  14250. ) );
  14251. // create CollectDetail HTML
  14252. $collectHtml = array ();
  14253. foreach ( $accountList as $key => $value ) {
  14254. $html = "";
  14255. $asum = 0;
  14256. for($i = 1; $i <= 12; $i ++) {
  14257. $falg = true;
  14258. foreach ( $receiptCollectList as $v ) {
  14259. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14260. if ($v ['item'] == '可自加费用') {
  14261. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14262. }
  14263. $asum += $v ['price'];
  14264. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14265. $falg = false;
  14266. break;
  14267. }
  14268. }
  14269. if ($falg)
  14270. $html .= '<td class="taR">-</td>';
  14271. }
  14272. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14273. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14274. }
  14275. $data ['collectHtml'] = $collectHtml;
  14276. // print_r($collectHtml);
  14277. // create Adjustment price html
  14278. $receiptCollectList = $receiptDetail->find ( array (
  14279. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14280. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14281. 'groupby' => 'itemCategory,Month(pastDate)',
  14282. 'asArray' => true
  14283. ) );
  14284. $adjustment = array ();
  14285. $collectArray = array (
  14286. '日常相关费用' => array (),
  14287. '差旅相关费用' => array (),
  14288. '培训班费用' => array (),
  14289. '内部培训费用'=>array(),
  14290. '其他' => array ()
  14291. );
  14292. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14293. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14294. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14295. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14296. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14297. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14298. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14299. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14300. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14301. array_push ( $collectArray ['其他'], $collectHtml );
  14302. $data ['collectArray'] = $collectArray;
  14303. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14304. array_push ( $adjustment, $collectHtml );
  14305. $data ['adjustment'] = $adjustment;
  14306. // total price html
  14307. $collectHtml = "";
  14308. $total = 0;
  14309. for($i = 1; $i <= 12; $i ++) {
  14310. $sumPrice = 0;
  14311. foreach ( $receiptCollectList as $key => $value ) {
  14312. if ($value ['month'] == $i) {
  14313. $sumPrice += $value ['price'];
  14314. }
  14315. }
  14316. if ($sumPrice == 0)
  14317. $collectHtml .= '<td class="taR">-</td>';
  14318. else
  14319. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14320. $total += $sumPrice;
  14321. }
  14322. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14323. // statistics html
  14324. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14325. if (empty ( $stList ))
  14326. $stList = array (
  14327. 'rePrice' => 0,
  14328. 'agPrice' => 0
  14329. );
  14330. $data ['stList'] = array (
  14331. 'rePrice' => $stList ['rePrice'],
  14332. 'agPrice' => $stList ['agPrice'],
  14333. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14334. );
  14335. $data ['totalPrice'] = $collectHtml;
  14336. $data ['totalYear'] = $total;
  14337. $data ['stHtml'] = $stHtml;
  14338. $data ['year'] = $year;
  14339. $data ['stTitle'] = $stTitle;
  14340. $data ['staffname'] = urlencode ( $staffname );
  14341. $data ['memu'] = "receipt";
  14342. $data ['staff'] = $this->staff;
  14343. $data ['receiptMemu'] = 'companyCategoryCollect';
  14344. $data ['verifyId'] = $this->verifyId;
  14345. $data ['executeId'] = $this->executeId;
  14346. if ($year < date ( "Y" )) {
  14347. Doo::loadModel ( 'receipt' );
  14348. $receipt = new receipt ();
  14349. $receiptList = $receipt->find ( array (
  14350. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14351. 'asArray' => true
  14352. ) );
  14353. if (empty ( $receiptList )) { // generated files
  14354. ob_start ();
  14355. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14356. $this->cacheFile ( $path );
  14357. die ();
  14358. }
  14359. }
  14360. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14361. }
  14362. function BUGFLAG() {
  14363. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14364. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14365. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14366. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14367. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14368. if (empty ( $status ))
  14369. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14370. $page_size = 12;
  14371. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14372. $vidList = array ();
  14373. $button = 0;
  14374. Doo::loadModel ( 'verify' );
  14375. $verify = new verify ();
  14376. Doo::loadModel ( 'receipt' );
  14377. $receipt = new receipt ();
  14378. Doo::loadModel ( 'staff' );
  14379. $staff = new staff ();
  14380. Doo::loadModel ( 'L_category' );
  14381. $Lcategory = new L_category ();
  14382. $dateCondition = " and Year(date) =" . $year;
  14383. if (! empty ( $month ))
  14384. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14385. $categoryList = $Lcategory->find ( array (
  14386. 'asArray' => true
  14387. ) );
  14388. $staffList = $staff->find ( array (
  14389. 'where' => 'cid=' . $cid,
  14390. 'asArray' => true
  14391. ) );
  14392. $cateCondition = "";
  14393. $staffCondition = "";
  14394. $approvalCondition = "";
  14395. if (! empty ( $cid ))
  14396. $cateCondition = ' and cid=' . $cid;
  14397. if (! empty ( $sid )) {
  14398. $staffCondition = ' and staff=' . $sid;
  14399. $cateCondition = "";
  14400. }
  14401. $approvalCondition = " and status=" . $status;
  14402. if ($status == 2) {
  14403. // 查找角色审批人
  14404. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14405. }
  14406. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14407. $approvalCondition = ' and status=2 ';
  14408. }
  14409. if ($status == 1) {
  14410. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14411. }
  14412. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14413. $pageinfo ['page'] = array (
  14414. 'previous' => ''
  14415. );
  14416. if ($status == 0) {
  14417. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14418. $receiptList = $receipt->find ( array (
  14419. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14420. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14421. 'desc' => 'rid',
  14422. 'asArray' => true
  14423. ) );
  14424. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14425. } else
  14426. $receiptList = $receipt->find ( array (
  14427. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14428. 'desc' => 'rid',
  14429. 'asArray' => true
  14430. ) );
  14431. $rLRes = $receipt->find ( array (
  14432. '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,
  14433. 'desc' => 'rid',
  14434. 'asArray' => true
  14435. ) );
  14436. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14437. // print_r($pageinfo);
  14438. $Locate = 0;
  14439. foreach ( $receiptList as $key => $value ) {
  14440. $receiptList [$key] ['Locate'] = $Locate;
  14441. $Locate ++;
  14442. $receiptList [$key] ['reviseDetail'] = array ();
  14443. if (! empty ( $value ['reviseDetail'] ))
  14444. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14445. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14446. $categoryDetil = $Lcategory->getOne ( array (
  14447. 'where' => 'cid=' . $value ['cid'],
  14448. 'asArray' => true
  14449. ) );
  14450. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14451. $verifyList = $verify->getOne ( array (
  14452. 'where' => 'vid=' . $value ['verify'],
  14453. 'asArray' => true
  14454. ) );
  14455. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14456. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14457. foreach ( $verifyList as $k => $v ) {
  14458. // init verifyStaff
  14459. $verifyList [$k] ['date'] = "";
  14460. $verifyList [$k] ['opinion'] = "";
  14461. $verifyList [$k] ['status'] = "";
  14462. if (empty ( $verifyStaff )) {
  14463. $verifyList [$k] ['date'] = "";
  14464. $verifyList [$k] ['opinion'] = "";
  14465. if ($v [0] == $this->staff [0] ['sid']) {
  14466. $verifyList [$k] ['status'] = 4;
  14467. $button = 4;
  14468. }
  14469. } else {
  14470. $flag = true;
  14471. foreach ( $verifyStaff as $m => $u ) {
  14472. if ($v [0] == $m) {
  14473. $verifyList [$k] ['date'] = $u ['date'];
  14474. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14475. $verifyList [$k] ['status'] = $u ['status'];
  14476. $flag = false;
  14477. break;
  14478. }
  14479. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14480. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14481. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14482. }
  14483. if ($flag) { // 检测可编辑
  14484. if ($v [0] == $this->staff [0] ['sid']) {
  14485. $verifyList [$k] ['status'] = 4;
  14486. $button = 4;
  14487. }
  14488. }
  14489. }
  14490. }
  14491. $receiptList [$key] ['verifyList'] = $verifyList;
  14492. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14493. 'where' => 'sid=' . $value ['staff'],
  14494. 'asArray' => true
  14495. ) );
  14496. $receiptList [$key] ['button'] = $button;
  14497. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14498. }
  14499. // print_r($receiptList);die;
  14500. // $data['verifyDetail']=$verifyDetail;
  14501. $mothHtml = "";
  14502. for($i = 1; $i <= 12; $i ++) {
  14503. if ($month == $i)
  14504. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14505. else
  14506. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14507. }
  14508. $data ['mothHtml'] = $mothHtml;
  14509. $data ['page'] = $pageinfo;
  14510. $data ['receiptList'] = $receiptList;
  14511. $data ['receiptApprovalCount'] = count ( $rLRes );
  14512. $data ['status'] = $status;
  14513. $data ['year'] = $year;
  14514. $data ['categoryList'] = $categoryList;
  14515. $data ['staffList'] = $staffList;
  14516. $data ['cid'] = $cid;
  14517. $data ['sid'] = $sid;
  14518. // print_r($receiptList);
  14519. $data ['memu'] = "receipt";
  14520. $data ['staff'] = $this->staff;
  14521. $data ['receiptMemu'] = 'approvalExpenses';
  14522. $data ['verifyId'] = $this->verifyId;
  14523. $data ['executeId'] = $this->executeId;
  14524. $this->render ( "/admin/FALG", $data );
  14525. }
  14526. function ajaxGetReceiptOrder() {
  14527. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14528. if (! empty ( $receiptOrder )) {
  14529. Doo::loadModel ( 'receipt' );
  14530. $receipt = new receipt ();
  14531. Doo::loadModel ( 'staff' );
  14532. $staff = new staff ();
  14533. $receiptInfo = $receipt->getOne ( array (
  14534. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14535. 'asArray' => true
  14536. ) );
  14537. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14538. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14539. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14540. </tbody></table><table class="table table table-bordered"><tbody>';
  14541. foreach ( $verifyStaff as $key => $value ) {
  14542. $staffInfo = $staff->getOne ( array (
  14543. 'select' => 'username',
  14544. 'where' => ' sid="' . $key . '"',
  14545. 'asArray' => true
  14546. ) );
  14547. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14548. }
  14549. $html .= '</tbody></table></div></div>';
  14550. echo json_encode ( array (
  14551. 'status' => 1,
  14552. 'receiptHtml' => $html
  14553. ) );
  14554. die ();
  14555. }
  14556. echo json_encode ( array (
  14557. 'status' => 2,
  14558. 'receiptHtml' => ''
  14559. ) );
  14560. die ();
  14561. }
  14562. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14563. if (! empty ( $receiptCollectList )) {
  14564. $receiptL = array (
  14565. '日常相关费用' => array (),
  14566. '差旅相关费用' => array (),
  14567. '内部培训费用'=>array(),
  14568. '培训班费用' => array (),
  14569. '其他' => array ()
  14570. );
  14571. $html = "";
  14572. $psum = 0;
  14573. foreach ( $aiList[$this->AGENCY] as $value ) {
  14574. $falg = true;
  14575. foreach ( $receiptCollectList as $v ) {
  14576. if ($v ['itemCategory'] == '日常相关费用') {
  14577. if ($v ['item'] == $value['name']) {
  14578. $psum += $v ['price'];
  14579. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14580. $falg = false;
  14581. break;
  14582. }
  14583. }
  14584. }
  14585. if ($falg)
  14586. $html .= '<td class="taR">-</td>';
  14587. }
  14588. if (! empty ( $psum ))
  14589. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14590. else
  14591. $psum = '<td class="colGreen taR">-</td>';
  14592. $receiptL ['日常相关费用'] = $psum . $html;
  14593. /* ----------------------------------- */
  14594. $html = "";
  14595. $psum = 0;
  14596. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14597. $falg = true;
  14598. foreach ( $receiptCollectList as $v ) {
  14599. if ($v ['itemCategory'] == '差旅相关费用') {
  14600. if ($v ['item'] == $value['name']) {
  14601. $psum += $v ['price'];
  14602. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14603. $falg = false;
  14604. break;
  14605. }
  14606. }
  14607. }
  14608. if ($falg)
  14609. $html .= '<td class="taR">-</td>';
  14610. }
  14611. if (! empty ( $psum ))
  14612. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14613. else
  14614. $psum = '<td class="colGreen taR">-</td>';
  14615. $receiptL ['差旅相关费用'] = $psum . $html;
  14616. /* ----------------------------------- */
  14617. $html = "";
  14618. $psum = 0;
  14619. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14620. $falg = true;
  14621. foreach ( $receiptCollectList as $v ) {
  14622. if ($v ['itemCategory'] == '内部培训费用') {
  14623. if ($v ['item'] == $value['name']) {
  14624. $psum += $v ['price'];
  14625. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14626. $falg = false;
  14627. break;
  14628. }
  14629. }
  14630. }
  14631. if ($falg)
  14632. $html .= '<td class="taR">-</td>';
  14633. }
  14634. if (! empty ( $psum ))
  14635. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14636. else
  14637. $psum = '<td class="colGreen taR">-</td>';
  14638. $receiptL ['内部培训费用'] = $psum . $html;
  14639. /* ------------------------------------- */
  14640. $html = "";
  14641. $psum = 0;
  14642. foreach ( $aiList[$this->TRAIN] as $value ) {
  14643. $falg = true;
  14644. foreach ( $receiptCollectList as $v ) {
  14645. if ($v ['itemCategory'] == '培训班费用') {
  14646. if ($v ['item'] == $value['name']) {
  14647. $psum += $v ['price'];
  14648. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14649. $falg = false;
  14650. break;
  14651. }
  14652. }
  14653. }
  14654. if ($falg)
  14655. $html .= '<td class="taR">-</td>';
  14656. }
  14657. if (! empty ( $psum ))
  14658. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14659. else
  14660. $psum = '<td class="colGreen taR">-</td>';
  14661. $receiptL ['培训班费用'] = $psum . $html;
  14662. /* ------------------------------------- */
  14663. $html = "";
  14664. $psum = 0;
  14665. foreach ( $aiList[$this->OTHER] as $value ) {
  14666. $falg = true;
  14667. foreach ( $receiptCollectList as $v ) {
  14668. if ($v ['itemCategory'] == '其他') {
  14669. if ($v ['item'] == $value['name']) {
  14670. $psum += $v ['price'];
  14671. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14672. $falg = false;
  14673. break;
  14674. }
  14675. }
  14676. }
  14677. if ($falg)
  14678. $html .= '<td class="taR">-</td>';
  14679. }
  14680. if (! empty ( $psum ))
  14681. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14682. else
  14683. $psum = '<td class="colGreen taR">-</td>';
  14684. $receiptL ['其他'] = $psum . $html;
  14685. /* ------------------------------------- */
  14686. $html = "";
  14687. $psum = 0;
  14688. foreach ( $receiptCollectList as $v ) {
  14689. if ($v ['itemCategory'] == '报销金额调整') {
  14690. if (! empty ( $v ['price'] ))
  14691. $psum += $v ['price'];
  14692. }
  14693. }
  14694. if (! empty ( $psum ))
  14695. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14696. else
  14697. $psum = '<td class="taR colOrange">-</td>';
  14698. $receiptL ['报销金额调整'] = $psum . $html;
  14699. } else {
  14700. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14701. foreach ( $aiList[$this->AGENCY] as $va ) {
  14702. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14703. }
  14704. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14705. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14706. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14707. }
  14708. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14709. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14710. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14711. }
  14712. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14713. foreach ( $aiList[$this->TRAIN] as $va ) {
  14714. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14715. }
  14716. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14717. foreach ( $aiList[$this->OTHER] as $va ) {
  14718. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14719. }
  14720. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14721. }
  14722. return $receiptL;
  14723. }
  14724. function eMail() {
  14725. Doo::loadModel ( 'staff' );
  14726. $staff = new staff ();
  14727. Doo::loadModel ( 'receipt' );
  14728. $receipt = new receipt ();
  14729. Doo::loadModel ( 'L_category' );
  14730. $Lcategory = new L_category ();
  14731. Doo::loadModel ( "verify" );
  14732. $verify = new verify ();
  14733. $staffList = $staff->find ( array (
  14734. 'asArray' => true
  14735. ) );
  14736. foreach ( $staffList as $key => $value ) {
  14737. if ($value ['username'] != 'admin') {
  14738. // 提交人
  14739. $receiptList = $receipt->find ( array (
  14740. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14741. 'asArray' => true
  14742. ) );
  14743. if (! empty ( $receiptList )) {
  14744. $html = '<br><div><style></style>
  14745. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14746. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14747. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14748. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14749. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14750. <tbody><tr>
  14751. <td style="padding: 0 40px;" align="left">
  14752. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14753. </td></tr><tr>
  14754. <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>
  14755. </tr>
  14756. </tbody> </table></td> </tr> <tr><td>
  14757. <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">
  14758. <tbody> <tr><td>
  14759. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14760. 以下报销单完成了审批,等着收款吧:</p>
  14761. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14762. foreach ( $receiptList as $k => $v ) {
  14763. $category = $Lcategory->getOne ( array (
  14764. 'where' => 'cid=' . $v ['cid'],
  14765. 'asArray' => true
  14766. ) );
  14767. $html .= '
  14768. <tr>
  14769. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14770. <td align="left">
  14771. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14772. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14773. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14774. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14775. </tr>';
  14776. }
  14777. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14778. <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>
  14779. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14780. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14781. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14782. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14783. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14784. $receipt = new receipt ();
  14785. $receipt->notice = 1;
  14786. $receipt->update ( array (
  14787. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14788. ) );
  14789. }
  14790. }
  14791. // 审批人
  14792. $verifyList = $verify->find ( array (
  14793. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14794. 'asArray' => true
  14795. ) );
  14796. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14797. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14798. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14799. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14800. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14801. <tbody><tr><td style="padding: 0 40px;" align="left">
  14802. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14803. </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>
  14804. </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">
  14805. <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>
  14806. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14807. foreach ( $verifyList as $k => $v ) {
  14808. $receiptList = $receipt->find ( array (
  14809. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14810. 'asArray' => true
  14811. ) );
  14812. foreach ( $receiptList as $r => $l ) {
  14813. $category = $Lcategory->getOne ( array (
  14814. 'where' => 'cid=' . $l ['cid'],
  14815. 'asArray' => true
  14816. ) );
  14817. $staffDetile = $staff->getOne ( array (
  14818. 'where' => 'sid=' . $l ['staff'],
  14819. 'asArray' => true
  14820. ) );
  14821. $html .= '
  14822. <tr>
  14823. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14824. <td align="left">
  14825. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14826. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14827. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14828. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14829. </tr>';
  14830. }
  14831. }
  14832. $html .= '
  14833. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14834. <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>
  14835. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14836. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14837. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14838. // $receipt=new receipt();
  14839. // $receipt->notice=1;
  14840. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14841. }
  14842. }
  14843. }
  14844. }
  14845. function setWXMsg($rid, $type) {
  14846. Doo::loadModel ( "receipt" );
  14847. $receipt = new receipt ();
  14848. $receiptDetail = $receipt->getOne ( array (
  14849. 'where' => 'rid=' . $rid,
  14850. 'asArray' => true
  14851. ) );
  14852. if (! empty ( $receiptDetail )) {
  14853. Doo::loadModel ( 'staff' );
  14854. $staff = new staff ();
  14855. $staffmsg = $staff->getOne ( array (
  14856. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14857. 'asArray' => TRUE
  14858. ) );
  14859. if (! empty ( $staffmsg ['wxid'] )) {
  14860. require_once (SITE_PATH . '/protected/class/client.php');
  14861. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14862. $user = $staffmsg ['wxid'];
  14863. $receiptName = '';
  14864. $msg = '';
  14865. switch ($receiptDetail ['Rtype']) {
  14866. case 0 :
  14867. $receiptName = '报销';
  14868. break;
  14869. case 1 :
  14870. $receiptName = '借款';
  14871. break;
  14872. case 2 :
  14873. $receiptName = '对公汇款';
  14874. break;
  14875. }
  14876. switch ($type) {
  14877. case 1 :
  14878. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14879. break;
  14880. case 2 :
  14881. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14882. break;
  14883. case 3 :
  14884. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14885. break;
  14886. }
  14887. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14888. }
  14889. }
  14890. }
  14891. // Email发送函数
  14892. function SMail($toemail, $subject, $contents) {
  14893. Doo::loadClass ( 'class.phpmailer' );
  14894. $mail = new PHPMailer ();
  14895. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14896. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14897. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14898. $mail->Password = "cDO1GjtY1seH"; // 密码
  14899. $mail->CharSet = "UTF8";
  14900. $mail->SMTPAuth = true;
  14901. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14902. $mail->Mailer = "smtp";
  14903. $mail->Port = 25;
  14904. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14905. $mail->MsgHTML ( $contents );
  14906. $mail->AddAddress ( $toemail );
  14907. $mail->CharSet = "UTF-8";
  14908. return $mail->Send ();
  14909. }
  14910. function h5Upload() {
  14911. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14912. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14913. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14914. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14915. header ( "HTTP/1.1 500 Internal Server Error" );
  14916. echo "POST exceeded maximum allowed size.";
  14917. exit ( 0 );
  14918. }
  14919. // Settings
  14920. $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)
  14921. $upload_name = "Filedata";
  14922. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14923. $extension_whitelist = array (
  14924. "doc",
  14925. "txt",
  14926. "jpg",
  14927. "gif",
  14928. "png"
  14929. ); // Allowed file extensions
  14930. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14931. // Other variables
  14932. $MAX_FILENAME_LENGTH = 260;
  14933. $file_name = "";
  14934. $file_extension = "";
  14935. $uploadErrors = array (
  14936. 0 => "文件上传成功",
  14937. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14938. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14939. 3 => "上传的文件仅为部分文件",
  14940. 4 => "没有文件上传",
  14941. 6 => "缺少临时文件夹"
  14942. );
  14943. $nk = time ();
  14944. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14945. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14946. echo "文件无法保存.";
  14947. exit ( 0 );
  14948. }
  14949. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14950. echo json_encode ( array (
  14951. 'filename' => $file_name,
  14952. 'id' => $nk
  14953. ) );
  14954. exit ( 0 );
  14955. }
  14956. function swfupload() {
  14957. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14958. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14959. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14960. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14961. header ( "HTTP/1.1 500 Internal Server Error" );
  14962. echo "POST exceeded maximum allowed size.";
  14963. exit ( 0 );
  14964. }
  14965. // Settings
  14966. $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)
  14967. $upload_name = "Filedata";
  14968. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14969. $extension_whitelist = array (
  14970. "doc",
  14971. "txt",
  14972. "jpg",
  14973. "gif",
  14974. "png"
  14975. ); // Allowed file extensions
  14976. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14977. // Other variables
  14978. $MAX_FILENAME_LENGTH = 260;
  14979. $file_name = "";
  14980. $file_extension = "";
  14981. $uploadErrors = array (
  14982. 0 => "文件上传成功",
  14983. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14984. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14985. 3 => "上传的文件仅为部分文件",
  14986. 4 => "没有文件上传",
  14987. 6 => "缺少临时文件夹"
  14988. );
  14989. $nk = time ();
  14990. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14991. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14992. echo "文件无法保存.";
  14993. exit ( 0 );
  14994. }
  14995. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14996. echo json_encode ( array (
  14997. 'filename' => $file_name,
  14998. 'id' => $nk
  14999. ) );
  15000. exit ( 0 );
  15001. }
  15002. function _GetFileEXT($filename) {
  15003. $pics = explode ( '.', $filename );
  15004. $num = count ( $pics );
  15005. return $pics [$num - 1];
  15006. }
  15007. /**
  15008. * 获取get或者POST值
  15009. * @param string $name 属性名称
  15010. * @return fixed 值
  15011. */
  15012. function get_args($name) {
  15013. if (isset ( $_GET [$name] )) {
  15014. if (is_array ( $_GET [$name] ))
  15015. return $_GET [$name];
  15016. else
  15017. return addslashes ( $_GET [$name] );
  15018. } elseif (isset ( $_POST [$name] )) {
  15019. if (is_array ( $_POST [$name] ))
  15020. return $_POST [$name];
  15021. else
  15022. return addslashes ( $_POST [$name] );
  15023. } else
  15024. return false;
  15025. }
  15026. function num_to_rmb($num) {
  15027. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15028. $c2 = "分角元拾佰仟万拾佰仟亿";
  15029. // 精确到分后面就不要了,所以只留两个小数位
  15030. $num = round ( $num, 2 );
  15031. // 将数字转化为整数
  15032. $num = $num * 100;
  15033. if (strlen ( $num ) > 10) {
  15034. return "金额太大,请检查";
  15035. }
  15036. $i = 0;
  15037. $c = "";
  15038. while ( 1 ) {
  15039. if ($i == 0) {
  15040. // 获取最后一位数字
  15041. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15042. } else {
  15043. $n = $num % 10;
  15044. }
  15045. // 每次将最后一位数字转化为中文
  15046. $p1 = substr ( $c1, 3 * $n, 3 );
  15047. $p2 = substr ( $c2, 3 * $i, 3 );
  15048. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15049. $c = $p1 . $p2 . $c;
  15050. } else {
  15051. $c = $p1 . $c;
  15052. }
  15053. $i = $i + 1;
  15054. // 去掉数字最后一位了
  15055. $num = $num / 10;
  15056. // echo $num.'</br>';
  15057. $num = ( int ) $num;
  15058. // $num =floor($num);
  15059. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15060. // echo $num.'</br>';
  15061. // 结束循环
  15062. if ($num == 0) {
  15063. break;
  15064. }
  15065. }
  15066. // echo $c.'</br>';
  15067. $j = 0;
  15068. $slen = strlen ( $c );
  15069. while ( $j < $slen ) {
  15070. // utf8一个汉字相当3个字符
  15071. $m = substr ( $c, $j, 6 );
  15072. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15073. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15074. $left = substr ( $c, 0, $j );
  15075. $right = substr ( $c, $j + 3 );
  15076. $c = $left . $right;
  15077. $j = $j - 3;
  15078. $slen = $slen - 3;
  15079. }
  15080. $j = $j + 3;
  15081. }
  15082. // 这个是为了去掉类似23.0中最后一个“零”字
  15083. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15084. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15085. }
  15086. // 将处理的汉字加上“整”
  15087. if (empty ( $c )) {
  15088. return "零元整";
  15089. } else {
  15090. return $c . "整";
  15091. }
  15092. }
  15093. /**
  15094. * 获得分页数据
  15095. * @param unknown_type $table
  15096. * @param unknown_type $condition
  15097. * @param unknown_type $on_page
  15098. * @param unknown_type $page_size
  15099. */
  15100. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15101. $page_c = "";
  15102. $page ['previous'] = $this->get_previous ( $on_page );
  15103. $page ['on_page'] = $on_page;
  15104. $total_count = $this->get_table_count ( $table, $condition );
  15105. $total = intval ( $total_count / $page_size );
  15106. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15107. $page ['total_data'] = $total_count;
  15108. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15109. $i = 1;
  15110. $page_max = 1;
  15111. $page_width = 3;
  15112. if ($on_page >= $page_width) {
  15113. $page_max = intval ( $on_page / $page_width ) + 1;
  15114. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15115. }
  15116. for(; $i <= $page ['total_page']; $i ++) {
  15117. if ($i == $on_page)
  15118. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15119. else
  15120. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15121. if ($i == ($page_width * $page_max))
  15122. break;
  15123. }
  15124. $page ['page'] = $page_c;
  15125. $page ['lower'] = (-- $on_page) * $page_size;
  15126. return $page;
  15127. }
  15128. /**
  15129. * 获取总页数
  15130. * @param unknown_type $table
  15131. * @param unknown_type $condition
  15132. */
  15133. public function get_table_count($table = "", $condition = "") {
  15134. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15135. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15136. // echo $sql;die;
  15137. $query = Doo::db ()->query ( $sql );
  15138. $result = $query->fetch ();
  15139. return $result ['count'];
  15140. }
  15141. /**
  15142. * 获取上一页
  15143. * @param unknown_type $on_page
  15144. */
  15145. function get_previous($on_page = 1) {
  15146. return $on_page != 0 ? $on_page - 1 : $on_page;
  15147. }
  15148. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15149. // 收入合计
  15150. Doo::loadModel ( 'invoiceTraining' );
  15151. $invoiceTraining = new invoiceTraining ();
  15152. Doo::loadModel ( 'receipt' );
  15153. $receipt = new receipt ();
  15154. $invoiceTrainingDetail = array (
  15155. 'invoiceArriveAmount' => '0.00',
  15156. 'RIAmount' => '0.00',
  15157. 'invoiceTotalAmount' => '0.00',
  15158. 'invoiceCompanyAmount' => '0.00',
  15159. 'invoiceArriveAmountM'=>'0.00',
  15160. 'invoiceCompanyAmountM'=>'0.00'
  15161. );
  15162. if ($invoiceTrainId != 0) {
  15163. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15164. }
  15165. $invoiceArriveAmount = $RIAmount = 0;
  15166. if (! empty ( $invoiceTrainingDetail )) {
  15167. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15168. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15169. }
  15170. // 备用金
  15171. $sum = 0;
  15172. if (! empty ( $trainLoanRid )) {
  15173. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15174. foreach ($receiptLoanList as $key=>$value){
  15175. $sum+=$value['sum'];
  15176. }
  15177. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15178. // $sum = $receiptLoanDetailBak ['sum'];
  15179. }
  15180. // 支出项金额详情
  15181. // 项目金额合计
  15182. Doo::loadModel ( 'RItem' );
  15183. $RItem = new RItem ();
  15184. Doo::loadModel ( 'accountItem' );
  15185. $accountItem = new accountItem ();
  15186. // 讲师获得
  15187. Doo::loadModel ( 'RILecturer' );
  15188. $RILecturer = new RILecturer ();
  15189. $RItemList = $RItem->getRItemByRid ($rid );
  15190. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15191. // 支出项金额详情
  15192. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15193. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15194. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15195. return $payment;
  15196. }
  15197. }
  15198. ?>