ReceiptController.php 569 KB

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