ReceiptController.php 569 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416
  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. // print_r($receiptList);
  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. $this->setWXMsg ( $rid, 3 );
  9483. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9484. $receipt->status = 1;
  9485. $reviseSum = 0;
  9486. $receipt->verifyBreakup = $verifyString;
  9487. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9488. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9489. foreach ( $reviseDetail as $key => $value ) {
  9490. $receiptDetailObj = new receiptDetail ();
  9491. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9492. $receiptDetailObj->item = $value ['description'];
  9493. $receiptDetailObj->itemCategory = "报销金额调整";
  9494. $receiptDetailObj->price = $value ['price'];
  9495. $receiptDetailObj->date = $receiptDetail ['date'];
  9496. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9497. $receiptDetailObj->rid = $rid;
  9498. $receiptDetailObj->status = 1;
  9499. $receiptDetailObj->insert ();
  9500. $reviseSum += $value ['price'];
  9501. }
  9502. $itemStatistics = new itemStatistics ();
  9503. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9504. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9505. $itemStatistics->price = $reviseSum;
  9506. $itemStatistics->itemCategory = "报销金额调整";
  9507. $itemStatistics->date = $receiptDetail ['date'];
  9508. $itemStatistics->insert ();
  9509. }
  9510. $receiptDetailObj = new receiptDetail ();
  9511. $receiptDetailObj->status = 1;
  9512. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9513. $receiptDetailObj->update ( array (
  9514. 'where' => 'rid=' . $rid
  9515. ) );
  9516. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9517. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9518. $stat = $statistics->getOne ( array (
  9519. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9520. 'asArray' => true
  9521. ) );
  9522. if (empty ( $stat )) {
  9523. $statistics->date = $receiptDetail ['date'];
  9524. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9525. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9526. $statistics->agPrice = $receiptDetail ['sum'];
  9527. $statistics->rePrice = $reviseSum;
  9528. $statistics->insert ();
  9529. } else {
  9530. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9531. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9532. $statistics->update ( array (
  9533. 'where' => 'sid=' . $stat ['sid']
  9534. ) );
  9535. }
  9536. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9537. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9538. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9539. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9540. if ($key == "agencySum") {
  9541. $iStatistics = $itemStatistics->getOne ( array (
  9542. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9543. 'asArray' => true
  9544. ) );
  9545. if (empty ( $iStatistics )) {
  9546. $itemStatistics->cid = $receiptDetail ['cid'];
  9547. ;
  9548. $itemStatistics->staff = $receiptDetail ['staff'];
  9549. $itemStatistics->price = $value;
  9550. $itemStatistics->itemCategory = $this->AGENCY;
  9551. $itemStatistics->date = $receiptDetail ['date'];
  9552. $itemStatistics->insert ();
  9553. } else {
  9554. if (! empty ( $value )) {
  9555. $itemStatistics->price = $value + $iStatistics ['price'];
  9556. $itemStatistics->update ( array (
  9557. 'where' => 'sid=' . $iStatistics ['sid']
  9558. ) );
  9559. }
  9560. }
  9561. } elseif ($key == "travelSum") {
  9562. $iStatistics = $itemStatistics->getOne ( array (
  9563. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9564. 'asArray' => true
  9565. ) );
  9566. if (empty ( $iStatistics )) {
  9567. $itemStatistics->cid = $receiptDetail ['cid'];
  9568. $itemStatistics->staff = $receiptDetail ['staff'];
  9569. $itemStatistics->price = $value;
  9570. $itemStatistics->itemCategory = $this->TRAVEL;
  9571. $itemStatistics->date = $receiptDetail ['date'];
  9572. $itemStatistics->insert ();
  9573. } else {
  9574. if (! empty ( $value )) {
  9575. $itemStatistics->price = $value + $iStatistics ['price'];
  9576. $itemStatistics->update ( array (
  9577. 'where' => 'sid=' . $iStatistics ['sid']
  9578. ) );
  9579. }
  9580. }
  9581. } elseif ($key == "trainSum") {
  9582. $iStatistics = $itemStatistics->getOne ( array (
  9583. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9584. 'asArray' => true
  9585. ) );
  9586. if (empty ( $iStatistics )) {
  9587. $itemStatistics->cid = $receiptDetail ['cid'];
  9588. $itemStatistics->staff = $receiptDetail ['staff'];
  9589. $itemStatistics->price = $value;
  9590. $itemStatistics->itemCategory = $this->TRAIN;
  9591. $itemStatistics->date = $receiptDetail ['date'];
  9592. $itemStatistics->insert ();
  9593. } else {
  9594. if (! empty ( $value )) {
  9595. $itemStatistics->price = $value + $iStatistics ['price'];
  9596. $itemStatistics->update ( array (
  9597. 'where' => 'sid=' . $iStatistics ['sid']
  9598. ) );
  9599. }
  9600. }
  9601. } elseif ($key == "otherSum") {
  9602. $iStatistics = $itemStatistics->getOne ( array (
  9603. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9604. 'asArray' => true
  9605. ) );
  9606. if (empty ( $iStatistics )) {
  9607. $itemStatistics->cid = $receiptDetail ['cid'];
  9608. $itemStatistics->staff = $receiptDetail ['staff'];
  9609. $itemStatistics->price = $value;
  9610. $itemStatistics->itemCategory = $this->OTHER;
  9611. $itemStatistics->date = $receiptDetail ['date'];
  9612. $itemStatistics->insert ();
  9613. } else {
  9614. if (! empty ( $value )) {
  9615. $itemStatistics->price = $value + $iStatistics ['price'];
  9616. $itemStatistics->update ( array (
  9617. 'where' => 'sid=' . $iStatistics ['sid']
  9618. ) );
  9619. }
  9620. }
  9621. }
  9622. }
  9623. $receipt->pastDate = date ( "Y-m-d" );
  9624. // 微信企业号通知
  9625. $this->setWXMsg ( $rid, 1 );
  9626. }
  9627. //是否有流水
  9628. Doo::loadModel ( 'wasteBook' );
  9629. $wasteBook = new wasteBook ();
  9630. $accountType=3;
  9631. if ($receiptDetail['Rtype']==1){
  9632. $accountType=2;
  9633. }elseif($receiptDetail['Rtype']==2){
  9634. $accountType=4;
  9635. }
  9636. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9637. if (empty($wbDetail)){
  9638. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9639. $receipt->amount = $rsum;//$amount;
  9640. }
  9641. $receipt->update ( array (
  9642. 'where' => ' rid = ' . $rid
  9643. ) );
  9644. // 进入下一条审批费用新加需求
  9645. $vidList = array ();
  9646. $verifyDetail = $verify->find ( array (
  9647. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9648. 'asArray' => true
  9649. ) );
  9650. foreach ( $verifyDetail as $key => $value ) {
  9651. array_push ( $vidList, $value ['vid'] );
  9652. }
  9653. $vid = implode ( ",", $vidList );
  9654. if (empty ( $verifyDetail ))
  9655. $vid = 0;
  9656. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9657. $receipt = new receipt ();
  9658. $rd = $receipt->getOne ( array (
  9659. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9660. 'asc' => 'rid',
  9661. 'asArray' => true
  9662. ) );
  9663. if (empty ( $rd )) {
  9664. return '/approvalExpenses/pendApproval';
  9665. }
  9666. if ($rd ['Rtype'] == 1) {
  9667. if ($rd ['isBK'] == 1) {
  9668. return '/receiptburEdi/' . $rd ['rid'];
  9669. } else {
  9670. return '/expensesEdi/' . $rd ['rid'];
  9671. }
  9672. } elseif ($rd ['Rtype'] == 2) {
  9673. return '/remitApproval/' . $rd ['rid'];
  9674. } else {
  9675. return '/receiptburEdi/' . $rd ['rid'];
  9676. }
  9677. // return "/approvalExpenses/pendApproval";
  9678. }
  9679. }
  9680. function expensesRetreats() {
  9681. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9682. if (! empty ( $rid )) {
  9683. // 操作记录
  9684. Doo::loadModel ( "receipt" );
  9685. $receipt = new receipt ();
  9686. Doo::loadModel ( "receiptLog" );
  9687. $receiptLog = new receiptLog ();
  9688. Doo::loadModel ( "verify" );
  9689. $verify = new verify ();
  9690. $receiptInfo = $receipt->getOne ( array (
  9691. 'where' => 'rid=' . $rid,
  9692. 'asArray' => true
  9693. ) );
  9694. $vr = $verify->getOne ( array (
  9695. 'where' => 'vid=' . $receiptInfo ['verify'],
  9696. 'asArray' => true
  9697. ) );
  9698. $jd = json_decode ( $vr ['staff'] );
  9699. $roleId = 0;
  9700. foreach ( $jd as $key => $value ) {
  9701. if ($value [1] == 'ROLE') {
  9702. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9703. if ($pos !== false) {
  9704. $roleId = $value [0];
  9705. }
  9706. }
  9707. }
  9708. // 审批日志
  9709. // echo $roleId;die;
  9710. if (! empty ( $roleId )) {
  9711. Doo::loadModel ( "role" );
  9712. $role = new role ();
  9713. $roleInfo = $role->getOne ( array (
  9714. 'where' => 'rid=' . $roleId,
  9715. 'asArray' => true
  9716. ) );
  9717. $receiptLog->rolename = $roleInfo ['name'];
  9718. }
  9719. $receiptLog->username = $this->staff [0] ['username'];
  9720. $receiptLog->uid = $this->staff [0] ['sid'];
  9721. $receiptLog->date = date ( "Y-m-d" );
  9722. $receiptLog->opinion = '撤回';
  9723. $receiptLog->img = $this->staff [0] ['avatar'];
  9724. $receiptLog->status = 4;
  9725. $receiptLog->rid = $rid;
  9726. $receiptLog->insert ();
  9727. $receipt->status = 4;
  9728. $receipt->update ( array (
  9729. 'where' => 'rid=' . $rid
  9730. ) );
  9731. // 微信企业号通知
  9732. $this->setWXMsg ( $rid, 2 );
  9733. }
  9734. // echo "ddd";
  9735. return '/approvalExpenses/pendApproval';
  9736. }
  9737. function updateCheReceipt() {
  9738. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9739. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9740. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9741. if (! empty ( $rid )) {
  9742. // 操作记录
  9743. Doo::loadModel ( "receipt" );
  9744. $receipt = new receipt ();
  9745. Doo::loadModel ( "receiptLog" );
  9746. $receiptLog = new receiptLog ();
  9747. Doo::loadModel ( "verify" );
  9748. $verify = new verify ();
  9749. $receiptInfo = $receipt->getOne ( array (
  9750. 'where' => 'rid=' . $rid . ' and status=2',
  9751. 'asArray' => true
  9752. ) );
  9753. if (empty ( $receiptInfo )) {
  9754. echo json_encode ( array (
  9755. 'status' => 2
  9756. ) );
  9757. die ();
  9758. }
  9759. $vr = $verify->getOne ( array (
  9760. 'where' => 'vid=' . $receiptInfo ['verify'],
  9761. 'asArray' => true
  9762. ) );
  9763. $jd = json_decode ( $vr ['staff'] );
  9764. $roleId = 0;
  9765. foreach ( $jd as $key => $value ) {
  9766. if ($value [1] == 'ROLE') {
  9767. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9768. if ($pos !== false) {
  9769. $roleId = $value [0];
  9770. }
  9771. }
  9772. }
  9773. // 审批日志
  9774. // echo $roleId;die;
  9775. if (! empty ( $roleId )) {
  9776. Doo::loadModel ( "role" );
  9777. $role = new role ();
  9778. $roleInfo = $role->getOne ( array (
  9779. 'where' => 'rid=' . $roleId,
  9780. 'asArray' => true
  9781. ) );
  9782. $receiptLog->rolename = $roleInfo ['name'];
  9783. }
  9784. $receiptLog->username = $this->staff [0] ['username'];
  9785. $receiptLog->uid = $this->staff [0] ['sid'];
  9786. $receiptLog->date = date ( "Y-m-d" );
  9787. $receiptLog->opinion = $opinion;
  9788. $receiptLog->img = $this->staff [0] ['avatar'];
  9789. $receiptLog->status = 4;
  9790. $receiptLog->rid = $rid;
  9791. $receiptLog->insert ();
  9792. $receipt->status = 4;
  9793. $receipt->update ( array (
  9794. 'where' => 'rid=' . $rid
  9795. ) );
  9796. // 微信企业号通知
  9797. $this->setWXMsg ( $rid, 2 );
  9798. echo json_encode ( array (
  9799. 'status' => 1
  9800. ) );
  9801. // Header("HTTP/1.1 303 See Other");
  9802. // Header("Location: /approvalExpenses/pendApproval");
  9803. die ();
  9804. }
  9805. echo json_encode ( array (
  9806. 'status' => 2
  9807. ) );
  9808. die ();
  9809. // echo "ddd";
  9810. // return '/saeaBorad';
  9811. }
  9812. function revisePrice() {
  9813. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9814. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9815. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9816. // echo $price;die;
  9817. if (! empty ( $rid )) {
  9818. Doo::loadModel ( "receipt" );
  9819. $receipt = new receipt ();
  9820. $receiptDetail = $receipt->getOne ( array (
  9821. 'where' => 'rid=' . $rid . ' and status=2 ',
  9822. 'asArray' => true
  9823. ) );
  9824. if (empty ( $receiptDetail ))
  9825. die ( 'illegal request' );
  9826. $reviseDetail = array ();
  9827. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9828. array_push ( $reviseDetail, array (
  9829. 'sid' => $this->staff [0] ['sid'],
  9830. 'name' => $this->staff [0] ['username'],
  9831. 'description' => $description,
  9832. 'price' => $price
  9833. ) );
  9834. $reviseDetailString = json_encode ( $reviseDetail );
  9835. $receipt->reviseDetail = $reviseDetailString;
  9836. $receipt->revisePrice = $price;
  9837. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9838. } else {
  9839. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9840. array_push ( $reviseDetail, array (
  9841. 'sid' => $this->staff [0] ['sid'],
  9842. 'name' => $this->staff [0] ['username'],
  9843. 'description' => $description,
  9844. 'price' => $price
  9845. ) );
  9846. $reviseDetailString = json_encode ( $reviseDetail );
  9847. $receipt->reviseDetail = $reviseDetailString;
  9848. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9849. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9850. }
  9851. $receipt->update ( array (
  9852. 'where' => 'rid=' . $rid
  9853. ) );
  9854. if ($receiptDetail ['Rtype'] == 1) {
  9855. if ($receiptDetail ['isBK'] == 1) {
  9856. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9857. }
  9858. } elseif ($receiptDetail ['Rtype'] == 2) {
  9859. } else {
  9860. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9861. }
  9862. }
  9863. die ( 'illegal request' );
  9864. }
  9865. function personalCollect() {
  9866. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9867. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9868. $this->showCache ( $path );
  9869. Doo::loadModel ( "receiptDetail" );
  9870. Doo::loadModel ( "itemStatistics" );
  9871. Doo::loadModel ( 'statistics' );
  9872. $statistics = new statistics ();
  9873. $itemStatistics = new itemStatistics ();
  9874. $receiptDetail = new receiptDetail ();
  9875. $receiptCollectList = $receiptDetail->find ( array (
  9876. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9877. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9878. 'groupby' => 'itemCategory,Month(date)',
  9879. 'asArray' => true
  9880. ) );
  9881. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9882. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9883. 'asArray' => true
  9884. ) );
  9885. // create collect html
  9886. $collectArray = array (
  9887. '日常相关费用' => array (),
  9888. '差旅相关费用' => array (),
  9889. '培训班费用' => array (),
  9890. '其他' => array ()
  9891. );
  9892. $adjustment = array ();
  9893. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9894. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9895. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9896. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9897. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9898. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9899. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9900. array_push ( $collectArray ['其他'], $collectHtml );
  9901. $data ['collectArray'] = $collectArray;
  9902. // statistics html
  9903. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9904. if (empty ( $stList ))
  9905. $stList = array (
  9906. 'rePrice' => 0,
  9907. 'agPrice' => 0
  9908. );
  9909. $data ['stList'] = array (
  9910. 'rePrice' => $stList ['rePrice'],
  9911. 'agPrice' => $stList ['agPrice'],
  9912. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9913. );
  9914. // Adjustment price html
  9915. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9916. array_push ( $adjustment, $collectHtml );
  9917. $data ['adjustment'] = $adjustment;
  9918. // total price html
  9919. $collectHtml = "";
  9920. $total = 0;
  9921. for($i = 1; $i <= 12; $i ++) {
  9922. $sumPrice = 0;
  9923. foreach ( $receiptCollectList as $key => $value ) {
  9924. if ($value ['month'] == $i) {
  9925. $sumPrice += $value ['price'];
  9926. }
  9927. }
  9928. if ($sumPrice == 0)
  9929. $collectHtml .= '<td class="taR">-</td>';
  9930. else
  9931. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9932. $total += $sumPrice;
  9933. }
  9934. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9935. $data ['totalPrice'] = $collectHtml;
  9936. $dateHtml = "";
  9937. $now = date ( "Y" );
  9938. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9939. if ($YEARD <= $now) {
  9940. $dateHtml .= '<option ';
  9941. if ($year == $YEARD) {
  9942. $dateHtml .= 'selected ';
  9943. }
  9944. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9945. }
  9946. }
  9947. $data ['dateHtml'] = $dateHtml;
  9948. $data ['year'] = $year;
  9949. $data ['totalYear'] = $total;
  9950. $data ['memu'] = "receipt";
  9951. $data ['staff'] = $this->staff;
  9952. $data ['receiptMemu'] = 'personalCollect';
  9953. $data ['verifyId'] = $this->verifyId;
  9954. $data ['executeId'] = $this->executeId;
  9955. // year staff status 2,4
  9956. if ($year < date ( "Y" )) {
  9957. Doo::loadModel ( 'receipt' );
  9958. $receipt = new receipt ();
  9959. $receiptList = $receipt->find ( array (
  9960. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9961. 'asArray' => true
  9962. ) );
  9963. if (empty ( $receiptList )) {
  9964. ob_start ();
  9965. $this->render ( "/admin/saea_slist_collect", $data );
  9966. $this->cacheFile ( $path );
  9967. die ();
  9968. }
  9969. }
  9970. $this->render ( "/admin/saea_slist_collect", $data );
  9971. }
  9972. function personalCollectDetail() {
  9973. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9974. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9975. $this->showCache ( $path );
  9976. Doo::loadModel ( "receiptDetail" );
  9977. Doo::loadModel ( "itemStatistics" );
  9978. Doo::loadModel ( 'statistics' );
  9979. Doo::loadModel ( 'accountItem' );
  9980. $accountItem = new accountItem ();
  9981. $statistics = new statistics ();
  9982. $itemStatistics = new itemStatistics ();
  9983. $receiptDetail = new receiptDetail ();
  9984. $receiptCollectList = $receiptDetail->find ( array (
  9985. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9986. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9987. 'groupby' => 'item,Month(date)',
  9988. 'asArray' => true
  9989. ) );
  9990. $accountList = $accountItem->find ( array (
  9991. 'asArray' => true
  9992. ) );
  9993. // create CollectDetail HTML
  9994. $collectHtml = array ();
  9995. foreach ( $accountList as $key => $value ) {
  9996. $html = "";
  9997. $asum = 0;
  9998. for($i = 1; $i <= 12; $i ++) {
  9999. $falg = true;
  10000. foreach ( $receiptCollectList as $v ) {
  10001. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10002. $asum += $v ['price'];
  10003. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10004. $falg = false;
  10005. break;
  10006. }
  10007. }
  10008. if ($falg)
  10009. $html .= '<td class="taR">-</td>';
  10010. }
  10011. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10012. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10013. }
  10014. $data ['collectHtml'] = $collectHtml;
  10015. // create Adjustment price html
  10016. $receiptCollectList = $receiptDetail->find ( array (
  10017. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  10018. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  10019. 'groupby' => 'itemCategory,Month(date)',
  10020. 'asArray' => true
  10021. ) );
  10022. $adjustment = array ();
  10023. $collectArray = array (
  10024. '日常相关费用' => array (),
  10025. '差旅相关费用' => array (),
  10026. '培训班费用' => array (),
  10027. '其他' => array ()
  10028. );
  10029. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10030. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10031. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10032. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10033. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10034. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10035. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10036. array_push ( $collectArray ['其他'], $collectHtml );
  10037. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10038. array_push ( $adjustment, $collectHtml );
  10039. // total price html
  10040. $collectHtml = "";
  10041. $total = 0;
  10042. for($i = 1; $i <= 12; $i ++) {
  10043. $sumPrice = 0;
  10044. foreach ( $receiptCollectList as $key => $value ) {
  10045. if ($value ['month'] == $i) {
  10046. $sumPrice += $value ['price'];
  10047. }
  10048. }
  10049. if ($sumPrice == 0)
  10050. $collectHtml .= '<td class="taR">-</td>';
  10051. else
  10052. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10053. $total += $sumPrice;
  10054. }
  10055. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10056. // statistics html
  10057. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  10058. if (empty ( $stList ))
  10059. $stList = array (
  10060. 'rePrice' => 0,
  10061. 'agPrice' => 0
  10062. );
  10063. $data ['stList'] = array (
  10064. 'rePrice' => $stList ['rePrice'],
  10065. 'agPrice' => $stList ['agPrice'],
  10066. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10067. );
  10068. $data ['collectArray'] = $collectArray;
  10069. $data ['adjustment'] = $adjustment;
  10070. $data ['totalPrice'] = $collectHtml;
  10071. $data ['totalYear'] = $total;
  10072. $data ['year'] = $year;
  10073. $dateHtml = "";
  10074. $now = date ( "Y" );
  10075. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10076. if ($YEARD <= $now) {
  10077. $dateHtml .= '<option ';
  10078. if ($year == $YEARD) {
  10079. $dateHtml .= 'selected ';
  10080. }
  10081. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10082. }
  10083. }
  10084. $data ['dateHtml'] = $dateHtml;
  10085. $data ['memu'] = "receipt";
  10086. $data ['staff'] = $this->staff;
  10087. $data ['receiptMemu'] = 'personalCollect';
  10088. $data ['verifyId'] = $this->verifyId;
  10089. $data ['executeId'] = $this->executeId;
  10090. // year staff status 2,4
  10091. if ($year < date ( "Y" )) {
  10092. Doo::loadModel ( 'receipt' );
  10093. $receipt = new receipt ();
  10094. $receiptList = $receipt->find ( array (
  10095. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  10096. 'asArray' => true
  10097. ) );
  10098. if (empty ( $receiptList )) {
  10099. ob_start ();
  10100. $this->render ( "/admin/saeaCollectArticles", $data );
  10101. $this->cacheFile ( $path );
  10102. die ();
  10103. }
  10104. }
  10105. $this->render ( "/admin/saeaCollectArticles", $data );
  10106. }
  10107. function companyCategoryCollect() {
  10108. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10109. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  10110. $this->showCache ( $path );
  10111. Doo::loadModel ( 'L_category' );
  10112. Doo::loadModel ( 'itemStatistics' );
  10113. Doo::loadModel ( 'statistics' );
  10114. $statistics = new statistics ();
  10115. $Lcategory = new L_category ();
  10116. $itemStatistics = new itemStatistics ();
  10117. Doo::loadModel ( "receiptAuthorityManage" );
  10118. $receiptAuthorityManage = new receiptAuthorityManage ();
  10119. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10120. $cidList = array ();
  10121. foreach ( $imcStaff as $key => $value ) {
  10122. array_push ( $cidList, $value ['cid'] );
  10123. }
  10124. $cidString = implode ( ',', $cidList );
  10125. $LcategoryList = $Lcategory->find ( array (
  10126. 'where' => ' cid in (' . $cidString . ')',
  10127. 'asArray' => true
  10128. ) ); // 'staff='.$this->staff[0]['sid']." and
  10129. $itemStatisticsList = $itemStatistics->find ( array (
  10130. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10131. 'where' => " Year(date)=" . $year,
  10132. 'groupby' => 'cid,Month(date)',
  10133. 'asArray' => true
  10134. ) );
  10135. // ceatre companyCollectHtml
  10136. foreach ( $LcategoryList as $value ) {
  10137. $html = "";
  10138. $asum = 0;
  10139. for($i = 1; $i <= 12; $i ++) {
  10140. $falg = true;
  10141. foreach ( $itemStatisticsList as $v ) {
  10142. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  10143. $asum += $v ['price'];
  10144. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10145. $falg = false;
  10146. break;
  10147. }
  10148. }
  10149. if ($falg)
  10150. $html .= '<td class="taR">-</td>';
  10151. }
  10152. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10153. $collectHtml [$value ['title']] = array (
  10154. 'html' => $html,
  10155. 'cid' => $value ['cid']
  10156. );
  10157. }
  10158. $data ['companyHtml'] = $collectHtml;
  10159. // total price html
  10160. $collectHtml = "";
  10161. $total = 0;
  10162. for($i = 1; $i <= 12; $i ++) {
  10163. $sumPrice = 0;
  10164. foreach ( $itemStatisticsList as $key => $value ) {
  10165. if ($value ['month'] == $i) {
  10166. $sumPrice += $value ['price'];
  10167. }
  10168. }
  10169. if ($sumPrice == 0)
  10170. $collectHtml .= '<td class="taR">-</td>';
  10171. else
  10172. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10173. $total += $sumPrice;
  10174. }
  10175. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10176. $data ['companyTotalHtml'] = $collectHtml;
  10177. $data ['total'] = $total;
  10178. // statistics html
  10179. // echo $cidString;
  10180. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10181. if (empty ( $stList ))
  10182. $stList = array (
  10183. 'rePrice' => 0,
  10184. 'agPrice' => 0
  10185. );
  10186. $data ['stList'] = array (
  10187. 'rePrice' => $stList ['rePrice'],
  10188. 'agPrice' => $stList ['agPrice'],
  10189. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10190. );
  10191. $data ['year'] = $year;
  10192. $data ['memu'] = "receipt";
  10193. $data ['staff'] = $this->staff;
  10194. $data ['receiptMemu'] = 'companyCategoryCollect';
  10195. $data ['verifyId'] = $this->verifyId;
  10196. $data ['executeId'] = $this->executeId;
  10197. $dateHtml = "";
  10198. $now = date ( "Y" );
  10199. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10200. if ($YEARD <= $now) {
  10201. $dateHtml .= '<option ';
  10202. if ($year == $YEARD) {
  10203. $dateHtml .= 'selected ';
  10204. }
  10205. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10206. }
  10207. }
  10208. $data ['dateHtml'] = $dateHtml;
  10209. // year staff status 2,4
  10210. if ($year < date ( "Y" )) {
  10211. Doo::loadModel ( 'receipt' );
  10212. $receipt = new receipt ();
  10213. $receiptList = $receipt->find ( array (
  10214. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10215. 'asArray' => true
  10216. ) );
  10217. if (empty ( $receiptList )) {
  10218. ob_start ();
  10219. $this->render ( "/admin/saeaCompanyCollect", $data );
  10220. $this->cacheFile ( $path );
  10221. die ();
  10222. }
  10223. }
  10224. $this->render ( "/admin/saeaCompanyCollect", $data );
  10225. }
  10226. function categoryCollectDetail() {
  10227. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10228. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10229. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10230. $this->showCache ( $path ); */
  10231. Doo::loadModel ( 'statistics' );
  10232. $statistics = new statistics ();
  10233. Doo::loadModel ( "receiptDetail" );
  10234. $receiptDetail = new receiptDetail ();
  10235. Doo::loadModel ( 'L_category' );
  10236. $Lcategory = new L_category ();
  10237. Doo::loadModel ( 'accountItem' );
  10238. $accountItem = new accountItem ();
  10239. Doo::loadModel ( "receiptAuthorityManage" );
  10240. $receiptAuthorityManage = new receiptAuthorityManage ();
  10241. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10242. $cidList = array ();
  10243. foreach ( $imcStaff as $key => $value ) {
  10244. array_push ( $cidList, $value ['cid'] );
  10245. }
  10246. $cidString = implode ( ',', $cidList );
  10247. $LcategoryList = $Lcategory->find ( array (
  10248. 'where' => 'cid in (' . $cidString . ')',
  10249. 'asArray' => true
  10250. ) );
  10251. if ($cid == 0) {
  10252. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10253. if ($cid == 0)
  10254. $cid = $LcategoryList [0] ['cid'];
  10255. }
  10256. $data ['LcategoryList'] = $LcategoryList;
  10257. $receiptCollectList = $receiptDetail->find ( array (
  10258. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10259. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10260. 'groupby' => 'item,Month(pastDate)',
  10261. 'asArray' => true
  10262. ) );
  10263. $accountList = $accountItem->find ( array (
  10264. 'asArray' => true
  10265. ) );
  10266. // create CollectDetail HTML
  10267. $collectHtml = array ();
  10268. foreach ( $accountList as $key => $value ) {
  10269. $html = "";
  10270. $asum = 0;
  10271. for($i = 1; $i <= 12; $i ++) {
  10272. $falg = true;
  10273. foreach ( $receiptCollectList as $v ) {
  10274. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10275. $asum += $v ['price'];
  10276. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10277. $falg = false;
  10278. break;
  10279. }
  10280. }
  10281. if ($falg)
  10282. $html .= '<td class="taR">-</td>';
  10283. }
  10284. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10285. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10286. }
  10287. $data ['collectHtml'] = $collectHtml;
  10288. // create Adjustment price html
  10289. $receiptCollectList = $receiptDetail->find ( array (
  10290. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10291. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10292. 'groupby' => 'itemCategory,Month(pastDate)',
  10293. 'asArray' => true
  10294. ) );
  10295. $adjustment = array ();
  10296. $collectArray = array (
  10297. '日常相关费用' => array (),
  10298. '差旅相关费用' => array (),
  10299. '培训班费用' => array (),
  10300. '内部培训费用'=>array(),
  10301. '其他' => array ()
  10302. );
  10303. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10304. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10305. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10306. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10307. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10308. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10309. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10310. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10311. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10312. array_push ( $collectArray ['其他'], $collectHtml );
  10313. $data ['collectArray'] = $collectArray;
  10314. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10315. array_push ( $adjustment, $collectHtml );
  10316. $data ['adjustment'] = $adjustment;
  10317. // total price html
  10318. $collectHtml = "";
  10319. $total = 0;
  10320. for($i = 1; $i <= 12; $i ++) {
  10321. $sumPrice = 0;
  10322. foreach ( $receiptCollectList as $key => $value ) {
  10323. if ($value ['month'] == $i) {
  10324. $sumPrice += $value ['price'];
  10325. }
  10326. }
  10327. if ($sumPrice == 0)
  10328. $collectHtml .= '<td class="taR">-</td>';
  10329. else
  10330. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10331. $total += $sumPrice;
  10332. }
  10333. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10334. // statistics html
  10335. $stList = $statistics->statisticsByCid ( $year, $cid );
  10336. if (empty ( $stList ))
  10337. $stList = array (
  10338. 'rePrice' => 0,
  10339. 'agPrice' => 0
  10340. );
  10341. $data ['stList'] = array (
  10342. 'rePrice' => $stList ['rePrice'],
  10343. 'agPrice' => $stList ['agPrice'],
  10344. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10345. );
  10346. $data ['totalYear'] = $total;
  10347. $data ['year'] = $year;
  10348. $data ['cid'] = $cid;
  10349. $data ['memu'] = "receipt";
  10350. $data ['staff'] = $this->staff;
  10351. $data ['receiptMemu'] = 'companyCategoryCollect';
  10352. $data ['verifyId'] = $this->verifyId;
  10353. $data ['executeId'] = $this->executeId;
  10354. // year staff status 2,4
  10355. /* if ($year < date ( "Y" )) {
  10356. Doo::loadModel ( 'receipt' );
  10357. $receipt = new receipt ();
  10358. $receiptList = $receipt->find ( array (
  10359. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10360. 'asArray' => true
  10361. ) );
  10362. if (empty ( $receiptList )) {
  10363. ob_start ();
  10364. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10365. $this->cacheFile ( $path );
  10366. die ();
  10367. }
  10368. } */
  10369. $dateHtml = "";
  10370. $now = date ( "Y" );
  10371. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10372. if ($YEARD <= $now) {
  10373. $dateHtml .= '<option ';
  10374. if ($year == $YEARD) {
  10375. $dateHtml .= 'selected ';
  10376. }
  10377. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10378. }
  10379. }
  10380. $data ['dateHtml'] = $dateHtml;
  10381. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10382. }
  10383. function staffCollect() {
  10384. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10385. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10386. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10387. // $this->showCache($path);
  10388. Doo::loadModel ( 'statistics' );
  10389. $statistics = new statistics ();
  10390. Doo::loadModel ( "receiptDetail" );
  10391. $receiptDetail = new receiptDetail ();
  10392. Doo::loadModel ( 'L_category' );
  10393. $Lcategory = new L_category ();
  10394. Doo::loadModel ( 'accountItem' );
  10395. $accountItem = new accountItem ();
  10396. Doo::loadModel ( 'staff' );
  10397. $staff = new staff ();
  10398. Doo::loadModel ( 'itemStatistics' );
  10399. $itemStatistics = new itemStatistics ();
  10400. Doo::loadModel ( "receiptAuthorityManage" );
  10401. $receiptAuthorityManage = new receiptAuthorityManage ();
  10402. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10403. $cidList = array ();
  10404. foreach ( $imcStaff as $key => $value ) {
  10405. array_push ( $cidList, $value ['cid'] );
  10406. }
  10407. $cidString = implode ( ',', $cidList );
  10408. $naturecon='';
  10409. if ($nature=='ONJOB'){
  10410. $naturecon=' and (nature!=4 )';
  10411. }elseif($nature=='LEAVEJOB'){
  10412. $naturecon=' and (nature=4 )';
  10413. }else{
  10414. die ( 'illegal request--nature' );
  10415. }
  10416. // statistics html
  10417. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10418. if (empty ( $stList ))
  10419. $stList = array (
  10420. 'rePrice' => 0,
  10421. 'agPrice' => 0
  10422. );
  10423. $data ['stList'] = array (
  10424. 'rePrice' => $stList ['rePrice'],
  10425. 'agPrice' => $stList ['agPrice'],
  10426. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10427. );
  10428. // ---
  10429. $staffList = $staff->find ( array (
  10430. 'where' => 'username !="admin" '.$naturecon,
  10431. 'asArray' => true
  10432. ) );
  10433. $LcategoryList = $Lcategory->find ( array (
  10434. 'asArray' => true
  10435. ) ); // 'staff='.$this->staff[0]['sid']." and
  10436. $itemStatisticsList = $itemStatistics->find ( array (
  10437. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10438. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10439. 'groupby' => 'staff,Month(date)',
  10440. 'asArray' => true
  10441. ) );
  10442. $categoryList = $staff->find ( array (
  10443. 'select' => 'COUNT(*) as count,cid,category',
  10444. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10445. 'groupby' => 'cid',
  10446. 'asArray' => true
  10447. ) );
  10448. // print_r($itemStatisticsList);die;
  10449. // ceatre companyCollectHtml
  10450. foreach ( $categoryList as $vlu ) {
  10451. $count = $vlu ['count'] + 1;
  10452. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10453. $m1 = 0;
  10454. $m2 = 0;
  10455. $m3 = 0;
  10456. $m4 = 0;
  10457. $m5 = 0;
  10458. $m6 = 0;
  10459. $m7 = 0;
  10460. $m8 = 0;
  10461. $m9 = 0;
  10462. $m10 = 0;
  10463. $m11 = 0;
  10464. $m12 = 0;
  10465. $m13 = 0;
  10466. foreach ( $staffList as $value ) {
  10467. if ($vlu ['cid'] == $value ['cid']) {
  10468. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10469. $asum = 0;
  10470. for($i = 1; $i <= 12; $i ++) {
  10471. $falg = true;
  10472. foreach ( $itemStatisticsList as $v ) {
  10473. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10474. if ($v ['month'] == 1)
  10475. $m1 += $v ['price'];
  10476. if ($v ['month'] == 2)
  10477. $m2 += $v ['price'];
  10478. if ($v ['month'] == 3)
  10479. $m3 += $v ['price'];
  10480. if ($v ['month'] == 4)
  10481. $m4 += $v ['price'];
  10482. if ($v ['month'] == 5)
  10483. $m5 += $v ['price'];
  10484. if ($v ['month'] == 6)
  10485. $m6 += $v ['price'];
  10486. if ($v ['month'] == 7)
  10487. $m7 += $v ['price'];
  10488. if ($v ['month'] == 8)
  10489. $m8 += $v ['price'];
  10490. if ($v ['month'] == 9)
  10491. $m9 += $v ['price'];
  10492. if ($v ['month'] == 10)
  10493. $m10 += $v ['price'];
  10494. if ($v ['month'] == 11)
  10495. $m11 += $v ['price'];
  10496. if ($v ['month'] == 12)
  10497. $m12 += $v ['price'];
  10498. $asum += $v ['price'];
  10499. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10500. $falg = false;
  10501. break;
  10502. }
  10503. }
  10504. if ($falg)
  10505. $html .= '<td class="taR">-</td>';
  10506. }
  10507. $m13 += $asum;
  10508. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10509. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10510. 'html' => $html,
  10511. 'sid' => $value ['sid']
  10512. );
  10513. $html = "";
  10514. }
  10515. }
  10516. $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>
  10517. <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>
  10518. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10519. $collectHtml [$vlu ['cid']] = array (
  10520. 'html' => $hl,
  10521. 'sid' => ''
  10522. );
  10523. }
  10524. $data ['companyHtml'] = $collectHtml;
  10525. // total price html
  10526. $collectHtml = "";
  10527. $total = 0;
  10528. for($i = 1; $i <= 12; $i ++) {
  10529. $sumPrice = 0;
  10530. foreach ( $itemStatisticsList as $key => $value ) {
  10531. if ($value ['month'] == $i) {
  10532. $sumPrice += $value ['price'];
  10533. }
  10534. }
  10535. if ($sumPrice == 0)
  10536. $collectHtml .= '<td class="taR">-</td>';
  10537. else
  10538. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10539. $total += $sumPrice;
  10540. }
  10541. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10542. $data ['companyTotalHtml'] = $collectHtml;
  10543. $data ['total'] = $total;
  10544. $data ['nature'] =$nature;
  10545. $data ['year'] = $year;
  10546. $data ['memu'] = "receipt";
  10547. $data ['staff'] = $this->staff;
  10548. $data ['receiptMemu'] = 'companyCategoryCollect';
  10549. $data ['verifyId'] = $this->verifyId;
  10550. $data ['executeId'] = $this->executeId;
  10551. if ($year <= date ( "Y" )) {
  10552. Doo::loadModel ( 'receipt' );
  10553. $receipt = new receipt ();
  10554. $receiptList = $receipt->find ( array (
  10555. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10556. 'asArray' => true
  10557. ) );
  10558. if (empty ( $receiptList )) { // generated files
  10559. ob_start ();
  10560. $this->render ( "/admin/saeaStaffCollectB", $data );
  10561. $this->cacheFile ( $path );
  10562. die ();
  10563. }
  10564. }
  10565. $this->render ( "/admin/saeaStaffCollectB", $data );
  10566. }
  10567. function staffCollectBak() {
  10568. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10569. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10570. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10571. $this->showCache ( $path );
  10572. Doo::loadModel ( 'statistics' );
  10573. $statistics = new statistics ();
  10574. Doo::loadModel ( "receiptDetail" );
  10575. $receiptDetail = new receiptDetail ();
  10576. Doo::loadModel ( 'L_category' );
  10577. $Lcategory = new L_category ();
  10578. Doo::loadModel ( 'accountItem' );
  10579. $accountItem = new accountItem ();
  10580. Doo::loadModel ( 'staff' );
  10581. $staff = new staff ();
  10582. Doo::loadModel ( 'itemStatistics' );
  10583. $itemStatistics = new itemStatistics ();
  10584. $itemStatisticsList = $itemStatistics->find ( array (
  10585. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10586. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10587. 'groupby' => 'staff,itemCategory,Month(date)',
  10588. 'asArray' => true
  10589. ) );
  10590. $itemCategoryList = $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' => 'cid,itemCategory,Month(date)',
  10594. 'asArray' => true
  10595. ) );
  10596. $LcategoryList = $Lcategory->find ( array (
  10597. 'asArray' => true
  10598. ) );
  10599. $staffList = $staff->find ( array (
  10600. 'asArray' => true
  10601. ) );
  10602. $htmlArray = array ();
  10603. foreach ( $LcategoryList as $value ) {
  10604. $htmlArray [$value ['title']] = array ();
  10605. foreach ( $staffList as $v ) {
  10606. if ($value ['cid'] == $v ['cid']) {
  10607. $html = "";
  10608. $falg = true;
  10609. $staffSumPrice = 0;
  10610. foreach ( $itemStatisticsList as $a ) {
  10611. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10612. if (empty ( $a ['price'] )) {
  10613. $html .= '<td class="taR">-</td>';
  10614. $falg = false;
  10615. break;
  10616. } else {
  10617. $staffSumPrice += $a ['price'];
  10618. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10619. $falg = false;
  10620. break;
  10621. }
  10622. }
  10623. }
  10624. if ($falg) {
  10625. $html .= '<td class="taR">-</td>';
  10626. $falg = true;
  10627. }
  10628. $falg = true;
  10629. foreach ( $itemStatisticsList as $a ) {
  10630. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10631. if (empty ( $a ['price'] )) {
  10632. $html .= '<td class="taR">-</td>';
  10633. $falg = false;
  10634. break;
  10635. } else {
  10636. $staffSumPrice += $a ['price'];
  10637. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10638. $falg = false;
  10639. break;
  10640. }
  10641. }
  10642. }
  10643. if ($falg) {
  10644. $html .= '<td class="taR">-</td>';
  10645. $falg = true;
  10646. }
  10647. $falg = true;
  10648. foreach ( $itemStatisticsList as $a ) {
  10649. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10650. if (empty ( $a ['price'] )) {
  10651. $html .= '<td class="taR">-</td>';
  10652. $falg = false;
  10653. break;
  10654. } else {
  10655. $staffSumPrice += $a ['price'];
  10656. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10657. $falg = false;
  10658. break;
  10659. }
  10660. }
  10661. }
  10662. if ($falg) {
  10663. $html .= '<td class="taR">-</td>';
  10664. $falg = true;
  10665. }
  10666. $falg = true;
  10667. foreach ( $itemStatisticsList as $a ) {
  10668. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10669. if (! empty ( $a ['price'] )) {
  10670. $staffSumPrice += $a ['price'];
  10671. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10672. $falg = false;
  10673. break;
  10674. } else {
  10675. $html .= '<td class="taR">-</td>';
  10676. $falg = false;
  10677. break;
  10678. }
  10679. }
  10680. }
  10681. if ($falg) {
  10682. $html .= '<td class="taR">-</td>';
  10683. $falg = true;
  10684. }
  10685. $falg = true;
  10686. foreach ( $itemStatisticsList as $a ) {
  10687. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10688. if (! empty ( $a ['price'] )) {
  10689. $staffSumPrice += $a ['price'];
  10690. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10691. $falg = false;
  10692. break;
  10693. } else {
  10694. $html .= '<td class="taR">-</td>';
  10695. $falg = false;
  10696. break;
  10697. }
  10698. }
  10699. }
  10700. if ($falg) {
  10701. $html .= '<td class="taR">-</td>';
  10702. $falg = true;
  10703. }
  10704. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10705. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10706. }
  10707. }
  10708. /* -- --- */
  10709. // 合计费用
  10710. $cateHtml = "";
  10711. $catePrice = 0;
  10712. $cateFalg = true;
  10713. foreach ( $itemCategoryList as $l ) {
  10714. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10715. if (empty ( $l ['price'] )) {
  10716. $cateHtml .= '<td class="colGreen taR">-</td>';
  10717. $cateFalg = false;
  10718. break;
  10719. } else {
  10720. $catePrice += $l ['price'];
  10721. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10722. $cateFalg = false;
  10723. break;
  10724. }
  10725. }
  10726. }
  10727. if ($cateFalg) {
  10728. $cateHtml .= '<td class="colGreen taR">-</td>';
  10729. $cateFalg = true;
  10730. }
  10731. $cateFalg = true;
  10732. foreach ( $itemCategoryList as $l ) {
  10733. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10734. if (empty ( $l ['price'] )) {
  10735. $cateHtml .= '<td class="colGreen taR">-</td>';
  10736. $cateFalg = false;
  10737. break;
  10738. } else {
  10739. $catePrice += $l ['price'];
  10740. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10741. $cateFalg = false;
  10742. break;
  10743. }
  10744. }
  10745. }
  10746. if ($cateFalg) {
  10747. $cateHtml .= '<td class="colGreen taR">-</td>';
  10748. $cateFalg = true;
  10749. }
  10750. $cateFalg = true;
  10751. foreach ( $itemCategoryList as $l ) {
  10752. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10753. if (empty ( $l ['price'] )) {
  10754. $cateHtml .= '<td class="colGreen taR">-</td>';
  10755. $cateFalg = false;
  10756. break;
  10757. } else {
  10758. $catePrice += $l ['price'];
  10759. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10760. $cateFalg = false;
  10761. break;
  10762. }
  10763. }
  10764. }
  10765. if ($cateFalg) {
  10766. $cateHtml .= '<td class="colGreen taR">-</td>';
  10767. $cateFalg = true;
  10768. }
  10769. $cateFalg = true;
  10770. foreach ( $itemCategoryList as $l ) {
  10771. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10772. if (empty ( $l ['price'] )) {
  10773. $cateHtml .= '<td class="colGreen taR">-</td>';
  10774. $cateFalg = false;
  10775. break;
  10776. } else {
  10777. $catePrice += $l ['price'];
  10778. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10779. $cateFalg = false;
  10780. break;
  10781. }
  10782. }
  10783. }
  10784. if ($cateFalg) {
  10785. $cateHtml .= '<td class="colGreen taR">-</td>';
  10786. $cateFalg = true;
  10787. }
  10788. $cateFalg = true;
  10789. foreach ( $itemCategoryList as $l ) {
  10790. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10791. if (empty ( $l ['price'] )) {
  10792. $cateHtml .= '<td class="colGreen taR">-</td>';
  10793. $cateFalg = false;
  10794. break;
  10795. } else {
  10796. $catePrice += $l ['price'];
  10797. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10798. $cateFalg = false;
  10799. break;
  10800. }
  10801. }
  10802. }
  10803. if ($cateFalg) {
  10804. $cateHtml .= '<td class="colGreen taR">-</td>';
  10805. $cateFalg = true;
  10806. }
  10807. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10808. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10809. /* -- --- */
  10810. }
  10811. // print_r($htmlArray);die;
  10812. $data ['htmlArray'] = $htmlArray;
  10813. // statistics html
  10814. $stList = $statistics->getOne ( array (
  10815. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10816. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10817. 'groupby' => 'Month(date)',
  10818. 'asArray' => true
  10819. ) );
  10820. if (empty ( $stList ))
  10821. $stList = array (
  10822. 'rePrice' => 0,
  10823. 'agPrice' => 0
  10824. );
  10825. $data ['stList'] = array (
  10826. 'rePrice' => $stList ['rePrice'],
  10827. 'agPrice' => $stList ['agPrice'],
  10828. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10829. );
  10830. $monthHtml = "";
  10831. for($i = 1; $i <= 12; $i ++) {
  10832. if ($i == $month)
  10833. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10834. else
  10835. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10836. }
  10837. $data ['monthHtml'] = $monthHtml;
  10838. $data ['year'] = $year;
  10839. $data ['month'] = $month;
  10840. $data ['memu'] = "receipt";
  10841. $data ['staff'] = $this->staff;
  10842. $data ['receiptMemu'] = 'companyCategoryCollect';
  10843. $data ['verifyId'] = $this->verifyId;
  10844. $data ['executeId'] = $this->executeId;
  10845. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10846. Doo::loadModel ( 'receipt' );
  10847. $receipt = new receipt ();
  10848. $receiptList = $receipt->find ( array (
  10849. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10850. 'asArray' => true
  10851. ) );
  10852. if (empty ( $receiptList )) { // generated files
  10853. ob_start ();
  10854. $this->render ( "/admin/saeaStaffCollect", $data );
  10855. $this->cacheFile ( $path );
  10856. die ();
  10857. }
  10858. }
  10859. $this->render ( "/admin/saeaStaffCollect", $data );
  10860. }
  10861. /**
  10862. * 日常收支
  10863. */
  10864. function payments() {
  10865. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10866. Doo::loadModel ( "execute" );
  10867. $execute = new execute ();
  10868. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10869. die ( 'illegal request' );
  10870. }
  10871. Doo::loadModel ( "accountBook" );
  10872. $accountBook = new accountBook ();
  10873. Doo::loadModel ( "accountBookStatistics" );
  10874. $accountBookStatistics = new accountBookStatistics ();
  10875. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10876. $list = $accountBook->getAccountBookByLimit ( 10 );
  10877. $data ['date'] = date ( "Y-m-d" );
  10878. $data ['statisticsList'] = $statisticsList;
  10879. $data ['list'] = $list;
  10880. $data ['memu'] = "receipt";
  10881. $data ['staff'] = $this->staff;
  10882. $data ['receiptMemu'] = 'payments';
  10883. $data ['verifyId'] = $this->verifyId;
  10884. $data ['executeId'] = $this->executeId;
  10885. $this->render ( "/expenses/payments", $data );
  10886. }
  10887. function paymentsIncomeDo() {
  10888. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10889. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10890. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10891. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10892. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10893. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10894. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10895. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10896. Doo::loadClass ( 'XDeode' );
  10897. $XDeode = new XDeode ( 5 );
  10898. Doo::loadModel ( "accountBook" );
  10899. Doo::loadModel ( "accountBookStatistics" );
  10900. Doo::loadModel ( 'wasteBook' );
  10901. // 记录流水时银行的转换
  10902. $accountBank = '';
  10903. if ($receivedBank == '纵横广发') {
  10904. $accountBank = 'CGBDeposit';
  10905. } elseif ($receivedBank == '纵横工行') {
  10906. $accountBank = 'ICBCDeposit';
  10907. } elseif ($receivedBank == '华润银行') {
  10908. $accountBank = 'HUADeposit';
  10909. } elseif ($receivedBank == '个人广发') {
  10910. $accountBank = 'PersonalDeposit';
  10911. }
  10912. if (empty ( $accountBank ))
  10913. die ( 'illegal request' );
  10914. if($accountType == 11 || $accountType == 12){
  10915. if($accountType == 11){
  10916. $receivedBank = '纵横广发';
  10917. }elseif($accountType == 12){
  10918. $receivedBank = '纵横工行';
  10919. }
  10920. // 添加一条收入
  10921. $accountBook = new accountBook ();
  10922. $accountBook->accountType = $accountType;
  10923. $accountBook->accountMsg = $accountMsg;
  10924. $accountBook->receivedPrice = $receivedPrice;
  10925. $accountBook->receivedMsg = $receivedMsg;
  10926. $accountBook->receivedBank = $receivedBank;
  10927. $accountBook->receivedDate = $receivedDate;
  10928. $accountBook->remarks = $remarks;
  10929. $accountBook->expensesType = 1;
  10930. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10931. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10932. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10933. $inComeId = $accountBook->insert ();
  10934. // 收支汇总-添加一条收入日常汇总
  10935. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10936. $accountBookStatistics = new accountBookStatistics ();
  10937. $item = array (
  10938. 'date' => date ( "Y-m-d" ),
  10939. 'accountType' => $abDetail ['accountType'],
  10940. 'accountMsg' => $abDetail ['accountMsg'],
  10941. 'aid' => $abDetail ['aid'],
  10942. 'inComePrice' => $abDetail ['receivedPrice'],
  10943. 'expensesType' => $abDetail ['expensesType']
  10944. );
  10945. $accountBookStatistics->setAccountBookStatistics ( $item );
  10946. //流水支出
  10947. // if($accountBank=='CGBDeposit'){
  10948. // $dailyExpenditureType='8';
  10949. // }elseif($accountBank=='ICBCDeposit'){
  10950. // $dailyExpenditureType='9';
  10951. // }elseif($accountBank=='PersonalDeposit'){
  10952. // $dailyExpenditureType='10';
  10953. // }elseif($accountBank=='HUADeposit'){
  10954. // $dailyExpenditureType='11';
  10955. // }
  10956. //
  10957. // $wasteBook = new wasteBook ();
  10958. // $itemWaste = array (
  10959. // 'expensesType' => 2,
  10960. // 'accountType' => 5,
  10961. // 'accountPriceShow' => $receivedPrice,
  10962. // 'accountPrice' => - $receivedPrice,
  10963. // 'dataID' => $inComeId,
  10964. // 'dailyExpenditureType' => $dailyExpenditureType,
  10965. // 'accountBank' => $accountBank,
  10966. // 'category' => $this->staff [0] ['category'],
  10967. // 'cid' => $this->staff [0] ['cid'],
  10968. // 'name' => $this->staff [0] ['username'],
  10969. // 'sid' => $this->staff [0] ['sid'],
  10970. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10971. // );
  10972. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10973. // 添加收入流水
  10974. if($accountType == 11){
  10975. $accountBank = 'CGBDeposit';
  10976. }elseif($accountType == 12){
  10977. $accountBank = 'ICBCDeposit';
  10978. }
  10979. $wasteBook = new wasteBook ();
  10980. $itemWaste = array (
  10981. 'accountPriceShow' => $receivedPrice,
  10982. 'accountPrice' => $receivedPrice,
  10983. 'expensesType' => 1,
  10984. 'accountType' => 6, // 流水类型
  10985. 'dataID' => $inComeId,
  10986. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10987. 'accountBank' => $accountBank,
  10988. 'category' => $this->staff [0] ['category'],
  10989. 'cid' => $this->staff [0] ['cid'],
  10990. 'name' => $this->staff [0] ['username'],
  10991. 'sid' => $this->staff [0] ['sid'],
  10992. 'inputDate' => date ( "Y-m-d H:i:s" )
  10993. );
  10994. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10995. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10996. if ($receivedBank == '个人广发') {
  10997. die ( '个人广发 illegal request' );
  10998. }
  10999. // 添加一条收入
  11000. $accountBook = new accountBook ();
  11001. $accountBook->accountType = 10;
  11002. $accountBook->accountMsg = $accountMsg;
  11003. $accountBook->receivedPrice = $receivedPrice;
  11004. $accountBook->receivedMsg = $receivedMsg;
  11005. $accountBook->receivedBank = $receivedBank;
  11006. $accountBook->receivedDate = $receivedDate;
  11007. $accountBook->remarks = $remarks;
  11008. $accountBook->expensesType = 1;
  11009. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11010. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11011. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11012. $inComeId = $accountBook->insert ();
  11013. // 收支汇总-添加一条收入日常汇总
  11014. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  11015. $accountBookStatistics = new accountBookStatistics ();
  11016. $item = array (
  11017. 'date' => date ( "Y-m-d" ),
  11018. 'accountType' => $abDetail ['accountType'],
  11019. 'accountMsg' => $abDetail ['accountMsg'],
  11020. 'aid' => $abDetail ['aid'],
  11021. 'inComePrice' => $abDetail ['receivedPrice'],
  11022. 'expensesType' => $abDetail ['expensesType']
  11023. );
  11024. $accountBookStatistics->setAccountBookStatistics ( $item );
  11025. // 添加收入流水
  11026. $wasteBook = new wasteBook ();
  11027. $itemWaste = array (
  11028. 'accountPriceShow' => $receivedPrice,
  11029. 'accountPrice' => $receivedPrice,
  11030. 'expensesType' => 1,
  11031. 'accountType' => 6, // 流水类型
  11032. 'dataID' => $inComeId,
  11033. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11034. 'accountBank' => $accountBank,
  11035. 'category' => $this->staff [0] ['category'],
  11036. 'cid' => $this->staff [0] ['cid'],
  11037. 'name' => $this->staff [0] ['username'],
  11038. 'sid' => $this->staff [0] ['sid'],
  11039. 'inputDate' => date ( "Y-m-d H:i:s" )
  11040. );
  11041. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11042. // 添加一条理财支出
  11043. $accountBank = 'CGBDeposit';
  11044. $expenditureBank = '纵横广发';
  11045. $dailyExpenditureType = 4;
  11046. if ($accountType == 9) {
  11047. $accountBank = 'ICBCDeposit';
  11048. $expenditureBank = '纵横工行';
  11049. $dailyExpenditureType = 6;
  11050. }
  11051. $accountBook = new accountBook ();
  11052. $accountBook->expensesType = 2;
  11053. $accountBook->expenditureType = $dailyExpenditureType;
  11054. $accountBook->expenditureMsg = $accountMsg;
  11055. $accountBook->expenditurePrice = $receivedPrice;
  11056. $accountBook->expenditureBank = $expenditureBank;
  11057. $accountBook->expenditureDate = $receivedDate;
  11058. $accountBook->remarks = $remarks;
  11059. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11060. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11061. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11062. $id = $accountBook->insert ();
  11063. // 收支汇总-添加一条理财支出汇总
  11064. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11065. $accountBookStatistics = new accountBookStatistics ();
  11066. $item = array (
  11067. 'date' => date ( "Y-m-d" ),
  11068. 'accountType' => $abDetail ['accountType'],
  11069. 'accountMsg' => $abDetail ['accountMsg'],
  11070. 'aid' => $abDetail ['aid'],
  11071. 'financingPrice' => - $receivedPrice,
  11072. 'expensesType' => 3
  11073. );
  11074. $accountBookStatistics->setAccountBookStatistics ( $item );
  11075. // 添加一条支出理财流水
  11076. $accountTypeWaste = 5;
  11077. if ($accountMsg == '公司固定') {
  11078. $accountTypeWaste = 9;
  11079. } elseif ($accountMsg == '公司活期') {
  11080. $accountTypeWaste = 10;
  11081. } elseif ($accountMsg == '个人(GR)') {
  11082. $accountBank = 'PersonalDeposit';
  11083. }
  11084. $itemWaste = array (
  11085. 'expensesType' => 2,
  11086. 'accountType' => $accountTypeWaste,
  11087. 'accountPriceShow' => $receivedPrice,
  11088. 'accountPrice' => - $receivedPrice,
  11089. 'dataID' => $id,
  11090. 'dailyExpenditureType' => $dailyExpenditureType,
  11091. 'accountBank' => $accountBank,
  11092. 'category' => $this->staff [0] ['category'],
  11093. 'cid' => $this->staff [0] ['cid'],
  11094. 'name' => $this->staff [0] ['username'],
  11095. 'sid' => $this->staff [0] ['sid'],
  11096. 'inputDate' => date ( "Y-m-d H:i:s" )
  11097. );
  11098. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11099. } elseif ($accountType == 1) {
  11100. if ($receivedBank == '个人广发')
  11101. die ( 'illegal request' );
  11102. // 添加一条收入
  11103. $accountBook = new accountBook ();
  11104. $accountBook->accountType = $accountType;
  11105. $accountBook->accountMsg = $accountMsg;
  11106. $accountBook->receivedPrice = $receivedPrice;
  11107. $accountBook->receivedMsg = $receivedMsg;
  11108. $accountBook->receivedBank = $receivedBank;
  11109. $accountBook->receivedDate = $receivedDate;
  11110. $accountBook->remarks = $remarks;
  11111. $accountBook->expensesType = 1;
  11112. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11113. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11114. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11115. $id = $accountBook->insert ();
  11116. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11117. // 收支汇总-添加一条收入日常汇总
  11118. $accountBookStatistics = new accountBookStatistics ();
  11119. $item = array (
  11120. 'date' => date ( "Y-m-d" ),
  11121. 'accountType' => $abDetail ['accountType'],
  11122. 'accountMsg' => $abDetail ['accountMsg'],
  11123. 'aid' => $abDetail ['aid'],
  11124. 'expensesType' => $abDetail ['expensesType']
  11125. );
  11126. if ($abDetail ['accountType'] == 8) {
  11127. $item += array (
  11128. 'inComePrice' => $abDetail ['receivedPrice']
  11129. );
  11130. } else {
  11131. $item += array (
  11132. 'inComePrice' => $abDetail ['receivedPrice']
  11133. );
  11134. }
  11135. $accountBookStatistics->setAccountBookStatistics ( $item );
  11136. // 流水存储方向
  11137. $itemWaste = array (
  11138. 'accountType' => 6
  11139. ); // 流水类型
  11140. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  11141. // }else
  11142. if ($accountMsg == '活期理财收益') {
  11143. $itemWaste = array (
  11144. 'accountType' => 10
  11145. ); // 流水类型
  11146. }
  11147. // 添加收入流水
  11148. $wasteBook = new wasteBook ();
  11149. $itemWaste += array (
  11150. 'accountPrice' => $receivedPrice,
  11151. 'accountPriceShow' => $receivedPrice,
  11152. 'expensesType' => 1,
  11153. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11154. 'dataID' => $id,
  11155. 'accountBank' => $accountBank,
  11156. 'category' => $this->staff [0] ['category'],
  11157. 'cid' => $this->staff [0] ['cid'],
  11158. 'name' => $this->staff [0] ['username'],
  11159. 'sid' => $this->staff [0] ['sid'],
  11160. 'inputDate' => date ( "Y-m-d H:i:s" )
  11161. );
  11162. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11163. } else { // 普通日常收入处理
  11164. // 添加一条收入
  11165. $accountBook = new accountBook ();
  11166. $accountBook->accountType = $accountType;
  11167. $accountBook->accountMsg = $accountMsg;
  11168. $accountBook->receivedPrice = $receivedPrice;
  11169. $accountBook->receivedMsg = $receivedMsg;
  11170. $accountBook->receivedBank = $receivedBank;
  11171. $accountBook->receivedDate = $receivedDate;
  11172. $accountBook->remarks = $remarks;
  11173. $accountBook->expensesType = 1;
  11174. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11175. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11176. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11177. $id = $accountBook->insert ();
  11178. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11179. // 收支汇总-添加一条收入日常汇总
  11180. $accountBookStatistics = new accountBookStatistics ();
  11181. $item = array (
  11182. 'date' => date ( "Y-m-d" ),
  11183. 'accountType' => $abDetail ['accountType'],
  11184. 'accountMsg' => $abDetail ['accountMsg'],
  11185. 'aid' => $abDetail ['aid'],
  11186. 'expensesType' => $abDetail ['expensesType']
  11187. );
  11188. if ($abDetail ['accountType'] == 8) {
  11189. $item += array (
  11190. 'inComePrice' => $abDetail ['receivedPrice']
  11191. );
  11192. } else {
  11193. $item += array (
  11194. 'inComePrice' => $abDetail ['receivedPrice']
  11195. );
  11196. }
  11197. $accountBookStatistics->setAccountBookStatistics ( $item );
  11198. // 添加收入流水
  11199. $itemWaste = array (
  11200. 'accountPrice' => $receivedPrice
  11201. );
  11202. if ($receivedBank == '个人广发') {
  11203. $itemWaste = array (
  11204. 'accountPrice' => - $receivedPrice
  11205. );
  11206. }
  11207. $wasteBook = new wasteBook ();
  11208. $itemWaste += array (
  11209. 'accountPriceShow' => $receivedPrice,
  11210. 'expensesType' => 1,
  11211. 'accountType' => 6, // 流水类型
  11212. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11213. 'dataID' => $id,
  11214. 'accountBank' => $accountBank,
  11215. 'category' => $this->staff [0] ['category'],
  11216. 'cid' => $this->staff [0] ['cid'],
  11217. 'name' => $this->staff [0] ['username'],
  11218. 'sid' => $this->staff [0] ['sid'],
  11219. 'inputDate' => date ( "Y-m-d H:i:s" )
  11220. );
  11221. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11222. }
  11223. }
  11224. return '/payments';
  11225. }
  11226. function paymentsExpenditureDo() {
  11227. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11228. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11229. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11230. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11231. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11232. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11233. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11234. // 理财支出特殊处理
  11235. Doo::loadModel ( "accountBook" );
  11236. Doo::loadModel ( "accountBookStatistics" );
  11237. Doo::loadModel ( 'wasteBook' );
  11238. $accountBank = '';
  11239. if ($expenditureBank == '纵横广发') {
  11240. $accountBank = 'CGBDeposit';
  11241. } elseif ($expenditureBank == '纵横工行') {
  11242. $accountBank = 'ICBCDeposit';
  11243. } elseif ($expenditureBank == '华润银行') {
  11244. $accountBank = 'HUADeposit';
  11245. } elseif ($expenditureBank == '个人广发') {
  11246. $accountBank = 'PersonalDeposit';
  11247. }
  11248. if (empty ( $accountBank ))
  11249. die ( 'illegal request' );
  11250. if($expenditureType == 8 || $expenditureType == 9){
  11251. if($expenditureType == 8 ){
  11252. $expenditureBank='纵横广发';
  11253. }elseif($expenditureType == 9){
  11254. $expenditureBank='纵横工行';
  11255. }
  11256. // 添加一笔日常支出
  11257. $accountBook = new accountBook ();
  11258. $accountBook->expensesType = 2;
  11259. $accountBook->expenditureType = $expenditureType;
  11260. $accountBook->expenditureMsg = $expenditureMsg;
  11261. $accountBook->expenditurePrice = $expenditurePrice;
  11262. $accountBook->expenditureBank = $expenditureBank;
  11263. $accountBook->expenditureDate = $expenditureDate;
  11264. $accountBook->remarks = $remarks;
  11265. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11266. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11267. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11268. $expenditureId = $accountBook->insert ();
  11269. // 添加日常支出汇总
  11270. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11271. $accountBookStatistics = new accountBookStatistics ();
  11272. $item = array (
  11273. 'date' => date ( "Y-m-d" ),
  11274. 'expenditureType' => $abDetail ['expenditureType'],
  11275. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11276. 'aid' => $abDetail ['aid'],
  11277. 'payPrice' => $abDetail ['expenditurePrice'],
  11278. 'expensesType' => $abDetail ['expensesType']
  11279. );
  11280. $accountBookStatistics->setAccountBookStatistics ( $item );
  11281. // 公司日常支出流水
  11282. if($expenditureType == 8 ){
  11283. $accountBank = 'CGBDeposit';
  11284. }elseif($expenditureType == 9){
  11285. $accountBank = 'ICBCDeposit';
  11286. }
  11287. if($accountBank=='CGBDeposit'){
  11288. $dailyExpenditureType='8';
  11289. }elseif($accountBank=='ICBCDeposit'){
  11290. $dailyExpenditureType='9';
  11291. }elseif($accountBank=='PersonalDeposit'){
  11292. $dailyExpenditureType='10';
  11293. }elseif($accountBank=='HUADeposit'){
  11294. $dailyExpenditureType='11';
  11295. }
  11296. $wasteBook = new wasteBook ();
  11297. $itemWaste = array (
  11298. 'expensesType' => 2,
  11299. 'accountType' => 5,
  11300. 'dailyExpenditureType' => $dailyExpenditureType,
  11301. 'accountPriceShow' => $expenditurePrice,
  11302. 'accountPrice' => - $expenditurePrice,
  11303. 'dataID' => $expenditureId,
  11304. 'accountBank' => $accountBank,
  11305. 'category' => $this->staff [0] ['category'],
  11306. 'cid' => $this->staff [0] ['cid'],
  11307. 'name' => $this->staff [0] ['username'],
  11308. 'sid' => $this->staff [0] ['sid'],
  11309. 'inputDate' => date ( "Y-m-d H:i:s" )
  11310. );
  11311. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11312. // 添加一笔收入流水
  11313. // if($expenditureType==8){
  11314. // $dailyIncomeType='11';
  11315. // }elseif($expenditureType==9){
  11316. // $dailyIncomeType='12';
  11317. // }
  11318. // $wasteBook = new wasteBook ();
  11319. // $itemWaste = array (
  11320. // 'expensesType' => 1,
  11321. // 'accountType' => 6,
  11322. // 'accountPriceShow' => $expenditurePrice,
  11323. // 'accountPrice' => $expenditurePrice,
  11324. // 'dataID' => $expenditureId,
  11325. //
  11326. // 'dailyIncomeType' => $dailyIncomeType,
  11327. // 'accountBank' => $accountBank,
  11328. // 'category' => $this->staff [0] ['category'],
  11329. // 'cid' => $this->staff [0] ['cid'],
  11330. // 'name' => $this->staff [0] ['username'],
  11331. // 'sid' => $this->staff [0] ['sid'],
  11332. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11333. // );
  11334. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11335. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11336. if ($expenditureBank == '个人广发') {
  11337. die ( '个人广发 illegal request' );
  11338. }
  11339. // 添加一笔日常支出
  11340. $accountBook = new accountBook ();
  11341. $accountBook->expensesType = 2;
  11342. $accountBook->expenditureType = 7;
  11343. $accountBook->expenditureMsg = $expenditureMsg;
  11344. $accountBook->expenditurePrice = $expenditurePrice;
  11345. $accountBook->expenditureBank = $expenditureBank;
  11346. $accountBook->expenditureDate = $expenditureDate;
  11347. $accountBook->remarks = $remarks;
  11348. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11349. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11350. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11351. $expenditureId = $accountBook->insert ();
  11352. // 添加日常支出汇总
  11353. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11354. $accountBookStatistics = new accountBookStatistics ();
  11355. $item = array (
  11356. 'date' => date ( "Y-m-d" ),
  11357. 'expenditureType' => $abDetail ['expenditureType'],
  11358. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11359. 'aid' => $abDetail ['aid'],
  11360. 'payPrice' => $abDetail ['expenditurePrice'],
  11361. 'expensesType' => $abDetail ['expensesType']
  11362. );
  11363. $accountBookStatistics->setAccountBookStatistics ( $item );
  11364. // 公司日常支出流水
  11365. $wasteBook = new wasteBook ();
  11366. $itemWaste = array (
  11367. 'accountPrice' => - $expenditurePrice
  11368. );
  11369. if ($expenditureBank == '个人广发') {
  11370. $itemWaste = array (
  11371. 'accountPrice' => $expenditurePrice
  11372. );
  11373. }
  11374. $itemWaste += array (
  11375. 'expensesType' => 2,
  11376. 'accountType' => 5,
  11377. 'dailyExpenditureType' => $expenditureType,
  11378. 'accountPriceShow' => $expenditurePrice,
  11379. 'accountPrice' => - $expenditurePrice,
  11380. 'dataID' => $expenditureId,
  11381. 'accountBank' => $accountBank,
  11382. 'category' => $this->staff [0] ['category'],
  11383. 'cid' => $this->staff [0] ['cid'],
  11384. 'name' => $this->staff [0] ['username'],
  11385. 'sid' => $this->staff [0] ['sid'],
  11386. 'inputDate' => date ( "Y-m-d H:i:s" )
  11387. );
  11388. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11389. // 添加一笔理财收入
  11390. $accountBank = 'CGBDeposit';
  11391. $dailyIncomeType = 7;
  11392. $receivedBank = '纵横广发';
  11393. if ($expenditureType == 6) {
  11394. $accountBank = 'ICBCDeposit';
  11395. $receivedBank = '纵横工行';
  11396. $dailyIncomeType = 9;
  11397. }
  11398. $accountBook = new accountBook ();
  11399. $accountBook->expensesType = 1;
  11400. $accountBook->accountType = $dailyIncomeType;
  11401. $accountBook->accountMsg = $expenditureMsg;
  11402. $accountBook->receivedPrice = $expenditurePrice;
  11403. $accountBook->receivedBank = $receivedBank;
  11404. $accountBook->receivedDate = $expenditureDate;
  11405. $accountBook->remarks = $remarks;
  11406. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11407. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11408. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11409. $id = $accountBook->insert ();
  11410. // 添加日常理财收入汇总
  11411. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11412. $accountBookStatistics = new accountBookStatistics ();
  11413. $item = array (
  11414. 'date' => date ( "Y-m-d" ),
  11415. 'expenditureType' => $abDetail ['expenditureType'],
  11416. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11417. 'aid' => $abDetail ['aid'],
  11418. 'financingPrice' => $expenditurePrice,
  11419. 'expensesType' => 3
  11420. );
  11421. $accountBookStatistics->setAccountBookStatistics ( $item );
  11422. // 添加一笔收入流水
  11423. if ($expenditureMsg == '公司固定') {
  11424. $accountTypeWaste = 9;
  11425. } elseif ($expenditureMsg == '公司活期') {
  11426. $accountTypeWaste = 10;
  11427. } elseif ($expenditureMsg == '个人(GR)') {
  11428. $accountBank = 'PersonalDeposit';
  11429. }
  11430. $itemWaste = array (
  11431. 'expensesType' => 1,
  11432. 'accountType' => $accountTypeWaste,
  11433. 'accountPriceShow' => $expenditurePrice,
  11434. 'accountPrice' => $expenditurePrice,
  11435. 'dataID' => $id,
  11436. 'dailyIncomeType' => $dailyIncomeType,
  11437. 'accountBank' => $accountBank,
  11438. 'category' => $this->staff [0] ['category'],
  11439. 'cid' => $this->staff [0] ['cid'],
  11440. 'name' => $this->staff [0] ['username'],
  11441. 'sid' => $this->staff [0] ['sid'],
  11442. 'inputDate' => date ( "Y-m-d H:i:s" )
  11443. );
  11444. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11445. } else {
  11446. // 添加一笔日常支出
  11447. $accountBook = new accountBook ();
  11448. $accountBook->expensesType = 2;
  11449. $accountBook->expenditureType = $expenditureType;
  11450. $accountBook->expenditureMsg = $expenditureMsg;
  11451. $accountBook->expenditurePrice = $expenditurePrice;
  11452. $accountBook->expenditureBank = $expenditureBank;
  11453. $accountBook->expenditureDate = $expenditureDate;
  11454. $accountBook->remarks = $remarks;
  11455. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11456. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11457. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11458. $id = $accountBook->insert ();
  11459. // 添加日常支出汇总
  11460. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11461. $accountBookStatistics = new accountBookStatistics ();
  11462. $item = array (
  11463. 'date' => date ( "Y-m-d" ),
  11464. 'expenditureType' => $abDetail ['expenditureType'],
  11465. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11466. 'aid' => $abDetail ['aid'],
  11467. 'expensesType' => $abDetail ['expensesType']
  11468. );
  11469. if ($expenditureType == 5) {
  11470. $item += array (
  11471. 'payPrice' => - $abDetail ['expenditurePrice']
  11472. );
  11473. } else {
  11474. $item += array (
  11475. 'payPrice' => $abDetail ['expenditurePrice']
  11476. );
  11477. }
  11478. $accountBookStatistics->setAccountBookStatistics ( $item );
  11479. // 公司日常支出流水
  11480. $wasteBook = new wasteBook ();
  11481. $itemWaste = array (
  11482. 'accountPrice' => - $expenditurePrice
  11483. );
  11484. if ($expenditureBank == '个人广发') {
  11485. $itemWaste = array (
  11486. 'accountPrice' => $expenditurePrice
  11487. );
  11488. }
  11489. $itemWaste += array (
  11490. 'expensesType' => 2,
  11491. 'accountType' => 5,
  11492. 'accountPriceShow' => $expenditurePrice,
  11493. 'dataID' => $id,
  11494. 'dailyExpenditureType' => $expenditureType,
  11495. 'accountBank' => $accountBank,
  11496. 'category' => $this->staff [0] ['category'],
  11497. 'cid' => $this->staff [0] ['cid'],
  11498. 'name' => $this->staff [0] ['username'],
  11499. 'sid' => $this->staff [0] ['sid'],
  11500. 'inputDate' => date ( "Y-m-d H:i:s" )
  11501. );
  11502. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11503. }
  11504. }
  11505. return '/payments';
  11506. }
  11507. /**
  11508. * 添加支出
  11509. */
  11510. function paymentsExpenditureDo_() {
  11511. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11512. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11513. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11514. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11515. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11516. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11517. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11518. $dailyExpenditureType = '';
  11519. $accountTypeWaste = 5;
  11520. $accountBank = '';
  11521. if ($expenditureBank == '纵横广发') {
  11522. $accountBank = 'CGBDeposit';
  11523. } elseif ($expenditureBank == '纵横工行') {
  11524. $accountBank = 'ICBCDeposit';
  11525. } elseif ($expenditureBank == '华润银行') {
  11526. $accountBank = 'HUADeposit';
  11527. } elseif ($expenditureBank == '个人广发') {
  11528. $accountBank = 'PersonalDeposit';
  11529. }
  11530. if (empty ( $accountBank ))
  11531. die ( 'illegal request' );
  11532. $itemWaste = array (
  11533. 'accountPrice' => - $expenditurePrice
  11534. );
  11535. if ($expenditureBank == '个人广发') {
  11536. $itemWaste = array (
  11537. 'accountPrice' => $expenditurePrice
  11538. );
  11539. }
  11540. if ($expenditureType == 4 || $expenditureType == 6) {
  11541. $dailyExpenditureType = 4;
  11542. if ($expenditureMsg == '公司固定') {
  11543. $accountTypeWaste = 9;
  11544. } elseif ($expenditureMsg == '公司活期') {
  11545. $accountTypeWaste = 10;
  11546. } elseif ($expenditureMsg == '个人(GR)') {
  11547. $accountBank = 'PersonalDeposit';
  11548. }
  11549. $itemWaste = array (
  11550. 'accountPrice' => $expenditurePrice
  11551. );
  11552. } elseif ($expenditureType == 1) {
  11553. $dailyExpenditureType = 1;
  11554. } elseif ($expenditureType == 2) {
  11555. $dailyExpenditureType = 2;
  11556. } elseif ($expenditureType == 3) {
  11557. $dailyExpenditureType = 3;
  11558. } elseif ($expenditureType == 5) {
  11559. $dailyExpenditureType = 5;
  11560. }
  11561. if (empty ( $dailyExpenditureType ))
  11562. die ( 'illegal request' );
  11563. Doo::loadModel ( "accountBook" );
  11564. $accountBook = new accountBook ();
  11565. $accountBook->expenditureType = $expenditureType;
  11566. $accountBook->expenditureMsg = $expenditureMsg;
  11567. $accountBook->expenditurePrice = $expenditurePrice;
  11568. $accountBook->expenditureBank = $expenditureBank;
  11569. $accountBook->expenditureDate = $expenditureDate;
  11570. $accountBook->remarks = $remarks;
  11571. $accountBook->expensesType = 2;
  11572. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11573. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11574. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11575. $id = $accountBook->insert ();
  11576. //
  11577. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11578. Doo::loadModel ( "accountBookStatistics" );
  11579. $accountBookStatistics = new accountBookStatistics ();
  11580. $item = array (
  11581. 'date' => date ( "Y-m-d" ),
  11582. 'expenditureType' => $abDetail ['expenditureType'],
  11583. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11584. 'aid' => $abDetail ['aid']
  11585. );
  11586. if ($abDetail ['expensesType'] == 2) {
  11587. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11588. $item += array (
  11589. 'financingPrice' => $expenditurePrice,
  11590. 'expensesType' => 3
  11591. );
  11592. } elseif ($abDetail ['expenditureType'] == 5) {
  11593. $item += array (
  11594. 'payPrice' => $abDetail ['expenditurePrice'],
  11595. 'expensesType' => $abDetail ['expensesType']
  11596. );
  11597. } else {
  11598. $item += array (
  11599. 'payPrice' => $abDetail ['expenditurePrice'],
  11600. 'expensesType' => $abDetail ['expensesType']
  11601. );
  11602. }
  11603. }
  11604. $accountBookStatistics->setAccountBookStatistics ( $item );
  11605. // 公司流水记录
  11606. Doo::loadModel ( 'wasteBook' );
  11607. $wasteBook = new wasteBook ();
  11608. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11609. // 银行
  11610. if (empty ( $abDetail )) {
  11611. $itemWaste += array (
  11612. 'accountPriceShow' => $expenditurePrice,
  11613. 'dataID' => $id,
  11614. 'expensesType' => 2,
  11615. 'accountType' => $accountTypeWaste,
  11616. 'dailyExpenditureType' => $expenditureType,
  11617. 'accountBank' => $accountBank,
  11618. 'category' => $this->staff [0] ['category'],
  11619. 'cid' => $this->staff [0] ['cid'],
  11620. 'name' => $this->staff [0] ['username'],
  11621. 'sid' => $this->staff [0] ['sid'],
  11622. 'inputDate' => date ( "Y-m-d H:i:s" )
  11623. );
  11624. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11625. }
  11626. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11627. if ($expenditureType == 4 || $expenditureType == 6) {
  11628. $accountBank = 'CGBDeposit';
  11629. $dailyIncomeType = 7;
  11630. $receivedBank = '纵横广发';
  11631. if ($expenditureType == 6) {
  11632. $accountBank = 'ICBCDeposit';
  11633. $receivedBank = '纵横工行';
  11634. $dailyIncomeType = 9;
  11635. }
  11636. // 添加一笔收入
  11637. $accountBook = new accountBook ();
  11638. $accountBook->accountType = $dailyIncomeType;
  11639. $accountBook->accountMsg = $expenditureMsg;
  11640. $accountBook->receivedPrice = $expenditurePrice;
  11641. $accountBook->receivedBank = $receivedBank;
  11642. $accountBook->receivedDate = $expenditureDate;
  11643. $accountBook->remarks = $remarks;
  11644. $accountBook->expensesType = 1;
  11645. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11646. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11647. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11648. $id = $accountBook->insert ();
  11649. // 添加一笔收入流水
  11650. $itemWaste = array (
  11651. 'accountPriceShow' => $expenditurePrice,
  11652. 'accountPrice' => - $expenditurePrice,
  11653. 'dataID' => $id,
  11654. 'expensesType' => 1,
  11655. 'accountType' => $accountTypeWaste,
  11656. 'dailyIncomeType' => $dailyIncomeType,
  11657. 'accountBank' => $accountBank,
  11658. 'category' => $this->staff [0] ['category'],
  11659. 'cid' => $this->staff [0] ['cid'],
  11660. 'name' => $this->staff [0] ['username'],
  11661. 'sid' => $this->staff [0] ['sid'],
  11662. 'inputDate' => date ( "Y-m-d H:i:s" )
  11663. );
  11664. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11665. }
  11666. }
  11667. return '/payments';
  11668. }
  11669. /**
  11670. * 所有收支
  11671. */
  11672. function paymentsAchieve() {
  11673. $page_size = 12;
  11674. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11675. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11676. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11677. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11678. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11679. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11680. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11681. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11682. Doo::loadModel ( "accountBookStatistics" );
  11683. $accountBookStatistics = new accountBookStatistics ();
  11684. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11685. $data ['statisticsList'] = $statisticsList;
  11686. Doo::loadModel ( "accountBook" );
  11687. $accountBook = new accountBook ();
  11688. $con = '';
  11689. if ($expensesType == 'INCOME')
  11690. $con = ' and expensesType=1 ';
  11691. elseif ($expensesType == 'PAY')
  11692. $con = ' and expensesType=2 ';
  11693. $dateArr = explode ( ':', $date );
  11694. $D1 = $dateString = '';
  11695. $D2 = '';
  11696. if (! empty ( $date )) {
  11697. $D1 = $dateArr [0];
  11698. if (isset ( $dateArr [1] ))
  11699. $D2 = $dateArr [1];
  11700. else
  11701. $D2 = '';
  11702. $dateString = $D1 . " : " . $D2;
  11703. }
  11704. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11705. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11706. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11707. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11708. if (! empty ( $price ))
  11709. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11710. if ($submitType == 1) {
  11711. if ($accountType != '') {
  11712. $expenditureType = '';
  11713. $con .= ' and accountType=' . $accountType;
  11714. if (! empty ( $accountMsg ))
  11715. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11716. }
  11717. } elseif ($submitType == 2) {
  11718. if ($expenditureType != '') {
  11719. $accountType = $accountMsg = '';
  11720. $con .= ' and expenditureType=' . $expenditureType;
  11721. }
  11722. } else {
  11723. $accountType = $accountMsg = $expenditureType = '';
  11724. }
  11725. $sql = "" . $con;
  11726. $action = "paymentsAchieve";
  11727. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11728. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11729. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11730. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11731. $data ['expenditureType'] = $expenditureType;
  11732. $data ['accountMsg'] = $accountMsg;
  11733. $data ['accountType'] = $accountType;
  11734. $data ['inputDate'] = $date;
  11735. $data ['price'] = $price;
  11736. $data ['expensesType'] = $expensesType;
  11737. $data ['page'] = $pageinfo;
  11738. $data ['list'] = $list;
  11739. $data ['memu'] = "receipt";
  11740. $data ['staff'] = $this->staff;
  11741. $data ['receiptMemu'] = 'payments';
  11742. $data ['verifyId'] = $this->verifyId;
  11743. $data ['executeId'] = $this->executeId;
  11744. $this->render ( "/expenses/paymentsAchieve", $data );
  11745. }
  11746. function paymentsIncomeUpdateDo() {
  11747. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11748. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11749. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11750. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11751. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11752. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11753. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11754. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11755. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11756. Doo::loadClass ( 'XDeode' );
  11757. $XDeode = new XDeode ( 5 );
  11758. $aid = $XDeode->decode ( $aidKey );
  11759. Doo::loadModel ( "accountBook" );
  11760. $accountBook = new accountBook ();
  11761. //
  11762. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11763. $price = $receivedPrice - $abDetail [inComePrice];
  11764. Doo::loadModel ( "accountBookStatistics" );
  11765. $accountBookStatistics = new accountBookStatistics ();
  11766. if ($abDetail ['accountType'] == 7) {
  11767. $item += array (
  11768. 'date' => date ( "Y-m-d" ),
  11769. 'financingPrice' => - $price,
  11770. 'expensesType' => 3,
  11771. 'aid' => $abDetail ['aid']
  11772. );
  11773. } elseif ($abDetail ['accountType'] == 8) {
  11774. $item += array (
  11775. 'date' => date ( "Y-m-d" ),
  11776. 'expensesType' => $abDetail ['expensesType'],
  11777. 'inComePrice' => - $price,
  11778. 'aid' => $abDetail ['aid']
  11779. );
  11780. } else {
  11781. $item = array (
  11782. 'date' => date ( "Y-m-d" ),
  11783. 'expensesType' => $abDetail ['expensesType'],
  11784. 'inComePrice' => $price,
  11785. 'aid' => $abDetail ['aid']
  11786. );
  11787. }
  11788. $accountBookStatistics->setAccountBookStatistics ( $item );
  11789. $accountBook->accountType = $accountType;
  11790. $accountBook->accountMsg = $accountMsg;
  11791. $accountBook->receivedPrice = $receivedPrice;
  11792. $accountBook->receivedMsg = $receivedMsg;
  11793. $accountBook->receivedBank = $receivedBank;
  11794. $accountBook->receivedDate = $receivedDate;
  11795. $accountBook->remarks = $remarks;
  11796. $accountBook->aid = $aid;
  11797. $accountBook->update ();
  11798. }
  11799. return '/paymentsAchieve';
  11800. }
  11801. function paymentsExpenditureEdiDo() {
  11802. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11803. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11804. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11805. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11806. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11807. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11808. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11809. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11810. Doo::loadClass ( 'XDeode' );
  11811. $XDeode = new XDeode ( 5 );
  11812. $aid = $XDeode->decode ( $aidKey );
  11813. Doo::loadModel ( "accountBook" );
  11814. $accountBook = new accountBook ();
  11815. // 汇总信息
  11816. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11817. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11818. Doo::loadModel ( "accountBookStatistics" );
  11819. $accountBookStatistics = new accountBookStatistics ();
  11820. if ($abDetail ['expenditureType'] == 4) {
  11821. $item += array (
  11822. 'date' => date ( "Y-m-d" ),
  11823. 'financingPrice' => $price,
  11824. 'expensesType' => 3,
  11825. 'aid' => $abDetail ['aid']
  11826. );
  11827. } elseif ($abDetail ['expenditureType'] == 5) {
  11828. $item += array (
  11829. 'date' => date ( "Y-m-d" ),
  11830. 'expensesType' => $abDetail ['expensesType'],
  11831. 'payPrice' => $price,
  11832. 'aid' => $abDetail ['aid']
  11833. );
  11834. } else {
  11835. $item = array (
  11836. 'date' => date ( "Y-m-d" ),
  11837. 'expensesType' => $abDetail ['expensesType'],
  11838. 'payPrice' => $price,
  11839. 'aid' => $abDetail ['aid']
  11840. );
  11841. }
  11842. $accountBookStatistics->setAccountBookStatistics ( $item );
  11843. //
  11844. $accountBook->expenditureType = $expenditureType;
  11845. $accountBook->expenditureMsg = $expenditureMsg;
  11846. $accountBook->expenditurePrice = $expenditurePrice;
  11847. $accountBook->expenditureBank = $expenditureBank;
  11848. $accountBook->remarks = $remarks;
  11849. $accountBook->expenditureDate = $expenditureDate;
  11850. $accountBook->aid = $aid;
  11851. $id = $accountBook->update ();
  11852. }
  11853. return '/paymentsAchieve';
  11854. }
  11855. function paymentsDelDo() {
  11856. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11857. if (! empty ( $aidKey )) {
  11858. Doo::loadClass ( 'XDeode' );
  11859. $XDeode = new XDeode ( 5 );
  11860. $aid = $XDeode->decode ( $aidKey );
  11861. Doo::loadModel ( "accountBook" );
  11862. $accountBook = new accountBook ();
  11863. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11864. if (empty ( $abDetail ))
  11865. die ( 'illegal request' );
  11866. // 删除收支
  11867. Doo::loadModel ( "accountBookStatistics" );
  11868. $accountBookStatistics = new accountBookStatistics ();
  11869. $item = array (
  11870. 'date' => date ( "Y-m-d" ),
  11871. 'aid' => $abDetail ['aid']
  11872. );
  11873. $accountType = '';
  11874. if ($abDetail ['expensesType'] == 1) {
  11875. $accountType = 6;
  11876. if ($abDetail ['accountType'] != 7) {
  11877. $item += array (
  11878. 'expensesType' => $abDetail ['expensesType'],
  11879. 'inComePrice' => - $abDetail ['receivedPrice']
  11880. );
  11881. } else {
  11882. $item += array (
  11883. 'financingPrice' => $abDetail ['receivedPrice'],
  11884. 'expensesType' => 3
  11885. );
  11886. }
  11887. } elseif ($abDetail ['expensesType'] == 2) {
  11888. $accountType = 5;
  11889. if ($abDetail ['accountType'] != 7) {
  11890. $item += array (
  11891. 'expensesType' => $abDetail ['expensesType'],
  11892. 'payPrice' => - $abDetail ['expenditurePrice']
  11893. );
  11894. } else {
  11895. $item += array (
  11896. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11897. 'expensesType' => 3
  11898. );
  11899. }
  11900. }
  11901. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11902. if ($abDetail ['expenditureMsg'] == '公司固定')
  11903. $accountType = 9;
  11904. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11905. $accountType = 10;
  11906. }
  11907. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11908. if ($abDetail ['accountMsg'] == '公司固定')
  11909. $accountType = 9;
  11910. elseif ($abDetail ['accountMsg'] == '公司活期')
  11911. $accountType = 10;
  11912. }
  11913. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11914. $accountType = 10;
  11915. }
  11916. $accountBookStatistics->setAccountBookStatistics ( $item );
  11917. $accountBook->delete ( array (
  11918. 'where' => 'aid=' . $aid,
  11919. 'limit' => 1
  11920. ) );
  11921. // 删除收入流水
  11922. if (! empty ( $accountType )) {
  11923. Doo::loadModel ( 'wasteBook' );
  11924. $wasteBook = new wasteBook ();
  11925. $wasteBook->delete ( array (
  11926. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11927. 'limit' => 1
  11928. ) );
  11929. }
  11930. }
  11931. return '/paymentsAchieve';
  11932. }
  11933. function paymentsCollect() {
  11934. Doo::loadModel ( "execute" );
  11935. $execute = new execute ();
  11936. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11937. die ( 'illegal request' );
  11938. }
  11939. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11940. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11941. Doo::loadModel ( "accountBookStatistics" );
  11942. $accountBookStatistics = new accountBookStatistics ();
  11943. Doo::loadClass ( 'receipt.func' );
  11944. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11945. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11946. $data ['html'] = $html ['html'];
  11947. $data ['inSum'] = $html ['sum'];
  11948. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11949. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11950. $data ['payHtml'] = $html ['html'];
  11951. $data ['paySum'] = $html ['sum'];
  11952. // 余额统计
  11953. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11954. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11955. include './protected/config/wasteBook.conf.php';
  11956. Doo::loadModel ( 'wasteBook' );
  11957. $wasteBook = new wasteBook ();
  11958. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11959. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11960. // 获得年份之前所有金额
  11961. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11962. // print_r($detail);
  11963. // $waste['total'];
  11964. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11965. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11966. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11967. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11968. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11969. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11970. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11971. if (date ( 'Y' ) > $year) {
  11972. $limitMonth = 12;
  11973. }
  11974. for($i = 1; $i <= 12; $i ++) {
  11975. $inComeA = $payB = 0;
  11976. $falg = true;
  11977. foreach ( $inComePay as $key => $value ) {
  11978. if ($value ['month'] == $i) {
  11979. $falg = false;
  11980. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11981. $inSum += $value ['accountPrice'];
  11982. $showInSum += $value ['accountPriceShow'];
  11983. $inComeA = $value ['accountPrice'];
  11984. break;
  11985. }
  11986. }
  11987. if ($falg)
  11988. $inComeHtml .= '<td class="taR">-</td>';
  11989. $payFalg = true;
  11990. foreach ( $pay as $key => $value ) {
  11991. if ($value ['month'] == $i) {
  11992. $payFalg = false;
  11993. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11994. $paySum += $value ['accountPrice'];
  11995. $showPaySum += $value ['accountPriceShow'];
  11996. $payB = $value ['accountPrice'];
  11997. break;
  11998. }
  11999. }
  12000. if ($payFalg)
  12001. $payHtml .= '<td class="taR">-</td>';
  12002. if (empty ( $balanceC ) || $limitMonth < $i)
  12003. $lastBalanceHtml .= '<td class="taR">-</td>';
  12004. else
  12005. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12006. $balanceC = $balanceC + $inComeA + $payB;
  12007. $balanceSum += $balanceC;
  12008. if (empty ( $balanceC ) || $limitMonth < $i)
  12009. $BalanceHtml .= '<td class="taR">-</td>';
  12010. else
  12011. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12012. // 余额统计
  12013. }
  12014. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12015. $data ['inComeHtml'] = $inComeHtml;
  12016. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12017. $data ['payBalanceHtml'] = $payHtml;
  12018. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12019. $data ['BalanceHtml'] = $BalanceHtml;
  12020. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12021. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12022. $mothHtml = "";
  12023. for($i = 1; $i <= 12; $i ++) {
  12024. if ($moth == $i)
  12025. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12026. else
  12027. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12028. }
  12029. $data ['mothHtml'] = $mothHtml;
  12030. $dateHtml = "";
  12031. $now = date ( "Y" );
  12032. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12033. if ($YEARD <= $now) {
  12034. $dateHtml .= '<option ';
  12035. if ($year == $YEARD) {
  12036. $dateHtml .= 'selected ';
  12037. }
  12038. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12039. }
  12040. }
  12041. $data ['dateHtml'] = $dateHtml;
  12042. $data ['year'] = $year;
  12043. $data ['memu'] = "receipt";
  12044. $data ['staff'] = $this->staff;
  12045. $data ['receiptMemu'] = 'paymentsCollect';
  12046. $data ['verifyId'] = $this->verifyId;
  12047. $data ['executeId'] = $this->executeId;
  12048. $this->render ( "/expenses/paymentsCollect", $data );
  12049. }
  12050. function paymentsCollectDay() {
  12051. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12052. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  12053. if (empty ( $moth ))
  12054. return 'paymentsCollect';
  12055. Doo::loadModel ( "accountBookStatistics" );
  12056. $accountBookStatistics = new accountBookStatistics ();
  12057. $i = 2;
  12058. $y = 2013;
  12059. $day = date ( "t", strtotime ( "$year-$moth" ) );
  12060. Doo::loadClass ( 'receipt.func' );
  12061. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  12062. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  12063. $data ['html'] = $html ['html'];
  12064. $data ['inSum'] = $html ['sum'];
  12065. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  12066. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  12067. $data ['payHtml'] = $html ['html'];
  12068. $data ['paySum'] = $html ['sum'];
  12069. $mothHtml = "";
  12070. for($i = 1; $i <= 12; $i ++) {
  12071. if ($moth == $i)
  12072. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12073. else
  12074. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12075. }
  12076. $data ['mothHtml'] = $mothHtml;
  12077. $data ['year'] = $year;
  12078. // 余额
  12079. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  12080. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  12081. include './protected/config/wasteBook.conf.php';
  12082. Doo::loadModel ( 'wasteBook' );
  12083. $wasteBook = new wasteBook ();
  12084. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  12085. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  12086. // 获得年份之前所有金额
  12087. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  12088. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  12089. $inComeHtml = '<tr><th colspan="2">收入</th>';
  12090. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  12091. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  12092. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  12093. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  12094. // $balanceC = 0;
  12095. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  12096. $limitDay = date ( 'd' );
  12097. $monthLK = ( int ) date ( 'm' );
  12098. if (date ( 'Y' ) > $year) {
  12099. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  12100. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  12101. $limitDay = 0;
  12102. }
  12103. for($i = 1; $i <= $day; $i ++) {
  12104. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  12105. $inComeA = $payB = 0;
  12106. $falg = true;
  12107. foreach ( $inComePay as $key => $value ) {
  12108. if ($value ['day'] == $i) {
  12109. $falg = false;
  12110. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12111. $inSum += $value ['accountPrice'];
  12112. $showInSum += $value ['accountPriceShow'];
  12113. $inComeA = $value ['accountPrice'];
  12114. break;
  12115. }
  12116. }
  12117. if ($falg)
  12118. $inComeHtml .= '<td class="taR">-</td>';
  12119. $payFalg = true;
  12120. foreach ( $pay as $key => $value ) {
  12121. if ($value ['day'] == $i) {
  12122. $payFalg = false;
  12123. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12124. $paySum += $value ['accountPrice'];
  12125. $showPaySum += $value ['accountPriceShow'];
  12126. $payB = $value ['accountPrice'];
  12127. break;
  12128. }
  12129. }
  12130. if ($payFalg)
  12131. $payHtml .= '<td class="taR">-</td>';
  12132. if (empty ( $balanceC ) || $limitDay < $i)
  12133. $lastBalanceHtml .= '<td class="taR">-</td>';
  12134. else
  12135. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12136. $balanceC = $balanceC + $inComeA + $payB;
  12137. $balanceSum += $balanceC;
  12138. if (empty ( $balanceC ) || $limitDay < $i)
  12139. $BalanceHtml .= '<td class="taR">-</td>';
  12140. else
  12141. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12142. }
  12143. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12144. $data ['inComeHtml'] = $inComeHtml;
  12145. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12146. $data ['payBalanceHtml'] = $payHtml;
  12147. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12148. $data ['BalanceHtml'] = $BalanceHtml;
  12149. $dayHtml .= '<td class="taR ">总计</td></tr>';
  12150. $data ['dayHtml'] = $dayHtml;
  12151. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12152. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12153. $dateHtml = "";
  12154. $now = date ( "Y" );
  12155. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12156. if ($YEARD <= $now) {
  12157. $dateHtml .= '<option ';
  12158. if ($year == $YEARD) {
  12159. $dateHtml .= 'selected ';
  12160. }
  12161. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12162. }
  12163. }
  12164. $data ['dateHtml'] = $dateHtml;
  12165. $data ['memu'] = "receipt";
  12166. $data ['staff'] = $this->staff;
  12167. $data ['receiptMemu'] = 'paymentsCollect';
  12168. $data ['verifyId'] = $this->verifyId;
  12169. $data ['executeId'] = $this->executeId;
  12170. $this->render ( "/expenses/paymentsCollectDay", $data );
  12171. }
  12172. // 公司流水
  12173. function wasteBook() {
  12174. Doo::loadModel ( "execute" );
  12175. $execute = new execute ();
  12176. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  12177. die ( 'illegal request' );
  12178. }
  12179. include './protected/config/wasteBook.conf.php';
  12180. Doo::loadModel ( 'wasteBook' );
  12181. $wasteBook = new wasteBook ();
  12182. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  12183. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  12184. //
  12185. $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'];
  12186. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12187. // print_r($waste);
  12188. $data ['waste'] = $waste;
  12189. $data ['total'] = $total;
  12190. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  12191. $data['cashBalance']= $CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12192. // 月流水数据结构
  12193. $monthStatistics = array ();
  12194. $incomeMothStatistics = array ();
  12195. $expenditureMothStatistics = array ();
  12196. for($i = 1; $i <= 12; $i ++) {
  12197. $month = date ( 'Y' ) . '-' . $i;
  12198. if ($i < 10)
  12199. $month = date ( 'Y' ) . '-0' . $i;
  12200. array_push ( $monthStatistics, $month );
  12201. }
  12202. foreach ( $monthStatistics as $value ) {
  12203. $falg = true;
  12204. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12205. if ($value == $v ['inputDate']) {
  12206. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12207. $falg = false;
  12208. }
  12209. }
  12210. if ($falg) {
  12211. array_push ( $incomeMothStatistics, '' );
  12212. }
  12213. $falgEx = true;
  12214. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12215. if ($value == $v ['inputDate']) {
  12216. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12217. $falg = false;
  12218. }
  12219. }
  12220. if ($falgEx) {
  12221. array_push ( $expenditureMothStatistics, '' );
  12222. }
  12223. }
  12224. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12225. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12226. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12227. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12228. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12229. // print_r($incomeList);
  12230. $data ['expenditureList'] = $expenditureList;
  12231. $data ['incomeList'] = $incomeList;
  12232. $data ['memu'] = "receipt";
  12233. $data ['staff'] = $this->staff;
  12234. $data ['receiptMemu'] = 'wasteBook';
  12235. $data ['verifyId'] = $this->verifyId;
  12236. $data ['executeId'] = $this->executeId;
  12237. $this->render ( "/expenses/wasteBook", $data );
  12238. }
  12239. function wasteBookIncome() {
  12240. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12241. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12242. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12243. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12244. $data ['dailyIncomeType'] = $dailyIncomeType;
  12245. Doo::loadModel ( 'wasteBook' );
  12246. $wasteBook = new wasteBook ();
  12247. Doo::loadModel ( 'L_category' );
  12248. $L_category = new L_category ();
  12249. Doo::loadClass ( 'XDeode' );
  12250. $XDeode = new XDeode ( 5 );
  12251. // echo $XDeode->encode(1).'<br>';
  12252. // echo $XDeode->encode(2).'<br>';
  12253. // echo $XDeode->encode(3).'<br>';
  12254. // echo $XDeode->encode(4).'<br>';
  12255. // echo $XDeode->encode(5).'<br>';
  12256. // echo $XDeode->encode(6).'<br>';
  12257. // echo $XDeode->encode(7).'<br>';
  12258. // echo $XDeode->encode(8).'<br>';
  12259. // echo $XDeode->encode(9).'<br>';
  12260. // echo $XDeode->encode(10).'<br>';
  12261. $year=date("Y");
  12262. $theDay=date("Y-m-d");
  12263. $dateArr = explode ( ':', $date );
  12264. $D1 = '';
  12265. $D2 = '';
  12266. $con = '';
  12267. if (! empty ( $date )) {
  12268. $D1 = $dateArr [0];
  12269. $D2 = $dateArr [1];
  12270. }
  12271. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12272. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12273. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12274. $con = ' and inputDate = "' . $D1 . '"';
  12275. else{
  12276. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12277. }
  12278. if ($cid != 'ALL') {
  12279. $cid = $XDeode->decode ( $cid );
  12280. $con .= ' and cid = "' . $cid . '"';
  12281. }
  12282. if ($accountType != 'ALL') {
  12283. if ($accountType == 'INVOICE') {
  12284. $con .= ' and (accountType = 7 or accountType = 8)';
  12285. } elseif ($accountType == 'PAYMENTS') {
  12286. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12287. if ($dailyIncomeType != 'ALL') {
  12288. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12289. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12290. }
  12291. }
  12292. }
  12293. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12294. $sum = 0;$thsDaySum=0;
  12295. foreach ( $incomeList as $key => $value ) {
  12296. $sum += $value ['accountPrice'];
  12297. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12298. $thsDaySum+=$value ['accountPrice'];
  12299. }
  12300. }
  12301. // print_r($incomeList);
  12302. // 获得办事和部门
  12303. $categoryList = $L_category->getCategory ();
  12304. $data ['accountType'] = $accountType;
  12305. $data ['cid'] = $cid;
  12306. $data ['categoryList'] = $categoryList;
  12307. $data ['sum'] = $sum;
  12308. $data ['incomeList'] = $incomeList;
  12309. $data ['inputDate'] = $date;
  12310. $data['year']=$year;
  12311. $data ['thsDay'] =$theDay;
  12312. $data ['thsDaySum'] =$thsDaySum;
  12313. $data ['memu'] = "receipt";
  12314. $data ['staff'] = $this->staff;
  12315. $data ['receiptMemu'] = 'wasteBook';
  12316. $data ['verifyId'] = $this->verifyId;
  12317. $data ['executeId'] = $this->executeId;
  12318. $this->render ( "/expenses/wasteBookIncome", $data );
  12319. }
  12320. /**
  12321. * 所有支出
  12322. */
  12323. function wasteBookExpenditure() {
  12324. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12325. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12326. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12327. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12328. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12329. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12330. $data ['receiptType'] = $receiptType;
  12331. Doo::loadModel ( 'wasteBook' );
  12332. $wasteBook = new wasteBook ();
  12333. Doo::loadModel ( 'L_category' );
  12334. $L_category = new L_category ();
  12335. Doo::loadClass ( 'XDeode' );
  12336. $XDeode = new XDeode ( 5 );
  12337. $year=date("Y");
  12338. $theDay=date("Y-m-d");
  12339. $dateArr = explode ( ':', $date );
  12340. $D1 = '';
  12341. $D2 = '';
  12342. $con = '';
  12343. if (! empty ( $date )) {
  12344. $D1 = $dateArr [0];
  12345. $D2 = $dateArr [1];
  12346. }
  12347. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12348. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12349. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12350. $con = ' and inputDate = "' . $D1 . '"';
  12351. else{
  12352. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12353. }
  12354. if ($cid != 'ALL') {
  12355. $cid = $XDeode->decode ( $cid );
  12356. $con .= ' and cid = "' . $cid . '"';
  12357. }
  12358. if ($accountType != 'ALL') {
  12359. if ($accountType == 'INVOICE') {
  12360. $con .= ' and accountType = 11';
  12361. } elseif ($accountType == 'PAYMENTS') {
  12362. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12363. if ($dailyExpenditureType != 'ALL') {
  12364. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12365. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12366. }
  12367. } elseif ($accountType == 'RECEIPT') {
  12368. if ($receiptType == 'ALL') {
  12369. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12370. } else {
  12371. $receiptType = $XDeode->decode ( $receiptType );
  12372. echo $receiptType;
  12373. if ($receiptType == 1) {
  12374. $con .= ' and (accountType = 1 or accountType=2)';
  12375. } else {
  12376. $con .= ' and accountType = ' . $receiptType;
  12377. }
  12378. }
  12379. }
  12380. }
  12381. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12382. $sum = 0;$thsDaySum=0;
  12383. foreach ( $incomeList as $key => $value ) {
  12384. $sum += $value ['accountPriceShow'];
  12385. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12386. $thsDaySum+=$value ['accountPriceShow'];
  12387. }
  12388. }
  12389. // print_r($incomeList);
  12390. // 获得办事和部门
  12391. $categoryList = $L_category->getCategory ();
  12392. $data ['accountType'] = $accountType;
  12393. $data ['cid'] = $cid;
  12394. $data ['categoryList'] = $categoryList;
  12395. $data ['sum'] = $sum;
  12396. $data ['incomeList'] = $incomeList;
  12397. $data ['inputDate'] = $date;
  12398. $data['year']=$year;
  12399. $data ['thsDay'] =$theDay;
  12400. $data ['thsDaySum'] =$thsDaySum;
  12401. $data ['memu'] = "receipt";
  12402. $data ['staff'] = $this->staff;
  12403. $data ['receiptMemu'] = 'wasteBook';
  12404. $data ['verifyId'] = $this->verifyId;
  12405. $data ['executeId'] = $this->executeId;
  12406. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12407. }
  12408. function ajaxGetWasteinvoiceReceivables() {
  12409. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12410. Doo::loadClass ( 'XDeode' );
  12411. $XDeode = new XDeode ( 5 );
  12412. $irid = $XDeode->decode ( $serial );
  12413. Doo::loadModel ( 'invoiceReceivables' );
  12414. $invoiceReceivables = new invoiceReceivables ();
  12415. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12416. echo json_encode ( array (
  12417. 'status' => 1,
  12418. 'detail' => $detail
  12419. ) );
  12420. }
  12421. function ajaxGetPaymentsByAid() {
  12422. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12423. Doo::loadModel ( "accountBook" );
  12424. $accountBook = new accountBook ();
  12425. $detail = $accountBook->getAccountBookByAid ( $serial );
  12426. echo json_encode ( array (
  12427. 'status' => 1,
  12428. 'detail' => $detail
  12429. ) );
  12430. }
  12431. function ajaxGetWasteInvoice() {
  12432. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12433. Doo::loadModel ( 'invoice' );
  12434. $invoice = new invoice ();
  12435. Doo::loadModel ( 'invoiceReceivables' );
  12436. $invoiceReceivables = new invoiceReceivables ();
  12437. $detail = $invoice->getInvoiceByIid ( $serial );
  12438. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12439. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12440. echo json_encode ( array (
  12441. 'status' => 1,
  12442. 'detail' => $detail
  12443. ) );
  12444. }
  12445. /**
  12446. */
  12447. function ajaxGetWasteReceipt() {
  12448. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12449. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12450. Doo::loadModel ( 'receipt' );
  12451. $receipt = new receipt ();
  12452. Doo::loadClass ( 'XDeode' );
  12453. $XDeode = new XDeode ( 5 );
  12454. $rid = $XDeode->decode ( $serial );
  12455. $accountType= $XDeode->decode ( $accountTypeKey );
  12456. // 获得个数据
  12457. $detail = $receipt->getReceiptByRid ( $rid );
  12458. // 初始化
  12459. $detail ['reviseDetail'] = array ();
  12460. if (! empty ( $value ['reviseDetail'] ))
  12461. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12462. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12463. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12464. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12465. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12466. // 获得费用html
  12467. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12468. // 获得费用审批人数据
  12469. $detail = $this->getReceiptApproverHtml ( $detail );
  12470. // 审批执行
  12471. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12472. <th class="taC" width="90">审批人</th>
  12473. <th class="taC">审批意见</th></tr>';
  12474. foreach ( $detail ['verifyList'] as $key => $value ) {
  12475. $html .= '<tr>
  12476. <td>' . $value [1] . '</td>
  12477. <td>' . $value ['opinion'] . '</td>
  12478. </tr>
  12479. ';
  12480. }
  12481. $html .= ' </tbody></table>';
  12482. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12483. <th class="taC" width="90">执行人</th>
  12484. <th class="taC">执行意见</th></tr>';
  12485. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12486. $html .= '<tr>
  12487. <td>' . $value [1] . '</td>
  12488. <td>' . $value ['opinion'] . '</td>
  12489. </tr>
  12490. ';
  12491. }
  12492. $html .= ' </tbody></table>';
  12493. if($accountType==1){
  12494. Doo::loadModel ( 'loanReceipt' );
  12495. $loanReceipt = new loanReceipt ();
  12496. $loanList = $loanReceipt->getOne ( array (
  12497. 'where' => 'rid=' . $detail ['loanRid'],
  12498. 'desc' => 'rid',
  12499. 'asArray' => true
  12500. ) );
  12501. $html .= '<table class="table table-bordered table-condensed">
  12502. <tr class="warning">
  12503. <td class="taR"><b>汇款金额</b></td>
  12504. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12505. </tr>
  12506. </table>';
  12507. }else{
  12508. $html .= '<table class="table table-bordered table-condensed">
  12509. <tr class="warning">
  12510. <td class="taR"><b>汇款金额</b></td>
  12511. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12512. </tr>
  12513. </table>';
  12514. }
  12515. // print_r($detail['verifyList']);
  12516. // header ( 'Content-Type:text/html;charset=utf-8' );
  12517. // echo $html;
  12518. echo json_encode ( array (
  12519. 'status' => 1,
  12520. 'html' => $html,
  12521. 'detail' => $detail
  12522. ) );
  12523. }
  12524. function getReceiptApproverHtml($detail = array()) {
  12525. Doo::loadModel ( 'loanReceipt' );
  12526. $loanReceipt = new loanReceipt ();
  12527. Doo::loadModel ( 'verify' );
  12528. $verify = new verify ();
  12529. Doo::loadModel ( 'staff' );
  12530. $staff = new staff ();
  12531. if (empty ( $detail ))
  12532. return array ();
  12533. $loanList = $loanReceipt->getOne ( array (
  12534. 'where' => 'rid=' . $detail ['loanRid'],
  12535. 'desc' => 'rid',
  12536. 'asArray' => true
  12537. ) );
  12538. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12539. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12540. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12541. else
  12542. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12543. } else
  12544. $verifyList = $verify->getOne ( array (
  12545. 'where' => 'vid=' . $detail ['verify'],
  12546. 'asArray' => true
  12547. ) );
  12548. $verifyList = json_decode ( $verifyList ['staff'], true );
  12549. Doo::loadModel ( 'role' );
  12550. $role = new role ();
  12551. $roleId = 0;
  12552. $flag = true;
  12553. $roleKey = 0;
  12554. $endStaffArray = array ();
  12555. $roleArrayCopy = array ();
  12556. foreach ( $verifyList as $k => $v ) {
  12557. // init verifyStaff
  12558. if ($v [1] == 'ROLE') {
  12559. if (! empty ( $verifyStaff )) {
  12560. $endStaffArray = end ( $verifyStaff );
  12561. }
  12562. $roleVerify = json_decode ( $v [3], true );
  12563. $roleKey = $k;
  12564. $roleArray = array ();
  12565. $rolename = $role->getOne ( array (
  12566. 'where' => 'rid=' . $v [0],
  12567. 'asArray' => true
  12568. ) );
  12569. foreach ( $roleVerify as $o => $p ) {
  12570. $staffID = explode ( '_', $p );
  12571. $staffInfo = $staff->getOne ( array (
  12572. 'where' => 'sid=' . $staffID [0],
  12573. 'asArray' => true
  12574. ) );
  12575. // print_r($staffID);
  12576. $exp = array (
  12577. 0 => $staffInfo ['sid'],
  12578. 1 => $staffID [1],
  12579. 2 => $staffInfo ['avatar'],
  12580. 'date' => '',
  12581. 'date' => '',
  12582. 'opinion' => '',
  12583. 'status' => '',
  12584. 'rolename' => $rolename ['name']
  12585. );
  12586. array_push ( $roleArray, $exp );
  12587. }
  12588. $roleArrayCopy [$v [0]] = $roleArray;
  12589. // $verifyList[$k]['roleArray']=$roleArray;
  12590. }
  12591. $verifyList [$k] ['date'] = "";
  12592. $verifyList [$k] ['opinion'] = "";
  12593. $verifyList [$k] ['status'] = "";
  12594. if (empty ( $verifyStaff )) {
  12595. $verifyList [$k] ['date'] = "";
  12596. $verifyList [$k] ['opinion'] = "";
  12597. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12598. $verifyList [$k] ['status'] = 4;
  12599. $flag = false;
  12600. }
  12601. } else {
  12602. foreach ( $verifyStaff as $m => $u ) {
  12603. if ($v [0] == $m) {
  12604. $verifyList [$k] ['date'] = $u ['date'];
  12605. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12606. $verifyList [$k] ['status'] = $u ['status'];
  12607. $flag = false;
  12608. break;
  12609. }
  12610. }
  12611. $endStaffArray = end ( $verifyStaff );
  12612. }
  12613. }
  12614. $rolename ['name'] = '';
  12615. if (! empty ( $roleId )) {
  12616. Doo::loadModel ( 'role' );
  12617. $role = new role ();
  12618. $rolename = $role->getOne ( array (
  12619. 'where' => 'rid=' . $roleId,
  12620. 'asArray' => true
  12621. ) );
  12622. }
  12623. if (! empty ( $verifyStaff ))
  12624. $endStaffArray = end ( $verifyStaff );
  12625. $KOP = false;
  12626. foreach ( $roleArrayCopy as $P => $A ) {
  12627. foreach ( $A as $MKI => $AVL ) {
  12628. if (! empty ( $verifyStaff )) {
  12629. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12630. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12631. $button = 4;
  12632. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12633. }
  12634. foreach ( $verifyStaff as $m => $u ) {
  12635. $AVLFK = $AVL [0] . '_R';
  12636. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12637. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12638. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12639. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12640. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12641. break;
  12642. }
  12643. }
  12644. } else {
  12645. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12646. $button = 4;
  12647. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12648. }
  12649. }
  12650. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12651. $KOP = true;
  12652. }
  12653. }
  12654. foreach ( $roleArrayCopy as $k => $v ) {
  12655. foreach ( $verifyList as $m => $n ) {
  12656. if ($n [0] == $k) {
  12657. array_splice ( $verifyList, $m, 1, $v );
  12658. }
  12659. }
  12660. }
  12661. // 费用执行人相关数据
  12662. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12663. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12664. foreach ( $executeCopy as $k => $v ) {
  12665. $executeCopy [$k] ['date'] = '';
  12666. $executeCopy [$k] ['opinion'] = '';
  12667. $executeCopy [$k] ['status'] = '';
  12668. if (! empty ( $executeStaff ))
  12669. foreach ( $executeStaff as $m => $u ) {
  12670. if ($v [0] == $m) {
  12671. $executeCopy [$k] ['date'] = $u ['date'];
  12672. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12673. $executeCopy [$k] ['status'] = $u ['status'];
  12674. break;
  12675. }
  12676. }
  12677. }
  12678. $detail ['executeCopy'] = $executeCopy;
  12679. $detail ['verifyList'] = $verifyList;
  12680. return $detail;
  12681. }
  12682. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12683. if (empty ( $detail ))
  12684. return '';
  12685. $html = '';
  12686. if ($detail ['Rtype'] == 0) { // 报销单
  12687. $html .= '<table class="table table-bordered table-condensed">
  12688. <tbody>
  12689. <tr>
  12690. <th colspan="2" class="taC">日常相关费用</th>
  12691. </tr>';
  12692. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12693. $html .= '
  12694. <tr>
  12695. <th>' . $value ['name'] . '</th>
  12696. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12697. </tr>';
  12698. }
  12699. $html .= '
  12700. <tr>
  12701. <th class="taR">合计</th>
  12702. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12703. </tr>';
  12704. $html .= '<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'] ['travelSum'] . '</td>
  12718. </tr>';
  12719. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12720. $html .= '<tr>
  12721. <th colspan="2" class="taC">内部培训费用</th>
  12722. </tr>';
  12723. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12724. $html .= '
  12725. <tr>
  12726. <th>' . $value ['name'] . '</th>
  12727. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12728. </tr>';
  12729. }
  12730. $html .= '
  12731. <tr>
  12732. <th class="taR">合计</th>
  12733. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12734. </tr>';
  12735. }
  12736. $html .= '<tr>
  12737. <th colspan="2" class="taC">其他</th>
  12738. </tr>';
  12739. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12740. $html .= '
  12741. <tr>
  12742. <th>' . $value ['name'] . '</th>
  12743. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12744. </tr>';
  12745. }
  12746. $html .= '
  12747. <tr>
  12748. <th class="taR">合计</th>
  12749. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12750. </tr>';
  12751. $html .= '<tr>
  12752. <th colspan="2" class="taC">报销金额调整</th>
  12753. </tr>';
  12754. foreach ( $detail ['reviseDetail'] 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 ['revisePrice'] . '</td>
  12765. </tr>';
  12766. $html .= '
  12767. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12768. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12769. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12770. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12771. <tr class="warning">
  12772. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12773. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12774. </tr>
  12775. </tbody>
  12776. </table>';
  12777. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12778. $html .= '
  12779. <table class="table table-bordered table-condensed">
  12780. <tbody>
  12781. <tr>
  12782. <th colspan="2" class="taC">办事处相关费用</th>
  12783. </tr>';
  12784. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12785. $html .= '
  12786. <tr>
  12787. <th>' . $value ['name'] . '</th>
  12788. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12789. </tr>';
  12790. }
  12791. $html .= '
  12792. <tr>
  12793. <th class="taR">合计</th>
  12794. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12795. </tr>';
  12796. $html .= '
  12797. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12798. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12799. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12800. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12801. <tr class="warning">
  12802. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12803. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12804. </tr>
  12805. </tbody>
  12806. </table>';
  12807. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12808. Doo::loadModel ( 'loanReceipt' );
  12809. $loanReceipt = new loanReceipt ();
  12810. $loanList = $loanReceipt->getOne ( array (
  12811. 'where' => 'rid=' . $detail ['loanRid'],
  12812. 'desc' => 'rid',
  12813. 'asArray' => true
  12814. ) );
  12815. // print_r($loanList);
  12816. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12817. $html .= '<table class="table table-bordered table-condensed">
  12818. <tbody>
  12819. <tr>
  12820. <th colspan="2" class="taC">借款费用</th>
  12821. </tr>';
  12822. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12823. $html .= '<tr>
  12824. <th>' . $value ['name'] . '</th>
  12825. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12826. </tr>';
  12827. }
  12828. $html .= '<tr>
  12829. <th class="taC" colspan="2">产生费用所在办事处</th>
  12830. </tr>
  12831. <tr>
  12832. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12833. </tr>
  12834. <tr>
  12835. <th class="taC" colspan="2">费用说明</th>
  12836. </tr>
  12837. <tr>
  12838. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12839. </tr>
  12840. <tr class="warning">
  12841. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12842. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12843. </tr>
  12844. </tbody>
  12845. </table>
  12846. ';
  12847. if ( $accountType==2) {
  12848. $balance=$detail ['sum']-$loanList ['sum'];
  12849. $balanceCN=$this->num_to_rmb($balance);
  12850. $html .= '<table class="table table-bordered table-condensed">
  12851. <tbody>
  12852. <tr>
  12853. <th colspan="2" class="taC">日常相关费用</th>
  12854. </tr>';
  12855. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12856. $html .= '
  12857. <tr>
  12858. <th>' . $value ['name'] . '</th>
  12859. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12860. </tr>';
  12861. }
  12862. $html .= '
  12863. <tr>
  12864. <th class="taR">合计</th>
  12865. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12866. </tr>';
  12867. $html .= '<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'] ['travelSum'] . '</td>
  12881. </tr>';
  12882. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12883. $html .= '<tr>
  12884. <th colspan="2" class="taC">内部培训费用</th>
  12885. </tr>';
  12886. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12887. $html .= '
  12888. <tr>
  12889. <th>' . $value ['name'] . '</th>
  12890. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12891. </tr>';
  12892. }
  12893. $html .= '
  12894. <tr>
  12895. <th class="taR">合计</th>
  12896. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12897. </tr>';
  12898. }
  12899. $html .= '<tr>
  12900. <th colspan="2" class="taC">其他</th>
  12901. </tr>';
  12902. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12903. $html .= '
  12904. <tr>
  12905. <th>' . $value ['name'] . '</th>
  12906. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12907. </tr>';
  12908. }
  12909. $html .= '
  12910. <tr>
  12911. <th class="taR">合计</th>
  12912. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12913. </tr>';
  12914. $html .= '<tr>
  12915. <th colspan="2" class="taC">报销金额调整</th>
  12916. </tr>';
  12917. foreach ( $detail ['reviseDetail'] 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 ['revisePrice'] . '</td>
  12928. </tr>';
  12929. $html .= '
  12930. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12931. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12932. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12933. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12934. <tr class="warning">
  12935. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12936. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12937. </tr>
  12938. <tr class="success">
  12939. <td class="taR"><b>借款结余</b></td>
  12940. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12941. </tr>
  12942. </tbody>
  12943. </table>';
  12944. }
  12945. }
  12946. return $html;
  12947. }
  12948. /**
  12949. * 计算流水
  12950. */
  12951. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12952. $bakWaste ['bank'] = array (
  12953. 'CGBDeposit' => 0,
  12954. 'ICBCDeposit' => 0,
  12955. 'HUADeposit' => 0,
  12956. 'PersonalDeposit' => 0
  12957. );
  12958. $bakWaste ['financial'] = array (
  12959. 'current' => array (
  12960. 'CGBDeposit' => 0,
  12961. 'ICBCDeposit' => 0
  12962. ),
  12963. 'fixed' => array (
  12964. 'CGBDeposit' => 0,
  12965. 'ICBCDeposit' => 0
  12966. )
  12967. );
  12968. // 存款
  12969. foreach ( $waste ['bank'] as $key => $value ) {
  12970. // 收入
  12971. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12972. // 广发
  12973. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12974. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12975. }
  12976. // 工商
  12977. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12978. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12979. }
  12980. // 华润
  12981. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12982. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12983. }
  12984. // 个人
  12985. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12986. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12987. }
  12988. }
  12989. }
  12990. foreach ( $waste ['bank'] as $key => $value ) {
  12991. // 支出
  12992. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12993. // 广发
  12994. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12995. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12996. }
  12997. // 工商
  12998. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12999. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13000. }
  13001. // 华润
  13002. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13003. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13004. }
  13005. // 个人
  13006. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13007. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13008. }
  13009. }
  13010. }
  13011. // 活期
  13012. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13013. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13014. // 广发
  13015. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13016. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13017. }
  13018. // 工商
  13019. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13020. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13021. }
  13022. // 个人
  13023. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13024. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13025. }
  13026. }
  13027. }
  13028. // print_r($inComeStatistics ['fixedStatistics']);
  13029. // 固期
  13030. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13031. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13032. // 广发
  13033. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13034. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13035. }
  13036. // 工商
  13037. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13038. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13039. }
  13040. // 个人
  13041. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13042. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13043. }
  13044. }
  13045. }
  13046. return $waste;
  13047. }
  13048. function lyt() {
  13049. Doo::loadModel ( "receiptDetail" );
  13050. $receiptDetail = new receiptDetail ();
  13051. $receiptCollectList = $receiptDetail->find ( array (
  13052. 'where' => 'status=1 ',
  13053. 'asArray' => true
  13054. ) );
  13055. foreach ( $receiptCollectList as $key => $value ) {
  13056. $receiptDetail = new receiptDetail ();
  13057. $receiptDetail->pastDate = $value ['date'];
  13058. $receiptDetail->update ( array (
  13059. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13060. ) );
  13061. }
  13062. }
  13063. function staffCollectMonthDetail() {
  13064. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13065. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13066. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13067. if (! $year)
  13068. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13069. if (! $month)
  13070. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13071. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13072. if (! $nature){
  13073. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13074. }
  13075. Doo::loadModel ( 'staff' );
  13076. $staff = new staff ();
  13077. Doo::loadModel ( "receiptDetail" );
  13078. $receiptDetail = new receiptDetail ();
  13079. Doo::loadModel ( 'accountItem' );
  13080. $accountItem = new accountItem ();
  13081. Doo::loadModel ( 'statistics' );
  13082. $statistics = new statistics ();
  13083. Doo::loadModel ( "receiptAuthorityManage" );
  13084. $receiptAuthorityManage = new receiptAuthorityManage ();
  13085. $aiList=$accountItem->getAccountItem();
  13086. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13087. $cidList = array ();
  13088. foreach ( $imcStaff as $key => $value ) {
  13089. array_push ( $cidList, $value ['cid'] );
  13090. }
  13091. $cidString = implode ( ',', $cidList );
  13092. $naturecon='';
  13093. if ($nature=='ONJOB'){
  13094. $naturecon=' and (nature!=4 )';
  13095. }elseif($nature=='LEAVEJOB'){
  13096. $naturecon=' and (nature=4 )';
  13097. }else{
  13098. die ( 'illegal request--nature' );
  13099. }
  13100. $staffList = $staff->find ( array (
  13101. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13102. 'asArray' => true
  13103. ) );
  13104. $categoryList = $staff->find ( array (
  13105. 'select' => 'COUNT(*) as count,cid,category',
  13106. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13107. 'groupby' => 'cid',
  13108. 'asArray' => true
  13109. ) );
  13110. $list = array ();
  13111. foreach($aiList as $key=>$value){
  13112. foreach ($value as $v){
  13113. $subtotal[$key][$v['name']]=0;
  13114. }
  13115. }
  13116. foreach ( $categoryList as $vlu ) {
  13117. $s1 = 0;
  13118. $m1 = 0;
  13119. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13120. foreach ( $staffList as $value ) {
  13121. if ($vlu ['cid'] == $value ['cid']) {
  13122. // pastDate
  13123. $receiptCollectList = $receiptDetail->find ( array (
  13124. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13125. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13126. 'groupby' => 'item,Month(pastDate),itemCategory',
  13127. 'asArray' => true
  13128. ) );
  13129. if (! empty ( $receiptCollectList )) {
  13130. $receiptL = array (
  13131. '日常相关费用' => array (),
  13132. '差旅相关费用' => array (),
  13133. '内部培训费用' => array (),
  13134. '培训班费用' => array (),
  13135. '其他' => array ()
  13136. );
  13137. $html = "";
  13138. $psum = 0;
  13139. foreach ( $aiList[$this->AGENCY] as $va ) {
  13140. $falg = true;
  13141. foreach ( $receiptCollectList as $v ) {
  13142. if ($v ['itemCategory'] == '日常相关费用') {
  13143. if ($v ['item'] == $va['name']) {
  13144. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13145. $psum += $v ['price'];
  13146. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13147. $falg = false;
  13148. break;
  13149. }
  13150. }
  13151. }
  13152. if ($falg)
  13153. $html .= '<td class="taR">-</td>';
  13154. }
  13155. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13156. if (! empty ( $psum ))
  13157. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13158. else
  13159. $psum = '<td class="colGreen taR">-</td>';
  13160. $receiptL ['日常相关费用'] = $psum . $html;
  13161. /* ----------------------------------- */
  13162. $html = "";
  13163. $psum = 0;
  13164. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13165. $falg = true;
  13166. foreach ( $receiptCollectList as $v ) {
  13167. if ($v ['itemCategory'] == '差旅相关费用') {
  13168. if ($v ['item'] == $va['name']) {
  13169. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13170. $psum += $v ['price'];
  13171. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13172. $falg = false;
  13173. break;
  13174. }
  13175. }
  13176. }
  13177. if ($falg)
  13178. $html .= '<td class="taR">-</td>';
  13179. }
  13180. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13181. if (! empty ( $psum ))
  13182. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13183. else
  13184. $psum = '<td class="colGreen taR">-</td>';
  13185. $receiptL ['差旅相关费用'] = $psum . $html;
  13186. /* ------------------------------------- */
  13187. $html = "";
  13188. $psum = 0;
  13189. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13190. $falg = true;
  13191. foreach ( $receiptCollectList as $v ) {
  13192. if ($v ['itemCategory'] == '内部培训费用') {
  13193. if ($v ['item'] == $va['name']) {
  13194. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13195. $psum += $v ['price'];
  13196. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13197. $falg = false;
  13198. break;
  13199. }
  13200. }
  13201. }
  13202. if ($falg)
  13203. $html .= '<td class="taR">-</td>';
  13204. }
  13205. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13206. if (! empty ( $psum ))
  13207. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13208. else
  13209. $psum = '<td class="colGreen taR">-</td>';
  13210. $receiptL ['内部培训费用'] = $psum . $html;
  13211. /* ----------------------------------- */
  13212. $html = "";
  13213. $psum = 0;
  13214. foreach ( $aiList[$this->TRAIN] as $va ) {
  13215. $falg = true;
  13216. foreach ( $receiptCollectList as $v ) {
  13217. if ($v ['itemCategory'] == '培训班费用') {
  13218. if ($v ['item'] == $va['name']) {
  13219. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13220. $psum += $v ['price'];
  13221. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13222. $falg = false;
  13223. break;
  13224. }
  13225. }
  13226. }
  13227. if ($falg)
  13228. $html .= '<td class="taR">-</td>';
  13229. }
  13230. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13231. if (! empty ( $psum ))
  13232. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13233. else
  13234. $psum = '<td class="colGreen taR">-</td>';
  13235. $receiptL ['培训班费用'] = $psum . $html;
  13236. /* ------------------------------------- */
  13237. $html = "";
  13238. $psum = 0;
  13239. foreach ( $aiList[$this->OTHER] as $va ) {
  13240. $falg = true;
  13241. foreach ( $receiptCollectList as $v ) {
  13242. if ($v ['itemCategory'] == '其他') {
  13243. if (trim ( $v ['item'] ) == $va['name']) {
  13244. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13245. $psum += $v ['price'];
  13246. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13247. $falg = false;
  13248. break;
  13249. }
  13250. }
  13251. }
  13252. if ($falg)
  13253. $html .= '<td class="taR">-</td>';
  13254. }
  13255. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13256. if (! empty ( $psum ))
  13257. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13258. else
  13259. $psum = '<td class="colGreen taR">-</td>';
  13260. $receiptL ['其他'] = $psum . $html;
  13261. /* ------------------------------------- */
  13262. $html = "";
  13263. $psum = 0;
  13264. foreach ( $receiptCollectList as $v ) {
  13265. if ($v ['itemCategory'] == '报销金额调整') {
  13266. if (! empty ( $v ['price'] )) {
  13267. $psum += $v ['price'];
  13268. }
  13269. }
  13270. }
  13271. $s1 += $psum;
  13272. if (! empty ( $psum ))
  13273. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13274. else
  13275. $psum = '<td class="taR colOrange">-</td>';
  13276. $receiptL ['报销金额调整'] = $psum . $html;
  13277. } else {
  13278. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13279. foreach ( $aiList[$this->AGENCY] as $va ) {
  13280. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13281. }
  13282. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13283. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13284. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13285. }
  13286. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13287. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13288. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13289. }
  13290. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13291. foreach ( $aiList[$this->TRAIN] as $va ) {
  13292. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13293. }
  13294. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13295. foreach ( $aiList[$this->OTHER] as $va ) {
  13296. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13297. }
  13298. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13299. }
  13300. $monthStaffPrice = $receiptDetail->find ( array (
  13301. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13302. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13303. 'groupby' => 'Month(pastDate)',
  13304. 'asArray' => true
  13305. ) );
  13306. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13307. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13308. $m1 += $monthStaffPrice [0] ['price'];
  13309. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13310. } else
  13311. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13312. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13313. $list [$value ['username']] = $receiptL;
  13314. }
  13315. }
  13316. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13317. foreach ( $aiList[$this->AGENCY] as $va ) {
  13318. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13319. $subtotal[$this->AGENCY][$va['name']]=0;
  13320. }
  13321. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13322. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13323. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13324. $subtotal[$this->TRAVEL][$va['name']]=0;
  13325. }
  13326. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13327. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13328. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13329. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13330. }
  13331. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13332. foreach ( $aiList[$this->TRAIN] as $va ) {
  13333. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13334. $subtotal[$this->TRAIN][$va['name']]=0;
  13335. }
  13336. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13337. foreach ( $aiList[$this->OTHER] as $va ) {
  13338. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13339. $subtotal[$this->OTHER][$va['name']]=0;
  13340. }
  13341. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13342. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13343. $receiptL ['usernameEn'] =false;
  13344. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13345. }
  13346. $data ['list'] = $list;
  13347. // print_r($list);
  13348. $receiptCollectList = $receiptDetail->find ( array (
  13349. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13350. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13351. 'groupby' => 'item,Month(pastDate),itemCategory',
  13352. 'asArray' => true
  13353. ) );
  13354. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13355. // statistics html
  13356. $stList = $statistics->getOne ( array (
  13357. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13358. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13359. 'groupby' => 'Month(date)',
  13360. 'asArray' => true
  13361. ) );
  13362. if (empty ( $stList ))
  13363. $stList = array (
  13364. 'rePrice' => 0,
  13365. 'agPrice' => 0
  13366. );
  13367. $data ['stList'] = array (
  13368. 'rePrice' => $stList ['rePrice'],
  13369. 'agPrice' => $stList ['agPrice'],
  13370. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13371. );
  13372. $monthHtml = "";
  13373. for($i = 1; $i <= 12; $i ++) {
  13374. if ($i == $month)
  13375. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13376. else
  13377. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13378. }
  13379. $data ['monthHtml'] = $monthHtml;
  13380. $data ['year'] = $year;
  13381. $data ['month'] = $month;
  13382. $data ['nature'] = $nature;
  13383. $data ['aiList'] = $aiList;
  13384. $data ['memu'] = "receipt";
  13385. $data ['staff'] = $this->staff;
  13386. $data ['receiptMemu'] = 'companyCategoryCollect';
  13387. $data ['verifyId'] = $this->verifyId;
  13388. $data ['executeId'] = $this->executeId;
  13389. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13390. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13391. }
  13392. function staffCollectMonthDetail2() {
  13393. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13394. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13395. if (! $year)
  13396. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13397. if (! $month)
  13398. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13399. Doo::loadModel ( 'staff' );
  13400. $staff = new staff ();
  13401. Doo::loadModel ( "receiptDetail" );
  13402. $receiptDetail = new receiptDetail ();
  13403. Doo::loadModel ( 'accountItem' );
  13404. $accountItem = new accountItem ();
  13405. Doo::loadModel ( 'statistics' );
  13406. $statistics = new statistics ();
  13407. Doo::loadModel ( 'L_category' );
  13408. $lCategory = new L_category ();
  13409. $staffList = $staff->find ( array (
  13410. 'where' => 'username!="admin"',
  13411. 'asArray' => true
  13412. ) );
  13413. $categoryList = $staff->find ( array (
  13414. 'select' => 'COUNT(*) as count,cid,category',
  13415. 'where' => 'username !="admin"',
  13416. 'groupby' => 'cid',
  13417. 'asArray' => true
  13418. ) );
  13419. $list = array ();
  13420. foreach ( $categoryList as $vlu ) {
  13421. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13422. $r1 = 0;
  13423. $r2 = 0;
  13424. $r3 = 0;
  13425. $r4 = 0;
  13426. $r5 = 0;
  13427. $r6 = 0;
  13428. $r7 = 0;
  13429. $r8 = 0;
  13430. $r9 = 0;
  13431. $r10 = 0;
  13432. $r11 = 0;
  13433. $r12 = 0;
  13434. $r13 = 0;
  13435. $r14 = 0;
  13436. $r15 = 0;
  13437. $c1 = 0;
  13438. $c2 = 0;
  13439. $c3 = 0;
  13440. $c4 = 0;
  13441. $c5 = 0;
  13442. $c6 = 0;
  13443. $p1 = 0;
  13444. $p2 = 0;
  13445. $p3 = 0;
  13446. $p4 = 0;
  13447. $p5 = 0;
  13448. $p6 = 0;
  13449. $p7 = 0;
  13450. $p8 = 0;
  13451. $p9 = 0;
  13452. $t1 = 0;
  13453. $t2 = 0;
  13454. $t3 = 0;
  13455. $t4 = 0;
  13456. $t5 = 0;
  13457. $s1 = 0;
  13458. $m1 = 0;
  13459. foreach ( $staffList as $value ) {
  13460. if ($vlu ['cid'] == $value ['cid']) {
  13461. $receiptCollectList = $receiptDetail->find ( array (
  13462. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13463. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13464. 'groupby' => 'item,Month(date),itemCategory',
  13465. 'asArray' => true
  13466. ) );
  13467. if (! empty ( $receiptCollectList )) {
  13468. $receiptL = array (
  13469. '日常相关费用' => array (),
  13470. '差旅相关费用' => array (),
  13471. '培训班费用' => array (),
  13472. '其他' => array ()
  13473. );
  13474. $html = "";
  13475. $psum = 0;
  13476. $item = array (
  13477. '市内交通费',
  13478. '市内出租费',
  13479. '办事处房租',
  13480. '电话费',
  13481. '水费',
  13482. '电费',
  13483. '办公费用',
  13484. '邮寄费',
  13485. '其他费用',
  13486. '车辆费用',
  13487. '广告费',
  13488. '团队建设费',
  13489. '物业管理费',
  13490. '宽带费'
  13491. );
  13492. foreach ( $item as $va ) {
  13493. $falg = true;
  13494. foreach ( $receiptCollectList as $v ) {
  13495. if ($v ['itemCategory'] == '日常相关费用') {
  13496. if ($v ['item'] == $va) {
  13497. if ($va == '市内交通费')
  13498. $r1 += $v ['price'];
  13499. if ($va == '市内出租费')
  13500. $r2 += $v ['price'];
  13501. if ($va == '办事处房租')
  13502. $r3 += $v ['price'];
  13503. if ($va == '电话费')
  13504. $r4 += $v ['price'];
  13505. if ($va == '水费')
  13506. $r5 += $v ['price'];
  13507. if ($va == '电费')
  13508. $r6 += $v ['price'];
  13509. if ($va == '办公费用')
  13510. $r7 += $v ['price'];
  13511. if ($va == '邮寄费')
  13512. $r8 += $v ['price'];
  13513. if ($va == '其他费用')
  13514. $r9 += $v ['price'];
  13515. if ($va == '车辆费用')
  13516. $r10 += $v ['price'];
  13517. if ($va == '广告费')
  13518. $r11 += $v ['price'];
  13519. if ($va == '团队建设费')
  13520. $r13 += $v ['price'];
  13521. if ($va == '物业管理费')
  13522. $r14 += $v ['price'];
  13523. if ($va == '宽带费')
  13524. $r15 += $v ['price'];
  13525. $psum += $v ['price'];
  13526. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13527. $falg = false;
  13528. break;
  13529. }
  13530. }
  13531. }
  13532. if ($falg)
  13533. $html .= '<td class="taR">-</td>';
  13534. }
  13535. $r12 += $psum;
  13536. if (! empty ( $psum ))
  13537. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13538. else
  13539. $psum = '<td class="colGreen taR">-</td>';
  13540. $receiptL ['日常相关费用'] = $psum . $html;
  13541. /* ----------------------------------- */
  13542. $html = "";
  13543. $psum = 0;
  13544. $item = array (
  13545. '往来交通费',
  13546. '市内交通费',
  13547. '出差住宿费',
  13548. '出差补助',
  13549. '其他费用'
  13550. );
  13551. foreach ( $item as $va ) {
  13552. $falg = true;
  13553. foreach ( $receiptCollectList as $v ) {
  13554. if ($v ['itemCategory'] == '差旅相关费用') {
  13555. if ($v ['item'] == $va) {
  13556. if ($va == '往来交通费')
  13557. $c1 += $v ['price'];
  13558. if ($va == '市内交通费')
  13559. $c2 += $v ['price'];
  13560. if ($va == '出差住宿费')
  13561. $c3 += $v ['price'];
  13562. if ($va == '出差补助')
  13563. $c4 += $v ['price'];
  13564. if ($va == '其他费用')
  13565. $c5 += $v ['price'];
  13566. $psum += $v ['price'];
  13567. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13568. $falg = false;
  13569. break;
  13570. }
  13571. }
  13572. }
  13573. if ($falg)
  13574. $html .= '<td class="taR">-</td>';
  13575. }
  13576. $c6 += $psum;
  13577. if (! empty ( $psum ))
  13578. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13579. else
  13580. $psum = '<td class="colGreen taR">-</td>';
  13581. $receiptL ['差旅相关费用'] = $psum . $html;
  13582. /* ------------------------------------- */
  13583. $html = "";
  13584. $psum = 0;
  13585. $item = array (
  13586. '场租费',
  13587. '薪酬',
  13588. '住宿费',
  13589. '交通费',
  13590. '餐饮费',
  13591. '办公费',
  13592. '公关费',
  13593. '其他'
  13594. );
  13595. foreach ( $item as $va ) {
  13596. $falg = true;
  13597. foreach ( $receiptCollectList as $v ) {
  13598. if ($v ['itemCategory'] == '培训班费用') {
  13599. if ($v ['item'] == $va) {
  13600. if ($va == '场租费')
  13601. $p1 += $v ['price'];
  13602. if ($va == '薪酬')
  13603. $p2 += $v ['price'];
  13604. if ($va == '住宿费')
  13605. $p3 += $v ['price'];
  13606. if ($va == '交通费')
  13607. $p4 += $v ['price'];
  13608. if ($va == '餐饮费')
  13609. $p5 += $v ['price'];
  13610. if ($va == '办公费')
  13611. $p6 += $v ['price'];
  13612. if ($va == '公关费')
  13613. $p7 += $v ['price'];
  13614. if ($va == '其他')
  13615. $p8 += $v ['price'];
  13616. $psum += $v ['price'];
  13617. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13618. $falg = false;
  13619. break;
  13620. }
  13621. }
  13622. }
  13623. if ($falg)
  13624. $html .= '<td class="taR">-</td>';
  13625. }
  13626. $p9 += $psum;
  13627. if (! empty ( $psum ))
  13628. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13629. else
  13630. $psum = '<td class="colGreen taR">-</td>';
  13631. $receiptL ['培训班费用'] = $psum . $html;
  13632. /* ------------------------------------- */
  13633. $html = "";
  13634. $psum = 0;
  13635. $item = array (
  13636. '公关费',
  13637. '广告费',
  13638. '借款',
  13639. '可自加费用'
  13640. );
  13641. foreach ( $item as $va ) {
  13642. $falg = true;
  13643. foreach ( $receiptCollectList as $v ) {
  13644. if ($v ['itemCategory'] == '其他') {
  13645. if ($v ['item'] == $va) {
  13646. if ($va == '公关费')
  13647. $t1 += $v ['price'];
  13648. if ($va == '广告费')
  13649. $t2 += $v ['price'];
  13650. if ($va == '借款')
  13651. $t3 += $v ['price'];
  13652. if ($va == '可自加费用')
  13653. $t4 += $v ['price'];
  13654. $psum += $v ['price'];
  13655. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13656. $falg = false;
  13657. break;
  13658. }
  13659. }
  13660. }
  13661. if ($falg)
  13662. $html .= '<td class="taR">-</td>';
  13663. }
  13664. $t5 += $psum;
  13665. if (! empty ( $psum ))
  13666. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13667. else
  13668. $psum = '<td class="colGreen taR">-</td>';
  13669. $receiptL ['其他'] = $psum . $html;
  13670. /* ------------------------------------- */
  13671. $html = "";
  13672. $psum = 0;
  13673. foreach ( $receiptCollectList as $v ) {
  13674. if ($v ['itemCategory'] == '报销金额调整') {
  13675. if (! empty ( $v ['price'] )) {
  13676. $psum += $v ['price'];
  13677. }
  13678. }
  13679. }
  13680. $s1 += $psum;
  13681. if (! empty ( $psum ))
  13682. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13683. else
  13684. $psum = '<td class="taR colOrange">-</td>';
  13685. $receiptL ['报销金额调整'] = $psum . $html;
  13686. } else {
  13687. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13688. <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>';
  13689. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13690. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13691. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13692. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13693. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13694. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13695. }
  13696. $monthStaffPrice = $receiptDetail->find ( array (
  13697. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13698. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13699. 'asArray' => true
  13700. ) );
  13701. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13702. $m1 += $monthStaffPrice [0] ['price'];
  13703. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13704. } else
  13705. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13706. $list [$value ['username']] = $receiptL;
  13707. }
  13708. }
  13709. $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>
  13710. <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>
  13711. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13712. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13713. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13714. $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>
  13715. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13716. $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>';
  13717. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13718. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13719. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13720. }
  13721. $data ['list'] = $list;
  13722. $receiptCollectList = $receiptDetail->find ( array (
  13723. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13724. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13725. 'groupby' => 'item,Month(date),itemCategory',
  13726. 'asArray' => true
  13727. ) );
  13728. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13729. // statistics html
  13730. $stList = $statistics->getOne ( array (
  13731. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13732. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13733. 'groupby' => 'Month(date)',
  13734. 'asArray' => true
  13735. ) );
  13736. if (empty ( $stList ))
  13737. $stList = array (
  13738. 'rePrice' => 0,
  13739. 'agPrice' => 0
  13740. );
  13741. $data ['stList'] = array (
  13742. 'rePrice' => $stList ['rePrice'],
  13743. 'agPrice' => $stList ['agPrice'],
  13744. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13745. );
  13746. $monthHtml = "";
  13747. for($i = 1; $i <= 12; $i ++) {
  13748. if ($i == $month)
  13749. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13750. else
  13751. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13752. }
  13753. $data ['monthHtml'] = $monthHtml;
  13754. $data ['year'] = $year;
  13755. $data ['month'] = $month;
  13756. $data ['memu'] = "receipt";
  13757. $data ['staff'] = $this->staff;
  13758. $data ['receiptMemu'] = 'companyCategoryCollect';
  13759. $data ['verifyId'] = $this->verifyId;
  13760. $data ['executeId'] = $this->executeId;
  13761. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13762. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13763. }
  13764. /**
  13765. * 用户报销单列表
  13766. */
  13767. function receiptStatisticsStaffDetail() {
  13768. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13769. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13770. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13771. Doo::loadModel ( "receipt" );
  13772. $receipt = new receipt ();
  13773. Doo::loadModel ( "receiptDetail" );
  13774. $receiptDetail = new receiptDetail ();
  13775. Doo::loadModel ( 'staff' );
  13776. $staff = new staff ();
  13777. Doo::loadModel ( 'accountItem' );
  13778. $accountItem = new accountItem ();
  13779. Doo::loadModel ( 'statistics' );
  13780. $statistics = new statistics ();
  13781. if (! empty ( $username )) {
  13782. $username = addslashes ( urldecode ( $username ) );
  13783. $staffDetail = $staff->getStaffByName ( $username );
  13784. if (empty ( $staffDetail ))
  13785. die ( 'illegal request' );
  13786. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13787. $itemList = $accountItem->getAccountItem ();
  13788. $itemHtml = '';
  13789. $categoryHtml = '';
  13790. $itemKeyList = array_keys ( $itemList );
  13791. $revisePrice = 0;
  13792. // 报销单内容详情
  13793. foreach ( $list as $key => $value ) {
  13794. $accountItemList = json_decode ( $value ['accountItem'], true );
  13795. $list [$key] ['accountItemList'] = $accountItemList;
  13796. $receiptItemHtml = '';
  13797. foreach ( $itemKeyList as $v ) {
  13798. if ($v == '日常相关费用')
  13799. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13800. elseif ($v == '差旅相关费用')
  13801. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13802. elseif ($v == '培训班费用')
  13803. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13804. elseif ($v == '内部培训费用'){
  13805. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13806. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13807. }else{
  13808. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13809. }
  13810. }elseif ($v == '其他')
  13811. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13812. foreach ( $itemList [$v] as $ke => $va ) {
  13813. $falg = true;
  13814. if (! empty ( $accountItemList [$v] )) {
  13815. foreach ( $accountItemList [$v] as $ve ) {
  13816. if ($va ['name'] == $ve ['name']) {
  13817. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13818. $falg = false;
  13819. break;
  13820. }
  13821. }
  13822. }
  13823. if ($falg)
  13824. $receiptItemHtml .= '<td class="taR"></td>';
  13825. }
  13826. }
  13827. // 金额调整和费用查看
  13828. $revisePrice += $value ['revisePrice'];
  13829. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13830. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13831. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13832. }
  13833. // 报销单合计
  13834. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13835. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13836. $receiptTotalHtml = '';
  13837. // 报销单项目抬头
  13838. foreach ( $itemKeyList as $value ) {
  13839. $count = count ( $itemList [$value] ) + 1;
  13840. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13841. $categoryHtml .= '<th class="taC">合计</th>';
  13842. $sumfalg=true;
  13843. foreach ( $rtl as $rtlValue ) {
  13844. if ($rtlValue ['itemCategory'] == $value) {
  13845. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13846. $sumfalg=false;
  13847. break;
  13848. }
  13849. }
  13850. if ($sumfalg)
  13851. $receiptTotalHtml .= '<th></th>';
  13852. foreach ( $itemList [$value] as $k => $v ) {
  13853. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13854. // 合计
  13855. $falg = true;
  13856. foreach ( $receiptTotalList as $ve ) {
  13857. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13858. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13859. $falg = false;
  13860. break;
  13861. }
  13862. }
  13863. if ($falg)
  13864. $receiptTotalHtml .= '<th></th>';
  13865. }
  13866. }
  13867. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13868. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13869. if (empty ( $stList ))
  13870. $stList = array (
  13871. 'rePrice' => 0,
  13872. 'agPrice' => 0
  13873. );
  13874. $data ['stList'] = array (
  13875. 'rePrice' => $stList ['rePrice'],
  13876. 'agPrice' => $stList ['agPrice'],
  13877. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13878. );
  13879. $monthHtml = "";
  13880. for($i = 1; $i <= 12; $i ++) {
  13881. if ($i == $month)
  13882. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13883. else
  13884. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13885. }
  13886. $data ['username'] = urlencode ( $username );
  13887. $data ['usernameEN'] = $username;
  13888. $data ['monthHtml'] = $monthHtml;
  13889. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13890. $data ['list'] = $list;
  13891. $data ['categoryHtml'] = $categoryHtml;
  13892. $data ['itemHtml'] = $itemHtml;
  13893. $data ['itemList'] = $itemList;
  13894. $data ['year'] = $year;
  13895. $data ['month'] = $month;
  13896. $data ['memu'] = "receipt";
  13897. $data ['staff'] = $this->staff;
  13898. $data ['receiptMemu'] = 'companyCategoryCollect';
  13899. $data ['verifyId'] = $this->verifyId;
  13900. $data ['executeId'] = $this->executeId;
  13901. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13902. }
  13903. die ( 'illegal request' );
  13904. }
  13905. function companyMonthCollectDetail() {
  13906. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13907. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13908. if (! $year)
  13909. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13910. if (! $month)
  13911. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13912. Doo::loadModel ( 'staff' );
  13913. $staff = new staff ();
  13914. Doo::loadModel ( "receiptDetail" );
  13915. $receiptDetail = new receiptDetail ();
  13916. Doo::loadModel ( 'accountItem' );
  13917. $accountItem = new accountItem ();
  13918. Doo::loadModel ( 'statistics' );
  13919. $statistics = new statistics ();
  13920. Doo::loadModel ( 'L_category' );
  13921. $lCategory = new L_category ();
  13922. $staffList = $staff->find ( array (
  13923. 'where' => 'username!="admin"',
  13924. 'asArray' => true
  13925. ) );
  13926. $categoryList = $lCategory->find ( array (
  13927. 'asArray' => true
  13928. ) );
  13929. $aiList=$accountItem->getAccountItem();
  13930. $list = array ();
  13931. foreach ( $categoryList as $value ) {
  13932. $receiptCollectList = $receiptDetail->find ( array (
  13933. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13934. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13935. 'groupby' => 'item,Month(pastDate),itemCategory',
  13936. 'asArray' => true
  13937. ) );
  13938. if (! empty ( $receiptCollectList )) {
  13939. $receiptL = array (
  13940. '日常相关费用' => array (),
  13941. '差旅相关费用' => array (),
  13942. '内部培训费用' => array (),
  13943. '培训班费用' => array (),
  13944. '其他' => array ()
  13945. );
  13946. $html = "";
  13947. $psum = 0;
  13948. foreach ( $aiList[$this->AGENCY] as $va ) {
  13949. $falg = true;
  13950. foreach ( $receiptCollectList as $v ) {
  13951. if ($v ['itemCategory'] == $this->AGENCY) {
  13952. if ($v ['item'] == $va['name']) {
  13953. $psum += $v ['price'];
  13954. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13955. $falg = false;
  13956. break;
  13957. }
  13958. }
  13959. }
  13960. if ($falg)
  13961. $html .= '<td class="taR">-</td>';
  13962. }
  13963. if (! empty ( $psum ))
  13964. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13965. else
  13966. $psum = '<td class="colGreen taR">-</td>';
  13967. $receiptL [$this->AGENCY] = $psum . $html;
  13968. /* ----------------------------------- */
  13969. $html = "";
  13970. $psum = 0;
  13971. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13972. $falg = true;
  13973. foreach ( $receiptCollectList as $v ) {
  13974. if ($v ['itemCategory'] == $this->TRAVEL) {
  13975. if ($v ['item'] == $va['name']) {
  13976. $psum += $v ['price'];
  13977. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13978. $falg = false;
  13979. break;
  13980. }
  13981. }
  13982. }
  13983. if ($falg)
  13984. $html .= '<td class="taR">-</td>';
  13985. }
  13986. if (! empty ( $psum ))
  13987. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13988. else
  13989. $psum = '<td class="colGreen taR">-</td>';
  13990. $receiptL [$this->TRAVEL] = $psum . $html;
  13991. /* ------------------------------------- */
  13992. $html = "";
  13993. $psum = 0;
  13994. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13995. $falg = true;
  13996. foreach ( $receiptCollectList as $v ) {
  13997. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13998. if ($v ['item'] == $va['name']) {
  13999. $psum += $v ['price'];
  14000. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14001. $falg = false;
  14002. break;
  14003. }
  14004. }
  14005. }
  14006. if ($falg)
  14007. $html .= '<td class="taR">-</td>';
  14008. }
  14009. if (! empty ( $psum ))
  14010. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14011. else
  14012. $psum = '<td class="colGreen taR">-</td>';
  14013. $receiptL [$this->INTTRAIN] = $psum . $html;
  14014. /* ------------------------------------- */
  14015. $html = "";
  14016. $psum = 0;
  14017. foreach ( $aiList[$this->TRAIN] as $va ) {
  14018. $falg = true;
  14019. foreach ( $receiptCollectList as $v ) {
  14020. if ($v ['itemCategory'] == $this->TRAIN) {
  14021. if ($v ['item'] == $va['name']) {
  14022. $psum += $v ['price'];
  14023. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14024. $falg = false;
  14025. break;
  14026. }
  14027. }
  14028. }
  14029. if ($falg)
  14030. $html .= '<td class="taR">-</td>';
  14031. }
  14032. if (! empty ( $psum ))
  14033. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14034. else
  14035. $psum = '<td class="colGreen taR">-</td>';
  14036. $receiptL [$this->TRAIN] = $psum . $html;
  14037. /* ------------------------------------- */
  14038. $html = "";
  14039. $psum = 0;
  14040. foreach ( $aiList[$this->OTHER] as $va ) {
  14041. $falg = true;
  14042. foreach ( $receiptCollectList as $v ) {
  14043. if ($v ['itemCategory'] == $this->OTHER) {
  14044. if ($v ['item'] == $va['name']) {
  14045. $psum += $v ['price'];
  14046. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14047. $falg = false;
  14048. break;
  14049. }
  14050. }
  14051. }
  14052. if ($falg)
  14053. $html .= '<td class="taR">-</td>';
  14054. }
  14055. if (! empty ( $psum ))
  14056. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14057. else
  14058. $psum = '<td class="colGreen taR">-</td>';
  14059. $receiptL [$this->OTHER] = $psum . $html;
  14060. /* ------------------------------------- */
  14061. $html = "";
  14062. $psum = 0;
  14063. foreach ( $receiptCollectList as $v ) {
  14064. if ($v ['itemCategory'] == '报销金额调整') {
  14065. if (! empty ( $v ['price'] ))
  14066. $psum += $v ['price'];
  14067. }
  14068. }
  14069. if (! empty ( $psum ))
  14070. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14071. else
  14072. $psum = '<td class="taR colOrange">-</td>';
  14073. $receiptL ['报销金额调整'] = $psum . $html;
  14074. } else {
  14075. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14076. foreach ( $aiList[$this->AGENCY] as $va ) {
  14077. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14078. }
  14079. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14080. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14081. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14082. }
  14083. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14084. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14085. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14086. }
  14087. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14088. foreach ( $aiList[$this->TRAIN] as $va ) {
  14089. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14090. }
  14091. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14092. foreach ( $aiList[$this->OTHER] as $va ) {
  14093. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14094. }
  14095. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14096. }
  14097. $monthStaffPrice = $receiptDetail->find ( array (
  14098. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14099. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14100. 'asArray' => true
  14101. ) );
  14102. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14103. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14104. else
  14105. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14106. $list [$value ['title']] = $receiptL;
  14107. }
  14108. $data ['list'] = $list;
  14109. $receiptCollectList = $receiptDetail->find ( array (
  14110. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14111. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14112. 'groupby' => 'item,Month(pastDate),itemCategory',
  14113. 'asArray' => true
  14114. ) );
  14115. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14116. //print_r($data['monthPriceHtml']);
  14117. // foreach ($data['monthPriceHtml'] as $value){
  14118. // echo $value;
  14119. // }
  14120. // die;
  14121. // statistics html
  14122. $stList = $statistics->getOne ( array (
  14123. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14124. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14125. 'groupby' => 'Month(date)',
  14126. 'asArray' => true
  14127. ) );
  14128. if (empty ( $stList ))
  14129. $stList = array (
  14130. 'rePrice' => 0,
  14131. 'agPrice' => 0
  14132. );
  14133. $data ['stList'] = array (
  14134. 'rePrice' => $stList ['rePrice'],
  14135. 'agPrice' => $stList ['agPrice'],
  14136. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14137. );
  14138. $monthHtml = "";
  14139. for($i = 1; $i <= 12; $i ++) {
  14140. if ($i == $month)
  14141. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14142. else
  14143. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14144. }
  14145. $data ['aiList'] = $aiList;
  14146. $dateHtml = "";
  14147. $now = date ( "Y" );
  14148. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14149. if ($YEARD <= $now) {
  14150. $dateHtml .= '<option ';
  14151. if ($year == $YEARD) {
  14152. $dateHtml .= 'selected ';
  14153. }
  14154. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14155. }
  14156. }
  14157. $data ['dateHtml'] = $dateHtml;
  14158. $data ['monthHtml'] = $monthHtml;
  14159. $data ['year'] = $year;
  14160. $data ['month'] = $month;
  14161. $data ['memu'] = "receipt";
  14162. $data ['staff'] = $this->staff;
  14163. $data ['receiptMemu'] = 'companyCategoryCollect';
  14164. $data ['verifyId'] = $this->verifyId;
  14165. $data ['executeId'] = $this->executeId;
  14166. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14167. }
  14168. function staffCollectDetail() {
  14169. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14170. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14171. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14172. if (! $staffname) {
  14173. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14174. $staffname = urldecode ( $staffname );
  14175. }
  14176. Doo::loadModel ( 'staff' );
  14177. $staff = new staff ();
  14178. Doo::loadModel ( "receiptDetail" );
  14179. $receiptDetail = new receiptDetail ();
  14180. Doo::loadModel ( 'accountItem' );
  14181. $accountItem = new accountItem ();
  14182. Doo::loadModel ( 'statistics' );
  14183. $statistics = new statistics ();
  14184. Doo::loadModel ( 'L_category' );
  14185. $lCategory = new L_category ();
  14186. Doo::loadModel ( "receiptAuthorityManage" );
  14187. $receiptAuthorityManage = new receiptAuthorityManage ();
  14188. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14189. $cidList = array ();
  14190. foreach ( $imcStaff as $key => $value ) {
  14191. array_push ( $cidList, $value ['cid'] );
  14192. }
  14193. $cidString = implode ( ',', $cidList );
  14194. $staffList = $staff->find ( array (
  14195. 'where' => ' cid in (' . $cidString . ')',
  14196. 'asArray' => true
  14197. ) );
  14198. $stHtml = '';
  14199. $stTitle = "";
  14200. $staffId = 0;
  14201. $cid = 0;
  14202. $ocid = 0;
  14203. foreach ( $staffList as $value ) {
  14204. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14205. $stTitle = $value ['category'] . '-' . $value ['username'];
  14206. $staffId = $value ['sid'];
  14207. $cid = $value ['cid'];
  14208. $ocid = $value ['cid'];
  14209. if (! empty ( $value ['othercid'] ))
  14210. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14211. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14212. } elseif ($value ['username'] != 'admin')
  14213. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14214. }
  14215. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14216. 'where' => 'cid in(' . $cid . ')',
  14217. 'asArray' => true
  14218. ) );
  14219. if (empty ( $pcid ))
  14220. $pcid = $ocid;
  14221. $data ['ocid'] = $pcid;
  14222. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14223. $this->showCache ( $path );
  14224. //
  14225. $receiptCollectList = $receiptDetail->find ( array (
  14226. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14227. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14228. 'groupby' => 'item,Month(pastDate),itemCategory',
  14229. 'asArray' => true
  14230. ) );
  14231. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14232. // print_r($receiptCollectList);
  14233. $accountList = $accountItem->find ( array (
  14234. 'asArray' => true
  14235. ) );
  14236. // create CollectDetail HTML
  14237. $collectHtml = array ();
  14238. foreach ( $accountList as $key => $value ) {
  14239. $html = "";
  14240. $asum = 0;
  14241. for($i = 1; $i <= 12; $i ++) {
  14242. $falg = true;
  14243. foreach ( $receiptCollectList as $v ) {
  14244. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14245. if ($v ['item'] == '可自加费用') {
  14246. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14247. }
  14248. $asum += $v ['price'];
  14249. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14250. $falg = false;
  14251. break;
  14252. }
  14253. }
  14254. if ($falg)
  14255. $html .= '<td class="taR">-</td>';
  14256. }
  14257. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14258. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14259. }
  14260. $data ['collectHtml'] = $collectHtml;
  14261. // print_r($collectHtml);
  14262. // create Adjustment price html
  14263. $receiptCollectList = $receiptDetail->find ( array (
  14264. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14265. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14266. 'groupby' => 'itemCategory,Month(pastDate)',
  14267. 'asArray' => true
  14268. ) );
  14269. $adjustment = array ();
  14270. $collectArray = array (
  14271. '日常相关费用' => array (),
  14272. '差旅相关费用' => array (),
  14273. '培训班费用' => array (),
  14274. '内部培训费用'=>array(),
  14275. '其他' => array ()
  14276. );
  14277. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14278. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14279. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14280. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14281. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14282. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14283. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14284. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14285. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14286. array_push ( $collectArray ['其他'], $collectHtml );
  14287. $data ['collectArray'] = $collectArray;
  14288. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14289. array_push ( $adjustment, $collectHtml );
  14290. $data ['adjustment'] = $adjustment;
  14291. // total price html
  14292. $collectHtml = "";
  14293. $total = 0;
  14294. for($i = 1; $i <= 12; $i ++) {
  14295. $sumPrice = 0;
  14296. foreach ( $receiptCollectList as $key => $value ) {
  14297. if ($value ['month'] == $i) {
  14298. $sumPrice += $value ['price'];
  14299. }
  14300. }
  14301. if ($sumPrice == 0)
  14302. $collectHtml .= '<td class="taR">-</td>';
  14303. else
  14304. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14305. $total += $sumPrice;
  14306. }
  14307. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14308. // statistics html
  14309. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14310. if (empty ( $stList ))
  14311. $stList = array (
  14312. 'rePrice' => 0,
  14313. 'agPrice' => 0
  14314. );
  14315. $data ['stList'] = array (
  14316. 'rePrice' => $stList ['rePrice'],
  14317. 'agPrice' => $stList ['agPrice'],
  14318. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14319. );
  14320. $data ['totalPrice'] = $collectHtml;
  14321. $data ['totalYear'] = $total;
  14322. $data ['stHtml'] = $stHtml;
  14323. $data ['year'] = $year;
  14324. $data ['stTitle'] = $stTitle;
  14325. $data ['staffname'] = urlencode ( $staffname );
  14326. $data ['memu'] = "receipt";
  14327. $data ['staff'] = $this->staff;
  14328. $data ['receiptMemu'] = 'companyCategoryCollect';
  14329. $data ['verifyId'] = $this->verifyId;
  14330. $data ['executeId'] = $this->executeId;
  14331. if ($year < date ( "Y" )) {
  14332. Doo::loadModel ( 'receipt' );
  14333. $receipt = new receipt ();
  14334. $receiptList = $receipt->find ( array (
  14335. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14336. 'asArray' => true
  14337. ) );
  14338. if (empty ( $receiptList )) { // generated files
  14339. ob_start ();
  14340. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14341. $this->cacheFile ( $path );
  14342. die ();
  14343. }
  14344. }
  14345. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14346. }
  14347. function BUGFLAG() {
  14348. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14349. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14350. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14351. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14352. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14353. if (empty ( $status ))
  14354. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14355. $page_size = 12;
  14356. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14357. $vidList = array ();
  14358. $button = 0;
  14359. Doo::loadModel ( 'verify' );
  14360. $verify = new verify ();
  14361. Doo::loadModel ( 'receipt' );
  14362. $receipt = new receipt ();
  14363. Doo::loadModel ( 'staff' );
  14364. $staff = new staff ();
  14365. Doo::loadModel ( 'L_category' );
  14366. $Lcategory = new L_category ();
  14367. $dateCondition = " and Year(date) =" . $year;
  14368. if (! empty ( $month ))
  14369. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14370. $categoryList = $Lcategory->find ( array (
  14371. 'asArray' => true
  14372. ) );
  14373. $staffList = $staff->find ( array (
  14374. 'where' => 'cid=' . $cid,
  14375. 'asArray' => true
  14376. ) );
  14377. $cateCondition = "";
  14378. $staffCondition = "";
  14379. $approvalCondition = "";
  14380. if (! empty ( $cid ))
  14381. $cateCondition = ' and cid=' . $cid;
  14382. if (! empty ( $sid )) {
  14383. $staffCondition = ' and staff=' . $sid;
  14384. $cateCondition = "";
  14385. }
  14386. $approvalCondition = " and status=" . $status;
  14387. if ($status == 2) {
  14388. // 查找角色审批人
  14389. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14390. }
  14391. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14392. $approvalCondition = ' and status=2 ';
  14393. }
  14394. if ($status == 1) {
  14395. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14396. }
  14397. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14398. $pageinfo ['page'] = array (
  14399. 'previous' => ''
  14400. );
  14401. if ($status == 0) {
  14402. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14403. $receiptList = $receipt->find ( array (
  14404. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14405. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14406. 'desc' => 'rid',
  14407. 'asArray' => true
  14408. ) );
  14409. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14410. } else
  14411. $receiptList = $receipt->find ( array (
  14412. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14413. 'desc' => 'rid',
  14414. 'asArray' => true
  14415. ) );
  14416. $rLRes = $receipt->find ( array (
  14417. '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,
  14418. 'desc' => 'rid',
  14419. 'asArray' => true
  14420. ) );
  14421. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14422. // print_r($pageinfo);
  14423. $Locate = 0;
  14424. foreach ( $receiptList as $key => $value ) {
  14425. $receiptList [$key] ['Locate'] = $Locate;
  14426. $Locate ++;
  14427. $receiptList [$key] ['reviseDetail'] = array ();
  14428. if (! empty ( $value ['reviseDetail'] ))
  14429. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14430. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14431. $categoryDetil = $Lcategory->getOne ( array (
  14432. 'where' => 'cid=' . $value ['cid'],
  14433. 'asArray' => true
  14434. ) );
  14435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14436. $verifyList = $verify->getOne ( array (
  14437. 'where' => 'vid=' . $value ['verify'],
  14438. 'asArray' => true
  14439. ) );
  14440. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14441. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14442. foreach ( $verifyList as $k => $v ) {
  14443. // init verifyStaff
  14444. $verifyList [$k] ['date'] = "";
  14445. $verifyList [$k] ['opinion'] = "";
  14446. $verifyList [$k] ['status'] = "";
  14447. if (empty ( $verifyStaff )) {
  14448. $verifyList [$k] ['date'] = "";
  14449. $verifyList [$k] ['opinion'] = "";
  14450. if ($v [0] == $this->staff [0] ['sid']) {
  14451. $verifyList [$k] ['status'] = 4;
  14452. $button = 4;
  14453. }
  14454. } else {
  14455. $flag = true;
  14456. foreach ( $verifyStaff as $m => $u ) {
  14457. if ($v [0] == $m) {
  14458. $verifyList [$k] ['date'] = $u ['date'];
  14459. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14460. $verifyList [$k] ['status'] = $u ['status'];
  14461. $flag = false;
  14462. break;
  14463. }
  14464. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14465. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14466. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14467. }
  14468. if ($flag) { // 检测可编辑
  14469. if ($v [0] == $this->staff [0] ['sid']) {
  14470. $verifyList [$k] ['status'] = 4;
  14471. $button = 4;
  14472. }
  14473. }
  14474. }
  14475. }
  14476. $receiptList [$key] ['verifyList'] = $verifyList;
  14477. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14478. 'where' => 'sid=' . $value ['staff'],
  14479. 'asArray' => true
  14480. ) );
  14481. $receiptList [$key] ['button'] = $button;
  14482. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14483. }
  14484. // print_r($receiptList);die;
  14485. // $data['verifyDetail']=$verifyDetail;
  14486. $mothHtml = "";
  14487. for($i = 1; $i <= 12; $i ++) {
  14488. if ($month == $i)
  14489. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14490. else
  14491. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14492. }
  14493. $data ['mothHtml'] = $mothHtml;
  14494. $data ['page'] = $pageinfo;
  14495. $data ['receiptList'] = $receiptList;
  14496. $data ['receiptApprovalCount'] = count ( $rLRes );
  14497. $data ['status'] = $status;
  14498. $data ['year'] = $year;
  14499. $data ['categoryList'] = $categoryList;
  14500. $data ['staffList'] = $staffList;
  14501. $data ['cid'] = $cid;
  14502. $data ['sid'] = $sid;
  14503. // print_r($receiptList);
  14504. $data ['memu'] = "receipt";
  14505. $data ['staff'] = $this->staff;
  14506. $data ['receiptMemu'] = 'approvalExpenses';
  14507. $data ['verifyId'] = $this->verifyId;
  14508. $data ['executeId'] = $this->executeId;
  14509. $this->render ( "/admin/FALG", $data );
  14510. }
  14511. function ajaxGetReceiptOrder() {
  14512. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14513. if (! empty ( $receiptOrder )) {
  14514. Doo::loadModel ( 'receipt' );
  14515. $receipt = new receipt ();
  14516. Doo::loadModel ( 'staff' );
  14517. $staff = new staff ();
  14518. $receiptInfo = $receipt->getOne ( array (
  14519. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14520. 'asArray' => true
  14521. ) );
  14522. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14523. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14524. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14525. </tbody></table><table class="table table table-bordered"><tbody>';
  14526. foreach ( $verifyStaff as $key => $value ) {
  14527. $staffInfo = $staff->getOne ( array (
  14528. 'select' => 'username',
  14529. 'where' => ' sid="' . $key . '"',
  14530. 'asArray' => true
  14531. ) );
  14532. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14533. }
  14534. $html .= '</tbody></table></div></div>';
  14535. echo json_encode ( array (
  14536. 'status' => 1,
  14537. 'receiptHtml' => $html
  14538. ) );
  14539. die ();
  14540. }
  14541. echo json_encode ( array (
  14542. 'status' => 2,
  14543. 'receiptHtml' => ''
  14544. ) );
  14545. die ();
  14546. }
  14547. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14548. if (! empty ( $receiptCollectList )) {
  14549. $receiptL = array (
  14550. '日常相关费用' => array (),
  14551. '差旅相关费用' => array (),
  14552. '内部培训费用'=>array(),
  14553. '培训班费用' => array (),
  14554. '其他' => array ()
  14555. );
  14556. $html = "";
  14557. $psum = 0;
  14558. foreach ( $aiList[$this->AGENCY] as $value ) {
  14559. $falg = true;
  14560. foreach ( $receiptCollectList as $v ) {
  14561. if ($v ['itemCategory'] == '日常相关费用') {
  14562. if ($v ['item'] == $value['name']) {
  14563. $psum += $v ['price'];
  14564. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14565. $falg = false;
  14566. break;
  14567. }
  14568. }
  14569. }
  14570. if ($falg)
  14571. $html .= '<td class="taR">-</td>';
  14572. }
  14573. if (! empty ( $psum ))
  14574. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14575. else
  14576. $psum = '<td class="colGreen taR">-</td>';
  14577. $receiptL ['日常相关费用'] = $psum . $html;
  14578. /* ----------------------------------- */
  14579. $html = "";
  14580. $psum = 0;
  14581. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14582. $falg = true;
  14583. foreach ( $receiptCollectList as $v ) {
  14584. if ($v ['itemCategory'] == '差旅相关费用') {
  14585. if ($v ['item'] == $value['name']) {
  14586. $psum += $v ['price'];
  14587. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14588. $falg = false;
  14589. break;
  14590. }
  14591. }
  14592. }
  14593. if ($falg)
  14594. $html .= '<td class="taR">-</td>';
  14595. }
  14596. if (! empty ( $psum ))
  14597. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14598. else
  14599. $psum = '<td class="colGreen taR">-</td>';
  14600. $receiptL ['差旅相关费用'] = $psum . $html;
  14601. /* ----------------------------------- */
  14602. $html = "";
  14603. $psum = 0;
  14604. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14605. $falg = true;
  14606. foreach ( $receiptCollectList as $v ) {
  14607. if ($v ['itemCategory'] == '内部培训费用') {
  14608. if ($v ['item'] == $value['name']) {
  14609. $psum += $v ['price'];
  14610. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14611. $falg = false;
  14612. break;
  14613. }
  14614. }
  14615. }
  14616. if ($falg)
  14617. $html .= '<td class="taR">-</td>';
  14618. }
  14619. if (! empty ( $psum ))
  14620. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14621. else
  14622. $psum = '<td class="colGreen taR">-</td>';
  14623. $receiptL ['内部培训费用'] = $psum . $html;
  14624. /* ------------------------------------- */
  14625. $html = "";
  14626. $psum = 0;
  14627. foreach ( $aiList[$this->TRAIN] as $value ) {
  14628. $falg = true;
  14629. foreach ( $receiptCollectList as $v ) {
  14630. if ($v ['itemCategory'] == '培训班费用') {
  14631. if ($v ['item'] == $value['name']) {
  14632. $psum += $v ['price'];
  14633. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14634. $falg = false;
  14635. break;
  14636. }
  14637. }
  14638. }
  14639. if ($falg)
  14640. $html .= '<td class="taR">-</td>';
  14641. }
  14642. if (! empty ( $psum ))
  14643. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14644. else
  14645. $psum = '<td class="colGreen taR">-</td>';
  14646. $receiptL ['培训班费用'] = $psum . $html;
  14647. /* ------------------------------------- */
  14648. $html = "";
  14649. $psum = 0;
  14650. foreach ( $aiList[$this->OTHER] as $value ) {
  14651. $falg = true;
  14652. foreach ( $receiptCollectList as $v ) {
  14653. if ($v ['itemCategory'] == '其他') {
  14654. if ($v ['item'] == $value['name']) {
  14655. $psum += $v ['price'];
  14656. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14657. $falg = false;
  14658. break;
  14659. }
  14660. }
  14661. }
  14662. if ($falg)
  14663. $html .= '<td class="taR">-</td>';
  14664. }
  14665. if (! empty ( $psum ))
  14666. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14667. else
  14668. $psum = '<td class="colGreen taR">-</td>';
  14669. $receiptL ['其他'] = $psum . $html;
  14670. /* ------------------------------------- */
  14671. $html = "";
  14672. $psum = 0;
  14673. foreach ( $receiptCollectList as $v ) {
  14674. if ($v ['itemCategory'] == '报销金额调整') {
  14675. if (! empty ( $v ['price'] ))
  14676. $psum += $v ['price'];
  14677. }
  14678. }
  14679. if (! empty ( $psum ))
  14680. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14681. else
  14682. $psum = '<td class="taR colOrange">-</td>';
  14683. $receiptL ['报销金额调整'] = $psum . $html;
  14684. } else {
  14685. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14686. foreach ( $aiList[$this->AGENCY] as $va ) {
  14687. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14688. }
  14689. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14690. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14691. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14692. }
  14693. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14694. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14695. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14696. }
  14697. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14698. foreach ( $aiList[$this->TRAIN] as $va ) {
  14699. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14700. }
  14701. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14702. foreach ( $aiList[$this->OTHER] as $va ) {
  14703. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14704. }
  14705. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14706. }
  14707. return $receiptL;
  14708. }
  14709. function eMail() {
  14710. Doo::loadModel ( 'staff' );
  14711. $staff = new staff ();
  14712. Doo::loadModel ( 'receipt' );
  14713. $receipt = new receipt ();
  14714. Doo::loadModel ( 'L_category' );
  14715. $Lcategory = new L_category ();
  14716. Doo::loadModel ( "verify" );
  14717. $verify = new verify ();
  14718. $staffList = $staff->find ( array (
  14719. 'asArray' => true
  14720. ) );
  14721. foreach ( $staffList as $key => $value ) {
  14722. if ($value ['username'] != 'admin') {
  14723. // 提交人
  14724. $receiptList = $receipt->find ( array (
  14725. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14726. 'asArray' => true
  14727. ) );
  14728. if (! empty ( $receiptList )) {
  14729. $html = '<br><div><style></style>
  14730. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14731. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14732. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14733. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14734. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14735. <tbody><tr>
  14736. <td style="padding: 0 40px;" align="left">
  14737. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14738. </td></tr><tr>
  14739. <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>
  14740. </tr>
  14741. </tbody> </table></td> </tr> <tr><td>
  14742. <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">
  14743. <tbody> <tr><td>
  14744. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14745. 以下报销单完成了审批,等着收款吧:</p>
  14746. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14747. foreach ( $receiptList as $k => $v ) {
  14748. $category = $Lcategory->getOne ( array (
  14749. 'where' => 'cid=' . $v ['cid'],
  14750. 'asArray' => true
  14751. ) );
  14752. $html .= '
  14753. <tr>
  14754. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14755. <td align="left">
  14756. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14757. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14758. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14759. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14760. </tr>';
  14761. }
  14762. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14763. <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>
  14764. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14765. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14766. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14767. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14768. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14769. $receipt = new receipt ();
  14770. $receipt->notice = 1;
  14771. $receipt->update ( array (
  14772. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14773. ) );
  14774. }
  14775. }
  14776. // 审批人
  14777. $verifyList = $verify->find ( array (
  14778. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14779. 'asArray' => true
  14780. ) );
  14781. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14782. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14783. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14784. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14785. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14786. <tbody><tr><td style="padding: 0 40px;" align="left">
  14787. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14788. </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>
  14789. </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">
  14790. <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>
  14791. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14792. foreach ( $verifyList as $k => $v ) {
  14793. $receiptList = $receipt->find ( array (
  14794. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14795. 'asArray' => true
  14796. ) );
  14797. foreach ( $receiptList as $r => $l ) {
  14798. $category = $Lcategory->getOne ( array (
  14799. 'where' => 'cid=' . $l ['cid'],
  14800. 'asArray' => true
  14801. ) );
  14802. $staffDetile = $staff->getOne ( array (
  14803. 'where' => 'sid=' . $l ['staff'],
  14804. 'asArray' => true
  14805. ) );
  14806. $html .= '
  14807. <tr>
  14808. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14809. <td align="left">
  14810. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14811. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14812. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14813. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14814. </tr>';
  14815. }
  14816. }
  14817. $html .= '
  14818. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14819. <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>
  14820. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14821. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14822. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14823. // $receipt=new receipt();
  14824. // $receipt->notice=1;
  14825. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14826. }
  14827. }
  14828. }
  14829. }
  14830. function setWXMsg($rid, $type) {
  14831. Doo::loadModel ( "receipt" );
  14832. $receipt = new receipt ();
  14833. $receiptDetail = $receipt->getOne ( array (
  14834. 'where' => 'rid=' . $rid,
  14835. 'asArray' => true
  14836. ) );
  14837. if (! empty ( $receiptDetail )) {
  14838. Doo::loadModel ( 'staff' );
  14839. $staff = new staff ();
  14840. $staffmsg = $staff->getOne ( array (
  14841. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14842. 'asArray' => TRUE
  14843. ) );
  14844. if (! empty ( $staffmsg ['wxid'] )) {
  14845. require_once (SITE_PATH . '/protected/class/client.php');
  14846. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14847. $user = $staffmsg ['wxid'];
  14848. $receiptName = '';
  14849. $msg = '';
  14850. switch ($receiptDetail ['Rtype']) {
  14851. case 0 :
  14852. $receiptName = '报销';
  14853. break;
  14854. case 1 :
  14855. $receiptName = '借款';
  14856. break;
  14857. case 2 :
  14858. $receiptName = '对公汇款';
  14859. break;
  14860. }
  14861. switch ($type) {
  14862. case 1 :
  14863. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14864. break;
  14865. case 2 :
  14866. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14867. break;
  14868. case 3 :
  14869. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14870. break;
  14871. }
  14872. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14873. }
  14874. }
  14875. }
  14876. // Email发送函数
  14877. function SMail($toemail, $subject, $contents) {
  14878. Doo::loadClass ( 'class.phpmailer' );
  14879. $mail = new PHPMailer ();
  14880. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14881. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14882. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14883. $mail->Password = "cDO1GjtY1seH"; // 密码
  14884. $mail->CharSet = "UTF8";
  14885. $mail->SMTPAuth = true;
  14886. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14887. $mail->Mailer = "smtp";
  14888. $mail->Port = 25;
  14889. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14890. $mail->MsgHTML ( $contents );
  14891. $mail->AddAddress ( $toemail );
  14892. $mail->CharSet = "UTF-8";
  14893. return $mail->Send ();
  14894. }
  14895. function h5Upload() {
  14896. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14897. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14898. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14899. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14900. header ( "HTTP/1.1 500 Internal Server Error" );
  14901. echo "POST exceeded maximum allowed size.";
  14902. exit ( 0 );
  14903. }
  14904. // Settings
  14905. $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)
  14906. $upload_name = "Filedata";
  14907. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14908. $extension_whitelist = array (
  14909. "doc",
  14910. "txt",
  14911. "jpg",
  14912. "gif",
  14913. "png"
  14914. ); // Allowed file extensions
  14915. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14916. // Other variables
  14917. $MAX_FILENAME_LENGTH = 260;
  14918. $file_name = "";
  14919. $file_extension = "";
  14920. $uploadErrors = array (
  14921. 0 => "文件上传成功",
  14922. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14923. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14924. 3 => "上传的文件仅为部分文件",
  14925. 4 => "没有文件上传",
  14926. 6 => "缺少临时文件夹"
  14927. );
  14928. $nk = time ();
  14929. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14930. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14931. echo "文件无法保存.";
  14932. exit ( 0 );
  14933. }
  14934. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14935. echo json_encode ( array (
  14936. 'filename' => $file_name,
  14937. 'id' => $nk
  14938. ) );
  14939. exit ( 0 );
  14940. }
  14941. function swfupload() {
  14942. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14943. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14944. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14945. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14946. header ( "HTTP/1.1 500 Internal Server Error" );
  14947. echo "POST exceeded maximum allowed size.";
  14948. exit ( 0 );
  14949. }
  14950. // Settings
  14951. $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)
  14952. $upload_name = "Filedata";
  14953. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14954. $extension_whitelist = array (
  14955. "doc",
  14956. "txt",
  14957. "jpg",
  14958. "gif",
  14959. "png"
  14960. ); // Allowed file extensions
  14961. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14962. // Other variables
  14963. $MAX_FILENAME_LENGTH = 260;
  14964. $file_name = "";
  14965. $file_extension = "";
  14966. $uploadErrors = array (
  14967. 0 => "文件上传成功",
  14968. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14969. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14970. 3 => "上传的文件仅为部分文件",
  14971. 4 => "没有文件上传",
  14972. 6 => "缺少临时文件夹"
  14973. );
  14974. $nk = time ();
  14975. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14976. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14977. echo "文件无法保存.";
  14978. exit ( 0 );
  14979. }
  14980. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14981. echo json_encode ( array (
  14982. 'filename' => $file_name,
  14983. 'id' => $nk
  14984. ) );
  14985. exit ( 0 );
  14986. }
  14987. function _GetFileEXT($filename) {
  14988. $pics = explode ( '.', $filename );
  14989. $num = count ( $pics );
  14990. return $pics [$num - 1];
  14991. }
  14992. /**
  14993. * 获取get或者POST值
  14994. * @param string $name 属性名称
  14995. * @return fixed 值
  14996. */
  14997. function get_args($name) {
  14998. if (isset ( $_GET [$name] )) {
  14999. if (is_array ( $_GET [$name] ))
  15000. return $_GET [$name];
  15001. else
  15002. return addslashes ( $_GET [$name] );
  15003. } elseif (isset ( $_POST [$name] )) {
  15004. if (is_array ( $_POST [$name] ))
  15005. return $_POST [$name];
  15006. else
  15007. return addslashes ( $_POST [$name] );
  15008. } else
  15009. return false;
  15010. }
  15011. function num_to_rmb($num) {
  15012. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15013. $c2 = "分角元拾佰仟万拾佰仟亿";
  15014. // 精确到分后面就不要了,所以只留两个小数位
  15015. $num = round ( $num, 2 );
  15016. // 将数字转化为整数
  15017. $num = $num * 100;
  15018. if (strlen ( $num ) > 10) {
  15019. return "金额太大,请检查";
  15020. }
  15021. $i = 0;
  15022. $c = "";
  15023. while ( 1 ) {
  15024. if ($i == 0) {
  15025. // 获取最后一位数字
  15026. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15027. } else {
  15028. $n = $num % 10;
  15029. }
  15030. // 每次将最后一位数字转化为中文
  15031. $p1 = substr ( $c1, 3 * $n, 3 );
  15032. $p2 = substr ( $c2, 3 * $i, 3 );
  15033. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15034. $c = $p1 . $p2 . $c;
  15035. } else {
  15036. $c = $p1 . $c;
  15037. }
  15038. $i = $i + 1;
  15039. // 去掉数字最后一位了
  15040. $num = $num / 10;
  15041. // echo $num.'</br>';
  15042. $num = ( int ) $num;
  15043. // $num =floor($num);
  15044. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15045. // echo $num.'</br>';
  15046. // 结束循环
  15047. if ($num == 0) {
  15048. break;
  15049. }
  15050. }
  15051. // echo $c.'</br>';
  15052. $j = 0;
  15053. $slen = strlen ( $c );
  15054. while ( $j < $slen ) {
  15055. // utf8一个汉字相当3个字符
  15056. $m = substr ( $c, $j, 6 );
  15057. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15058. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15059. $left = substr ( $c, 0, $j );
  15060. $right = substr ( $c, $j + 3 );
  15061. $c = $left . $right;
  15062. $j = $j - 3;
  15063. $slen = $slen - 3;
  15064. }
  15065. $j = $j + 3;
  15066. }
  15067. // 这个是为了去掉类似23.0中最后一个“零”字
  15068. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15069. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15070. }
  15071. // 将处理的汉字加上“整”
  15072. if (empty ( $c )) {
  15073. return "零元整";
  15074. } else {
  15075. return $c . "整";
  15076. }
  15077. }
  15078. /**
  15079. * 获得分页数据
  15080. * @param unknown_type $table
  15081. * @param unknown_type $condition
  15082. * @param unknown_type $on_page
  15083. * @param unknown_type $page_size
  15084. */
  15085. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15086. $page_c = "";
  15087. $page ['previous'] = $this->get_previous ( $on_page );
  15088. $page ['on_page'] = $on_page;
  15089. $total_count = $this->get_table_count ( $table, $condition );
  15090. $total = intval ( $total_count / $page_size );
  15091. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15092. $page ['total_data'] = $total_count;
  15093. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15094. $i = 1;
  15095. $page_max = 1;
  15096. $page_width = 3;
  15097. if ($on_page >= $page_width) {
  15098. $page_max = intval ( $on_page / $page_width ) + 1;
  15099. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15100. }
  15101. for(; $i <= $page ['total_page']; $i ++) {
  15102. if ($i == $on_page)
  15103. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15104. else
  15105. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15106. if ($i == ($page_width * $page_max))
  15107. break;
  15108. }
  15109. $page ['page'] = $page_c;
  15110. $page ['lower'] = (-- $on_page) * $page_size;
  15111. return $page;
  15112. }
  15113. /**
  15114. * 获取总页数
  15115. * @param unknown_type $table
  15116. * @param unknown_type $condition
  15117. */
  15118. public function get_table_count($table = "", $condition = "") {
  15119. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15120. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15121. // echo $sql;die;
  15122. $query = Doo::db ()->query ( $sql );
  15123. $result = $query->fetch ();
  15124. return $result ['count'];
  15125. }
  15126. /**
  15127. * 获取上一页
  15128. * @param unknown_type $on_page
  15129. */
  15130. function get_previous($on_page = 1) {
  15131. return $on_page != 0 ? $on_page - 1 : $on_page;
  15132. }
  15133. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15134. // 收入合计
  15135. Doo::loadModel ( 'invoiceTraining' );
  15136. $invoiceTraining = new invoiceTraining ();
  15137. Doo::loadModel ( 'receipt' );
  15138. $receipt = new receipt ();
  15139. $invoiceTrainingDetail = array (
  15140. 'invoiceArriveAmount' => '0.00',
  15141. 'RIAmount' => '0.00',
  15142. 'invoiceTotalAmount' => '0.00',
  15143. 'invoiceCompanyAmount' => '0.00',
  15144. 'invoiceArriveAmountM'=>'0.00',
  15145. 'invoiceCompanyAmountM'=>'0.00'
  15146. );
  15147. if ($invoiceTrainId != 0) {
  15148. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15149. }
  15150. $invoiceArriveAmount = $RIAmount = 0;
  15151. if (! empty ( $invoiceTrainingDetail )) {
  15152. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15153. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15154. }
  15155. // 备用金
  15156. $sum = 0;
  15157. if (! empty ( $trainLoanRid )) {
  15158. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15159. foreach ($receiptLoanList as $key=>$value){
  15160. $sum+=$value['sum'];
  15161. }
  15162. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15163. // $sum = $receiptLoanDetailBak ['sum'];
  15164. }
  15165. // 支出项金额详情
  15166. // 项目金额合计
  15167. Doo::loadModel ( 'RItem' );
  15168. $RItem = new RItem ();
  15169. Doo::loadModel ( 'accountItem' );
  15170. $accountItem = new accountItem ();
  15171. // 讲师获得
  15172. Doo::loadModel ( 'RILecturer' );
  15173. $RILecturer = new RILecturer ();
  15174. $RItemList = $RItem->getRItemByRid ($rid );
  15175. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15176. // 支出项金额详情
  15177. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15178. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15179. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15180. return $payment;
  15181. }
  15182. }
  15183. ?>