ReceiptController.php 569 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418
  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. echo $itinerary;
  417. die;
  418. Doo::loadModel ( 'receipt' );
  419. Doo::loadModel ( 'receiptDetail' );
  420. Doo::loadModel ( 'accountItem' );
  421. $accountItem = new accountItem ();
  422. $receipt = new receipt ();
  423. Doo::loadModel ( 'enclosur' );
  424. Doo::loadModel ( 'execute' );
  425. $execute = new execute ();
  426. $executeDetail = $execute->getOne ( array (
  427. 'where' => 'mold="报销单执行人"',
  428. 'asArray' => true
  429. ) );
  430. $aItem = $accountItem->find ( array (
  431. 'asArray' => true
  432. ) );
  433. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  434. $ag = $tr = $ta = $ot= $it = 0;
  435. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  436. foreach ( $aItem as $key => $value ) {
  437. if ($value ['category'] == $this->AGENCY) {
  438. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  439. array_push ( $accountJson [$this->AGENCY], array (
  440. 'aid' => $value ['aid'],
  441. 'name' => $value ['name'],
  442. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  443. ) );
  444. $sum += $agency [$ag];
  445. $agencySum += $agency [$ag];
  446. }
  447. $ag ++;
  448. }
  449. if ($value ['category'] == $this->TRAVEL) {
  450. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  451. array_push ( $accountJson [$this->TRAVEL], array (
  452. 'aid' => $value ['aid'],
  453. 'name' => $value ['name'],
  454. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  455. ) );
  456. $sum += $travel [$tr];
  457. $travelSum += $travel [$tr];
  458. }
  459. $tr ++;
  460. }
  461. if ($value ['category'] == $this->TRAIN) {
  462. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  463. array_push ( $accountJson [$this->TRAIN], array (
  464. 'aid' => $value ['aid'],
  465. 'name' => $value ['name'],
  466. 'price' => number_format ( $train [$ta], 2, '.', '' )
  467. ) );
  468. $sum += $train [$ta];
  469. $trainSum += $train [$ta];
  470. }
  471. $ta ++;
  472. }
  473. if ($value ['category'] == $this->INTTRAIN) {
  474. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  475. array_push ( $accountJson [$this->INTTRAIN], array (
  476. 'aid' => $value ['aid'],
  477. 'name' => $value ['name'],
  478. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  479. ) );
  480. $sum += $inttrain [$it];
  481. $inttrainSum += $inttrain [$it];
  482. }
  483. $it ++;
  484. }
  485. if ($value ['category'] == $this->OTHER) {
  486. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  487. array_push ( $accountJson [$this->OTHER], array (
  488. 'aid' => $value ['aid'],
  489. 'name' => $value ['name'],
  490. 'price' => number_format ( $other [$ot], 2, '.', '' )
  491. ) );
  492. $sum += $other [$ot];
  493. $otherSum += $other [$ot];
  494. }
  495. $ot ++;
  496. }
  497. }
  498. $accountJson ['cSum'] = array (
  499. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  500. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  501. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  502. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  503. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  504. );
  505. // 报销单
  506. $receipt->accountItem = json_encode ( $accountJson );
  507. $receipt->staff = $this->staff [0] ['sid'];
  508. $receipt->sum = number_format ( $sum, 2, '.', '' );
  509. $receipt->date = date ( "Y-m-d" );
  510. $receipt->cid = $cid;
  511. $receipt->status = 5;
  512. // 修改审批流程加入角色
  513. $receipt->verify = $verify;
  514. $receipt->executeCopy = $executeDetail ['staff'];
  515. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  516. $order = array (
  517. "\r\n",
  518. "\n",
  519. "\r"
  520. );
  521. $replace = '<br/>';
  522. $explanation = str_replace ( $order, $replace, $explanation );
  523. $receipt->explanation = $explanation;
  524. $receipt->receiptClass = $receiptClass;
  525. $receipt->itinerary=$itinerary;
  526. $receipt->remittanceName = $remittanceName;
  527. $receipt->bankName = $bankName;
  528. $receipt->bankNumber = $bankNumber;
  529. $receipt->remittanceBankType = $remittanceBankType;
  530. if ($remittanceBankType == 1) {
  531. $receipt->coupletNumber = $coupletNumber;
  532. }
  533. $rid = $receipt->insert ();
  534. //记录行程单
  535. $this->_storageItinerary($itinerary,$rid);
  536. // 附件
  537. if (! empty ( $enclosurName )) {
  538. $enclosurArray = explode ( '-', $enclosurName );
  539. foreach ( $enclosurArray as $value ) {
  540. $enclosur = new enclosur ();
  541. $enclosur->name = $value;
  542. $enclosur->rid = $rid;
  543. $enclosur->insert ();
  544. }
  545. }
  546. // 报销详情
  547. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  548. $receiptDetail = new receiptDetail ();
  549. $receiptDetail->staff = $this->staff [0] ['sid'];
  550. $receiptDetail->item = $value ['name'];
  551. $receiptDetail->itemCategory = $this->AGENCY;
  552. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  553. $receiptDetail->date = date ( "Y-m-d" );
  554. $receiptDetail->cid = $cid;
  555. $receiptDetail->rid = $rid;
  556. $receiptDetail->status = 4;
  557. $receiptDetail->insert ();
  558. }
  559. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  560. $receiptDetail = new receiptDetail ();
  561. $receiptDetail->staff = $this->staff [0] ['sid'];
  562. $receiptDetail->item = $value ['name'];
  563. $receiptDetail->itemCategory = $this->TRAVEL;
  564. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  565. $receiptDetail->date = date ( "Y-m-d" );
  566. $receiptDetail->cid = $cid;
  567. $receiptDetail->rid = $rid;
  568. $receiptDetail->status = 4;
  569. $receiptDetail->insert ();
  570. }
  571. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  572. $receiptDetail = new receiptDetail ();
  573. $receiptDetail->staff = $this->staff [0] ['sid'];
  574. $receiptDetail->item = $value ['name'];
  575. $receiptDetail->itemCategory = $this->TRAIN;
  576. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  577. $receiptDetail->date = date ( "Y-m-d" );
  578. $receiptDetail->cid = $cid;
  579. $receiptDetail->rid = $rid;
  580. $receiptDetail->status = 4;
  581. $receiptDetail->insert ();
  582. }
  583. // 内训
  584. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  585. $receiptDetail = new receiptDetail ();
  586. $receiptDetail->staff = $this->staff [0] ['sid'];
  587. $receiptDetail->item = $value ['name'];
  588. $receiptDetail->itemCategory = $this->INTTRAIN;
  589. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  590. $receiptDetail->date = date ( "Y-m-d" );
  591. $receiptDetail->cid = $cid;
  592. $receiptDetail->rid = $rid;
  593. $receiptDetail->status = 4;
  594. $receiptDetail->insert ();
  595. }
  596. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  597. $receiptDetail = new receiptDetail ();
  598. $receiptDetail->staff = $this->staff [0] ['sid'];
  599. $receiptDetail->item = $value ['name'];
  600. $receiptDetail->itemCategory = $this->OTHER;
  601. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  602. $receiptDetail->date = date ( "Y-m-d" );
  603. $receiptDetail->cid = $cid;
  604. $receiptDetail->rid = $rid;
  605. $receiptDetail->status = 4;
  606. $receiptDetail->insert ();
  607. }
  608. return true;
  609. } else
  610. return false;
  611. }
  612. function addReceipt() {
  613. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  614. if ($this->_buildFeeData(1)) {
  615. return "/saeaBorad";
  616. } else{
  617. die ( 'illegal request' );
  618. }
  619. }
  620. function addFeeTravel(){
  621. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  622. $itineraryList=json_decode($itinerary,true);
  623. foreach ($itineraryList as $key=>$value){
  624. if(empty($value['departuredate'])||empty($value['departurecity'])){
  625. header ( 'Content-Type:text/html;charset=utf-8' );
  626. die ( '请设置出发地和出发日期' );
  627. }
  628. }
  629. if ($this->_buildFeeData(2,$itinerary)) {
  630. return "/saeaBorad?travel=success";
  631. } else{
  632. die ( 'illegal request' );
  633. }
  634. }
  635. function addFeeInternalTrain(){
  636. if ($this->_buildFeeData(3)) {
  637. return "/saeaBorad";
  638. } else{
  639. die ( 'illegal request' );
  640. }
  641. }
  642. function referReceipt() {
  643. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  644. Doo::loadModel ( 'receipt' );
  645. Doo::loadModel ( 'verify' );
  646. $verify = new verify ();
  647. $receipt = new receipt ();
  648. Doo::loadModel ( 'L_category' );
  649. $lCategory = new L_category ();
  650. Doo::loadModel ( "role" );
  651. $role = new role ();
  652. $receiptDetail = $receipt->find ( array (
  653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  654. 'asArray' => true
  655. ) );
  656. if (empty ( $receiptDetail ))
  657. return "/addReceipt";
  658. foreach ( $receiptDetail as $key => $value ) {
  659. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  660. $veList = $verify->getOne ( array (
  661. 'where' => 'vid=' . $value ['verify'],
  662. 'asArray' => true
  663. ) );
  664. $v = json_decode ( $veList ['staff'] );
  665. array_push ( $v [0], $veList ['description'] );
  666. foreach ( $v as $n => $m ) {
  667. if ($m ['1'] == 'ROLE') {
  668. $roleInfo = $role->getOne ( array (
  669. 'where' => 'rid=' . $m [0],
  670. 'asArray' => true
  671. ) );
  672. $v [$n] [1] = $roleInfo ['name'];
  673. }
  674. }
  675. $receiptDetail [$key] ['staff'] = $v;
  676. $category = $lCategory->getOne ( array (
  677. 'where' => 'cid=' . $value ['cid'],
  678. 'asArray' => true
  679. ) );
  680. $receiptDetail [$key] ['category'] = $category ['title'];
  681. }
  682. // print_r($receiptDetail);
  683. $data ['receiptDetail'] = $receiptDetail;
  684. $data ['memu'] = "receipt";
  685. $data ['staff'] = $this->staff;
  686. $data ['receiptMemu'] = 'saeaCreate';
  687. $data ['verifyId'] = $this->verifyId;
  688. $data ['executeId'] = $this->executeId;
  689. $this->render ( "/admin/saea_confirm", $data );
  690. }
  691. function editReceipt() {
  692. // edit status 4
  693. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  694. Doo::loadClass ( 'XDeode' );
  695. $XDeode = new XDeode ( 7 );
  696. $rid = $XDeode->decode ( $ridKey );
  697. if (empty ( $rid )) {
  698. die ( 'illegal request-id' );
  699. }
  700. // echo $rid.'sd';
  701. Doo::loadModel ( 'accountItem' );
  702. Doo::loadModel ( 'verify' );
  703. Doo::loadModel ( 'receipt' );
  704. $receipt = new receipt ();
  705. $verify = new verify ();
  706. $accountItem = new accountItem ();
  707. Doo::loadModel ( 'L_category' );
  708. $lCategory = new L_category ();
  709. Doo::loadModel ( "role" );
  710. $role = new role ();
  711. Doo::loadModel ( 'enclosur' );
  712. $enclosur = new enclosur ();
  713. $receiptDetail = $receipt->getOne ( array (
  714. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  715. 'asArray' => true
  716. ) );
  717. if (empty ( $receiptDetail )) {
  718. die ( 'illegal request-emptyData' );
  719. }
  720. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  721. $acItem = $accountItem->find ( array (
  722. 'asArray' => true
  723. ) );
  724. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  725. // 配置编辑信息
  726. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  727. foreach ( $acItem as $key => $value ) {
  728. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  729. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  730. $acItem [$key] ['price'] = $v ['price'];
  731. }
  732. }
  733. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  734. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  735. $acItem [$key] ['price'] = $v ['price'];
  736. }
  737. }
  738. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  739. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  740. $acItem [$key] ['price'] = $v ['price'];
  741. }
  742. }
  743. // 内训
  744. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  745. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  746. $acItem [$key] ['price'] = $v ['price'];
  747. }
  748. }
  749. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  750. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  751. $acItem [$key] ['price'] = $v ['price'];
  752. }
  753. }
  754. }
  755. $data ['category'] = $lCategory->find ( array (
  756. 'asArray' => true
  757. ) );
  758. $data ['cSum'] = $accountItemList ['cSum'];
  759. $data ['sum'] = $receiptDetail ['sum'];
  760. $data ['enclosurList'] = $enclosurList;
  761. $data ['receiptDetail'] = $receiptDetail;
  762. $data ['veList'] = $veList;
  763. $data ['acItem'] = $acItem;
  764. $data ['memu'] = "receipt";
  765. $data ['staff'] = $this->staff;
  766. $data ['receiptMemu'] = 'saeaBorad';
  767. $data ['verify'] = $receiptDetail ['verify'];
  768. $data ['verifyId'] = $this->verifyId;
  769. $data ['executeId'] = $this->executeId;
  770. $data ['rid'] = $ridKey;
  771. if($receiptDetail['receiptClass']==1){
  772. $this->render ( "/receipt/feeAgencyEdi", $data );
  773. }elseif($receiptDetail['receiptClass']==2){
  774. $this->render ( "/receipt/feeTravelEdi", $data );
  775. }elseif($receiptDetail['receiptClass']==3){
  776. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  777. }else{
  778. $this->render ( "/admin/saea_edit", $data );
  779. //die ( 'illegal request-renderHtml' );
  780. }
  781. }
  782. function updateReceipt() {
  783. $agency = $this->get_args ( 'agency' );
  784. $travel = $this->get_args ( 'travel' );
  785. $train = $this->get_args ( 'train' );
  786. $other = $this->get_args ( 'other' );
  787. $inttrain = $this->get_args ( 'inttrain' );
  788. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  789. $itinerary = $this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  790. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  791. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  792. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  793. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  794. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  795. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  796. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  797. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  798. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  799. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  800. Doo::loadClass ( 'XDeode' );
  801. $XDeode = new XDeode ( 7 );
  802. $rid = $XDeode->decode ( $ridKey );
  803. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  804. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  805. header ( 'Content-Type:text/html;charset=utf-8' );
  806. die ( '请填写联行号' );
  807. }
  808. Doo::loadModel ( 'receipt' );
  809. Doo::loadModel ( 'receiptDetail' );
  810. Doo::loadModel ( 'accountItem' );
  811. $accountItem = new accountItem ();
  812. $receipt = new receipt ();
  813. Doo::loadModel ( 'enclosur' );
  814. Doo::loadModel ( 'execute' );
  815. $execute = new execute ();
  816. $receiptDetail = $receipt->getOne ( array (
  817. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  818. 'asArray' => true
  819. ) );
  820. if (empty ( $receiptDetail )) {
  821. return "/saeaBorad";
  822. }
  823. //行程单
  824. $this->_storageItinerary($itinerary,$rid);
  825. if ($receiptDetail ['Rtype'] == 1) {
  826. $executeDetail = $execute->getOne ( array (
  827. 'where' => 'mold="借款费用执行人"',
  828. 'asArray' => true
  829. ) );
  830. } else {
  831. $executeDetail = $execute->getOne ( array (
  832. 'where' => 'mold="报销单执行人"',
  833. 'asArray' => true
  834. ) );
  835. }
  836. $aItem = $accountItem->find ( array (
  837. 'asArray' => true
  838. ) );
  839. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  840. $ag = $tr = $ta = $ot = $it = 0;
  841. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  842. foreach ( $aItem as $key => $value ) {
  843. if ($value ['category'] == $this->AGENCY) {
  844. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  845. array_push ( $accountJson [$this->AGENCY], array (
  846. 'aid' => $value ['aid'],
  847. 'name' => $value ['name'],
  848. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  849. ) );
  850. $sum += $agency [$ag];
  851. $agencySum += $agency [$ag];
  852. }
  853. $ag ++;
  854. }
  855. if ($value ['category'] == $this->TRAVEL) {
  856. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  857. array_push ( $accountJson [$this->TRAVEL], array (
  858. 'aid' => $value ['aid'],
  859. 'name' => $value ['name'],
  860. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  861. ) );
  862. $sum += $travel [$tr];
  863. $travelSum += $travel [$tr];
  864. }
  865. $tr ++;
  866. }
  867. if ($value ['category'] == $this->TRAIN) {
  868. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  869. array_push ( $accountJson [$this->TRAIN], array (
  870. 'aid' => $value ['aid'],
  871. 'name' => $value ['name'],
  872. 'price' => number_format ( $train [$ta], 2, '.', '' )
  873. ) );
  874. $sum += $train [$ta];
  875. $trainSum += $train [$ta];
  876. }
  877. $ta ++;
  878. }
  879. if ($value ['category'] == $this->INTTRAIN) {
  880. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  881. array_push ( $accountJson [$this->INTTRAIN], array (
  882. 'aid' => $value ['aid'],
  883. 'name' => $value ['name'],
  884. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  885. ) );
  886. $sum += $inttrain [$it];
  887. $inttrainSum += $inttrain [$it];
  888. }
  889. $it ++;
  890. }
  891. if ($value ['category'] == $this->OTHER) {
  892. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  893. array_push ( $accountJson [$this->OTHER], array (
  894. 'aid' => $value ['aid'],
  895. 'name' => $value ['name'],
  896. 'price' => number_format ( $other [$ot], 2, '.', '' )
  897. ) );
  898. $sum += $other [$ot];
  899. $otherSum += $other [$ot];
  900. }
  901. $ot ++;
  902. }
  903. }
  904. $accountJson ['cSum'] = array (
  905. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  906. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  907. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  908. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  909. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  910. );
  911. // 报销单
  912. $rid = $receipt->rid = $receiptDetail ['rid'];
  913. $receipt->accountItem = json_encode ( $accountJson );
  914. $receipt->staff = $this->staff [0] ['sid'];
  915. $receipt->sum = number_format ( $sum, 2, '.', '' );
  916. $receipt->date = date ( "Y-m-d" );
  917. $receipt->cid = $cid;
  918. if (($receiptDetail ['status'] != 4)) {
  919. if ($receiptDetail ['Rtype'] == 1) {
  920. $receipt->status = 7;
  921. } else {
  922. $receipt->status = 5;
  923. }
  924. }
  925. if ($receiptDetail != 4 && ! empty ( $verify ))
  926. $receipt->verify = $verify;
  927. $receipt->executeCopy = $executeDetail ['staff'];
  928. $order = array (
  929. "\r\n",
  930. "\n",
  931. "\r"
  932. );
  933. $replace = '<br/>';
  934. $explanation = str_replace ( $order, $replace, $explanation );
  935. $receipt->explanation = $explanation;
  936. if($receiptClass=='trave'){
  937. $receipt->itinerary=$itinerary;
  938. }
  939. $receipt->remittanceName = $remittanceName;
  940. $receipt->bankName = $bankName;
  941. $receipt->bankNumber = $bankNumber;
  942. $receipt->remittanceBankType = $remittanceBankType;
  943. if ($remittanceBankType == 1)
  944. $receipt->coupletNumber = $coupletNumber;
  945. $receipt->update ();
  946. $receiptDetail = new receiptDetail ();
  947. $receiptDetail->delete ( array (
  948. 'where' => 'rid=' . $rid
  949. ) );
  950. // 报销详情
  951. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  952. $receiptDetail = new receiptDetail ();
  953. $receiptDetail->staff = $this->staff [0] ['sid'];
  954. $receiptDetail->item = $value ['name'];
  955. $receiptDetail->itemCategory = $this->AGENCY;
  956. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  957. $receiptDetail->date = date ( "Y-m-d" );
  958. $receiptDetail->cid = $cid;
  959. $receiptDetail->rid = $rid;
  960. $receiptDetail->status = 4;
  961. $receiptDetail->insert ();
  962. }
  963. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  964. $receiptDetail = new receiptDetail ();
  965. $receiptDetail->staff = $this->staff [0] ['sid'];
  966. $receiptDetail->item = $value ['name'];
  967. $receiptDetail->itemCategory = $this->TRAVEL;
  968. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  969. $receiptDetail->date = date ( "Y-m-d" );
  970. $receiptDetail->cid = $cid;
  971. $receiptDetail->rid = $rid;
  972. $receiptDetail->status = 4;
  973. $receiptDetail->insert ();
  974. }
  975. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  976. $receiptDetail = new receiptDetail ();
  977. $receiptDetail->staff = $this->staff [0] ['sid'];
  978. $receiptDetail->item = $value ['name'];
  979. $receiptDetail->itemCategory = $this->TRAIN;
  980. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  981. $receiptDetail->date = date ( "Y-m-d" );
  982. $receiptDetail->cid = $cid;
  983. $receiptDetail->rid = $rid;
  984. $receiptDetail->status = 4;
  985. $receiptDetail->insert ();
  986. }
  987. // 内训
  988. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  989. $receiptDetail = new receiptDetail ();
  990. $receiptDetail->staff = $this->staff [0] ['sid'];
  991. $receiptDetail->item = $value ['name'];
  992. $receiptDetail->itemCategory = $this->INTTRAIN;
  993. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  994. $receiptDetail->date = date ( "Y-m-d" );
  995. $receiptDetail->cid = $cid;
  996. $receiptDetail->rid = $rid;
  997. $receiptDetail->status = 4;
  998. $receiptDetail->insert ();
  999. }
  1000. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1001. $receiptDetail = new receiptDetail ();
  1002. $receiptDetail->staff = $this->staff [0] ['sid'];
  1003. $receiptDetail->item = $value ['name'];
  1004. $receiptDetail->itemCategory = $this->OTHER;
  1005. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1006. $receiptDetail->date = date ( "Y-m-d" );
  1007. $receiptDetail->cid = $cid;
  1008. $receiptDetail->rid = $rid;
  1009. $receiptDetail->status = 4;
  1010. $receiptDetail->insert ();
  1011. }
  1012. // 附件
  1013. if (! empty ( $enclosurName )) {
  1014. $enclosurArray = explode ( '-', $enclosurName );
  1015. foreach ( $enclosurArray as $value ) {
  1016. $enclosur = new enclosur ();
  1017. $enclosur->name = $value;
  1018. $enclosur->rid = $rid;
  1019. $enclosur->insert ();
  1020. }
  1021. }
  1022. // return "/referReceipt/".$rid;
  1023. }
  1024. return "/saeaBorad";
  1025. }
  1026. function remitAdd() {
  1027. Doo::loadModel ( 'accountItem' );
  1028. Doo::loadModel ( 'verify' );
  1029. Doo::loadModel ( 'receipt' );
  1030. Doo::loadModel ( 'L_category' );
  1031. $lCategory = new L_category ();
  1032. $receipt = new receipt ();
  1033. $verify = new verify ();
  1034. $accountItem = new accountItem ();
  1035. Doo::loadModel ( "role" );
  1036. $role = new role ();
  1037. $acItem = $accountItem->find ( array (
  1038. 'asArray' => true
  1039. ) );
  1040. $veList = $verify->getVerifyBySubordinate('REMIT');
  1041. $data ['category'] = $lCategory->find ( array (
  1042. 'asArray' => true
  1043. ) );
  1044. $data ['veList'] = $veList;
  1045. $data ['acItem'] = $acItem;
  1046. $data ['memu'] = "receipt";
  1047. $data ['staff'] = $this->staff;
  1048. $data ['receiptMemu'] = 'saeaBorad';
  1049. $data ['verifyId'] = $this->verifyId;
  1050. $data ['executeId'] = $this->executeId;
  1051. $this->render ( "/admin/remitAdd", $data );
  1052. }
  1053. function remitAddDo() {
  1054. $agency = $this->get_args ( 'agency' );
  1055. $travel = $this->get_args ( 'travel' );
  1056. $train = $this->get_args ( 'train' );
  1057. $other = $this->get_args ( 'other' );
  1058. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1059. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1060. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1061. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1062. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1063. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1064. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1065. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1066. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1067. // print_r($agency);die;
  1068. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1069. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1070. header ( 'Content-Type:text/html;charset=utf-8' );
  1071. die ( '请填写联行号' );
  1072. }
  1073. Doo::loadModel ( 'receipt' );
  1074. Doo::loadModel ( 'receiptDetail' );
  1075. Doo::loadModel ( 'accountItem' );
  1076. $accountItem = new accountItem ();
  1077. $receipt = new receipt ();
  1078. Doo::loadModel ( 'enclosur' );
  1079. Doo::loadModel ( 'execute' );
  1080. $execute = new execute ();
  1081. $executeDetail = $execute->getOne ( array (
  1082. 'where' => 'mold="对公汇款执行人"',
  1083. 'asArray' => true
  1084. ) );
  1085. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1086. $aItem = $accountItem->find ( array (
  1087. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1088. 'asArray' => true
  1089. ) );
  1090. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1091. $ag = $tr = $ta = $ot = 0;
  1092. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1093. print_r($aItem);
  1094. foreach ( $aItem as $key => $value ) {
  1095. if ($value ['category'] == $this->AGENCY) {
  1096. if (isset ( $agency [$ag] )) {
  1097. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1098. array_push ( $accountJson [$this->AGENCY], array (
  1099. 'aid' => $value ['aid'],
  1100. 'name' => $value ['name'],
  1101. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1102. ) );
  1103. $sum += $agency [$ag];
  1104. $agencySum += $agency [$ag];
  1105. }
  1106. }
  1107. $ag ++;
  1108. }
  1109. }
  1110. $accountJson ['cSum'] = array (
  1111. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1112. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1113. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1114. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1115. );
  1116. //die;
  1117. // 报销单
  1118. $receipt->accountItem = json_encode ( $accountJson );
  1119. $receipt->staff = $this->staff [0] ['sid'];
  1120. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1121. $receipt->date = date ( "Y-m-d" );
  1122. $receipt->cid = $cid;
  1123. $receipt->status = 5;
  1124. $receipt->Rtype = 2;
  1125. // 修改审批流程加入角色
  1126. $receipt->verify = $verify;
  1127. $receipt->executeCopy = $executeDetail ['staff'];
  1128. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1129. $order = array (
  1130. "\r\n",
  1131. "\n",
  1132. "\r"
  1133. );
  1134. $replace = '<br/>';
  1135. $explanation = str_replace ( $order, $replace, $explanation );
  1136. $receipt->explanation = $explanation;
  1137. $receipt->remittanceName = $remittanceName;
  1138. $receipt->bankName = $bankName;
  1139. $receipt->bankNumber = $bankNumber;
  1140. $receipt->remittanceBankType = $remittanceBankType;
  1141. if ($remittanceBankType == 1)
  1142. $receipt->coupletNumber = $coupletNumber;
  1143. $rid = $receipt->insert ();
  1144. // 附件
  1145. if (! empty ( $enclosurName )) {
  1146. $enclosurArray = explode ( '-', $enclosurName );
  1147. foreach ( $enclosurArray as $value ) {
  1148. $enclosur = new enclosur ();
  1149. $enclosur->name = $value;
  1150. $enclosur->rid = $rid;
  1151. $enclosur->insert ();
  1152. }
  1153. // print_r($enclosurArray);die;
  1154. }
  1155. // 报销详情
  1156. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1157. $receiptDetail = new receiptDetail ();
  1158. $receiptDetail->staff = $this->staff [0] ['sid'];
  1159. $receiptDetail->item = $value ['name'];
  1160. $receiptDetail->itemCategory = $this->AGENCY;
  1161. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1162. $receiptDetail->date = date ( "Y-m-d" );
  1163. $receiptDetail->cid = $cid;
  1164. $receiptDetail->rid = $rid;
  1165. $receiptDetail->status = 4;
  1166. $receiptDetail->insert ();
  1167. }
  1168. return "/saeaBorad";
  1169. } else
  1170. die ( 'illegal request' );
  1171. }
  1172. function remitEdit() {
  1173. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1174. Doo::loadClass ( 'XDeode' );
  1175. $XDeode = new XDeode ( 7 );
  1176. $rid = $XDeode->decode ( $ridKey );
  1177. if (! is_numeric ( $rid ))
  1178. die ( 'illegal request' );
  1179. Doo::loadModel ( 'accountItem' );
  1180. Doo::loadModel ( 'verify' );
  1181. Doo::loadModel ( 'receipt' );
  1182. $receipt = new receipt ();
  1183. $verify = new verify ();
  1184. $accountItem = new accountItem ();
  1185. Doo::loadModel ( 'L_category' );
  1186. $lCategory = new L_category ();
  1187. Doo::loadModel ( "role" );
  1188. $role = new role ();
  1189. Doo::loadModel ( 'enclosur' );
  1190. $enclosur = new enclosur ();
  1191. $receiptDetail = $receipt->getOne ( array (
  1192. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1193. 'asArray' => true
  1194. ) );
  1195. if (empty ( $receiptDetail ))
  1196. return "/saeaCreate";
  1197. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1198. $acItem = $accountItem->find ( array (
  1199. 'asArray' => true
  1200. ) );
  1201. $veList = $verify->getVerifyBySubordinate('REMIT');
  1202. // 配置编辑信息
  1203. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1204. foreach ( $acItem as $key => $value ) {
  1205. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1206. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1207. $acItem [$key] ['price'] = $v ['price'];
  1208. }
  1209. }
  1210. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1211. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1212. $acItem [$key] ['price'] = $v ['price'];
  1213. }
  1214. }
  1215. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1216. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1217. $acItem [$key] ['price'] = $v ['price'];
  1218. }
  1219. }
  1220. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1221. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1222. $acItem [$key] ['price'] = $v ['price'];
  1223. }
  1224. }
  1225. }
  1226. $data ['category'] = $lCategory->find ( array (
  1227. 'asArray' => true
  1228. ) );
  1229. $data ['enclosurList'] = $enclosurList;
  1230. $data ['cSum'] = $accountItemList ['cSum'];
  1231. $data ['sum'] = $receiptDetail ['sum'];
  1232. $data ['receiptDetail'] = $receiptDetail;
  1233. $data ['veList'] = $veList;
  1234. $data ['acItem'] = $acItem;
  1235. $data ['memu'] = "receipt";
  1236. $data ['staff'] = $this->staff;
  1237. $data ['receiptMemu'] = 'saeaBorad';
  1238. $data ['verify'] = $receiptDetail ['verify'];
  1239. $data ['verifyId'] = $this->verifyId;
  1240. $data ['executeId'] = $this->executeId;
  1241. $data ['rid'] = $rid;
  1242. $data ['ridKey'] = $ridKey;
  1243. $this->render ( "/admin/remitEdit", $data );
  1244. }
  1245. function remitEdiDo() {
  1246. $agency = $this->get_args ( 'agency' );
  1247. $travel = $this->get_args ( 'travel' );
  1248. $train = $this->get_args ( 'train' );
  1249. $other = $this->get_args ( 'other' );
  1250. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1251. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1252. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1253. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1254. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1255. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1256. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1257. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1258. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1259. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1260. Doo::loadClass ( 'XDeode' );
  1261. $XDeode = new XDeode ( 7 );
  1262. $rid = $XDeode->decode ( $ridKey );
  1263. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1264. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1265. header ( 'Content-Type:text/html;charset=utf-8' );
  1266. die ( '请填写联行号' );
  1267. }
  1268. Doo::loadModel ( 'receipt' );
  1269. Doo::loadModel ( 'receiptDetail' );
  1270. Doo::loadModel ( 'accountItem' );
  1271. $accountItem = new accountItem ();
  1272. $receipt = new receipt ();
  1273. Doo::loadModel ( 'enclosur' );
  1274. $enclosur = new enclosur ();
  1275. Doo::loadModel ( 'execute' );
  1276. $execute = new execute ();
  1277. $executeDetail = $execute->getOne ( array (
  1278. 'where' => 'mold="对公汇款执行人"',
  1279. 'asArray' => true
  1280. ) );
  1281. $receiptDetail = $receipt->getOne ( array (
  1282. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1283. 'asArray' => true
  1284. ) );
  1285. if (empty ( $receiptDetail ))
  1286. return "/saeaBorad";
  1287. $aItem = $accountItem->find ( array (
  1288. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1289. 'asArray' => true
  1290. ) );
  1291. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1292. $ag = $tr = $ta = $ot = 0;
  1293. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1294. foreach ( $aItem as $key => $value ) {
  1295. if ($value ['category'] == $this->AGENCY) {
  1296. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1297. array_push ( $accountJson [$this->AGENCY], array (
  1298. 'aid' => $value ['aid'],
  1299. 'name' => $value ['name'],
  1300. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1301. ) );
  1302. $sum += $agency [$ag];
  1303. $agencySum += $agency [$ag];
  1304. }
  1305. $ag ++;
  1306. }
  1307. }
  1308. $accountJson ['cSum'] = array (
  1309. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1310. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1311. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1312. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1313. );
  1314. // 报销单
  1315. $rid = $receipt->rid = $receiptDetail ['rid'];
  1316. $receipt->accountItem = json_encode ( $accountJson );
  1317. $receipt->staff = $this->staff [0] ['sid'];
  1318. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1319. $receipt->date = date ( "Y-m-d" );
  1320. $receipt->cid = $cid;
  1321. if ($receiptDetail ['Rtype'] == 1)
  1322. $receipt->status = 7;
  1323. else
  1324. $receipt->status = 5;
  1325. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1326. $receipt->verify = $verify;
  1327. $receipt->executeCopy = $executeDetail ['staff'];
  1328. $order = array (
  1329. "\r\n",
  1330. "\n",
  1331. "\r"
  1332. );
  1333. $replace = '<br/>';
  1334. $explanation = str_replace ( $order, $replace, $explanation );
  1335. $receipt->explanation = $explanation;
  1336. $receipt->remittanceName = $remittanceName;
  1337. $receipt->bankName = $bankName;
  1338. $receipt->bankNumber = $bankNumber;
  1339. $receipt->remittanceBankType = $remittanceBankType;
  1340. if ($remittanceBankType == 1)
  1341. $receipt->coupletNumber = $coupletNumber;
  1342. $receipt->update ();
  1343. $receiptDetail = new receiptDetail ();
  1344. $receiptDetail->delete ( array (
  1345. 'where' => 'rid=' . $rid
  1346. ) );
  1347. // 报销详情
  1348. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1349. $receiptDetail = new receiptDetail ();
  1350. $receiptDetail->staff = $this->staff [0] ['sid'];
  1351. $receiptDetail->item = $value ['name'];
  1352. $receiptDetail->itemCategory = $this->AGENCY;
  1353. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1354. $receiptDetail->date = date ( "Y-m-d" );
  1355. $receiptDetail->cid = $cid;
  1356. $receiptDetail->rid = $rid;
  1357. $receiptDetail->status = 4;
  1358. $receiptDetail->insert ();
  1359. }
  1360. // 附件
  1361. if (! empty ( $enclosurName )) {
  1362. $enclosurArray = explode ( '-', $enclosurName );
  1363. foreach ( $enclosurArray as $value ) {
  1364. $enclosur = new enclosur ();
  1365. $enclosur->name = $value;
  1366. $enclosur->rid = $rid;
  1367. $enclosur->insert ();
  1368. }
  1369. }
  1370. }
  1371. return "/saeaBorad";
  1372. }
  1373. function remitApproval() {
  1374. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1375. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1376. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1377. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1378. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1379. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1380. if (empty ( $status ))
  1381. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1382. $vidList = array ();
  1383. $button = 0;
  1384. Doo::loadModel ( 'verify' );
  1385. Doo::loadModel ( 'receipt' );
  1386. Doo::loadModel ( 'staff' );
  1387. $staff = new staff ();
  1388. $receipt = new receipt ();
  1389. $verify = new verify ();
  1390. Doo::loadModel ( 'L_category' );
  1391. $Lcategory = new L_category ();
  1392. Doo::loadModel ( 'enclosur' );
  1393. $enclosur = new enclosur ();
  1394. // user verify ID
  1395. $verifyDetail = $verify->find ( array (
  1396. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1397. 'asArray' => true
  1398. ) );
  1399. foreach ( $verifyDetail as $key => $value ) {
  1400. array_push ( $vidList, $value ['vid'] );
  1401. }
  1402. $vid = implode ( ",", $vidList );
  1403. if (empty ( $verifyDetail ))
  1404. $vid = 0;
  1405. $categoryList = $Lcategory->find ( array (
  1406. 'asArray' => true
  1407. ) );
  1408. $staffList = $staff->find ( array (
  1409. 'where' => 'cid=' . $cid,
  1410. 'asArray' => true
  1411. ) );
  1412. $ap = "";
  1413. if ($status == 4) {
  1414. $ap = 4;
  1415. $status = 2;
  1416. }
  1417. // get Receipt By verifyID status 2
  1418. $receiptList = $receipt->find ( array (
  1419. 'where' => 'rid =' . $rid . ' and status=2',
  1420. 'desc' => 'rid',
  1421. 'asArray' => true
  1422. ) );
  1423. if (empty ( $receiptList )) {
  1424. die ( 'illegal request' );
  1425. }
  1426. $Locate = 0;
  1427. $roleId = 0;
  1428. if ($ap == 4)
  1429. $status = 4;
  1430. foreach ( $receiptList as $key => $value ) {
  1431. $receiptList [$key] ['Locate'] = $Locate;
  1432. $Locate ++;
  1433. $receiptList [$key] ['reviseDetail'] = array ();
  1434. if (! empty ( $value ['reviseDetail'] ))
  1435. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1436. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1437. $categoryDetil = $Lcategory->getOne ( array (
  1438. 'where' => 'cid=' . $value ['cid'],
  1439. 'asArray' => true
  1440. ) );
  1441. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1442. // 检测编辑状态
  1443. $verifyList = $verify->getOne ( array (
  1444. 'where' => 'vid=' . $value ['verify'],
  1445. 'asArray' => true
  1446. ) );
  1447. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1448. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1449. Doo::loadModel ( 'role' );
  1450. $role = new role ();
  1451. // print_r($verifyList);
  1452. $flag = true;
  1453. $roleKey = 0;
  1454. $endStaffArray = array ();
  1455. $roleArrayCopy = array ();
  1456. foreach ( $verifyList as $k => $v ) {
  1457. // init verifyStaff
  1458. if ($v [1] == 'ROLE') {
  1459. if (! empty ( $verifyStaff )) {
  1460. $endStaffArray = end ( $verifyStaff );
  1461. if ($v [0] == $endStaffArray ['nextStaff']) {
  1462. $roleId = $v [0];
  1463. }
  1464. }
  1465. $roleVerify = json_decode ( $v [3], true );
  1466. $roleKey = $k;
  1467. $roleArray = array ();
  1468. $rolename = $role->getOne ( array (
  1469. 'where' => 'rid=' . $v [0],
  1470. 'asArray' => true
  1471. ) );
  1472. foreach ( $roleVerify as $o => $p ) {
  1473. $staffID = explode ( '_', $p );
  1474. $staffInfo = $staff->getOne ( array (
  1475. 'where' => 'sid=' . $staffID [0],
  1476. 'asArray' => true
  1477. ) );
  1478. // print_r($staffID);
  1479. $exp = array (
  1480. 0 => $staffInfo ['sid'],
  1481. 1 => $staffID [1],
  1482. 2 => $staffInfo ['avatar'],
  1483. 'date' => '',
  1484. 'date' => '',
  1485. 'opinion' => '',
  1486. 'status' => '',
  1487. 'rolename' => $rolename ['name']
  1488. );
  1489. array_push ( $roleArray, $exp );
  1490. }
  1491. $roleArrayCopy [$v [0]] = $roleArray;
  1492. // $verifyList[$k]['roleArray']=$roleArray;
  1493. }
  1494. // print_r($roleArray);
  1495. $verifyList [$k] ['date'] = "";
  1496. $verifyList [$k] ['opinion'] = "";
  1497. $verifyList [$k] ['status'] = "";
  1498. if (empty ( $verifyStaff )) {
  1499. $verifyList [$k] ['date'] = "";
  1500. $verifyList [$k] ['opinion'] = "";
  1501. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1502. $verifyList [$k] ['status'] = 4;
  1503. $button = 4;
  1504. $flag = false;
  1505. }
  1506. } else {
  1507. foreach ( $verifyStaff as $m => $u ) {
  1508. if ($v [0] == $m) {
  1509. $verifyList [$k] ['date'] = $u ['date'];
  1510. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1511. $verifyList [$k] ['status'] = $u ['status'];
  1512. $flag = false;
  1513. break;
  1514. }
  1515. }
  1516. $endStaffArray = end ( $verifyStaff );
  1517. if (isset ( $endStaffArray ['ROLE'] )) {
  1518. } else {
  1519. $endKey = key ( $verifyStaff );
  1520. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1521. $button = 4;
  1522. $verifyList [$k] ['status'] = 4;
  1523. }
  1524. }
  1525. }
  1526. }
  1527. $rolename ['name'] = '';
  1528. if (! empty ( $roleId )) {
  1529. Doo::loadModel ( 'role' );
  1530. $role = new role ();
  1531. $rolename = $role->getOne ( array (
  1532. 'where' => 'rid=' . $roleId,
  1533. 'asArray' => true
  1534. ) );
  1535. }
  1536. if (! empty ( $verifyStaff ))
  1537. $endStaffArray = end ( $verifyStaff );
  1538. $KOP = false;
  1539. foreach ( $roleArrayCopy as $P => $A ) {
  1540. foreach ( $A as $MKI => $AVL ) {
  1541. if (! empty ( $verifyStaff )) {
  1542. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1543. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1544. $button = 4;
  1545. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1546. }
  1547. foreach ( $verifyStaff as $m => $u ) {
  1548. $AVLFK = $AVL [0] . '_R';
  1549. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1550. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1551. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1552. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1553. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1554. break;
  1555. }
  1556. }
  1557. } else {
  1558. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1559. $button = 4;
  1560. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1561. }
  1562. }
  1563. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1564. $KOP = true;
  1565. }
  1566. }
  1567. foreach ( $roleArrayCopy as $k => $v ) {
  1568. foreach ( $verifyList as $m => $n ) {
  1569. if ($n [0] == $k) {
  1570. array_splice ( $verifyList, $m, 1, $v );
  1571. }
  1572. }
  1573. }
  1574. $receiptList [$key] ['verifyList'] = $verifyList;
  1575. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1576. 'where' => 'sid=' . $value ['staff'],
  1577. 'asArray' => true
  1578. ) );
  1579. $receiptList [$key] ['button'] = $button;
  1580. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1581. }
  1582. $mothHtml = "";
  1583. for($i = 1; $i <= 12; $i ++) {
  1584. if ($month == $i)
  1585. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1586. else
  1587. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1588. }
  1589. // 获取审批日志
  1590. Doo::loadModel ( 'receiptLog' );
  1591. $receiptLog = new receiptLog ();
  1592. $rlList = array ();
  1593. $rlInfo = $receiptLog->getOne ( array (
  1594. 'where' => 'rid=' . $rid . ' and status=4',
  1595. 'asArray' => true
  1596. ) );
  1597. $tijdate = $receiptLog->getOne ( array (
  1598. 'where' => 'rid=' . $rid . ' and status=2',
  1599. 'asc' => 'rlid',
  1600. 'asArray' => true
  1601. ) );
  1602. if (! empty ( $rlInfo )) {
  1603. $rlList = $receiptLog->find ( array (
  1604. 'where' => 'rid=' . $rid,
  1605. 'asc' => 'rlid',
  1606. 'asArray' => true
  1607. ) );
  1608. }
  1609. $receiptList [0] ['rlList'] = $rlList;
  1610. $enclosurList = $enclosur->find ( array (
  1611. 'where' => 'rid=' . $rid,
  1612. 'asArray' => true
  1613. ) );
  1614. $enclosurHtml = '';
  1615. foreach ( $enclosurList as $value ) {
  1616. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1617. }
  1618. // print_r($receiptList);
  1619. $data ['enclosurHtml'] = $enclosurHtml;
  1620. $data ['rolename'] = $rolename ['name'];
  1621. $data ['datetij'] = $tijdate ['date'];
  1622. $data ['mothHtml'] = $mothHtml;
  1623. $data ['rid'] = $rid;
  1624. $data ['receiptList'] = $receiptList;
  1625. $data ['receiptApprovalCount'] = count ( $receiptList );
  1626. $data ['status'] = $status;
  1627. $data ['year'] = $year;
  1628. $data ['categoryList'] = $categoryList;
  1629. $data ['staffList'] = $staffList;
  1630. $data ['cid'] = $cid;
  1631. $data ['sid'] = $sid;
  1632. $data ['ap'] = $ap;
  1633. $data ['memu'] = "receipt";
  1634. $data ['staff'] = $this->staff;
  1635. $data ['receiptMemu'] = 'approvalExpenses';
  1636. $data ['verifyId'] = $this->verifyId;
  1637. $data ['executeId'] = $this->executeId;
  1638. $this->render ( "/admin/remitApproval", $data );
  1639. }
  1640. function saeaLoanAdd() {
  1641. Doo::loadModel ( 'verify' );
  1642. $verify = new verify ();
  1643. Doo::loadModel ( "role" );
  1644. $role = new role ();
  1645. Doo::loadModel ( 'L_category' );
  1646. $lCategory = new L_category ();
  1647. $veList = $verify->getVerifyBySubordinate('LOAN');
  1648. $data ['category'] = $lCategory->find ( array (
  1649. 'asArray' => true
  1650. ) );
  1651. $data ['veList'] = $veList;
  1652. $data ['memu'] = "receipt";
  1653. $data ['staff'] = $this->staff;
  1654. $data ['receiptMemu'] = 'saeaBorad';
  1655. $data ['verifyId'] = $this->verifyId;
  1656. $data ['executeId'] = $this->executeId;
  1657. $this->render ( "/admin/saeaLoanAdd", $data );
  1658. }
  1659. function saeaLoanAddDo() {
  1660. $agency = $this->get_args ( 'agency' );
  1661. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1662. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1663. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1664. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1665. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1666. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1667. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1668. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1669. // die;
  1670. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1671. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1672. header ( 'Content-Type:text/html;charset=utf-8' );
  1673. die ( '请填写联行号' );
  1674. }
  1675. Doo::loadModel ( 'receipt' );
  1676. Doo::loadModel ( 'receiptDetail' );
  1677. Doo::loadModel ( 'accountItem' );
  1678. $accountItem = new accountItem ();
  1679. $receipt = new receipt ();
  1680. Doo::loadModel ( 'loanReceipt' );
  1681. $loanReceipt = new loanReceipt ();
  1682. Doo::loadModel ( 'execute' );
  1683. $execute = new execute ();
  1684. Doo::loadModel ( 'enclosur' );
  1685. $executeDetail = $execute->getOne ( array (
  1686. 'where' => 'mold="借款执行人"',
  1687. 'asArray' => true
  1688. ) );
  1689. $aItem = $accountItem->find ( array (
  1690. 'asArray' => true
  1691. ) );
  1692. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1693. $ag = $tr = $ta = $ot = 0;
  1694. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1695. array_push ( $accountJson ['借款费用'], array (
  1696. 'aid' => 0,
  1697. 'name' => '申请金额',
  1698. 'price' => number_format ( $agency, 2, '.', '' )
  1699. ) );
  1700. $sum += $agency;
  1701. $agencySum += $agency;
  1702. $accountJson ['cSum'] = array (
  1703. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1704. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1705. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1706. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1707. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1708. );
  1709. // 借款数据备份
  1710. $loanReceipt->loanItem = json_encode ( $accountJson );
  1711. $loanReceipt->staff = $this->staff [0] ['sid'];
  1712. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1713. $loanReceipt->date = date ( "Y-m-d" );
  1714. $loanReceipt->cid = $cid;
  1715. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1716. $loanReceipt->status = 5;
  1717. $loanReceipt->Rtype = 1;
  1718. $loanReceipt->verify = $verify;
  1719. $receipt->receiptOrder = $receipt->receiptOrder;
  1720. // 添加HTML换行符
  1721. // var_dump($explanation);
  1722. $order = array (
  1723. "\r\n",
  1724. "\n",
  1725. "\r"
  1726. );
  1727. $replace = '<br/>';
  1728. $explanation = str_replace ( $order, $replace, $explanation );
  1729. // $explanation=str_replace('\r',"<br/>",$explanation);
  1730. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1731. $loanReceipt->explanation = $explanation;
  1732. $loanRid = $loanReceipt->insert ();
  1733. // 报销单
  1734. $receipt->loanItem = json_encode ( $accountJson );
  1735. $receipt->staff = $this->staff [0] ['sid'];
  1736. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1737. $receipt->date = date ( "Y-m-d" );
  1738. $receipt->cid = $cid;
  1739. // 特殊状态
  1740. $receipt->status = 5;
  1741. $receipt->Rtype = 1;
  1742. $receipt->loanRid = $loanRid;
  1743. // 修改审批流程加入角色
  1744. $receipt->verify = $verify;
  1745. $receipt->executeCopy = $executeDetail ['staff'];
  1746. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1747. $receipt->explanation = $explanation;
  1748. $receipt->remittanceName = $remittanceName;
  1749. $receipt->bankName = $bankName;
  1750. $receipt->bankNumber = $bankNumber;
  1751. $receipt->remittanceBankType = $remittanceBankType;
  1752. if ($remittanceBankType == 1)
  1753. $receipt->coupletNumber = $coupletNumber;
  1754. $rid = $receipt->insert ();
  1755. return "/saeaBorad";
  1756. } else
  1757. die ( 'illegal request' );
  1758. }
  1759. function saeaLoanEdi() {
  1760. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1761. Doo::loadClass ( 'XDeode' );
  1762. $XDeode = new XDeode ( 7 );
  1763. $rid = $XDeode->decode ( $ridKey );
  1764. if (! is_numeric ( $rid ))
  1765. die ( 'illegal request' );
  1766. Doo::loadModel ( 'verify' );
  1767. $verify = new verify ();
  1768. Doo::loadModel ( "role" );
  1769. $role = new role ();
  1770. Doo::loadModel ( 'L_category' );
  1771. $lCategory = new L_category ();
  1772. Doo::loadModel ( 'receipt' );
  1773. $receipt = new receipt ();
  1774. $receiptInfo = $receipt->getOne ( array (
  1775. 'where' => 'rid=' . $rid,
  1776. 'asArray' => true
  1777. ) );
  1778. $veList = $verify->find ( array (
  1779. 'where'=>'subordinate like "%LOAN%"',
  1780. 'asArray' => true
  1781. ) );
  1782. foreach ( $veList as $key => $value ) {
  1783. $v = json_decode ( $value ['staff'] );
  1784. $list = array ();
  1785. foreach ( $v as $n => $m ) {
  1786. if ($m ['1'] == 'ROLE') {
  1787. $roleInfo = $role->getOne ( array (
  1788. 'where' => 'rid=' . $m [0],
  1789. 'asArray' => true
  1790. ) );
  1791. $v [$n] [1] = $roleInfo ['name'];
  1792. array_push ( $list, $roleInfo ['name'] );
  1793. } else {
  1794. array_push ( $list, $v [$n] [1] );
  1795. }
  1796. }
  1797. $veList [$key] ['staff'] = implode ( '>', $list );
  1798. }
  1799. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1800. // print_r($receiptInfo);
  1801. $data ['receiptInfo'] = $receiptInfo;
  1802. $data ['category'] = $lCategory->find ( array (
  1803. 'asArray' => true
  1804. ) );
  1805. $data ['veList'] = $veList;
  1806. $data ['ridKey'] = $ridKey;
  1807. $data ['memu'] = "receipt";
  1808. $data ['staff'] = $this->staff;
  1809. $data ['receiptMemu'] = 'saeaBorad';
  1810. $data ['verifyId'] = $this->verifyId;
  1811. $data ['executeId'] = $this->executeId;
  1812. $this->render ( "/admin/saeaLoanEdi", $data );
  1813. }
  1814. function saeaLoanEdiDo() {
  1815. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1816. $agency = $this->get_args ( 'agency' );
  1817. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1818. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1819. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1820. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1821. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1822. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1823. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1824. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1825. // die;
  1826. Doo::loadClass ( 'XDeode' );
  1827. $XDeode = new XDeode ( 7 );
  1828. $rid = $XDeode->decode ( $ridKey );
  1829. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1830. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1831. header ( 'Content-Type:text/html;charset=utf-8' );
  1832. die ( '请填写联行号' );
  1833. }
  1834. Doo::loadModel ( 'receipt' );
  1835. Doo::loadModel ( 'receiptDetail' );
  1836. Doo::loadModel ( 'accountItem' );
  1837. $accountItem = new accountItem ();
  1838. $receipt = new receipt ();
  1839. Doo::loadModel ( 'loanReceipt' );
  1840. $loanReceipt = new loanReceipt ();
  1841. Doo::loadModel ( 'enclosur' );
  1842. Doo::loadModel ( 'execute' );
  1843. $execute = new execute ();
  1844. $executeDetail = $execute->getOne ( array (
  1845. 'where' => 'mold="借款执行人"',
  1846. 'asArray' => true
  1847. ) );
  1848. $receiptDetail = $receipt->getOne ( array (
  1849. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1850. 'asArray' => true
  1851. ) );
  1852. if (empty ( $receiptDetail ))
  1853. die ( '参数错误' );
  1854. $aItem = $accountItem->find ( array (
  1855. 'asArray' => true
  1856. ) );
  1857. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1858. $ag = $tr = $ta = $ot = 0;
  1859. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1860. array_push ( $accountJson ['借款费用'], array (
  1861. 'aid' => 0,
  1862. 'name' => '申请金额',
  1863. 'price' => number_format ( $agency, 2, '.', '' )
  1864. ) );
  1865. $sum += $agency;
  1866. $agencySum += $agency;
  1867. $accountJson ['cSum'] = array (
  1868. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1869. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1870. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1871. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1872. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1873. );
  1874. // 报销单
  1875. $receipt->loanItem = json_encode ( $accountJson );
  1876. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1877. $receipt->cid = $cid;
  1878. // 特殊状态
  1879. // 修改审批流程加入角色
  1880. if ($receiptDetail ['status'] != 4)
  1881. $receipt->verify = $verify;
  1882. $order = array (
  1883. "\r\n",
  1884. "\n",
  1885. "\r"
  1886. );
  1887. $replace = '<br/>';
  1888. $explanation = str_replace ( $order, $replace, $explanation );
  1889. $receipt->explanation = $explanation;
  1890. $receipt->remittanceName = $remittanceName;
  1891. $receipt->bankName = $bankName;
  1892. $receipt->bankNumber = $bankNumber;
  1893. $receipt->remittanceBankType = $remittanceBankType;
  1894. if ($remittanceBankType == 1)
  1895. $receipt->coupletNumber = $coupletNumber;
  1896. $receipt->update ( array (
  1897. 'where' => 'rid=' . $rid
  1898. ) );
  1899. // 借款数据更新
  1900. $loanReceipt->loanItem = json_encode ( $accountJson );
  1901. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1902. $loanReceipt->cid = $cid;
  1903. if ($receiptDetail ['status'] != 4)
  1904. $loanReceipt->verify = $verify;
  1905. $loanReceipt->explanation = $explanation;
  1906. $receipt->executeCopy = $executeDetail ['staff'];
  1907. $loanReceipt->update ( array (
  1908. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1909. ) );
  1910. }
  1911. return "/saeaBorad";
  1912. }
  1913. function saeaLoanReceiptAdd() {
  1914. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1915. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  1916. Doo::loadModel ( 'receipt' );
  1917. $receipt = new receipt ();
  1918. Doo::loadModel ( 'loanReceipt' );
  1919. $loanReceipt = new loanReceipt ();
  1920. Doo::loadModel ( 'L_category' );
  1921. $Lcategory = new L_category ();
  1922. Doo::loadModel ( 'verify' );
  1923. Doo::loadModel ( 'statistics' );
  1924. $statistics = new statistics ();
  1925. $verify = new verify ();
  1926. Doo::loadModel ( 'staff' );
  1927. $staff = new staff ();
  1928. $receiptDetail = $receipt->getOne ( array (
  1929. 'where' => 'rid=' . $rid,
  1930. 'desc' => 'rid',
  1931. 'asArray' => true
  1932. ) );
  1933. $receiptList = $loanReceipt->find ( array (
  1934. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1935. 'desc' => 'rid',
  1936. 'asArray' => true
  1937. ) );
  1938. $Locate = 0;
  1939. $roleId = 0;
  1940. $button = 0;
  1941. foreach ( $receiptList as $key => $value ) {
  1942. $receiptList [$key] ['Locate'] = $Locate;
  1943. $Locate ++;
  1944. $receiptList [$key] ['reviseDetail'] = array ();
  1945. if (! empty ( $value ['reviseDetail'] ))
  1946. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1947. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1948. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1949. $categoryDetil = $Lcategory->getOne ( array (
  1950. 'where' => 'cid=' . $value ['cid'],
  1951. 'asArray' => true
  1952. ) );
  1953. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1954. // 检测编辑状态
  1955. $verifyList = $verify->getOne ( array (
  1956. 'where' => 'vid=' . $value ['verify'],
  1957. 'asArray' => true
  1958. ) );
  1959. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1960. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1961. Doo::loadModel ( 'role' );
  1962. $role = new role ();
  1963. $flag = true;
  1964. $roleKey = 0;
  1965. $endStaffArray = array ();
  1966. $roleArrayCopy = array ();
  1967. foreach ( $verifyList as $k => $v ) {
  1968. // init verifyStaff
  1969. if ($v [1] == 'ROLE') {
  1970. if (! empty ( $verifyStaff )) {
  1971. $endStaffArray = end ( $verifyStaff );
  1972. // if ($v[0]==$endStaffArray['nextStaff']){
  1973. // $roleId=$v[0];
  1974. // }
  1975. }
  1976. $roleVerify = json_decode ( $v [3], true );
  1977. $roleKey = $k;
  1978. $roleArray = array ();
  1979. $rolename = $role->getOne ( array (
  1980. 'where' => 'rid=' . $v [0],
  1981. 'asArray' => true
  1982. ) );
  1983. foreach ( $roleVerify as $o => $p ) {
  1984. $staffID = explode ( '_', $p );
  1985. $staffInfo = $staff->getOne ( array (
  1986. 'where' => 'sid=' . $staffID [0],
  1987. 'asArray' => true
  1988. ) );
  1989. // print_r($staffID);
  1990. $exp = array (
  1991. 0 => $staffInfo ['sid'],
  1992. 1 => $staffID [1],
  1993. 2 => $staffInfo ['avatar'],
  1994. 'date' => '',
  1995. 'date' => '',
  1996. 'opinion' => '',
  1997. 'status' => '',
  1998. 'rolename' => $rolename ['name']
  1999. );
  2000. array_push ( $roleArray, $exp );
  2001. }
  2002. $roleArrayCopy [$v [0]] = $roleArray;
  2003. // $verifyList[$k]['roleArray']=$roleArray;
  2004. }
  2005. $verifyList [$k] ['date'] = "";
  2006. $verifyList [$k] ['opinion'] = "";
  2007. $verifyList [$k] ['status'] = "";
  2008. if (empty ( $verifyStaff )) {
  2009. $verifyList [$k] ['date'] = "";
  2010. $verifyList [$k] ['opinion'] = "";
  2011. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2012. $verifyList [$k] ['status'] = 4;
  2013. $flag = false;
  2014. }
  2015. } else {
  2016. foreach ( $verifyStaff as $m => $u ) {
  2017. if ($v [0] == $m) {
  2018. $verifyList [$k] ['date'] = $u ['date'];
  2019. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2020. $verifyList [$k] ['status'] = $u ['status'];
  2021. $flag = false;
  2022. break;
  2023. }
  2024. }
  2025. $endStaffArray = end ( $verifyStaff );
  2026. if (isset ( $endStaffArray ['ROLE'] )) {
  2027. } else {
  2028. // $endKey=key($verifyStaff);
  2029. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2030. // $button=4;
  2031. // $verifyList[$k]['status']=4;
  2032. // }
  2033. }
  2034. }
  2035. }
  2036. $rolename ['name'] = '';
  2037. if (! empty ( $roleId )) {
  2038. Doo::loadModel ( 'role' );
  2039. $role = new role ();
  2040. $rolename = $role->getOne ( array (
  2041. 'where' => 'rid=' . $roleId,
  2042. 'asArray' => true
  2043. ) );
  2044. }
  2045. if (! empty ( $verifyStaff ))
  2046. $endStaffArray = end ( $verifyStaff );
  2047. $KOP = false;
  2048. foreach ( $roleArrayCopy as $P => $A ) {
  2049. foreach ( $A as $MKI => $AVL ) {
  2050. if (! empty ( $verifyStaff )) {
  2051. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2052. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2053. $button = 4;
  2054. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2055. }
  2056. foreach ( $verifyStaff as $m => $u ) {
  2057. $AVLFK = $AVL [0] . '_R';
  2058. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2059. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2060. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2061. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2062. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2063. break;
  2064. }
  2065. }
  2066. } else {
  2067. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2068. $button = 4;
  2069. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2070. }
  2071. }
  2072. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2073. $KOP = true;
  2074. }
  2075. }
  2076. foreach ( $roleArrayCopy as $k => $v ) {
  2077. foreach ( $verifyList as $m => $n ) {
  2078. if ($n [0] == $k) {
  2079. array_splice ( $verifyList, $m, 1, $v );
  2080. }
  2081. }
  2082. }
  2083. $receiptList [$key] ['verifyList'] = $verifyList;
  2084. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2085. 'where' => 'sid=' . $value ['staff'],
  2086. 'asArray' => true
  2087. ) );
  2088. $receiptList [$key] ['button'] = $button;
  2089. //
  2090. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2091. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2092. }
  2093. $data ['receiptList'] = $receiptList;
  2094. $data ['receiptDetail'] = $receiptDetail;
  2095. Doo::loadModel ( 'L_category' );
  2096. $lCategory = new L_category ();
  2097. Doo::loadModel ( 'accountItem' );
  2098. $accountItem = new accountItem ();
  2099. $acItem = $accountItem->find ( array (
  2100. 'asArray' => true
  2101. ) );
  2102. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2103. $data ['rid'] = $rid;
  2104. $data ['category'] = $lCategory->find ( array (
  2105. 'asArray' => true
  2106. ) );
  2107. $data ['veList'] = $veList;
  2108. $data ['acItem'] = $acItem;
  2109. $data['itineraryDate']=$this->_itineraryDateMin();
  2110. $data ['memu'] = "receipt";
  2111. $data ['staff'] = $this->staff;
  2112. $data ['receiptMemu'] = 'saeaBorad';
  2113. $data ['verifyId'] = $this->verifyId;
  2114. $data ['executeId'] = $this->executeId;
  2115. $data['receiptClass']=$receiptClass;
  2116. if($receiptClass=='trave'){
  2117. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2118. }else{
  2119. $this->render ( "/receipt/feeLoanReceipt", $data );
  2120. }
  2121. }
  2122. function saeaLoanReceiptAddDo() {
  2123. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2124. $agency = $this->get_args ( 'agency' );
  2125. $travel = $this->get_args ( 'travel' );
  2126. $train = $this->get_args ( 'train' );
  2127. $other = $this->get_args ( 'other' );
  2128. $inttrain = $this->get_args ( 'inttrain' );
  2129. $itinerary = $_POST['itinerary'];//$this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2130. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2131. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2132. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2133. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2134. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2135. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2136. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2137. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2138. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2139. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2140. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2141. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2142. header ( 'Content-Type:text/html;charset=utf-8' );
  2143. die ( '请填写联行号' );
  2144. }
  2145. if($receiptClass=='agency'){
  2146. $receiptClass=1;
  2147. }elseif($receiptClass=='trave'){
  2148. $receiptClass=2;
  2149. if($this->_verificationItinerary($itinerary)){
  2150. header ( 'Content-Type:text/html;charset=utf-8' );
  2151. die ( '已申请过类此日期的行程' );
  2152. }
  2153. }elseif($receiptClass=='internalTrain'){
  2154. $receiptClass=3;
  2155. }else{
  2156. header ( 'Content-Type:text/html;charset=utf-8' );
  2157. die ( '借款报销单分类不正确' );
  2158. }
  2159. Doo::loadModel ( 'receipt' );
  2160. Doo::loadModel ( 'receiptDetail' );
  2161. Doo::loadModel ( 'accountItem' );
  2162. $accountItem = new accountItem ();
  2163. $receipt = new receipt ();
  2164. Doo::loadModel ( 'enclosur' );
  2165. Doo::loadModel ( 'execute' );
  2166. $execute = new execute ();
  2167. $executeDetail = $execute->getOne ( array (
  2168. 'where' => 'mold="借款费用执行人"',
  2169. 'asArray' => true
  2170. ) );
  2171. $receiptDet = $receipt->getOne ( array (
  2172. 'where' => 'rid=' . $rid,
  2173. 'asArray' => true
  2174. ) );
  2175. // if(!empty($receiptDetail))
  2176. // return "/referReceipt/".$receiptDetail['rid'];
  2177. $aItem = $accountItem->find ( array (
  2178. 'asArray' => true
  2179. ) );
  2180. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2181. $ag = $tr = $ta = $ot =$it = 0;
  2182. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2183. foreach ( $aItem as $key => $value ) {
  2184. if ($value ['category'] == $this->AGENCY) {
  2185. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2186. array_push ( $accountJson [$this->AGENCY], array (
  2187. 'aid' => $value ['aid'],
  2188. 'name' => $value ['name'],
  2189. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2190. ) );
  2191. $sum += $agency [$ag];
  2192. $agencySum += $agency [$ag];
  2193. }
  2194. $ag ++;
  2195. }
  2196. if ($value ['category'] == $this->TRAVEL) {
  2197. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2198. array_push ( $accountJson [$this->TRAVEL], array (
  2199. 'aid' => $value ['aid'],
  2200. 'name' => $value ['name'],
  2201. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2202. ) );
  2203. $sum += $travel [$tr];
  2204. $travelSum += $travel [$tr];
  2205. }
  2206. $tr ++;
  2207. }
  2208. if ($value ['category'] == $this->INTTRAIN) {
  2209. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2210. array_push ( $accountJson [$this->INTTRAIN], array (
  2211. 'aid' => $value ['aid'],
  2212. 'name' => $value ['name'],
  2213. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2214. ) );
  2215. $sum += $inttrain [$it];
  2216. $inttrainSum += $inttrain [$it];
  2217. }
  2218. $it ++;
  2219. }
  2220. if ($value ['category'] == $this->TRAIN) {
  2221. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2222. array_push ( $accountJson [$this->TRAIN], array (
  2223. 'aid' => $value ['aid'],
  2224. 'name' => $value ['name'],
  2225. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2226. ) );
  2227. $sum += $train [$ta];
  2228. $trainSum += $train [$ta];
  2229. }
  2230. $ta ++;
  2231. }
  2232. if ($value ['category'] == $this->OTHER) {
  2233. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2234. array_push ( $accountJson [$this->OTHER], array (
  2235. 'aid' => $value ['aid'],
  2236. 'name' => $value ['name'],
  2237. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2238. ) );
  2239. $sum += $other [$ot];
  2240. $otherSum += $other [$ot];
  2241. }
  2242. $ot ++;
  2243. }
  2244. }
  2245. $accountJson ['cSum'] = array (
  2246. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2247. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2248. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2249. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2250. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2251. );
  2252. // 报销单
  2253. $receipt->accountItem = json_encode ( $accountJson );
  2254. $receipt->staff = $this->staff [0] ['sid'];
  2255. $receipt->loanSum = $receiptDet ['sum'];
  2256. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2257. $receipt->date = date ( "Y-m-d" );
  2258. $receipt->pastDate = '0000-00-00';
  2259. $receipt->cid = $cid;
  2260. $receipt->status = 7;
  2261. $receipt->receiptClass=$receiptClass;
  2262. if($receiptClass==2){
  2263. $receipt->itinerary=$itinerary;
  2264. $this->_storageItinerary($itinerary, $rid);
  2265. }
  2266. // 修改审批流程加入角色
  2267. $receipt->verify = $verify;
  2268. $receipt->verifyStaff = '';
  2269. $receipt->executeStaff = '';
  2270. $receipt->executeCopy = $executeDetail ['staff'];
  2271. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2272. $receipt->explanation = $explanation;
  2273. $receipt->remittanceName = $remittanceName;
  2274. $receipt->bankName = $bankName;
  2275. $receipt->bankNumber = $bankNumber;
  2276. $receipt->remittanceBankType = $remittanceBankType;
  2277. if ($remittanceBankType == 1)
  2278. $receipt->coupletNumber = $coupletNumber;
  2279. $receipt->update ( array (
  2280. 'where' => 'rid=' . $rid
  2281. ) );
  2282. // 附件
  2283. if (! empty ( $enclosurName )) {
  2284. $enclosurArray = explode ( '-', $enclosurName );
  2285. foreach ( $enclosurArray as $value ) {
  2286. $enclosur = new enclosur ();
  2287. $enclosur->name = $value;
  2288. $enclosur->rid = $rid;
  2289. $enclosur->insert ();
  2290. }
  2291. // print_r($enclosurArray);die;
  2292. }
  2293. // 报销详情
  2294. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2295. $receiptDetail = new receiptDetail ();
  2296. $receiptDetail->staff = $this->staff [0] ['sid'];
  2297. $receiptDetail->item = $value ['name'];
  2298. $receiptDetail->itemCategory = $this->AGENCY;
  2299. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2300. $receiptDetail->date = date ( "Y-m-d" );
  2301. $receiptDetail->cid = $cid;
  2302. $receiptDetail->rid = $rid;
  2303. $receiptDetail->status = 4;
  2304. $receiptDetail->insert ();
  2305. }
  2306. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2307. $receiptDetail = new receiptDetail ();
  2308. $receiptDetail->staff = $this->staff [0] ['sid'];
  2309. $receiptDetail->item = $value ['name'];
  2310. $receiptDetail->itemCategory = $this->TRAVEL;
  2311. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2312. $receiptDetail->date = date ( "Y-m-d" );
  2313. $receiptDetail->cid = $cid;
  2314. $receiptDetail->rid = $rid;
  2315. $receiptDetail->status = 4;
  2316. $receiptDetail->insert ();
  2317. }
  2318. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2319. $receiptDetail = new receiptDetail ();
  2320. $receiptDetail->staff = $this->staff [0] ['sid'];
  2321. $receiptDetail->item = $value ['name'];
  2322. $receiptDetail->itemCategory = $this->TRAIN;
  2323. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2324. $receiptDetail->date = date ( "Y-m-d" );
  2325. $receiptDetail->cid = $cid;
  2326. $receiptDetail->rid = $rid;
  2327. $receiptDetail->status = 4;
  2328. $receiptDetail->insert ();
  2329. }
  2330. //内训
  2331. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2332. $receiptDetail = new receiptDetail ();
  2333. $receiptDetail->staff = $this->staff [0] ['sid'];
  2334. $receiptDetail->item = $value ['name'];
  2335. $receiptDetail->itemCategory = $this->INTTRAIN;
  2336. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2337. $receiptDetail->date = date ( "Y-m-d" );
  2338. $receiptDetail->cid = $cid;
  2339. $receiptDetail->rid = $rid;
  2340. $receiptDetail->status = 4;
  2341. $receiptDetail->insert ();
  2342. }
  2343. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2344. $receiptDetail = new receiptDetail ();
  2345. $receiptDetail->staff = $this->staff [0] ['sid'];
  2346. $receiptDetail->item = $value ['name'];
  2347. $receiptDetail->itemCategory = $this->OTHER;
  2348. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2349. $receiptDetail->date = date ( "Y-m-d" );
  2350. $receiptDetail->cid = $cid;
  2351. $receiptDetail->rid = $rid;
  2352. $receiptDetail->status = 4;
  2353. $receiptDetail->insert ();
  2354. }
  2355. return "/saeaBorad";
  2356. }
  2357. return "/saeaLoanReceiptAdd/" . $rid;
  2358. }
  2359. function saeaLoanReceiptEdi() {
  2360. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2361. Doo::loadClass ( 'XDeode' );
  2362. $XDeode = new XDeode ( 7 );
  2363. $rid = $XDeode->decode ( $ridKey );
  2364. if (! is_numeric ( $rid ))
  2365. die ( 'illegal request' );
  2366. Doo::loadModel ( 'accountItem' );
  2367. Doo::loadModel ( 'verify' );
  2368. Doo::loadModel ( 'receipt' );
  2369. $receipt = new receipt ();
  2370. $verify = new verify ();
  2371. $accountItem = new accountItem ();
  2372. Doo::loadModel ( 'L_category' );
  2373. $Lcategory = new L_category ();
  2374. Doo::loadModel ( "role" );
  2375. $role = new role ();
  2376. Doo::loadModel ( 'loanReceipt' );
  2377. $loanReceipt = new loanReceipt ();
  2378. Doo::loadModel ( 'staff' );
  2379. $staff = new staff ();
  2380. $receiptDetail = $receipt->getOne ( array (
  2381. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2382. 'asArray' => true
  2383. ) );
  2384. if (empty ( $receiptDetail ))
  2385. return "/saeaBorad";
  2386. $receiptList = $loanReceipt->find ( array (
  2387. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2388. 'desc' => 'rid',
  2389. 'asArray' => true
  2390. ) );
  2391. $Locate = 0;
  2392. $roleId = 0;
  2393. $button = 0;
  2394. foreach ( $receiptList as $key => $value ) {
  2395. $receiptList [$key] ['Locate'] = $Locate;
  2396. $Locate ++;
  2397. $receiptList [$key] ['reviseDetail'] = array ();
  2398. if (! empty ( $value ['reviseDetail'] ))
  2399. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2400. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2401. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2402. $categoryDetil = $Lcategory->getOne ( array (
  2403. 'where' => 'cid=' . $value ['cid'],
  2404. 'asArray' => true
  2405. ) );
  2406. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2407. // 检测编辑状态
  2408. $verifyList = $verify->getOne ( array (
  2409. 'where' => 'vid=' . $value ['verify'],
  2410. 'asArray' => true
  2411. ) );
  2412. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2413. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2414. Doo::loadModel ( 'role' );
  2415. $role = new role ();
  2416. $flag = true;
  2417. $roleKey = 0;
  2418. $endStaffArray = array ();
  2419. $roleArrayCopy = array ();
  2420. foreach ( $verifyList as $k => $v ) {
  2421. // init verifyStaff
  2422. if ($v [1] == 'ROLE') {
  2423. if (! empty ( $verifyStaff )) {
  2424. $endStaffArray = end ( $verifyStaff );
  2425. // if ($v[0]==$endStaffArray['nextStaff']){
  2426. // $roleId=$v[0];
  2427. // }
  2428. }
  2429. $roleVerify = json_decode ( $v [3], true );
  2430. $roleKey = $k;
  2431. $roleArray = array ();
  2432. $rolename = $role->getOne ( array (
  2433. 'where' => 'rid=' . $v [0],
  2434. 'asArray' => true
  2435. ) );
  2436. foreach ( $roleVerify as $o => $p ) {
  2437. $staffID = explode ( '_', $p );
  2438. $staffInfo = $staff->getOne ( array (
  2439. 'where' => 'sid=' . $staffID [0],
  2440. 'asArray' => true
  2441. ) );
  2442. // print_r($staffID);
  2443. $exp = array (
  2444. 0 => $staffInfo ['sid'],
  2445. 1 => $staffID [1],
  2446. 2 => $staffInfo ['avatar'],
  2447. 'date' => '',
  2448. 'date' => '',
  2449. 'opinion' => '',
  2450. 'status' => '',
  2451. 'rolename' => $rolename ['name']
  2452. );
  2453. array_push ( $roleArray, $exp );
  2454. }
  2455. $roleArrayCopy [$v [0]] = $roleArray;
  2456. // $verifyList[$k]['roleArray']=$roleArray;
  2457. }
  2458. $verifyList [$k] ['date'] = "";
  2459. $verifyList [$k] ['opinion'] = "";
  2460. $verifyList [$k] ['status'] = "";
  2461. if (empty ( $verifyStaff )) {
  2462. $verifyList [$k] ['date'] = "";
  2463. $verifyList [$k] ['opinion'] = "";
  2464. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2465. $verifyList [$k] ['status'] = 4;
  2466. $flag = false;
  2467. }
  2468. } else {
  2469. foreach ( $verifyStaff as $m => $u ) {
  2470. if ($v [0] == $m) {
  2471. $verifyList [$k] ['date'] = $u ['date'];
  2472. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2473. $verifyList [$k] ['status'] = $u ['status'];
  2474. $flag = false;
  2475. break;
  2476. }
  2477. }
  2478. $endStaffArray = end ( $verifyStaff );
  2479. if (isset ( $endStaffArray ['ROLE'] )) {
  2480. } else {
  2481. // $endKey=key($verifyStaff);
  2482. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2483. // $button=4;
  2484. // $verifyList[$k]['status']=4;
  2485. // }
  2486. }
  2487. }
  2488. }
  2489. $rolename ['name'] = '';
  2490. if (! empty ( $roleId )) {
  2491. Doo::loadModel ( 'role' );
  2492. $role = new role ();
  2493. $rolename = $role->getOne ( array (
  2494. 'where' => 'rid=' . $roleId,
  2495. 'asArray' => true
  2496. ) );
  2497. }
  2498. if (! empty ( $verifyStaff ))
  2499. $endStaffArray = end ( $verifyStaff );
  2500. $KOP = false;
  2501. foreach ( $roleArrayCopy as $P => $A ) {
  2502. foreach ( $A as $MKI => $AVL ) {
  2503. if (! empty ( $verifyStaff )) {
  2504. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2505. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2506. $button = 4;
  2507. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2508. }
  2509. foreach ( $verifyStaff as $m => $u ) {
  2510. $AVLFK = $AVL [0] . '_R';
  2511. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2512. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2513. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2514. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2515. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2516. break;
  2517. }
  2518. }
  2519. } else {
  2520. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2521. $button = 4;
  2522. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2523. }
  2524. }
  2525. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2526. $KOP = true;
  2527. }
  2528. }
  2529. foreach ( $roleArrayCopy as $k => $v ) {
  2530. foreach ( $verifyList as $m => $n ) {
  2531. if ($n [0] == $k) {
  2532. array_splice ( $verifyList, $m, 1, $v );
  2533. }
  2534. }
  2535. }
  2536. $receiptList [$key] ['verifyList'] = $verifyList;
  2537. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2538. 'where' => 'sid=' . $value ['staff'],
  2539. 'asArray' => true
  2540. ) );
  2541. $receiptList [$key] ['button'] = $button;
  2542. //
  2543. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2544. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2545. }
  2546. $data ['receiptList'] = $receiptList;
  2547. $acItem = $accountItem->find ( array (
  2548. 'asArray' => true
  2549. ) );
  2550. $veList = $verify->find ( array (
  2551. 'asArray' => true
  2552. ) );
  2553. foreach ( $veList as $key => $value ) {
  2554. $v = json_decode ( $value ['staff'] );
  2555. $list = array ();
  2556. foreach ( $v as $n => $m ) {
  2557. if ($m ['1'] == 'ROLE') {
  2558. $roleInfo = $role->getOne ( array (
  2559. 'where' => 'rid=' . $m [0],
  2560. 'asArray' => true
  2561. ) );
  2562. $v [$n] [1] = $roleInfo ['name'];
  2563. array_push ( $list, $roleInfo ['name'] );
  2564. } else {
  2565. array_push ( $list, $v [$n] [1] );
  2566. }
  2567. }
  2568. $veList [$key] ['staff'] = implode ( '>', $list );
  2569. }
  2570. // 配置编辑信息
  2571. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2572. foreach ( $acItem as $key => $value ) {
  2573. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2574. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2575. $acItem [$key] ['price'] = $v ['price'];
  2576. }
  2577. }
  2578. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2579. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2580. $acItem [$key] ['price'] = $v ['price'];
  2581. }
  2582. }
  2583. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2584. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2585. $acItem [$key] ['price'] = $v ['price'];
  2586. }
  2587. }
  2588. //内训
  2589. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2590. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2591. $acItem [$key] ['price'] = $v ['price'];
  2592. }
  2593. }
  2594. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2595. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2596. $acItem [$key] ['price'] = $v ['price'];
  2597. }
  2598. }
  2599. }
  2600. $data ['category'] = $Lcategory->find ( array (
  2601. 'asArray' => true
  2602. ) );
  2603. $data ['ridKey'] = $ridKey;
  2604. $data ['cSum'] = $accountItemList ['cSum'];
  2605. $data ['sum'] = $receiptDetail ['sum'];
  2606. $data ['receiptDetail'] = $receiptDetail;
  2607. $data ['veList'] = $veList;
  2608. $data ['acItem'] = $acItem;
  2609. $data ['memu'] = "receipt";
  2610. $data ['staff'] = $this->staff;
  2611. $data ['receiptMemu'] = 'saeaBorad';
  2612. $data ['verify'] = $receiptDetail ['verify'];
  2613. $data ['verifyId'] = $this->verifyId;
  2614. $data ['executeId'] = $this->executeId;
  2615. $data ['rid'] = $rid;
  2616. if($receiptDetail['receiptClass']==1){
  2617. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2618. }elseif($receiptDetail['receiptClass']==2){
  2619. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2620. }elseif($receiptDetail['receiptClass']==3){
  2621. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2622. }else{
  2623. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2624. }
  2625. }
  2626. /**
  2627. * 培训班结算
  2628. */
  2629. function receiptTrainAdd() {
  2630. Doo::loadModel ( 'accountItem' );
  2631. $accountItem = new accountItem ();
  2632. $acItem = $accountItem->find ( array (
  2633. 'asArray' => true
  2634. ) );
  2635. // 审批组
  2636. Doo::loadModel ( 'verify' );
  2637. $verify = new verify ();
  2638. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2639. // 办事处
  2640. Doo::loadModel ( 'L_category' );
  2641. $lCategory = new L_category ();
  2642. $data ['category'] = $lCategory->getCategory ();
  2643. $data ['veList'] = $veList;
  2644. $data ['memu'] = "receipt";
  2645. $data ['staff'] = $this->staff;
  2646. $data ['acItem'] = $acItem;
  2647. $data ['receiptMemu'] = 'saeaBorad';
  2648. $data ['verifyId'] = $this->verifyId;
  2649. $data ['executeId'] = $this->executeId;
  2650. $this->render ( "/receipt/receiptTrainAdd", $data );
  2651. }
  2652. /**
  2653. * 添加培训班结算
  2654. */
  2655. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2656. // 培训班信息
  2657. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2658. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2659. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2660. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2661. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2662. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2663. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2664. // 发票信息
  2665. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2666. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2667. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2668. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2669. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2670. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2671. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2672. //&&! empty ( $participants )
  2673. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2674. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2675. header ( 'Content-Type:text/html;charset=utf-8' );
  2676. die ( '请填写联行号' );
  2677. }
  2678. Doo::loadModel ( 'execute' );
  2679. $execute = new execute ();
  2680. $executeDetail = $execute->getOne ( array (
  2681. 'where' => 'mold="培训班结算"',
  2682. 'asArray' => true
  2683. ) );
  2684. if (empty ( $executeDetail )) {
  2685. header ( 'Content-Type:text/html;charset=utf-8' );
  2686. die ( '未设置执行人' );
  2687. }
  2688. Doo::loadClass ( 'XDeode' );
  2689. $XDeode = new XDeode ( 5 );
  2690. $cid = $XDeode->decode ( $cid );
  2691. Doo::loadModel ( 'receipt' );
  2692. $receipt = new receipt ();
  2693. Doo::loadModel ( 'receiptTraining' );
  2694. $receiptTraining = new receiptTraining ();
  2695. // 创建费用培训班
  2696. $item = array (
  2697. 'cid' => $this->staff [0] ['cid'],
  2698. 'categoryName' => $this->staff [0] ['category'],
  2699. 'trainName' => $trainName,
  2700. 'trainStartDate' => $trainStartDate,
  2701. 'trainEndDate' => $trainEndDate,
  2702. 'participants' => $participants,
  2703. 'freeParticipants'=>$freeParticipants,
  2704. 'trainAddress' => $trainAddress,
  2705. 'trainRemarks' => $trainRemarks,
  2706. 'creator' => $this->staff [0] ['sid'],
  2707. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2708. );
  2709. $irid = $receiptTraining->addReceiptTraining ( $item );
  2710. // 报销单
  2711. $receipt->status = 5;
  2712. $receipt->trainId = $irid;
  2713. $receipt->Rtype = 3;
  2714. $receipt->staff = $this->staff [0] ['sid'];
  2715. $receipt->cid = $cid;
  2716. $receipt->verify = $verify;
  2717. $receipt->date = date ( "Y-m-d" );
  2718. $receipt->executeCopy = $executeDetail ['staff'];
  2719. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2720. $receipt->remittanceName = $remittanceName;
  2721. $receipt->bankName = $bankName;
  2722. $receipt->bankNumber = $bankNumber;
  2723. $receipt->remittanceBankType = $remittanceBankType;
  2724. if ($remittanceBankType == 1)
  2725. $receipt->coupletNumber = $coupletNumber;
  2726. $rid = $receipt->insert ();
  2727. $XDeode = new XDeode ( 7 );
  2728. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2729. } else
  2730. die ( 'illegal request' );
  2731. }
  2732. /**
  2733. * 培训班编辑
  2734. */
  2735. function receiptTrainEdi() {
  2736. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2737. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2738. Doo::loadClass ( 'XDeode' );
  2739. $XDeode = new XDeode ( 7 );
  2740. $rid = $XDeode->decode ( $ridKey );
  2741. if (! is_numeric ( $rid ))
  2742. die ( 'illegal request' );
  2743. Doo::loadModel ( 'receipt' );
  2744. $receipt = new receipt ();
  2745. Doo::loadModel ( 'receiptTraining' );
  2746. $receiptTraining = new receiptTraining ();
  2747. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2748. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2749. die ('illegal request--status');
  2750. }
  2751. //如有已入账已收款的发票,自动取消办事处已收款
  2752. // Doo::loadModel ( 'RIExtend' );
  2753. // $RIExtend = new RIExtend ();
  2754. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2755. // if (!empty($RIExtendList)){
  2756. // foreach ($RIExtendList as $key=>$value){
  2757. // $RIExtend = new RIExtend ();
  2758. // $RIExtend->delete(array (
  2759. // 'where' => 'iid=' . $value['iid'],
  2760. // 'limit' => 1
  2761. // ));
  2762. // }
  2763. // }
  2764. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2765. // 汇总表合计
  2766. // 收入合计--加入开票合计
  2767. Doo::loadModel ( 'invoiceTraining' );
  2768. $invoiceTraining = new invoiceTraining ();
  2769. $invoiceTrainingDetail = array (
  2770. 'invoiceArriveAmount' => 0,
  2771. 'RIAmount' => 0,
  2772. 'invoiceTotalAmount' => 0,
  2773. 'invoiceCompanyAmount'=>0
  2774. );
  2775. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2776. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2777. }
  2778. // print_r($invoiceTrainingDetail);
  2779. $invoiceArriveAmount = $RIAmount = 0;
  2780. if (! empty ( $invoiceTrainingDetail )) {
  2781. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2782. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2783. }
  2784. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2785. //print_r($invoiceTrainingDetail);
  2786. // 支出项目
  2787. Doo::loadModel ( 'accountItem' );
  2788. $accountItem = new accountItem ();
  2789. // 项目金额合计
  2790. Doo::loadModel ( 'RItem' );
  2791. $RItem = new RItem ();
  2792. // 讲师获得
  2793. Doo::loadModel ( 'RILecturer' );
  2794. $RILecturer = new RILecturer ();
  2795. $RItemList = $RItem->getRItemByRid ( $rid );
  2796. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2797. // 支出项金额详情
  2798. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2799. // print_r($aiData);
  2800. // 利润
  2801. $profit=$invoiceArriveAmount - $aiData ['total'];
  2802. $companyProfit=$profit * 0.6;
  2803. $categoryProfit=$profit * 0.4;
  2804. $data ['profit'] = sprintf("%.2f",$profit);
  2805. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2806. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2807. //发票利润
  2808. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2809. //发票公司利润
  2810. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2811. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2812. //办事处利润
  2813. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2814. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2815. // print_r($aiData['dataList']);
  2816. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2817. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2818. // 备用金
  2819. $sum = 0;
  2820. $data ['receiptLoanDetail'] = array (
  2821. 'sum' => '0.00'
  2822. );
  2823. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2824. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2825. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2826. $sum=0;
  2827. foreach ($receiptLoanList as $key=>$value){
  2828. $sum+=$value['sum'];
  2829. }
  2830. $data ['receiptLoanDetail'] = array (
  2831. 'sum' => $sum
  2832. );
  2833. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2834. }
  2835. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2836. $data ['payment'] = sprintf("%.2f",$payment);
  2837. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2838. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2839. $data ['aiList'] = $aiData ['dataList'];
  2840. // 占比计算
  2841. if ($invoiceArriveAmount != 0) {
  2842. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2843. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2844. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2845. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2846. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2847. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2848. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2849. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2850. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2851. } else {
  2852. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2853. }
  2854. //发票金额占比计算
  2855. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2856. //支出
  2857. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2858. //利润
  2859. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2860. //公司利润
  2861. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2862. //办事处利润
  2863. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2864. //公司收款
  2865. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2866. //备用金
  2867. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2868. //办事处收款
  2869. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2870. //办事处实际支出
  2871. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2872. //付总部款
  2873. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2874. }else{
  2875. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2876. }
  2877. //讲师人数
  2878. Doo::loadModel ( 'RILecturer' );
  2879. $RILecturer = new RILecturer ();
  2880. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2881. $data['lectureCount']=count($RILecturerList);
  2882. // 审批组
  2883. Doo::loadModel ( 'verify' );
  2884. $verify = new verify ();
  2885. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2886. // 办事处
  2887. Doo::loadModel ( 'L_category' );
  2888. $lCategory = new L_category ();
  2889. $data ['category'] = $lCategory->getCategory ();
  2890. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2891. $data ['receiptDetail'] = $receiptDetail;
  2892. $data ['veList'] = $veList;
  2893. $data ['trainEdiType'] = $trainEdiType;
  2894. $data ['ridKey'] = $ridKey;
  2895. $data ['memu'] = "receipt";
  2896. $data ['staff'] = $this->staff;
  2897. $data ['receiptMemu'] = 'saeaBorad';
  2898. $data ['verifyId'] = $this->verifyId;
  2899. $data ['executeId'] = $this->executeId;
  2900. $this->render ( "/receipt/receiptTrainEdi", $data );
  2901. }
  2902. /**
  2903. * 培训班借款编辑
  2904. */
  2905. function receiptTrainLoanEdi() {
  2906. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2907. Doo::loadClass ( 'XDeode' );
  2908. $XDeode = new XDeode ( 7 );
  2909. $rid = $XDeode->decode ( $ridKey );
  2910. if (! is_numeric ( $rid ))
  2911. die ( 'illegal request' );
  2912. Doo::loadModel ( 'receipt' );
  2913. $receipt = new receipt ();
  2914. Doo::loadModel ( 'receiptTraining' );
  2915. $receiptTraining = new receiptTraining ();
  2916. Doo::loadModel ( 'verify' );
  2917. $verify = new verify ();
  2918. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2919. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2920. die ();
  2921. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2922. // 借款详情HTML
  2923. // 获得借款信息
  2924. $receiptLoanHtml = '';
  2925. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2926. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2927. foreach ($receiptLoanList as $key=>$value){
  2928. // 获得某费用单审批信息
  2929. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2930. Doo::loadClass ( 'receipt.func' );
  2931. $extendHtml = '<p><a class="button"
  2932. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2933. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2934. }
  2935. }
  2936. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2937. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2938. $data ['receiptDetail'] = $receiptDetail;
  2939. $data ['trainEdiType'] = "LOAN";
  2940. $data ['ridKey'] = $ridKey;
  2941. $data ['memu'] = "receipt";
  2942. $data ['staff'] = $this->staff;
  2943. $data ['receiptMemu'] = 'saeaBorad';
  2944. $data ['verifyId'] = $this->verifyId;
  2945. $data ['executeId'] = $this->executeId;
  2946. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2947. }
  2948. /**
  2949. * 更新培训班结算基本信息
  2950. */
  2951. function receiptTrainInfoEdiDo() {
  2952. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2953. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2954. // 培训班信息
  2955. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2956. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2957. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2958. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2959. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2960. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2961. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2962. // 发票信息
  2963. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2964. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2965. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2966. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2967. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2968. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2969. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2970. //&& ! empty ( $participants )
  2971. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2972. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2973. header ( 'Content-Type:text/html;charset=utf-8' );
  2974. die ( '请填写联行号' );
  2975. }
  2976. Doo::loadClass ( 'XDeode' );
  2977. $XDeode = new XDeode ( 5 );
  2978. $cid = $XDeode->decode ( $cid );
  2979. $rtid = $XDeode->decode ( $rtid );
  2980. $rid = $XDeode->decode ( $rid );
  2981. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2982. die ( 'illegal request-IdError' );
  2983. }
  2984. Doo::loadModel ( 'receipt' );
  2985. $receipt = new receipt ();
  2986. Doo::loadModel ( 'receiptTraining' );
  2987. $receiptTraining = new receiptTraining ();
  2988. // 更新费用培训班
  2989. $item = array (
  2990. 'rtid' => $rtid,
  2991. 'trainName' => $trainName,
  2992. 'trainStartDate' => $trainStartDate,
  2993. 'trainEndDate' => $trainEndDate,
  2994. 'participants' => $participants,
  2995. 'freeParticipants'=>$freeParticipants,
  2996. 'trainAddress' => $trainAddress,
  2997. 'trainRemarks' => $trainRemarks
  2998. );
  2999. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  3000. // 报销单
  3001. $receipt->rid = $rid;
  3002. $receipt->cid = $cid;
  3003. $receipt->verify = $verify;
  3004. $receipt->remittanceName = $remittanceName;
  3005. $receipt->bankName = $bankName;
  3006. $receipt->bankNumber = $bankNumber;
  3007. $receipt->remittanceBankType = $remittanceBankType;
  3008. if ($remittanceBankType == 1)
  3009. $receipt->coupletNumber = $coupletNumber;
  3010. $receipt->update ();
  3011. $XDeode = new XDeode ( 7 );
  3012. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  3013. } else
  3014. die ( 'illegal request' );
  3015. }
  3016. /**
  3017. * 编辑培训班结算---更新借款
  3018. */
  3019. function receiptTrainLoanEdiDo() {
  3020. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3021. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3022. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3023. Doo::loadModel ( 'receipt' );
  3024. $receipt = new receipt ();
  3025. Doo::loadClass ( 'XDeode' );
  3026. $XDeode = new XDeode ( 5 );
  3027. $rid = $XDeode->decode ( $ridKey );
  3028. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3029. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3030. die ( 'illegal request-ridError' );
  3031. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3032. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3033. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3034. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3035. die ( 'illegal request-receiptError' );
  3036. }
  3037. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3038. die ( 'illegal request-receipLoantError' );
  3039. }
  3040. // 培训班结算挂钩借款
  3041. $receipt = new receipt ();
  3042. $trainLoanRid=$ridLoan;
  3043. if (!empty($receiptDetail['trainLoanRid'])){
  3044. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3045. }
  3046. $item = array (
  3047. 'rid' => $rid,
  3048. 'trainLoanRid' => $trainLoanRid
  3049. );
  3050. $receipt->setReceiptByCondition ( $item );
  3051. // 更新借款状态变成已挂钩
  3052. $receipt = new receipt ();
  3053. $item = array (
  3054. 'rid' => $ridLoan,
  3055. 'status' => 10,
  3056. 'statusTrain' => 1
  3057. );
  3058. $receipt->setReceiptByCondition ( $item );
  3059. $XDeode = new XDeode ( 7 );
  3060. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3061. } else
  3062. die ( 'illegal request' );
  3063. }
  3064. /**
  3065. * 编辑培训班结算--移除借款
  3066. */
  3067. function receiptTrainLoanRemoveDo() {
  3068. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3069. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3070. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3071. Doo::loadModel ( 'receipt' );
  3072. $receipt = new receipt ();
  3073. Doo::loadClass ( 'XDeode' );
  3074. $XDeode = new XDeode ( 5 );
  3075. $rid = $XDeode->decode ( $ridKey );
  3076. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3077. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3078. die ( 'illegal request-ridError' );
  3079. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3080. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3081. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3082. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3083. die ( 'illegal request-receiptError' );
  3084. }
  3085. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3086. die ( 'illegal request-receipLoantError' );
  3087. }
  3088. // 培训班结算挂钩借款
  3089. $receipt = new receipt ();
  3090. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3091. foreach ($trainLoanRidArray as $key=>$value){
  3092. if($value==$ridLoan){
  3093. unset($trainLoanRidArray[$key]);
  3094. }
  3095. }
  3096. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3097. $item = array (
  3098. 'rid' => $rid,
  3099. 'trainLoanRid' => $trainLoanRidString
  3100. );
  3101. $receipt->setReceiptByCondition ( $item );
  3102. // 更新借款状态变成已挂钩
  3103. $receipt = new receipt ();
  3104. $item = array (
  3105. 'rid' => $ridLoan,
  3106. 'status' => 8,
  3107. 'statusTrain' => 0
  3108. );
  3109. $receipt->setReceiptByCondition ( $item );
  3110. $XDeode = new XDeode ( 7 );
  3111. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3112. } else
  3113. die ( 'illegal request' );
  3114. }
  3115. /**
  3116. * 编辑培训班结算 ---开票
  3117. */
  3118. function receiptTrainInvoiceEdi() {
  3119. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3120. Doo::loadClass ( 'XDeode' );
  3121. $XDeode = new XDeode ( 7 );
  3122. $rid = $XDeode->decode ( $ridKey );
  3123. if (! is_numeric ( $rid ))
  3124. die ( 'illegal request' );
  3125. Doo::loadModel ( 'receipt' );
  3126. $receipt = new receipt ();
  3127. Doo::loadModel ( 'receiptTraining' );
  3128. $receiptTraining = new receiptTraining ();
  3129. Doo::loadModel ( 'invoice' );
  3130. $invoice = new invoice ();
  3131. Doo::loadModel ( 'invoiceTraining' );
  3132. $invoiceTraining = new invoiceTraining ();
  3133. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3134. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3135. die ();
  3136. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3137. $invoiceList = $invoiceTrainingDetail = array ();
  3138. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3139. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3140. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3141. }
  3142. //print_r($invoiceList);
  3143. $data ['invoiceList'] = $invoiceList;
  3144. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3145. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3146. $data ['receiptDetail'] = $receiptDetail;
  3147. $data ['trainEdiType'] = "INVOICE";
  3148. $data ['ridKey'] = $ridKey;
  3149. $data ['memu'] = "receipt";
  3150. $data ['staff'] = $this->staff;
  3151. $data ['receiptMemu'] = 'saeaBorad';
  3152. $data ['verifyId'] = $this->verifyId;
  3153. $data ['executeId'] = $this->executeId;
  3154. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3155. }
  3156. /**
  3157. * 编辑培训班结算---更新开票
  3158. */
  3159. function receiptTrainInvoiceEdiDo() {
  3160. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3161. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3162. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3163. Doo::loadModel ( 'receipt' );
  3164. $receipt = new receipt ();
  3165. Doo::loadModel ( 'invoiceTraining' );
  3166. $invoiceTraining = new invoiceTraining ();
  3167. Doo::loadClass ( 'XDeode' );
  3168. $XDeode = new XDeode ( 5 );
  3169. $rid = $XDeode->decode ( $ridKey );
  3170. $itid = $XDeode->decode ( $itidKey );
  3171. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3172. die ( 'illegal request-idError' );
  3173. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3174. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3175. // 不合法的数据
  3176. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3177. die ( 'illegal request-receiptError' );
  3178. }
  3179. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3180. die ( 'illegal request-receipLoantError' );
  3181. }
  3182. // 培训班结算挂钩借款
  3183. $receipt = new receipt ();
  3184. $item = array (
  3185. 'rid' => $rid,
  3186. 'invoiceTrainId' => $itid
  3187. );
  3188. $receipt->setReceiptByCondition ( $item );
  3189. $invoiceTraining = new invoiceTraining ();
  3190. $item = array (
  3191. 'bindReceipt' => 1,
  3192. 'itid' => $itid
  3193. );
  3194. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3195. $XDeode = new XDeode ( 7 );
  3196. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3197. } else
  3198. die ( 'illegal request' );
  3199. }
  3200. /**
  3201. * 更新培训班结算 收款和取消收款
  3202. */
  3203. function receiptTrainReceivables() {
  3204. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3205. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3206. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3207. Doo::loadClass ( 'XDeode' );
  3208. $XDeode = new XDeode ( 5 );
  3209. $rid = $XDeode->decode ( $ridKey );
  3210. $iid = $XDeode->decode ( $iidKey );
  3211. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3212. die ( 'illegal request-iid' );
  3213. Doo::loadModel ( 'RIExtend' );
  3214. $RIExtend = new RIExtend ();
  3215. if ($doType == 'CONFIRM') {
  3216. $RIExtend->rid = $rid;
  3217. $RIExtend->iid = $iid;
  3218. $RIExtend->RIstatus = 1;
  3219. $RIExtend->insert ();
  3220. echo json_encode ( array (
  3221. 'status' => 1,
  3222. ) );
  3223. die ( );
  3224. } elseif ($doType == 'CANCEL') {
  3225. $RIExtend->delete ( array (
  3226. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3227. 'limit' => 1
  3228. ) );
  3229. echo json_encode ( array (
  3230. 'status' => 1,
  3231. ) );
  3232. die ( );
  3233. } else {
  3234. echo json_encode ( array (
  3235. 'status' => 2,
  3236. ) );
  3237. die ( );
  3238. }
  3239. }
  3240. /**
  3241. * 移除挂钩的培训班发票
  3242. */
  3243. function receiptTrainReceivablesDelDo() {
  3244. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3245. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3246. Doo::loadModel ( 'receipt' );
  3247. $receipt = new receipt ();
  3248. Doo::loadModel ( 'RIExtend' );
  3249. $RIExtend = new RIExtend ();
  3250. Doo::loadClass ( 'XDeode' );
  3251. $XDeode = new XDeode ( 5 );
  3252. $rid = $XDeode->decode ( $ridKey );
  3253. $itid = $XDeode->decode ( $itidKey );
  3254. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3255. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3256. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3257. die ( 'illegal request-status' );
  3258. }
  3259. $receipt = new receipt ();
  3260. $receipt->rid = $rid;
  3261. $receipt->invoiceTrainId = 0;
  3262. $receipt->update ();
  3263. Doo::loadModel ( 'invoiceTraining' );
  3264. $invoiceTraining = new invoiceTraining ();
  3265. $item = array (
  3266. 'bindReceipt' => 0,
  3267. 'itid' => $itid
  3268. );
  3269. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3270. $RIExtend->delete ( array (
  3271. 'where' => 'rid=' . $rid
  3272. ) );
  3273. $XDeode = new XDeode ( 7 );
  3274. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3275. } else
  3276. die ( 'illegal request-iid' );
  3277. }
  3278. /**
  3279. * 编辑培训班结算
  3280. */
  3281. function receiptTrainItemEdi() {
  3282. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3283. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3284. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3285. Doo::loadClass ( 'XDeode' );
  3286. $XDeode = new XDeode ( 7 );
  3287. $rid = $XDeode->decode ( $ridKey );
  3288. if (! is_numeric ( $rid ))
  3289. die ( 'illegal request' );
  3290. Doo::loadModel ( 'receipt' );
  3291. $receipt = new receipt ();
  3292. Doo::loadModel ( 'receiptTraining' );
  3293. $receiptTraining = new receiptTraining ();
  3294. Doo::loadModel ( 'RItem' );
  3295. $RItem = new RItem ();
  3296. Doo::loadModel ( 'accountItem' );
  3297. $accountItem = new accountItem ();
  3298. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3299. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3300. die ();
  3301. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3302. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3303. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3304. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3305. // if($value['name']=='税款'){
  3306. // unset($aiList[$key]);break;
  3307. // }
  3308. // }
  3309. //print_r($RItemList);
  3310. $data ['name'] = $name;
  3311. $data ['RItemList'] = $RItemList;
  3312. $data ['aiList'] = $aiList;
  3313. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3314. $data ['receiptDetail'] = $receiptDetail;
  3315. $data ['trainEdiType'] = "ITEM";
  3316. $data ['ridKey'] = $ridKey;
  3317. $data ['memu'] = "receipt";
  3318. $data ['staff'] = $this->staff;
  3319. $data ['receiptMemu'] = 'saeaBorad';
  3320. $data ['verifyId'] = $this->verifyId;
  3321. $data ['executeId'] = $this->executeId;
  3322. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3323. }
  3324. /**
  3325. * 添加支出项 需要修改 费用金额合计
  3326. */
  3327. function receiptTrainItemAddDo() {
  3328. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3329. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3330. // 支出项信息
  3331. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3332. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3333. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3334. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3335. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3336. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3337. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3338. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3339. Doo::loadClass ( 'XDeode' );
  3340. $XDeode = new XDeode ( 5 );
  3341. Doo::loadModel ( 'RItem' );
  3342. $RItem = new RItem ();
  3343. $rid = $XDeode->decode ( $ridKey );
  3344. $rtid= $XDeode->decode ( $rtidKey );
  3345. if (! is_numeric ( $rid )){
  3346. die ( 'illegal request' );
  3347. }
  3348. Doo::loadModel ( 'receiptDetail' );
  3349. $receiptDetail = new receiptDetail ();
  3350. Doo::loadModel ( 'receipt' );
  3351. $receipt = new receipt ();
  3352. Doo::loadModel ( 'receiptTraining' );
  3353. $receiptTraining = new receiptTraining ();
  3354. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3355. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3356. $order = array (
  3357. "\r\n",
  3358. "\n",
  3359. "\r"
  3360. );
  3361. $replace = '<br/>';
  3362. $describe = str_replace ( $order, $replace, $describe );
  3363. $itemData = array (
  3364. 'rid' => $rid,
  3365. 'item' => $item,
  3366. 'price' => $price,
  3367. 'date' => $date,
  3368. 'inputer' => $inputer,
  3369. 'describe' => $describe,
  3370. 'creater' => $this->staff['0']['username'],
  3371. 'createrId' => $this->staff['0']['sid'],
  3372. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3373. 'identifying'=>$identifyingTotal
  3374. );
  3375. if($payType=='company'){
  3376. $itemData += array (
  3377. 'payType' => 1
  3378. );
  3379. }
  3380. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3381. //更新支出项标识总数
  3382. $itemData = array (
  3383. 'rtid'=>$rtid,
  3384. 'identifyingTotal'=>$identifyingTotal
  3385. );
  3386. $receiptTraining->setReceiptTrainByCondition($itemData);
  3387. $XDeode = new XDeode ( 7 );
  3388. if($payType=='company'){
  3389. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3390. }else{
  3391. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3392. }
  3393. } else
  3394. die ( 'illegal request-dataError' );
  3395. }
  3396. /**
  3397. * 培训班结算-讲师
  3398. */
  3399. function receiptTrainLecturerEdi() {
  3400. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3401. Doo::loadClass ( 'XDeode' );
  3402. $XDeode = new XDeode ( 7 );
  3403. $rid = $XDeode->decode ( $ridKey );
  3404. if (! is_numeric ( $rid ))
  3405. die ( 'illegal request' );
  3406. Doo::loadModel ( 'receipt' );
  3407. $receipt = new receipt ();
  3408. Doo::loadModel ( 'receiptTraining' );
  3409. $receiptTraining = new receiptTraining ();
  3410. Doo::loadModel ( 'RILecturer' );
  3411. $RILecturer = new RILecturer ();
  3412. Doo::loadModel ( 'lecturer' );
  3413. $lecturer = new lecturer ();
  3414. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3415. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3416. die ();
  3417. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3418. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3419. $lecturerList = $lecturer->getLecturerAll ();
  3420. $INSIDEhtml = $OUTSIDEhtml = '';
  3421. foreach ( $lecturerList as $key => $value ) {
  3422. if ($value ['ltype'] == 'INSIDE') {
  3423. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3424. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3425. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3426. }
  3427. }
  3428. $data ['INSIDEhtml'] = $INSIDEhtml;
  3429. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3430. // print_r($RItemList);
  3431. $data ['RILecturerList'] = $RILecturerList;
  3432. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3433. $data ['receiptDetail'] = $receiptDetail;
  3434. $data ['trainEdiType'] = "LECTURER";
  3435. $data ['ridKey'] = $ridKey;
  3436. $data ['memu'] = "receipt";
  3437. $data ['staff'] = $this->staff;
  3438. $data ['receiptMemu'] = 'saeaBorad';
  3439. $data ['verifyId'] = $this->verifyId;
  3440. $data ['executeId'] = $this->executeId;
  3441. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3442. }
  3443. /**
  3444. * 添加讲师
  3445. */
  3446. function receiptTrainLecturerAddDo() {
  3447. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3448. // 支出项信息
  3449. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3450. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3451. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3452. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3453. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3454. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3455. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3456. Doo::loadClass ( 'XDeode' );
  3457. $XDeode = new XDeode ( 5 );
  3458. Doo::loadModel ( 'RILecturer' );
  3459. $RILecturer = new RILecturer ();
  3460. $rid = $XDeode->decode ( $ridKey );
  3461. if (! is_numeric ( $rid ))
  3462. die ( 'illegal request' );
  3463. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3464. die ( 'illegal request-taxationError' );
  3465. $RILecturer->rid = $rid;
  3466. $RILecturer->ltype = $ltype;
  3467. if ($ltype == 'OUTSIDE') {
  3468. if ($taxation == 'TAXATION') {
  3469. $RILecturer->taxation = 1;
  3470. } elseif ($taxation == 'NOTAXATION') {
  3471. $RILecturer->taxation = 0;
  3472. }
  3473. }
  3474. $RILecturer->lecturerName = $lecturerName;
  3475. $RILecturer->schoolDay = $schoolDay;
  3476. $RILecturer->price = $price;
  3477. $RILecturer->fees=$fees;
  3478. $RILecturer->insert ();
  3479. // 添加公司汇总
  3480. // 报销详情
  3481. Doo::loadModel ( 'receiptDetail' );
  3482. $receiptDetail = new receiptDetail ();
  3483. Doo::loadModel ( 'receipt' );
  3484. $receipt = new receipt ();
  3485. // 金额总计
  3486. $price = $price * $schoolDay;
  3487. $rInfo = $receipt->getReceiptByRid ( $rid );
  3488. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3489. if (empty ( $rdInfo )) {
  3490. $receiptDetail = new receiptDetail ();
  3491. $receiptDetail->staff = $rInfo ['staff'];
  3492. $receiptDetail->item = '讲课费';
  3493. $receiptDetail->itemCategory = '培训班费用';
  3494. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3495. $receiptDetail->date = date ( "Y-m-d" );
  3496. $receiptDetail->cid = $rInfo ['cid'];
  3497. $receiptDetail->rid = $rid;
  3498. $receiptDetail->status = 4;
  3499. $receiptDetail->insert ();
  3500. } else {
  3501. $receiptDetail = new receiptDetail ();
  3502. $rdInfo ['price'] += $fees;
  3503. $receiptDetail->price = $rdInfo ['price'];
  3504. $receiptDetail->update ( array (
  3505. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3506. ) );
  3507. }
  3508. $receipt = new receipt ();
  3509. $receipt->sum=$rInfo['sum']+$fees;
  3510. $receipt->update ( array (
  3511. 'where' => 'rid=' . $rid
  3512. ) );
  3513. $XDeode = new XDeode ( 7 );
  3514. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3515. } else
  3516. die ( 'illegal request' );
  3517. }
  3518. /**
  3519. * 移除讲师
  3520. */
  3521. function receiptTrainLecturerDelDo() {
  3522. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3523. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3524. Doo::loadModel ( 'receipt' );
  3525. $receipt = new receipt ();
  3526. Doo::loadModel ( 'RILecturer' );
  3527. $RILecturer = new RILecturer ();
  3528. Doo::loadClass ( 'XDeode' );
  3529. $XDeode = new XDeode ( 5 );
  3530. $rid = $XDeode->decode ( $ridKey );
  3531. $rlid = $XDeode->decode ( $rlidKey );
  3532. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3533. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3534. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3535. die ( 'illegal request-status' );
  3536. }
  3537. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3538. if (empty($detail)){
  3539. die ( 'illegal request-data' );
  3540. }
  3541. $RILecturer->delete ( array (
  3542. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3543. ) );
  3544. //更新费用合计金额
  3545. $rInfo = $receipt->getReceiptByRid ( $rid );
  3546. $receipt = new receipt ();
  3547. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3548. $receipt->update ( array (
  3549. 'where' => 'rid=' . $rid
  3550. ) );
  3551. Doo::loadModel ( 'receiptDetail' );
  3552. $receiptDetail = new receiptDetail ();
  3553. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3554. $receiptDetail = new receiptDetail ();
  3555. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3556. $receiptDetail->price = $rdInfo ['price'];
  3557. $receiptDetail->update ( array (
  3558. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3559. ) );
  3560. $XDeode = new XDeode ( 7 );
  3561. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3562. } else
  3563. die ( 'illegal request-iid' );
  3564. }
  3565. /**
  3566. * 培训班提交审批
  3567. */
  3568. function receiptTrainDo() {
  3569. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3570. Doo::loadClass ( 'XDeode' );
  3571. $XDeode = new XDeode ( 7 );
  3572. $rid = $XDeode->decode ( $ridKey );
  3573. Doo::loadModel ( 'receipt' );
  3574. $receipt = new receipt ();
  3575. Doo::loadModel ( 'receiptDetail' );
  3576. $receiptDetail = new receiptDetail ();
  3577. Doo::loadModel ( 'statistics' );
  3578. $statistics = new statistics ();
  3579. Doo::loadModel ( "verify" );
  3580. $verify = new verify ();
  3581. // 审批状态的判定
  3582. $receiptDetailList = $receipt->getOne ( array (
  3583. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3584. 'asArray' => true
  3585. ) );
  3586. if (empty ( $receiptDetailList ))
  3587. return "/saeaBorad";
  3588. $verifyDetail = $verify->getOne ( array (
  3589. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3590. 'asArray' => true
  3591. ) );
  3592. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3593. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3594. $nowStaff = "";
  3595. $nowStaffList = array ();
  3596. if ($verifyDetail [0] [1] == 'ROLE') {
  3597. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3598. foreach ( $vStaffString as $key => $value ) {
  3599. $staffK = explode ( "_", $value );
  3600. array_push ( $nowStaffList, $staffK [0] );
  3601. }
  3602. $nowStaff = implode ( ',', $nowStaffList );
  3603. } else {
  3604. $nowStaff = $verifyDetail [0] [0];
  3605. }
  3606. $receipt->nowStaff = $nowStaff;
  3607. }
  3608. // echo $nowStaff;
  3609. // print_r($verifyDetail);die;
  3610. $receipt->rid = $receiptDetailList ['rid'];
  3611. $receipt->date = date ( "Y-m-d" );
  3612. $receipt->status = 2;
  3613. $receipt->update ();
  3614. $receiptDetail->status = 2;
  3615. $receiptDetail->update ( array (
  3616. 'where' => 'rid=' . $receiptDetailList ['rid']
  3617. ) );
  3618. Doo::loadModel ( "receiptLog" );
  3619. $receiptLog = new receiptLog ();
  3620. Doo::loadModel ( "verify" );
  3621. $verify = new verify ();
  3622. $vr = $verify->getOne ( array (
  3623. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3624. 'asArray' => true
  3625. ) );
  3626. $jd = json_decode ( $vr ['staff'] );
  3627. $roleId = 0;
  3628. foreach ( $jd as $key => $value ) {
  3629. if ($value [1] == 'ROLE') {
  3630. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3631. if ($pos !== false) {
  3632. $roleId = $value [0];
  3633. }
  3634. }
  3635. }
  3636. // 审批日志
  3637. // echo $roleId;die;
  3638. if (! empty ( $roleId )) {
  3639. Doo::loadModel ( "role" );
  3640. $role = new role ();
  3641. $roleInfo = $role->getOne ( array (
  3642. 'where' => 'rid=' . $roleId,
  3643. 'asArray' => true
  3644. ) );
  3645. // $receiptLog->rolename = $roleInfo ['name'];
  3646. }
  3647. $receiptLog->username = $this->staff [0] ['username'];
  3648. $receiptLog->uid = $this->staff [0] ['sid'];
  3649. $receiptLog->date = date ( "Y-m-d" );
  3650. $receiptLog->opinion = '提交审批';
  3651. $receiptLog->img = $this->staff [0] ['avatar'];
  3652. $receiptLog->status = 2;
  3653. $receiptLog->rid = $rid;
  3654. $receiptLog->insert ();
  3655. // 写入列表项
  3656. Doo::loadModel ( 'accountItem' );
  3657. $accountItem = new accountItem ();
  3658. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3659. // 项目金额合计
  3660. Doo::loadModel ( 'RItem' );
  3661. $RItem = new RItem ();
  3662. // 讲师获得
  3663. Doo::loadModel ( 'RILecturer' );
  3664. $RILecturer = new RILecturer ();
  3665. $RItemList = $RItem->getRItemByRid ( $rid );
  3666. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3667. // 支出项金额详情
  3668. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3669. // print_r($aItem);
  3670. // print_r($aiData);
  3671. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3672. $ag = $tr = $ta = $ot = 0;
  3673. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3674. foreach ( $aItem as $key => $value ) {
  3675. if ($value ['category'] == $this->TRAIN) {
  3676. foreach ( $aiData ['dataList'] as $k => $v ) {
  3677. if ($value ['name'] == $v ['name']) {
  3678. array_push ( $accountJson [$this->TRAIN], array (
  3679. 'aid' => $value ['aid'],
  3680. 'name' => $value ['name'],
  3681. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3682. ) );
  3683. $sum += $v ['price'];
  3684. $trainSum += $v ['price'];
  3685. unset ( $aiData ['dataList'] [$k] );
  3686. break;
  3687. }
  3688. }
  3689. }
  3690. }
  3691. $accountJson ['cSum'] = array (
  3692. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3693. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3694. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3695. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3696. );
  3697. // 报销单
  3698. $receipt = new receipt ();
  3699. $receipt->accountItem = json_encode ( $accountJson );
  3700. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3701. $receipt->update ( array (
  3702. 'where' => 'rid=' . $rid
  3703. ) );
  3704. // print_r($accountJson);
  3705. // statistics item 统计写入
  3706. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3707. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3708. $accountItem = $accountJson;
  3709. $stat = $statistics->getOne ( array (
  3710. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3711. 'asArray' => true
  3712. ) );
  3713. if (empty ( $stat )) {
  3714. $statistics->date = date ( "Y-m-d" );
  3715. $statistics->cid = $this->staff [0] ['cid'];
  3716. $statistics->staff = $this->staff [0] ['sid'];
  3717. $statistics->agPrice = 0;
  3718. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3719. $statistics->insert ();
  3720. } else {
  3721. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3722. $statistics->update ( array (
  3723. 'where' => 'sid=' . $stat ['sid']
  3724. ) );
  3725. }
  3726. return "/saeaBorad";
  3727. }
  3728. function confirmation() {
  3729. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3730. Doo::loadModel ( 'receipt' );
  3731. Doo::loadModel ( 'receiptDetail' );
  3732. $receipt = new receipt ();
  3733. $receiptDetail = new receiptDetail ();
  3734. Doo::loadModel ( 'statistics' );
  3735. Doo::loadModel ( 'itemStatistics' );
  3736. $statistics = new statistics ();
  3737. $itemStatistics = new itemStatistics ();
  3738. Doo::loadModel ( "verify" );
  3739. $verify = new verify ();
  3740. $receiptDetailList = $receipt->getOne ( array (
  3741. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3742. 'asArray' => true
  3743. ) );
  3744. if (empty ( $receiptDetailList ))
  3745. return "/saeaBorad";
  3746. $verifyDetail = $verify->getOne ( array (
  3747. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3748. 'asArray' => true
  3749. ) );
  3750. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3751. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3752. $nowStaff = "";
  3753. $nowStaffList = array ();
  3754. if ($verifyDetail [0] [1] == 'ROLE') {
  3755. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3756. foreach ( $vStaffString as $key => $value ) {
  3757. $staffK = explode ( "_", $value );
  3758. array_push ( $nowStaffList, $staffK [0] );
  3759. }
  3760. $nowStaff = implode ( ',', $nowStaffList );
  3761. } else {
  3762. $nowStaff = $verifyDetail [0] [0];
  3763. }
  3764. $receipt->nowStaff = $nowStaff;
  3765. }
  3766. // echo $nowStaff;
  3767. // print_r($verifyDetail);die;
  3768. $receipt->rid = $receiptDetailList ['rid'];
  3769. $receipt->status = 2;
  3770. $receipt->update ();
  3771. // 操作日志
  3772. Doo::loadModel ( "receiptLog" );
  3773. $receiptLog = new receiptLog ();
  3774. $verify = new verify ();
  3775. $receiptInfo = $receipt->getOne ( array (
  3776. 'where' => 'rid=' . $rid,
  3777. 'asArray' => true
  3778. ) );
  3779. $vr = $verify->getOne ( array (
  3780. 'where' => 'vid=' . $receiptInfo ['verify'],
  3781. 'asArray' => true
  3782. ) );
  3783. $jd = json_decode ( $vr ['staff'] );
  3784. $roleId = 0;
  3785. foreach ( $jd as $key => $value ) {
  3786. if ($value [1] == 'ROLE') {
  3787. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3788. if ($pos !== false) {
  3789. $roleId = $value [0];
  3790. }
  3791. }
  3792. }
  3793. // 审批日志
  3794. // echo $roleId;die;
  3795. if (! empty ( $roleId )) {
  3796. Doo::loadModel ( "role" );
  3797. $role = new role ();
  3798. $roleInfo = $role->getOne ( array (
  3799. 'where' => 'rid=' . $roleId,
  3800. 'asArray' => true
  3801. ) );
  3802. // $receiptLog->rolename = $roleInfo ['name'];
  3803. }
  3804. $receiptLog->username = $this->staff [0] ['username'];
  3805. $receiptLog->uid = $this->staff [0] ['sid'];
  3806. $receiptLog->date = date ( "Y-m-d" );
  3807. $receiptLog->opinion = '提交审批';
  3808. $receiptLog->img = $this->staff [0] ['avatar'];
  3809. $receiptLog->status = 2;
  3810. $receiptLog->rid = $rid;
  3811. $receiptLog->insert ();
  3812. return "/expenses";
  3813. }
  3814. function expenses() {
  3815. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3816. if (empty ( $item ))
  3817. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3818. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3819. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3820. Doo::loadClass ( 'XDeode' );
  3821. $XDeode = new XDeode ( 7 );
  3822. Doo::loadModel ( 'receipt' );
  3823. $receipt = new receipt ();
  3824. Doo::loadModel ( 'L_category' );
  3825. $Lcategory = new L_category ();
  3826. Doo::loadModel ( 'verify' );
  3827. Doo::loadModel ( 'statistics' );
  3828. $statistics = new statistics ();
  3829. $verify = new verify ();
  3830. Doo::loadModel ( 'staff' );
  3831. $staff = new staff ();
  3832. $condition = "";
  3833. if ($item == "expenses")
  3834. $condition = " and Rtype=1 ";
  3835. elseif ($item == "receipts")
  3836. $condition = " and Rtype=0 ";
  3837. elseif ($item == "remits")
  3838. $condition = " and Rtype=2 ";
  3839. elseif ($item == "train")
  3840. $condition = " and Rtype=3 ";
  3841. $dateCondition = " and Year(date) =" . $year;
  3842. if (! empty ( $moth )) {
  3843. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3844. $stList = $statistics->getOne ( array (
  3845. 'select' => 'rePrice ,agPrice',
  3846. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3847. 'asArray' => true
  3848. ) );
  3849. } else
  3850. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3851. if (empty ( $stList ))
  3852. $stList = array (
  3853. 'rePrice' => 0,
  3854. 'agPrice' => 0
  3855. );
  3856. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3857. if (! isset ( $noPassSum ['sum'] ))
  3858. $noPassSum ['sum'] = 0;
  3859. $data ['stList'] = array (
  3860. 'rePrice' => $stList ['rePrice'],
  3861. 'agPrice' => $stList ['agPrice'],
  3862. 'skPrice' => ($noPassSum ['sum'])
  3863. );
  3864. $receiptList = $receipt->find ( array (
  3865. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3866. 'desc' => 'rid',
  3867. 'asArray' => true
  3868. ) );
  3869. $Locate = 0;
  3870. $roleId = 0;
  3871. $button = 0;
  3872. foreach ( $receiptList as $key => $value ) {
  3873. $receiptList[$key]['balance']='';
  3874. if($value['Rtype']==1){
  3875. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3876. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3877. }elseif($value['Rtype']==3){
  3878. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3879. $receiptList[$key]['payment']=$payment;
  3880. $receiptList[$key]['paymentABS']=abs($payment);
  3881. }
  3882. $receiptList [$key] ['Locate'] = $Locate;
  3883. $Locate ++;
  3884. $receiptList [$key] ['reviseDetail'] = array ();
  3885. if (! empty ( $value ['reviseDetail'] ))
  3886. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3887. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3888. $categoryDetil = $Lcategory->getOne ( array (
  3889. 'where' => 'cid=' . $value ['cid'],
  3890. 'asArray' => true
  3891. ) );
  3892. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3893. // 检测编辑状态
  3894. $verifyList = $verify->getOne ( array (
  3895. 'where' => 'vid=' . $value ['verify'],
  3896. 'asArray' => true
  3897. ) );
  3898. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3899. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3900. Doo::loadModel ( 'role' );
  3901. $role = new role ();
  3902. $flag = true;
  3903. $roleKey = 0;
  3904. $endStaffArray = array ();
  3905. $roleArrayCopy = array ();
  3906. foreach ( $verifyList as $k => $v ) {
  3907. // init verifyStaff
  3908. if ($v [1] == 'ROLE') {
  3909. if (! empty ( $verifyStaff )) {
  3910. $endStaffArray = end ( $verifyStaff );
  3911. // if ($v[0]==$endStaffArray['nextStaff']){
  3912. // $roleId=$v[0];
  3913. // }
  3914. }
  3915. $roleVerify = json_decode ( $v [3], true );
  3916. $roleKey = $k;
  3917. $roleArray = array ();
  3918. $rolename = $role->getOne ( array (
  3919. 'where' => 'rid=' . $v [0],
  3920. 'asArray' => true
  3921. ) );
  3922. foreach ( $roleVerify as $o => $p ) {
  3923. $staffID = explode ( '_', $p );
  3924. $staffInfo = $staff->getOne ( array (
  3925. 'where' => 'sid=' . $staffID [0],
  3926. 'asArray' => true
  3927. ) );
  3928. // print_r($staffID);
  3929. $exp = array (
  3930. 0 => $staffInfo ['sid'],
  3931. 1 => $staffID [1],
  3932. 2 => $staffInfo ['avatar'],
  3933. 'date' => '',
  3934. 'date' => '',
  3935. 'opinion' => '',
  3936. 'status' => '',
  3937. 'rolename' => $rolename ['name']
  3938. );
  3939. array_push ( $roleArray, $exp );
  3940. }
  3941. $roleArrayCopy [$v [0]] = $roleArray;
  3942. // $verifyList[$k]['roleArray']=$roleArray;
  3943. }
  3944. $verifyList [$k] ['date'] = "";
  3945. $verifyList [$k] ['opinion'] = "";
  3946. $verifyList [$k] ['status'] = "";
  3947. if (empty ( $verifyStaff )) {
  3948. $verifyList [$k] ['date'] = "";
  3949. $verifyList [$k] ['opinion'] = "";
  3950. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3951. $verifyList [$k] ['status'] = 4;
  3952. $flag = false;
  3953. }
  3954. } else {
  3955. foreach ( $verifyStaff as $m => $u ) {
  3956. if ($v [0] == $m) {
  3957. $verifyList [$k] ['date'] = $u ['date'];
  3958. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3959. $verifyList [$k] ['status'] = $u ['status'];
  3960. $flag = false;
  3961. break;
  3962. }
  3963. }
  3964. $endStaffArray = end ( $verifyStaff );
  3965. if (isset ( $endStaffArray ['ROLE'] )) {
  3966. } else {
  3967. // $endKey=key($verifyStaff);
  3968. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3969. // $button=4;
  3970. // $verifyList[$k]['status']=4;
  3971. // }
  3972. }
  3973. }
  3974. }
  3975. $rolename ['name'] = '';
  3976. if (! empty ( $roleId )) {
  3977. Doo::loadModel ( 'role' );
  3978. $role = new role ();
  3979. $rolename = $role->getOne ( array (
  3980. 'where' => 'rid=' . $roleId,
  3981. 'asArray' => true
  3982. ) );
  3983. }
  3984. if (! empty ( $verifyStaff ))
  3985. $endStaffArray = end ( $verifyStaff );
  3986. $KOP = false;
  3987. foreach ( $roleArrayCopy as $P => $A ) {
  3988. foreach ( $A as $MKI => $AVL ) {
  3989. if (! empty ( $verifyStaff )) {
  3990. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3991. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3992. $button = 4;
  3993. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3994. }
  3995. foreach ( $verifyStaff as $m => $u ) {
  3996. $AVLFK = $AVL [0] . '_R';
  3997. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3998. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3999. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4000. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4001. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4002. break;
  4003. }
  4004. }
  4005. } else {
  4006. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4007. $button = 4;
  4008. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4009. }
  4010. }
  4011. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4012. $KOP = true;
  4013. }
  4014. }
  4015. foreach ( $roleArrayCopy as $k => $v ) {
  4016. foreach ( $verifyList as $m => $n ) {
  4017. if ($n [0] == $k) {
  4018. array_splice ( $verifyList, $m, 1, $v );
  4019. }
  4020. }
  4021. }
  4022. $receiptList [$key] ['verifyList'] = $verifyList;
  4023. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4024. 'where' => 'sid=' . $value ['staff'],
  4025. 'asArray' => true
  4026. ) );
  4027. $receiptList [$key] ['button'] = $button;
  4028. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4029. }
  4030. // print_r($receiptList);die;
  4031. $mothHtml = "";
  4032. for($i = 1; $i <= 12; $i ++) {
  4033. if ($moth == $i)
  4034. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4035. else
  4036. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4037. }
  4038. $dateHtml = "";
  4039. $now = date ( "Y" );
  4040. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4041. if ($YEARD <= $now) {
  4042. $dateHtml .= '<option ';
  4043. if ($year == $YEARD) {
  4044. $dateHtml .= 'selected ';
  4045. }
  4046. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4047. }
  4048. }
  4049. $data ['dateHtml'] = $dateHtml;
  4050. $data ['mothHtml'] = $mothHtml;
  4051. $data ['receiptList'] = $receiptList;
  4052. $data ['memu'] = "receipt";
  4053. $data ['staff'] = $this->staff;
  4054. $data ['receiptMemu'] = 'expenses';
  4055. $data ['verifyId'] = $this->verifyId;
  4056. $data ['executeId'] = $this->executeId;
  4057. $data ['item'] = $item;
  4058. $data ['year'] = $year;
  4059. $this->render ( "/admin/expenses", $data );
  4060. }
  4061. function expensesCollect() {
  4062. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4063. Doo::loadModel ( 'receipt' );
  4064. $receipt = new receipt ();
  4065. Doo::loadModel ( 'L_category' );
  4066. $Lcategory = new L_category ();
  4067. Doo::loadModel ( 'verify' );
  4068. Doo::loadModel ( 'statistics' );
  4069. $statistics = new statistics ();
  4070. $verify = new verify ();
  4071. Doo::loadModel ( 'staff' );
  4072. $staff = new staff ();
  4073. Doo::loadModel ( 'loanReceipt' );
  4074. $loanReceipt = new loanReceipt ();
  4075. $receiptList = $receipt->find ( array (//去掉
  4076. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4077. 'desc' => 'rid',
  4078. 'asArray' => true
  4079. ) );
  4080. $loanList = $loanReceipt->find ( array (
  4081. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4082. 'desc' => 'rid',
  4083. 'asArray' => true
  4084. ) );
  4085. /*
  4086. * $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;
  4087. */
  4088. $data ['explanation'] = '';
  4089. if (! empty ( $loanList ))
  4090. $data ['explanation'] = $loanList [0] ['explanation'];
  4091. $Locate = 0;
  4092. $roleId = 0;
  4093. $button = 0;
  4094. foreach ( $receiptList as $key => $value ) {
  4095. $receiptList [$key] ['Locate'] = $Locate;
  4096. $Locate ++;
  4097. $receiptList [$key] ['reviseDetail'] = array ();
  4098. if (! empty ( $value ['reviseDetail'] ))
  4099. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4100. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4101. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4102. $categoryDetil = $Lcategory->getOne ( array (
  4103. 'where' => 'cid=' . $value ['cid'],
  4104. 'asArray' => true
  4105. ) );
  4106. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4107. // 检测编辑状态
  4108. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4109. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4110. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4111. else
  4112. $verifyList ['staff'] = $value ['verifyBreakup'];
  4113. } else
  4114. $verifyList = $verify->getOne ( array (
  4115. 'where' => 'vid=' . $value ['verify'],
  4116. 'asArray' => true
  4117. ) );
  4118. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4119. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4120. Doo::loadModel ( 'role' );
  4121. $role = new role ();
  4122. $flag = true;
  4123. $roleKey = 0;
  4124. $endStaffArray = array ();
  4125. $roleArrayCopy = array ();
  4126. foreach ( $verifyList as $k => $v ) {
  4127. // init verifyStaff
  4128. if ($v [1] == 'ROLE') {
  4129. if (! empty ( $verifyStaff )) {
  4130. $endStaffArray = end ( $verifyStaff );
  4131. // if ($v[0]==$endStaffArray['nextStaff']){
  4132. // $roleId=$v[0];
  4133. // }
  4134. }
  4135. $roleVerify = json_decode ( $v [3], true );
  4136. $roleKey = $k;
  4137. $roleArray = array ();
  4138. $rolename = $role->getOne ( array (
  4139. 'where' => 'rid=' . $v [0],
  4140. 'asArray' => true
  4141. ) );
  4142. foreach ( $roleVerify as $o => $p ) {
  4143. $staffID = explode ( '_', $p );
  4144. $staffInfo = $staff->getOne ( array (
  4145. 'where' => 'sid=' . $staffID [0],
  4146. 'asArray' => true
  4147. ) );
  4148. // print_r($staffID);
  4149. $exp = array (
  4150. 0 => $staffInfo ['sid'],
  4151. 1 => $staffID [1],
  4152. 2 => $staffInfo ['avatar'],
  4153. 'date' => '',
  4154. 'date' => '',
  4155. 'opinion' => '',
  4156. 'status' => '',
  4157. 'rolename' => $rolename ['name']
  4158. );
  4159. array_push ( $roleArray, $exp );
  4160. }
  4161. $roleArrayCopy [$v [0]] = $roleArray;
  4162. // $verifyList[$k]['roleArray']=$roleArray;
  4163. }
  4164. $verifyList [$k] ['date'] = "";
  4165. $verifyList [$k] ['opinion'] = "";
  4166. $verifyList [$k] ['status'] = "";
  4167. if (empty ( $verifyStaff )) {
  4168. $verifyList [$k] ['date'] = "";
  4169. $verifyList [$k] ['opinion'] = "";
  4170. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4171. $verifyList [$k] ['status'] = 4;
  4172. $flag = false;
  4173. }
  4174. } else {
  4175. foreach ( $verifyStaff as $m => $u ) {
  4176. if ($v [0] == $m) {
  4177. $verifyList [$k] ['date'] = $u ['date'];
  4178. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4179. $verifyList [$k] ['status'] = $u ['status'];
  4180. $flag = false;
  4181. break;
  4182. }
  4183. }
  4184. $endStaffArray = end ( $verifyStaff );
  4185. if (isset ( $endStaffArray ['ROLE'] )) {
  4186. } else {
  4187. // $endKey=key($verifyStaff);
  4188. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4189. // $button=4;
  4190. // $verifyList[$k]['status']=4;
  4191. // }
  4192. }
  4193. }
  4194. }
  4195. $rolename ['name'] = '';
  4196. if (! empty ( $roleId )) {
  4197. Doo::loadModel ( 'role' );
  4198. $role = new role ();
  4199. $rolename = $role->getOne ( array (
  4200. 'where' => 'rid=' . $roleId,
  4201. 'asArray' => true
  4202. ) );
  4203. }
  4204. if (! empty ( $verifyStaff ))
  4205. $endStaffArray = end ( $verifyStaff );
  4206. $KOP = false;
  4207. foreach ( $roleArrayCopy as $P => $A ) {
  4208. foreach ( $A as $MKI => $AVL ) {
  4209. if (! empty ( $verifyStaff )) {
  4210. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4211. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4212. $button = 4;
  4213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4214. }
  4215. foreach ( $verifyStaff as $m => $u ) {
  4216. $AVLFK = $AVL [0] . '_R';
  4217. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4218. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4219. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4220. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4221. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4222. break;
  4223. }
  4224. }
  4225. } else {
  4226. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4227. $button = 4;
  4228. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4229. }
  4230. }
  4231. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4232. $KOP = true;
  4233. }
  4234. }
  4235. foreach ( $roleArrayCopy as $k => $v ) {
  4236. foreach ( $verifyList as $m => $n ) {
  4237. if ($n [0] == $k) {
  4238. array_splice ( $verifyList, $m, 1, $v );
  4239. }
  4240. }
  4241. }
  4242. // 费用执行人相关数据
  4243. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4244. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4245. foreach ( $executeCopy as $k => $v ) {
  4246. $executeCopy [$k] ['date'] = '';
  4247. $executeCopy [$k] ['opinion'] = '';
  4248. $executeCopy [$k] ['status'] = '';
  4249. if (! empty ( $executeStaff ))
  4250. foreach ( $executeStaff as $m => $u ) {
  4251. if ($v [0] == $m) {
  4252. $executeCopy [$k] ['date'] = $u ['date'];
  4253. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4254. $executeCopy [$k] ['status'] = $u ['status'];
  4255. break;
  4256. }
  4257. }
  4258. }
  4259. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4260. $receiptList [$key] ['verifyList'] = $verifyList;
  4261. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4262. 'where' => 'sid=' . $value ['staff'],
  4263. 'asArray' => true
  4264. ) );
  4265. $receiptList [$key] ['button'] = $button;
  4266. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4267. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4268. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4269. $receiptList [$key] ['relust'] = $relust;
  4270. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4271. }
  4272. Doo::loadModel ( 'enclosur' );
  4273. $enclosur = new enclosur ();
  4274. $enclosurList = $enclosur->find ( array (
  4275. 'where' => 'rid=' . $rid,
  4276. 'asArray' => true
  4277. ) );
  4278. $enclosurHtml = '';
  4279. foreach ( $enclosurList as $value ) {
  4280. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4281. }
  4282. $data ['enclosurHtml'] = $enclosurHtml;
  4283. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4284. $data ['receiptList'] = $receiptList;
  4285. $data ['memu'] = "receipt";
  4286. $data ['staff'] = $this->staff;
  4287. $data ['receiptMemu'] = 'expenses';
  4288. $data ['verifyId'] = $this->verifyId;
  4289. $data ['executeId'] = $this->executeId;
  4290. if($receiptList[0]['receiptClass']==2){
  4291. $this->render ( "/receipt/feeTraveDetail", $data );
  4292. //$this->render ( "/admin/expensesCollect", $data );
  4293. }else{
  4294. $this->render ( "/admin/expensesCollect", $data );
  4295. }
  4296. }
  4297. function approvalExpenses() {
  4298. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4299. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4300. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4301. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4302. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4303. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4304. // echo $rdate;
  4305. if (empty ( $status ))
  4306. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4307. $page_size = 8;
  4308. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4309. $vidList = array ();
  4310. $button = 0;
  4311. Doo::loadModel ( 'verify' );
  4312. $verify = new verify ();
  4313. Doo::loadModel ( 'receipt' );
  4314. $receipt = new receipt ();
  4315. Doo::loadModel ( 'staff' );
  4316. $staff = new staff ();
  4317. Doo::loadModel ( 'L_category' );
  4318. $Lcategory = new L_category ();
  4319. // user verify ID
  4320. $verifyDetail = $verify->find ( array (
  4321. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4322. 'asArray' => true
  4323. ) );
  4324. foreach ( $verifyDetail as $key => $value ) {
  4325. array_push ( $vidList, $value ['vid'] );
  4326. }
  4327. $vid = implode ( ",", $vidList );
  4328. if (empty ( $verifyDetail ))
  4329. $vid = 0;
  4330. // if ($status==0)
  4331. // $dateCondition="";
  4332. // else
  4333. $dateCondition = " ";
  4334. // if (! empty ( $month ))
  4335. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4336. if ($status == 'done' || $status == 'termination') {
  4337. if (! empty ( $year )) {
  4338. $dateCondition = " and Year(pastDate) =" . $year;
  4339. if (! empty ( $month ))
  4340. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4341. }
  4342. } elseif ($status == 'finish') {
  4343. if (! empty ( $year )) {
  4344. $dateCondition = " and Year(pastDate) =" . $year;
  4345. if (! empty ( $month ))
  4346. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4347. }
  4348. }
  4349. // date ( 'Y-m' )
  4350. // if (! empty ( $rdate ) && $status == 'done')
  4351. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4352. // elseif (! empty ( $rdate ))
  4353. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4354. $categoryList = $Lcategory->find ( array (
  4355. 'asArray' => true
  4356. ) );
  4357. $staffList = $staff->find ( array (
  4358. 'where' => 'cid=' . $cid,
  4359. 'asArray' => true
  4360. ) );
  4361. $cateCondition = "";
  4362. $staffCondition = "";
  4363. $approvalCondition = "";
  4364. if (! empty ( $cid )) {
  4365. $cateCondition = ' and cid=' . $cid;
  4366. }
  4367. if (! empty ( $sid )) {
  4368. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4369. $cateCondition = "";
  4370. }
  4371. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4372. if ($status == 'pendApproval') {
  4373. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4374. }
  4375. if ($status == 'ongoing') {
  4376. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4377. }
  4378. if ($status == 'done') {
  4379. $approvalCondition = ' and (status=8 or status=9 ) ';
  4380. }
  4381. if ($status == 'termination') {
  4382. $approvalCondition = " and status=3";
  4383. }
  4384. if ($status == 'finish') {
  4385. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4386. }
  4387. $pageinfo ['page'] = array (
  4388. 'previous' => ''
  4389. );
  4390. if(!empty($receiptOrder)){
  4391. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4392. $receiptList = $receipt->find ( array ( // $dateCondition
  4393. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4394. 'desc' => 'rid',
  4395. 'asArray' => true
  4396. ) );
  4397. }else{
  4398. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4399. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4400. $receiptList = $receipt->find ( array ( // $dateCondition.
  4401. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4402. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4403. 'desc' => 'rid',
  4404. 'asArray' => true
  4405. ) );
  4406. } else {
  4407. $receiptList = $receipt->find ( array ( // $dateCondition
  4408. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4409. 'desc' => 'rid',
  4410. 'asArray' => true
  4411. ) );
  4412. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4413. }
  4414. }
  4415. $rLRes = $receipt->find ( array (
  4416. '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 . ')',
  4417. 'desc' => 'rid',
  4418. 'asArray' => true
  4419. ) );
  4420. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4421. // print_r($receiptList);
  4422. Doo::loadClass ( 'XDeode' );
  4423. $XDeode = new XDeode ( 7 );
  4424. $Locate = 0;
  4425. //
  4426. $reportList = $reportCateList = array ();
  4427. foreach ( $receiptList as $key => $value ) {
  4428. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4429. $receiptList [$key] ['Locate'] = $Locate;
  4430. $Locate ++;
  4431. $receiptList [$key] ['reviseDetail'] = array ();
  4432. if (! empty ( $value ['reviseDetail'] ))
  4433. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4434. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4435. $categoryDetil = $Lcategory->getOne ( array (
  4436. 'where' => 'cid=' . $value ['cid'],
  4437. 'asArray' => true
  4438. ) );
  4439. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4440. $verifyList = $verify->getOne ( array (
  4441. 'where' => 'vid=' . $value ['verify'],
  4442. 'asArray' => true
  4443. ) );
  4444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4446. foreach ( $verifyList as $k => $v ) {
  4447. // init verifyStaff
  4448. $verifyList [$k] ['date'] = "";
  4449. $verifyList [$k] ['opinion'] = "";
  4450. $verifyList [$k] ['status'] = "";
  4451. if (empty ( $verifyStaff )) {
  4452. $verifyList [$k] ['date'] = "";
  4453. $verifyList [$k] ['opinion'] = "";
  4454. if ($v [0] == $this->staff [0] ['sid']) {
  4455. $verifyList [$k] ['status'] = 4;
  4456. $button = 4;
  4457. }
  4458. } else {
  4459. $flag = true;
  4460. foreach ( $verifyStaff as $m => $u ) {
  4461. if ($v [0] == $m) {
  4462. $verifyList [$k] ['date'] = $u ['date'];
  4463. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4464. $verifyList [$k] ['status'] = $u ['status'];
  4465. $flag = false;
  4466. break;
  4467. }
  4468. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4469. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4470. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4471. }
  4472. if ($flag) { // 检测可编辑
  4473. if ($v [0] == $this->staff [0] ['sid']) {
  4474. $verifyList [$k] ['status'] = 4;
  4475. $button = 4;
  4476. }
  4477. }
  4478. }
  4479. }
  4480. $receiptList [$key] ['verifyList'] = $verifyList;
  4481. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4482. 'where' => 'sid=' . $value ['staff'],
  4483. 'asArray' => true
  4484. ) );
  4485. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4486. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4487. $receiptList [$key] ['button'] = $button;
  4488. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4489. //获得培训班结算RID 借款费用--已经锁定
  4490. if($value['status']==10){
  4491. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4492. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4493. }
  4494. }
  4495. $reportList = array_unique ( $reportList );
  4496. $reportHtml = '';
  4497. foreach ( $reportList as $key => $value ) {
  4498. $v = explode ( "-", $value );
  4499. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4500. }
  4501. // print_r($reportList)
  4502. $data ['reportHtml'] = $reportHtml;
  4503. $reportCateList = array_unique ( $reportCateList );
  4504. $reportCateHtml = '';
  4505. foreach ( $reportCateList as $key => $value ) {
  4506. $v = explode ( "-", $value );
  4507. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4508. }
  4509. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4510. $data ['reportCateHtml'] = $reportCateHtml;
  4511. // print_r($receiptList);die;
  4512. // $data['verifyDetail']=$verifyDetail;
  4513. $mothHtml = "";
  4514. for($i = 1; $i <= 12; $i ++) {
  4515. if ($month == $i)
  4516. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4517. else
  4518. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4519. }
  4520. $data ['mothHtml'] = $mothHtml;
  4521. $dateHtml = "";
  4522. $now = date ( "Y" );
  4523. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4524. if ($YEARD <= $now) {
  4525. $dateHtml .= '<option ';
  4526. if ($year == $YEARD) {
  4527. $dateHtml .= 'selected ';
  4528. }
  4529. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4530. }
  4531. }
  4532. $data ['dateHtml'] = $dateHtml;
  4533. $data ['page'] = $pageinfo;
  4534. $data ['receiptList'] = $receiptList;
  4535. $data ['receiptApprovalCount'] = count ( $rLRes );
  4536. $data ['status'] = $status;
  4537. $data ['year'] = $year;
  4538. $data ['month'] = $month;
  4539. $data ['categoryList'] = $categoryList;
  4540. $data ['staffList'] = $staffList;
  4541. $data ['cid'] = $cid;
  4542. $data ['sid'] = $sid;
  4543. // print_r($receiptList);
  4544. $data['receiptOrder']=$receiptOrder;
  4545. $data ['memu'] = "receipt";
  4546. $data ['staff'] = $this->staff;
  4547. $data ['receiptMemu'] = 'approvalExpenses';
  4548. $data ['verifyId'] = $this->verifyId;
  4549. $data ['executeId'] = $this->executeId;
  4550. $this->render ( "/admin/approvalExpenses", $data );
  4551. }
  4552. private function _expensesDoc(){
  4553. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4554. Doo::loadClass ( 'XDeode' );
  4555. $XDeode = new XDeode ( 5 );
  4556. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4557. $rid = $XDeode->decode ( $rid );
  4558. if (! is_numeric ( $rid ))
  4559. die ( 'illegal request' );
  4560. Doo::loadModel ( 'receipt' );
  4561. $receipt = new receipt ();
  4562. Doo::loadModel ( 'L_category' );
  4563. $Lcategory = new L_category ();
  4564. Doo::loadModel ( 'verify' );
  4565. Doo::loadModel ( 'statistics' );
  4566. $statistics = new statistics ();
  4567. $verify = new verify ();
  4568. Doo::loadModel ( 'staff' );
  4569. $staff = new staff ();
  4570. Doo::loadModel ( 'loanReceipt' );
  4571. $loanReceipt = new loanReceipt ();
  4572. $receiptList = $receipt->find ( array (
  4573. 'where' => ' rid=' . $rid,
  4574. 'desc' => 'rid',
  4575. 'asArray' => true
  4576. ) );
  4577. $loanList = array ();
  4578. if (! empty ( $receiptList ))
  4579. $loanList = $loanReceipt->find ( array (
  4580. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4581. 'desc' => 'rid',
  4582. 'asArray' => true
  4583. ) );
  4584. $Locate = 0;
  4585. $roleId = 0;
  4586. $button = 0;
  4587. foreach ( $loanList as $key => $value ) {
  4588. $loanList [$key] ['Locate'] = $Locate;
  4589. $Locate ++;
  4590. $loanList [$key] ['reviseDetail'] = array ();
  4591. if (! empty ( $value ['reviseDetail'] ))
  4592. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4593. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4594. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4595. $categoryDetil = $Lcategory->getOne ( array (
  4596. 'where' => 'cid=' . $value ['cid'],
  4597. 'asArray' => true
  4598. ) );
  4599. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4600. // 检测编辑状态
  4601. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4602. $verifyList ['staff'] = $value ['verifyBreakup'];
  4603. else
  4604. $verifyList = $verify->getOne ( array (
  4605. 'where' => 'vid=' . $value ['verify'],
  4606. 'asArray' => true
  4607. ) );
  4608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4610. Doo::loadModel ( 'role' );
  4611. $role = new role ();
  4612. $flag = true;
  4613. $roleKey = 0;
  4614. $endStaffArray = array ();
  4615. $roleArrayCopy = array ();
  4616. foreach ( $verifyList as $k => $v ) {
  4617. // init verifyStaff
  4618. if ($v [1] == 'ROLE') {
  4619. if (! empty ( $verifyStaff )) {
  4620. $endStaffArray = end ( $verifyStaff );
  4621. // if ($v[0]==$endStaffArray['nextStaff']){
  4622. // $roleId=$v[0];
  4623. // }
  4624. }
  4625. $roleVerify = json_decode ( $v [3], true );
  4626. $roleKey = $k;
  4627. $roleArray = array ();
  4628. $rolename = $role->getOne ( array (
  4629. 'where' => 'rid=' . $v [0],
  4630. 'asArray' => true
  4631. ) );
  4632. foreach ( $roleVerify as $o => $p ) {
  4633. $staffID = explode ( '_', $p );
  4634. $staffInfo = $staff->getOne ( array (
  4635. 'where' => 'sid=' . $staffID [0],
  4636. 'asArray' => true
  4637. ) );
  4638. // print_r($staffID);
  4639. $exp = array (
  4640. 0 => $staffInfo ['sid'],
  4641. 1 => $staffID [1],
  4642. 2 => $staffInfo ['avatar'],
  4643. 'date' => '',
  4644. 'date' => '',
  4645. 'opinion' => '',
  4646. 'status' => '',
  4647. 'rolename' => $rolename ['name']
  4648. );
  4649. array_push ( $roleArray, $exp );
  4650. }
  4651. $roleArrayCopy [$v [0]] = $roleArray;
  4652. // $verifyList[$k]['roleArray']=$roleArray;
  4653. }
  4654. $verifyList [$k] ['date'] = "";
  4655. $verifyList [$k] ['opinion'] = "";
  4656. $verifyList [$k] ['status'] = "";
  4657. if (empty ( $verifyStaff )) {
  4658. $verifyList [$k] ['date'] = "";
  4659. $verifyList [$k] ['opinion'] = "";
  4660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4661. $verifyList [$k] ['status'] = 4;
  4662. $flag = false;
  4663. }
  4664. } else {
  4665. foreach ( $verifyStaff as $m => $u ) {
  4666. if ($v [0] == $m) {
  4667. $verifyList [$k] ['date'] = $u ['date'];
  4668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4669. $verifyList [$k] ['status'] = $u ['status'];
  4670. $flag = false;
  4671. break;
  4672. }
  4673. }
  4674. $endStaffArray = end ( $verifyStaff );
  4675. if (isset ( $endStaffArray ['ROLE'] )) {
  4676. } else {
  4677. // $endKey=key($verifyStaff);
  4678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4679. // $button=4;
  4680. // $verifyList[$k]['status']=4;
  4681. // }
  4682. }
  4683. }
  4684. }
  4685. $rolename ['name'] = '';
  4686. if (! empty ( $roleId )) {
  4687. Doo::loadModel ( 'role' );
  4688. $role = new role ();
  4689. $rolename = $role->getOne ( array (
  4690. 'where' => 'rid=' . $roleId,
  4691. 'asArray' => true
  4692. ) );
  4693. }
  4694. if (! empty ( $verifyStaff ))
  4695. $endStaffArray = end ( $verifyStaff );
  4696. $KOP = false;
  4697. foreach ( $roleArrayCopy as $P => $A ) {
  4698. foreach ( $A as $MKI => $AVL ) {
  4699. if (! empty ( $verifyStaff )) {
  4700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4702. $button = 4;
  4703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4704. }
  4705. foreach ( $verifyStaff as $m => $u ) {
  4706. $AVLFK = $AVL [0] . '_R';
  4707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4712. break;
  4713. }
  4714. }
  4715. } else {
  4716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4717. $button = 4;
  4718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4719. }
  4720. }
  4721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4722. $KOP = true;
  4723. }
  4724. }
  4725. foreach ( $roleArrayCopy as $k => $v ) {
  4726. foreach ( $verifyList as $m => $n ) {
  4727. if ($n [0] == $k) {
  4728. array_splice ( $verifyList, $m, 1, $v );
  4729. }
  4730. }
  4731. }
  4732. $loanList [$key] ['verifyList'] = $verifyList;
  4733. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4734. 'where' => 'sid=' . $value ['staff'],
  4735. 'asArray' => true
  4736. ) );
  4737. $loanList [$key] ['button'] = $button;
  4738. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4739. }
  4740. $data ['loanList'] = $loanList;
  4741. //print_r($loanList);
  4742. $Locate = 0;
  4743. $roleId = 0;
  4744. $button = 0;
  4745. foreach ( $receiptList as $key => $value ) {
  4746. $receiptList [$key] ['Locate'] = $Locate;
  4747. $Locate ++;
  4748. $receiptList [$key] ['reviseDetail'] = array ();
  4749. if (! empty ( $value ['reviseDetail'] ))
  4750. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4751. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4752. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4753. $categoryDetil = $Lcategory->getOne ( array (
  4754. 'where' => 'cid=' . $value ['cid'],
  4755. 'asArray' => true
  4756. ) );
  4757. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4758. // 检测编辑状态
  4759. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4760. $verifyList ['staff'] = $value ['verifyBreakup'];
  4761. } else
  4762. $verifyList = $verify->getOne ( array (
  4763. 'where' => 'vid=' . $value ['verify'],
  4764. 'asArray' => true
  4765. ) );
  4766. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4767. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4768. Doo::loadModel ( 'role' );
  4769. $role = new role ();
  4770. if ($verifyList == NULL)
  4771. $verifyList = array ();
  4772. $flag = true;
  4773. $roleKey = 0;
  4774. $endStaffArray = array ();
  4775. $roleArrayCopy = array ();
  4776. foreach ( $verifyList as $k => $v ) {
  4777. // init verifyStaff
  4778. if ($v [1] == 'ROLE') {
  4779. if (! empty ( $verifyStaff )) {
  4780. $endStaffArray = end ( $verifyStaff );
  4781. // if ($v[0]==$endStaffArray['nextStaff']){
  4782. // $roleId=$v[0];
  4783. // }
  4784. }
  4785. $roleVerify = json_decode ( $v [3], true );
  4786. $roleKey = $k;
  4787. $roleArray = array ();
  4788. $rolename = $role->getOne ( array (
  4789. 'where' => 'rid=' . $v [0],
  4790. 'asArray' => true
  4791. ) );
  4792. foreach ( $roleVerify as $o => $p ) {
  4793. $staffID = explode ( '_', $p );
  4794. $staffInfo = $staff->getOne ( array (
  4795. 'where' => 'sid=' . $staffID [0],
  4796. 'asArray' => true
  4797. ) );
  4798. // print_r($staffID);
  4799. $exp = array (
  4800. 0 => $staffInfo ['sid'],
  4801. 1 => $staffID [1],
  4802. 2 => $staffInfo ['avatar'],
  4803. 'date' => '',
  4804. 'date' => '',
  4805. 'opinion' => '',
  4806. 'status' => '',
  4807. 'rolename' => $rolename ['name']
  4808. );
  4809. array_push ( $roleArray, $exp );
  4810. }
  4811. $roleArrayCopy [$v [0]] = $roleArray;
  4812. // $verifyList[$k]['roleArray']=$roleArray;
  4813. }
  4814. $verifyList [$k] ['date'] = "";
  4815. $verifyList [$k] ['opinion'] = "";
  4816. $verifyList [$k] ['status'] = "";
  4817. if (empty ( $verifyStaff )) {
  4818. $verifyList [$k] ['date'] = "";
  4819. $verifyList [$k] ['opinion'] = "";
  4820. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4821. $verifyList [$k] ['status'] = 4;
  4822. $flag = false;
  4823. }
  4824. } else {
  4825. foreach ( $verifyStaff as $m => $u ) {
  4826. if ($v [0] == $m) {
  4827. $verifyList [$k] ['date'] = $u ['date'];
  4828. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4829. $verifyList [$k] ['status'] = $u ['status'];
  4830. $flag = false;
  4831. break;
  4832. }
  4833. }
  4834. $endStaffArray = end ( $verifyStaff );
  4835. if (isset ( $endStaffArray ['ROLE'] )) {
  4836. } else {
  4837. // $endKey=key($verifyStaff);
  4838. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4839. // $button=4;
  4840. // $verifyList[$k]['status']=4;
  4841. // }
  4842. }
  4843. }
  4844. }
  4845. $FC = @$rolename ['name'];
  4846. $rolename ['name'] = '';
  4847. if (! empty ( $roleId )) {
  4848. Doo::loadModel ( 'role' );
  4849. $role = new role ();
  4850. $rolename = $role->getOne ( array (
  4851. 'where' => 'rid=' . $roleId,
  4852. 'asArray' => true
  4853. ) );
  4854. }
  4855. if (! empty ( $verifyStaff ))
  4856. $endStaffArray = end ( $verifyStaff );
  4857. $KOP = false;
  4858. foreach ( $roleArrayCopy as $P => $A ) {
  4859. foreach ( $A as $MKI => $AVL ) {
  4860. if (! empty ( $verifyStaff )) {
  4861. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4862. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4863. $button = 4;
  4864. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4865. }
  4866. foreach ( $verifyStaff as $m => $u ) {
  4867. $AVLFK = $AVL [0] . '_R';
  4868. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4869. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4870. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4871. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4872. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4873. break;
  4874. }
  4875. }
  4876. } else {
  4877. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4878. $button = 4;
  4879. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4880. }
  4881. }
  4882. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4883. $KOP = true;
  4884. }
  4885. }
  4886. foreach ( $roleArrayCopy as $k => $v ) {
  4887. foreach ( $verifyList as $m => $n ) {
  4888. if ($n [0] == $k) {
  4889. array_splice ( $verifyList, $m, 1, $v );
  4890. }
  4891. }
  4892. }
  4893. // 费用执行人相关数据
  4894. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4895. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4896. foreach ( $executeCopy as $k => $v ) {
  4897. $executeCopy [$k] ['date'] = '';
  4898. $executeCopy [$k] ['opinion'] = '';
  4899. $executeCopy [$k] ['status'] = '';
  4900. if (! empty ( $executeStaff ))
  4901. foreach ( $executeStaff as $m => $u ) {
  4902. if ($v [0] == $m) {
  4903. $executeCopy [$k] ['date'] = $u ['date'];
  4904. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4905. $executeCopy [$k] ['status'] = $u ['status'];
  4906. break;
  4907. }
  4908. }
  4909. }
  4910. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4911. // print_r($verifyList);
  4912. $receiptList [$key] ['verifyList'] = $verifyList;
  4913. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4914. 'where' => 'sid=' . $value ['staff'],
  4915. 'asArray' => true
  4916. ) );
  4917. $receiptList [$key] ['button'] = $button;
  4918. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4919. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4920. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4921. $receiptList [$key] ['relust'] = $relust;
  4922. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4923. }
  4924. // print_r($receiptList);
  4925. // 获取审批日志
  4926. Doo::loadModel ( 'receiptLog' );
  4927. $receiptLog = new receiptLog ();
  4928. $rlList = array ();
  4929. $rlInfo = $receiptLog->getOne ( array (
  4930. 'where' => 'rid=' . $rid . ' and status=4',
  4931. 'asArray' => true
  4932. ) );
  4933. // $tijdate = $receiptLog->getOne ( array (
  4934. // 'where' => 'rid=' . $rid . ' and status=2',
  4935. // 'asc' => 'rlid',
  4936. // 'asArray' => true
  4937. // ) );
  4938. if (! empty ( $rlInfo )) {
  4939. $rlList = $receiptLog->find ( array (
  4940. 'where' => 'rid=' . $rid,
  4941. 'asc' => 'rlid',
  4942. 'asArray' => true
  4943. ) );
  4944. }
  4945. $RN=array();
  4946. if (!empty( $rolename ['staff'])){
  4947. $RN = @json_decode ( $rolename ['staff'] );
  4948. }
  4949. //
  4950. foreach ( $rlList as $key => $value ) {
  4951. $rlList [$key] ['rolename'] = '';
  4952. foreach ( $RN as $k => $v ) {
  4953. $id = explode ( "_", $v );
  4954. if ($id [0] == $value ['uid']) {
  4955. $rlList [$key] ['rolename'] = $FC;
  4956. break;
  4957. }
  4958. }
  4959. }
  4960. Doo::loadModel ( 'enclosur' );
  4961. $enclosur = new enclosur ();
  4962. $enclosurList = $enclosur->find ( array (
  4963. 'where' => 'rid=' . $rid,
  4964. 'asArray' => true
  4965. ) );
  4966. $enclosurHtml = '';
  4967. foreach ( $enclosurList as $value ) {
  4968. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4969. }
  4970. $data ['enclosurHtml'] = $enclosurHtml;
  4971. $receiptList [0] ['rlList'] = $rlList;
  4972. $data ['receiptList'] = $receiptList;
  4973. // print_r($receiptList);
  4974. $data ['memu'] = "receipt";
  4975. $data ['staff'] = $this->staff;
  4976. $data ['receiptMemu'] = 'approvalExpenses';
  4977. $data ['verifyId'] = $this->verifyId;
  4978. $data ['executeId'] = $this->executeId;
  4979. return $data;
  4980. }
  4981. function expensesDoc() {
  4982. $data=$this->_expensesDoc();
  4983. // $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4984. // Doo::loadClass ( 'XDeode' );
  4985. // $XDeode = new XDeode ( 5 );
  4986. // if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4987. // $rid = $XDeode->decode ( $rid );
  4988. // if (! is_numeric ( $rid ))
  4989. // die ( 'illegal request' );
  4990. // Doo::loadModel ( 'receipt' );
  4991. // $receipt = new receipt ();
  4992. // Doo::loadModel ( 'L_category' );
  4993. // $Lcategory = new L_category ();
  4994. // Doo::loadModel ( 'verify' );
  4995. // Doo::loadModel ( 'statistics' );
  4996. // $statistics = new statistics ();
  4997. // $verify = new verify ();
  4998. // Doo::loadModel ( 'staff' );
  4999. // $staff = new staff ();
  5000. // Doo::loadModel ( 'loanReceipt' );
  5001. // $loanReceipt = new loanReceipt ();
  5002. // $receiptList = $receipt->find ( array (
  5003. // 'where' => ' rid=' . $rid,
  5004. // 'desc' => 'rid',
  5005. // 'asArray' => true
  5006. // ) );
  5007. // $loanList = array ();
  5008. // if (! empty ( $receiptList ))
  5009. // $loanList = $loanReceipt->find ( array (
  5010. // 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5011. // 'desc' => 'rid',
  5012. // 'asArray' => true
  5013. // ) );
  5014. // $Locate = 0;
  5015. // $roleId = 0;
  5016. // $button = 0;
  5017. // foreach ( $loanList as $key => $value ) {
  5018. // $loanList [$key] ['Locate'] = $Locate;
  5019. // $Locate ++;
  5020. // $loanList [$key] ['reviseDetail'] = array ();
  5021. // if (! empty ( $value ['reviseDetail'] ))
  5022. // $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5023. // $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5024. // $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5025. // $categoryDetil = $Lcategory->getOne ( array (
  5026. // 'where' => 'cid=' . $value ['cid'],
  5027. // 'asArray' => true
  5028. // ) );
  5029. // $loanList [$key] ['category'] = $categoryDetil ['title'];
  5030. // // 检测编辑状态
  5031. // if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  5032. // $verifyList ['staff'] = $value ['verifyBreakup'];
  5033. // else
  5034. // $verifyList = $verify->getOne ( array (
  5035. // 'where' => 'vid=' . $value ['verify'],
  5036. // 'asArray' => true
  5037. // ) );
  5038. // $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5039. // $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5040. // Doo::loadModel ( 'role' );
  5041. // $role = new role ();
  5042. // $flag = true;
  5043. // $roleKey = 0;
  5044. // $endStaffArray = array ();
  5045. // $roleArrayCopy = array ();
  5046. // foreach ( $verifyList as $k => $v ) {
  5047. // // init verifyStaff
  5048. // if ($v [1] == 'ROLE') {
  5049. // if (! empty ( $verifyStaff )) {
  5050. // $endStaffArray = end ( $verifyStaff );
  5051. // // if ($v[0]==$endStaffArray['nextStaff']){
  5052. // // $roleId=$v[0];
  5053. // // }
  5054. // }
  5055. // $roleVerify = json_decode ( $v [3], true );
  5056. // $roleKey = $k;
  5057. // $roleArray = array ();
  5058. // $rolename = $role->getOne ( array (
  5059. // 'where' => 'rid=' . $v [0],
  5060. // 'asArray' => true
  5061. // ) );
  5062. // foreach ( $roleVerify as $o => $p ) {
  5063. // $staffID = explode ( '_', $p );
  5064. // $staffInfo = $staff->getOne ( array (
  5065. // 'where' => 'sid=' . $staffID [0],
  5066. // 'asArray' => true
  5067. // ) );
  5068. // // print_r($staffID);
  5069. // $exp = array (
  5070. // 0 => $staffInfo ['sid'],
  5071. // 1 => $staffID [1],
  5072. // 2 => $staffInfo ['avatar'],
  5073. // 'date' => '',
  5074. // 'date' => '',
  5075. // 'opinion' => '',
  5076. // 'status' => '',
  5077. // 'rolename' => $rolename ['name']
  5078. // );
  5079. // array_push ( $roleArray, $exp );
  5080. // }
  5081. // $roleArrayCopy [$v [0]] = $roleArray;
  5082. // // $verifyList[$k]['roleArray']=$roleArray;
  5083. // }
  5084. // $verifyList [$k] ['date'] = "";
  5085. // $verifyList [$k] ['opinion'] = "";
  5086. // $verifyList [$k] ['status'] = "";
  5087. // if (empty ( $verifyStaff )) {
  5088. // $verifyList [$k] ['date'] = "";
  5089. // $verifyList [$k] ['opinion'] = "";
  5090. // if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5091. // $verifyList [$k] ['status'] = 4;
  5092. // $flag = false;
  5093. // }
  5094. // } else {
  5095. // foreach ( $verifyStaff as $m => $u ) {
  5096. // if ($v [0] == $m) {
  5097. // $verifyList [$k] ['date'] = $u ['date'];
  5098. // $verifyList [$k] ['opinion'] = $u ['opinion'];
  5099. // $verifyList [$k] ['status'] = $u ['status'];
  5100. // $flag = false;
  5101. // break;
  5102. // }
  5103. // }
  5104. // $endStaffArray = end ( $verifyStaff );
  5105. // if (isset ( $endStaffArray ['ROLE'] )) {
  5106. // } else {
  5107. // // $endKey=key($verifyStaff);
  5108. // // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5109. // // $button=4;
  5110. // // $verifyList[$k]['status']=4;
  5111. // // }
  5112. // }
  5113. // }
  5114. // }
  5115. // $rolename ['name'] = '';
  5116. // if (! empty ( $roleId )) {
  5117. // Doo::loadModel ( 'role' );
  5118. // $role = new role ();
  5119. // $rolename = $role->getOne ( array (
  5120. // 'where' => 'rid=' . $roleId,
  5121. // 'asArray' => true
  5122. // ) );
  5123. // }
  5124. // if (! empty ( $verifyStaff ))
  5125. // $endStaffArray = end ( $verifyStaff );
  5126. // $KOP = false;
  5127. // foreach ( $roleArrayCopy as $P => $A ) {
  5128. // foreach ( $A as $MKI => $AVL ) {
  5129. // if (! empty ( $verifyStaff )) {
  5130. // // &&$rolename['rid']==$endStaffArray['nextStaff']
  5131. // if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5132. // $button = 4;
  5133. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5134. // }
  5135. // foreach ( $verifyStaff as $m => $u ) {
  5136. // $AVLFK = $AVL [0] . '_R';
  5137. // // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5138. // if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5139. // $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5140. // $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5141. // $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5142. // break;
  5143. // }
  5144. // }
  5145. // } else {
  5146. // if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5147. // $button = 4;
  5148. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5149. // }
  5150. // }
  5151. // // $roleArray[$MKI]['rolename']=$rolename['name'];
  5152. // $KOP = true;
  5153. // }
  5154. // }
  5155. // foreach ( $roleArrayCopy as $k => $v ) {
  5156. // foreach ( $verifyList as $m => $n ) {
  5157. // if ($n [0] == $k) {
  5158. // array_splice ( $verifyList, $m, 1, $v );
  5159. // }
  5160. // }
  5161. // }
  5162. // $loanList [$key] ['verifyList'] = $verifyList;
  5163. // $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5164. // 'where' => 'sid=' . $value ['staff'],
  5165. // 'asArray' => true
  5166. // ) );
  5167. // $loanList [$key] ['button'] = $button;
  5168. // //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  5169. // }
  5170. // $data ['loanList'] = $loanList;
  5171. // //print_r($loanList);
  5172. // $Locate = 0;
  5173. // $roleId = 0;
  5174. // $button = 0;
  5175. // foreach ( $receiptList as $key => $value ) {
  5176. // $receiptList [$key] ['Locate'] = $Locate;
  5177. // $Locate ++;
  5178. // $receiptList [$key] ['reviseDetail'] = array ();
  5179. // if (! empty ( $value ['reviseDetail'] ))
  5180. // $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5181. // $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5182. // $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5183. // $categoryDetil = $Lcategory->getOne ( array (
  5184. // 'where' => 'cid=' . $value ['cid'],
  5185. // 'asArray' => true
  5186. // ) );
  5187. // $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5188. // // 检测编辑状态
  5189. // if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5190. // $verifyList ['staff'] = $value ['verifyBreakup'];
  5191. // } else
  5192. // $verifyList = $verify->getOne ( array (
  5193. // 'where' => 'vid=' . $value ['verify'],
  5194. // 'asArray' => true
  5195. // ) );
  5196. // $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5197. // $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5198. // Doo::loadModel ( 'role' );
  5199. // $role = new role ();
  5200. // if ($verifyList == NULL)
  5201. // $verifyList = array ();
  5202. // $flag = true;
  5203. // $roleKey = 0;
  5204. // $endStaffArray = array ();
  5205. // $roleArrayCopy = array ();
  5206. // foreach ( $verifyList as $k => $v ) {
  5207. // // init verifyStaff
  5208. // if ($v [1] == 'ROLE') {
  5209. // if (! empty ( $verifyStaff )) {
  5210. // $endStaffArray = end ( $verifyStaff );
  5211. // // if ($v[0]==$endStaffArray['nextStaff']){
  5212. // // $roleId=$v[0];
  5213. // // }
  5214. // }
  5215. // $roleVerify = json_decode ( $v [3], true );
  5216. // $roleKey = $k;
  5217. // $roleArray = array ();
  5218. // $rolename = $role->getOne ( array (
  5219. // 'where' => 'rid=' . $v [0],
  5220. // 'asArray' => true
  5221. // ) );
  5222. // foreach ( $roleVerify as $o => $p ) {
  5223. // $staffID = explode ( '_', $p );
  5224. // $staffInfo = $staff->getOne ( array (
  5225. // 'where' => 'sid=' . $staffID [0],
  5226. // 'asArray' => true
  5227. // ) );
  5228. // // print_r($staffID);
  5229. // $exp = array (
  5230. // 0 => $staffInfo ['sid'],
  5231. // 1 => $staffID [1],
  5232. // 2 => $staffInfo ['avatar'],
  5233. // 'date' => '',
  5234. // 'date' => '',
  5235. // 'opinion' => '',
  5236. // 'status' => '',
  5237. // 'rolename' => $rolename ['name']
  5238. // );
  5239. // array_push ( $roleArray, $exp );
  5240. // }
  5241. // $roleArrayCopy [$v [0]] = $roleArray;
  5242. // // $verifyList[$k]['roleArray']=$roleArray;
  5243. // }
  5244. // $verifyList [$k] ['date'] = "";
  5245. // $verifyList [$k] ['opinion'] = "";
  5246. // $verifyList [$k] ['status'] = "";
  5247. // if (empty ( $verifyStaff )) {
  5248. // $verifyList [$k] ['date'] = "";
  5249. // $verifyList [$k] ['opinion'] = "";
  5250. // if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5251. // $verifyList [$k] ['status'] = 4;
  5252. // $flag = false;
  5253. // }
  5254. // } else {
  5255. // foreach ( $verifyStaff as $m => $u ) {
  5256. // if ($v [0] == $m) {
  5257. // $verifyList [$k] ['date'] = $u ['date'];
  5258. // $verifyList [$k] ['opinion'] = $u ['opinion'];
  5259. // $verifyList [$k] ['status'] = $u ['status'];
  5260. // $flag = false;
  5261. // break;
  5262. // }
  5263. // }
  5264. // $endStaffArray = end ( $verifyStaff );
  5265. // if (isset ( $endStaffArray ['ROLE'] )) {
  5266. // } else {
  5267. // // $endKey=key($verifyStaff);
  5268. // // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5269. // // $button=4;
  5270. // // $verifyList[$k]['status']=4;
  5271. // // }
  5272. // }
  5273. // }
  5274. // }
  5275. // $FC = @$rolename ['name'];
  5276. // $rolename ['name'] = '';
  5277. // if (! empty ( $roleId )) {
  5278. // Doo::loadModel ( 'role' );
  5279. // $role = new role ();
  5280. // $rolename = $role->getOne ( array (
  5281. // 'where' => 'rid=' . $roleId,
  5282. // 'asArray' => true
  5283. // ) );
  5284. // }
  5285. // if (! empty ( $verifyStaff ))
  5286. // $endStaffArray = end ( $verifyStaff );
  5287. // $KOP = false;
  5288. // foreach ( $roleArrayCopy as $P => $A ) {
  5289. // foreach ( $A as $MKI => $AVL ) {
  5290. // if (! empty ( $verifyStaff )) {
  5291. // // &&$rolename['rid']==$endStaffArray['nextStaff']
  5292. // if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5293. // $button = 4;
  5294. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5295. // }
  5296. // foreach ( $verifyStaff as $m => $u ) {
  5297. // $AVLFK = $AVL [0] . '_R';
  5298. // // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5299. // if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5300. // $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5301. // $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5302. // $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5303. // break;
  5304. // }
  5305. // }
  5306. // } else {
  5307. // if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5308. // $button = 4;
  5309. // $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5310. // }
  5311. // }
  5312. // // $roleArray[$MKI]['rolename']=$rolename['name'];
  5313. // $KOP = true;
  5314. // }
  5315. // }
  5316. // foreach ( $roleArrayCopy as $k => $v ) {
  5317. // foreach ( $verifyList as $m => $n ) {
  5318. // if ($n [0] == $k) {
  5319. // array_splice ( $verifyList, $m, 1, $v );
  5320. // }
  5321. // }
  5322. // }
  5323. // // 费用执行人相关数据
  5324. // $executeCopy = json_decode ( $value ['executeCopy'], true );
  5325. // $executeStaff = json_decode ( $value ['executeStaff'], true );
  5326. // foreach ( $executeCopy as $k => $v ) {
  5327. // $executeCopy [$k] ['date'] = '';
  5328. // $executeCopy [$k] ['opinion'] = '';
  5329. // $executeCopy [$k] ['status'] = '';
  5330. // if (! empty ( $executeStaff ))
  5331. // foreach ( $executeStaff as $m => $u ) {
  5332. // if ($v [0] == $m) {
  5333. // $executeCopy [$k] ['date'] = $u ['date'];
  5334. // $executeCopy [$k] ['opinion'] = $u ['opinion'];
  5335. // $executeCopy [$k] ['status'] = $u ['status'];
  5336. // break;
  5337. // }
  5338. // }
  5339. // }
  5340. // $receiptList [$key] ['executeCopy'] = $executeCopy;
  5341. // // print_r($verifyList);
  5342. // $receiptList [$key] ['verifyList'] = $verifyList;
  5343. // $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5344. // 'where' => 'sid=' . $value ['staff'],
  5345. // 'asArray' => true
  5346. // ) );
  5347. // $receiptList [$key] ['button'] = $button;
  5348. // $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5349. // $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5350. // $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5351. // $receiptList [$key] ['relust'] = $relust;
  5352. // $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5353. // }
  5354. // // print_r($receiptList);
  5355. // // 获取审批日志
  5356. // Doo::loadModel ( 'receiptLog' );
  5357. // $receiptLog = new receiptLog ();
  5358. // $rlList = array ();
  5359. // $rlInfo = $receiptLog->getOne ( array (
  5360. // 'where' => 'rid=' . $rid . ' and status=4',
  5361. // 'asArray' => true
  5362. // ) );
  5363. // // $tijdate = $receiptLog->getOne ( array (
  5364. // // 'where' => 'rid=' . $rid . ' and status=2',
  5365. // // 'asc' => 'rlid',
  5366. // // 'asArray' => true
  5367. // // ) );
  5368. // if (! empty ( $rlInfo )) {
  5369. // $rlList = $receiptLog->find ( array (
  5370. // 'where' => 'rid=' . $rid,
  5371. // 'asc' => 'rlid',
  5372. // 'asArray' => true
  5373. // ) );
  5374. // }
  5375. // $RN=array();
  5376. // if (!empty( $rolename ['staff'])){
  5377. // $RN = @json_decode ( $rolename ['staff'] );
  5378. // }
  5379. // //
  5380. // foreach ( $rlList as $key => $value ) {
  5381. // $rlList [$key] ['rolename'] = '';
  5382. // foreach ( $RN as $k => $v ) {
  5383. // $id = explode ( "_", $v );
  5384. // if ($id [0] == $value ['uid']) {
  5385. // $rlList [$key] ['rolename'] = $FC;
  5386. // break;
  5387. // }
  5388. // }
  5389. // }
  5390. // Doo::loadModel ( 'enclosur' );
  5391. // $enclosur = new enclosur ();
  5392. // $enclosurList = $enclosur->find ( array (
  5393. // 'where' => 'rid=' . $rid,
  5394. // 'asArray' => true
  5395. // ) );
  5396. // $enclosurHtml = '';
  5397. // foreach ( $enclosurList as $value ) {
  5398. // $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5399. // }
  5400. // $data ['enclosurHtml'] = $enclosurHtml;
  5401. // $receiptList [0] ['rlList'] = $rlList;
  5402. // $data ['receiptList'] = $receiptList;
  5403. // // print_r($receiptList);
  5404. // $data ['memu'] = "receipt";
  5405. // $data ['staff'] = $this->staff;
  5406. // $data ['receiptMemu'] = 'approvalExpenses';
  5407. // $data ['verifyId'] = $this->verifyId;
  5408. // $data ['executeId'] = $this->executeId;
  5409. $this->render ( "/admin/expensesDoc", $data );
  5410. }
  5411. function expensesDocPrint(){
  5412. $data=$this->_expensesDoc();
  5413. $this->render ( "/receipt/expensesDocPrint", $data );
  5414. }
  5415. function expensesEdi() {
  5416. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5417. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5418. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5419. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5420. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5421. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5422. if (empty ( $status ))
  5423. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5424. $vidList = array ();
  5425. $button = 0;
  5426. Doo::loadModel ( 'verify' );
  5427. Doo::loadModel ( 'receipt' );
  5428. Doo::loadModel ( 'staff' );
  5429. $staff = new staff ();
  5430. $receipt = new receipt ();
  5431. $verify = new verify ();
  5432. Doo::loadModel ( 'L_category' );
  5433. $Lcategory = new L_category ();
  5434. Doo::loadModel ( 'enclosur' );
  5435. $enclosur = new enclosur ();
  5436. // user verify ID
  5437. $verifyDetail = $verify->find ( array (
  5438. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5439. 'asArray' => true
  5440. ) );
  5441. foreach ( $verifyDetail as $key => $value ) {
  5442. array_push ( $vidList, $value ['vid'] );
  5443. }
  5444. $vid = implode ( ",", $vidList );
  5445. if (empty ( $verifyDetail ))
  5446. $vid = 0;
  5447. $categoryList = $Lcategory->find ( array (
  5448. 'asArray' => true
  5449. ) );
  5450. $staffList = $staff->find ( array (
  5451. 'where' => 'cid=' . $cid,
  5452. 'asArray' => true
  5453. ) );
  5454. $ap = "";
  5455. if ($status == 4) {
  5456. $ap = 4;
  5457. $status = 2;
  5458. }
  5459. // get Receipt By verifyID status 2
  5460. $receiptList = $receipt->find ( array (
  5461. 'where' => 'rid =' . $rid . ' and status=2',
  5462. 'desc' => 'rid',
  5463. 'asArray' => true
  5464. ) );
  5465. if (empty ( $receiptList )) {
  5466. die ( 'illegal request' );
  5467. }
  5468. $Locate = 0;
  5469. $roleId = 0;
  5470. if ($ap == 4)
  5471. $status = 4;
  5472. foreach ( $receiptList as $key => $value ) {
  5473. $receiptList [$key] ['Locate'] = $Locate;
  5474. $Locate ++;
  5475. $receiptList [$key] ['reviseDetail'] = array ();
  5476. if (! empty ( $value ['reviseDetail'] ))
  5477. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5478. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5479. $categoryDetil = $Lcategory->getOne ( array (
  5480. 'where' => 'cid=' . $value ['cid'],
  5481. 'asArray' => true
  5482. ) );
  5483. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5484. // 检测编辑状态
  5485. $verifyList = $verify->getOne ( array (
  5486. 'where' => 'vid=' . $value ['verify'],
  5487. 'asArray' => true
  5488. ) );
  5489. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5490. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5491. Doo::loadModel ( 'role' );
  5492. $role = new role ();
  5493. // print_r($verifyList);
  5494. $flag = true;
  5495. $roleKey = 0;
  5496. $endStaffArray = array ();
  5497. $roleArrayCopy = array ();
  5498. foreach ( $verifyList as $k => $v ) {
  5499. // init verifyStaff
  5500. if ($v [1] == 'ROLE') {
  5501. if (! empty ( $verifyStaff )) {
  5502. $endStaffArray = end ( $verifyStaff );
  5503. if ($v [0] == $endStaffArray ['nextStaff']) {
  5504. $roleId = $v [0];
  5505. }
  5506. }
  5507. $roleVerify = json_decode ( $v [3], true );
  5508. $roleKey = $k;
  5509. $roleArray = array ();
  5510. $rolename = $role->getOne ( array (
  5511. 'where' => 'rid=' . $v [0],
  5512. 'asArray' => true
  5513. ) );
  5514. foreach ( $roleVerify as $o => $p ) {
  5515. $staffID = explode ( '_', $p );
  5516. $staffInfo = $staff->getOne ( array (
  5517. 'where' => 'sid=' . $staffID [0],
  5518. 'asArray' => true
  5519. ) );
  5520. // print_r($staffID);
  5521. $exp = array (
  5522. 0 => $staffInfo ['sid'],
  5523. 1 => $staffID [1],
  5524. 2 => $staffInfo ['avatar'],
  5525. 'date' => '',
  5526. 'date' => '',
  5527. 'opinion' => '',
  5528. 'status' => '',
  5529. 'rolename' => $rolename ['name']
  5530. );
  5531. array_push ( $roleArray, $exp );
  5532. }
  5533. $roleArrayCopy [$v [0]] = $roleArray;
  5534. // $verifyList[$k]['roleArray']=$roleArray;
  5535. }
  5536. // print_r($roleArray);
  5537. $verifyList [$k] ['date'] = "";
  5538. $verifyList [$k] ['opinion'] = "";
  5539. $verifyList [$k] ['status'] = "";
  5540. if (empty ( $verifyStaff )) {
  5541. $verifyList [$k] ['date'] = "";
  5542. $verifyList [$k] ['opinion'] = "";
  5543. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5544. $verifyList [$k] ['status'] = 4;
  5545. $button = 4;
  5546. $flag = false;
  5547. }
  5548. } else {
  5549. foreach ( $verifyStaff as $m => $u ) {
  5550. if ($v [0] == $m) {
  5551. $verifyList [$k] ['date'] = $u ['date'];
  5552. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5553. $verifyList [$k] ['status'] = $u ['status'];
  5554. $flag = false;
  5555. break;
  5556. }
  5557. }
  5558. $endStaffArray = end ( $verifyStaff );
  5559. if (isset ( $endStaffArray ['ROLE'] )) {
  5560. } else {
  5561. $endKey = key ( $verifyStaff );
  5562. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5563. $button = 4;
  5564. $verifyList [$k] ['status'] = 4;
  5565. }
  5566. }
  5567. }
  5568. }
  5569. $rolename ['name'] = '';
  5570. if (! empty ( $roleId )) {
  5571. Doo::loadModel ( 'role' );
  5572. $role = new role ();
  5573. $rolename = $role->getOne ( array (
  5574. 'where' => 'rid=' . $roleId,
  5575. 'asArray' => true
  5576. ) );
  5577. }
  5578. if (! empty ( $verifyStaff ))
  5579. $endStaffArray = end ( $verifyStaff );
  5580. $KOP = false;
  5581. foreach ( $roleArrayCopy as $P => $A ) {
  5582. foreach ( $A as $MKI => $AVL ) {
  5583. if (! empty ( $verifyStaff )) {
  5584. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5585. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5586. $button = 4;
  5587. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5588. }
  5589. foreach ( $verifyStaff as $m => $u ) {
  5590. $AVLFK = $AVL [0] . '_R';
  5591. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5592. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5593. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5594. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5595. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5596. break;
  5597. }
  5598. }
  5599. } else {
  5600. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5601. $button = 4;
  5602. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5603. }
  5604. }
  5605. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5606. $KOP = true;
  5607. }
  5608. }
  5609. // print_r($roleArrayCopy);
  5610. // echo $roleKey;
  5611. foreach ( $roleArrayCopy as $k => $v ) {
  5612. foreach ( $verifyList as $m => $n ) {
  5613. if ($n [0] == $k) {
  5614. array_splice ( $verifyList, $m, 1, $v );
  5615. }
  5616. }
  5617. }
  5618. $receiptList [$key] ['verifyList'] = $verifyList;
  5619. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5620. 'where' => 'sid=' . $value ['staff'],
  5621. 'asArray' => true
  5622. ) );
  5623. $receiptList [$key] ['button'] = $button;
  5624. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5625. }
  5626. // $data['verifyDetail']=$verifyDetail;
  5627. $mothHtml = "";
  5628. for($i = 1; $i <= 12; $i ++) {
  5629. if ($month == $i)
  5630. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5631. else
  5632. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5633. }
  5634. // 获取审批日志
  5635. Doo::loadModel ( 'receiptLog' );
  5636. $receiptLog = new receiptLog ();
  5637. $rlList = array ();
  5638. $rlInfo = $receiptLog->getOne ( array (
  5639. 'where' => 'rid=' . $rid . ' and status=4',
  5640. 'asArray' => true
  5641. ) );
  5642. $tijdate = $receiptLog->getOne ( array (
  5643. 'where' => 'rid=' . $rid . ' and status=2',
  5644. 'asc' => 'rlid',
  5645. 'asArray' => true
  5646. ) );
  5647. if (! empty ( $rlInfo )) {
  5648. $rlList = $receiptLog->find ( array (
  5649. 'where' => 'rid=' . $rid,
  5650. 'asc' => 'rlid',
  5651. 'asArray' => true
  5652. ) );
  5653. }
  5654. $receiptList [0] ['rlList'] = $rlList;
  5655. $enclosurList = $enclosur->find ( array (
  5656. 'where' => 'rid=' . $rid,
  5657. 'asArray' => true
  5658. ) );
  5659. $enclosurHtml = '';
  5660. foreach ( $enclosurList as $value ) {
  5661. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5662. }
  5663. // print_r($receiptList);
  5664. $data ['rid'] = $rid;
  5665. $data ['enclosurHtml'] = $enclosurHtml;
  5666. $data ['rolename'] = $rolename ['name'];
  5667. $data ['datetij'] = $tijdate ['date'];
  5668. $data ['mothHtml'] = $mothHtml;
  5669. $data ['receiptList'] = $receiptList;
  5670. $data ['receiptApprovalCount'] = count ( $receiptList );
  5671. $data ['status'] = $status;
  5672. $data ['year'] = $year;
  5673. $data ['categoryList'] = $categoryList;
  5674. $data ['staffList'] = $staffList;
  5675. $data ['cid'] = $cid;
  5676. $data ['sid'] = $sid;
  5677. $data ['ap'] = $ap;
  5678. $data ['memu'] = "receipt";
  5679. $data ['staff'] = $this->staff;
  5680. $data ['receiptMemu'] = 'approvalExpenses';
  5681. $data ['verifyId'] = $this->verifyId;
  5682. $data ['executeId'] = $this->executeId;
  5683. $this->render ( "/admin/expensesEdi", $data );
  5684. }
  5685. function expensesDefray() {
  5686. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5687. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5688. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5689. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5690. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5691. if (! empty ( $rid )) {
  5692. Doo::loadModel ( "verify" );
  5693. $verify = new verify ();
  5694. Doo::loadModel ( "receiptDetail" );
  5695. $receiptDetailObj = new receiptDetail ();
  5696. Doo::loadModel ( "itemStatistics" );
  5697. Doo::loadModel ( "statistics" );
  5698. $statistics = new statistics ();
  5699. $itemStatistics = new itemStatistics ();
  5700. Doo::loadModel ( "receipt" );
  5701. $receipt = new receipt ();
  5702. Doo::loadModel ( "loanReceipt" );
  5703. $loanReceipt = new loanReceipt ();
  5704. $receiptDetail = $receipt->getOne ( array (
  5705. 'where' => 'rid=' . $rid . ' and status=2 ',
  5706. 'asArray' => true
  5707. ) );
  5708. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5709. $nsflag = true;
  5710. foreach ( $nslist as $value ) {
  5711. if ($value == $this->staff ['0'] ['sid']) {
  5712. $nsflag = false;
  5713. break;
  5714. }
  5715. }
  5716. // print_r($nslist);die;
  5717. if (empty ( $receiptDetail ) || $nsflag)
  5718. return "/approvalExpenses/pendApproval";
  5719. $verifyDetail = $verify->getOne ( array (
  5720. 'where' => ' vid =' . $receiptDetail ['verify'],
  5721. 'asArray' => true
  5722. ) );
  5723. $verifyString = $verifyDetail ['staff'];
  5724. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5725. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5726. if (empty ( $opinion )) {
  5727. if ($status == 3)
  5728. $opinion = "终止";
  5729. else
  5730. $opinion = "同意支付";
  5731. }
  5732. $nowStaff = 0;
  5733. $nowStaffList = array ();
  5734. if (empty ( $verifyStaff )) {
  5735. // 还需加入是否已经进入角色审批
  5736. if ($verifyDetail [0] [1] == 'ROLE') {
  5737. // print_r($verifyDetail);echo "ddd";
  5738. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5739. foreach ( $vStaffString as $key => $value ) {
  5740. $staffK = explode ( "_", $value );
  5741. if ($staffK [0] != $this->staff [0] ['sid'])
  5742. array_push ( $nowStaffList, $staffK [0] );
  5743. }
  5744. // print_r($verifyDetail);
  5745. // die;
  5746. if (! empty ( $nowStaffList )) {
  5747. $nowStaff = implode ( ',', $nowStaffList );
  5748. $verifyStaff = array (
  5749. $this->staff [0] ['sid'] . "_R" => array (
  5750. 'date' => date ( 'Y-m-d' ),
  5751. 'opinion' => $opinion,
  5752. 'status' => $status,
  5753. 'nextStaff' => $verifyDetail [0] [0],
  5754. 'ROLE' => 1
  5755. )
  5756. );
  5757. } else {
  5758. $nowStaff = $verifyDetail [1] [0];
  5759. $verifyStaff = array (
  5760. $this->staff [0] ['sid'] . "_R" => array (
  5761. 'date' => date ( 'Y-m-d' ),
  5762. 'opinion' => $opinion,
  5763. 'status' => $status,
  5764. 'nextStaff' => $verifyDetail [1] [0]
  5765. )
  5766. );
  5767. }
  5768. } else {
  5769. if ($verifyDetail [1] [1] == 'ROLE') {
  5770. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5771. // echo "dd";
  5772. foreach ( $vStaffString as $key => $value ) {
  5773. $staffK = explode ( "_", $value );
  5774. array_push ( $nowStaffList, $staffK [0] );
  5775. }
  5776. $nowStaff = implode ( ',', $nowStaffList );
  5777. $verifyStaff = array (
  5778. $this->staff [0] ['sid'] => array (
  5779. 'date' => date ( 'Y-m-d' ),
  5780. 'opinion' => $opinion,
  5781. 'status' => $status,
  5782. 'nextStaff' => $verifyDetail [1] [0],
  5783. 'ROLE' => 1
  5784. )
  5785. );
  5786. } else {
  5787. $nowStaff = $verifyDetail [1] [0];
  5788. $verifyStaff = array (
  5789. $this->staff [0] ['sid'] => array (
  5790. 'date' => date ( 'Y-m-d' ),
  5791. 'opinion' => $opinion,
  5792. 'status' => $status,
  5793. 'nextStaff' => $verifyDetail [1] [0]
  5794. )
  5795. );
  5796. }
  5797. }
  5798. if ($status == 3)
  5799. $verifyStaff = array (
  5800. 'final' => $status,
  5801. $this->staff [0] ['sid'] => array (
  5802. 'date' => date ( 'Y-m-d' ),
  5803. 'opinion' => $opinion,
  5804. 'status' => $status
  5805. )
  5806. );
  5807. $vStaffString = json_encode ( $verifyStaff );
  5808. $receipt->nowStaff = $nowStaff;
  5809. $receipt->verifyStaff = $vStaffString;
  5810. $loanReceipt->nowStaff = $nowStaff;
  5811. $loanReceipt->verifyStaff = $vStaffString;
  5812. } else {
  5813. $VS = end ( $verifyStaff );
  5814. // 非角色审批
  5815. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5816. $nextStaff = 0;
  5817. $roleSTF = false;
  5818. foreach ( $verifyDetail as $key => $value ) {
  5819. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5820. if (isset ( $verifyDetail [$key + 1] )) {
  5821. $nextStaff = $verifyDetail [$key + 1] [0];
  5822. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5823. $roleSTF = true;
  5824. }
  5825. break;
  5826. }
  5827. }
  5828. if (! $roleSTF) {
  5829. $nowStaff = $nextStaff;
  5830. $verifyStaff [$this->staff [0] ['sid']] = array (
  5831. 'date' => date ( 'Y-m-d' ),
  5832. 'opinion' => $opinion,
  5833. 'status' => $status,
  5834. 'nextStaff' => $nextStaff
  5835. );
  5836. } else {
  5837. // 获取角色下的所有用户ID
  5838. $nowStaffList = array ();
  5839. foreach ( $verifyDetail as $vfk ) {
  5840. if ($vfk [1] == 'ROLE') {
  5841. $vStaffString = json_decode ( $vfk [3] );
  5842. foreach ( $vStaffString as $key => $value ) {
  5843. $staffK = explode ( "_", $value );
  5844. array_push ( $nowStaffList, $staffK [0] );
  5845. }
  5846. }
  5847. }
  5848. $nowStaff = implode ( ',', $nowStaffList );
  5849. $verifyStaff [$this->staff [0] ['sid']] = array (
  5850. 'date' => date ( 'Y-m-d' ),
  5851. 'opinion' => $opinion,
  5852. 'status' => $status,
  5853. 'nextStaff' => $nextStaff,
  5854. 'ROLE' => 0
  5855. );
  5856. }
  5857. if ($status == 3) {
  5858. $verifyStaff ['final'] = $status;
  5859. $verifyStaff [$this->staff [0] ['sid']] = array (
  5860. 'date' => date ( 'Y-m-d' ),
  5861. 'opinion' => $opinion,
  5862. 'status' => $status
  5863. );
  5864. }
  5865. $vStaffString = json_encode ( $verifyStaff );
  5866. $receipt->nowStaff = $nowStaff;
  5867. $receipt->verifyStaff = $vStaffString;
  5868. $loanReceipt->nowStaff = $nowStaff;
  5869. $loanReceipt->verifyStaff = $vStaffString;
  5870. }
  5871. // 角色审批
  5872. if (isset ( $VS ['ROLE'] )) {
  5873. // 找出角色人 当前审批角色组
  5874. $verifyJSStaff = array ();
  5875. $nowStaffList2 = array ();
  5876. foreach ( $verifyDetail as $key => $value ) {
  5877. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5878. $verifyJSStaff = json_decode ( $value [3] );
  5879. foreach ( $verifyJSStaff as $m ) {
  5880. $staffK = explode ( "_", $m );
  5881. array_push ( $nowStaffList2, $staffK [0] );
  5882. }
  5883. // print_r($nowStaffList2);
  5884. }
  5885. }
  5886. $RoleVerifyStaff = array ();
  5887. foreach ( $verifyStaff as $key => $value ) {
  5888. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5889. foreach ( $nowStaffList2 as $m ) {
  5890. if ($key == $m . "_R")
  5891. $RoleVerifyStaff [$key] = $value;
  5892. }
  5893. }
  5894. }
  5895. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5896. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5897. // 下一个审批人ID
  5898. $nextStaff = 0;
  5899. $falg = false;
  5900. foreach ( $verifyDetail as $key => $value ) {
  5901. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5902. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5903. $falg = true;
  5904. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5905. $nowStaffList = array ();
  5906. foreach ( $vStaffString as $v ) {
  5907. $staffK = explode ( "_", $v );
  5908. array_push ( $nowStaffList, $staffK [0] );
  5909. }
  5910. $nowStaff = implode ( ',', $nowStaffList );
  5911. $nextStaff = $verifyDetail [$key + 1] [0];
  5912. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5913. $nextStaff = $verifyDetail [$key + 1] [0];
  5914. $nowStaff = $nextStaff;
  5915. } else
  5916. $nowStaff = '';
  5917. break;
  5918. }
  5919. }
  5920. if ($falg)
  5921. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5922. 'date' => date ( 'Y-m-d' ),
  5923. 'opinion' => $opinion,
  5924. 'status' => $status,
  5925. 'nextStaff' => $nextStaff,
  5926. 'ROLE' => 1
  5927. );
  5928. else
  5929. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5930. 'date' => date ( 'Y-m-d' ),
  5931. 'opinion' => $opinion,
  5932. 'status' => $status,
  5933. 'nextStaff' => $nextStaff
  5934. );
  5935. // print_r($verifyStaff);
  5936. // echo $nowStaff;die;
  5937. } else { // 进入下一个角色或者审批人
  5938. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5939. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5940. 'date' => date ( 'Y-m-d' ),
  5941. 'opinion' => $opinion,
  5942. 'status' => $status,
  5943. 'nextStaff' => $VS ['nextStaff'],
  5944. 'ROLE' => 1
  5945. );
  5946. }
  5947. if ($status == 3) {
  5948. $verifyStaff ['final'] = $status;
  5949. $verifyStaff [$this->staff [0] ['sid']] = array (
  5950. 'date' => date ( 'Y-m-d' ),
  5951. 'opinion' => $opinion,
  5952. 'status' => $status
  5953. );
  5954. }
  5955. $vStaffString = json_encode ( $verifyStaff );
  5956. $receipt->verifyStaff = $vStaffString;
  5957. $receipt->nowStaff = $nowStaff;
  5958. $loanReceipt->nowStaff = $nowStaff;
  5959. $loanReceipt->verifyStaff = $vStaffString;
  5960. }
  5961. // print_r($verifyStaff);die;
  5962. }
  5963. $roleKey = 0;
  5964. $roleId = 0;
  5965. $verifyDetailCopy = array ();
  5966. foreach ( $verifyDetail as $k => $v ) {
  5967. if ($v [1] == 'ROLE') {
  5968. $roleId = $v [0];
  5969. $roleVerify = json_decode ( $v [3], true );
  5970. $roleKey = $k;
  5971. $roleArray = array ();
  5972. foreach ( $roleVerify as $o => $p ) {
  5973. $staffID = explode ( '_', $p );
  5974. $exp = array (
  5975. 0 => $staffID [0],
  5976. 1 => $staffID [1]
  5977. );
  5978. array_push ( $roleArray, $exp );
  5979. }
  5980. $verifyDetailCopy [$v [0]] = $roleArray;
  5981. }
  5982. }
  5983. // print_r($verifyDetail);
  5984. foreach ( $verifyDetailCopy as $k => $v ) {
  5985. foreach ( $verifyDetail as $m => $n ) {
  5986. if ($n [0] == $k) {
  5987. array_splice ( $verifyDetail, $m, 1, $v );
  5988. }
  5989. }
  5990. }
  5991. // 审批日志
  5992. if (! isset ( $verifyStaff ['final'] )) {
  5993. Doo::loadModel ( "receiptLog" );
  5994. $receiptLog = new receiptLog ();
  5995. if (! empty ( $roleId )) {
  5996. Doo::loadModel ( "role" );
  5997. $role = new role ();
  5998. $roleInfo = $role->getOne ( array (
  5999. 'where' => 'rid=' . $roleId,
  6000. 'asArray' => true
  6001. ) );
  6002. $receiptLog->rolename = $roleInfo ['name'];
  6003. }
  6004. $receiptLog->username = $this->staff [0] ['username'];
  6005. $receiptLog->uid = $this->staff [0] ['sid'];
  6006. $receiptLog->date = date ( "Y-m-d" );
  6007. $receiptLog->opinion = $opinion;
  6008. $receiptLog->img = $this->staff [0] ['avatar'];
  6009. $receiptLog->status = 1;
  6010. $receiptLog->rid = $rid;
  6011. $receiptLog->insert ();
  6012. }
  6013. if (isset ( $verifyStaff ['final'] )) { // rDetail
  6014. $receipt->status = 3;
  6015. $receipt->verifyBreakup = $verifyString;
  6016. $receiptDetailObj->status = 3;
  6017. $receiptDetailObj->update ( array (
  6018. 'where' => 'rid=' . $rid
  6019. ) );
  6020. // 微信企业号通知
  6021. $this->setWXMsg ( $rid, 3 );
  6022. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  6023. $receipt->status = 6;
  6024. $receipt->pastDate = date ( "Y-m-d" );
  6025. $receipt->isBK = 1;
  6026. $loanReceipt->verifyBreakup = $verifyString;
  6027. $loanReceipt->status = 1;
  6028. $loanReceipt->pastDate = date ( "Y-m-d" );
  6029. //生成流水后 不更新汇款金额
  6030. Doo::loadModel ( 'wasteBook' );
  6031. $wasteBook = new wasteBook ();
  6032. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  6033. if (empty($wbDetail)){
  6034. $loanReceipt->amount = $receiptDetail ['amount'];
  6035. }
  6036. $loanReceipt->update ( array (
  6037. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  6038. ) );
  6039. // 微信企业号通知
  6040. $this->setWXMsg ( $rid, 1 );
  6041. }
  6042. $receipt->amount = $receiptDetail['sum'];
  6043. $receipt->update ( array (
  6044. 'where' => ' rid = ' . $rid
  6045. ) );
  6046. // 进入下一条审批费用新加需求
  6047. $vidList = array ();
  6048. $verifyDetail = $verify->find ( array (
  6049. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  6050. 'asArray' => true
  6051. ) );
  6052. foreach ( $verifyDetail as $key => $value ) {
  6053. array_push ( $vidList, $value ['vid'] );
  6054. }
  6055. $vid = implode ( ",", $vidList );
  6056. if (empty ( $verifyDetail ))
  6057. $vid = 0;
  6058. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  6059. $receipt = new receipt ();
  6060. $rd = $receipt->getOne ( array (
  6061. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  6062. 'asc' => 'rid',
  6063. 'asArray' => true
  6064. ) );
  6065. if (empty ( $rd )) {
  6066. return '/approvalExpenses/pendApproval';
  6067. }
  6068. if ($rd ['Rtype'] == 1) {
  6069. if ($rd ['isBK'] == 1) {
  6070. return '/receiptburEdi/' . $rd ['rid'];
  6071. } else {
  6072. return '/expensesEdi/' . $rd ['rid'];
  6073. }
  6074. } elseif ($rd ['Rtype'] == 2) {
  6075. return '/remitApproval/' . $rd ['rid'];
  6076. } else {
  6077. return '/receiptburEdi/' . $rd ['rid'];
  6078. }
  6079. // return "/approvalExpenses/pendApproval";
  6080. }
  6081. }
  6082. function ajaxExamineExe() {
  6083. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6084. Doo::loadModel ( 'receipt' );
  6085. $receipt = new receipt ();
  6086. Doo::loadClass ( 'XDeode' );
  6087. $XDeode = new XDeode ( 5 );
  6088. if (! empty ( $rid )) {
  6089. $rLRes = $receipt->find ( array (
  6090. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  6091. 'asArray' => true
  6092. ) );
  6093. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  6094. echo json_encode ( array (
  6095. 'status' => 1,
  6096. 'receipt' => $rLRes [0]
  6097. ) );
  6098. die ();
  6099. }
  6100. echo json_encode ( array (
  6101. 'status' => 0,
  6102. 'receipt' => array ()
  6103. ) );
  6104. die ();
  6105. }
  6106. function implement() {
  6107. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6108. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  6109. Doo::loadClass ( 'XDeode' );
  6110. $XDeode = new XDeode ( 5 );
  6111. Doo::loadModel ( 'receipt' );
  6112. $receipt = new receipt ();
  6113. Doo::loadModel ( 'L_category' );
  6114. $Lcategory = new L_category ();
  6115. Doo::loadModel ( 'verify' );
  6116. $verify = new verify ();
  6117. Doo::loadModel ( 'staff' );
  6118. $staff = new staff ();
  6119. Doo::loadModel ( "execute" );
  6120. $execute = new execute ();
  6121. $rid = $XDeode->decode ( $rid );
  6122. $receiptList = $receipt->find ( array (
  6123. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  6124. 'desc' => 'rid',
  6125. 'asArray' => true
  6126. ) );
  6127. Doo::loadModel ( 'loanReceipt' );
  6128. $loanReceipt = new loanReceipt ();
  6129. // print_r($receiptList);
  6130. $loanList = array ();
  6131. if (! isset ( $receiptList ))
  6132. $loanList = $loanReceipt->find ( array (
  6133. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6134. 'desc' => 'rid',
  6135. 'asArray' => true
  6136. ) );
  6137. $Locate = 0;
  6138. $roleId = 0;
  6139. $button = 0;
  6140. foreach ( $loanList as $key => $value ) {
  6141. $loanList [$key] ['Locate'] = $Locate;
  6142. $Locate ++;
  6143. $loanList [$key] ['reviseDetail'] = array ();
  6144. if (! empty ( $value ['reviseDetail'] ))
  6145. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6146. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6147. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6148. $categoryDetil = $Lcategory->getOne ( array (
  6149. 'where' => 'cid=' . $value ['cid'],
  6150. 'asArray' => true
  6151. ) );
  6152. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6153. // 检测编辑状态
  6154. $verifyList = $verify->getOne ( array (
  6155. 'where' => 'vid=' . $value ['verify'],
  6156. 'asArray' => true
  6157. ) );
  6158. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6159. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6160. Doo::loadModel ( 'role' );
  6161. $role = new role ();
  6162. $flag = true;
  6163. $roleKey = 0;
  6164. $endStaffArray = array ();
  6165. $roleArrayCopy = array ();
  6166. foreach ( $verifyList as $k => $v ) {
  6167. // init verifyStaff
  6168. if ($v [1] == 'ROLE') {
  6169. if (! empty ( $verifyStaff )) {
  6170. $endStaffArray = end ( $verifyStaff );
  6171. // if ($v[0]==$endStaffArray['nextStaff']){
  6172. // $roleId=$v[0];
  6173. // }
  6174. }
  6175. $roleVerify = json_decode ( $v [3], true );
  6176. $roleKey = $k;
  6177. $roleArray = array ();
  6178. $rolename = $role->getOne ( array (
  6179. 'where' => 'rid=' . $v [0],
  6180. 'asArray' => true
  6181. ) );
  6182. foreach ( $roleVerify as $o => $p ) {
  6183. $staffID = explode ( '_', $p );
  6184. $staffInfo = $staff->getOne ( array (
  6185. 'where' => 'sid=' . $staffID [0],
  6186. 'asArray' => true
  6187. ) );
  6188. // print_r($staffID);
  6189. $exp = array (
  6190. 0 => $staffInfo ['sid'],
  6191. 1 => $staffID [1],
  6192. 2 => $staffInfo ['avatar'],
  6193. 'date' => '',
  6194. 'date' => '',
  6195. 'opinion' => '',
  6196. 'status' => '',
  6197. 'rolename' => $rolename ['name']
  6198. );
  6199. array_push ( $roleArray, $exp );
  6200. }
  6201. $roleArrayCopy [$v [0]] = $roleArray;
  6202. // $verifyList[$k]['roleArray']=$roleArray;
  6203. }
  6204. $verifyList [$k] ['date'] = "";
  6205. $verifyList [$k] ['opinion'] = "";
  6206. $verifyList [$k] ['status'] = "";
  6207. if (empty ( $verifyStaff )) {
  6208. $verifyList [$k] ['date'] = "";
  6209. $verifyList [$k] ['opinion'] = "";
  6210. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6211. $verifyList [$k] ['status'] = 4;
  6212. $flag = false;
  6213. }
  6214. } else {
  6215. foreach ( $verifyStaff as $m => $u ) {
  6216. if ($v [0] == $m) {
  6217. $verifyList [$k] ['date'] = $u ['date'];
  6218. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6219. $verifyList [$k] ['status'] = $u ['status'];
  6220. $flag = false;
  6221. break;
  6222. }
  6223. }
  6224. $endStaffArray = end ( $verifyStaff );
  6225. if (isset ( $endStaffArray ['ROLE'] )) {
  6226. } else {
  6227. // $endKey=key($verifyStaff);
  6228. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6229. // $button=4;
  6230. // $verifyList[$k]['status']=4;
  6231. // }
  6232. }
  6233. }
  6234. }
  6235. $rolename ['name'] = '';
  6236. if (! empty ( $roleId )) {
  6237. Doo::loadModel ( 'role' );
  6238. $role = new role ();
  6239. $rolename = $role->getOne ( array (
  6240. 'where' => 'rid=' . $roleId,
  6241. 'asArray' => true
  6242. ) );
  6243. }
  6244. if (! empty ( $verifyStaff ))
  6245. $endStaffArray = end ( $verifyStaff );
  6246. $KOP = false;
  6247. foreach ( $roleArrayCopy as $P => $A ) {
  6248. foreach ( $A as $MKI => $AVL ) {
  6249. if (! empty ( $verifyStaff )) {
  6250. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6251. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6252. $button = 4;
  6253. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6254. }
  6255. foreach ( $verifyStaff as $m => $u ) {
  6256. $AVLFK = $AVL [0] . '_R';
  6257. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6258. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6259. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6260. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6261. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6262. break;
  6263. }
  6264. }
  6265. } else {
  6266. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6267. $button = 4;
  6268. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6269. }
  6270. }
  6271. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6272. $KOP = true;
  6273. }
  6274. }
  6275. foreach ( $roleArrayCopy as $k => $v ) {
  6276. foreach ( $verifyList as $m => $n ) {
  6277. if ($n [0] == $k) {
  6278. array_splice ( $verifyList, $m, 1, $v );
  6279. }
  6280. }
  6281. }
  6282. $loanList [$key] ['verifyList'] = $verifyList;
  6283. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  6284. 'where' => 'sid=' . $value ['staff'],
  6285. 'asArray' => true
  6286. ) );
  6287. }
  6288. $data ['loanList'] = $loanList;
  6289. $Locate = 0;
  6290. $roleId = 0;
  6291. $button = 0;
  6292. Doo::loadClass ( 'XDeode' );
  6293. $XDeode = new XDeode ( 5 );
  6294. foreach ( $receiptList as $key => $value ) {
  6295. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  6296. $button2 = 0;
  6297. $receiptList [$key] ['Locate'] = $Locate;
  6298. $Locate ++;
  6299. $receiptList [$key] ['reviseDetail'] = array ();
  6300. if (! empty ( $value ['reviseDetail'] ))
  6301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6303. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6304. $categoryDetil = $Lcategory->getOne ( array (
  6305. 'where' => 'cid=' . $value ['cid'],
  6306. 'asArray' => true
  6307. ) );
  6308. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6309. $executeList = json_decode ( $value ['executeCopy'], true );
  6310. $executeStaff = array ();
  6311. if (! empty ( $value ['executeStaff'] ))
  6312. $executeStaff = json_decode ( $value ['executeStaff'], true );
  6313. if (isset ( $executeList )) {
  6314. foreach ( $executeList as $op => $lo ) {
  6315. $executeList [$op] ['date'] = "";
  6316. $executeList [$op] ['opinion'] = "";
  6317. $executeList [$op] ['status'] = "";
  6318. foreach ( $executeStaff as $m => $u ) {
  6319. if ($lo [0] == $m) {
  6320. $executeList [$op] ['date'] = $u ['date'];
  6321. $executeList [$op] ['opinion'] = $u ['opinion'];
  6322. $executeList [$op] ['status'] = $u ['status'];
  6323. break;
  6324. }
  6325. }
  6326. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  6327. $button2 = 1;
  6328. $executeList [$op] ['status'] = 4;
  6329. }
  6330. }
  6331. }
  6332. // 检测编辑状态
  6333. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  6334. $verifyList ['staff'] = $value ['verifyBreakup'];
  6335. } else
  6336. $verifyList = $verify->getOne ( array (
  6337. 'where' => 'vid=' . $value ['verify'],
  6338. 'asArray' => true
  6339. ) );
  6340. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6341. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6342. Doo::loadModel ( 'role' );
  6343. $role = new role ();
  6344. if ($verifyList == NULL)
  6345. $verifyList = array ();
  6346. $flag = true;
  6347. $roleKey = 0;
  6348. $endStaffArray = array ();
  6349. $roleArrayCopy = array ();
  6350. foreach ( $verifyList as $k => $v ) {
  6351. // init verifyStaff
  6352. if ($v [1] == 'ROLE') {
  6353. if (! empty ( $verifyStaff )) {
  6354. $endStaffArray = end ( $verifyStaff );
  6355. // if ($v[0]==$endStaffArray['nextStaff']){
  6356. // $roleId=$v[0];
  6357. // }
  6358. }
  6359. $roleVerify = json_decode ( $v [3], true );
  6360. $roleKey = $k;
  6361. $roleArray = array ();
  6362. $rolename = $role->getOne ( array (
  6363. 'where' => 'rid=' . $v [0],
  6364. 'asArray' => true
  6365. ) );
  6366. foreach ( $roleVerify as $o => $p ) {
  6367. $staffID = explode ( '_', $p );
  6368. $staffInfo = $staff->getOne ( array (
  6369. 'where' => 'sid=' . $staffID [0],
  6370. 'asArray' => true
  6371. ) );
  6372. // print_r($staffID);
  6373. $exp = array (
  6374. 0 => $staffInfo ['sid'],
  6375. 1 => $staffID [1],
  6376. 2 => $staffInfo ['avatar'],
  6377. 'date' => '',
  6378. 'date' => '',
  6379. 'opinion' => '',
  6380. 'status' => '',
  6381. 'rolename' => $rolename ['name']
  6382. );
  6383. array_push ( $roleArray, $exp );
  6384. }
  6385. $roleArrayCopy [$v [0]] = $roleArray;
  6386. // $verifyList[$k]['roleArray']=$roleArray;
  6387. }
  6388. $verifyList [$k] ['date'] = "";
  6389. $verifyList [$k] ['opinion'] = "";
  6390. $verifyList [$k] ['status'] = "";
  6391. if (empty ( $verifyStaff )) {
  6392. $verifyList [$k] ['date'] = "";
  6393. $verifyList [$k] ['opinion'] = "";
  6394. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6395. $verifyList [$k] ['status'] = 4;
  6396. $flag = false;
  6397. }
  6398. } else {
  6399. foreach ( $verifyStaff as $m => $u ) {
  6400. if ($v [0] == $m) {
  6401. $verifyList [$k] ['date'] = $u ['date'];
  6402. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6403. $verifyList [$k] ['status'] = $u ['status'];
  6404. $flag = false;
  6405. break;
  6406. }
  6407. }
  6408. $endStaffArray = end ( $verifyStaff );
  6409. if (isset ( $endStaffArray ['ROLE'] )) {
  6410. } else {
  6411. // $endKey=key($verifyStaff);
  6412. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6413. // $button=4;
  6414. // $verifyList[$k]['status']=4;
  6415. // }
  6416. }
  6417. }
  6418. }
  6419. $rolename ['name'] = '';
  6420. if (! empty ( $roleId )) {
  6421. Doo::loadModel ( 'role' );
  6422. $role = new role ();
  6423. $rolename = $role->getOne ( array (
  6424. 'where' => 'rid=' . $roleId,
  6425. 'asArray' => true
  6426. ) );
  6427. }
  6428. if (! empty ( $verifyStaff ))
  6429. $endStaffArray = end ( $verifyStaff );
  6430. $KOP = false;
  6431. foreach ( $roleArrayCopy as $P => $A ) {
  6432. foreach ( $A as $MKI => $AVL ) {
  6433. if (! empty ( $verifyStaff )) {
  6434. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6435. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6436. $button = 4;
  6437. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6438. }
  6439. foreach ( $verifyStaff as $m => $u ) {
  6440. $AVLFK = $AVL [0] . '_R';
  6441. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6442. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6443. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6444. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6445. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6446. break;
  6447. }
  6448. }
  6449. } else {
  6450. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6451. $button = 4;
  6452. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6453. }
  6454. }
  6455. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6456. $KOP = true;
  6457. }
  6458. }
  6459. foreach ( $roleArrayCopy as $k => $v ) {
  6460. foreach ( $verifyList as $m => $n ) {
  6461. if ($n [0] == $k) {
  6462. array_splice ( $verifyList, $m, 1, $v );
  6463. }
  6464. }
  6465. }
  6466. $receiptList [$key] ['verifyList'] = $verifyList;
  6467. $receiptList [$key] ['executeList'] = $executeList;
  6468. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6469. 'where' => 'sid=' . $value ['staff'],
  6470. 'asArray' => true
  6471. ) );
  6472. $receiptList [$key] ['button2'] = $button2;
  6473. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6474. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6475. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6476. $receiptList [$key] ['relust'] = $relust;
  6477. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6478. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6479. }
  6480. //执行人是否是最后一位
  6481. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6482. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6483. $executePrimary=count($executeCopy)-1;
  6484. $lastOne=true;
  6485. if($executePrimary!=count($executeStaff)){
  6486. $lastOne=false;
  6487. }
  6488. $data['lastOne']=$lastOne;
  6489. // 是否写入过流水
  6490. $accountType = 0;
  6491. if ($receiptList [0] ['Rtype'] == 0) {
  6492. $accountType = 3;
  6493. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6494. if (!empty($receiptList [0]['accountItem']) )
  6495. $accountType = 2;
  6496. else
  6497. $accountType = 1;
  6498. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6499. $accountType = 4;
  6500. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6501. $accountType = 12;
  6502. }
  6503. Doo::loadModel ( 'wasteBook' );
  6504. $wasteBook = new wasteBook ();
  6505. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6506. $data ['wbDetail'] = $wbDetail;
  6507. $wbDetailLoan=array();
  6508. if ($accountType==2){
  6509. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6510. }
  6511. $data ['wbDetailLoan'] = $wbDetailLoan;
  6512. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6513. //print_r($wbDetail);
  6514. $data ['receiptList'] = $receiptList;
  6515. $data ['memu'] = "receipt";
  6516. $data ['staff'] = $this->staff;
  6517. $data ['receiptMemu'] = 'implement';
  6518. $data ['verifyId'] = $this->verifyId;
  6519. $data ['executeId'] = $this->executeId;
  6520. if ($Rtype=="loan"){
  6521. $this->render ( "/receipt/receiptImplementLoan", $data );
  6522. }elseif($Rtype=="receipt"){
  6523. if($receiptList[0]['receiptClass']==2){
  6524. $this->render ( "/receipt/receiptImplementTrave", $data );
  6525. }else{
  6526. $this->render ( "/receipt/receiptImplement", $data );
  6527. }
  6528. }elseif($Rtype=="public"){
  6529. $this->render ( "/receipt/receiptImplementPublic", $data );
  6530. }else{
  6531. //$this->render ( "/admin/implement", $data );
  6532. }
  6533. }
  6534. function implementDo() {
  6535. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6536. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6537. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6538. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6539. // $ab = '';
  6540. // if ($accountBank == 'CGBDeposit')
  6541. // $ab = '纵横广发';
  6542. // elseif ($accountBank == 'ICBCDeposit')
  6543. // $ab = '纵横工行';
  6544. // elseif ($accountBank == 'HUADeposit')
  6545. // $ab = '华润银行';
  6546. // elseif ($accountBank == 'PersonalDeposit')
  6547. // $ab = '个人广发';
  6548. // if (empty ( $ab ))
  6549. // die ( 'illegal request--22' );
  6550. if (! empty ( $rid )) {
  6551. Doo::loadModel ( 'receipt' );
  6552. $receipt = new receipt ();
  6553. Doo::loadClass ( 'XDeode' );
  6554. $XDeode = new XDeode ( 5 );
  6555. $rid=$XDeode->decode($rid);
  6556. if (!is_numeric($rid)){
  6557. die;
  6558. }
  6559. // $rinfo = $receipt->getOne ( array (
  6560. // 'where' => 'rid=' . $rid,
  6561. // 'asArray' => true
  6562. // ) );
  6563. $rinfo = $receipt->getReceiptByRid ( $rid );
  6564. // $accountType = '';
  6565. // if ($rinfo ['Rtype'] == 1) {
  6566. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6567. // $accountType = 2;
  6568. // else
  6569. // $accountType = 1;
  6570. // } elseif ($rinfo ['Rtype'] == 2) {
  6571. // $accountType = 4;
  6572. // } elseif ($rinfo ['Rtype'] == 0)
  6573. // $accountType = 3;
  6574. // if (empty ( $accountType ))
  6575. // die ( 'illegal request' );
  6576. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6577. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6578. if (empty ( $executeStaff )) {
  6579. $executeStaff = array (
  6580. $this->staff [0] ['sid'] => array (
  6581. 'date' => date ( 'Y-m-d' ),
  6582. 'opinion' => $implementOpinions,
  6583. 'status' => 1
  6584. )
  6585. );
  6586. } else {
  6587. $executeStaff [$this->staff [0] ['sid']] = array (
  6588. 'date' => date ( 'Y-m-d' ),
  6589. 'opinion' => $implementOpinions,
  6590. 'status' => 1
  6591. );
  6592. }
  6593. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6594. $receipt->executeStaff = json_encode ( $executeStaff );
  6595. $receipt->status = 8;
  6596. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6597. $receipt->status = 9;
  6598. if ($rinfo ['status'] == 6) {
  6599. $receipt->loanDate = date ( "Y-m-d" );
  6600. }
  6601. $receipt->executeDate = date ( "Y-m-d" );
  6602. } else {
  6603. $receipt->executeStaff = json_encode ( $executeStaff );
  6604. }
  6605. //$receipt->amount = $amount;
  6606. $receipt->update ( array (
  6607. 'where' => 'rid=' . $rid
  6608. ) );
  6609. // 公司流水记录
  6610. // Doo::loadModel ( 'wasteBook' );
  6611. // $wasteBook = new wasteBook ();
  6612. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6613. // // 银行
  6614. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6615. // $item = array (
  6616. // 'dataID' => $rid,
  6617. // 'expensesType' => 2,
  6618. // 'accountType' => $accountType,
  6619. // 'accountPriceShow' => $amount,
  6620. // 'accountPrice' => - $amount,
  6621. // 'accountBank' => $accountBank,
  6622. // 'category' => $rinfo ['category'] [0] ['title'],
  6623. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6624. // 'name' => $rinfo ['staffDetail'] ['username'],
  6625. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6626. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6627. // );
  6628. // $wasteBook->setAccountBookStatistics ( $item );
  6629. // }
  6630. }
  6631. //$ridKey = $XDeode->encode ( $rid );
  6632. return "/hisImplement";
  6633. // return "/implement/" . $ridKey . ".html";
  6634. }
  6635. function receiptburEdi() {
  6636. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6637. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6638. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6639. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6640. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6641. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6642. if (empty ( $status ))
  6643. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6644. $vidList = array ();
  6645. $button = 0;
  6646. Doo::loadModel ( 'verify' );
  6647. Doo::loadModel ( 'receipt' );
  6648. Doo::loadModel ( 'staff' );
  6649. $staff = new staff ();
  6650. $receipt = new receipt ();
  6651. $verify = new verify ();
  6652. Doo::loadModel ( 'L_category' );
  6653. $Lcategory = new L_category ();
  6654. Doo::loadModel ( 'enclosur' );
  6655. $enclosur = new enclosur ();
  6656. Doo::loadModel ( 'loanReceipt' );
  6657. $loanReceipt = new loanReceipt ();
  6658. // user verify ID
  6659. $verifyDetail = $verify->find ( array (
  6660. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6661. 'asArray' => true
  6662. ) );
  6663. foreach ( $verifyDetail as $key => $value ) {
  6664. array_push ( $vidList, $value ['vid'] );
  6665. }
  6666. $vid = implode ( ",", $vidList );
  6667. if (empty ( $verifyDetail ))
  6668. $vid = 0;
  6669. $categoryList = $Lcategory->find ( array (
  6670. 'asArray' => true
  6671. ) );
  6672. $staffList = $staff->find ( array (
  6673. 'where' => 'cid=' . $cid,
  6674. 'asArray' => true
  6675. ) );
  6676. $ap = "";
  6677. if ($status == 4) {
  6678. $ap = 4;
  6679. $status = 2;
  6680. }
  6681. // get Receipt By verifyID status 2
  6682. $receiptList = $receipt->find ( array (
  6683. 'where' => 'rid =' . $rid . ' and status=2',
  6684. 'desc' => 'rid',
  6685. 'asArray' => true
  6686. ) );
  6687. if (empty ( $receiptList )) {
  6688. die ( 'illegal request' );
  6689. }
  6690. $loanList = $loanReceipt->find ( array (
  6691. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6692. 'desc' => 'rid',
  6693. 'asArray' => true
  6694. ) );
  6695. $data ['explanation'] = '';
  6696. if (! empty ( $loanList ))
  6697. $data ['explanation'] = $loanList [0] ['explanation'];
  6698. $Locate = 0;
  6699. $roleId = 0;
  6700. $button = 0;
  6701. foreach ( $loanList as $key => $value ) {
  6702. $loanList [$key] ['Locate'] = $Locate;
  6703. $Locate ++;
  6704. $loanList [$key] ['reviseDetail'] = array ();
  6705. if (! empty ( $value ['reviseDetail'] ))
  6706. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6707. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6708. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6709. $categoryDetil = $Lcategory->getOne ( array (
  6710. 'where' => 'cid=' . $value ['cid'],
  6711. 'asArray' => true
  6712. ) );
  6713. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6714. // 检测编辑状态
  6715. $verifyList = $verify->getOne ( array (
  6716. 'where' => 'vid=' . $value ['verify'],
  6717. 'asArray' => true
  6718. ) );
  6719. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6720. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6721. Doo::loadModel ( 'role' );
  6722. $role = new role ();
  6723. $flag = true;
  6724. $roleKey = 0;
  6725. $endStaffArray = array ();
  6726. $roleArrayCopy = array ();
  6727. foreach ( $verifyList as $k => $v ) {
  6728. // init verifyStaff
  6729. if ($v [1] == 'ROLE') {
  6730. if (! empty ( $verifyStaff )) {
  6731. $endStaffArray = end ( $verifyStaff );
  6732. }
  6733. $roleVerify = json_decode ( $v [3], true );
  6734. $roleKey = $k;
  6735. $roleArray = array ();
  6736. $rolename = $role->getOne ( array (
  6737. 'where' => 'rid=' . $v [0],
  6738. 'asArray' => true
  6739. ) );
  6740. foreach ( $roleVerify as $o => $p ) {
  6741. $staffID = explode ( '_', $p );
  6742. $staffInfo = $staff->getOne ( array (
  6743. 'where' => 'sid=' . $staffID [0],
  6744. 'asArray' => true
  6745. ) );
  6746. // print_r($staffID);
  6747. $exp = array (
  6748. 0 => $staffInfo ['sid'],
  6749. 1 => $staffID [1],
  6750. 2 => $staffInfo ['avatar'],
  6751. 'date' => '',
  6752. 'date' => '',
  6753. 'opinion' => '',
  6754. 'status' => '',
  6755. 'rolename' => $rolename ['name']
  6756. );
  6757. array_push ( $roleArray, $exp );
  6758. }
  6759. $roleArrayCopy [$v [0]] = $roleArray;
  6760. // $verifyList[$k]['roleArray']=$roleArray;
  6761. }
  6762. $verifyList [$k] ['date'] = "";
  6763. $verifyList [$k] ['opinion'] = "";
  6764. $verifyList [$k] ['status'] = "";
  6765. if (empty ( $verifyStaff )) {
  6766. $verifyList [$k] ['date'] = "";
  6767. $verifyList [$k] ['opinion'] = "";
  6768. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6769. $verifyList [$k] ['status'] = 4;
  6770. $flag = false;
  6771. }
  6772. } else {
  6773. foreach ( $verifyStaff as $m => $u ) {
  6774. if ($v [0] == $m) {
  6775. $verifyList [$k] ['date'] = $u ['date'];
  6776. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6777. $verifyList [$k] ['status'] = $u ['status'];
  6778. $flag = false;
  6779. break;
  6780. }
  6781. }
  6782. $endStaffArray = end ( $verifyStaff );
  6783. if (isset ( $endStaffArray ['ROLE'] )) {
  6784. } else {
  6785. }
  6786. }
  6787. }
  6788. $rolename ['name'] = '';
  6789. if (! empty ( $roleId )) {
  6790. Doo::loadModel ( 'role' );
  6791. $role = new role ();
  6792. $rolename = $role->getOne ( array (
  6793. 'where' => 'rid=' . $roleId,
  6794. 'asArray' => true
  6795. ) );
  6796. }
  6797. if (! empty ( $verifyStaff ))
  6798. $endStaffArray = end ( $verifyStaff );
  6799. $KOP = false;
  6800. foreach ( $roleArrayCopy as $P => $A ) {
  6801. foreach ( $A as $MKI => $AVL ) {
  6802. if (! empty ( $verifyStaff )) {
  6803. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6804. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6805. $button = 4;
  6806. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6807. }
  6808. foreach ( $verifyStaff as $m => $u ) {
  6809. $AVLFK = $AVL [0] . '_R';
  6810. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6811. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6812. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6813. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6814. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6815. break;
  6816. }
  6817. }
  6818. } else {
  6819. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6820. $button = 4;
  6821. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6822. }
  6823. }
  6824. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6825. $KOP = true;
  6826. }
  6827. }
  6828. foreach ( $roleArrayCopy as $k => $v ) {
  6829. foreach ( $verifyList as $m => $n ) {
  6830. if ($n [0] == $k) {
  6831. array_splice ( $verifyList, $m, 1, $v );
  6832. }
  6833. }
  6834. }
  6835. $loanList [$key] ['verifyList'] = $verifyList;
  6836. }
  6837. $htmlLoan = '';
  6838. $data ['loanReceiptDate'] = '';
  6839. if (isset ( $loanList [0] )) {
  6840. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6841. if ($value ['status'] == 1)
  6842. $htmlLoan .= '<li class="done" >';
  6843. elseif ($value ['status'] == 3)
  6844. $htmlLoan .= '<li class="undone" >';
  6845. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6846. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6847. if (isset ( $value ['rolename'] ))
  6848. $htmlLoan .= $value ['rolename'];
  6849. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6850. }
  6851. $data ['loanDate'] = $loanList [0] ['date'];
  6852. } else {
  6853. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6854. }
  6855. $data ['htmlLoan'] = $htmlLoan;
  6856. // $data ['LoanReceipt']=$loanList[0];
  6857. // print_r($loanList);
  6858. $Locate = 0;
  6859. $roleId = 0;
  6860. $button = 0;
  6861. if ($ap == 4)
  6862. $status = 4;
  6863. Doo::loadClass ( 'XDeode' );
  6864. $XDeode = new XDeode ( 5 );
  6865. foreach ( $receiptList as $key => $value ) {
  6866. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6867. $receiptList [$key] ['Locate'] = $Locate;
  6868. $Locate ++;
  6869. $receiptList [$key] ['reviseDetail'] = array ();
  6870. // 调整金额 代码调整
  6871. if (! empty ( $value ['reviseDetail'] )) {
  6872. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6873. foreach ( $reviseDetail as $ry => $re ) {
  6874. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6875. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6876. }
  6877. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6878. // print_r($reviseDetail);
  6879. }
  6880. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6881. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6882. $categoryDetil = $Lcategory->getOne ( array (
  6883. 'where' => 'cid=' . $value ['cid'],
  6884. 'asArray' => true
  6885. ) );
  6886. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6887. // 检测编辑状态
  6888. $verifyList = $verify->getOne ( array (
  6889. 'where' => 'vid=' . $value ['verify'],
  6890. 'asArray' => true
  6891. ) );
  6892. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6893. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6894. Doo::loadModel ( 'role' );
  6895. $role = new role ();
  6896. // print_r($verifyList);
  6897. $flag = true;
  6898. $roleKey = 0;
  6899. $endStaffArray = array ();
  6900. $roleArrayCopy = array ();
  6901. foreach ( $verifyList as $k => $v ) {
  6902. // init verifyStaff
  6903. if ($v [1] == 'ROLE') {
  6904. if (! empty ( $verifyStaff )) {
  6905. $endStaffArray = end ( $verifyStaff );
  6906. if ($v [0] == $endStaffArray ['nextStaff']) {
  6907. $roleId = $v [0];
  6908. }
  6909. }
  6910. $roleVerify = json_decode ( $v [3], true );
  6911. $roleKey = $k;
  6912. $roleArray = array ();
  6913. $rolename = $role->getOne ( array (
  6914. 'where' => 'rid=' . $v [0],
  6915. 'asArray' => true
  6916. ) );
  6917. foreach ( $roleVerify as $o => $p ) {
  6918. $staffID = explode ( '_', $p );
  6919. $staffInfo = $staff->getOne ( array (
  6920. 'where' => 'sid=' . $staffID [0],
  6921. 'asArray' => true
  6922. ) );
  6923. // print_r($staffID);
  6924. $exp = array (
  6925. 0 => $staffInfo ['sid'],
  6926. 1 => $staffID [1],
  6927. 2 => $staffInfo ['avatar'],
  6928. 'date' => '',
  6929. 'date' => '',
  6930. 'opinion' => '',
  6931. 'status' => '',
  6932. 'rolename' => $rolename ['name']
  6933. );
  6934. array_push ( $roleArray, $exp );
  6935. }
  6936. $roleArrayCopy [$v [0]] = $roleArray;
  6937. // $verifyList[$k]['roleArray']=$roleArray;
  6938. }
  6939. // print_r($roleArray);
  6940. $verifyList [$k] ['date'] = "";
  6941. $verifyList [$k] ['opinion'] = "";
  6942. $verifyList [$k] ['status'] = "";
  6943. if (empty ( $verifyStaff )) {
  6944. $verifyList [$k] ['date'] = "";
  6945. $verifyList [$k] ['opinion'] = "";
  6946. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6947. $verifyList [$k] ['status'] = 4;
  6948. $button = 4;
  6949. $flag = false;
  6950. }
  6951. } else {
  6952. foreach ( $verifyStaff as $m => $u ) {
  6953. if ($v [0] == $m) {
  6954. $verifyList [$k] ['date'] = $u ['date'];
  6955. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6956. $verifyList [$k] ['status'] = $u ['status'];
  6957. $flag = false;
  6958. break;
  6959. }
  6960. }
  6961. $endStaffArray = end ( $verifyStaff );
  6962. if (isset ( $endStaffArray ['ROLE'] )) {
  6963. } else {
  6964. $endKey = key ( $verifyStaff );
  6965. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6966. $button = 4;
  6967. $verifyList [$k] ['status'] = 4;
  6968. }
  6969. }
  6970. }
  6971. }
  6972. $rolename ['name'] = '';
  6973. if (! empty ( $roleId )) {
  6974. Doo::loadModel ( 'role' );
  6975. $role = new role ();
  6976. $rolename = $role->getOne ( array (
  6977. 'where' => 'rid=' . $roleId,
  6978. 'asArray' => true
  6979. ) );
  6980. }
  6981. if (! empty ( $verifyStaff ))
  6982. $endStaffArray = end ( $verifyStaff );
  6983. $KOP = false;
  6984. foreach ( $roleArrayCopy as $P => $A ) {
  6985. foreach ( $A as $MKI => $AVL ) {
  6986. if (! empty ( $verifyStaff )) {
  6987. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6988. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6989. $button = 4;
  6990. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6991. }
  6992. foreach ( $verifyStaff as $m => $u ) {
  6993. $AVLFK = $AVL [0] . '_R';
  6994. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6995. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6996. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6997. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6998. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6999. break;
  7000. }
  7001. }
  7002. } else {
  7003. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7004. $button = 4;
  7005. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7006. }
  7007. }
  7008. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7009. $KOP = true;
  7010. }
  7011. }
  7012. foreach ( $roleArrayCopy as $k => $v ) {
  7013. foreach ( $verifyList as $m => $n ) {
  7014. if ($n [0] == $k) {
  7015. array_splice ( $verifyList, $m, 1, $v );
  7016. }
  7017. }
  7018. }
  7019. // print_r($verifyList);
  7020. $receiptList [$key] ['verifyList'] = $verifyList;
  7021. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7022. 'where' => 'sid=' . $value ['staff'],
  7023. 'asArray' => true
  7024. ) );
  7025. $receiptList [$key] ['button'] = $button;
  7026. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  7027. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  7028. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  7029. $receiptList [$key] ['relust'] = $relust;
  7030. $receiptList [$key] ['relustABS'] = abs ( $relust );
  7031. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  7032. }
  7033. //print_r($receiptList);die;
  7034. // $data['verifyDetail']=$verifyDetail;
  7035. $mothHtml = "";
  7036. for($i = 1; $i <= 12; $i ++) {
  7037. if ($month == $i)
  7038. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7039. else
  7040. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7041. }
  7042. // 获取审批日志
  7043. Doo::loadModel ( 'receiptLog' );
  7044. $receiptLog = new receiptLog ();
  7045. $rlList = array ();
  7046. $rlInfo = $receiptLog->getOne ( array (
  7047. 'where' => 'rid=' . $rid . ' and status=4',
  7048. 'asArray' => true
  7049. ) );
  7050. $tijdate = $receiptLog->getOne ( array (
  7051. 'where' => 'rid=' . $rid . ' and status=2',
  7052. 'asc' => 'rlid',
  7053. 'asArray' => true
  7054. ) );
  7055. if (! empty ( $rlInfo )) {
  7056. $rlList = $receiptLog->find ( array (
  7057. 'where' => 'rid=' . $rid,
  7058. 'asc' => 'rlid',
  7059. 'asArray' => true
  7060. ) );
  7061. }
  7062. // echo $rid;
  7063. // print_r($receiptList);
  7064. $receiptList [0] ['rlList'] = $rlList;
  7065. // print_r($receiptList);
  7066. $enclosurList = $enclosur->find ( array (
  7067. 'where' => 'rid=' . $rid,
  7068. 'asArray' => true
  7069. ) );
  7070. $enclosurHtml = '';
  7071. foreach ( $enclosurList as $value ) {
  7072. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7073. }
  7074. $data ['enclosurHtml'] = $enclosurHtml;
  7075. $data ['rolename'] = $rolename ['name'];
  7076. $data ['mothHtml'] = $mothHtml;
  7077. // print_r($receiptList);
  7078. $data ['rid'] = $rid;
  7079. $data ['tijdate'] = $tijdate ['date'];
  7080. $data ['receiptList'] = $receiptList;
  7081. $data ['receiptApprovalCount'] = count ( $receiptList );
  7082. $data ['status'] = $status;
  7083. $data ['year'] = $year;
  7084. $data ['categoryList'] = $categoryList;
  7085. $data ['staffList'] = $staffList;
  7086. $data ['cid'] = $cid;
  7087. $data ['sid'] = $sid;
  7088. $data ['ap'] = $ap;
  7089. $data ['memu'] = "receipt";
  7090. $data ['staff'] = $this->staff;
  7091. $data ['receiptMemu'] = 'approvalExpenses';
  7092. $data ['verifyId'] = $this->verifyId;
  7093. $data ['executeId'] = $this->executeId;
  7094. if($receiptList[0]['receiptClass']==1){
  7095. $this->render ( "/receipt/feeAgencyApproval", $data );
  7096. }elseif($receiptList[0]['receiptClass']==2){
  7097. //$this->render ( "/admin/receiptburEdi", $data );
  7098. $this->render ( "/receipt/feeTraveApproval", $data );
  7099. }elseif($receiptList[0]['receiptClass']==3){
  7100. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  7101. }else{
  7102. $this->render ( "/admin/receiptburEdi", $data );
  7103. }
  7104. }
  7105. function hisImplement() {
  7106. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7107. if (empty ( $item ))
  7108. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  7109. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  7110. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7111. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  7112. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7113. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  7114. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  7115. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  7116. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  7117. Doo::loadClass ( 'XDeode' );
  7118. $XDeode = new XDeode ( 5 );
  7119. Doo::loadModel ( 'receipt' );
  7120. $receipt = new receipt ();
  7121. Doo::loadModel ( 'L_category' );
  7122. $Lcategory = new L_category ();
  7123. Doo::loadModel ( 'verify' );
  7124. Doo::loadModel ( 'statistics' );
  7125. $statistics = new statistics ();
  7126. $verify = new verify ();
  7127. Doo::loadModel ( 'staff' );
  7128. $staff = new staff ();
  7129. Doo::loadClass ( 'XDeode' );
  7130. $XDeode = new XDeode ( 5 );
  7131. $XDeode7 = new XDeode ( 7 );
  7132. $cid = $XDeode->decode ( $cidKey );
  7133. $condition = "";
  7134. if ($item == "expenses")
  7135. $condition = " and Rtype=1 ";
  7136. elseif ($item == "receipts")
  7137. $condition = " and Rtype=0 ";
  7138. elseif ($item == "remits")
  7139. $condition = " and Rtype=2 ";
  7140. elseif($item == "train")
  7141. $condition = " and Rtype=3 ";
  7142. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  7143. $sopString = $cidString = "";
  7144. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  7145. if (empty ( $rdate ))
  7146. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  7147. else
  7148. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  7149. if ($status == 'pendImplement') {
  7150. $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 ) ) ';
  7151. } elseif ($status == 'alerpts') {
  7152. $statusCon = '(status=8 or status=9 )';
  7153. if (empty ( $rdate )){
  7154. $dateCondition = " and Year(date) =" . $year;
  7155. }else{
  7156. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  7157. }
  7158. }
  7159. if ($sop != 'SOP')
  7160. $sopString = " and staff=" . $sop;
  7161. if ($cidKey != 'ALL')
  7162. $cidString = " and cid=" . $cid;
  7163. //汇款信息需要提取出来
  7164. if(!empty($receiptOrder)){
  7165. $receiptList = $receipt->find ( array (
  7166. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  7167. 'desc' => 'rid',
  7168. 'asArray' => true
  7169. ) );
  7170. // 员工筛选
  7171. $receiptList2 = $receipt->find ( array (
  7172. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  7173. 'desc' => 'rid',
  7174. 'asArray' => true
  7175. ) );
  7176. }else{
  7177. $receiptList = $receipt->find ( array (
  7178. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  7179. 'desc' => 'rid',
  7180. 'asArray' => true
  7181. ) );
  7182. // 员工筛选
  7183. $receiptList2 = $receipt->find ( array (
  7184. 'where' => $statusCon . $condition . $dateCondition,
  7185. 'desc' => 'rid',
  7186. 'asArray' => true
  7187. ) );
  7188. }
  7189. $sopStaff = array ();
  7190. foreach ( $receiptList2 as $key => $value ) {
  7191. $staffDetail = $staff->getOne ( array (
  7192. 'select' => 'username',
  7193. 'where' => 'sid=' . $value ['staff'],
  7194. 'asArray' => true
  7195. ) );
  7196. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  7197. }
  7198. // 办事处筛选
  7199. $categoryScreen = array ();
  7200. $categorList = $Lcategory->getCategory ();
  7201. foreach ( $receiptList2 as $key => $value ) {
  7202. foreach ( $categorList as $k => $v ) {
  7203. if ($value ['cid'] == $v ['cid']) {
  7204. $categoryScreen [$v ['cidKey']] = $v ['title'];
  7205. break;
  7206. }
  7207. }
  7208. }
  7209. $categoryScreenHtml = "";
  7210. foreach ( $categoryScreen as $key => $value ) {
  7211. if ($cidKey == $key)
  7212. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7213. else
  7214. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7215. }
  7216. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  7217. $data ['cidKey'] = $cidKey;
  7218. $Locate = 0;
  7219. $roleId = 0;
  7220. $button = 0;
  7221. $staffBatchNumber = 100001;
  7222. $remittanceList = array ();
  7223. foreach ( $receiptList as $key => $value ) {
  7224. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  7225. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  7226. $receiptList [$key] ['Texe'] = 'false';
  7227. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  7228. $receiptList [$key] ['Texe'] = 'true';
  7229. }
  7230. $receiptList [$key] ['TRexe'] = 'true';
  7231. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  7232. $receiptList [$key] ['TRexe'] = 'false';
  7233. }
  7234. $receiptList [$key] ['Locate'] = $Locate;
  7235. $Locate ++;
  7236. $receiptList [$key] ['reviseDetail'] = array ();
  7237. if (! empty ( $value ['reviseDetail'] ))
  7238. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7239. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7240. $categoryDetil = $Lcategory->getOne ( array (
  7241. 'where' => 'cid=' . $value ['cid'],
  7242. 'asArray' => true
  7243. ) );
  7244. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7245. // 检测编辑状态
  7246. $verifyList = $verify->getOne ( array (
  7247. 'where' => 'vid=' . $value ['verify'],
  7248. 'asArray' => true
  7249. ) );
  7250. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7251. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7252. Doo::loadModel ( 'role' );
  7253. $role = new role ();
  7254. $flag = true;
  7255. $roleKey = 0;
  7256. $endStaffArray = array ();
  7257. $roleArrayCopy = array ();
  7258. foreach ( $verifyList as $k => $v ) {
  7259. // init verifyStaff
  7260. if ($v [1] == 'ROLE') {
  7261. if (! empty ( $verifyStaff )) {
  7262. $endStaffArray = end ( $verifyStaff );
  7263. }
  7264. $roleVerify = json_decode ( $v [3], true );
  7265. $roleKey = $k;
  7266. $roleArray = array ();
  7267. $rolename = $role->getOne ( array (
  7268. 'where' => 'rid=' . $v [0],
  7269. 'asArray' => true
  7270. ) );
  7271. foreach ( $roleVerify as $o => $p ) {
  7272. $staffID = explode ( '_', $p );
  7273. $staffInfo = $staff->getOne ( array (
  7274. 'where' => 'sid=' . $staffID [0],
  7275. 'asArray' => true
  7276. ) );
  7277. $exp = array (
  7278. 0 => $staffInfo ['sid'],
  7279. 1 => $staffID [1],
  7280. 2 => $staffInfo ['avatar'],
  7281. 'date' => '',
  7282. 'date' => '',
  7283. 'opinion' => '',
  7284. 'status' => '',
  7285. 'rolename' => $rolename ['name']
  7286. );
  7287. array_push ( $roleArray, $exp );
  7288. }
  7289. $roleArrayCopy [$v [0]] = $roleArray;
  7290. }
  7291. $verifyList [$k] ['date'] = "";
  7292. $verifyList [$k] ['opinion'] = "";
  7293. $verifyList [$k] ['status'] = "";
  7294. if (empty ( $verifyStaff )) {
  7295. $verifyList [$k] ['date'] = "";
  7296. $verifyList [$k] ['opinion'] = "";
  7297. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7298. $verifyList [$k] ['status'] = 4;
  7299. $flag = false;
  7300. }
  7301. } else {
  7302. foreach ( $verifyStaff as $m => $u ) {
  7303. if ($v [0] == $m) {
  7304. $verifyList [$k] ['date'] = $u ['date'];
  7305. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7306. $verifyList [$k] ['status'] = $u ['status'];
  7307. $flag = false;
  7308. break;
  7309. }
  7310. }
  7311. $endStaffArray = end ( $verifyStaff );
  7312. }
  7313. }
  7314. $rolename ['name'] = '';
  7315. if (! empty ( $roleId )) {
  7316. Doo::loadModel ( 'role' );
  7317. $role = new role ();
  7318. $rolename = $role->getOne ( array (
  7319. 'where' => 'rid=' . $roleId,
  7320. 'asArray' => true
  7321. ) );
  7322. }
  7323. if (! empty ( $verifyStaff ))
  7324. $endStaffArray = end ( $verifyStaff );
  7325. $KOP = false;
  7326. foreach ( $roleArrayCopy as $P => $A ) {
  7327. foreach ( $A as $MKI => $AVL ) {
  7328. if (! empty ( $verifyStaff )) {
  7329. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7330. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7331. $button = 4;
  7332. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7333. }
  7334. foreach ( $verifyStaff as $m => $u ) {
  7335. $AVLFK = $AVL [0] . '_R';
  7336. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7337. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7338. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7339. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7340. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7341. break;
  7342. }
  7343. }
  7344. } else {
  7345. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7346. $button = 4;
  7347. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7348. }
  7349. }
  7350. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7351. $KOP = true;
  7352. }
  7353. }
  7354. foreach ( $roleArrayCopy as $k => $v ) {
  7355. foreach ( $verifyList as $m => $n ) {
  7356. if ($n [0] == $k) {
  7357. array_splice ( $verifyList, $m, 1, $v );
  7358. }
  7359. }
  7360. }
  7361. $receiptList [$key] ['verifyList'] = $verifyList;
  7362. $staffDetail = $staff->getOne ( array (
  7363. 'where' => 'sid=' . $value ['staff'],
  7364. 'asArray' => true
  7365. ) );
  7366. $receiptList [$key] ['staffDetail'] = $staffDetail;
  7367. $receiptList [$key] ['button'] = $button;
  7368. if ($value['Rtype']==1){
  7369. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  7370. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  7371. }elseif($value['Rtype']==3){
  7372. // 收入合计
  7373. Doo::loadModel ( 'invoiceTraining' );
  7374. $invoiceTraining = new invoiceTraining ();
  7375. $invoiceTrainingDetail = array (
  7376. 'invoiceArriveAmount' => '0.00',
  7377. 'RIAmount' => '0.00',
  7378. 'invoiceTotalAmount' => '0.00',
  7379. 'invoiceCompanyAmount' => '0.00',
  7380. 'invoiceArriveAmountM'=>'0.00',
  7381. 'invoiceCompanyAmountM'=>'0.00'
  7382. );
  7383. if ($value ['invoiceTrainId'] != 0) {
  7384. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  7385. }
  7386. $invoiceArriveAmount = $RIAmount = 0;
  7387. if (! empty ( $invoiceTrainingDetail )) {
  7388. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  7389. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  7390. }
  7391. // 备用金
  7392. $sum = 0;
  7393. if (! empty ( $value ['trainLoanRid'] )) {
  7394. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  7395. foreach ($receiptLoanList as $kll=>$vll){
  7396. $sum+=$vll['sum'];
  7397. }
  7398. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  7399. // $sum = $receiptLoanDetailBak ['sum'];
  7400. }
  7401. // 支出项金额详情
  7402. // 项目金额合计
  7403. Doo::loadModel ( 'RItem' );
  7404. $RItem = new RItem ();
  7405. Doo::loadModel ( 'accountItem' );
  7406. $accountItem = new accountItem ();
  7407. // 讲师获得
  7408. Doo::loadModel ( 'RILecturer' );
  7409. $RILecturer = new RILecturer ();
  7410. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  7411. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  7412. // 支出项金额详情
  7413. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  7414. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  7415. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  7416. $receiptList [$key] ['payment'] =$payment;
  7417. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  7418. }
  7419. // 设置导出汇款execl
  7420. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  7421. $remittanceDetail = array (
  7422. $staffBatchNumber,
  7423. $value ['remittanceName'],
  7424. $value ['bankNumber'],
  7425. $value ['bankName'],
  7426. $value ['remittanceBankType'],
  7427. $value ['coupletNumber'],
  7428. $value ['sum']
  7429. );
  7430. array_push ( $remittanceList, $remittanceDetail );
  7431. $staffBatchNumber ++;
  7432. }
  7433. }
  7434. $data ['remittanceList'] = json_encode ( $remittanceList );
  7435. // print_r($receiptList);
  7436. $mothHtml = "";
  7437. for($i = 1; $i <= 12; $i ++) {
  7438. if ($moth == $i)
  7439. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7440. else
  7441. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7442. }
  7443. $dayHtml = "";
  7444. if ($day != "DAY" || $moth != "MONTH") {
  7445. for($i = 1; $i <= 31; $i ++) {
  7446. if ($day == $i)
  7447. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7448. else
  7449. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7450. }
  7451. }
  7452. $sopHtml = "";
  7453. foreach ( $sopStaff as $key => $value ) {
  7454. if ($sop == $key)
  7455. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  7456. else
  7457. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  7458. }
  7459. $data ['status'] = $status;
  7460. $data ['rdate'] = $rdate;
  7461. $data ['sopHtml'] = $sopHtml;
  7462. $data ['dayHtml'] = $dayHtml;
  7463. $data ['mothHtml'] = $mothHtml;
  7464. $data ['receiptList'] = $receiptList;
  7465. $data ['memu'] = "receipt";
  7466. $data ['staff'] = $this->staff;
  7467. $data ['receiptMemu'] = 'implement';
  7468. $data ['verifyId'] = $this->verifyId;
  7469. $data ['executeId'] = $this->executeId;
  7470. $data ['item'] = $item;
  7471. $data ['year'] = $year;
  7472. $data ['moth'] = $moth;
  7473. $data['receiptOrder']=$receiptOrder;
  7474. $data ['day'] = $day;
  7475. $data ['sop'] = $sop;
  7476. $this->render ( "/admin/hisImplement", $data );
  7477. }
  7478. /**
  7479. * 导出汇款信息的exelc
  7480. */
  7481. function exportRemittance() {
  7482. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7483. if (empty ( $remittanceInfo ))
  7484. die ( 'illegal request' );
  7485. $title = array (
  7486. '员工编号',
  7487. '姓名',
  7488. '员工账号',
  7489. '员工账户开户行',
  7490. '转账类型',
  7491. '联行号',
  7492. '金额'
  7493. );
  7494. $data = json_decode ( $remittanceInfo, true );
  7495. if (empty ( $data ))
  7496. die ( 'illegal request' );
  7497. Doo::loadClass ( 'receipt.func' );
  7498. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7499. header ( 'Content-Type:text/html;charset=utf-8' );
  7500. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7501. }
  7502. function ajaxExamine() {
  7503. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7504. Doo::loadModel ( 'receipt' );
  7505. $receipt = new receipt ();
  7506. if (! empty ( $rid )) {
  7507. $rLRes = $receipt->find ( array (
  7508. '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,
  7509. 'asArray' => true
  7510. ) );
  7511. if(!empty($rLRes)){
  7512. Doo::loadClass ( 'XDeode' );
  7513. $XDeode = new XDeode ( 7 );
  7514. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7515. echo json_encode ( array (
  7516. 'status' => 1,
  7517. 'receipt' => $rLRes [0]
  7518. ) );
  7519. die ();
  7520. }else{
  7521. echo json_encode ( array (
  7522. 'status' => 1,
  7523. 'receipt' => array ()
  7524. ) );
  7525. die ();
  7526. }
  7527. }
  7528. echo json_encode ( array (
  7529. 'status' => 0,
  7530. 'receipt' => array ()
  7531. ) );
  7532. die ();
  7533. }
  7534. /*
  7535. * 废弃
  7536. */
  7537. function myReceipt() {
  7538. // all approval past withdraw
  7539. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7540. if (empty ( $item ))
  7541. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7542. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7543. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7544. Doo::loadModel ( 'receipt' );
  7545. $receipt = new receipt ();
  7546. // pre-loaded
  7547. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7548. // have cache
  7549. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7550. if (! empty ( $moth )) // yearPage
  7551. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7552. $this->showCache ( $path );
  7553. }
  7554. Doo::loadModel ( 'L_category' );
  7555. $Lcategory = new L_category ();
  7556. Doo::loadModel ( 'verify' );
  7557. Doo::loadModel ( 'statistics' );
  7558. $statistics = new statistics ();
  7559. $verify = new verify ();
  7560. Doo::loadModel ( 'staff' );
  7561. $staff = new staff ();
  7562. $condition = " and status!=0 ";
  7563. if ($item == "approval")
  7564. $condition = " and status=2 ";
  7565. elseif ($item == "withdraw")
  7566. $condition = " and status=3 ";
  7567. elseif ($item == "past")
  7568. $condition = " and status=1 ";
  7569. elseif ($item == "whdw")
  7570. $condition = " and status=4 ";
  7571. $dateCondition = " and Year(date) =" . $year;
  7572. if (! empty ( $moth )) {
  7573. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7574. $stList = $statistics->getOne ( array (
  7575. 'select' => 'rePrice ,agPrice',
  7576. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7577. 'asArray' => true
  7578. ) );
  7579. } else
  7580. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7581. if (empty ( $stList ))
  7582. $stList = array (
  7583. 'rePrice' => 0,
  7584. 'agPrice' => 0
  7585. );
  7586. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7587. $data ['stList'] = array (
  7588. 'rePrice' => $stList ['rePrice'],
  7589. 'agPrice' => $stList ['agPrice'],
  7590. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7591. );
  7592. $receiptList = $receipt->find ( array (
  7593. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7594. 'desc' => 'rid',
  7595. 'asArray' => true
  7596. ) );
  7597. $Locate = 0;
  7598. $roleId = 0;
  7599. $button = 0;
  7600. foreach ( $receiptList as $key => $value ) {
  7601. $receiptList [$key] ['Locate'] = $Locate;
  7602. $Locate ++;
  7603. $receiptList [$key] ['reviseDetail'] = array ();
  7604. if (! empty ( $value ['reviseDetail'] ))
  7605. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7606. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7607. $categoryDetil = $Lcategory->getOne ( array (
  7608. 'where' => 'cid=' . $value ['cid'],
  7609. 'asArray' => true
  7610. ) );
  7611. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7612. // 检测编辑状态
  7613. $verifyList = $verify->getOne ( array (
  7614. 'where' => 'vid=' . $value ['verify'],
  7615. 'asArray' => true
  7616. ) );
  7617. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7618. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7619. Doo::loadModel ( 'role' );
  7620. $role = new role ();
  7621. $flag = true;
  7622. $roleKey = 0;
  7623. $endStaffArray = array ();
  7624. $roleArrayCopy = array ();
  7625. foreach ( $verifyList as $k => $v ) {
  7626. // init verifyStaff
  7627. if ($v [1] == 'ROLE') {
  7628. if (! empty ( $verifyStaff )) {
  7629. $endStaffArray = end ( $verifyStaff );
  7630. // if ($v[0]==$endStaffArray['nextStaff']){
  7631. // $roleId=$v[0];
  7632. // }
  7633. }
  7634. $roleVerify = json_decode ( $v [3], true );
  7635. $roleKey = $k;
  7636. $roleArray = array ();
  7637. $rolename = $role->getOne ( array (
  7638. 'where' => 'rid=' . $v [0],
  7639. 'asArray' => true
  7640. ) );
  7641. foreach ( $roleVerify as $o => $p ) {
  7642. $staffID = explode ( '_', $p );
  7643. $staffInfo = $staff->getOne ( array (
  7644. 'where' => 'sid=' . $staffID [0],
  7645. 'asArray' => true
  7646. ) );
  7647. // print_r($staffID);
  7648. $exp = array (
  7649. 0 => $staffInfo ['sid'],
  7650. 1 => $staffID [1],
  7651. 2 => $staffInfo ['avatar'],
  7652. 'date' => '',
  7653. 'date' => '',
  7654. 'opinion' => '',
  7655. 'status' => '',
  7656. 'rolename' => $rolename ['name']
  7657. );
  7658. array_push ( $roleArray, $exp );
  7659. }
  7660. $roleArrayCopy [$v [0]] = $roleArray;
  7661. // $verifyList[$k]['roleArray']=$roleArray;
  7662. }
  7663. $verifyList [$k] ['date'] = "";
  7664. $verifyList [$k] ['opinion'] = "";
  7665. $verifyList [$k] ['status'] = "";
  7666. if (empty ( $verifyStaff )) {
  7667. $verifyList [$k] ['date'] = "";
  7668. $verifyList [$k] ['opinion'] = "";
  7669. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7670. $verifyList [$k] ['status'] = 4;
  7671. $flag = false;
  7672. }
  7673. } else {
  7674. foreach ( $verifyStaff as $m => $u ) {
  7675. if ($v [0] == $m) {
  7676. $verifyList [$k] ['date'] = $u ['date'];
  7677. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7678. $verifyList [$k] ['status'] = $u ['status'];
  7679. $flag = false;
  7680. break;
  7681. }
  7682. }
  7683. $endStaffArray = end ( $verifyStaff );
  7684. if (isset ( $endStaffArray ['ROLE'] )) {
  7685. } else {
  7686. // $endKey=key($verifyStaff);
  7687. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7688. // $button=4;
  7689. // $verifyList[$k]['status']=4;
  7690. // }
  7691. }
  7692. }
  7693. }
  7694. $rolename ['name'] = '';
  7695. if (! empty ( $roleId )) {
  7696. Doo::loadModel ( 'role' );
  7697. $role = new role ();
  7698. $rolename = $role->getOne ( array (
  7699. 'where' => 'rid=' . $roleId,
  7700. 'asArray' => true
  7701. ) );
  7702. }
  7703. if (! empty ( $verifyStaff ))
  7704. $endStaffArray = end ( $verifyStaff );
  7705. $KOP = false;
  7706. foreach ( $roleArrayCopy as $P => $A ) {
  7707. foreach ( $A as $MKI => $AVL ) {
  7708. if (! empty ( $verifyStaff )) {
  7709. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7710. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7711. $button = 4;
  7712. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7713. }
  7714. foreach ( $verifyStaff as $m => $u ) {
  7715. $AVLFK = $AVL [0] . '_R';
  7716. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7717. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7718. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7719. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7720. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7721. break;
  7722. }
  7723. }
  7724. } else {
  7725. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7726. $button = 4;
  7727. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7728. }
  7729. }
  7730. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7731. $KOP = true;
  7732. }
  7733. }
  7734. foreach ( $roleArrayCopy as $k => $v ) {
  7735. foreach ( $verifyList as $m => $n ) {
  7736. if ($n [0] == $k) {
  7737. array_splice ( $verifyList, $m, 1, $v );
  7738. }
  7739. }
  7740. }
  7741. $receiptList [$key] ['verifyList'] = $verifyList;
  7742. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7743. 'where' => 'sid=' . $value ['staff'],
  7744. 'asArray' => true
  7745. ) );
  7746. $receiptList [$key] ['button'] = $button;
  7747. }
  7748. // print_r($receiptList);die;
  7749. $mothHtml = "";
  7750. for($i = 1; $i <= 12; $i ++) {
  7751. if ($moth == $i)
  7752. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7753. else
  7754. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7755. }
  7756. $data ['mothHtml'] = $mothHtml;
  7757. $data ['receiptList'] = $receiptList;
  7758. $data ['memu'] = "receipt";
  7759. $data ['staff'] = $this->staff;
  7760. $data ['receiptMemu'] = 'receipt';
  7761. $data ['verifyId'] = $this->verifyId;
  7762. $data ['executeId'] = $this->executeId;
  7763. $data ['item'] = $item;
  7764. $data ['year'] = $year;
  7765. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7766. // sufficient condition to generate cache
  7767. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7768. $receiptList = $receipt->find ( array (
  7769. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7770. 'asArray' => true
  7771. ) );
  7772. if (empty ( $receiptList )) { // generated files
  7773. ob_start ();
  7774. $this->render ( "/admin/saea_myList", $data );
  7775. $this->cacheFile ( $path );
  7776. die ();
  7777. // $content = ob_get_contents();
  7778. // $fp = fopen($path, "w");
  7779. // fwrite($fp, $content);
  7780. // fclose($fp);
  7781. }
  7782. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7783. $receiptList = $receipt->find ( array (
  7784. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7785. 'asArray' => true
  7786. ) );
  7787. if (empty ( $receiptList )) { // generated files
  7788. ob_start ();
  7789. $this->render ( "/admin/saea_myList", $data );
  7790. $this->cacheFile ( $path );
  7791. die ();
  7792. }
  7793. }
  7794. }
  7795. $this->render ( "/admin/saea_myList", $data );
  7796. }
  7797. function approvedReceipt() {
  7798. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7799. Doo::loadModel ( 'receipt' );
  7800. Doo::loadModel ( 'receiptDetail' );
  7801. $receipt = new receipt ();
  7802. $receiptDetail = new receiptDetail ();
  7803. Doo::loadModel ( 'statistics' );
  7804. Doo::loadModel ( 'itemStatistics' );
  7805. $statistics = new statistics ();
  7806. $itemStatistics = new itemStatistics ();
  7807. Doo::loadModel ( "verify" );
  7808. $verify = new verify ();
  7809. // 审批状态的判定
  7810. $receiptDetailList = $receipt->getOne ( array (
  7811. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7812. 'asArray' => true
  7813. ) );
  7814. if (empty ( $receiptDetailList ))
  7815. return "/saeaBorad";
  7816. $verifyDetail = $verify->getOne ( array (
  7817. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7818. 'asArray' => true
  7819. ) );
  7820. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7821. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7822. $nowStaff = "";
  7823. $nowStaffList = array ();
  7824. if ($verifyDetail [0] [1] == 'ROLE') {
  7825. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7826. foreach ( $vStaffString as $key => $value ) {
  7827. $staffK = explode ( "_", $value );
  7828. array_push ( $nowStaffList, $staffK [0] );
  7829. }
  7830. $nowStaff = implode ( ',', $nowStaffList );
  7831. } else {
  7832. $nowStaff = $verifyDetail [0] [0];
  7833. }
  7834. $receipt->nowStaff = $nowStaff;
  7835. }
  7836. // echo $nowStaff;
  7837. // print_r($verifyDetail);die;
  7838. $receipt->rid = $receiptDetailList ['rid'];
  7839. $receipt->date = date ( "Y-m-d" );
  7840. $receipt->status = 2;
  7841. $receipt->update ();
  7842. $receiptDetail->status = 2;
  7843. $receiptDetail->update ( array (
  7844. 'where' => 'rid=' . $receiptDetailList ['rid']
  7845. ) );
  7846. Doo::loadModel ( "receiptLog" );
  7847. $receiptLog = new receiptLog ();
  7848. Doo::loadModel ( "verify" );
  7849. $verify = new verify ();
  7850. $receiptInfo = $receipt->getOne ( array (
  7851. 'where' => 'rid=' . $rid,
  7852. 'asArray' => true
  7853. ) );
  7854. $vr = $verify->getOne ( array (
  7855. 'where' => 'vid=' . $receiptInfo ['verify'],
  7856. 'asArray' => true
  7857. ) );
  7858. $jd = json_decode ( $vr ['staff'] );
  7859. $roleId = 0;
  7860. foreach ( $jd as $key => $value ) {
  7861. if ($value [1] == 'ROLE') {
  7862. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7863. if ($pos !== false) {
  7864. $roleId = $value [0];
  7865. }
  7866. }
  7867. }
  7868. // 审批日志
  7869. // echo $roleId;die;
  7870. if (! empty ( $roleId )) {
  7871. Doo::loadModel ( "role" );
  7872. $role = new role ();
  7873. $roleInfo = $role->getOne ( array (
  7874. 'where' => 'rid=' . $roleId,
  7875. 'asArray' => true
  7876. ) );
  7877. // $receiptLog->rolename = $roleInfo ['name'];
  7878. }
  7879. $receiptLog->username = $this->staff [0] ['username'];
  7880. $receiptLog->uid = $this->staff [0] ['sid'];
  7881. $receiptLog->date = date ( "Y-m-d" );
  7882. $receiptLog->opinion = '提交审批';
  7883. $receiptLog->img = $this->staff [0] ['avatar'];
  7884. $receiptLog->status = 2;
  7885. $receiptLog->rid = $rid;
  7886. $receiptLog->insert ();
  7887. // statistics item
  7888. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7889. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7890. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7891. $stat = $statistics->getOne ( array (
  7892. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7893. 'asArray' => true
  7894. ) );
  7895. if (empty ( $stat )) {
  7896. $statistics->date = date ( "Y-m-d" );
  7897. $statistics->cid = $this->staff [0] ['cid'];
  7898. $statistics->staff = $this->staff [0] ['sid'];
  7899. $statistics->agPrice = 0;
  7900. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7901. $statistics->insert ();
  7902. } else {
  7903. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7904. $statistics->update ( array (
  7905. 'where' => 'sid=' . $stat ['sid']
  7906. ) );
  7907. }
  7908. return "/expenses";
  7909. }
  7910. function approval() {
  7911. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7912. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7913. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7914. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7915. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7916. if (empty ( $status ))
  7917. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7918. $vidList = array ();
  7919. $button = 0;
  7920. Doo::loadModel ( 'verify' );
  7921. $verify = new verify ();
  7922. Doo::loadModel ( 'receipt' );
  7923. $receipt = new receipt ();
  7924. Doo::loadModel ( 'staff' );
  7925. $staff = new staff ();
  7926. Doo::loadModel ( 'L_category' );
  7927. $Lcategory = new L_category ();
  7928. // user verify ID
  7929. $verifyDetail = $verify->find ( array (
  7930. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7931. 'asArray' => true
  7932. ) );
  7933. foreach ( $verifyDetail as $key => $value ) {
  7934. array_push ( $vidList, $value ['vid'] );
  7935. }
  7936. $vid = implode ( ",", $vidList );
  7937. if (empty ( $verifyDetail ))
  7938. $vid = 0;
  7939. /*
  7940. */
  7941. $dateCondition = " and Year(date) =" . $year;
  7942. if (! empty ( $month ))
  7943. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7944. $categoryList = $Lcategory->find ( array (
  7945. 'asArray' => true
  7946. ) );
  7947. $staffList = $staff->find ( array (
  7948. 'where' => 'cid=' . $cid,
  7949. 'asArray' => true
  7950. ) );
  7951. $cateCondition = "";
  7952. $staffCondition = "";
  7953. $approvalCondition = "";
  7954. if (! empty ( $cid ))
  7955. $cateCondition = ' and cid=' . $cid;
  7956. if (! empty ( $sid )) {
  7957. $staffCondition = ' and staff=' . $sid;
  7958. $cateCondition = "";
  7959. }
  7960. // elseif($status==1){
  7961. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7962. // }
  7963. if ($status == 2) {
  7964. // 查找角色审批人
  7965. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7966. }
  7967. $ap = "";
  7968. if ($status == 4) {
  7969. $ap = 4;
  7970. $status = 2;
  7971. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7972. }
  7973. if ($status == 5) {
  7974. $status = 4;
  7975. $ap = 5;
  7976. }
  7977. // echo $vid;
  7978. // get Receipt By verifyID status 2 .$approvalCondition
  7979. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7980. $receiptList = $receipt->find ( array (
  7981. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7982. 'desc' => 'rid',
  7983. 'asArray' => true
  7984. ) );
  7985. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7986. $Locate = 0;
  7987. if ($ap == 4)
  7988. $status = 4;
  7989. elseif ($ap == 5)
  7990. $status = 5;
  7991. foreach ( $receiptList as $key => $value ) {
  7992. $receiptList [$key] ['Locate'] = $Locate;
  7993. $Locate ++;
  7994. $receiptList [$key] ['reviseDetail'] = array ();
  7995. if (! empty ( $value ['reviseDetail'] ))
  7996. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7997. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7998. $categoryDetil = $Lcategory->getOne ( array (
  7999. 'where' => 'cid=' . $value ['cid'],
  8000. 'asArray' => true
  8001. ) );
  8002. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8003. $verifyList = $verify->getOne ( array (
  8004. 'where' => 'vid=' . $value ['verify'],
  8005. 'asArray' => true
  8006. ) );
  8007. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8008. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8009. foreach ( $verifyList as $k => $v ) {
  8010. // init verifyStaff
  8011. $verifyList [$k] ['date'] = "";
  8012. $verifyList [$k] ['opinion'] = "";
  8013. $verifyList [$k] ['status'] = "";
  8014. if (empty ( $verifyStaff )) {
  8015. $verifyList [$k] ['date'] = "";
  8016. $verifyList [$k] ['opinion'] = "";
  8017. if ($v [0] == $this->staff [0] ['sid']) {
  8018. $verifyList [$k] ['status'] = 4;
  8019. $button = 4;
  8020. }
  8021. } else {
  8022. $flag = true;
  8023. foreach ( $verifyStaff as $m => $u ) {
  8024. if ($v [0] == $m) {
  8025. $verifyList [$k] ['date'] = $u ['date'];
  8026. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8027. $verifyList [$k] ['status'] = $u ['status'];
  8028. $flag = false;
  8029. break;
  8030. }
  8031. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  8032. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  8033. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  8034. }
  8035. if ($flag) { // 检测可编辑
  8036. if ($v [0] == $this->staff [0] ['sid']) {
  8037. $verifyList [$k] ['status'] = 4;
  8038. $button = 4;
  8039. }
  8040. }
  8041. }
  8042. }
  8043. $receiptList [$key] ['verifyList'] = $verifyList;
  8044. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8045. 'where' => 'sid=' . $value ['staff'],
  8046. 'asArray' => true
  8047. ) );
  8048. $receiptList [$key] ['button'] = $button;
  8049. }
  8050. // print_r($receiptList);die;
  8051. // $data['verifyDetail']=$verifyDetail;
  8052. $mothHtml = "";
  8053. for($i = 1; $i <= 12; $i ++) {
  8054. if ($month == $i)
  8055. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8056. else
  8057. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8058. }
  8059. $data ['mothHtml'] = $mothHtml;
  8060. $data ['receiptList'] = $receiptList;
  8061. $data ['receiptApprovalCount'] = count ( $receiptList );
  8062. $data ['status'] = $status;
  8063. $data ['year'] = $year;
  8064. $data ['categoryList'] = $categoryList;
  8065. $data ['staffList'] = $staffList;
  8066. $data ['cid'] = $cid;
  8067. $data ['sid'] = $sid;
  8068. $data ['ap'] = $ap;
  8069. $data ['memu'] = "receipt";
  8070. $data ['staff'] = $this->staff;
  8071. $data ['receiptMemu'] = 'approval';
  8072. $data ['verifyId'] = $this->verifyId;
  8073. $data ['executeId'] = $this->executeId;
  8074. $this->render ( "/admin/saea_reportList", $data );
  8075. }
  8076. function approvalDetails() {
  8077. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8078. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8079. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8080. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8081. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8082. Doo::loadModel ( 'verify' );
  8083. $verify = new verify ();
  8084. Doo::loadModel ( 'receipt' );
  8085. $receipt = new receipt ();
  8086. Doo::loadModel ( 'staff' );
  8087. $staff = new staff ();
  8088. Doo::loadModel ( 'L_category' );
  8089. $Lcategory = new L_category ();
  8090. Doo::loadModel ( 'enclosur' );
  8091. $enclosur = new enclosur ();
  8092. $vidList = array ();
  8093. $verifyDetail = $verify->find ( array (
  8094. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8095. 'asArray' => true
  8096. ) );
  8097. foreach ( $verifyDetail as $key => $value ) {
  8098. array_push ( $vidList, $value ['vid'] );
  8099. }
  8100. $vid = implode ( ",", $vidList );
  8101. if (empty ( $verifyDetail ))
  8102. $vid = 0;
  8103. $categoryList = $Lcategory->find ( array (
  8104. 'asArray' => true
  8105. ) );
  8106. $staffList = $staff->find ( array (
  8107. 'where' => 'cid=' . $cid,
  8108. 'asArray' => true
  8109. ) );
  8110. $ap = 0;
  8111. $receiptList = $receipt->find ( array (
  8112. 'where' => 'rid =' . $rid,
  8113. 'desc' => 'rid',
  8114. 'asArray' => true
  8115. ) );
  8116. $Locate = 0;
  8117. $roleId = 0;
  8118. $button = 0;
  8119. foreach ( $receiptList as $key => $value ) {
  8120. $receiptList [$key] ['Locate'] = $Locate;
  8121. $Locate ++;
  8122. $receiptList [$key] ['reviseDetail'] = array ();
  8123. if (! empty ( $value ['reviseDetail'] ))
  8124. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8125. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8126. $categoryDetil = $Lcategory->getOne ( array (
  8127. 'where' => 'cid=' . $value ['cid'],
  8128. 'asArray' => true
  8129. ) );
  8130. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8131. // 检测编辑状态
  8132. $verifyList = $verify->getOne ( array (
  8133. 'where' => 'vid=' . $value ['verify'],
  8134. 'asArray' => true
  8135. ) );
  8136. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8137. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8138. Doo::loadModel ( 'role' );
  8139. $role = new role ();
  8140. // print_r($verifyList);
  8141. $flag = true;
  8142. $roleKey = 0;
  8143. $endStaffArray = array ();
  8144. $roleArrayCopy = array ();
  8145. foreach ( $verifyList as $k => $v ) {
  8146. // init verifyStaff
  8147. if ($v [1] == 'ROLE') {
  8148. if (! empty ( $verifyStaff )) {
  8149. $endStaffArray = end ( $verifyStaff );
  8150. if ($v [0] == $endStaffArray ['nextStaff']) {
  8151. $roleId = $v [0];
  8152. }
  8153. }
  8154. $roleVerify = json_decode ( $v [3], true );
  8155. $roleKey = $k;
  8156. $roleArray = array ();
  8157. $rolename = $role->getOne ( array (
  8158. 'where' => 'rid=' . $v [0],
  8159. 'asArray' => true
  8160. ) );
  8161. foreach ( $roleVerify as $o => $p ) {
  8162. $staffID = explode ( '_', $p );
  8163. $staffInfo = $staff->getOne ( array (
  8164. 'where' => 'sid=' . $staffID [0],
  8165. 'asArray' => true
  8166. ) );
  8167. // print_r($staffID);
  8168. $exp = array (
  8169. 0 => $staffInfo ['sid'],
  8170. 1 => $staffID [1],
  8171. 2 => $staffInfo ['avatar'],
  8172. 'date' => '',
  8173. 'date' => '',
  8174. 'opinion' => '',
  8175. 'status' => '',
  8176. 'rolename' => $rolename ['name']
  8177. );
  8178. array_push ( $roleArray, $exp );
  8179. }
  8180. $roleArrayCopy [$v [0]] = $roleArray;
  8181. // $verifyList[$k]['roleArray']=$roleArray;
  8182. }
  8183. // print_r($roleArray);
  8184. $verifyList [$k] ['date'] = "";
  8185. $verifyList [$k] ['opinion'] = "";
  8186. $verifyList [$k] ['status'] = "";
  8187. if (empty ( $verifyStaff )) {
  8188. $verifyList [$k] ['date'] = "";
  8189. $verifyList [$k] ['opinion'] = "";
  8190. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8191. $verifyList [$k] ['status'] = 4;
  8192. $button = 4;
  8193. $flag = false;
  8194. }
  8195. } else {
  8196. foreach ( $verifyStaff as $m => $u ) {
  8197. if ($v [0] == $m) {
  8198. $verifyList [$k] ['date'] = $u ['date'];
  8199. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8200. $verifyList [$k] ['status'] = $u ['status'];
  8201. $flag = false;
  8202. break;
  8203. }
  8204. }
  8205. $endStaffArray = end ( $verifyStaff );
  8206. if (isset ( $endStaffArray ['ROLE'] )) {
  8207. } else {
  8208. $endKey = key ( $verifyStaff );
  8209. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8210. $button = 4;
  8211. $verifyList [$k] ['status'] = 4;
  8212. }
  8213. }
  8214. }
  8215. }
  8216. $rolename ['name'] = '';
  8217. if (! empty ( $roleId )) {
  8218. Doo::loadModel ( 'role' );
  8219. $role = new role ();
  8220. $rolename = $role->getOne ( array (
  8221. 'where' => 'rid=' . $roleId,
  8222. 'asArray' => true
  8223. ) );
  8224. }
  8225. if (! empty ( $verifyStaff ))
  8226. $endStaffArray = end ( $verifyStaff );
  8227. $KOP = false;
  8228. foreach ( $roleArrayCopy as $P => $A ) {
  8229. foreach ( $A as $MKI => $AVL ) {
  8230. if (! empty ( $verifyStaff )) {
  8231. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8232. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8233. $button = 4;
  8234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8235. }
  8236. foreach ( $verifyStaff as $m => $u ) {
  8237. $AVLFK = $AVL [0] . '_R';
  8238. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8239. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8240. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8241. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8242. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8243. break;
  8244. }
  8245. }
  8246. } else {
  8247. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8248. $button = 4;
  8249. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8250. }
  8251. }
  8252. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8253. $KOP = true;
  8254. }
  8255. }
  8256. foreach ( $roleArrayCopy as $k => $v ) {
  8257. foreach ( $verifyList as $m => $n ) {
  8258. if ($n [0] == $k) {
  8259. array_splice ( $verifyList, $m, 1, $v );
  8260. }
  8261. }
  8262. }
  8263. $receiptList [$key] ['verifyList'] = $verifyList;
  8264. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8265. 'where' => 'sid=' . $value ['staff'],
  8266. 'asArray' => true
  8267. ) );
  8268. $receiptList [$key] ['button'] = $button;
  8269. }
  8270. $mothHtml = "";
  8271. for($i = 1; $i <= 12; $i ++) {
  8272. if ($month == $i)
  8273. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8274. else
  8275. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8276. }
  8277. // 获取审批日志
  8278. Doo::loadModel ( 'receiptLog' );
  8279. $receiptLog = new receiptLog ();
  8280. $rlList = array ();
  8281. $rlInfo = $receiptLog->getOne ( array (
  8282. 'where' => 'rid=' . $rid . ' and status=4',
  8283. 'asArray' => true
  8284. ) );
  8285. $tijdate = $receiptLog->getOne ( array (
  8286. 'where' => 'rid=' . $rid . ' and status=2',
  8287. 'asc' => 'rlid',
  8288. 'asArray' => true
  8289. ) );
  8290. if (! empty ( $rlInfo )) {
  8291. $rlList = $receiptLog->find ( array (
  8292. 'where' => 'rid=' . $rid,
  8293. 'asc' => 'rlid',
  8294. 'asArray' => true
  8295. ) );
  8296. }
  8297. $receiptList [0] ['rlList'] = $rlList;
  8298. $enclosurList = $enclosur->find ( array (
  8299. 'where' => 'rid=' . $rid,
  8300. 'asArray' => true
  8301. ) );
  8302. $enclosurHtml = '';
  8303. foreach ( $enclosurList as $value ) {
  8304. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8305. }
  8306. $data ['enclosurHtml'] = $enclosurHtml;
  8307. $data ['rolename'] = $rolename ['name'];
  8308. $data ['datetij'] = $tijdate ['date'];
  8309. $data ['mothHtml'] = $mothHtml;
  8310. $data ['receiptList'] = $receiptList;
  8311. $data ['receiptApprovalCount'] = count ( $receiptList );
  8312. $data ['year'] = $year;
  8313. $data ['categoryList'] = $categoryList;
  8314. $data ['staffList'] = $staffList;
  8315. $data ['cid'] = $cid;
  8316. $data ['sid'] = $sid;
  8317. $data ['status'] = 0;
  8318. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  8319. $ap = 4;
  8320. } else
  8321. $data ['status'] = $receiptList [0] ['status'];
  8322. if ($receiptList [0] ['status'] == 4) {
  8323. $data ['status'] = 5;
  8324. $ap = 0;
  8325. }
  8326. $data ['ap'] = $ap;
  8327. $data ['memu'] = "receipt";
  8328. $data ['staff'] = $this->staff;
  8329. $data ['receiptMemu'] = 'approval';
  8330. $data ['verifyId'] = $this->verifyId;
  8331. $data ['executeId'] = $this->executeId;
  8332. $this->render ( "/admin/saeaReportListReport", $data );
  8333. }
  8334. function approvalEdi() {
  8335. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8336. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  8337. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8338. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8339. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8340. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  8341. if (empty ( $status ))
  8342. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  8343. $vidList = array ();
  8344. $button = 0;
  8345. Doo::loadModel ( 'verify' );
  8346. Doo::loadModel ( 'receipt' );
  8347. Doo::loadModel ( 'staff' );
  8348. $staff = new staff ();
  8349. $receipt = new receipt ();
  8350. $verify = new verify ();
  8351. Doo::loadModel ( 'L_category' );
  8352. $Lcategory = new L_category ();
  8353. Doo::loadModel ( 'enclosur' );
  8354. $enclosur = new enclosur ();
  8355. // user verify ID
  8356. $verifyDetail = $verify->find ( array (
  8357. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  8358. 'asArray' => true
  8359. ) );
  8360. foreach ( $verifyDetail as $key => $value ) {
  8361. array_push ( $vidList, $value ['vid'] );
  8362. }
  8363. $vid = implode ( ",", $vidList );
  8364. if (empty ( $verifyDetail ))
  8365. $vid = 0;
  8366. $categoryList = $Lcategory->find ( array (
  8367. 'asArray' => true
  8368. ) );
  8369. $staffList = $staff->find ( array (
  8370. 'where' => 'cid=' . $cid,
  8371. 'asArray' => true
  8372. ) );
  8373. $ap = "";
  8374. if ($status == 4) {
  8375. $ap = 4;
  8376. $status = 2;
  8377. }
  8378. // get Receipt By verifyID status 2
  8379. $receiptList = $receipt->find ( array (
  8380. 'where' => 'rid =' . $rid,
  8381. 'desc' => 'rid',
  8382. 'asArray' => true
  8383. ) );
  8384. $Locate = 0;
  8385. $roleId = 0;
  8386. if ($ap == 4)
  8387. $status = 4;
  8388. foreach ( $receiptList as $key => $value ) {
  8389. $receiptList [$key] ['Locate'] = $Locate;
  8390. $Locate ++;
  8391. $receiptList [$key] ['reviseDetail'] = array ();
  8392. if (! empty ( $value ['reviseDetail'] ))
  8393. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  8394. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  8395. $categoryDetil = $Lcategory->getOne ( array (
  8396. 'where' => 'cid=' . $value ['cid'],
  8397. 'asArray' => true
  8398. ) );
  8399. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  8400. // 检测编辑状态
  8401. $verifyList = $verify->getOne ( array (
  8402. 'where' => 'vid=' . $value ['verify'],
  8403. 'asArray' => true
  8404. ) );
  8405. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  8406. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  8407. // print_r($verifyList);
  8408. //
  8409. // if (empty($verifyStaff)){
  8410. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8411. // $verifyList[0]['status']=4;$button=4;
  8412. // }
  8413. //
  8414. // }else{
  8415. //
  8416. // }
  8417. // die;
  8418. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  8419. // echo array_search("green",$a);
  8420. //
  8421. Doo::loadModel ( 'role' );
  8422. $role = new role ();
  8423. // print_r($verifyList);
  8424. $flag = true;
  8425. $roleKey = 0;
  8426. $endStaffArray = array ();
  8427. $roleArrayCopy = array ();
  8428. foreach ( $verifyList as $k => $v ) {
  8429. // init verifyStaff
  8430. if ($v [1] == 'ROLE') {
  8431. if (! empty ( $verifyStaff )) {
  8432. $endStaffArray = end ( $verifyStaff );
  8433. if ($v [0] == $endStaffArray ['nextStaff']) {
  8434. $roleId = $v [0];
  8435. }
  8436. }
  8437. $roleVerify = json_decode ( $v [3], true );
  8438. $roleKey = $k;
  8439. $roleArray = array ();
  8440. $rolename = $role->getOne ( array (
  8441. 'where' => 'rid=' . $v [0],
  8442. 'asArray' => true
  8443. ) );
  8444. foreach ( $roleVerify as $o => $p ) {
  8445. $staffID = explode ( '_', $p );
  8446. $staffInfo = $staff->getOne ( array (
  8447. 'where' => 'sid=' . $staffID [0],
  8448. 'asArray' => true
  8449. ) );
  8450. // print_r($staffID);
  8451. $exp = array (
  8452. 0 => $staffInfo ['sid'],
  8453. 1 => $staffID [1],
  8454. 2 => $staffInfo ['avatar'],
  8455. 'date' => '',
  8456. 'date' => '',
  8457. 'opinion' => '',
  8458. 'status' => '',
  8459. 'rolename' => $rolename ['name']
  8460. );
  8461. array_push ( $roleArray, $exp );
  8462. }
  8463. $roleArrayCopy [$v [0]] = $roleArray;
  8464. // $verifyList[$k]['roleArray']=$roleArray;
  8465. }
  8466. // print_r($roleArray);
  8467. $verifyList [$k] ['date'] = "";
  8468. $verifyList [$k] ['opinion'] = "";
  8469. $verifyList [$k] ['status'] = "";
  8470. if (empty ( $verifyStaff )) {
  8471. $verifyList [$k] ['date'] = "";
  8472. $verifyList [$k] ['opinion'] = "";
  8473. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8474. $verifyList [$k] ['status'] = 4;
  8475. $button = 4;
  8476. $flag = false;
  8477. }
  8478. } else {
  8479. foreach ( $verifyStaff as $m => $u ) {
  8480. if ($v [0] == $m) {
  8481. $verifyList [$k] ['date'] = $u ['date'];
  8482. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8483. $verifyList [$k] ['status'] = $u ['status'];
  8484. $flag = false;
  8485. break;
  8486. }
  8487. }
  8488. $endStaffArray = end ( $verifyStaff );
  8489. if (isset ( $endStaffArray ['ROLE'] )) {
  8490. } else {
  8491. $endKey = key ( $verifyStaff );
  8492. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8493. $button = 4;
  8494. $verifyList [$k] ['status'] = 4;
  8495. }
  8496. }
  8497. // print_r($endStaffArray);die;
  8498. // if (empty($verifyStaff)){
  8499. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8500. // $verifyList[$k]['status']=4;$button=4;
  8501. // }
  8502. //
  8503. // }else{
  8504. //
  8505. // }
  8506. // if($flag){//检测可编辑
  8507. // if($v[0]==$this->staff[0]['sid']){
  8508. // $verifyList[$k]['status']=4;$button=4;
  8509. // }
  8510. // }
  8511. }
  8512. }
  8513. $rolename ['name'] = '';
  8514. if (! empty ( $roleId )) {
  8515. Doo::loadModel ( 'role' );
  8516. $role = new role ();
  8517. $rolename = $role->getOne ( array (
  8518. 'where' => 'rid=' . $roleId,
  8519. 'asArray' => true
  8520. ) );
  8521. }
  8522. if (! empty ( $verifyStaff ))
  8523. $endStaffArray = end ( $verifyStaff );
  8524. $KOP = false;
  8525. foreach ( $roleArrayCopy as $P => $A ) {
  8526. foreach ( $A as $MKI => $AVL ) {
  8527. if (! empty ( $verifyStaff )) {
  8528. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8529. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8530. $button = 4;
  8531. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8532. }
  8533. foreach ( $verifyStaff as $m => $u ) {
  8534. $AVLFK = $AVL [0] . '_R';
  8535. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8536. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8537. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8538. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8539. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8540. break;
  8541. }
  8542. }
  8543. } else {
  8544. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8545. $button = 4;
  8546. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8547. }
  8548. }
  8549. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8550. $KOP = true;
  8551. }
  8552. }
  8553. // print_r($roleArrayCopy);
  8554. // echo $roleKey;
  8555. foreach ( $roleArrayCopy as $k => $v ) {
  8556. foreach ( $verifyList as $m => $n ) {
  8557. if ($n [0] == $k) {
  8558. array_splice ( $verifyList, $m, 1, $v );
  8559. }
  8560. }
  8561. }
  8562. // if ($KOP)
  8563. // array_splice($verifyList,$roleKey,1,$roleArray);
  8564. // print_r($verifyList);
  8565. $receiptList [$key] ['verifyList'] = $verifyList;
  8566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8567. 'where' => 'sid=' . $value ['staff'],
  8568. 'asArray' => true
  8569. ) );
  8570. $receiptList [$key] ['button'] = $button;
  8571. }
  8572. // $data['verifyDetail']=$verifyDetail;
  8573. $mothHtml = "";
  8574. for($i = 1; $i <= 12; $i ++) {
  8575. if ($month == $i)
  8576. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8577. else
  8578. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8579. }
  8580. // 获取审批日志
  8581. Doo::loadModel ( 'receiptLog' );
  8582. $receiptLog = new receiptLog ();
  8583. $rlList = array ();
  8584. $rlInfo = $receiptLog->getOne ( array (
  8585. 'where' => 'rid=' . $rid . ' and status=4',
  8586. 'asArray' => true
  8587. ) );
  8588. $tijdate = $receiptLog->getOne ( array (
  8589. 'where' => 'rid=' . $rid . ' and status=2',
  8590. 'asc' => 'rlid',
  8591. 'asArray' => true
  8592. ) );
  8593. if (! empty ( $rlInfo )) {
  8594. $rlList = $receiptLog->find ( array (
  8595. 'where' => 'rid=' . $rid,
  8596. 'asc' => 'rlid',
  8597. 'asArray' => true
  8598. ) );
  8599. }
  8600. $receiptList [0] ['rlList'] = $rlList;
  8601. $enclosurList = $enclosur->find ( array (
  8602. 'where' => 'rid=' . $rid,
  8603. 'asArray' => true
  8604. ) );
  8605. $enclosurHtml = '';
  8606. foreach ( $enclosurList as $value ) {
  8607. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8608. }
  8609. $data ['enclosurHtml'] = $enclosurHtml;
  8610. $data ['rolename'] = $rolename ['name'];
  8611. $data ['datetij'] = $tijdate ['date'];
  8612. $data ['mothHtml'] = $mothHtml;
  8613. $data ['receiptList'] = $receiptList;
  8614. $data ['receiptApprovalCount'] = count ( $receiptList );
  8615. $data ['status'] = $status;
  8616. $data ['year'] = $year;
  8617. $data ['categoryList'] = $categoryList;
  8618. $data ['staffList'] = $staffList;
  8619. $data ['cid'] = $cid;
  8620. $data ['sid'] = $sid;
  8621. $data ['ap'] = $ap;
  8622. $data ['memu'] = "receipt";
  8623. $data ['staff'] = $this->staff;
  8624. $data ['receiptMemu'] = 'approval';
  8625. $data ['verifyId'] = $this->verifyId;
  8626. $data ['executeId'] = $this->executeId;
  8627. $this->render ( "/admin/saeaReportListReport", $data );
  8628. }
  8629. function remittanceHky() {
  8630. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8631. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8632. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8633. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8634. $page_size = 15;
  8635. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8636. Doo::loadModel ( 'receipt' );
  8637. $receipt = new receipt ();
  8638. Doo::loadModel ( 'staff' );
  8639. $staff = new staff ();
  8640. $dateCondition = " and Year(executeDate) =" . $year;
  8641. if ($moth != 'MONTH')
  8642. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8643. if ($day != 'DAY' && $moth != 'MONTH')
  8644. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8645. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8646. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8647. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8648. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8649. $dayList = $receipt->find ( array (
  8650. 'select' => 'executeDate,sum(amount) as amount',
  8651. 'where' => $sql,
  8652. 'desc' => 'executeDate',
  8653. 'groupby' => 'executeDate',
  8654. 'limit' => $limit,
  8655. 'asArray' => true
  8656. ) );
  8657. // print_r($dayList);
  8658. foreach ( $dayList as $key => $value ) {
  8659. $remitString = "";
  8660. $receiptList = $receipt->find ( array (
  8661. 'select' => 'rid,executeDate,amount,staff,cid',
  8662. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8663. 'desc' => 'executeDate',
  8664. 'asArray' => true
  8665. ) );
  8666. foreach ( $receiptList as $k => $v ) {
  8667. $sinfo = $staff->getOne ( array (
  8668. 'select' => 'username,category',
  8669. 'where' => ' sid=' . $v ['staff'],
  8670. 'asArray' => true
  8671. ) );
  8672. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8673. }
  8674. $dayList [$key] ['staff'] = $remitString;
  8675. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8676. }
  8677. // print_r($dayList);
  8678. $mothHtml = "";
  8679. for($i = 1; $i <= 12; $i ++) {
  8680. if ($moth == $i)
  8681. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8682. else
  8683. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8684. }
  8685. $dayHtml = "";
  8686. if ($day != "DAY" || $moth != "MONTH") {
  8687. for($i = 1; $i <= 31; $i ++) {
  8688. if ($day == $i)
  8689. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8690. else
  8691. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8692. }
  8693. }
  8694. $dateHtml = "";
  8695. $now = date ( "Y" );
  8696. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8697. if ($YEARD <= $now) {
  8698. $dateHtml .= '<option ';
  8699. if ($year == $YEARD) {
  8700. $dateHtml .= 'selected ';
  8701. }
  8702. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8703. }
  8704. }
  8705. $data ['dateHtml'] = $dateHtml;
  8706. $data ['page'] = $pageinfo;
  8707. $data ['year'] = $year;
  8708. $data ['moth'] = $moth;
  8709. $data ['day'] = $day;
  8710. $data ['get'] = $get;
  8711. $data ['dayHtml'] = $dayHtml;
  8712. $data ['mothHtml'] = $mothHtml;
  8713. $data ['receiptList'] = $dayList;
  8714. $data ['memu'] = "receipt";
  8715. $data ['staff'] = $this->staff;
  8716. $data ['receiptMemu'] = 'remittanceHky';
  8717. $data ['verifyId'] = $this->verifyId;
  8718. $data ['executeId'] = $this->executeId;
  8719. $this->render ( "/admin/remittanceHky", $data );
  8720. }
  8721. function remittancep() {
  8722. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8723. Doo::loadModel ( 'receipt' );
  8724. $receipt = new receipt ();
  8725. Doo::loadModel ( 'staff' );
  8726. $staff = new staff ();
  8727. Doo::loadClass ( 'XDeode' );
  8728. $XDeode = new XDeode ( 5 );
  8729. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8730. $rplist = $receipt->find ( array (
  8731. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8732. 'asArray' => true
  8733. ) );
  8734. $dayList = $receipt->find ( array (
  8735. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8736. 'desc' => 'executeDate',
  8737. 'groupby' => 'staff',
  8738. 'asArray' => true
  8739. ) );
  8740. $html = '';
  8741. foreach ( $dayList as $key => $value ) {
  8742. $sinfo = $staff->getOne ( array (
  8743. 'select' => 'username,category',
  8744. 'where' => ' sid=' . $value ['staff'],
  8745. 'asArray' => true
  8746. ) );
  8747. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8748. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8749. $au = 0;
  8750. foreach ( $rplist as $k => $v ) {
  8751. if ($value ['staff'] == $v ['staff']) {
  8752. $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>';
  8753. $au += $v ['amount'];
  8754. }
  8755. }
  8756. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8757. }
  8758. $data ['html'] = $html;
  8759. $data ['memu'] = "receipt";
  8760. $data ['staff'] = $this->staff;
  8761. $data ['receiptMemu'] = 'remittanceHky';
  8762. $data ['verifyId'] = $this->verifyId;
  8763. $data ['executeId'] = $this->executeId;
  8764. $this->render ( "/admin/remittancep", $data );
  8765. }
  8766. function ajaxGetReceiptDetails() {
  8767. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8768. Doo::loadClass ( 'XDeode' );
  8769. $XDeode = new XDeode ( 5 );
  8770. $rid = $XDeode->decode ( $rid );
  8771. if (empty ( $rid )) {
  8772. echo json_encode ( array (
  8773. 'status' => 2,
  8774. 'msg' => 'illegal request'
  8775. ) );
  8776. die ();
  8777. }
  8778. Doo::loadModel ( 'receipt' );
  8779. $receipt = new receipt ();
  8780. Doo::loadModel ( 'staff' );
  8781. $staff = new staff ();
  8782. $rinfo = $receipt->getOne ( array (
  8783. 'where' => 'rid= ' . $rid,
  8784. 'asArray' => true
  8785. ) );
  8786. $sinfo = $staff->getOne ( array (
  8787. 'select' => 'username,category',
  8788. 'where' => ' sid=' . $rinfo ['staff'],
  8789. 'asArray' => true
  8790. ) );
  8791. $rinfo ['reviseDetail'] = array ();
  8792. if (! empty ( $rinfo ['reviseDetail'] ))
  8793. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8794. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8795. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8796. $rinfo ['category'] = $sinfo ['category'];
  8797. $verifyStaff = array ();
  8798. if (! empty ( $rinfo ['verifyStaff'] ))
  8799. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8800. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8801. $rinfo ['relust'] = $relust;
  8802. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8803. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8804. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8805. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8806. // 费用执行人相关数据
  8807. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8808. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8809. foreach ( $executeCopy as $k => $v ) {
  8810. $executeCopy [$k] ['date'] = '';
  8811. $executeCopy [$k] ['opinion'] = '';
  8812. $executeCopy [$k] ['status'] = '';
  8813. if (! empty ( $executeStaff ))
  8814. foreach ( $executeStaff as $m => $u ) {
  8815. if ($v [0] == $m) {
  8816. $executeCopy [$k] ['date'] = $u ['date'];
  8817. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8818. $executeCopy [$k] ['status'] = $u ['status'];
  8819. break;
  8820. }
  8821. }
  8822. }
  8823. $rinfo ['executeCopy'] = $executeCopy;
  8824. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8825. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8826. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8827. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8828. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8829. $html .= '<tr><th>' . $value ['name'] . '</th>
  8830. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8831. }
  8832. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8833. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8834. <tr><th class="taC" colspan="2">费用说明</th>
  8835. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8836. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8837. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8838. </tbody></table>';
  8839. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8840. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8841. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8842. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8843. $html .= '<tr><th>' . $value ['name'] . '</th>
  8844. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8845. }
  8846. $html .= '<tr><th class="taR">合计</th>
  8847. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8848. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8849. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8850. $html .= '<tr><th>' . $value ['name'] . '</th>
  8851. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8852. }
  8853. $html .= '<tr><th class="taR">合计</th>
  8854. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8855. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8856. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8857. $html .= '<tr><th>' . $value ['name'] . '</th>
  8858. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8859. }
  8860. $html .= '<tr><th class="taR">合计</th>
  8861. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8862. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8863. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8864. $html .= '<tr><th>' . $value ['name'] . '</th>
  8865. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8866. }
  8867. $html .= '<tr><th class="taR">合计</th>
  8868. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8869. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8870. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8871. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8872. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8873. }
  8874. $html .= '<tr><th class="taR">合计</th>
  8875. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8876. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8877. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8878. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8879. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8880. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8881. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8882. <tr';
  8883. if ($rinfo ['relust'] >= 0) {
  8884. $html .= 'class="success"';
  8885. } else {
  8886. $html .= 'class="error"';
  8887. }
  8888. $html .= '><td class="taR"><b>借款结余</b></td>
  8889. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8890. </tbody></table>
  8891. ';
  8892. }
  8893. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8894. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8895. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8896. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8897. $html .= '<tr><th>' . $value ['name'] . '</th>
  8898. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8899. }
  8900. $html .= '<tr><th class="taR">合计</th>
  8901. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8902. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8903. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8904. <tr><th class="taC" colspan="2">费用说明</th>
  8905. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8906. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8907. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8908. </tbody></table>';
  8909. } else {
  8910. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8911. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8912. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8913. $html .= '<tr><th>' . $value ['name'] . '</th>
  8914. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8915. }
  8916. $html .= '<tr><th class="taR">合计</th>
  8917. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8918. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8919. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8920. $html .= '<tr><th>' . $value ['name'] . '</th>
  8921. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8922. }
  8923. $html .= '<tr><th class="taR">合计</th>
  8924. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8925. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8926. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8927. $html .= '<tr><th>' . $value ['name'] . '</th>
  8928. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8929. }
  8930. $html .= '<tr><th class="taR">合计</th>
  8931. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8932. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8933. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8934. $html .= '<tr><th>' . $value ['name'] . '</th>
  8935. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8936. }
  8937. $html .= '<tr><th class="taR">合计</th>
  8938. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8939. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8940. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8941. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8942. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8943. }
  8944. $html .= '<tr><th class="taR">合计</th>
  8945. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8946. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8947. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8948. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8949. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8950. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8951. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8952. $html .= '</tbody></table>';
  8953. /*
  8954. * <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>
  8955. */
  8956. }
  8957. // print_r($verifyStaff);die;
  8958. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8959. foreach ( $verifyStaff as $key => $value ) {
  8960. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8961. $sinfo = $staff->getOne ( array (
  8962. 'select' => 'username',
  8963. 'where' => ' sid=' . $key,
  8964. 'asArray' => true
  8965. ) );
  8966. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8967. }
  8968. $html .= '</tbody></table>';
  8969. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8970. foreach ( $rinfo ['executeCopy'] as $value ) {
  8971. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8972. }
  8973. $html .= '</tbody></table>';
  8974. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8975. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8976. </tr></table>';
  8977. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8978. echo json_encode ( array (
  8979. 'status' => 1,
  8980. 'html' => $html
  8981. ) );
  8982. die ();
  8983. }
  8984. /**
  8985. * 删除附件
  8986. */
  8987. function ajaxRemEnclousur() {
  8988. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8989. if (empty ( $key ))
  8990. echo json_encode ( array (
  8991. 'status' => 2
  8992. ) );
  8993. Doo::loadModel ( 'enclosur' );
  8994. $enclosur = new enclosur ();
  8995. $enclosur->delEnclosurByEid ( $key );
  8996. echo json_encode ( array (
  8997. 'status' => 1
  8998. ) );
  8999. }
  9000. function remittance() {
  9001. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9002. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9003. Doo::loadModel ( 'receipt' );
  9004. $receipt = new receipt ();
  9005. Doo::loadModel ( 'staff' );
  9006. $staff = new staff ();
  9007. $dateCondition = " and Year(pastDate) =" . $year;
  9008. if (! empty ( $month ))
  9009. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  9010. // get Receipt By verifyID status 1
  9011. $receiptList = $receipt->find ( array (
  9012. 'select' => 'sum(sum) as sum,staff,pastDate',
  9013. 'where' => ' status=1' . $dateCondition,
  9014. 'desc' => 'pastDate',
  9015. 'groupby' => 'staff,pastDate',
  9016. 'asArray' => true
  9017. ) );
  9018. $dateList = $receipt->find ( array (
  9019. 'select' => 'pastDate,verifyStaff',
  9020. 'where' => ' status=1' . $dateCondition,
  9021. 'desc' => 'pastDate',
  9022. 'groupby' => 'pastDate',
  9023. 'asArray' => true
  9024. ) );
  9025. $dataList = array ();
  9026. foreach ( $dateList as $d => $a ) {
  9027. $dataList [$a ['pastDate']] = array ();
  9028. $daySum = 0;
  9029. foreach ( $receiptList as $key => $value ) {
  9030. if ($a ['pastDate'] == $value ['pastDate']) {
  9031. $oderList = $receipt->find ( array (
  9032. 'select' => 'receiptOrder',
  9033. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  9034. 'asArray' => true
  9035. ) );
  9036. $list = array ();
  9037. $html = "";
  9038. foreach ( $oderList as $v ) {
  9039. array_push ( $list, $v ['receiptOrder'] );
  9040. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  9041. }
  9042. $receiptList [$key] ['receiptOrder'] = $html;
  9043. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  9044. $sinfo = $staff->getOne ( array (
  9045. 'select' => 'username ',
  9046. 'where' => ' sid=' . $value ['staff'],
  9047. 'asArray' => true
  9048. ) );
  9049. $receiptList [$key] ['username'] = $sinfo ['username'];
  9050. $daySum += $value ['sum'];
  9051. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  9052. }
  9053. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  9054. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  9055. }
  9056. }
  9057. // print_r($dataList);
  9058. $data ['dataList'] = $dataList;
  9059. $mothHtml = "";
  9060. for($i = 1; $i <= 12; $i ++) {
  9061. if ($month == $i)
  9062. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9063. else
  9064. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9065. }
  9066. $data ['year'] = $year;
  9067. $data ['mothHtml'] = $mothHtml;
  9068. $data ['memu'] = "receipt";
  9069. $data ['staff'] = $this->staff;
  9070. $data ['receiptMemu'] = 'approval';
  9071. $data ['verifyId'] = $this->verifyId;
  9072. $data ['executeId'] = $this->executeId;
  9073. $this->render ( "/admin/saeaReportListPay", $data );
  9074. }
  9075. /**
  9076. * 金额调整,提高稳定性
  9077. * @return string
  9078. */
  9079. function revocationAdjustment() {
  9080. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  9081. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  9082. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  9083. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  9084. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  9085. Doo::loadClass ( 'XDeode' );
  9086. $XDeode = new XDeode ( 5 );
  9087. Doo::loadModel ( 'receipt' );
  9088. $receipt = new receipt ();
  9089. $sid = $XDeode->decode ( $sidKey );
  9090. $rid = $XDeode->decode ( $ridKey );
  9091. $reviseKey = $XDeode->decode ( $reviseKey );
  9092. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  9093. die ( 'illegal request' );
  9094. $receiptDetail = $receipt->getOne ( array (
  9095. 'where' => 'rid=' . $rid,
  9096. 'asArray' => true
  9097. ) );
  9098. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  9099. die ( 'illegal request' );
  9100. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9101. if (! isset ( $reviseDetail [$reviseKey] ))
  9102. die ( 'illegal request' );
  9103. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  9104. unset ( $reviseDetail [$reviseKey] );
  9105. $revisePrice = 0;
  9106. foreach ( $reviseDetail as $key => $value ) {
  9107. $revisePrice += $value ['price'];
  9108. }
  9109. $reviseDetailString = json_encode ( $reviseDetail );
  9110. $receipt->reviseDetail = $reviseDetailString;
  9111. $receipt->sum = $receiptDetail ['sum'] - $price;
  9112. $receipt->revisePrice = $revisePrice;
  9113. $receipt->update ( array (
  9114. 'where' => 'rid=' . $rid
  9115. ) );
  9116. return '/receiptburEdi/' . $rid;
  9117. } else
  9118. die ( 'illegal request2' );
  9119. }
  9120. function updateApprovalReceipt() {
  9121. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9122. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9123. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9124. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  9125. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  9126. if (! empty ( $rid )) {
  9127. Doo::loadModel ( "verify" );
  9128. $verify = new verify ();
  9129. Doo::loadModel ( "receiptDetail" );
  9130. $receiptDetailObj = new receiptDetail ();
  9131. Doo::loadModel ( "itemStatistics" );
  9132. Doo::loadModel ( "statistics" );
  9133. $statistics = new statistics ();
  9134. $itemStatistics = new itemStatistics ();
  9135. Doo::loadModel ( "receipt" );
  9136. $receipt = new receipt ();
  9137. $receiptDetail = $receipt->getOne ( array (
  9138. 'where' => 'rid=' . $rid . ' and status=2 ',
  9139. 'asArray' => true
  9140. ) );
  9141. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  9142. $nsflag = true;
  9143. foreach ( $nslist as $value ) {
  9144. if ($value == $this->staff ['0'] ['sid']) {
  9145. $nsflag = false;
  9146. break;
  9147. }
  9148. }
  9149. if (empty ( $receiptDetail ) || $nsflag)
  9150. return "/approvalExpenses/pendApproval";
  9151. $verifyDetail = $verify->getOne ( array (
  9152. 'where' => ' vid =' . $receiptDetail ['verify'],
  9153. 'asArray' => true
  9154. ) );
  9155. $verifyString = $verifyDetail ['staff'];
  9156. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  9157. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  9158. if (empty ( $opinion )) {
  9159. if ($status == 3)
  9160. $opinion = "终止";
  9161. else
  9162. $opinion = "同意支付";
  9163. }
  9164. $nowStaff = 0;
  9165. $nowStaffList = array ();
  9166. if (empty ( $verifyStaff )) {
  9167. // 还需加入是否已经进入角色审批
  9168. if ($verifyDetail [0] [1] == 'ROLE') {
  9169. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  9170. foreach ( $vStaffString as $key => $value ) {
  9171. $staffK = explode ( "_", $value );
  9172. if ($staffK [0] != $this->staff [0] ['sid'])
  9173. array_push ( $nowStaffList, $staffK [0] );
  9174. }
  9175. // print_r($verifyDetail);
  9176. // die;
  9177. if (! empty ( $nowStaffList )) {
  9178. $nowStaff = implode ( ',', $nowStaffList );
  9179. $verifyStaff = array (
  9180. $this->staff [0] ['sid'] . "_R" => array (
  9181. 'date' => date ( 'Y-m-d' ),
  9182. 'opinion' => $opinion,
  9183. 'status' => $status,
  9184. 'nextStaff' => $verifyDetail [0] [0],
  9185. 'ROLE' => 1
  9186. )
  9187. );
  9188. } else {
  9189. $nowStaff = $verifyDetail [1] [0];
  9190. $verifyStaff = array (
  9191. $this->staff [0] ['sid'] . "_R" => array (
  9192. 'date' => date ( 'Y-m-d' ),
  9193. 'opinion' => $opinion,
  9194. 'status' => $status,
  9195. 'nextStaff' => $verifyDetail [1] [0]
  9196. )
  9197. );
  9198. }
  9199. } else {
  9200. if ($verifyDetail [1] [1] == 'ROLE') {
  9201. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  9202. // echo "dd";
  9203. foreach ( $vStaffString as $key => $value ) {
  9204. $staffK = explode ( "_", $value );
  9205. array_push ( $nowStaffList, $staffK [0] );
  9206. }
  9207. $nowStaff = implode ( ',', $nowStaffList );
  9208. $verifyStaff = array (
  9209. $this->staff [0] ['sid'] => array (
  9210. 'date' => date ( 'Y-m-d' ),
  9211. 'opinion' => $opinion,
  9212. 'status' => $status,
  9213. 'nextStaff' => $verifyDetail [1] [0],
  9214. 'ROLE' => 1
  9215. )
  9216. );
  9217. } else {
  9218. $nowStaff = $verifyDetail [1] [0];
  9219. $verifyStaff = array (
  9220. $this->staff [0] ['sid'] => array (
  9221. 'date' => date ( 'Y-m-d' ),
  9222. 'opinion' => $opinion,
  9223. 'status' => $status,
  9224. 'nextStaff' => $verifyDetail [1] [0]
  9225. )
  9226. );
  9227. }
  9228. }
  9229. if ($status == 3)
  9230. $verifyStaff = array (
  9231. 'final' => $status,
  9232. $this->staff [0] ['sid'] => array (
  9233. 'date' => date ( 'Y-m-d' ),
  9234. 'opinion' => $opinion,
  9235. 'status' => $status
  9236. )
  9237. );
  9238. $vStaffString = json_encode ( $verifyStaff );
  9239. $receipt->nowStaff = $nowStaff;
  9240. $receipt->verifyStaff = $vStaffString;
  9241. } else {
  9242. $VS = end ( $verifyStaff );
  9243. // 非角色审批
  9244. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  9245. $nextStaff = 0;
  9246. $roleSTF = false;
  9247. foreach ( $verifyDetail as $key => $value ) {
  9248. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  9249. if (isset ( $verifyDetail [$key + 1] )) {
  9250. $nextStaff = $verifyDetail [$key + 1] [0];
  9251. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  9252. $roleSTF = true;
  9253. }
  9254. break;
  9255. }
  9256. }
  9257. if (! $roleSTF) {
  9258. $nowStaff = $nextStaff;
  9259. $verifyStaff [$this->staff [0] ['sid']] = array (
  9260. 'date' => date ( 'Y-m-d' ),
  9261. 'opinion' => $opinion,
  9262. 'status' => $status,
  9263. 'nextStaff' => $nextStaff
  9264. );
  9265. } else {
  9266. // 获取角色下的所有用户ID
  9267. $nowStaffList = array ();
  9268. foreach ( $verifyDetail as $vfk ) {
  9269. if ($vfk [1] == 'ROLE') {
  9270. $vStaffString = json_decode ( $vfk [3] );
  9271. foreach ( $vStaffString as $key => $value ) {
  9272. $staffK = explode ( "_", $value );
  9273. array_push ( $nowStaffList, $staffK [0] );
  9274. }
  9275. }
  9276. }
  9277. $nowStaff = implode ( ',', $nowStaffList );
  9278. $verifyStaff [$this->staff [0] ['sid']] = array (
  9279. 'date' => date ( 'Y-m-d' ),
  9280. 'opinion' => $opinion,
  9281. 'status' => $status,
  9282. 'nextStaff' => $nextStaff,
  9283. 'ROLE' => 0
  9284. );
  9285. }
  9286. if ($status == 3) {
  9287. $verifyStaff ['final'] = $status;
  9288. $verifyStaff [$this->staff [0] ['sid']] = array (
  9289. 'date' => date ( 'Y-m-d' ),
  9290. 'opinion' => $opinion,
  9291. 'status' => $status
  9292. );
  9293. }
  9294. $vStaffString = json_encode ( $verifyStaff );
  9295. $receipt->nowStaff = $nowStaff;
  9296. $receipt->verifyStaff = $vStaffString;
  9297. }
  9298. // 角色审批
  9299. if (isset ( $VS ['ROLE'] )) {
  9300. // 找出角色人 当前审批角色组
  9301. $verifyJSStaff = array ();
  9302. $nowStaffList2 = array ();
  9303. foreach ( $verifyDetail as $key => $value ) {
  9304. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  9305. $verifyJSStaff = json_decode ( $value [3] );
  9306. foreach ( $verifyJSStaff as $m ) {
  9307. $staffK = explode ( "_", $m );
  9308. array_push ( $nowStaffList2, $staffK [0] );
  9309. }
  9310. // print_r($nowStaffList2);
  9311. }
  9312. }
  9313. $RoleVerifyStaff = array ();
  9314. foreach ( $verifyStaff as $key => $value ) {
  9315. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  9316. foreach ( $nowStaffList2 as $m ) {
  9317. if ($key == $m . "_R")
  9318. $RoleVerifyStaff [$key] = $value;
  9319. }
  9320. }
  9321. }
  9322. // print_r($verifyStaff);
  9323. // print_r($nowStaffList2);
  9324. // print_r($RoleVerifyStaff);
  9325. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  9326. // print_r($verifyJSStaff);
  9327. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  9328. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  9329. // 下一个审批人ID
  9330. $nextStaff = 0;
  9331. $falg = false;
  9332. foreach ( $verifyDetail as $key => $value ) {
  9333. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  9334. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  9335. $falg = true;
  9336. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  9337. $nowStaffList = array ();
  9338. foreach ( $vStaffString as $v ) {
  9339. $staffK = explode ( "_", $v );
  9340. array_push ( $nowStaffList, $staffK [0] );
  9341. }
  9342. $nowStaff = implode ( ',', $nowStaffList );
  9343. $nextStaff = $verifyDetail [$key + 1] [0];
  9344. } elseif (isset ( $verifyDetail [$key + 1] )) {
  9345. $nextStaff = $verifyDetail [$key + 1] [0];
  9346. $nowStaff = $nextStaff;
  9347. } else
  9348. $nowStaff = '';
  9349. break;
  9350. }
  9351. }
  9352. if ($falg)
  9353. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9354. 'date' => date ( 'Y-m-d' ),
  9355. 'opinion' => $opinion,
  9356. 'status' => $status,
  9357. 'nextStaff' => $nextStaff,
  9358. 'ROLE' => 1
  9359. );
  9360. else
  9361. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9362. 'date' => date ( 'Y-m-d' ),
  9363. 'opinion' => $opinion,
  9364. 'status' => $status,
  9365. 'nextStaff' => $nextStaff
  9366. );
  9367. // print_r($verifyStaff);
  9368. // echo $nowStaff;die;
  9369. } else { // 进入下一个角色或者审批人
  9370. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  9371. //
  9372. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  9373. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  9374. 'date' => date ( 'Y-m-d' ),
  9375. 'opinion' => $opinion,
  9376. 'status' => $status,
  9377. 'nextStaff' => $VS ['nextStaff'],
  9378. 'ROLE' => 1
  9379. );
  9380. // print_r($verifyStaff);
  9381. // die;
  9382. }
  9383. if ($status == 3) {
  9384. $verifyStaff ['final'] = $status;
  9385. $verifyStaff [$this->staff [0] ['sid']] = array (
  9386. 'date' => date ( 'Y-m-d' ),
  9387. 'opinion' => $opinion,
  9388. 'status' => $status
  9389. );
  9390. }
  9391. $vStaffString = json_encode ( $verifyStaff );
  9392. $receipt->verifyStaff = $vStaffString;
  9393. $receipt->nowStaff = $nowStaff;
  9394. // die;
  9395. // }
  9396. // print_r($verifyStaff);
  9397. // die;
  9398. }
  9399. // print_r($verifyStaff);die;
  9400. }
  9401. // print_r($verifyDetail);
  9402. $roleKey = 0;
  9403. $roleId = 0;
  9404. $verifyDetailCopy = array ();
  9405. foreach ( $verifyDetail as $k => $v ) {
  9406. if ($v [1] == 'ROLE') {
  9407. $roleId = $v [0];
  9408. $roleVerify = json_decode ( $v [3], true );
  9409. $roleKey = $k;
  9410. $roleArray = array ();
  9411. foreach ( $roleVerify as $o => $p ) {
  9412. $staffID = explode ( '_', $p );
  9413. $exp = array (
  9414. 0 => $staffID [0],
  9415. 1 => $staffID [1]
  9416. );
  9417. array_push ( $roleArray, $exp );
  9418. }
  9419. $verifyDetailCopy [$v [0]] = $roleArray;
  9420. }
  9421. }
  9422. // print_r($verifyDetail);
  9423. foreach ( $verifyDetailCopy as $k => $v ) {
  9424. foreach ( $verifyDetail as $m => $n ) {
  9425. if ($n [0] == $k) {
  9426. array_splice ( $verifyDetail, $m, 1, $v );
  9427. }
  9428. }
  9429. }
  9430. // die;
  9431. // if (!empty($roleArray))
  9432. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  9433. // echo $roleId;
  9434. // print_r($verifyStaff);
  9435. // print_r($verifyDetail);
  9436. // die;
  9437. Doo::loadModel ( "receiptLog" );
  9438. $receiptLog = new receiptLog ();
  9439. // 审批日志
  9440. if (! isset ( $verifyStaff ['final'] )) {
  9441. if (! empty ( $roleId )) {
  9442. Doo::loadModel ( "role" );
  9443. $role = new role ();
  9444. $roleInfo = $role->getOne ( array (
  9445. 'where' => 'rid=' . $roleId,
  9446. 'asArray' => true
  9447. ) );
  9448. $receiptLog->rolename = $roleInfo ['name'];
  9449. }
  9450. $receiptLog->username = $this->staff [0] ['username'];
  9451. $receiptLog->uid = $this->staff [0] ['sid'];
  9452. $receiptLog->date = date ( "Y-m-d" );
  9453. $receiptLog->opinion = $opinion;
  9454. $receiptLog->img = $this->staff [0] ['avatar'];
  9455. $receiptLog->status = 1;
  9456. $receiptLog->rid = $rid;
  9457. $receiptLog->insert ();
  9458. }
  9459. if (isset ( $verifyStaff ['final'] )) { // rDetail
  9460. $receipt->verifyBreakup = $verifyString;
  9461. $receipt->status = 3;
  9462. $receiptDetailObj->status = 3;
  9463. $receiptDetailObj->update ( array (
  9464. 'where' => 'rid=' . $rid
  9465. ) );
  9466. if (! empty ( $roleId )) {
  9467. Doo::loadModel ( "role" );
  9468. $role = new role ();
  9469. $roleInfo = $role->getOne ( array (
  9470. 'where' => 'rid=' . $roleId,
  9471. 'asArray' => true
  9472. ) );
  9473. $receiptLog->rolename = $roleInfo ['name'];
  9474. }
  9475. $receiptLog->username = $this->staff [0] ['username'];
  9476. $receiptLog->uid = $this->staff [0] ['sid'];
  9477. $receiptLog->date = date ( "Y-m-d" );
  9478. $receiptLog->opinion = $opinion;
  9479. $receiptLog->img = $this->staff [0] ['avatar'];
  9480. $receiptLog->status = 3;
  9481. $receiptLog->rid = $rid;
  9482. $receiptLog->insert ();
  9483. // 微信企业号通知
  9484. $this->setWXMsg ( $rid, 3 );
  9485. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9486. $receipt->status = 1;
  9487. $reviseSum = 0;
  9488. $receipt->verifyBreakup = $verifyString;
  9489. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9490. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9491. foreach ( $reviseDetail as $key => $value ) {
  9492. $receiptDetailObj = new receiptDetail ();
  9493. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9494. $receiptDetailObj->item = $value ['description'];
  9495. $receiptDetailObj->itemCategory = "报销金额调整";
  9496. $receiptDetailObj->price = $value ['price'];
  9497. $receiptDetailObj->date = $receiptDetail ['date'];
  9498. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9499. $receiptDetailObj->rid = $rid;
  9500. $receiptDetailObj->status = 1;
  9501. $receiptDetailObj->insert ();
  9502. $reviseSum += $value ['price'];
  9503. }
  9504. $itemStatistics = new itemStatistics ();
  9505. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9506. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9507. $itemStatistics->price = $reviseSum;
  9508. $itemStatistics->itemCategory = "报销金额调整";
  9509. $itemStatistics->date = $receiptDetail ['date'];
  9510. $itemStatistics->insert ();
  9511. }
  9512. $receiptDetailObj = new receiptDetail ();
  9513. $receiptDetailObj->status = 1;
  9514. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9515. $receiptDetailObj->update ( array (
  9516. 'where' => 'rid=' . $rid
  9517. ) );
  9518. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9519. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9520. $stat = $statistics->getOne ( array (
  9521. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9522. 'asArray' => true
  9523. ) );
  9524. if (empty ( $stat )) {
  9525. $statistics->date = $receiptDetail ['date'];
  9526. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9527. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9528. $statistics->agPrice = $receiptDetail ['sum'];
  9529. $statistics->rePrice = $reviseSum;
  9530. $statistics->insert ();
  9531. } else {
  9532. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9533. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9534. $statistics->update ( array (
  9535. 'where' => 'sid=' . $stat ['sid']
  9536. ) );
  9537. }
  9538. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9539. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9540. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9541. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9542. if ($key == "agencySum") {
  9543. $iStatistics = $itemStatistics->getOne ( array (
  9544. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9545. 'asArray' => true
  9546. ) );
  9547. if (empty ( $iStatistics )) {
  9548. $itemStatistics->cid = $receiptDetail ['cid'];
  9549. ;
  9550. $itemStatistics->staff = $receiptDetail ['staff'];
  9551. $itemStatistics->price = $value;
  9552. $itemStatistics->itemCategory = $this->AGENCY;
  9553. $itemStatistics->date = $receiptDetail ['date'];
  9554. $itemStatistics->insert ();
  9555. } else {
  9556. if (! empty ( $value )) {
  9557. $itemStatistics->price = $value + $iStatistics ['price'];
  9558. $itemStatistics->update ( array (
  9559. 'where' => 'sid=' . $iStatistics ['sid']
  9560. ) );
  9561. }
  9562. }
  9563. } elseif ($key == "travelSum") {
  9564. $iStatistics = $itemStatistics->getOne ( array (
  9565. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9566. 'asArray' => true
  9567. ) );
  9568. if (empty ( $iStatistics )) {
  9569. $itemStatistics->cid = $receiptDetail ['cid'];
  9570. $itemStatistics->staff = $receiptDetail ['staff'];
  9571. $itemStatistics->price = $value;
  9572. $itemStatistics->itemCategory = $this->TRAVEL;
  9573. $itemStatistics->date = $receiptDetail ['date'];
  9574. $itemStatistics->insert ();
  9575. } else {
  9576. if (! empty ( $value )) {
  9577. $itemStatistics->price = $value + $iStatistics ['price'];
  9578. $itemStatistics->update ( array (
  9579. 'where' => 'sid=' . $iStatistics ['sid']
  9580. ) );
  9581. }
  9582. }
  9583. } elseif ($key == "trainSum") {
  9584. $iStatistics = $itemStatistics->getOne ( array (
  9585. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9586. 'asArray' => true
  9587. ) );
  9588. if (empty ( $iStatistics )) {
  9589. $itemStatistics->cid = $receiptDetail ['cid'];
  9590. $itemStatistics->staff = $receiptDetail ['staff'];
  9591. $itemStatistics->price = $value;
  9592. $itemStatistics->itemCategory = $this->TRAIN;
  9593. $itemStatistics->date = $receiptDetail ['date'];
  9594. $itemStatistics->insert ();
  9595. } else {
  9596. if (! empty ( $value )) {
  9597. $itemStatistics->price = $value + $iStatistics ['price'];
  9598. $itemStatistics->update ( array (
  9599. 'where' => 'sid=' . $iStatistics ['sid']
  9600. ) );
  9601. }
  9602. }
  9603. } elseif ($key == "otherSum") {
  9604. $iStatistics = $itemStatistics->getOne ( array (
  9605. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9606. 'asArray' => true
  9607. ) );
  9608. if (empty ( $iStatistics )) {
  9609. $itemStatistics->cid = $receiptDetail ['cid'];
  9610. $itemStatistics->staff = $receiptDetail ['staff'];
  9611. $itemStatistics->price = $value;
  9612. $itemStatistics->itemCategory = $this->OTHER;
  9613. $itemStatistics->date = $receiptDetail ['date'];
  9614. $itemStatistics->insert ();
  9615. } else {
  9616. if (! empty ( $value )) {
  9617. $itemStatistics->price = $value + $iStatistics ['price'];
  9618. $itemStatistics->update ( array (
  9619. 'where' => 'sid=' . $iStatistics ['sid']
  9620. ) );
  9621. }
  9622. }
  9623. }
  9624. }
  9625. $receipt->pastDate = date ( "Y-m-d" );
  9626. // 微信企业号通知
  9627. $this->setWXMsg ( $rid, 1 );
  9628. }
  9629. //是否有流水
  9630. Doo::loadModel ( 'wasteBook' );
  9631. $wasteBook = new wasteBook ();
  9632. $accountType=3;
  9633. if ($receiptDetail['Rtype']==1){
  9634. $accountType=2;
  9635. }elseif($receiptDetail['Rtype']==2){
  9636. $accountType=4;
  9637. }
  9638. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9639. if (empty($wbDetail)){
  9640. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9641. $receipt->amount = $rsum;//$amount;
  9642. }
  9643. $receipt->update ( array (
  9644. 'where' => ' rid = ' . $rid
  9645. ) );
  9646. // 进入下一条审批费用新加需求
  9647. $vidList = array ();
  9648. $verifyDetail = $verify->find ( array (
  9649. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9650. 'asArray' => true
  9651. ) );
  9652. foreach ( $verifyDetail as $key => $value ) {
  9653. array_push ( $vidList, $value ['vid'] );
  9654. }
  9655. $vid = implode ( ",", $vidList );
  9656. if (empty ( $verifyDetail ))
  9657. $vid = 0;
  9658. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9659. $receipt = new receipt ();
  9660. $rd = $receipt->getOne ( array (
  9661. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9662. 'asc' => 'rid',
  9663. 'asArray' => true
  9664. ) );
  9665. if (empty ( $rd )) {
  9666. return '/approvalExpenses/pendApproval';
  9667. }
  9668. if ($rd ['Rtype'] == 1) {
  9669. if ($rd ['isBK'] == 1) {
  9670. return '/receiptburEdi/' . $rd ['rid'];
  9671. } else {
  9672. return '/expensesEdi/' . $rd ['rid'];
  9673. }
  9674. } elseif ($rd ['Rtype'] == 2) {
  9675. return '/remitApproval/' . $rd ['rid'];
  9676. } else {
  9677. return '/receiptburEdi/' . $rd ['rid'];
  9678. }
  9679. // return "/approvalExpenses/pendApproval";
  9680. }
  9681. }
  9682. function expensesRetreats() {
  9683. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9684. if (! empty ( $rid )) {
  9685. // 操作记录
  9686. Doo::loadModel ( "receipt" );
  9687. $receipt = new receipt ();
  9688. Doo::loadModel ( "receiptLog" );
  9689. $receiptLog = new receiptLog ();
  9690. Doo::loadModel ( "verify" );
  9691. $verify = new verify ();
  9692. $receiptInfo = $receipt->getOne ( array (
  9693. 'where' => 'rid=' . $rid,
  9694. 'asArray' => true
  9695. ) );
  9696. $vr = $verify->getOne ( array (
  9697. 'where' => 'vid=' . $receiptInfo ['verify'],
  9698. 'asArray' => true
  9699. ) );
  9700. $jd = json_decode ( $vr ['staff'] );
  9701. $roleId = 0;
  9702. foreach ( $jd as $key => $value ) {
  9703. if ($value [1] == 'ROLE') {
  9704. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9705. if ($pos !== false) {
  9706. $roleId = $value [0];
  9707. }
  9708. }
  9709. }
  9710. // 审批日志
  9711. // echo $roleId;die;
  9712. if (! empty ( $roleId )) {
  9713. Doo::loadModel ( "role" );
  9714. $role = new role ();
  9715. $roleInfo = $role->getOne ( array (
  9716. 'where' => 'rid=' . $roleId,
  9717. 'asArray' => true
  9718. ) );
  9719. $receiptLog->rolename = $roleInfo ['name'];
  9720. }
  9721. $receiptLog->username = $this->staff [0] ['username'];
  9722. $receiptLog->uid = $this->staff [0] ['sid'];
  9723. $receiptLog->date = date ( "Y-m-d" );
  9724. $receiptLog->opinion = '撤回';
  9725. $receiptLog->img = $this->staff [0] ['avatar'];
  9726. $receiptLog->status = 4;
  9727. $receiptLog->rid = $rid;
  9728. $receiptLog->insert ();
  9729. $receipt->status = 4;
  9730. $receipt->update ( array (
  9731. 'where' => 'rid=' . $rid
  9732. ) );
  9733. // 微信企业号通知
  9734. $this->setWXMsg ( $rid, 2 );
  9735. }
  9736. // echo "ddd";
  9737. return '/approvalExpenses/pendApproval';
  9738. }
  9739. function updateCheReceipt() {
  9740. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9741. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9742. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9743. if (! empty ( $rid )) {
  9744. // 操作记录
  9745. Doo::loadModel ( "receipt" );
  9746. $receipt = new receipt ();
  9747. Doo::loadModel ( "receiptLog" );
  9748. $receiptLog = new receiptLog ();
  9749. Doo::loadModel ( "verify" );
  9750. $verify = new verify ();
  9751. $receiptInfo = $receipt->getOne ( array (
  9752. 'where' => 'rid=' . $rid . ' and status=2',
  9753. 'asArray' => true
  9754. ) );
  9755. if (empty ( $receiptInfo )) {
  9756. echo json_encode ( array (
  9757. 'status' => 2
  9758. ) );
  9759. die ();
  9760. }
  9761. $vr = $verify->getOne ( array (
  9762. 'where' => 'vid=' . $receiptInfo ['verify'],
  9763. 'asArray' => true
  9764. ) );
  9765. $jd = json_decode ( $vr ['staff'] );
  9766. $roleId = 0;
  9767. foreach ( $jd as $key => $value ) {
  9768. if ($value [1] == 'ROLE') {
  9769. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9770. if ($pos !== false) {
  9771. $roleId = $value [0];
  9772. }
  9773. }
  9774. }
  9775. // 审批日志
  9776. // echo $roleId;die;
  9777. if (! empty ( $roleId )) {
  9778. Doo::loadModel ( "role" );
  9779. $role = new role ();
  9780. $roleInfo = $role->getOne ( array (
  9781. 'where' => 'rid=' . $roleId,
  9782. 'asArray' => true
  9783. ) );
  9784. $receiptLog->rolename = $roleInfo ['name'];
  9785. }
  9786. $receiptLog->username = $this->staff [0] ['username'];
  9787. $receiptLog->uid = $this->staff [0] ['sid'];
  9788. $receiptLog->date = date ( "Y-m-d" );
  9789. $receiptLog->opinion = $opinion;
  9790. $receiptLog->img = $this->staff [0] ['avatar'];
  9791. $receiptLog->status = 4;
  9792. $receiptLog->rid = $rid;
  9793. $receiptLog->insert ();
  9794. $receipt->status = 4;
  9795. $receipt->update ( array (
  9796. 'where' => 'rid=' . $rid
  9797. ) );
  9798. // 微信企业号通知
  9799. $this->setWXMsg ( $rid, 2 );
  9800. echo json_encode ( array (
  9801. 'status' => 1
  9802. ) );
  9803. // Header("HTTP/1.1 303 See Other");
  9804. // Header("Location: /approvalExpenses/pendApproval");
  9805. die ();
  9806. }
  9807. echo json_encode ( array (
  9808. 'status' => 2
  9809. ) );
  9810. die ();
  9811. // echo "ddd";
  9812. // return '/saeaBorad';
  9813. }
  9814. function revisePrice() {
  9815. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9816. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9817. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9818. // echo $price;die;
  9819. if (! empty ( $rid )) {
  9820. Doo::loadModel ( "receipt" );
  9821. $receipt = new receipt ();
  9822. $receiptDetail = $receipt->getOne ( array (
  9823. 'where' => 'rid=' . $rid . ' and status=2 ',
  9824. 'asArray' => true
  9825. ) );
  9826. if (empty ( $receiptDetail ))
  9827. die ( 'illegal request' );
  9828. $reviseDetail = array ();
  9829. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9830. array_push ( $reviseDetail, array (
  9831. 'sid' => $this->staff [0] ['sid'],
  9832. 'name' => $this->staff [0] ['username'],
  9833. 'description' => $description,
  9834. 'price' => $price
  9835. ) );
  9836. $reviseDetailString = json_encode ( $reviseDetail );
  9837. $receipt->reviseDetail = $reviseDetailString;
  9838. $receipt->revisePrice = $price;
  9839. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9840. } else {
  9841. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9842. array_push ( $reviseDetail, array (
  9843. 'sid' => $this->staff [0] ['sid'],
  9844. 'name' => $this->staff [0] ['username'],
  9845. 'description' => $description,
  9846. 'price' => $price
  9847. ) );
  9848. $reviseDetailString = json_encode ( $reviseDetail );
  9849. $receipt->reviseDetail = $reviseDetailString;
  9850. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9851. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9852. }
  9853. $receipt->update ( array (
  9854. 'where' => 'rid=' . $rid
  9855. ) );
  9856. if ($receiptDetail ['Rtype'] == 1) {
  9857. if ($receiptDetail ['isBK'] == 1) {
  9858. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9859. }
  9860. } elseif ($receiptDetail ['Rtype'] == 2) {
  9861. } else {
  9862. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9863. }
  9864. }
  9865. die ( 'illegal request' );
  9866. }
  9867. function personalCollect() {
  9868. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9869. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9870. $this->showCache ( $path );
  9871. Doo::loadModel ( "receiptDetail" );
  9872. Doo::loadModel ( "itemStatistics" );
  9873. Doo::loadModel ( 'statistics' );
  9874. $statistics = new statistics ();
  9875. $itemStatistics = new itemStatistics ();
  9876. $receiptDetail = new receiptDetail ();
  9877. $receiptCollectList = $receiptDetail->find ( array (
  9878. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9879. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9880. 'groupby' => 'itemCategory,Month(date)',
  9881. 'asArray' => true
  9882. ) );
  9883. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9884. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9885. 'asArray' => true
  9886. ) );
  9887. // create collect html
  9888. $collectArray = array (
  9889. '日常相关费用' => array (),
  9890. '差旅相关费用' => array (),
  9891. '培训班费用' => array (),
  9892. '其他' => array ()
  9893. );
  9894. $adjustment = array ();
  9895. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9896. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9897. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9898. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9899. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9900. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9901. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9902. array_push ( $collectArray ['其他'], $collectHtml );
  9903. $data ['collectArray'] = $collectArray;
  9904. // statistics html
  9905. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9906. if (empty ( $stList ))
  9907. $stList = array (
  9908. 'rePrice' => 0,
  9909. 'agPrice' => 0
  9910. );
  9911. $data ['stList'] = array (
  9912. 'rePrice' => $stList ['rePrice'],
  9913. 'agPrice' => $stList ['agPrice'],
  9914. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9915. );
  9916. // Adjustment price html
  9917. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9918. array_push ( $adjustment, $collectHtml );
  9919. $data ['adjustment'] = $adjustment;
  9920. // total price html
  9921. $collectHtml = "";
  9922. $total = 0;
  9923. for($i = 1; $i <= 12; $i ++) {
  9924. $sumPrice = 0;
  9925. foreach ( $receiptCollectList as $key => $value ) {
  9926. if ($value ['month'] == $i) {
  9927. $sumPrice += $value ['price'];
  9928. }
  9929. }
  9930. if ($sumPrice == 0)
  9931. $collectHtml .= '<td class="taR">-</td>';
  9932. else
  9933. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9934. $total += $sumPrice;
  9935. }
  9936. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9937. $data ['totalPrice'] = $collectHtml;
  9938. $dateHtml = "";
  9939. $now = date ( "Y" );
  9940. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9941. if ($YEARD <= $now) {
  9942. $dateHtml .= '<option ';
  9943. if ($year == $YEARD) {
  9944. $dateHtml .= 'selected ';
  9945. }
  9946. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9947. }
  9948. }
  9949. $data ['dateHtml'] = $dateHtml;
  9950. $data ['year'] = $year;
  9951. $data ['totalYear'] = $total;
  9952. $data ['memu'] = "receipt";
  9953. $data ['staff'] = $this->staff;
  9954. $data ['receiptMemu'] = 'personalCollect';
  9955. $data ['verifyId'] = $this->verifyId;
  9956. $data ['executeId'] = $this->executeId;
  9957. // year staff status 2,4
  9958. if ($year < date ( "Y" )) {
  9959. Doo::loadModel ( 'receipt' );
  9960. $receipt = new receipt ();
  9961. $receiptList = $receipt->find ( array (
  9962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9963. 'asArray' => true
  9964. ) );
  9965. if (empty ( $receiptList )) {
  9966. ob_start ();
  9967. $this->render ( "/admin/saea_slist_collect", $data );
  9968. $this->cacheFile ( $path );
  9969. die ();
  9970. }
  9971. }
  9972. $this->render ( "/admin/saea_slist_collect", $data );
  9973. }
  9974. function personalCollectDetail() {
  9975. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9976. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9977. $this->showCache ( $path );
  9978. Doo::loadModel ( "receiptDetail" );
  9979. Doo::loadModel ( "itemStatistics" );
  9980. Doo::loadModel ( 'statistics' );
  9981. Doo::loadModel ( 'accountItem' );
  9982. $accountItem = new accountItem ();
  9983. $statistics = new statistics ();
  9984. $itemStatistics = new itemStatistics ();
  9985. $receiptDetail = new receiptDetail ();
  9986. $receiptCollectList = $receiptDetail->find ( array (
  9987. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9988. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9989. 'groupby' => 'item,Month(date)',
  9990. 'asArray' => true
  9991. ) );
  9992. $accountList = $accountItem->find ( array (
  9993. 'asArray' => true
  9994. ) );
  9995. // create CollectDetail HTML
  9996. $collectHtml = array ();
  9997. foreach ( $accountList as $key => $value ) {
  9998. $html = "";
  9999. $asum = 0;
  10000. for($i = 1; $i <= 12; $i ++) {
  10001. $falg = true;
  10002. foreach ( $receiptCollectList as $v ) {
  10003. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10004. $asum += $v ['price'];
  10005. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10006. $falg = false;
  10007. break;
  10008. }
  10009. }
  10010. if ($falg)
  10011. $html .= '<td class="taR">-</td>';
  10012. }
  10013. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10014. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10015. }
  10016. $data ['collectHtml'] = $collectHtml;
  10017. // create Adjustment price html
  10018. $receiptCollectList = $receiptDetail->find ( array (
  10019. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  10020. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  10021. 'groupby' => 'itemCategory,Month(date)',
  10022. 'asArray' => true
  10023. ) );
  10024. $adjustment = array ();
  10025. $collectArray = array (
  10026. '日常相关费用' => array (),
  10027. '差旅相关费用' => array (),
  10028. '培训班费用' => array (),
  10029. '其他' => array ()
  10030. );
  10031. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10032. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10033. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10034. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10035. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10036. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10037. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10038. array_push ( $collectArray ['其他'], $collectHtml );
  10039. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10040. array_push ( $adjustment, $collectHtml );
  10041. // total price html
  10042. $collectHtml = "";
  10043. $total = 0;
  10044. for($i = 1; $i <= 12; $i ++) {
  10045. $sumPrice = 0;
  10046. foreach ( $receiptCollectList as $key => $value ) {
  10047. if ($value ['month'] == $i) {
  10048. $sumPrice += $value ['price'];
  10049. }
  10050. }
  10051. if ($sumPrice == 0)
  10052. $collectHtml .= '<td class="taR">-</td>';
  10053. else
  10054. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10055. $total += $sumPrice;
  10056. }
  10057. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10058. // statistics html
  10059. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  10060. if (empty ( $stList ))
  10061. $stList = array (
  10062. 'rePrice' => 0,
  10063. 'agPrice' => 0
  10064. );
  10065. $data ['stList'] = array (
  10066. 'rePrice' => $stList ['rePrice'],
  10067. 'agPrice' => $stList ['agPrice'],
  10068. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10069. );
  10070. $data ['collectArray'] = $collectArray;
  10071. $data ['adjustment'] = $adjustment;
  10072. $data ['totalPrice'] = $collectHtml;
  10073. $data ['totalYear'] = $total;
  10074. $data ['year'] = $year;
  10075. $dateHtml = "";
  10076. $now = date ( "Y" );
  10077. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10078. if ($YEARD <= $now) {
  10079. $dateHtml .= '<option ';
  10080. if ($year == $YEARD) {
  10081. $dateHtml .= 'selected ';
  10082. }
  10083. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10084. }
  10085. }
  10086. $data ['dateHtml'] = $dateHtml;
  10087. $data ['memu'] = "receipt";
  10088. $data ['staff'] = $this->staff;
  10089. $data ['receiptMemu'] = 'personalCollect';
  10090. $data ['verifyId'] = $this->verifyId;
  10091. $data ['executeId'] = $this->executeId;
  10092. // year staff status 2,4
  10093. if ($year < date ( "Y" )) {
  10094. Doo::loadModel ( 'receipt' );
  10095. $receipt = new receipt ();
  10096. $receiptList = $receipt->find ( array (
  10097. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  10098. 'asArray' => true
  10099. ) );
  10100. if (empty ( $receiptList )) {
  10101. ob_start ();
  10102. $this->render ( "/admin/saeaCollectArticles", $data );
  10103. $this->cacheFile ( $path );
  10104. die ();
  10105. }
  10106. }
  10107. $this->render ( "/admin/saeaCollectArticles", $data );
  10108. }
  10109. function companyCategoryCollect() {
  10110. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10111. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  10112. $this->showCache ( $path );
  10113. Doo::loadModel ( 'L_category' );
  10114. Doo::loadModel ( 'itemStatistics' );
  10115. Doo::loadModel ( 'statistics' );
  10116. $statistics = new statistics ();
  10117. $Lcategory = new L_category ();
  10118. $itemStatistics = new itemStatistics ();
  10119. Doo::loadModel ( "receiptAuthorityManage" );
  10120. $receiptAuthorityManage = new receiptAuthorityManage ();
  10121. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10122. $cidList = array ();
  10123. foreach ( $imcStaff as $key => $value ) {
  10124. array_push ( $cidList, $value ['cid'] );
  10125. }
  10126. $cidString = implode ( ',', $cidList );
  10127. $LcategoryList = $Lcategory->find ( array (
  10128. 'where' => ' cid in (' . $cidString . ')',
  10129. 'asArray' => true
  10130. ) ); // 'staff='.$this->staff[0]['sid']." and
  10131. $itemStatisticsList = $itemStatistics->find ( array (
  10132. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10133. 'where' => " Year(date)=" . $year,
  10134. 'groupby' => 'cid,Month(date)',
  10135. 'asArray' => true
  10136. ) );
  10137. // ceatre companyCollectHtml
  10138. foreach ( $LcategoryList as $value ) {
  10139. $html = "";
  10140. $asum = 0;
  10141. for($i = 1; $i <= 12; $i ++) {
  10142. $falg = true;
  10143. foreach ( $itemStatisticsList as $v ) {
  10144. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  10145. $asum += $v ['price'];
  10146. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10147. $falg = false;
  10148. break;
  10149. }
  10150. }
  10151. if ($falg)
  10152. $html .= '<td class="taR">-</td>';
  10153. }
  10154. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10155. $collectHtml [$value ['title']] = array (
  10156. 'html' => $html,
  10157. 'cid' => $value ['cid']
  10158. );
  10159. }
  10160. $data ['companyHtml'] = $collectHtml;
  10161. // total price html
  10162. $collectHtml = "";
  10163. $total = 0;
  10164. for($i = 1; $i <= 12; $i ++) {
  10165. $sumPrice = 0;
  10166. foreach ( $itemStatisticsList as $key => $value ) {
  10167. if ($value ['month'] == $i) {
  10168. $sumPrice += $value ['price'];
  10169. }
  10170. }
  10171. if ($sumPrice == 0)
  10172. $collectHtml .= '<td class="taR">-</td>';
  10173. else
  10174. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10175. $total += $sumPrice;
  10176. }
  10177. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10178. $data ['companyTotalHtml'] = $collectHtml;
  10179. $data ['total'] = $total;
  10180. // statistics html
  10181. // echo $cidString;
  10182. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10183. if (empty ( $stList ))
  10184. $stList = array (
  10185. 'rePrice' => 0,
  10186. 'agPrice' => 0
  10187. );
  10188. $data ['stList'] = array (
  10189. 'rePrice' => $stList ['rePrice'],
  10190. 'agPrice' => $stList ['agPrice'],
  10191. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10192. );
  10193. $data ['year'] = $year;
  10194. $data ['memu'] = "receipt";
  10195. $data ['staff'] = $this->staff;
  10196. $data ['receiptMemu'] = 'companyCategoryCollect';
  10197. $data ['verifyId'] = $this->verifyId;
  10198. $data ['executeId'] = $this->executeId;
  10199. $dateHtml = "";
  10200. $now = date ( "Y" );
  10201. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10202. if ($YEARD <= $now) {
  10203. $dateHtml .= '<option ';
  10204. if ($year == $YEARD) {
  10205. $dateHtml .= 'selected ';
  10206. }
  10207. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10208. }
  10209. }
  10210. $data ['dateHtml'] = $dateHtml;
  10211. // year staff status 2,4
  10212. if ($year < date ( "Y" )) {
  10213. Doo::loadModel ( 'receipt' );
  10214. $receipt = new receipt ();
  10215. $receiptList = $receipt->find ( array (
  10216. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  10217. 'asArray' => true
  10218. ) );
  10219. if (empty ( $receiptList )) {
  10220. ob_start ();
  10221. $this->render ( "/admin/saeaCompanyCollect", $data );
  10222. $this->cacheFile ( $path );
  10223. die ();
  10224. }
  10225. }
  10226. $this->render ( "/admin/saeaCompanyCollect", $data );
  10227. }
  10228. function categoryCollectDetail() {
  10229. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10230. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  10231. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  10232. $this->showCache ( $path ); */
  10233. Doo::loadModel ( 'statistics' );
  10234. $statistics = new statistics ();
  10235. Doo::loadModel ( "receiptDetail" );
  10236. $receiptDetail = new receiptDetail ();
  10237. Doo::loadModel ( 'L_category' );
  10238. $Lcategory = new L_category ();
  10239. Doo::loadModel ( 'accountItem' );
  10240. $accountItem = new accountItem ();
  10241. Doo::loadModel ( "receiptAuthorityManage" );
  10242. $receiptAuthorityManage = new receiptAuthorityManage ();
  10243. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10244. $cidList = array ();
  10245. foreach ( $imcStaff as $key => $value ) {
  10246. array_push ( $cidList, $value ['cid'] );
  10247. }
  10248. $cidString = implode ( ',', $cidList );
  10249. $LcategoryList = $Lcategory->find ( array (
  10250. 'where' => 'cid in (' . $cidString . ')',
  10251. 'asArray' => true
  10252. ) );
  10253. if ($cid == 0) {
  10254. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10255. if ($cid == 0)
  10256. $cid = $LcategoryList [0] ['cid'];
  10257. }
  10258. $data ['LcategoryList'] = $LcategoryList;
  10259. $receiptCollectList = $receiptDetail->find ( array (
  10260. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10261. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10262. 'groupby' => 'item,Month(pastDate)',
  10263. 'asArray' => true
  10264. ) );
  10265. $accountList = $accountItem->find ( array (
  10266. 'asArray' => true
  10267. ) );
  10268. // create CollectDetail HTML
  10269. $collectHtml = array ();
  10270. foreach ( $accountList as $key => $value ) {
  10271. $html = "";
  10272. $asum = 0;
  10273. for($i = 1; $i <= 12; $i ++) {
  10274. $falg = true;
  10275. foreach ( $receiptCollectList as $v ) {
  10276. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10277. $asum += $v ['price'];
  10278. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10279. $falg = false;
  10280. break;
  10281. }
  10282. }
  10283. if ($falg)
  10284. $html .= '<td class="taR">-</td>';
  10285. }
  10286. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10287. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10288. }
  10289. $data ['collectHtml'] = $collectHtml;
  10290. // create Adjustment price html
  10291. $receiptCollectList = $receiptDetail->find ( array (
  10292. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10293. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  10294. 'groupby' => 'itemCategory,Month(pastDate)',
  10295. 'asArray' => true
  10296. ) );
  10297. $adjustment = array ();
  10298. $collectArray = array (
  10299. '日常相关费用' => array (),
  10300. '差旅相关费用' => array (),
  10301. '培训班费用' => array (),
  10302. '内部培训费用'=>array(),
  10303. '其他' => array ()
  10304. );
  10305. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10306. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10307. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10308. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10309. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10310. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10311. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  10312. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  10313. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10314. array_push ( $collectArray ['其他'], $collectHtml );
  10315. $data ['collectArray'] = $collectArray;
  10316. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10317. array_push ( $adjustment, $collectHtml );
  10318. $data ['adjustment'] = $adjustment;
  10319. // total price html
  10320. $collectHtml = "";
  10321. $total = 0;
  10322. for($i = 1; $i <= 12; $i ++) {
  10323. $sumPrice = 0;
  10324. foreach ( $receiptCollectList as $key => $value ) {
  10325. if ($value ['month'] == $i) {
  10326. $sumPrice += $value ['price'];
  10327. }
  10328. }
  10329. if ($sumPrice == 0)
  10330. $collectHtml .= '<td class="taR">-</td>';
  10331. else
  10332. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10333. $total += $sumPrice;
  10334. }
  10335. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10336. // statistics html
  10337. $stList = $statistics->statisticsByCid ( $year, $cid );
  10338. if (empty ( $stList ))
  10339. $stList = array (
  10340. 'rePrice' => 0,
  10341. 'agPrice' => 0
  10342. );
  10343. $data ['stList'] = array (
  10344. 'rePrice' => $stList ['rePrice'],
  10345. 'agPrice' => $stList ['agPrice'],
  10346. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10347. );
  10348. $data ['totalYear'] = $total;
  10349. $data ['year'] = $year;
  10350. $data ['cid'] = $cid;
  10351. $data ['memu'] = "receipt";
  10352. $data ['staff'] = $this->staff;
  10353. $data ['receiptMemu'] = 'companyCategoryCollect';
  10354. $data ['verifyId'] = $this->verifyId;
  10355. $data ['executeId'] = $this->executeId;
  10356. // year staff status 2,4
  10357. /* if ($year < date ( "Y" )) {
  10358. Doo::loadModel ( 'receipt' );
  10359. $receipt = new receipt ();
  10360. $receiptList = $receipt->find ( array (
  10361. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  10362. 'asArray' => true
  10363. ) );
  10364. if (empty ( $receiptList )) {
  10365. ob_start ();
  10366. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10367. $this->cacheFile ( $path );
  10368. die ();
  10369. }
  10370. } */
  10371. $dateHtml = "";
  10372. $now = date ( "Y" );
  10373. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10374. if ($YEARD <= $now) {
  10375. $dateHtml .= '<option ';
  10376. if ($year == $YEARD) {
  10377. $dateHtml .= 'selected ';
  10378. }
  10379. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10380. }
  10381. }
  10382. $data ['dateHtml'] = $dateHtml;
  10383. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  10384. }
  10385. function staffCollect() {
  10386. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10387. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  10388. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  10389. // $this->showCache($path);
  10390. Doo::loadModel ( 'statistics' );
  10391. $statistics = new statistics ();
  10392. Doo::loadModel ( "receiptDetail" );
  10393. $receiptDetail = new receiptDetail ();
  10394. Doo::loadModel ( 'L_category' );
  10395. $Lcategory = new L_category ();
  10396. Doo::loadModel ( 'accountItem' );
  10397. $accountItem = new accountItem ();
  10398. Doo::loadModel ( 'staff' );
  10399. $staff = new staff ();
  10400. Doo::loadModel ( 'itemStatistics' );
  10401. $itemStatistics = new itemStatistics ();
  10402. Doo::loadModel ( "receiptAuthorityManage" );
  10403. $receiptAuthorityManage = new receiptAuthorityManage ();
  10404. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10405. $cidList = array ();
  10406. foreach ( $imcStaff as $key => $value ) {
  10407. array_push ( $cidList, $value ['cid'] );
  10408. }
  10409. $cidString = implode ( ',', $cidList );
  10410. $naturecon='';
  10411. if ($nature=='ONJOB'){
  10412. $naturecon=' and (nature!=4 )';
  10413. }elseif($nature=='LEAVEJOB'){
  10414. $naturecon=' and (nature=4 )';
  10415. }else{
  10416. die ( 'illegal request--nature' );
  10417. }
  10418. // statistics html
  10419. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  10420. if (empty ( $stList ))
  10421. $stList = array (
  10422. 'rePrice' => 0,
  10423. 'agPrice' => 0
  10424. );
  10425. $data ['stList'] = array (
  10426. 'rePrice' => $stList ['rePrice'],
  10427. 'agPrice' => $stList ['agPrice'],
  10428. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10429. );
  10430. // ---
  10431. $staffList = $staff->find ( array (
  10432. 'where' => 'username !="admin" '.$naturecon,
  10433. 'asArray' => true
  10434. ) );
  10435. $LcategoryList = $Lcategory->find ( array (
  10436. 'asArray' => true
  10437. ) ); // 'staff='.$this->staff[0]['sid']." and
  10438. $itemStatisticsList = $itemStatistics->find ( array (
  10439. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10440. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  10441. 'groupby' => 'staff,Month(date)',
  10442. 'asArray' => true
  10443. ) );
  10444. $categoryList = $staff->find ( array (
  10445. 'select' => 'COUNT(*) as count,cid,category',
  10446. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  10447. 'groupby' => 'cid',
  10448. 'asArray' => true
  10449. ) );
  10450. // print_r($itemStatisticsList);die;
  10451. // ceatre companyCollectHtml
  10452. foreach ( $categoryList as $vlu ) {
  10453. $count = $vlu ['count'] + 1;
  10454. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  10455. $m1 = 0;
  10456. $m2 = 0;
  10457. $m3 = 0;
  10458. $m4 = 0;
  10459. $m5 = 0;
  10460. $m6 = 0;
  10461. $m7 = 0;
  10462. $m8 = 0;
  10463. $m9 = 0;
  10464. $m10 = 0;
  10465. $m11 = 0;
  10466. $m12 = 0;
  10467. $m13 = 0;
  10468. foreach ( $staffList as $value ) {
  10469. if ($vlu ['cid'] == $value ['cid']) {
  10470. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10471. $asum = 0;
  10472. for($i = 1; $i <= 12; $i ++) {
  10473. $falg = true;
  10474. foreach ( $itemStatisticsList as $v ) {
  10475. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10476. if ($v ['month'] == 1)
  10477. $m1 += $v ['price'];
  10478. if ($v ['month'] == 2)
  10479. $m2 += $v ['price'];
  10480. if ($v ['month'] == 3)
  10481. $m3 += $v ['price'];
  10482. if ($v ['month'] == 4)
  10483. $m4 += $v ['price'];
  10484. if ($v ['month'] == 5)
  10485. $m5 += $v ['price'];
  10486. if ($v ['month'] == 6)
  10487. $m6 += $v ['price'];
  10488. if ($v ['month'] == 7)
  10489. $m7 += $v ['price'];
  10490. if ($v ['month'] == 8)
  10491. $m8 += $v ['price'];
  10492. if ($v ['month'] == 9)
  10493. $m9 += $v ['price'];
  10494. if ($v ['month'] == 10)
  10495. $m10 += $v ['price'];
  10496. if ($v ['month'] == 11)
  10497. $m11 += $v ['price'];
  10498. if ($v ['month'] == 12)
  10499. $m12 += $v ['price'];
  10500. $asum += $v ['price'];
  10501. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10502. $falg = false;
  10503. break;
  10504. }
  10505. }
  10506. if ($falg)
  10507. $html .= '<td class="taR">-</td>';
  10508. }
  10509. $m13 += $asum;
  10510. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10511. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10512. 'html' => $html,
  10513. 'sid' => $value ['sid']
  10514. );
  10515. $html = "";
  10516. }
  10517. }
  10518. $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>
  10519. <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>
  10520. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10521. $collectHtml [$vlu ['cid']] = array (
  10522. 'html' => $hl,
  10523. 'sid' => ''
  10524. );
  10525. }
  10526. $data ['companyHtml'] = $collectHtml;
  10527. // total price html
  10528. $collectHtml = "";
  10529. $total = 0;
  10530. for($i = 1; $i <= 12; $i ++) {
  10531. $sumPrice = 0;
  10532. foreach ( $itemStatisticsList as $key => $value ) {
  10533. if ($value ['month'] == $i) {
  10534. $sumPrice += $value ['price'];
  10535. }
  10536. }
  10537. if ($sumPrice == 0)
  10538. $collectHtml .= '<td class="taR">-</td>';
  10539. else
  10540. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10541. $total += $sumPrice;
  10542. }
  10543. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10544. $data ['companyTotalHtml'] = $collectHtml;
  10545. $data ['total'] = $total;
  10546. $data ['nature'] =$nature;
  10547. $data ['year'] = $year;
  10548. $data ['memu'] = "receipt";
  10549. $data ['staff'] = $this->staff;
  10550. $data ['receiptMemu'] = 'companyCategoryCollect';
  10551. $data ['verifyId'] = $this->verifyId;
  10552. $data ['executeId'] = $this->executeId;
  10553. if ($year <= date ( "Y" )) {
  10554. Doo::loadModel ( 'receipt' );
  10555. $receipt = new receipt ();
  10556. $receiptList = $receipt->find ( array (
  10557. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10558. 'asArray' => true
  10559. ) );
  10560. if (empty ( $receiptList )) { // generated files
  10561. ob_start ();
  10562. $this->render ( "/admin/saeaStaffCollectB", $data );
  10563. $this->cacheFile ( $path );
  10564. die ();
  10565. }
  10566. }
  10567. $this->render ( "/admin/saeaStaffCollectB", $data );
  10568. }
  10569. function staffCollectBak() {
  10570. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10571. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10572. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10573. $this->showCache ( $path );
  10574. Doo::loadModel ( 'statistics' );
  10575. $statistics = new statistics ();
  10576. Doo::loadModel ( "receiptDetail" );
  10577. $receiptDetail = new receiptDetail ();
  10578. Doo::loadModel ( 'L_category' );
  10579. $Lcategory = new L_category ();
  10580. Doo::loadModel ( 'accountItem' );
  10581. $accountItem = new accountItem ();
  10582. Doo::loadModel ( 'staff' );
  10583. $staff = new staff ();
  10584. Doo::loadModel ( 'itemStatistics' );
  10585. $itemStatistics = new itemStatistics ();
  10586. $itemStatisticsList = $itemStatistics->find ( array (
  10587. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10588. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10589. 'groupby' => 'staff,itemCategory,Month(date)',
  10590. 'asArray' => true
  10591. ) );
  10592. $itemCategoryList = $itemStatistics->find ( array (
  10593. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10594. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10595. 'groupby' => 'cid,itemCategory,Month(date)',
  10596. 'asArray' => true
  10597. ) );
  10598. $LcategoryList = $Lcategory->find ( array (
  10599. 'asArray' => true
  10600. ) );
  10601. $staffList = $staff->find ( array (
  10602. 'asArray' => true
  10603. ) );
  10604. $htmlArray = array ();
  10605. foreach ( $LcategoryList as $value ) {
  10606. $htmlArray [$value ['title']] = array ();
  10607. foreach ( $staffList as $v ) {
  10608. if ($value ['cid'] == $v ['cid']) {
  10609. $html = "";
  10610. $falg = true;
  10611. $staffSumPrice = 0;
  10612. foreach ( $itemStatisticsList as $a ) {
  10613. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10614. if (empty ( $a ['price'] )) {
  10615. $html .= '<td class="taR">-</td>';
  10616. $falg = false;
  10617. break;
  10618. } else {
  10619. $staffSumPrice += $a ['price'];
  10620. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10621. $falg = false;
  10622. break;
  10623. }
  10624. }
  10625. }
  10626. if ($falg) {
  10627. $html .= '<td class="taR">-</td>';
  10628. $falg = true;
  10629. }
  10630. $falg = true;
  10631. foreach ( $itemStatisticsList as $a ) {
  10632. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10633. if (empty ( $a ['price'] )) {
  10634. $html .= '<td class="taR">-</td>';
  10635. $falg = false;
  10636. break;
  10637. } else {
  10638. $staffSumPrice += $a ['price'];
  10639. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10640. $falg = false;
  10641. break;
  10642. }
  10643. }
  10644. }
  10645. if ($falg) {
  10646. $html .= '<td class="taR">-</td>';
  10647. $falg = true;
  10648. }
  10649. $falg = true;
  10650. foreach ( $itemStatisticsList as $a ) {
  10651. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10652. if (empty ( $a ['price'] )) {
  10653. $html .= '<td class="taR">-</td>';
  10654. $falg = false;
  10655. break;
  10656. } else {
  10657. $staffSumPrice += $a ['price'];
  10658. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10659. $falg = false;
  10660. break;
  10661. }
  10662. }
  10663. }
  10664. if ($falg) {
  10665. $html .= '<td class="taR">-</td>';
  10666. $falg = true;
  10667. }
  10668. $falg = true;
  10669. foreach ( $itemStatisticsList as $a ) {
  10670. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10671. if (! empty ( $a ['price'] )) {
  10672. $staffSumPrice += $a ['price'];
  10673. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10674. $falg = false;
  10675. break;
  10676. } else {
  10677. $html .= '<td class="taR">-</td>';
  10678. $falg = false;
  10679. break;
  10680. }
  10681. }
  10682. }
  10683. if ($falg) {
  10684. $html .= '<td class="taR">-</td>';
  10685. $falg = true;
  10686. }
  10687. $falg = true;
  10688. foreach ( $itemStatisticsList as $a ) {
  10689. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10690. if (! empty ( $a ['price'] )) {
  10691. $staffSumPrice += $a ['price'];
  10692. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10693. $falg = false;
  10694. break;
  10695. } else {
  10696. $html .= '<td class="taR">-</td>';
  10697. $falg = false;
  10698. break;
  10699. }
  10700. }
  10701. }
  10702. if ($falg) {
  10703. $html .= '<td class="taR">-</td>';
  10704. $falg = true;
  10705. }
  10706. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10707. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10708. }
  10709. }
  10710. /* -- --- */
  10711. // 合计费用
  10712. $cateHtml = "";
  10713. $catePrice = 0;
  10714. $cateFalg = true;
  10715. foreach ( $itemCategoryList as $l ) {
  10716. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10717. if (empty ( $l ['price'] )) {
  10718. $cateHtml .= '<td class="colGreen taR">-</td>';
  10719. $cateFalg = false;
  10720. break;
  10721. } else {
  10722. $catePrice += $l ['price'];
  10723. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10724. $cateFalg = false;
  10725. break;
  10726. }
  10727. }
  10728. }
  10729. if ($cateFalg) {
  10730. $cateHtml .= '<td class="colGreen taR">-</td>';
  10731. $cateFalg = true;
  10732. }
  10733. $cateFalg = true;
  10734. foreach ( $itemCategoryList as $l ) {
  10735. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10736. if (empty ( $l ['price'] )) {
  10737. $cateHtml .= '<td class="colGreen taR">-</td>';
  10738. $cateFalg = false;
  10739. break;
  10740. } else {
  10741. $catePrice += $l ['price'];
  10742. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10743. $cateFalg = false;
  10744. break;
  10745. }
  10746. }
  10747. }
  10748. if ($cateFalg) {
  10749. $cateHtml .= '<td class="colGreen taR">-</td>';
  10750. $cateFalg = true;
  10751. }
  10752. $cateFalg = true;
  10753. foreach ( $itemCategoryList as $l ) {
  10754. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10755. if (empty ( $l ['price'] )) {
  10756. $cateHtml .= '<td class="colGreen taR">-</td>';
  10757. $cateFalg = false;
  10758. break;
  10759. } else {
  10760. $catePrice += $l ['price'];
  10761. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10762. $cateFalg = false;
  10763. break;
  10764. }
  10765. }
  10766. }
  10767. if ($cateFalg) {
  10768. $cateHtml .= '<td class="colGreen taR">-</td>';
  10769. $cateFalg = true;
  10770. }
  10771. $cateFalg = true;
  10772. foreach ( $itemCategoryList as $l ) {
  10773. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10774. if (empty ( $l ['price'] )) {
  10775. $cateHtml .= '<td class="colGreen taR">-</td>';
  10776. $cateFalg = false;
  10777. break;
  10778. } else {
  10779. $catePrice += $l ['price'];
  10780. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10781. $cateFalg = false;
  10782. break;
  10783. }
  10784. }
  10785. }
  10786. if ($cateFalg) {
  10787. $cateHtml .= '<td class="colGreen taR">-</td>';
  10788. $cateFalg = true;
  10789. }
  10790. $cateFalg = true;
  10791. foreach ( $itemCategoryList as $l ) {
  10792. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10793. if (empty ( $l ['price'] )) {
  10794. $cateHtml .= '<td class="colGreen taR">-</td>';
  10795. $cateFalg = false;
  10796. break;
  10797. } else {
  10798. $catePrice += $l ['price'];
  10799. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10800. $cateFalg = false;
  10801. break;
  10802. }
  10803. }
  10804. }
  10805. if ($cateFalg) {
  10806. $cateHtml .= '<td class="colGreen taR">-</td>';
  10807. $cateFalg = true;
  10808. }
  10809. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10810. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10811. /* -- --- */
  10812. }
  10813. // print_r($htmlArray);die;
  10814. $data ['htmlArray'] = $htmlArray;
  10815. // statistics html
  10816. $stList = $statistics->getOne ( array (
  10817. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10818. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10819. 'groupby' => 'Month(date)',
  10820. 'asArray' => true
  10821. ) );
  10822. if (empty ( $stList ))
  10823. $stList = array (
  10824. 'rePrice' => 0,
  10825. 'agPrice' => 0
  10826. );
  10827. $data ['stList'] = array (
  10828. 'rePrice' => $stList ['rePrice'],
  10829. 'agPrice' => $stList ['agPrice'],
  10830. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10831. );
  10832. $monthHtml = "";
  10833. for($i = 1; $i <= 12; $i ++) {
  10834. if ($i == $month)
  10835. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10836. else
  10837. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10838. }
  10839. $data ['monthHtml'] = $monthHtml;
  10840. $data ['year'] = $year;
  10841. $data ['month'] = $month;
  10842. $data ['memu'] = "receipt";
  10843. $data ['staff'] = $this->staff;
  10844. $data ['receiptMemu'] = 'companyCategoryCollect';
  10845. $data ['verifyId'] = $this->verifyId;
  10846. $data ['executeId'] = $this->executeId;
  10847. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10848. Doo::loadModel ( 'receipt' );
  10849. $receipt = new receipt ();
  10850. $receiptList = $receipt->find ( array (
  10851. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10852. 'asArray' => true
  10853. ) );
  10854. if (empty ( $receiptList )) { // generated files
  10855. ob_start ();
  10856. $this->render ( "/admin/saeaStaffCollect", $data );
  10857. $this->cacheFile ( $path );
  10858. die ();
  10859. }
  10860. }
  10861. $this->render ( "/admin/saeaStaffCollect", $data );
  10862. }
  10863. /**
  10864. * 日常收支
  10865. */
  10866. function payments() {
  10867. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10868. Doo::loadModel ( "execute" );
  10869. $execute = new execute ();
  10870. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10871. die ( 'illegal request' );
  10872. }
  10873. Doo::loadModel ( "accountBook" );
  10874. $accountBook = new accountBook ();
  10875. Doo::loadModel ( "accountBookStatistics" );
  10876. $accountBookStatistics = new accountBookStatistics ();
  10877. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10878. $list = $accountBook->getAccountBookByLimit ( 10 );
  10879. $data ['date'] = date ( "Y-m-d" );
  10880. $data ['statisticsList'] = $statisticsList;
  10881. $data ['list'] = $list;
  10882. $data ['memu'] = "receipt";
  10883. $data ['staff'] = $this->staff;
  10884. $data ['receiptMemu'] = 'payments';
  10885. $data ['verifyId'] = $this->verifyId;
  10886. $data ['executeId'] = $this->executeId;
  10887. $this->render ( "/expenses/payments", $data );
  10888. }
  10889. function paymentsIncomeDo() {
  10890. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10891. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10892. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10893. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10894. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10895. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10896. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10897. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10898. Doo::loadClass ( 'XDeode' );
  10899. $XDeode = new XDeode ( 5 );
  10900. Doo::loadModel ( "accountBook" );
  10901. Doo::loadModel ( "accountBookStatistics" );
  10902. Doo::loadModel ( 'wasteBook' );
  10903. // 记录流水时银行的转换
  10904. $accountBank = '';
  10905. if ($receivedBank == '纵横广发') {
  10906. $accountBank = 'CGBDeposit';
  10907. } elseif ($receivedBank == '纵横工行') {
  10908. $accountBank = 'ICBCDeposit';
  10909. } elseif ($receivedBank == '华润银行') {
  10910. $accountBank = 'HUADeposit';
  10911. } elseif ($receivedBank == '个人广发') {
  10912. $accountBank = 'PersonalDeposit';
  10913. }
  10914. if (empty ( $accountBank ))
  10915. die ( 'illegal request' );
  10916. if($accountType == 11 || $accountType == 12){
  10917. if($accountType == 11){
  10918. $receivedBank = '纵横广发';
  10919. }elseif($accountType == 12){
  10920. $receivedBank = '纵横工行';
  10921. }
  10922. // 添加一条收入
  10923. $accountBook = new accountBook ();
  10924. $accountBook->accountType = $accountType;
  10925. $accountBook->accountMsg = $accountMsg;
  10926. $accountBook->receivedPrice = $receivedPrice;
  10927. $accountBook->receivedMsg = $receivedMsg;
  10928. $accountBook->receivedBank = $receivedBank;
  10929. $accountBook->receivedDate = $receivedDate;
  10930. $accountBook->remarks = $remarks;
  10931. $accountBook->expensesType = 1;
  10932. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10933. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10934. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10935. $inComeId = $accountBook->insert ();
  10936. // 收支汇总-添加一条收入日常汇总
  10937. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10938. $accountBookStatistics = new accountBookStatistics ();
  10939. $item = array (
  10940. 'date' => date ( "Y-m-d" ),
  10941. 'accountType' => $abDetail ['accountType'],
  10942. 'accountMsg' => $abDetail ['accountMsg'],
  10943. 'aid' => $abDetail ['aid'],
  10944. 'inComePrice' => $abDetail ['receivedPrice'],
  10945. 'expensesType' => $abDetail ['expensesType']
  10946. );
  10947. $accountBookStatistics->setAccountBookStatistics ( $item );
  10948. //流水支出
  10949. // if($accountBank=='CGBDeposit'){
  10950. // $dailyExpenditureType='8';
  10951. // }elseif($accountBank=='ICBCDeposit'){
  10952. // $dailyExpenditureType='9';
  10953. // }elseif($accountBank=='PersonalDeposit'){
  10954. // $dailyExpenditureType='10';
  10955. // }elseif($accountBank=='HUADeposit'){
  10956. // $dailyExpenditureType='11';
  10957. // }
  10958. //
  10959. // $wasteBook = new wasteBook ();
  10960. // $itemWaste = array (
  10961. // 'expensesType' => 2,
  10962. // 'accountType' => 5,
  10963. // 'accountPriceShow' => $receivedPrice,
  10964. // 'accountPrice' => - $receivedPrice,
  10965. // 'dataID' => $inComeId,
  10966. // 'dailyExpenditureType' => $dailyExpenditureType,
  10967. // 'accountBank' => $accountBank,
  10968. // 'category' => $this->staff [0] ['category'],
  10969. // 'cid' => $this->staff [0] ['cid'],
  10970. // 'name' => $this->staff [0] ['username'],
  10971. // 'sid' => $this->staff [0] ['sid'],
  10972. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10973. // );
  10974. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10975. // 添加收入流水
  10976. if($accountType == 11){
  10977. $accountBank = 'CGBDeposit';
  10978. }elseif($accountType == 12){
  10979. $accountBank = 'ICBCDeposit';
  10980. }
  10981. $wasteBook = new wasteBook ();
  10982. $itemWaste = array (
  10983. 'accountPriceShow' => $receivedPrice,
  10984. 'accountPrice' => $receivedPrice,
  10985. 'expensesType' => 1,
  10986. 'accountType' => 6, // 流水类型
  10987. 'dataID' => $inComeId,
  10988. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10989. 'accountBank' => $accountBank,
  10990. 'category' => $this->staff [0] ['category'],
  10991. 'cid' => $this->staff [0] ['cid'],
  10992. 'name' => $this->staff [0] ['username'],
  10993. 'sid' => $this->staff [0] ['sid'],
  10994. 'inputDate' => date ( "Y-m-d H:i:s" )
  10995. );
  10996. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10997. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10998. if ($receivedBank == '个人广发') {
  10999. die ( '个人广发 illegal request' );
  11000. }
  11001. // 添加一条收入
  11002. $accountBook = new accountBook ();
  11003. $accountBook->accountType = 10;
  11004. $accountBook->accountMsg = $accountMsg;
  11005. $accountBook->receivedPrice = $receivedPrice;
  11006. $accountBook->receivedMsg = $receivedMsg;
  11007. $accountBook->receivedBank = $receivedBank;
  11008. $accountBook->receivedDate = $receivedDate;
  11009. $accountBook->remarks = $remarks;
  11010. $accountBook->expensesType = 1;
  11011. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11012. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11013. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11014. $inComeId = $accountBook->insert ();
  11015. // 收支汇总-添加一条收入日常汇总
  11016. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  11017. $accountBookStatistics = new accountBookStatistics ();
  11018. $item = array (
  11019. 'date' => date ( "Y-m-d" ),
  11020. 'accountType' => $abDetail ['accountType'],
  11021. 'accountMsg' => $abDetail ['accountMsg'],
  11022. 'aid' => $abDetail ['aid'],
  11023. 'inComePrice' => $abDetail ['receivedPrice'],
  11024. 'expensesType' => $abDetail ['expensesType']
  11025. );
  11026. $accountBookStatistics->setAccountBookStatistics ( $item );
  11027. // 添加收入流水
  11028. $wasteBook = new wasteBook ();
  11029. $itemWaste = array (
  11030. 'accountPriceShow' => $receivedPrice,
  11031. 'accountPrice' => $receivedPrice,
  11032. 'expensesType' => 1,
  11033. 'accountType' => 6, // 流水类型
  11034. 'dataID' => $inComeId,
  11035. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11036. 'accountBank' => $accountBank,
  11037. 'category' => $this->staff [0] ['category'],
  11038. 'cid' => $this->staff [0] ['cid'],
  11039. 'name' => $this->staff [0] ['username'],
  11040. 'sid' => $this->staff [0] ['sid'],
  11041. 'inputDate' => date ( "Y-m-d H:i:s" )
  11042. );
  11043. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11044. // 添加一条理财支出
  11045. $accountBank = 'CGBDeposit';
  11046. $expenditureBank = '纵横广发';
  11047. $dailyExpenditureType = 4;
  11048. if ($accountType == 9) {
  11049. $accountBank = 'ICBCDeposit';
  11050. $expenditureBank = '纵横工行';
  11051. $dailyExpenditureType = 6;
  11052. }
  11053. $accountBook = new accountBook ();
  11054. $accountBook->expensesType = 2;
  11055. $accountBook->expenditureType = $dailyExpenditureType;
  11056. $accountBook->expenditureMsg = $accountMsg;
  11057. $accountBook->expenditurePrice = $receivedPrice;
  11058. $accountBook->expenditureBank = $expenditureBank;
  11059. $accountBook->expenditureDate = $receivedDate;
  11060. $accountBook->remarks = $remarks;
  11061. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11062. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11063. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11064. $id = $accountBook->insert ();
  11065. // 收支汇总-添加一条理财支出汇总
  11066. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11067. $accountBookStatistics = new accountBookStatistics ();
  11068. $item = array (
  11069. 'date' => date ( "Y-m-d" ),
  11070. 'accountType' => $abDetail ['accountType'],
  11071. 'accountMsg' => $abDetail ['accountMsg'],
  11072. 'aid' => $abDetail ['aid'],
  11073. 'financingPrice' => - $receivedPrice,
  11074. 'expensesType' => 3
  11075. );
  11076. $accountBookStatistics->setAccountBookStatistics ( $item );
  11077. // 添加一条支出理财流水
  11078. $accountTypeWaste = 5;
  11079. if ($accountMsg == '公司固定') {
  11080. $accountTypeWaste = 9;
  11081. } elseif ($accountMsg == '公司活期') {
  11082. $accountTypeWaste = 10;
  11083. } elseif ($accountMsg == '个人(GR)') {
  11084. $accountBank = 'PersonalDeposit';
  11085. }
  11086. $itemWaste = array (
  11087. 'expensesType' => 2,
  11088. 'accountType' => $accountTypeWaste,
  11089. 'accountPriceShow' => $receivedPrice,
  11090. 'accountPrice' => - $receivedPrice,
  11091. 'dataID' => $id,
  11092. 'dailyExpenditureType' => $dailyExpenditureType,
  11093. 'accountBank' => $accountBank,
  11094. 'category' => $this->staff [0] ['category'],
  11095. 'cid' => $this->staff [0] ['cid'],
  11096. 'name' => $this->staff [0] ['username'],
  11097. 'sid' => $this->staff [0] ['sid'],
  11098. 'inputDate' => date ( "Y-m-d H:i:s" )
  11099. );
  11100. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11101. } elseif ($accountType == 1) {
  11102. if ($receivedBank == '个人广发')
  11103. die ( 'illegal request' );
  11104. // 添加一条收入
  11105. $accountBook = new accountBook ();
  11106. $accountBook->accountType = $accountType;
  11107. $accountBook->accountMsg = $accountMsg;
  11108. $accountBook->receivedPrice = $receivedPrice;
  11109. $accountBook->receivedMsg = $receivedMsg;
  11110. $accountBook->receivedBank = $receivedBank;
  11111. $accountBook->receivedDate = $receivedDate;
  11112. $accountBook->remarks = $remarks;
  11113. $accountBook->expensesType = 1;
  11114. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11115. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11116. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11117. $id = $accountBook->insert ();
  11118. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11119. // 收支汇总-添加一条收入日常汇总
  11120. $accountBookStatistics = new accountBookStatistics ();
  11121. $item = array (
  11122. 'date' => date ( "Y-m-d" ),
  11123. 'accountType' => $abDetail ['accountType'],
  11124. 'accountMsg' => $abDetail ['accountMsg'],
  11125. 'aid' => $abDetail ['aid'],
  11126. 'expensesType' => $abDetail ['expensesType']
  11127. );
  11128. if ($abDetail ['accountType'] == 8) {
  11129. $item += array (
  11130. 'inComePrice' => $abDetail ['receivedPrice']
  11131. );
  11132. } else {
  11133. $item += array (
  11134. 'inComePrice' => $abDetail ['receivedPrice']
  11135. );
  11136. }
  11137. $accountBookStatistics->setAccountBookStatistics ( $item );
  11138. // 流水存储方向
  11139. $itemWaste = array (
  11140. 'accountType' => 6
  11141. ); // 流水类型
  11142. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  11143. // }else
  11144. if ($accountMsg == '活期理财收益') {
  11145. $itemWaste = array (
  11146. 'accountType' => 10
  11147. ); // 流水类型
  11148. }
  11149. // 添加收入流水
  11150. $wasteBook = new wasteBook ();
  11151. $itemWaste += array (
  11152. 'accountPrice' => $receivedPrice,
  11153. 'accountPriceShow' => $receivedPrice,
  11154. 'expensesType' => 1,
  11155. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11156. 'dataID' => $id,
  11157. 'accountBank' => $accountBank,
  11158. 'category' => $this->staff [0] ['category'],
  11159. 'cid' => $this->staff [0] ['cid'],
  11160. 'name' => $this->staff [0] ['username'],
  11161. 'sid' => $this->staff [0] ['sid'],
  11162. 'inputDate' => date ( "Y-m-d H:i:s" )
  11163. );
  11164. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11165. } else { // 普通日常收入处理
  11166. // 添加一条收入
  11167. $accountBook = new accountBook ();
  11168. $accountBook->accountType = $accountType;
  11169. $accountBook->accountMsg = $accountMsg;
  11170. $accountBook->receivedPrice = $receivedPrice;
  11171. $accountBook->receivedMsg = $receivedMsg;
  11172. $accountBook->receivedBank = $receivedBank;
  11173. $accountBook->receivedDate = $receivedDate;
  11174. $accountBook->remarks = $remarks;
  11175. $accountBook->expensesType = 1;
  11176. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11177. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11178. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11179. $id = $accountBook->insert ();
  11180. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11181. // 收支汇总-添加一条收入日常汇总
  11182. $accountBookStatistics = new accountBookStatistics ();
  11183. $item = array (
  11184. 'date' => date ( "Y-m-d" ),
  11185. 'accountType' => $abDetail ['accountType'],
  11186. 'accountMsg' => $abDetail ['accountMsg'],
  11187. 'aid' => $abDetail ['aid'],
  11188. 'expensesType' => $abDetail ['expensesType']
  11189. );
  11190. if ($abDetail ['accountType'] == 8) {
  11191. $item += array (
  11192. 'inComePrice' => $abDetail ['receivedPrice']
  11193. );
  11194. } else {
  11195. $item += array (
  11196. 'inComePrice' => $abDetail ['receivedPrice']
  11197. );
  11198. }
  11199. $accountBookStatistics->setAccountBookStatistics ( $item );
  11200. // 添加收入流水
  11201. $itemWaste = array (
  11202. 'accountPrice' => $receivedPrice
  11203. );
  11204. if ($receivedBank == '个人广发') {
  11205. $itemWaste = array (
  11206. 'accountPrice' => - $receivedPrice
  11207. );
  11208. }
  11209. $wasteBook = new wasteBook ();
  11210. $itemWaste += array (
  11211. 'accountPriceShow' => $receivedPrice,
  11212. 'expensesType' => 1,
  11213. 'accountType' => 6, // 流水类型
  11214. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  11215. 'dataID' => $id,
  11216. 'accountBank' => $accountBank,
  11217. 'category' => $this->staff [0] ['category'],
  11218. 'cid' => $this->staff [0] ['cid'],
  11219. 'name' => $this->staff [0] ['username'],
  11220. 'sid' => $this->staff [0] ['sid'],
  11221. 'inputDate' => date ( "Y-m-d H:i:s" )
  11222. );
  11223. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11224. }
  11225. }
  11226. return '/payments';
  11227. }
  11228. function paymentsExpenditureDo() {
  11229. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11230. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11231. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11232. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11233. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11234. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11235. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11236. // 理财支出特殊处理
  11237. Doo::loadModel ( "accountBook" );
  11238. Doo::loadModel ( "accountBookStatistics" );
  11239. Doo::loadModel ( 'wasteBook' );
  11240. $accountBank = '';
  11241. if ($expenditureBank == '纵横广发') {
  11242. $accountBank = 'CGBDeposit';
  11243. } elseif ($expenditureBank == '纵横工行') {
  11244. $accountBank = 'ICBCDeposit';
  11245. } elseif ($expenditureBank == '华润银行') {
  11246. $accountBank = 'HUADeposit';
  11247. } elseif ($expenditureBank == '个人广发') {
  11248. $accountBank = 'PersonalDeposit';
  11249. }
  11250. if (empty ( $accountBank ))
  11251. die ( 'illegal request' );
  11252. if($expenditureType == 8 || $expenditureType == 9){
  11253. if($expenditureType == 8 ){
  11254. $expenditureBank='纵横广发';
  11255. }elseif($expenditureType == 9){
  11256. $expenditureBank='纵横工行';
  11257. }
  11258. // 添加一笔日常支出
  11259. $accountBook = new accountBook ();
  11260. $accountBook->expensesType = 2;
  11261. $accountBook->expenditureType = $expenditureType;
  11262. $accountBook->expenditureMsg = $expenditureMsg;
  11263. $accountBook->expenditurePrice = $expenditurePrice;
  11264. $accountBook->expenditureBank = $expenditureBank;
  11265. $accountBook->expenditureDate = $expenditureDate;
  11266. $accountBook->remarks = $remarks;
  11267. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11268. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11269. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11270. $expenditureId = $accountBook->insert ();
  11271. // 添加日常支出汇总
  11272. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11273. $accountBookStatistics = new accountBookStatistics ();
  11274. $item = array (
  11275. 'date' => date ( "Y-m-d" ),
  11276. 'expenditureType' => $abDetail ['expenditureType'],
  11277. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11278. 'aid' => $abDetail ['aid'],
  11279. 'payPrice' => $abDetail ['expenditurePrice'],
  11280. 'expensesType' => $abDetail ['expensesType']
  11281. );
  11282. $accountBookStatistics->setAccountBookStatistics ( $item );
  11283. // 公司日常支出流水
  11284. if($expenditureType == 8 ){
  11285. $accountBank = 'CGBDeposit';
  11286. }elseif($expenditureType == 9){
  11287. $accountBank = 'ICBCDeposit';
  11288. }
  11289. if($accountBank=='CGBDeposit'){
  11290. $dailyExpenditureType='8';
  11291. }elseif($accountBank=='ICBCDeposit'){
  11292. $dailyExpenditureType='9';
  11293. }elseif($accountBank=='PersonalDeposit'){
  11294. $dailyExpenditureType='10';
  11295. }elseif($accountBank=='HUADeposit'){
  11296. $dailyExpenditureType='11';
  11297. }
  11298. $wasteBook = new wasteBook ();
  11299. $itemWaste = array (
  11300. 'expensesType' => 2,
  11301. 'accountType' => 5,
  11302. 'dailyExpenditureType' => $dailyExpenditureType,
  11303. 'accountPriceShow' => $expenditurePrice,
  11304. 'accountPrice' => - $expenditurePrice,
  11305. 'dataID' => $expenditureId,
  11306. 'accountBank' => $accountBank,
  11307. 'category' => $this->staff [0] ['category'],
  11308. 'cid' => $this->staff [0] ['cid'],
  11309. 'name' => $this->staff [0] ['username'],
  11310. 'sid' => $this->staff [0] ['sid'],
  11311. 'inputDate' => date ( "Y-m-d H:i:s" )
  11312. );
  11313. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11314. // 添加一笔收入流水
  11315. // if($expenditureType==8){
  11316. // $dailyIncomeType='11';
  11317. // }elseif($expenditureType==9){
  11318. // $dailyIncomeType='12';
  11319. // }
  11320. // $wasteBook = new wasteBook ();
  11321. // $itemWaste = array (
  11322. // 'expensesType' => 1,
  11323. // 'accountType' => 6,
  11324. // 'accountPriceShow' => $expenditurePrice,
  11325. // 'accountPrice' => $expenditurePrice,
  11326. // 'dataID' => $expenditureId,
  11327. //
  11328. // 'dailyIncomeType' => $dailyIncomeType,
  11329. // 'accountBank' => $accountBank,
  11330. // 'category' => $this->staff [0] ['category'],
  11331. // 'cid' => $this->staff [0] ['cid'],
  11332. // 'name' => $this->staff [0] ['username'],
  11333. // 'sid' => $this->staff [0] ['sid'],
  11334. // 'inputDate' => date ( "Y-m-d H:i:s" )
  11335. // );
  11336. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  11337. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  11338. if ($expenditureBank == '个人广发') {
  11339. die ( '个人广发 illegal request' );
  11340. }
  11341. // 添加一笔日常支出
  11342. $accountBook = new accountBook ();
  11343. $accountBook->expensesType = 2;
  11344. $accountBook->expenditureType = 7;
  11345. $accountBook->expenditureMsg = $expenditureMsg;
  11346. $accountBook->expenditurePrice = $expenditurePrice;
  11347. $accountBook->expenditureBank = $expenditureBank;
  11348. $accountBook->expenditureDate = $expenditureDate;
  11349. $accountBook->remarks = $remarks;
  11350. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11351. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11352. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11353. $expenditureId = $accountBook->insert ();
  11354. // 添加日常支出汇总
  11355. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11356. $accountBookStatistics = new accountBookStatistics ();
  11357. $item = array (
  11358. 'date' => date ( "Y-m-d" ),
  11359. 'expenditureType' => $abDetail ['expenditureType'],
  11360. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11361. 'aid' => $abDetail ['aid'],
  11362. 'payPrice' => $abDetail ['expenditurePrice'],
  11363. 'expensesType' => $abDetail ['expensesType']
  11364. );
  11365. $accountBookStatistics->setAccountBookStatistics ( $item );
  11366. // 公司日常支出流水
  11367. $wasteBook = new wasteBook ();
  11368. $itemWaste = array (
  11369. 'accountPrice' => - $expenditurePrice
  11370. );
  11371. if ($expenditureBank == '个人广发') {
  11372. $itemWaste = array (
  11373. 'accountPrice' => $expenditurePrice
  11374. );
  11375. }
  11376. $itemWaste += array (
  11377. 'expensesType' => 2,
  11378. 'accountType' => 5,
  11379. 'dailyExpenditureType' => $expenditureType,
  11380. 'accountPriceShow' => $expenditurePrice,
  11381. 'accountPrice' => - $expenditurePrice,
  11382. 'dataID' => $expenditureId,
  11383. 'accountBank' => $accountBank,
  11384. 'category' => $this->staff [0] ['category'],
  11385. 'cid' => $this->staff [0] ['cid'],
  11386. 'name' => $this->staff [0] ['username'],
  11387. 'sid' => $this->staff [0] ['sid'],
  11388. 'inputDate' => date ( "Y-m-d H:i:s" )
  11389. );
  11390. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11391. // 添加一笔理财收入
  11392. $accountBank = 'CGBDeposit';
  11393. $dailyIncomeType = 7;
  11394. $receivedBank = '纵横广发';
  11395. if ($expenditureType == 6) {
  11396. $accountBank = 'ICBCDeposit';
  11397. $receivedBank = '纵横工行';
  11398. $dailyIncomeType = 9;
  11399. }
  11400. $accountBook = new accountBook ();
  11401. $accountBook->expensesType = 1;
  11402. $accountBook->accountType = $dailyIncomeType;
  11403. $accountBook->accountMsg = $expenditureMsg;
  11404. $accountBook->receivedPrice = $expenditurePrice;
  11405. $accountBook->receivedBank = $receivedBank;
  11406. $accountBook->receivedDate = $expenditureDate;
  11407. $accountBook->remarks = $remarks;
  11408. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11409. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11410. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11411. $id = $accountBook->insert ();
  11412. // 添加日常理财收入汇总
  11413. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  11414. $accountBookStatistics = new accountBookStatistics ();
  11415. $item = array (
  11416. 'date' => date ( "Y-m-d" ),
  11417. 'expenditureType' => $abDetail ['expenditureType'],
  11418. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11419. 'aid' => $abDetail ['aid'],
  11420. 'financingPrice' => $expenditurePrice,
  11421. 'expensesType' => 3
  11422. );
  11423. $accountBookStatistics->setAccountBookStatistics ( $item );
  11424. // 添加一笔收入流水
  11425. if ($expenditureMsg == '公司固定') {
  11426. $accountTypeWaste = 9;
  11427. } elseif ($expenditureMsg == '公司活期') {
  11428. $accountTypeWaste = 10;
  11429. } elseif ($expenditureMsg == '个人(GR)') {
  11430. $accountBank = 'PersonalDeposit';
  11431. }
  11432. $itemWaste = array (
  11433. 'expensesType' => 1,
  11434. 'accountType' => $accountTypeWaste,
  11435. 'accountPriceShow' => $expenditurePrice,
  11436. 'accountPrice' => $expenditurePrice,
  11437. 'dataID' => $id,
  11438. 'dailyIncomeType' => $dailyIncomeType,
  11439. 'accountBank' => $accountBank,
  11440. 'category' => $this->staff [0] ['category'],
  11441. 'cid' => $this->staff [0] ['cid'],
  11442. 'name' => $this->staff [0] ['username'],
  11443. 'sid' => $this->staff [0] ['sid'],
  11444. 'inputDate' => date ( "Y-m-d H:i:s" )
  11445. );
  11446. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11447. } else {
  11448. // 添加一笔日常支出
  11449. $accountBook = new accountBook ();
  11450. $accountBook->expensesType = 2;
  11451. $accountBook->expenditureType = $expenditureType;
  11452. $accountBook->expenditureMsg = $expenditureMsg;
  11453. $accountBook->expenditurePrice = $expenditurePrice;
  11454. $accountBook->expenditureBank = $expenditureBank;
  11455. $accountBook->expenditureDate = $expenditureDate;
  11456. $accountBook->remarks = $remarks;
  11457. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11458. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11459. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11460. $id = $accountBook->insert ();
  11461. // 添加日常支出汇总
  11462. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11463. $accountBookStatistics = new accountBookStatistics ();
  11464. $item = array (
  11465. 'date' => date ( "Y-m-d" ),
  11466. 'expenditureType' => $abDetail ['expenditureType'],
  11467. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11468. 'aid' => $abDetail ['aid'],
  11469. 'expensesType' => $abDetail ['expensesType']
  11470. );
  11471. if ($expenditureType == 5) {
  11472. $item += array (
  11473. 'payPrice' => - $abDetail ['expenditurePrice']
  11474. );
  11475. } else {
  11476. $item += array (
  11477. 'payPrice' => $abDetail ['expenditurePrice']
  11478. );
  11479. }
  11480. $accountBookStatistics->setAccountBookStatistics ( $item );
  11481. // 公司日常支出流水
  11482. $wasteBook = new wasteBook ();
  11483. $itemWaste = array (
  11484. 'accountPrice' => - $expenditurePrice
  11485. );
  11486. if ($expenditureBank == '个人广发') {
  11487. $itemWaste = array (
  11488. 'accountPrice' => $expenditurePrice
  11489. );
  11490. }
  11491. $itemWaste += array (
  11492. 'expensesType' => 2,
  11493. 'accountType' => 5,
  11494. 'accountPriceShow' => $expenditurePrice,
  11495. 'dataID' => $id,
  11496. 'dailyExpenditureType' => $expenditureType,
  11497. 'accountBank' => $accountBank,
  11498. 'category' => $this->staff [0] ['category'],
  11499. 'cid' => $this->staff [0] ['cid'],
  11500. 'name' => $this->staff [0] ['username'],
  11501. 'sid' => $this->staff [0] ['sid'],
  11502. 'inputDate' => date ( "Y-m-d H:i:s" )
  11503. );
  11504. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11505. }
  11506. }
  11507. return '/payments';
  11508. }
  11509. /**
  11510. * 添加支出
  11511. */
  11512. function paymentsExpenditureDo_() {
  11513. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11514. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11515. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11516. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11517. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11518. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11519. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11520. $dailyExpenditureType = '';
  11521. $accountTypeWaste = 5;
  11522. $accountBank = '';
  11523. if ($expenditureBank == '纵横广发') {
  11524. $accountBank = 'CGBDeposit';
  11525. } elseif ($expenditureBank == '纵横工行') {
  11526. $accountBank = 'ICBCDeposit';
  11527. } elseif ($expenditureBank == '华润银行') {
  11528. $accountBank = 'HUADeposit';
  11529. } elseif ($expenditureBank == '个人广发') {
  11530. $accountBank = 'PersonalDeposit';
  11531. }
  11532. if (empty ( $accountBank ))
  11533. die ( 'illegal request' );
  11534. $itemWaste = array (
  11535. 'accountPrice' => - $expenditurePrice
  11536. );
  11537. if ($expenditureBank == '个人广发') {
  11538. $itemWaste = array (
  11539. 'accountPrice' => $expenditurePrice
  11540. );
  11541. }
  11542. if ($expenditureType == 4 || $expenditureType == 6) {
  11543. $dailyExpenditureType = 4;
  11544. if ($expenditureMsg == '公司固定') {
  11545. $accountTypeWaste = 9;
  11546. } elseif ($expenditureMsg == '公司活期') {
  11547. $accountTypeWaste = 10;
  11548. } elseif ($expenditureMsg == '个人(GR)') {
  11549. $accountBank = 'PersonalDeposit';
  11550. }
  11551. $itemWaste = array (
  11552. 'accountPrice' => $expenditurePrice
  11553. );
  11554. } elseif ($expenditureType == 1) {
  11555. $dailyExpenditureType = 1;
  11556. } elseif ($expenditureType == 2) {
  11557. $dailyExpenditureType = 2;
  11558. } elseif ($expenditureType == 3) {
  11559. $dailyExpenditureType = 3;
  11560. } elseif ($expenditureType == 5) {
  11561. $dailyExpenditureType = 5;
  11562. }
  11563. if (empty ( $dailyExpenditureType ))
  11564. die ( 'illegal request' );
  11565. Doo::loadModel ( "accountBook" );
  11566. $accountBook = new accountBook ();
  11567. $accountBook->expenditureType = $expenditureType;
  11568. $accountBook->expenditureMsg = $expenditureMsg;
  11569. $accountBook->expenditurePrice = $expenditurePrice;
  11570. $accountBook->expenditureBank = $expenditureBank;
  11571. $accountBook->expenditureDate = $expenditureDate;
  11572. $accountBook->remarks = $remarks;
  11573. $accountBook->expensesType = 2;
  11574. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11575. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11576. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11577. $id = $accountBook->insert ();
  11578. //
  11579. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11580. Doo::loadModel ( "accountBookStatistics" );
  11581. $accountBookStatistics = new accountBookStatistics ();
  11582. $item = array (
  11583. 'date' => date ( "Y-m-d" ),
  11584. 'expenditureType' => $abDetail ['expenditureType'],
  11585. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11586. 'aid' => $abDetail ['aid']
  11587. );
  11588. if ($abDetail ['expensesType'] == 2) {
  11589. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11590. $item += array (
  11591. 'financingPrice' => $expenditurePrice,
  11592. 'expensesType' => 3
  11593. );
  11594. } elseif ($abDetail ['expenditureType'] == 5) {
  11595. $item += array (
  11596. 'payPrice' => $abDetail ['expenditurePrice'],
  11597. 'expensesType' => $abDetail ['expensesType']
  11598. );
  11599. } else {
  11600. $item += array (
  11601. 'payPrice' => $abDetail ['expenditurePrice'],
  11602. 'expensesType' => $abDetail ['expensesType']
  11603. );
  11604. }
  11605. }
  11606. $accountBookStatistics->setAccountBookStatistics ( $item );
  11607. // 公司流水记录
  11608. Doo::loadModel ( 'wasteBook' );
  11609. $wasteBook = new wasteBook ();
  11610. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11611. // 银行
  11612. if (empty ( $abDetail )) {
  11613. $itemWaste += array (
  11614. 'accountPriceShow' => $expenditurePrice,
  11615. 'dataID' => $id,
  11616. 'expensesType' => 2,
  11617. 'accountType' => $accountTypeWaste,
  11618. 'dailyExpenditureType' => $expenditureType,
  11619. 'accountBank' => $accountBank,
  11620. 'category' => $this->staff [0] ['category'],
  11621. 'cid' => $this->staff [0] ['cid'],
  11622. 'name' => $this->staff [0] ['username'],
  11623. 'sid' => $this->staff [0] ['sid'],
  11624. 'inputDate' => date ( "Y-m-d H:i:s" )
  11625. );
  11626. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11627. }
  11628. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11629. if ($expenditureType == 4 || $expenditureType == 6) {
  11630. $accountBank = 'CGBDeposit';
  11631. $dailyIncomeType = 7;
  11632. $receivedBank = '纵横广发';
  11633. if ($expenditureType == 6) {
  11634. $accountBank = 'ICBCDeposit';
  11635. $receivedBank = '纵横工行';
  11636. $dailyIncomeType = 9;
  11637. }
  11638. // 添加一笔收入
  11639. $accountBook = new accountBook ();
  11640. $accountBook->accountType = $dailyIncomeType;
  11641. $accountBook->accountMsg = $expenditureMsg;
  11642. $accountBook->receivedPrice = $expenditurePrice;
  11643. $accountBook->receivedBank = $receivedBank;
  11644. $accountBook->receivedDate = $expenditureDate;
  11645. $accountBook->remarks = $remarks;
  11646. $accountBook->expensesType = 1;
  11647. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11648. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11649. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11650. $id = $accountBook->insert ();
  11651. // 添加一笔收入流水
  11652. $itemWaste = array (
  11653. 'accountPriceShow' => $expenditurePrice,
  11654. 'accountPrice' => - $expenditurePrice,
  11655. 'dataID' => $id,
  11656. 'expensesType' => 1,
  11657. 'accountType' => $accountTypeWaste,
  11658. 'dailyIncomeType' => $dailyIncomeType,
  11659. 'accountBank' => $accountBank,
  11660. 'category' => $this->staff [0] ['category'],
  11661. 'cid' => $this->staff [0] ['cid'],
  11662. 'name' => $this->staff [0] ['username'],
  11663. 'sid' => $this->staff [0] ['sid'],
  11664. 'inputDate' => date ( "Y-m-d H:i:s" )
  11665. );
  11666. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11667. }
  11668. }
  11669. return '/payments';
  11670. }
  11671. /**
  11672. * 所有收支
  11673. */
  11674. function paymentsAchieve() {
  11675. $page_size = 12;
  11676. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11677. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11678. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11679. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11680. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11681. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11682. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11683. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11684. Doo::loadModel ( "accountBookStatistics" );
  11685. $accountBookStatistics = new accountBookStatistics ();
  11686. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11687. $data ['statisticsList'] = $statisticsList;
  11688. Doo::loadModel ( "accountBook" );
  11689. $accountBook = new accountBook ();
  11690. $con = '';
  11691. if ($expensesType == 'INCOME')
  11692. $con = ' and expensesType=1 ';
  11693. elseif ($expensesType == 'PAY')
  11694. $con = ' and expensesType=2 ';
  11695. $dateArr = explode ( ':', $date );
  11696. $D1 = $dateString = '';
  11697. $D2 = '';
  11698. if (! empty ( $date )) {
  11699. $D1 = $dateArr [0];
  11700. if (isset ( $dateArr [1] ))
  11701. $D2 = $dateArr [1];
  11702. else
  11703. $D2 = '';
  11704. $dateString = $D1 . " : " . $D2;
  11705. }
  11706. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11707. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11708. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11709. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11710. if (! empty ( $price ))
  11711. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11712. if ($submitType == 1) {
  11713. if ($accountType != '') {
  11714. $expenditureType = '';
  11715. $con .= ' and accountType=' . $accountType;
  11716. if (! empty ( $accountMsg ))
  11717. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11718. }
  11719. } elseif ($submitType == 2) {
  11720. if ($expenditureType != '') {
  11721. $accountType = $accountMsg = '';
  11722. $con .= ' and expenditureType=' . $expenditureType;
  11723. }
  11724. } else {
  11725. $accountType = $accountMsg = $expenditureType = '';
  11726. }
  11727. $sql = "" . $con;
  11728. $action = "paymentsAchieve";
  11729. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11730. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11731. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11732. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11733. $data ['expenditureType'] = $expenditureType;
  11734. $data ['accountMsg'] = $accountMsg;
  11735. $data ['accountType'] = $accountType;
  11736. $data ['inputDate'] = $date;
  11737. $data ['price'] = $price;
  11738. $data ['expensesType'] = $expensesType;
  11739. $data ['page'] = $pageinfo;
  11740. $data ['list'] = $list;
  11741. $data ['memu'] = "receipt";
  11742. $data ['staff'] = $this->staff;
  11743. $data ['receiptMemu'] = 'payments';
  11744. $data ['verifyId'] = $this->verifyId;
  11745. $data ['executeId'] = $this->executeId;
  11746. $this->render ( "/expenses/paymentsAchieve", $data );
  11747. }
  11748. function paymentsIncomeUpdateDo() {
  11749. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11750. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11751. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11752. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11753. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11754. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11755. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11756. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11757. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11758. Doo::loadClass ( 'XDeode' );
  11759. $XDeode = new XDeode ( 5 );
  11760. $aid = $XDeode->decode ( $aidKey );
  11761. Doo::loadModel ( "accountBook" );
  11762. $accountBook = new accountBook ();
  11763. //
  11764. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11765. $price = $receivedPrice - $abDetail [inComePrice];
  11766. Doo::loadModel ( "accountBookStatistics" );
  11767. $accountBookStatistics = new accountBookStatistics ();
  11768. if ($abDetail ['accountType'] == 7) {
  11769. $item += array (
  11770. 'date' => date ( "Y-m-d" ),
  11771. 'financingPrice' => - $price,
  11772. 'expensesType' => 3,
  11773. 'aid' => $abDetail ['aid']
  11774. );
  11775. } elseif ($abDetail ['accountType'] == 8) {
  11776. $item += array (
  11777. 'date' => date ( "Y-m-d" ),
  11778. 'expensesType' => $abDetail ['expensesType'],
  11779. 'inComePrice' => - $price,
  11780. 'aid' => $abDetail ['aid']
  11781. );
  11782. } else {
  11783. $item = array (
  11784. 'date' => date ( "Y-m-d" ),
  11785. 'expensesType' => $abDetail ['expensesType'],
  11786. 'inComePrice' => $price,
  11787. 'aid' => $abDetail ['aid']
  11788. );
  11789. }
  11790. $accountBookStatistics->setAccountBookStatistics ( $item );
  11791. $accountBook->accountType = $accountType;
  11792. $accountBook->accountMsg = $accountMsg;
  11793. $accountBook->receivedPrice = $receivedPrice;
  11794. $accountBook->receivedMsg = $receivedMsg;
  11795. $accountBook->receivedBank = $receivedBank;
  11796. $accountBook->receivedDate = $receivedDate;
  11797. $accountBook->remarks = $remarks;
  11798. $accountBook->aid = $aid;
  11799. $accountBook->update ();
  11800. }
  11801. return '/paymentsAchieve';
  11802. }
  11803. function paymentsExpenditureEdiDo() {
  11804. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11805. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11806. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11807. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11808. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11809. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11810. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11811. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11812. Doo::loadClass ( 'XDeode' );
  11813. $XDeode = new XDeode ( 5 );
  11814. $aid = $XDeode->decode ( $aidKey );
  11815. Doo::loadModel ( "accountBook" );
  11816. $accountBook = new accountBook ();
  11817. // 汇总信息
  11818. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11819. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11820. Doo::loadModel ( "accountBookStatistics" );
  11821. $accountBookStatistics = new accountBookStatistics ();
  11822. if ($abDetail ['expenditureType'] == 4) {
  11823. $item += array (
  11824. 'date' => date ( "Y-m-d" ),
  11825. 'financingPrice' => $price,
  11826. 'expensesType' => 3,
  11827. 'aid' => $abDetail ['aid']
  11828. );
  11829. } elseif ($abDetail ['expenditureType'] == 5) {
  11830. $item += array (
  11831. 'date' => date ( "Y-m-d" ),
  11832. 'expensesType' => $abDetail ['expensesType'],
  11833. 'payPrice' => $price,
  11834. 'aid' => $abDetail ['aid']
  11835. );
  11836. } else {
  11837. $item = array (
  11838. 'date' => date ( "Y-m-d" ),
  11839. 'expensesType' => $abDetail ['expensesType'],
  11840. 'payPrice' => $price,
  11841. 'aid' => $abDetail ['aid']
  11842. );
  11843. }
  11844. $accountBookStatistics->setAccountBookStatistics ( $item );
  11845. //
  11846. $accountBook->expenditureType = $expenditureType;
  11847. $accountBook->expenditureMsg = $expenditureMsg;
  11848. $accountBook->expenditurePrice = $expenditurePrice;
  11849. $accountBook->expenditureBank = $expenditureBank;
  11850. $accountBook->remarks = $remarks;
  11851. $accountBook->expenditureDate = $expenditureDate;
  11852. $accountBook->aid = $aid;
  11853. $id = $accountBook->update ();
  11854. }
  11855. return '/paymentsAchieve';
  11856. }
  11857. function paymentsDelDo() {
  11858. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11859. if (! empty ( $aidKey )) {
  11860. Doo::loadClass ( 'XDeode' );
  11861. $XDeode = new XDeode ( 5 );
  11862. $aid = $XDeode->decode ( $aidKey );
  11863. Doo::loadModel ( "accountBook" );
  11864. $accountBook = new accountBook ();
  11865. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11866. if (empty ( $abDetail ))
  11867. die ( 'illegal request' );
  11868. // 删除收支
  11869. Doo::loadModel ( "accountBookStatistics" );
  11870. $accountBookStatistics = new accountBookStatistics ();
  11871. $item = array (
  11872. 'date' => date ( "Y-m-d" ),
  11873. 'aid' => $abDetail ['aid']
  11874. );
  11875. $accountType = '';
  11876. if ($abDetail ['expensesType'] == 1) {
  11877. $accountType = 6;
  11878. if ($abDetail ['accountType'] != 7) {
  11879. $item += array (
  11880. 'expensesType' => $abDetail ['expensesType'],
  11881. 'inComePrice' => - $abDetail ['receivedPrice']
  11882. );
  11883. } else {
  11884. $item += array (
  11885. 'financingPrice' => $abDetail ['receivedPrice'],
  11886. 'expensesType' => 3
  11887. );
  11888. }
  11889. } elseif ($abDetail ['expensesType'] == 2) {
  11890. $accountType = 5;
  11891. if ($abDetail ['accountType'] != 7) {
  11892. $item += array (
  11893. 'expensesType' => $abDetail ['expensesType'],
  11894. 'payPrice' => - $abDetail ['expenditurePrice']
  11895. );
  11896. } else {
  11897. $item += array (
  11898. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11899. 'expensesType' => 3
  11900. );
  11901. }
  11902. }
  11903. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11904. if ($abDetail ['expenditureMsg'] == '公司固定')
  11905. $accountType = 9;
  11906. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11907. $accountType = 10;
  11908. }
  11909. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11910. if ($abDetail ['accountMsg'] == '公司固定')
  11911. $accountType = 9;
  11912. elseif ($abDetail ['accountMsg'] == '公司活期')
  11913. $accountType = 10;
  11914. }
  11915. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11916. $accountType = 10;
  11917. }
  11918. $accountBookStatistics->setAccountBookStatistics ( $item );
  11919. $accountBook->delete ( array (
  11920. 'where' => 'aid=' . $aid,
  11921. 'limit' => 1
  11922. ) );
  11923. // 删除收入流水
  11924. if (! empty ( $accountType )) {
  11925. Doo::loadModel ( 'wasteBook' );
  11926. $wasteBook = new wasteBook ();
  11927. $wasteBook->delete ( array (
  11928. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11929. 'limit' => 1
  11930. ) );
  11931. }
  11932. }
  11933. return '/paymentsAchieve';
  11934. }
  11935. function paymentsCollect() {
  11936. Doo::loadModel ( "execute" );
  11937. $execute = new execute ();
  11938. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11939. die ( 'illegal request' );
  11940. }
  11941. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11942. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11943. Doo::loadModel ( "accountBookStatistics" );
  11944. $accountBookStatistics = new accountBookStatistics ();
  11945. Doo::loadClass ( 'receipt.func' );
  11946. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11947. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11948. $data ['html'] = $html ['html'];
  11949. $data ['inSum'] = $html ['sum'];
  11950. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11951. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11952. $data ['payHtml'] = $html ['html'];
  11953. $data ['paySum'] = $html ['sum'];
  11954. // 余额统计
  11955. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11956. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11957. include './protected/config/wasteBook.conf.php';
  11958. Doo::loadModel ( 'wasteBook' );
  11959. $wasteBook = new wasteBook ();
  11960. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11961. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11962. // 获得年份之前所有金额
  11963. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11964. // print_r($detail);
  11965. // $waste['total'];
  11966. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11967. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11968. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11969. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11970. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11971. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11972. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11973. if (date ( 'Y' ) > $year) {
  11974. $limitMonth = 12;
  11975. }
  11976. for($i = 1; $i <= 12; $i ++) {
  11977. $inComeA = $payB = 0;
  11978. $falg = true;
  11979. foreach ( $inComePay as $key => $value ) {
  11980. if ($value ['month'] == $i) {
  11981. $falg = false;
  11982. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11983. $inSum += $value ['accountPrice'];
  11984. $showInSum += $value ['accountPriceShow'];
  11985. $inComeA = $value ['accountPrice'];
  11986. break;
  11987. }
  11988. }
  11989. if ($falg)
  11990. $inComeHtml .= '<td class="taR">-</td>';
  11991. $payFalg = true;
  11992. foreach ( $pay as $key => $value ) {
  11993. if ($value ['month'] == $i) {
  11994. $payFalg = false;
  11995. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11996. $paySum += $value ['accountPrice'];
  11997. $showPaySum += $value ['accountPriceShow'];
  11998. $payB = $value ['accountPrice'];
  11999. break;
  12000. }
  12001. }
  12002. if ($payFalg)
  12003. $payHtml .= '<td class="taR">-</td>';
  12004. if (empty ( $balanceC ) || $limitMonth < $i)
  12005. $lastBalanceHtml .= '<td class="taR">-</td>';
  12006. else
  12007. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12008. $balanceC = $balanceC + $inComeA + $payB;
  12009. $balanceSum += $balanceC;
  12010. if (empty ( $balanceC ) || $limitMonth < $i)
  12011. $BalanceHtml .= '<td class="taR">-</td>';
  12012. else
  12013. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12014. // 余额统计
  12015. }
  12016. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12017. $data ['inComeHtml'] = $inComeHtml;
  12018. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12019. $data ['payBalanceHtml'] = $payHtml;
  12020. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12021. $data ['BalanceHtml'] = $BalanceHtml;
  12022. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12023. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12024. $mothHtml = "";
  12025. for($i = 1; $i <= 12; $i ++) {
  12026. if ($moth == $i)
  12027. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12028. else
  12029. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12030. }
  12031. $data ['mothHtml'] = $mothHtml;
  12032. $dateHtml = "";
  12033. $now = date ( "Y" );
  12034. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12035. if ($YEARD <= $now) {
  12036. $dateHtml .= '<option ';
  12037. if ($year == $YEARD) {
  12038. $dateHtml .= 'selected ';
  12039. }
  12040. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12041. }
  12042. }
  12043. $data ['dateHtml'] = $dateHtml;
  12044. $data ['year'] = $year;
  12045. $data ['memu'] = "receipt";
  12046. $data ['staff'] = $this->staff;
  12047. $data ['receiptMemu'] = 'paymentsCollect';
  12048. $data ['verifyId'] = $this->verifyId;
  12049. $data ['executeId'] = $this->executeId;
  12050. $this->render ( "/expenses/paymentsCollect", $data );
  12051. }
  12052. function paymentsCollectDay() {
  12053. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12054. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  12055. if (empty ( $moth ))
  12056. return 'paymentsCollect';
  12057. Doo::loadModel ( "accountBookStatistics" );
  12058. $accountBookStatistics = new accountBookStatistics ();
  12059. $i = 2;
  12060. $y = 2013;
  12061. $day = date ( "t", strtotime ( "$year-$moth" ) );
  12062. Doo::loadClass ( 'receipt.func' );
  12063. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  12064. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  12065. $data ['html'] = $html ['html'];
  12066. $data ['inSum'] = $html ['sum'];
  12067. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  12068. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  12069. $data ['payHtml'] = $html ['html'];
  12070. $data ['paySum'] = $html ['sum'];
  12071. $mothHtml = "";
  12072. for($i = 1; $i <= 12; $i ++) {
  12073. if ($moth == $i)
  12074. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12075. else
  12076. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12077. }
  12078. $data ['mothHtml'] = $mothHtml;
  12079. $data ['year'] = $year;
  12080. // 余额
  12081. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  12082. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  12083. include './protected/config/wasteBook.conf.php';
  12084. Doo::loadModel ( 'wasteBook' );
  12085. $wasteBook = new wasteBook ();
  12086. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  12087. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  12088. // 获得年份之前所有金额
  12089. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  12090. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  12091. $inComeHtml = '<tr><th colspan="2">收入</th>';
  12092. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  12093. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  12094. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  12095. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  12096. // $balanceC = 0;
  12097. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  12098. $limitDay = date ( 'd' );
  12099. $monthLK = ( int ) date ( 'm' );
  12100. if (date ( 'Y' ) > $year) {
  12101. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  12102. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  12103. $limitDay = 0;
  12104. }
  12105. for($i = 1; $i <= $day; $i ++) {
  12106. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  12107. $inComeA = $payB = 0;
  12108. $falg = true;
  12109. foreach ( $inComePay as $key => $value ) {
  12110. if ($value ['day'] == $i) {
  12111. $falg = false;
  12112. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12113. $inSum += $value ['accountPrice'];
  12114. $showInSum += $value ['accountPriceShow'];
  12115. $inComeA = $value ['accountPrice'];
  12116. break;
  12117. }
  12118. }
  12119. if ($falg)
  12120. $inComeHtml .= '<td class="taR">-</td>';
  12121. $payFalg = true;
  12122. foreach ( $pay as $key => $value ) {
  12123. if ($value ['day'] == $i) {
  12124. $payFalg = false;
  12125. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  12126. $paySum += $value ['accountPrice'];
  12127. $showPaySum += $value ['accountPriceShow'];
  12128. $payB = $value ['accountPrice'];
  12129. break;
  12130. }
  12131. }
  12132. if ($payFalg)
  12133. $payHtml .= '<td class="taR">-</td>';
  12134. if (empty ( $balanceC ) || $limitDay < $i)
  12135. $lastBalanceHtml .= '<td class="taR">-</td>';
  12136. else
  12137. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12138. $balanceC = $balanceC + $inComeA + $payB;
  12139. $balanceSum += $balanceC;
  12140. if (empty ( $balanceC ) || $limitDay < $i)
  12141. $BalanceHtml .= '<td class="taR">-</td>';
  12142. else
  12143. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  12144. }
  12145. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  12146. $data ['inComeHtml'] = $inComeHtml;
  12147. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  12148. $data ['payBalanceHtml'] = $payHtml;
  12149. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  12150. $data ['BalanceHtml'] = $BalanceHtml;
  12151. $dayHtml .= '<td class="taR ">总计</td></tr>';
  12152. $data ['dayHtml'] = $dayHtml;
  12153. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  12154. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  12155. $dateHtml = "";
  12156. $now = date ( "Y" );
  12157. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  12158. if ($YEARD <= $now) {
  12159. $dateHtml .= '<option ';
  12160. if ($year == $YEARD) {
  12161. $dateHtml .= 'selected ';
  12162. }
  12163. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  12164. }
  12165. }
  12166. $data ['dateHtml'] = $dateHtml;
  12167. $data ['memu'] = "receipt";
  12168. $data ['staff'] = $this->staff;
  12169. $data ['receiptMemu'] = 'paymentsCollect';
  12170. $data ['verifyId'] = $this->verifyId;
  12171. $data ['executeId'] = $this->executeId;
  12172. $this->render ( "/expenses/paymentsCollectDay", $data );
  12173. }
  12174. // 公司流水
  12175. function wasteBook() {
  12176. Doo::loadModel ( "execute" );
  12177. $execute = new execute ();
  12178. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  12179. die ( 'illegal request' );
  12180. }
  12181. include './protected/config/wasteBook.conf.php';
  12182. Doo::loadModel ( 'wasteBook' );
  12183. $wasteBook = new wasteBook ();
  12184. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  12185. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  12186. //
  12187. $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'];
  12188. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  12189. // print_r($waste);
  12190. $data ['waste'] = $waste;
  12191. $data ['total'] = $total;
  12192. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  12193. $data['cashBalance']= $CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  12194. // 月流水数据结构
  12195. $monthStatistics = array ();
  12196. $incomeMothStatistics = array ();
  12197. $expenditureMothStatistics = array ();
  12198. for($i = 1; $i <= 12; $i ++) {
  12199. $month = date ( 'Y' ) . '-' . $i;
  12200. if ($i < 10)
  12201. $month = date ( 'Y' ) . '-0' . $i;
  12202. array_push ( $monthStatistics, $month );
  12203. }
  12204. foreach ( $monthStatistics as $value ) {
  12205. $falg = true;
  12206. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  12207. if ($value == $v ['inputDate']) {
  12208. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  12209. $falg = false;
  12210. }
  12211. }
  12212. if ($falg) {
  12213. array_push ( $incomeMothStatistics, '' );
  12214. }
  12215. $falgEx = true;
  12216. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  12217. if ($value == $v ['inputDate']) {
  12218. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  12219. $falg = false;
  12220. }
  12221. }
  12222. if ($falgEx) {
  12223. array_push ( $expenditureMothStatistics, '' );
  12224. }
  12225. }
  12226. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  12227. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  12228. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  12229. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  12230. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  12231. // print_r($incomeList);
  12232. $data ['expenditureList'] = $expenditureList;
  12233. $data ['incomeList'] = $incomeList;
  12234. $data ['memu'] = "receipt";
  12235. $data ['staff'] = $this->staff;
  12236. $data ['receiptMemu'] = 'wasteBook';
  12237. $data ['verifyId'] = $this->verifyId;
  12238. $data ['executeId'] = $this->executeId;
  12239. $this->render ( "/expenses/wasteBook", $data );
  12240. }
  12241. function wasteBookIncome() {
  12242. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12243. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12244. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12245. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  12246. $data ['dailyIncomeType'] = $dailyIncomeType;
  12247. Doo::loadModel ( 'wasteBook' );
  12248. $wasteBook = new wasteBook ();
  12249. Doo::loadModel ( 'L_category' );
  12250. $L_category = new L_category ();
  12251. Doo::loadClass ( 'XDeode' );
  12252. $XDeode = new XDeode ( 5 );
  12253. // echo $XDeode->encode(1).'<br>';
  12254. // echo $XDeode->encode(2).'<br>';
  12255. // echo $XDeode->encode(3).'<br>';
  12256. // echo $XDeode->encode(4).'<br>';
  12257. // echo $XDeode->encode(5).'<br>';
  12258. // echo $XDeode->encode(6).'<br>';
  12259. // echo $XDeode->encode(7).'<br>';
  12260. // echo $XDeode->encode(8).'<br>';
  12261. // echo $XDeode->encode(9).'<br>';
  12262. // echo $XDeode->encode(10).'<br>';
  12263. $year=date("Y");
  12264. $theDay=date("Y-m-d");
  12265. $dateArr = explode ( ':', $date );
  12266. $D1 = '';
  12267. $D2 = '';
  12268. $con = '';
  12269. if (! empty ( $date )) {
  12270. $D1 = $dateArr [0];
  12271. $D2 = $dateArr [1];
  12272. }
  12273. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12274. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12275. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12276. $con = ' and inputDate = "' . $D1 . '"';
  12277. else{
  12278. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12279. }
  12280. if ($cid != 'ALL') {
  12281. $cid = $XDeode->decode ( $cid );
  12282. $con .= ' and cid = "' . $cid . '"';
  12283. }
  12284. if ($accountType != 'ALL') {
  12285. if ($accountType == 'INVOICE') {
  12286. $con .= ' and (accountType = 7 or accountType = 8)';
  12287. } elseif ($accountType == 'PAYMENTS') {
  12288. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  12289. if ($dailyIncomeType != 'ALL') {
  12290. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  12291. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  12292. }
  12293. }
  12294. }
  12295. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  12296. $sum = 0;$thsDaySum=0;
  12297. foreach ( $incomeList as $key => $value ) {
  12298. $sum += $value ['accountPrice'];
  12299. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12300. $thsDaySum+=$value ['accountPrice'];
  12301. }
  12302. }
  12303. // print_r($incomeList);
  12304. // 获得办事和部门
  12305. $categoryList = $L_category->getCategory ();
  12306. $data ['accountType'] = $accountType;
  12307. $data ['cid'] = $cid;
  12308. $data ['categoryList'] = $categoryList;
  12309. $data ['sum'] = $sum;
  12310. $data ['incomeList'] = $incomeList;
  12311. $data ['inputDate'] = $date;
  12312. $data['year']=$year;
  12313. $data ['thsDay'] =$theDay;
  12314. $data ['thsDaySum'] =$thsDaySum;
  12315. $data ['memu'] = "receipt";
  12316. $data ['staff'] = $this->staff;
  12317. $data ['receiptMemu'] = 'wasteBook';
  12318. $data ['verifyId'] = $this->verifyId;
  12319. $data ['executeId'] = $this->executeId;
  12320. $this->render ( "/expenses/wasteBookIncome", $data );
  12321. }
  12322. /**
  12323. * 所有支出
  12324. */
  12325. function wasteBookExpenditure() {
  12326. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  12327. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  12328. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  12329. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  12330. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  12331. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  12332. $data ['receiptType'] = $receiptType;
  12333. Doo::loadModel ( 'wasteBook' );
  12334. $wasteBook = new wasteBook ();
  12335. Doo::loadModel ( 'L_category' );
  12336. $L_category = new L_category ();
  12337. Doo::loadClass ( 'XDeode' );
  12338. $XDeode = new XDeode ( 5 );
  12339. $year=date("Y");
  12340. $theDay=date("Y-m-d");
  12341. $dateArr = explode ( ':', $date );
  12342. $D1 = '';
  12343. $D2 = '';
  12344. $con = '';
  12345. if (! empty ( $date )) {
  12346. $D1 = $dateArr [0];
  12347. $D2 = $dateArr [1];
  12348. }
  12349. if (! empty ( $D1 ) && ! empty ( $D2 ))
  12350. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  12351. elseif (! empty ( $D1 ) && empty ( $D2 ))
  12352. $con = ' and inputDate = "' . $D1 . '"';
  12353. else{
  12354. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  12355. }
  12356. if ($cid != 'ALL') {
  12357. $cid = $XDeode->decode ( $cid );
  12358. $con .= ' and cid = "' . $cid . '"';
  12359. }
  12360. if ($accountType != 'ALL') {
  12361. if ($accountType == 'INVOICE') {
  12362. $con .= ' and accountType = 11';
  12363. } elseif ($accountType == 'PAYMENTS') {
  12364. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  12365. if ($dailyExpenditureType != 'ALL') {
  12366. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  12367. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  12368. }
  12369. } elseif ($accountType == 'RECEIPT') {
  12370. if ($receiptType == 'ALL') {
  12371. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  12372. } else {
  12373. $receiptType = $XDeode->decode ( $receiptType );
  12374. echo $receiptType;
  12375. if ($receiptType == 1) {
  12376. $con .= ' and (accountType = 1 or accountType=2)';
  12377. } else {
  12378. $con .= ' and accountType = ' . $receiptType;
  12379. }
  12380. }
  12381. }
  12382. }
  12383. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  12384. $sum = 0;$thsDaySum=0;
  12385. foreach ( $incomeList as $key => $value ) {
  12386. $sum += $value ['accountPriceShow'];
  12387. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  12388. $thsDaySum+=$value ['accountPriceShow'];
  12389. }
  12390. }
  12391. // print_r($incomeList);
  12392. // 获得办事和部门
  12393. $categoryList = $L_category->getCategory ();
  12394. $data ['accountType'] = $accountType;
  12395. $data ['cid'] = $cid;
  12396. $data ['categoryList'] = $categoryList;
  12397. $data ['sum'] = $sum;
  12398. $data ['incomeList'] = $incomeList;
  12399. $data ['inputDate'] = $date;
  12400. $data['year']=$year;
  12401. $data ['thsDay'] =$theDay;
  12402. $data ['thsDaySum'] =$thsDaySum;
  12403. $data ['memu'] = "receipt";
  12404. $data ['staff'] = $this->staff;
  12405. $data ['receiptMemu'] = 'wasteBook';
  12406. $data ['verifyId'] = $this->verifyId;
  12407. $data ['executeId'] = $this->executeId;
  12408. $this->render ( "/expenses/wasteBookExpenditure", $data );
  12409. }
  12410. function ajaxGetWasteinvoiceReceivables() {
  12411. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12412. Doo::loadClass ( 'XDeode' );
  12413. $XDeode = new XDeode ( 5 );
  12414. $irid = $XDeode->decode ( $serial );
  12415. Doo::loadModel ( 'invoiceReceivables' );
  12416. $invoiceReceivables = new invoiceReceivables ();
  12417. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  12418. echo json_encode ( array (
  12419. 'status' => 1,
  12420. 'detail' => $detail
  12421. ) );
  12422. }
  12423. function ajaxGetPaymentsByAid() {
  12424. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12425. Doo::loadModel ( "accountBook" );
  12426. $accountBook = new accountBook ();
  12427. $detail = $accountBook->getAccountBookByAid ( $serial );
  12428. echo json_encode ( array (
  12429. 'status' => 1,
  12430. 'detail' => $detail
  12431. ) );
  12432. }
  12433. function ajaxGetWasteInvoice() {
  12434. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12435. Doo::loadModel ( 'invoice' );
  12436. $invoice = new invoice ();
  12437. Doo::loadModel ( 'invoiceReceivables' );
  12438. $invoiceReceivables = new invoiceReceivables ();
  12439. $detail = $invoice->getInvoiceByIid ( $serial );
  12440. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  12441. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  12442. echo json_encode ( array (
  12443. 'status' => 1,
  12444. 'detail' => $detail
  12445. ) );
  12446. }
  12447. /**
  12448. */
  12449. function ajaxGetWasteReceipt() {
  12450. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  12451. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  12452. Doo::loadModel ( 'receipt' );
  12453. $receipt = new receipt ();
  12454. Doo::loadClass ( 'XDeode' );
  12455. $XDeode = new XDeode ( 5 );
  12456. $rid = $XDeode->decode ( $serial );
  12457. $accountType= $XDeode->decode ( $accountTypeKey );
  12458. // 获得个数据
  12459. $detail = $receipt->getReceiptByRid ( $rid );
  12460. // 初始化
  12461. $detail ['reviseDetail'] = array ();
  12462. if (! empty ( $value ['reviseDetail'] ))
  12463. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12464. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12465. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12466. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12467. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12468. // 获得费用html
  12469. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12470. // 获得费用审批人数据
  12471. $detail = $this->getReceiptApproverHtml ( $detail );
  12472. // 审批执行
  12473. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12474. <th class="taC" width="90">审批人</th>
  12475. <th class="taC">审批意见</th></tr>';
  12476. foreach ( $detail ['verifyList'] as $key => $value ) {
  12477. $html .= '<tr>
  12478. <td>' . $value [1] . '</td>
  12479. <td>' . $value ['opinion'] . '</td>
  12480. </tr>
  12481. ';
  12482. }
  12483. $html .= ' </tbody></table>';
  12484. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12485. <th class="taC" width="90">执行人</th>
  12486. <th class="taC">执行意见</th></tr>';
  12487. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12488. $html .= '<tr>
  12489. <td>' . $value [1] . '</td>
  12490. <td>' . $value ['opinion'] . '</td>
  12491. </tr>
  12492. ';
  12493. }
  12494. $html .= ' </tbody></table>';
  12495. if($accountType==1){
  12496. Doo::loadModel ( 'loanReceipt' );
  12497. $loanReceipt = new loanReceipt ();
  12498. $loanList = $loanReceipt->getOne ( array (
  12499. 'where' => 'rid=' . $detail ['loanRid'],
  12500. 'desc' => 'rid',
  12501. 'asArray' => true
  12502. ) );
  12503. $html .= '<table class="table table-bordered table-condensed">
  12504. <tr class="warning">
  12505. <td class="taR"><b>汇款金额</b></td>
  12506. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12507. </tr>
  12508. </table>';
  12509. }else{
  12510. $html .= '<table class="table table-bordered table-condensed">
  12511. <tr class="warning">
  12512. <td class="taR"><b>汇款金额</b></td>
  12513. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12514. </tr>
  12515. </table>';
  12516. }
  12517. // print_r($detail['verifyList']);
  12518. // header ( 'Content-Type:text/html;charset=utf-8' );
  12519. // echo $html;
  12520. echo json_encode ( array (
  12521. 'status' => 1,
  12522. 'html' => $html,
  12523. 'detail' => $detail
  12524. ) );
  12525. }
  12526. function getReceiptApproverHtml($detail = array()) {
  12527. Doo::loadModel ( 'loanReceipt' );
  12528. $loanReceipt = new loanReceipt ();
  12529. Doo::loadModel ( 'verify' );
  12530. $verify = new verify ();
  12531. Doo::loadModel ( 'staff' );
  12532. $staff = new staff ();
  12533. if (empty ( $detail ))
  12534. return array ();
  12535. $loanList = $loanReceipt->getOne ( array (
  12536. 'where' => 'rid=' . $detail ['loanRid'],
  12537. 'desc' => 'rid',
  12538. 'asArray' => true
  12539. ) );
  12540. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12541. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12542. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12543. else
  12544. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12545. } else
  12546. $verifyList = $verify->getOne ( array (
  12547. 'where' => 'vid=' . $detail ['verify'],
  12548. 'asArray' => true
  12549. ) );
  12550. $verifyList = json_decode ( $verifyList ['staff'], true );
  12551. Doo::loadModel ( 'role' );
  12552. $role = new role ();
  12553. $roleId = 0;
  12554. $flag = true;
  12555. $roleKey = 0;
  12556. $endStaffArray = array ();
  12557. $roleArrayCopy = array ();
  12558. foreach ( $verifyList as $k => $v ) {
  12559. // init verifyStaff
  12560. if ($v [1] == 'ROLE') {
  12561. if (! empty ( $verifyStaff )) {
  12562. $endStaffArray = end ( $verifyStaff );
  12563. }
  12564. $roleVerify = json_decode ( $v [3], true );
  12565. $roleKey = $k;
  12566. $roleArray = array ();
  12567. $rolename = $role->getOne ( array (
  12568. 'where' => 'rid=' . $v [0],
  12569. 'asArray' => true
  12570. ) );
  12571. foreach ( $roleVerify as $o => $p ) {
  12572. $staffID = explode ( '_', $p );
  12573. $staffInfo = $staff->getOne ( array (
  12574. 'where' => 'sid=' . $staffID [0],
  12575. 'asArray' => true
  12576. ) );
  12577. // print_r($staffID);
  12578. $exp = array (
  12579. 0 => $staffInfo ['sid'],
  12580. 1 => $staffID [1],
  12581. 2 => $staffInfo ['avatar'],
  12582. 'date' => '',
  12583. 'date' => '',
  12584. 'opinion' => '',
  12585. 'status' => '',
  12586. 'rolename' => $rolename ['name']
  12587. );
  12588. array_push ( $roleArray, $exp );
  12589. }
  12590. $roleArrayCopy [$v [0]] = $roleArray;
  12591. // $verifyList[$k]['roleArray']=$roleArray;
  12592. }
  12593. $verifyList [$k] ['date'] = "";
  12594. $verifyList [$k] ['opinion'] = "";
  12595. $verifyList [$k] ['status'] = "";
  12596. if (empty ( $verifyStaff )) {
  12597. $verifyList [$k] ['date'] = "";
  12598. $verifyList [$k] ['opinion'] = "";
  12599. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12600. $verifyList [$k] ['status'] = 4;
  12601. $flag = false;
  12602. }
  12603. } else {
  12604. foreach ( $verifyStaff as $m => $u ) {
  12605. if ($v [0] == $m) {
  12606. $verifyList [$k] ['date'] = $u ['date'];
  12607. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12608. $verifyList [$k] ['status'] = $u ['status'];
  12609. $flag = false;
  12610. break;
  12611. }
  12612. }
  12613. $endStaffArray = end ( $verifyStaff );
  12614. }
  12615. }
  12616. $rolename ['name'] = '';
  12617. if (! empty ( $roleId )) {
  12618. Doo::loadModel ( 'role' );
  12619. $role = new role ();
  12620. $rolename = $role->getOne ( array (
  12621. 'where' => 'rid=' . $roleId,
  12622. 'asArray' => true
  12623. ) );
  12624. }
  12625. if (! empty ( $verifyStaff ))
  12626. $endStaffArray = end ( $verifyStaff );
  12627. $KOP = false;
  12628. foreach ( $roleArrayCopy as $P => $A ) {
  12629. foreach ( $A as $MKI => $AVL ) {
  12630. if (! empty ( $verifyStaff )) {
  12631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12633. $button = 4;
  12634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12635. }
  12636. foreach ( $verifyStaff as $m => $u ) {
  12637. $AVLFK = $AVL [0] . '_R';
  12638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12643. break;
  12644. }
  12645. }
  12646. } else {
  12647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12648. $button = 4;
  12649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12650. }
  12651. }
  12652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12653. $KOP = true;
  12654. }
  12655. }
  12656. foreach ( $roleArrayCopy as $k => $v ) {
  12657. foreach ( $verifyList as $m => $n ) {
  12658. if ($n [0] == $k) {
  12659. array_splice ( $verifyList, $m, 1, $v );
  12660. }
  12661. }
  12662. }
  12663. // 费用执行人相关数据
  12664. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12665. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12666. foreach ( $executeCopy as $k => $v ) {
  12667. $executeCopy [$k] ['date'] = '';
  12668. $executeCopy [$k] ['opinion'] = '';
  12669. $executeCopy [$k] ['status'] = '';
  12670. if (! empty ( $executeStaff ))
  12671. foreach ( $executeStaff as $m => $u ) {
  12672. if ($v [0] == $m) {
  12673. $executeCopy [$k] ['date'] = $u ['date'];
  12674. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12675. $executeCopy [$k] ['status'] = $u ['status'];
  12676. break;
  12677. }
  12678. }
  12679. }
  12680. $detail ['executeCopy'] = $executeCopy;
  12681. $detail ['verifyList'] = $verifyList;
  12682. return $detail;
  12683. }
  12684. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12685. if (empty ( $detail ))
  12686. return '';
  12687. $html = '';
  12688. if ($detail ['Rtype'] == 0) { // 报销单
  12689. $html .= '<table class="table table-bordered table-condensed">
  12690. <tbody>
  12691. <tr>
  12692. <th colspan="2" class="taC">日常相关费用</th>
  12693. </tr>';
  12694. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12695. $html .= '
  12696. <tr>
  12697. <th>' . $value ['name'] . '</th>
  12698. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12699. </tr>';
  12700. }
  12701. $html .= '
  12702. <tr>
  12703. <th class="taR">合计</th>
  12704. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12705. </tr>';
  12706. $html .= '<tr>
  12707. <th colspan="2" class="taC">差旅相关费用</th>
  12708. </tr>';
  12709. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12710. $html .= '
  12711. <tr>
  12712. <th>' . $value ['name'] . '</th>
  12713. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12714. </tr>';
  12715. }
  12716. $html .= '
  12717. <tr>
  12718. <th class="taR">合计</th>
  12719. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12720. </tr>';
  12721. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12722. $html .= '<tr>
  12723. <th colspan="2" class="taC">内部培训费用</th>
  12724. </tr>';
  12725. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12726. $html .= '
  12727. <tr>
  12728. <th>' . $value ['name'] . '</th>
  12729. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12730. </tr>';
  12731. }
  12732. $html .= '
  12733. <tr>
  12734. <th class="taR">合计</th>
  12735. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12736. </tr>';
  12737. }
  12738. $html .= '<tr>
  12739. <th colspan="2" class="taC">其他</th>
  12740. </tr>';
  12741. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12742. $html .= '
  12743. <tr>
  12744. <th>' . $value ['name'] . '</th>
  12745. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12746. </tr>';
  12747. }
  12748. $html .= '
  12749. <tr>
  12750. <th class="taR">合计</th>
  12751. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12752. </tr>';
  12753. $html .= '<tr>
  12754. <th colspan="2" class="taC">报销金额调整</th>
  12755. </tr>';
  12756. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12757. $html .= '
  12758. <tr>
  12759. <th>' . $value ['name'] . '</th>
  12760. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12761. </tr>';
  12762. }
  12763. $html .= '
  12764. <tr>
  12765. <th class="taR">合计</th>
  12766. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12767. </tr>';
  12768. $html .= '
  12769. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12770. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12771. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12772. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12773. <tr class="warning">
  12774. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12775. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12776. </tr>
  12777. </tbody>
  12778. </table>';
  12779. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12780. $html .= '
  12781. <table class="table table-bordered table-condensed">
  12782. <tbody>
  12783. <tr>
  12784. <th colspan="2" class="taC">办事处相关费用</th>
  12785. </tr>';
  12786. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12787. $html .= '
  12788. <tr>
  12789. <th>' . $value ['name'] . '</th>
  12790. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12791. </tr>';
  12792. }
  12793. $html .= '
  12794. <tr>
  12795. <th class="taR">合计</th>
  12796. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12797. </tr>';
  12798. $html .= '
  12799. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12800. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12801. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12802. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12803. <tr class="warning">
  12804. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12805. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12806. </tr>
  12807. </tbody>
  12808. </table>';
  12809. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12810. Doo::loadModel ( 'loanReceipt' );
  12811. $loanReceipt = new loanReceipt ();
  12812. $loanList = $loanReceipt->getOne ( array (
  12813. 'where' => 'rid=' . $detail ['loanRid'],
  12814. 'desc' => 'rid',
  12815. 'asArray' => true
  12816. ) );
  12817. // print_r($loanList);
  12818. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12819. $html .= '<table class="table table-bordered table-condensed">
  12820. <tbody>
  12821. <tr>
  12822. <th colspan="2" class="taC">借款费用</th>
  12823. </tr>';
  12824. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12825. $html .= '<tr>
  12826. <th>' . $value ['name'] . '</th>
  12827. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12828. </tr>';
  12829. }
  12830. $html .= '<tr>
  12831. <th class="taC" colspan="2">产生费用所在办事处</th>
  12832. </tr>
  12833. <tr>
  12834. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12835. </tr>
  12836. <tr>
  12837. <th class="taC" colspan="2">费用说明</th>
  12838. </tr>
  12839. <tr>
  12840. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12841. </tr>
  12842. <tr class="warning">
  12843. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12844. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12845. </tr>
  12846. </tbody>
  12847. </table>
  12848. ';
  12849. if ( $accountType==2) {
  12850. $balance=$detail ['sum']-$loanList ['sum'];
  12851. $balanceCN=$this->num_to_rmb($balance);
  12852. $html .= '<table class="table table-bordered table-condensed">
  12853. <tbody>
  12854. <tr>
  12855. <th colspan="2" class="taC">日常相关费用</th>
  12856. </tr>';
  12857. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12858. $html .= '
  12859. <tr>
  12860. <th>' . $value ['name'] . '</th>
  12861. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12862. </tr>';
  12863. }
  12864. $html .= '
  12865. <tr>
  12866. <th class="taR">合计</th>
  12867. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12868. </tr>';
  12869. $html .= '<tr>
  12870. <th colspan="2" class="taC">差旅相关费用</th>
  12871. </tr>';
  12872. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12873. $html .= '
  12874. <tr>
  12875. <th>' . $value ['name'] . '</th>
  12876. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12877. </tr>';
  12878. }
  12879. $html .= '
  12880. <tr>
  12881. <th class="taR">合计</th>
  12882. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12883. </tr>';
  12884. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12885. $html .= '<tr>
  12886. <th colspan="2" class="taC">内部培训费用</th>
  12887. </tr>';
  12888. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12889. $html .= '
  12890. <tr>
  12891. <th>' . $value ['name'] . '</th>
  12892. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12893. </tr>';
  12894. }
  12895. $html .= '
  12896. <tr>
  12897. <th class="taR">合计</th>
  12898. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12899. </tr>';
  12900. }
  12901. $html .= '<tr>
  12902. <th colspan="2" class="taC">其他</th>
  12903. </tr>';
  12904. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12905. $html .= '
  12906. <tr>
  12907. <th>' . $value ['name'] . '</th>
  12908. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12909. </tr>';
  12910. }
  12911. $html .= '
  12912. <tr>
  12913. <th class="taR">合计</th>
  12914. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12915. </tr>';
  12916. $html .= '<tr>
  12917. <th colspan="2" class="taC">报销金额调整</th>
  12918. </tr>';
  12919. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12920. $html .= '
  12921. <tr>
  12922. <th>' . $value ['name'] . '</th>
  12923. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12924. </tr>';
  12925. }
  12926. $html .= '
  12927. <tr>
  12928. <th class="taR">合计</th>
  12929. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12930. </tr>';
  12931. $html .= '
  12932. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12933. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12934. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12935. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12936. <tr class="warning">
  12937. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12938. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12939. </tr>
  12940. <tr class="success">
  12941. <td class="taR"><b>借款结余</b></td>
  12942. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12943. </tr>
  12944. </tbody>
  12945. </table>';
  12946. }
  12947. }
  12948. return $html;
  12949. }
  12950. /**
  12951. * 计算流水
  12952. */
  12953. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12954. $bakWaste ['bank'] = array (
  12955. 'CGBDeposit' => 0,
  12956. 'ICBCDeposit' => 0,
  12957. 'HUADeposit' => 0,
  12958. 'PersonalDeposit' => 0
  12959. );
  12960. $bakWaste ['financial'] = array (
  12961. 'current' => array (
  12962. 'CGBDeposit' => 0,
  12963. 'ICBCDeposit' => 0
  12964. ),
  12965. 'fixed' => array (
  12966. 'CGBDeposit' => 0,
  12967. 'ICBCDeposit' => 0
  12968. )
  12969. );
  12970. // 存款
  12971. foreach ( $waste ['bank'] as $key => $value ) {
  12972. // 收入
  12973. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12974. // 广发
  12975. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12976. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12977. }
  12978. // 工商
  12979. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12980. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12981. }
  12982. // 华润
  12983. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12984. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12985. }
  12986. // 个人
  12987. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12988. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12989. }
  12990. }
  12991. }
  12992. foreach ( $waste ['bank'] as $key => $value ) {
  12993. // 支出
  12994. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12995. // 广发
  12996. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12997. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12998. }
  12999. // 工商
  13000. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13001. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13002. }
  13003. // 华润
  13004. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  13005. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  13006. }
  13007. // 个人
  13008. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13009. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13010. }
  13011. }
  13012. }
  13013. // 活期
  13014. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  13015. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  13016. // 广发
  13017. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13018. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13019. }
  13020. // 工商
  13021. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13022. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13023. }
  13024. // 个人
  13025. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13026. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13027. }
  13028. }
  13029. }
  13030. // print_r($inComeStatistics ['fixedStatistics']);
  13031. // 固期
  13032. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  13033. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  13034. // 广发
  13035. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  13036. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  13037. }
  13038. // 工商
  13039. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  13040. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  13041. }
  13042. // 个人
  13043. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  13044. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  13045. }
  13046. }
  13047. }
  13048. return $waste;
  13049. }
  13050. function lyt() {
  13051. Doo::loadModel ( "receiptDetail" );
  13052. $receiptDetail = new receiptDetail ();
  13053. $receiptCollectList = $receiptDetail->find ( array (
  13054. 'where' => 'status=1 ',
  13055. 'asArray' => true
  13056. ) );
  13057. foreach ( $receiptCollectList as $key => $value ) {
  13058. $receiptDetail = new receiptDetail ();
  13059. $receiptDetail->pastDate = $value ['date'];
  13060. $receiptDetail->update ( array (
  13061. 'where' => "rdid= '" . $value ['rdid'] . "'"
  13062. ) );
  13063. }
  13064. }
  13065. function staffCollectMonthDetail() {
  13066. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  13067. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13068. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13069. if (! $year)
  13070. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13071. if (! $month)
  13072. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13073. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  13074. if (! $nature){
  13075. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  13076. }
  13077. Doo::loadModel ( 'staff' );
  13078. $staff = new staff ();
  13079. Doo::loadModel ( "receiptDetail" );
  13080. $receiptDetail = new receiptDetail ();
  13081. Doo::loadModel ( 'accountItem' );
  13082. $accountItem = new accountItem ();
  13083. Doo::loadModel ( 'statistics' );
  13084. $statistics = new statistics ();
  13085. Doo::loadModel ( "receiptAuthorityManage" );
  13086. $receiptAuthorityManage = new receiptAuthorityManage ();
  13087. $aiList=$accountItem->getAccountItem();
  13088. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13089. $cidList = array ();
  13090. foreach ( $imcStaff as $key => $value ) {
  13091. array_push ( $cidList, $value ['cid'] );
  13092. }
  13093. $cidString = implode ( ',', $cidList );
  13094. $naturecon='';
  13095. if ($nature=='ONJOB'){
  13096. $naturecon=' and (nature!=4 )';
  13097. }elseif($nature=='LEAVEJOB'){
  13098. $naturecon=' and (nature=4 )';
  13099. }else{
  13100. die ( 'illegal request--nature' );
  13101. }
  13102. $staffList = $staff->find ( array (
  13103. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  13104. 'asArray' => true
  13105. ) );
  13106. $categoryList = $staff->find ( array (
  13107. 'select' => 'COUNT(*) as count,cid,category',
  13108. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  13109. 'groupby' => 'cid',
  13110. 'asArray' => true
  13111. ) );
  13112. $list = array ();
  13113. foreach($aiList as $key=>$value){
  13114. foreach ($value as $v){
  13115. $subtotal[$key][$v['name']]=0;
  13116. }
  13117. }
  13118. foreach ( $categoryList as $vlu ) {
  13119. $s1 = 0;
  13120. $m1 = 0;
  13121. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  13122. foreach ( $staffList as $value ) {
  13123. if ($vlu ['cid'] == $value ['cid']) {
  13124. // pastDate
  13125. $receiptCollectList = $receiptDetail->find ( array (
  13126. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13127. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13128. 'groupby' => 'item,Month(pastDate),itemCategory',
  13129. 'asArray' => true
  13130. ) );
  13131. if (! empty ( $receiptCollectList )) {
  13132. $receiptL = array (
  13133. '日常相关费用' => array (),
  13134. '差旅相关费用' => array (),
  13135. '内部培训费用' => array (),
  13136. '培训班费用' => array (),
  13137. '其他' => array ()
  13138. );
  13139. $html = "";
  13140. $psum = 0;
  13141. foreach ( $aiList[$this->AGENCY] as $va ) {
  13142. $falg = true;
  13143. foreach ( $receiptCollectList as $v ) {
  13144. if ($v ['itemCategory'] == '日常相关费用') {
  13145. if ($v ['item'] == $va['name']) {
  13146. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  13147. $psum += $v ['price'];
  13148. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13149. $falg = false;
  13150. break;
  13151. }
  13152. }
  13153. }
  13154. if ($falg)
  13155. $html .= '<td class="taR">-</td>';
  13156. }
  13157. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  13158. if (! empty ( $psum ))
  13159. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13160. else
  13161. $psum = '<td class="colGreen taR">-</td>';
  13162. $receiptL ['日常相关费用'] = $psum . $html;
  13163. /* ----------------------------------- */
  13164. $html = "";
  13165. $psum = 0;
  13166. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13167. $falg = true;
  13168. foreach ( $receiptCollectList as $v ) {
  13169. if ($v ['itemCategory'] == '差旅相关费用') {
  13170. if ($v ['item'] == $va['name']) {
  13171. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  13172. $psum += $v ['price'];
  13173. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13174. $falg = false;
  13175. break;
  13176. }
  13177. }
  13178. }
  13179. if ($falg)
  13180. $html .= '<td class="taR">-</td>';
  13181. }
  13182. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  13183. if (! empty ( $psum ))
  13184. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13185. else
  13186. $psum = '<td class="colGreen taR">-</td>';
  13187. $receiptL ['差旅相关费用'] = $psum . $html;
  13188. /* ------------------------------------- */
  13189. $html = "";
  13190. $psum = 0;
  13191. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13192. $falg = true;
  13193. foreach ( $receiptCollectList as $v ) {
  13194. if ($v ['itemCategory'] == '内部培训费用') {
  13195. if ($v ['item'] == $va['name']) {
  13196. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  13197. $psum += $v ['price'];
  13198. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13199. $falg = false;
  13200. break;
  13201. }
  13202. }
  13203. }
  13204. if ($falg)
  13205. $html .= '<td class="taR">-</td>';
  13206. }
  13207. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  13208. if (! empty ( $psum ))
  13209. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13210. else
  13211. $psum = '<td class="colGreen taR">-</td>';
  13212. $receiptL ['内部培训费用'] = $psum . $html;
  13213. /* ----------------------------------- */
  13214. $html = "";
  13215. $psum = 0;
  13216. foreach ( $aiList[$this->TRAIN] as $va ) {
  13217. $falg = true;
  13218. foreach ( $receiptCollectList as $v ) {
  13219. if ($v ['itemCategory'] == '培训班费用') {
  13220. if ($v ['item'] == $va['name']) {
  13221. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  13222. $psum += $v ['price'];
  13223. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13224. $falg = false;
  13225. break;
  13226. }
  13227. }
  13228. }
  13229. if ($falg)
  13230. $html .= '<td class="taR">-</td>';
  13231. }
  13232. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  13233. if (! empty ( $psum ))
  13234. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13235. else
  13236. $psum = '<td class="colGreen taR">-</td>';
  13237. $receiptL ['培训班费用'] = $psum . $html;
  13238. /* ------------------------------------- */
  13239. $html = "";
  13240. $psum = 0;
  13241. foreach ( $aiList[$this->OTHER] as $va ) {
  13242. $falg = true;
  13243. foreach ( $receiptCollectList as $v ) {
  13244. if ($v ['itemCategory'] == '其他') {
  13245. if (trim ( $v ['item'] ) == $va['name']) {
  13246. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  13247. $psum += $v ['price'];
  13248. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13249. $falg = false;
  13250. break;
  13251. }
  13252. }
  13253. }
  13254. if ($falg)
  13255. $html .= '<td class="taR">-</td>';
  13256. }
  13257. $subtotal[$this->OTHER]['OTHER'] += $psum;
  13258. if (! empty ( $psum ))
  13259. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13260. else
  13261. $psum = '<td class="colGreen taR">-</td>';
  13262. $receiptL ['其他'] = $psum . $html;
  13263. /* ------------------------------------- */
  13264. $html = "";
  13265. $psum = 0;
  13266. foreach ( $receiptCollectList as $v ) {
  13267. if ($v ['itemCategory'] == '报销金额调整') {
  13268. if (! empty ( $v ['price'] )) {
  13269. $psum += $v ['price'];
  13270. }
  13271. }
  13272. }
  13273. $s1 += $psum;
  13274. if (! empty ( $psum ))
  13275. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13276. else
  13277. $psum = '<td class="taR colOrange">-</td>';
  13278. $receiptL ['报销金额调整'] = $psum . $html;
  13279. } else {
  13280. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13281. foreach ( $aiList[$this->AGENCY] as $va ) {
  13282. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13283. }
  13284. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13285. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13286. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13287. }
  13288. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13289. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13290. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13291. }
  13292. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13293. foreach ( $aiList[$this->TRAIN] as $va ) {
  13294. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13295. }
  13296. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13297. foreach ( $aiList[$this->OTHER] as $va ) {
  13298. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13299. }
  13300. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13301. }
  13302. $monthStaffPrice = $receiptDetail->find ( array (
  13303. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13304. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13305. 'groupby' => 'Month(pastDate)',
  13306. 'asArray' => true
  13307. ) );
  13308. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  13309. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13310. $m1 += $monthStaffPrice [0] ['price'];
  13311. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13312. } else
  13313. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13314. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  13315. $list [$value ['username']] = $receiptL;
  13316. }
  13317. }
  13318. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  13319. foreach ( $aiList[$this->AGENCY] as $va ) {
  13320. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  13321. $subtotal[$this->AGENCY][$va['name']]=0;
  13322. }
  13323. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  13324. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13325. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  13326. $subtotal[$this->TRAVEL][$va['name']]=0;
  13327. }
  13328. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  13329. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13330. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  13331. $subtotal[$this->INTTRAIN][$va['name']]=0;
  13332. }
  13333. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  13334. foreach ( $aiList[$this->TRAIN] as $va ) {
  13335. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  13336. $subtotal[$this->TRAIN][$va['name']]=0;
  13337. }
  13338. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  13339. foreach ( $aiList[$this->OTHER] as $va ) {
  13340. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  13341. $subtotal[$this->OTHER][$va['name']]=0;
  13342. }
  13343. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13344. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13345. $receiptL ['usernameEn'] =false;
  13346. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13347. }
  13348. $data ['list'] = $list;
  13349. // print_r($list);
  13350. $receiptCollectList = $receiptDetail->find ( array (
  13351. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13352. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13353. 'groupby' => 'item,Month(pastDate),itemCategory',
  13354. 'asArray' => true
  13355. ) );
  13356. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13357. // statistics html
  13358. $stList = $statistics->getOne ( array (
  13359. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13360. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13361. 'groupby' => 'Month(date)',
  13362. 'asArray' => true
  13363. ) );
  13364. if (empty ( $stList ))
  13365. $stList = array (
  13366. 'rePrice' => 0,
  13367. 'agPrice' => 0
  13368. );
  13369. $data ['stList'] = array (
  13370. 'rePrice' => $stList ['rePrice'],
  13371. 'agPrice' => $stList ['agPrice'],
  13372. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13373. );
  13374. $monthHtml = "";
  13375. for($i = 1; $i <= 12; $i ++) {
  13376. if ($i == $month)
  13377. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13378. else
  13379. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13380. }
  13381. $data ['monthHtml'] = $monthHtml;
  13382. $data ['year'] = $year;
  13383. $data ['month'] = $month;
  13384. $data ['nature'] = $nature;
  13385. $data ['aiList'] = $aiList;
  13386. $data ['memu'] = "receipt";
  13387. $data ['staff'] = $this->staff;
  13388. $data ['receiptMemu'] = 'companyCategoryCollect';
  13389. $data ['verifyId'] = $this->verifyId;
  13390. $data ['executeId'] = $this->executeId;
  13391. $this->render ( "/admin/staffCollectMonthDetail", $data );
  13392. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13393. }
  13394. function staffCollectMonthDetail2() {
  13395. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13396. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13397. if (! $year)
  13398. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13399. if (! $month)
  13400. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13401. Doo::loadModel ( 'staff' );
  13402. $staff = new staff ();
  13403. Doo::loadModel ( "receiptDetail" );
  13404. $receiptDetail = new receiptDetail ();
  13405. Doo::loadModel ( 'accountItem' );
  13406. $accountItem = new accountItem ();
  13407. Doo::loadModel ( 'statistics' );
  13408. $statistics = new statistics ();
  13409. Doo::loadModel ( 'L_category' );
  13410. $lCategory = new L_category ();
  13411. $staffList = $staff->find ( array (
  13412. 'where' => 'username!="admin"',
  13413. 'asArray' => true
  13414. ) );
  13415. $categoryList = $staff->find ( array (
  13416. 'select' => 'COUNT(*) as count,cid,category',
  13417. 'where' => 'username !="admin"',
  13418. 'groupby' => 'cid',
  13419. 'asArray' => true
  13420. ) );
  13421. $list = array ();
  13422. foreach ( $categoryList as $vlu ) {
  13423. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  13424. $r1 = 0;
  13425. $r2 = 0;
  13426. $r3 = 0;
  13427. $r4 = 0;
  13428. $r5 = 0;
  13429. $r6 = 0;
  13430. $r7 = 0;
  13431. $r8 = 0;
  13432. $r9 = 0;
  13433. $r10 = 0;
  13434. $r11 = 0;
  13435. $r12 = 0;
  13436. $r13 = 0;
  13437. $r14 = 0;
  13438. $r15 = 0;
  13439. $c1 = 0;
  13440. $c2 = 0;
  13441. $c3 = 0;
  13442. $c4 = 0;
  13443. $c5 = 0;
  13444. $c6 = 0;
  13445. $p1 = 0;
  13446. $p2 = 0;
  13447. $p3 = 0;
  13448. $p4 = 0;
  13449. $p5 = 0;
  13450. $p6 = 0;
  13451. $p7 = 0;
  13452. $p8 = 0;
  13453. $p9 = 0;
  13454. $t1 = 0;
  13455. $t2 = 0;
  13456. $t3 = 0;
  13457. $t4 = 0;
  13458. $t5 = 0;
  13459. $s1 = 0;
  13460. $m1 = 0;
  13461. foreach ( $staffList as $value ) {
  13462. if ($vlu ['cid'] == $value ['cid']) {
  13463. $receiptCollectList = $receiptDetail->find ( array (
  13464. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13465. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13466. 'groupby' => 'item,Month(date),itemCategory',
  13467. 'asArray' => true
  13468. ) );
  13469. if (! empty ( $receiptCollectList )) {
  13470. $receiptL = array (
  13471. '日常相关费用' => array (),
  13472. '差旅相关费用' => array (),
  13473. '培训班费用' => array (),
  13474. '其他' => array ()
  13475. );
  13476. $html = "";
  13477. $psum = 0;
  13478. $item = array (
  13479. '市内交通费',
  13480. '市内出租费',
  13481. '办事处房租',
  13482. '电话费',
  13483. '水费',
  13484. '电费',
  13485. '办公费用',
  13486. '邮寄费',
  13487. '其他费用',
  13488. '车辆费用',
  13489. '广告费',
  13490. '团队建设费',
  13491. '物业管理费',
  13492. '宽带费'
  13493. );
  13494. foreach ( $item as $va ) {
  13495. $falg = true;
  13496. foreach ( $receiptCollectList as $v ) {
  13497. if ($v ['itemCategory'] == '日常相关费用') {
  13498. if ($v ['item'] == $va) {
  13499. if ($va == '市内交通费')
  13500. $r1 += $v ['price'];
  13501. if ($va == '市内出租费')
  13502. $r2 += $v ['price'];
  13503. if ($va == '办事处房租')
  13504. $r3 += $v ['price'];
  13505. if ($va == '电话费')
  13506. $r4 += $v ['price'];
  13507. if ($va == '水费')
  13508. $r5 += $v ['price'];
  13509. if ($va == '电费')
  13510. $r6 += $v ['price'];
  13511. if ($va == '办公费用')
  13512. $r7 += $v ['price'];
  13513. if ($va == '邮寄费')
  13514. $r8 += $v ['price'];
  13515. if ($va == '其他费用')
  13516. $r9 += $v ['price'];
  13517. if ($va == '车辆费用')
  13518. $r10 += $v ['price'];
  13519. if ($va == '广告费')
  13520. $r11 += $v ['price'];
  13521. if ($va == '团队建设费')
  13522. $r13 += $v ['price'];
  13523. if ($va == '物业管理费')
  13524. $r14 += $v ['price'];
  13525. if ($va == '宽带费')
  13526. $r15 += $v ['price'];
  13527. $psum += $v ['price'];
  13528. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13529. $falg = false;
  13530. break;
  13531. }
  13532. }
  13533. }
  13534. if ($falg)
  13535. $html .= '<td class="taR">-</td>';
  13536. }
  13537. $r12 += $psum;
  13538. if (! empty ( $psum ))
  13539. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13540. else
  13541. $psum = '<td class="colGreen taR">-</td>';
  13542. $receiptL ['日常相关费用'] = $psum . $html;
  13543. /* ----------------------------------- */
  13544. $html = "";
  13545. $psum = 0;
  13546. $item = array (
  13547. '往来交通费',
  13548. '市内交通费',
  13549. '出差住宿费',
  13550. '出差补助',
  13551. '其他费用'
  13552. );
  13553. foreach ( $item as $va ) {
  13554. $falg = true;
  13555. foreach ( $receiptCollectList as $v ) {
  13556. if ($v ['itemCategory'] == '差旅相关费用') {
  13557. if ($v ['item'] == $va) {
  13558. if ($va == '往来交通费')
  13559. $c1 += $v ['price'];
  13560. if ($va == '市内交通费')
  13561. $c2 += $v ['price'];
  13562. if ($va == '出差住宿费')
  13563. $c3 += $v ['price'];
  13564. if ($va == '出差补助')
  13565. $c4 += $v ['price'];
  13566. if ($va == '其他费用')
  13567. $c5 += $v ['price'];
  13568. $psum += $v ['price'];
  13569. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13570. $falg = false;
  13571. break;
  13572. }
  13573. }
  13574. }
  13575. if ($falg)
  13576. $html .= '<td class="taR">-</td>';
  13577. }
  13578. $c6 += $psum;
  13579. if (! empty ( $psum ))
  13580. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13581. else
  13582. $psum = '<td class="colGreen taR">-</td>';
  13583. $receiptL ['差旅相关费用'] = $psum . $html;
  13584. /* ------------------------------------- */
  13585. $html = "";
  13586. $psum = 0;
  13587. $item = array (
  13588. '场租费',
  13589. '薪酬',
  13590. '住宿费',
  13591. '交通费',
  13592. '餐饮费',
  13593. '办公费',
  13594. '公关费',
  13595. '其他'
  13596. );
  13597. foreach ( $item as $va ) {
  13598. $falg = true;
  13599. foreach ( $receiptCollectList as $v ) {
  13600. if ($v ['itemCategory'] == '培训班费用') {
  13601. if ($v ['item'] == $va) {
  13602. if ($va == '场租费')
  13603. $p1 += $v ['price'];
  13604. if ($va == '薪酬')
  13605. $p2 += $v ['price'];
  13606. if ($va == '住宿费')
  13607. $p3 += $v ['price'];
  13608. if ($va == '交通费')
  13609. $p4 += $v ['price'];
  13610. if ($va == '餐饮费')
  13611. $p5 += $v ['price'];
  13612. if ($va == '办公费')
  13613. $p6 += $v ['price'];
  13614. if ($va == '公关费')
  13615. $p7 += $v ['price'];
  13616. if ($va == '其他')
  13617. $p8 += $v ['price'];
  13618. $psum += $v ['price'];
  13619. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13620. $falg = false;
  13621. break;
  13622. }
  13623. }
  13624. }
  13625. if ($falg)
  13626. $html .= '<td class="taR">-</td>';
  13627. }
  13628. $p9 += $psum;
  13629. if (! empty ( $psum ))
  13630. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13631. else
  13632. $psum = '<td class="colGreen taR">-</td>';
  13633. $receiptL ['培训班费用'] = $psum . $html;
  13634. /* ------------------------------------- */
  13635. $html = "";
  13636. $psum = 0;
  13637. $item = array (
  13638. '公关费',
  13639. '广告费',
  13640. '借款',
  13641. '可自加费用'
  13642. );
  13643. foreach ( $item as $va ) {
  13644. $falg = true;
  13645. foreach ( $receiptCollectList as $v ) {
  13646. if ($v ['itemCategory'] == '其他') {
  13647. if ($v ['item'] == $va) {
  13648. if ($va == '公关费')
  13649. $t1 += $v ['price'];
  13650. if ($va == '广告费')
  13651. $t2 += $v ['price'];
  13652. if ($va == '借款')
  13653. $t3 += $v ['price'];
  13654. if ($va == '可自加费用')
  13655. $t4 += $v ['price'];
  13656. $psum += $v ['price'];
  13657. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13658. $falg = false;
  13659. break;
  13660. }
  13661. }
  13662. }
  13663. if ($falg)
  13664. $html .= '<td class="taR">-</td>';
  13665. }
  13666. $t5 += $psum;
  13667. if (! empty ( $psum ))
  13668. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13669. else
  13670. $psum = '<td class="colGreen taR">-</td>';
  13671. $receiptL ['其他'] = $psum . $html;
  13672. /* ------------------------------------- */
  13673. $html = "";
  13674. $psum = 0;
  13675. foreach ( $receiptCollectList as $v ) {
  13676. if ($v ['itemCategory'] == '报销金额调整') {
  13677. if (! empty ( $v ['price'] )) {
  13678. $psum += $v ['price'];
  13679. }
  13680. }
  13681. }
  13682. $s1 += $psum;
  13683. if (! empty ( $psum ))
  13684. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13685. else
  13686. $psum = '<td class="taR colOrange">-</td>';
  13687. $receiptL ['报销金额调整'] = $psum . $html;
  13688. } else {
  13689. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13690. <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>';
  13691. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13692. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13693. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13694. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13695. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13696. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13697. }
  13698. $monthStaffPrice = $receiptDetail->find ( array (
  13699. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13700. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13701. 'asArray' => true
  13702. ) );
  13703. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13704. $m1 += $monthStaffPrice [0] ['price'];
  13705. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13706. } else
  13707. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13708. $list [$value ['username']] = $receiptL;
  13709. }
  13710. }
  13711. $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>
  13712. <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>
  13713. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13714. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13715. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13716. $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>
  13717. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13718. $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>';
  13719. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13720. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13721. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13722. }
  13723. $data ['list'] = $list;
  13724. $receiptCollectList = $receiptDetail->find ( array (
  13725. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13726. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13727. 'groupby' => 'item,Month(date),itemCategory',
  13728. 'asArray' => true
  13729. ) );
  13730. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13731. // statistics html
  13732. $stList = $statistics->getOne ( array (
  13733. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13734. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13735. 'groupby' => 'Month(date)',
  13736. 'asArray' => true
  13737. ) );
  13738. if (empty ( $stList ))
  13739. $stList = array (
  13740. 'rePrice' => 0,
  13741. 'agPrice' => 0
  13742. );
  13743. $data ['stList'] = array (
  13744. 'rePrice' => $stList ['rePrice'],
  13745. 'agPrice' => $stList ['agPrice'],
  13746. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13747. );
  13748. $monthHtml = "";
  13749. for($i = 1; $i <= 12; $i ++) {
  13750. if ($i == $month)
  13751. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13752. else
  13753. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13754. }
  13755. $data ['monthHtml'] = $monthHtml;
  13756. $data ['year'] = $year;
  13757. $data ['month'] = $month;
  13758. $data ['memu'] = "receipt";
  13759. $data ['staff'] = $this->staff;
  13760. $data ['receiptMemu'] = 'companyCategoryCollect';
  13761. $data ['verifyId'] = $this->verifyId;
  13762. $data ['executeId'] = $this->executeId;
  13763. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13764. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13765. }
  13766. /**
  13767. * 用户报销单列表
  13768. */
  13769. function receiptStatisticsStaffDetail() {
  13770. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13771. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13772. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13773. Doo::loadModel ( "receipt" );
  13774. $receipt = new receipt ();
  13775. Doo::loadModel ( "receiptDetail" );
  13776. $receiptDetail = new receiptDetail ();
  13777. Doo::loadModel ( 'staff' );
  13778. $staff = new staff ();
  13779. Doo::loadModel ( 'accountItem' );
  13780. $accountItem = new accountItem ();
  13781. Doo::loadModel ( 'statistics' );
  13782. $statistics = new statistics ();
  13783. if (! empty ( $username )) {
  13784. $username = addslashes ( urldecode ( $username ) );
  13785. $staffDetail = $staff->getStaffByName ( $username );
  13786. if (empty ( $staffDetail ))
  13787. die ( 'illegal request' );
  13788. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13789. $itemList = $accountItem->getAccountItem ();
  13790. $itemHtml = '';
  13791. $categoryHtml = '';
  13792. $itemKeyList = array_keys ( $itemList );
  13793. $revisePrice = 0;
  13794. // 报销单内容详情
  13795. foreach ( $list as $key => $value ) {
  13796. $accountItemList = json_decode ( $value ['accountItem'], true );
  13797. $list [$key] ['accountItemList'] = $accountItemList;
  13798. $receiptItemHtml = '';
  13799. foreach ( $itemKeyList as $v ) {
  13800. if ($v == '日常相关费用')
  13801. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13802. elseif ($v == '差旅相关费用')
  13803. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13804. elseif ($v == '培训班费用')
  13805. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13806. elseif ($v == '内部培训费用'){
  13807. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13808. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13809. }else{
  13810. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13811. }
  13812. }elseif ($v == '其他')
  13813. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13814. foreach ( $itemList [$v] as $ke => $va ) {
  13815. $falg = true;
  13816. if (! empty ( $accountItemList [$v] )) {
  13817. foreach ( $accountItemList [$v] as $ve ) {
  13818. if ($va ['name'] == $ve ['name']) {
  13819. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13820. $falg = false;
  13821. break;
  13822. }
  13823. }
  13824. }
  13825. if ($falg)
  13826. $receiptItemHtml .= '<td class="taR"></td>';
  13827. }
  13828. }
  13829. // 金额调整和费用查看
  13830. $revisePrice += $value ['revisePrice'];
  13831. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13832. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13833. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13834. }
  13835. // 报销单合计
  13836. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13837. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13838. $receiptTotalHtml = '';
  13839. // 报销单项目抬头
  13840. foreach ( $itemKeyList as $value ) {
  13841. $count = count ( $itemList [$value] ) + 1;
  13842. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13843. $categoryHtml .= '<th class="taC">合计</th>';
  13844. $sumfalg=true;
  13845. foreach ( $rtl as $rtlValue ) {
  13846. if ($rtlValue ['itemCategory'] == $value) {
  13847. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13848. $sumfalg=false;
  13849. break;
  13850. }
  13851. }
  13852. if ($sumfalg)
  13853. $receiptTotalHtml .= '<th></th>';
  13854. foreach ( $itemList [$value] as $k => $v ) {
  13855. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13856. // 合计
  13857. $falg = true;
  13858. foreach ( $receiptTotalList as $ve ) {
  13859. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13860. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13861. $falg = false;
  13862. break;
  13863. }
  13864. }
  13865. if ($falg)
  13866. $receiptTotalHtml .= '<th></th>';
  13867. }
  13868. }
  13869. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13870. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13871. if (empty ( $stList ))
  13872. $stList = array (
  13873. 'rePrice' => 0,
  13874. 'agPrice' => 0
  13875. );
  13876. $data ['stList'] = array (
  13877. 'rePrice' => $stList ['rePrice'],
  13878. 'agPrice' => $stList ['agPrice'],
  13879. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13880. );
  13881. $monthHtml = "";
  13882. for($i = 1; $i <= 12; $i ++) {
  13883. if ($i == $month)
  13884. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13885. else
  13886. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13887. }
  13888. $data ['username'] = urlencode ( $username );
  13889. $data ['usernameEN'] = $username;
  13890. $data ['monthHtml'] = $monthHtml;
  13891. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13892. $data ['list'] = $list;
  13893. $data ['categoryHtml'] = $categoryHtml;
  13894. $data ['itemHtml'] = $itemHtml;
  13895. $data ['itemList'] = $itemList;
  13896. $data ['year'] = $year;
  13897. $data ['month'] = $month;
  13898. $data ['memu'] = "receipt";
  13899. $data ['staff'] = $this->staff;
  13900. $data ['receiptMemu'] = 'companyCategoryCollect';
  13901. $data ['verifyId'] = $this->verifyId;
  13902. $data ['executeId'] = $this->executeId;
  13903. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13904. }
  13905. die ( 'illegal request' );
  13906. }
  13907. function companyMonthCollectDetail() {
  13908. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13909. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13910. if (! $year)
  13911. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13912. if (! $month)
  13913. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13914. Doo::loadModel ( 'staff' );
  13915. $staff = new staff ();
  13916. Doo::loadModel ( "receiptDetail" );
  13917. $receiptDetail = new receiptDetail ();
  13918. Doo::loadModel ( 'accountItem' );
  13919. $accountItem = new accountItem ();
  13920. Doo::loadModel ( 'statistics' );
  13921. $statistics = new statistics ();
  13922. Doo::loadModel ( 'L_category' );
  13923. $lCategory = new L_category ();
  13924. $staffList = $staff->find ( array (
  13925. 'where' => 'username!="admin"',
  13926. 'asArray' => true
  13927. ) );
  13928. $categoryList = $lCategory->find ( array (
  13929. 'asArray' => true
  13930. ) );
  13931. $aiList=$accountItem->getAccountItem();
  13932. $list = array ();
  13933. foreach ( $categoryList as $value ) {
  13934. $receiptCollectList = $receiptDetail->find ( array (
  13935. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13936. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13937. 'groupby' => 'item,Month(pastDate),itemCategory',
  13938. 'asArray' => true
  13939. ) );
  13940. if (! empty ( $receiptCollectList )) {
  13941. $receiptL = array (
  13942. '日常相关费用' => array (),
  13943. '差旅相关费用' => array (),
  13944. '内部培训费用' => array (),
  13945. '培训班费用' => array (),
  13946. '其他' => array ()
  13947. );
  13948. $html = "";
  13949. $psum = 0;
  13950. foreach ( $aiList[$this->AGENCY] as $va ) {
  13951. $falg = true;
  13952. foreach ( $receiptCollectList as $v ) {
  13953. if ($v ['itemCategory'] == $this->AGENCY) {
  13954. if ($v ['item'] == $va['name']) {
  13955. $psum += $v ['price'];
  13956. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13957. $falg = false;
  13958. break;
  13959. }
  13960. }
  13961. }
  13962. if ($falg)
  13963. $html .= '<td class="taR">-</td>';
  13964. }
  13965. if (! empty ( $psum ))
  13966. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13967. else
  13968. $psum = '<td class="colGreen taR">-</td>';
  13969. $receiptL [$this->AGENCY] = $psum . $html;
  13970. /* ----------------------------------- */
  13971. $html = "";
  13972. $psum = 0;
  13973. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13974. $falg = true;
  13975. foreach ( $receiptCollectList as $v ) {
  13976. if ($v ['itemCategory'] == $this->TRAVEL) {
  13977. if ($v ['item'] == $va['name']) {
  13978. $psum += $v ['price'];
  13979. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13980. $falg = false;
  13981. break;
  13982. }
  13983. }
  13984. }
  13985. if ($falg)
  13986. $html .= '<td class="taR">-</td>';
  13987. }
  13988. if (! empty ( $psum ))
  13989. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13990. else
  13991. $psum = '<td class="colGreen taR">-</td>';
  13992. $receiptL [$this->TRAVEL] = $psum . $html;
  13993. /* ------------------------------------- */
  13994. $html = "";
  13995. $psum = 0;
  13996. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13997. $falg = true;
  13998. foreach ( $receiptCollectList as $v ) {
  13999. if ($v ['itemCategory'] == $this->INTTRAIN) {
  14000. if ($v ['item'] == $va['name']) {
  14001. $psum += $v ['price'];
  14002. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14003. $falg = false;
  14004. break;
  14005. }
  14006. }
  14007. }
  14008. if ($falg)
  14009. $html .= '<td class="taR">-</td>';
  14010. }
  14011. if (! empty ( $psum ))
  14012. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14013. else
  14014. $psum = '<td class="colGreen taR">-</td>';
  14015. $receiptL [$this->INTTRAIN] = $psum . $html;
  14016. /* ------------------------------------- */
  14017. $html = "";
  14018. $psum = 0;
  14019. foreach ( $aiList[$this->TRAIN] as $va ) {
  14020. $falg = true;
  14021. foreach ( $receiptCollectList as $v ) {
  14022. if ($v ['itemCategory'] == $this->TRAIN) {
  14023. if ($v ['item'] == $va['name']) {
  14024. $psum += $v ['price'];
  14025. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14026. $falg = false;
  14027. break;
  14028. }
  14029. }
  14030. }
  14031. if ($falg)
  14032. $html .= '<td class="taR">-</td>';
  14033. }
  14034. if (! empty ( $psum ))
  14035. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14036. else
  14037. $psum = '<td class="colGreen taR">-</td>';
  14038. $receiptL [$this->TRAIN] = $psum . $html;
  14039. /* ------------------------------------- */
  14040. $html = "";
  14041. $psum = 0;
  14042. foreach ( $aiList[$this->OTHER] as $va ) {
  14043. $falg = true;
  14044. foreach ( $receiptCollectList as $v ) {
  14045. if ($v ['itemCategory'] == $this->OTHER) {
  14046. if ($v ['item'] == $va['name']) {
  14047. $psum += $v ['price'];
  14048. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14049. $falg = false;
  14050. break;
  14051. }
  14052. }
  14053. }
  14054. if ($falg)
  14055. $html .= '<td class="taR">-</td>';
  14056. }
  14057. if (! empty ( $psum ))
  14058. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14059. else
  14060. $psum = '<td class="colGreen taR">-</td>';
  14061. $receiptL [$this->OTHER] = $psum . $html;
  14062. /* ------------------------------------- */
  14063. $html = "";
  14064. $psum = 0;
  14065. foreach ( $receiptCollectList as $v ) {
  14066. if ($v ['itemCategory'] == '报销金额调整') {
  14067. if (! empty ( $v ['price'] ))
  14068. $psum += $v ['price'];
  14069. }
  14070. }
  14071. if (! empty ( $psum ))
  14072. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14073. else
  14074. $psum = '<td class="taR colOrange">-</td>';
  14075. $receiptL ['报销金额调整'] = $psum . $html;
  14076. } else {
  14077. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14078. foreach ( $aiList[$this->AGENCY] as $va ) {
  14079. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14080. }
  14081. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14082. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14083. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14084. }
  14085. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14086. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14087. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14088. }
  14089. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14090. foreach ( $aiList[$this->TRAIN] as $va ) {
  14091. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14092. }
  14093. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14094. foreach ( $aiList[$this->OTHER] as $va ) {
  14095. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14096. }
  14097. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14098. }
  14099. $monthStaffPrice = $receiptDetail->find ( array (
  14100. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14101. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14102. 'asArray' => true
  14103. ) );
  14104. if (! empty ( $monthStaffPrice [0] ['price'] ))
  14105. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  14106. else
  14107. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  14108. $list [$value ['title']] = $receiptL;
  14109. }
  14110. $data ['list'] = $list;
  14111. $receiptCollectList = $receiptDetail->find ( array (
  14112. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14113. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  14114. 'groupby' => 'item,Month(pastDate),itemCategory',
  14115. 'asArray' => true
  14116. ) );
  14117. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  14118. //print_r($data['monthPriceHtml']);
  14119. // foreach ($data['monthPriceHtml'] as $value){
  14120. // echo $value;
  14121. // }
  14122. // die;
  14123. // statistics html
  14124. $stList = $statistics->getOne ( array (
  14125. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  14126. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  14127. 'groupby' => 'Month(date)',
  14128. 'asArray' => true
  14129. ) );
  14130. if (empty ( $stList ))
  14131. $stList = array (
  14132. 'rePrice' => 0,
  14133. 'agPrice' => 0
  14134. );
  14135. $data ['stList'] = array (
  14136. 'rePrice' => $stList ['rePrice'],
  14137. 'agPrice' => $stList ['agPrice'],
  14138. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14139. );
  14140. $monthHtml = "";
  14141. for($i = 1; $i <= 12; $i ++) {
  14142. if ($i == $month)
  14143. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  14144. else
  14145. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  14146. }
  14147. $data ['aiList'] = $aiList;
  14148. $dateHtml = "";
  14149. $now = date ( "Y" );
  14150. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  14151. if ($YEARD <= $now) {
  14152. $dateHtml .= '<option ';
  14153. if ($year == $YEARD) {
  14154. $dateHtml .= 'selected ';
  14155. }
  14156. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  14157. }
  14158. }
  14159. $data ['dateHtml'] = $dateHtml;
  14160. $data ['monthHtml'] = $monthHtml;
  14161. $data ['year'] = $year;
  14162. $data ['month'] = $month;
  14163. $data ['memu'] = "receipt";
  14164. $data ['staff'] = $this->staff;
  14165. $data ['receiptMemu'] = 'companyCategoryCollect';
  14166. $data ['verifyId'] = $this->verifyId;
  14167. $data ['executeId'] = $this->executeId;
  14168. $this->render ( "/admin/companyMonthCollectDetail", $data );
  14169. }
  14170. function staffCollectDetail() {
  14171. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  14172. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  14173. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  14174. if (! $staffname) {
  14175. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  14176. $staffname = urldecode ( $staffname );
  14177. }
  14178. Doo::loadModel ( 'staff' );
  14179. $staff = new staff ();
  14180. Doo::loadModel ( "receiptDetail" );
  14181. $receiptDetail = new receiptDetail ();
  14182. Doo::loadModel ( 'accountItem' );
  14183. $accountItem = new accountItem ();
  14184. Doo::loadModel ( 'statistics' );
  14185. $statistics = new statistics ();
  14186. Doo::loadModel ( 'L_category' );
  14187. $lCategory = new L_category ();
  14188. Doo::loadModel ( "receiptAuthorityManage" );
  14189. $receiptAuthorityManage = new receiptAuthorityManage ();
  14190. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  14191. $cidList = array ();
  14192. foreach ( $imcStaff as $key => $value ) {
  14193. array_push ( $cidList, $value ['cid'] );
  14194. }
  14195. $cidString = implode ( ',', $cidList );
  14196. $staffList = $staff->find ( array (
  14197. 'where' => ' cid in (' . $cidString . ')',
  14198. 'asArray' => true
  14199. ) );
  14200. $stHtml = '';
  14201. $stTitle = "";
  14202. $staffId = 0;
  14203. $cid = 0;
  14204. $ocid = 0;
  14205. foreach ( $staffList as $value ) {
  14206. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  14207. $stTitle = $value ['category'] . '-' . $value ['username'];
  14208. $staffId = $value ['sid'];
  14209. $cid = $value ['cid'];
  14210. $ocid = $value ['cid'];
  14211. if (! empty ( $value ['othercid'] ))
  14212. $cid = $value ['cid'] . ',' . $value ['othercid'];
  14213. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14214. } elseif ($value ['username'] != 'admin')
  14215. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  14216. }
  14217. $data ['lCategoryHtml'] = $lCategory->find ( array (
  14218. 'where' => 'cid in(' . $cid . ')',
  14219. 'asArray' => true
  14220. ) );
  14221. if (empty ( $pcid ))
  14222. $pcid = $ocid;
  14223. $data ['ocid'] = $pcid;
  14224. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  14225. $this->showCache ( $path );
  14226. //
  14227. $receiptCollectList = $receiptDetail->find ( array (
  14228. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  14229. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14230. 'groupby' => 'item,Month(pastDate),itemCategory',
  14231. 'asArray' => true
  14232. ) );
  14233. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  14234. // print_r($receiptCollectList);
  14235. $accountList = $accountItem->find ( array (
  14236. 'asArray' => true
  14237. ) );
  14238. // create CollectDetail HTML
  14239. $collectHtml = array ();
  14240. foreach ( $accountList as $key => $value ) {
  14241. $html = "";
  14242. $asum = 0;
  14243. for($i = 1; $i <= 12; $i ++) {
  14244. $falg = true;
  14245. foreach ( $receiptCollectList as $v ) {
  14246. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  14247. if ($v ['item'] == '可自加费用') {
  14248. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  14249. }
  14250. $asum += $v ['price'];
  14251. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14252. $falg = false;
  14253. break;
  14254. }
  14255. }
  14256. if ($falg)
  14257. $html .= '<td class="taR">-</td>';
  14258. }
  14259. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  14260. $collectHtml [$value ['category']] [$value ['name']] = $html;
  14261. }
  14262. $data ['collectHtml'] = $collectHtml;
  14263. // print_r($collectHtml);
  14264. // create Adjustment price html
  14265. $receiptCollectList = $receiptDetail->find ( array (
  14266. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  14267. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  14268. 'groupby' => 'itemCategory,Month(pastDate)',
  14269. 'asArray' => true
  14270. ) );
  14271. $adjustment = array ();
  14272. $collectArray = array (
  14273. '日常相关费用' => array (),
  14274. '差旅相关费用' => array (),
  14275. '培训班费用' => array (),
  14276. '内部培训费用'=>array(),
  14277. '其他' => array ()
  14278. );
  14279. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  14280. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  14281. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  14282. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  14283. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  14284. array_push ( $collectArray ['培训班费用'], $collectHtml );
  14285. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  14286. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  14287. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  14288. array_push ( $collectArray ['其他'], $collectHtml );
  14289. $data ['collectArray'] = $collectArray;
  14290. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  14291. array_push ( $adjustment, $collectHtml );
  14292. $data ['adjustment'] = $adjustment;
  14293. // total price html
  14294. $collectHtml = "";
  14295. $total = 0;
  14296. for($i = 1; $i <= 12; $i ++) {
  14297. $sumPrice = 0;
  14298. foreach ( $receiptCollectList as $key => $value ) {
  14299. if ($value ['month'] == $i) {
  14300. $sumPrice += $value ['price'];
  14301. }
  14302. }
  14303. if ($sumPrice == 0)
  14304. $collectHtml .= '<td class="taR">-</td>';
  14305. else
  14306. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  14307. $total += $sumPrice;
  14308. }
  14309. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  14310. // statistics html
  14311. $stList = $statistics->statisticsByYear ( $year, $staffId );
  14312. if (empty ( $stList ))
  14313. $stList = array (
  14314. 'rePrice' => 0,
  14315. 'agPrice' => 0
  14316. );
  14317. $data ['stList'] = array (
  14318. 'rePrice' => $stList ['rePrice'],
  14319. 'agPrice' => $stList ['agPrice'],
  14320. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  14321. );
  14322. $data ['totalPrice'] = $collectHtml;
  14323. $data ['totalYear'] = $total;
  14324. $data ['stHtml'] = $stHtml;
  14325. $data ['year'] = $year;
  14326. $data ['stTitle'] = $stTitle;
  14327. $data ['staffname'] = urlencode ( $staffname );
  14328. $data ['memu'] = "receipt";
  14329. $data ['staff'] = $this->staff;
  14330. $data ['receiptMemu'] = 'companyCategoryCollect';
  14331. $data ['verifyId'] = $this->verifyId;
  14332. $data ['executeId'] = $this->executeId;
  14333. if ($year < date ( "Y" )) {
  14334. Doo::loadModel ( 'receipt' );
  14335. $receipt = new receipt ();
  14336. $receiptList = $receipt->find ( array (
  14337. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  14338. 'asArray' => true
  14339. ) );
  14340. if (empty ( $receiptList )) { // generated files
  14341. ob_start ();
  14342. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14343. $this->cacheFile ( $path );
  14344. die ();
  14345. }
  14346. }
  14347. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  14348. }
  14349. function BUGFLAG() {
  14350. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  14351. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  14352. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  14353. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  14354. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  14355. if (empty ( $status ))
  14356. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  14357. $page_size = 12;
  14358. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  14359. $vidList = array ();
  14360. $button = 0;
  14361. Doo::loadModel ( 'verify' );
  14362. $verify = new verify ();
  14363. Doo::loadModel ( 'receipt' );
  14364. $receipt = new receipt ();
  14365. Doo::loadModel ( 'staff' );
  14366. $staff = new staff ();
  14367. Doo::loadModel ( 'L_category' );
  14368. $Lcategory = new L_category ();
  14369. $dateCondition = " and Year(date) =" . $year;
  14370. if (! empty ( $month ))
  14371. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  14372. $categoryList = $Lcategory->find ( array (
  14373. 'asArray' => true
  14374. ) );
  14375. $staffList = $staff->find ( array (
  14376. 'where' => 'cid=' . $cid,
  14377. 'asArray' => true
  14378. ) );
  14379. $cateCondition = "";
  14380. $staffCondition = "";
  14381. $approvalCondition = "";
  14382. if (! empty ( $cid ))
  14383. $cateCondition = ' and cid=' . $cid;
  14384. if (! empty ( $sid )) {
  14385. $staffCondition = ' and staff=' . $sid;
  14386. $cateCondition = "";
  14387. }
  14388. $approvalCondition = " and status=" . $status;
  14389. if ($status == 2) {
  14390. // 查找角色审批人
  14391. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  14392. }
  14393. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  14394. $approvalCondition = ' and status=2 ';
  14395. }
  14396. if ($status == 1) {
  14397. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  14398. }
  14399. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  14400. $pageinfo ['page'] = array (
  14401. 'previous' => ''
  14402. );
  14403. if ($status == 0) {
  14404. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  14405. $receiptList = $receipt->find ( array (
  14406. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  14407. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  14408. 'desc' => 'rid',
  14409. 'asArray' => true
  14410. ) );
  14411. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14412. } else
  14413. $receiptList = $receipt->find ( array (
  14414. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  14415. 'desc' => 'rid',
  14416. 'asArray' => true
  14417. ) );
  14418. $rLRes = $receipt->find ( array (
  14419. '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,
  14420. 'desc' => 'rid',
  14421. 'asArray' => true
  14422. ) );
  14423. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  14424. // print_r($pageinfo);
  14425. $Locate = 0;
  14426. foreach ( $receiptList as $key => $value ) {
  14427. $receiptList [$key] ['Locate'] = $Locate;
  14428. $Locate ++;
  14429. $receiptList [$key] ['reviseDetail'] = array ();
  14430. if (! empty ( $value ['reviseDetail'] ))
  14431. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  14432. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  14433. $categoryDetil = $Lcategory->getOne ( array (
  14434. 'where' => 'cid=' . $value ['cid'],
  14435. 'asArray' => true
  14436. ) );
  14437. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  14438. $verifyList = $verify->getOne ( array (
  14439. 'where' => 'vid=' . $value ['verify'],
  14440. 'asArray' => true
  14441. ) );
  14442. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  14443. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  14444. foreach ( $verifyList as $k => $v ) {
  14445. // init verifyStaff
  14446. $verifyList [$k] ['date'] = "";
  14447. $verifyList [$k] ['opinion'] = "";
  14448. $verifyList [$k] ['status'] = "";
  14449. if (empty ( $verifyStaff )) {
  14450. $verifyList [$k] ['date'] = "";
  14451. $verifyList [$k] ['opinion'] = "";
  14452. if ($v [0] == $this->staff [0] ['sid']) {
  14453. $verifyList [$k] ['status'] = 4;
  14454. $button = 4;
  14455. }
  14456. } else {
  14457. $flag = true;
  14458. foreach ( $verifyStaff as $m => $u ) {
  14459. if ($v [0] == $m) {
  14460. $verifyList [$k] ['date'] = $u ['date'];
  14461. $verifyList [$k] ['opinion'] = $u ['opinion'];
  14462. $verifyList [$k] ['status'] = $u ['status'];
  14463. $flag = false;
  14464. break;
  14465. }
  14466. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14467. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14468. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14469. }
  14470. if ($flag) { // 检测可编辑
  14471. if ($v [0] == $this->staff [0] ['sid']) {
  14472. $verifyList [$k] ['status'] = 4;
  14473. $button = 4;
  14474. }
  14475. }
  14476. }
  14477. }
  14478. $receiptList [$key] ['verifyList'] = $verifyList;
  14479. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14480. 'where' => 'sid=' . $value ['staff'],
  14481. 'asArray' => true
  14482. ) );
  14483. $receiptList [$key] ['button'] = $button;
  14484. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14485. }
  14486. // print_r($receiptList);die;
  14487. // $data['verifyDetail']=$verifyDetail;
  14488. $mothHtml = "";
  14489. for($i = 1; $i <= 12; $i ++) {
  14490. if ($month == $i)
  14491. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14492. else
  14493. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14494. }
  14495. $data ['mothHtml'] = $mothHtml;
  14496. $data ['page'] = $pageinfo;
  14497. $data ['receiptList'] = $receiptList;
  14498. $data ['receiptApprovalCount'] = count ( $rLRes );
  14499. $data ['status'] = $status;
  14500. $data ['year'] = $year;
  14501. $data ['categoryList'] = $categoryList;
  14502. $data ['staffList'] = $staffList;
  14503. $data ['cid'] = $cid;
  14504. $data ['sid'] = $sid;
  14505. // print_r($receiptList);
  14506. $data ['memu'] = "receipt";
  14507. $data ['staff'] = $this->staff;
  14508. $data ['receiptMemu'] = 'approvalExpenses';
  14509. $data ['verifyId'] = $this->verifyId;
  14510. $data ['executeId'] = $this->executeId;
  14511. $this->render ( "/admin/FALG", $data );
  14512. }
  14513. function ajaxGetReceiptOrder() {
  14514. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14515. if (! empty ( $receiptOrder )) {
  14516. Doo::loadModel ( 'receipt' );
  14517. $receipt = new receipt ();
  14518. Doo::loadModel ( 'staff' );
  14519. $staff = new staff ();
  14520. $receiptInfo = $receipt->getOne ( array (
  14521. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14522. 'asArray' => true
  14523. ) );
  14524. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14525. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14526. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14527. </tbody></table><table class="table table table-bordered"><tbody>';
  14528. foreach ( $verifyStaff as $key => $value ) {
  14529. $staffInfo = $staff->getOne ( array (
  14530. 'select' => 'username',
  14531. 'where' => ' sid="' . $key . '"',
  14532. 'asArray' => true
  14533. ) );
  14534. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14535. }
  14536. $html .= '</tbody></table></div></div>';
  14537. echo json_encode ( array (
  14538. 'status' => 1,
  14539. 'receiptHtml' => $html
  14540. ) );
  14541. die ();
  14542. }
  14543. echo json_encode ( array (
  14544. 'status' => 2,
  14545. 'receiptHtml' => ''
  14546. ) );
  14547. die ();
  14548. }
  14549. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14550. if (! empty ( $receiptCollectList )) {
  14551. $receiptL = array (
  14552. '日常相关费用' => array (),
  14553. '差旅相关费用' => array (),
  14554. '内部培训费用'=>array(),
  14555. '培训班费用' => array (),
  14556. '其他' => array ()
  14557. );
  14558. $html = "";
  14559. $psum = 0;
  14560. foreach ( $aiList[$this->AGENCY] as $value ) {
  14561. $falg = true;
  14562. foreach ( $receiptCollectList as $v ) {
  14563. if ($v ['itemCategory'] == '日常相关费用') {
  14564. if ($v ['item'] == $value['name']) {
  14565. $psum += $v ['price'];
  14566. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14567. $falg = false;
  14568. break;
  14569. }
  14570. }
  14571. }
  14572. if ($falg)
  14573. $html .= '<td class="taR">-</td>';
  14574. }
  14575. if (! empty ( $psum ))
  14576. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14577. else
  14578. $psum = '<td class="colGreen taR">-</td>';
  14579. $receiptL ['日常相关费用'] = $psum . $html;
  14580. /* ----------------------------------- */
  14581. $html = "";
  14582. $psum = 0;
  14583. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14584. $falg = true;
  14585. foreach ( $receiptCollectList as $v ) {
  14586. if ($v ['itemCategory'] == '差旅相关费用') {
  14587. if ($v ['item'] == $value['name']) {
  14588. $psum += $v ['price'];
  14589. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14590. $falg = false;
  14591. break;
  14592. }
  14593. }
  14594. }
  14595. if ($falg)
  14596. $html .= '<td class="taR">-</td>';
  14597. }
  14598. if (! empty ( $psum ))
  14599. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14600. else
  14601. $psum = '<td class="colGreen taR">-</td>';
  14602. $receiptL ['差旅相关费用'] = $psum . $html;
  14603. /* ----------------------------------- */
  14604. $html = "";
  14605. $psum = 0;
  14606. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14607. $falg = true;
  14608. foreach ( $receiptCollectList as $v ) {
  14609. if ($v ['itemCategory'] == '内部培训费用') {
  14610. if ($v ['item'] == $value['name']) {
  14611. $psum += $v ['price'];
  14612. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14613. $falg = false;
  14614. break;
  14615. }
  14616. }
  14617. }
  14618. if ($falg)
  14619. $html .= '<td class="taR">-</td>';
  14620. }
  14621. if (! empty ( $psum ))
  14622. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14623. else
  14624. $psum = '<td class="colGreen taR">-</td>';
  14625. $receiptL ['内部培训费用'] = $psum . $html;
  14626. /* ------------------------------------- */
  14627. $html = "";
  14628. $psum = 0;
  14629. foreach ( $aiList[$this->TRAIN] as $value ) {
  14630. $falg = true;
  14631. foreach ( $receiptCollectList as $v ) {
  14632. if ($v ['itemCategory'] == '培训班费用') {
  14633. if ($v ['item'] == $value['name']) {
  14634. $psum += $v ['price'];
  14635. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14636. $falg = false;
  14637. break;
  14638. }
  14639. }
  14640. }
  14641. if ($falg)
  14642. $html .= '<td class="taR">-</td>';
  14643. }
  14644. if (! empty ( $psum ))
  14645. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14646. else
  14647. $psum = '<td class="colGreen taR">-</td>';
  14648. $receiptL ['培训班费用'] = $psum . $html;
  14649. /* ------------------------------------- */
  14650. $html = "";
  14651. $psum = 0;
  14652. foreach ( $aiList[$this->OTHER] as $value ) {
  14653. $falg = true;
  14654. foreach ( $receiptCollectList as $v ) {
  14655. if ($v ['itemCategory'] == '其他') {
  14656. if ($v ['item'] == $value['name']) {
  14657. $psum += $v ['price'];
  14658. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14659. $falg = false;
  14660. break;
  14661. }
  14662. }
  14663. }
  14664. if ($falg)
  14665. $html .= '<td class="taR">-</td>';
  14666. }
  14667. if (! empty ( $psum ))
  14668. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14669. else
  14670. $psum = '<td class="colGreen taR">-</td>';
  14671. $receiptL ['其他'] = $psum . $html;
  14672. /* ------------------------------------- */
  14673. $html = "";
  14674. $psum = 0;
  14675. foreach ( $receiptCollectList as $v ) {
  14676. if ($v ['itemCategory'] == '报销金额调整') {
  14677. if (! empty ( $v ['price'] ))
  14678. $psum += $v ['price'];
  14679. }
  14680. }
  14681. if (! empty ( $psum ))
  14682. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14683. else
  14684. $psum = '<td class="taR colOrange">-</td>';
  14685. $receiptL ['报销金额调整'] = $psum . $html;
  14686. } else {
  14687. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14688. foreach ( $aiList[$this->AGENCY] as $va ) {
  14689. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14690. }
  14691. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14692. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14693. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14694. }
  14695. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14696. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14697. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14698. }
  14699. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14700. foreach ( $aiList[$this->TRAIN] as $va ) {
  14701. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14702. }
  14703. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14704. foreach ( $aiList[$this->OTHER] as $va ) {
  14705. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14706. }
  14707. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14708. }
  14709. return $receiptL;
  14710. }
  14711. function eMail() {
  14712. Doo::loadModel ( 'staff' );
  14713. $staff = new staff ();
  14714. Doo::loadModel ( 'receipt' );
  14715. $receipt = new receipt ();
  14716. Doo::loadModel ( 'L_category' );
  14717. $Lcategory = new L_category ();
  14718. Doo::loadModel ( "verify" );
  14719. $verify = new verify ();
  14720. $staffList = $staff->find ( array (
  14721. 'asArray' => true
  14722. ) );
  14723. foreach ( $staffList as $key => $value ) {
  14724. if ($value ['username'] != 'admin') {
  14725. // 提交人
  14726. $receiptList = $receipt->find ( array (
  14727. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14728. 'asArray' => true
  14729. ) );
  14730. if (! empty ( $receiptList )) {
  14731. $html = '<br><div><style></style>
  14732. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14733. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14734. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14735. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14736. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14737. <tbody><tr>
  14738. <td style="padding: 0 40px;" align="left">
  14739. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14740. </td></tr><tr>
  14741. <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>
  14742. </tr>
  14743. </tbody> </table></td> </tr> <tr><td>
  14744. <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">
  14745. <tbody> <tr><td>
  14746. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14747. 以下报销单完成了审批,等着收款吧:</p>
  14748. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14749. foreach ( $receiptList as $k => $v ) {
  14750. $category = $Lcategory->getOne ( array (
  14751. 'where' => 'cid=' . $v ['cid'],
  14752. 'asArray' => true
  14753. ) );
  14754. $html .= '
  14755. <tr>
  14756. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14757. <td align="left">
  14758. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14759. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14760. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14761. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14762. </tr>';
  14763. }
  14764. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14765. <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>
  14766. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14767. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14768. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14769. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14770. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14771. $receipt = new receipt ();
  14772. $receipt->notice = 1;
  14773. $receipt->update ( array (
  14774. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14775. ) );
  14776. }
  14777. }
  14778. // 审批人
  14779. $verifyList = $verify->find ( array (
  14780. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14781. 'asArray' => true
  14782. ) );
  14783. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14784. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14785. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14786. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14787. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14788. <tbody><tr><td style="padding: 0 40px;" align="left">
  14789. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14790. </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>
  14791. </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">
  14792. <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>
  14793. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14794. foreach ( $verifyList as $k => $v ) {
  14795. $receiptList = $receipt->find ( array (
  14796. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14797. 'asArray' => true
  14798. ) );
  14799. foreach ( $receiptList as $r => $l ) {
  14800. $category = $Lcategory->getOne ( array (
  14801. 'where' => 'cid=' . $l ['cid'],
  14802. 'asArray' => true
  14803. ) );
  14804. $staffDetile = $staff->getOne ( array (
  14805. 'where' => 'sid=' . $l ['staff'],
  14806. 'asArray' => true
  14807. ) );
  14808. $html .= '
  14809. <tr>
  14810. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14811. <td align="left">
  14812. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14813. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14814. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14815. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14816. </tr>';
  14817. }
  14818. }
  14819. $html .= '
  14820. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14821. <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>
  14822. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14823. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14824. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14825. // $receipt=new receipt();
  14826. // $receipt->notice=1;
  14827. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14828. }
  14829. }
  14830. }
  14831. }
  14832. function setWXMsg($rid, $type) {
  14833. Doo::loadModel ( "receipt" );
  14834. $receipt = new receipt ();
  14835. $receiptDetail = $receipt->getOne ( array (
  14836. 'where' => 'rid=' . $rid,
  14837. 'asArray' => true
  14838. ) );
  14839. if (! empty ( $receiptDetail )) {
  14840. Doo::loadModel ( 'staff' );
  14841. $staff = new staff ();
  14842. $staffmsg = $staff->getOne ( array (
  14843. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14844. 'asArray' => TRUE
  14845. ) );
  14846. if (! empty ( $staffmsg ['wxid'] )) {
  14847. require_once (SITE_PATH . '/protected/class/client.php');
  14848. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14849. $user = $staffmsg ['wxid'];
  14850. $receiptName = '';
  14851. $msg = '';
  14852. switch ($receiptDetail ['Rtype']) {
  14853. case 0 :
  14854. $receiptName = '报销';
  14855. break;
  14856. case 1 :
  14857. $receiptName = '借款';
  14858. break;
  14859. case 2 :
  14860. $receiptName = '对公汇款';
  14861. break;
  14862. }
  14863. switch ($type) {
  14864. case 1 :
  14865. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14866. break;
  14867. case 2 :
  14868. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14869. break;
  14870. case 3 :
  14871. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14872. break;
  14873. }
  14874. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14875. }
  14876. }
  14877. }
  14878. // Email发送函数
  14879. function SMail($toemail, $subject, $contents) {
  14880. Doo::loadClass ( 'class.phpmailer' );
  14881. $mail = new PHPMailer ();
  14882. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14883. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14884. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14885. $mail->Password = "cDO1GjtY1seH"; // 密码
  14886. $mail->CharSet = "UTF8";
  14887. $mail->SMTPAuth = true;
  14888. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14889. $mail->Mailer = "smtp";
  14890. $mail->Port = 25;
  14891. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14892. $mail->MsgHTML ( $contents );
  14893. $mail->AddAddress ( $toemail );
  14894. $mail->CharSet = "UTF-8";
  14895. return $mail->Send ();
  14896. }
  14897. function h5Upload() {
  14898. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14899. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14900. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14901. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14902. header ( "HTTP/1.1 500 Internal Server Error" );
  14903. echo "POST exceeded maximum allowed size.";
  14904. exit ( 0 );
  14905. }
  14906. // Settings
  14907. $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)
  14908. $upload_name = "Filedata";
  14909. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14910. $extension_whitelist = array (
  14911. "doc",
  14912. "txt",
  14913. "jpg",
  14914. "gif",
  14915. "png"
  14916. ); // Allowed file extensions
  14917. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14918. // Other variables
  14919. $MAX_FILENAME_LENGTH = 260;
  14920. $file_name = "";
  14921. $file_extension = "";
  14922. $uploadErrors = array (
  14923. 0 => "文件上传成功",
  14924. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14925. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14926. 3 => "上传的文件仅为部分文件",
  14927. 4 => "没有文件上传",
  14928. 6 => "缺少临时文件夹"
  14929. );
  14930. $nk = time ();
  14931. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14932. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14933. echo "文件无法保存.";
  14934. exit ( 0 );
  14935. }
  14936. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14937. echo json_encode ( array (
  14938. 'filename' => $file_name,
  14939. 'id' => $nk
  14940. ) );
  14941. exit ( 0 );
  14942. }
  14943. function swfupload() {
  14944. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14945. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14946. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14947. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14948. header ( "HTTP/1.1 500 Internal Server Error" );
  14949. echo "POST exceeded maximum allowed size.";
  14950. exit ( 0 );
  14951. }
  14952. // Settings
  14953. $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)
  14954. $upload_name = "Filedata";
  14955. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14956. $extension_whitelist = array (
  14957. "doc",
  14958. "txt",
  14959. "jpg",
  14960. "gif",
  14961. "png"
  14962. ); // Allowed file extensions
  14963. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14964. // Other variables
  14965. $MAX_FILENAME_LENGTH = 260;
  14966. $file_name = "";
  14967. $file_extension = "";
  14968. $uploadErrors = array (
  14969. 0 => "文件上传成功",
  14970. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14971. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14972. 3 => "上传的文件仅为部分文件",
  14973. 4 => "没有文件上传",
  14974. 6 => "缺少临时文件夹"
  14975. );
  14976. $nk = time ();
  14977. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14978. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14979. echo "文件无法保存.";
  14980. exit ( 0 );
  14981. }
  14982. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14983. echo json_encode ( array (
  14984. 'filename' => $file_name,
  14985. 'id' => $nk
  14986. ) );
  14987. exit ( 0 );
  14988. }
  14989. function _GetFileEXT($filename) {
  14990. $pics = explode ( '.', $filename );
  14991. $num = count ( $pics );
  14992. return $pics [$num - 1];
  14993. }
  14994. /**
  14995. * 获取get或者POST值
  14996. * @param string $name 属性名称
  14997. * @return fixed 值
  14998. */
  14999. function get_args($name) {
  15000. if (isset ( $_GET [$name] )) {
  15001. if (is_array ( $_GET [$name] ))
  15002. return $_GET [$name];
  15003. else
  15004. return addslashes ( $_GET [$name] );
  15005. } elseif (isset ( $_POST [$name] )) {
  15006. if (is_array ( $_POST [$name] ))
  15007. return $_POST [$name];
  15008. else
  15009. return addslashes ( $_POST [$name] );
  15010. } else
  15011. return false;
  15012. }
  15013. function num_to_rmb($num) {
  15014. $c1 = "零壹贰叁肆伍陆柒捌玖";
  15015. $c2 = "分角元拾佰仟万拾佰仟亿";
  15016. // 精确到分后面就不要了,所以只留两个小数位
  15017. $num = round ( $num, 2 );
  15018. // 将数字转化为整数
  15019. $num = $num * 100;
  15020. if (strlen ( $num ) > 10) {
  15021. return "金额太大,请检查";
  15022. }
  15023. $i = 0;
  15024. $c = "";
  15025. while ( 1 ) {
  15026. if ($i == 0) {
  15027. // 获取最后一位数字
  15028. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  15029. } else {
  15030. $n = $num % 10;
  15031. }
  15032. // 每次将最后一位数字转化为中文
  15033. $p1 = substr ( $c1, 3 * $n, 3 );
  15034. $p2 = substr ( $c2, 3 * $i, 3 );
  15035. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  15036. $c = $p1 . $p2 . $c;
  15037. } else {
  15038. $c = $p1 . $c;
  15039. }
  15040. $i = $i + 1;
  15041. // 去掉数字最后一位了
  15042. $num = $num / 10;
  15043. // echo $num.'</br>';
  15044. $num = ( int ) $num;
  15045. // $num =floor($num);
  15046. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  15047. // echo $num.'</br>';
  15048. // 结束循环
  15049. if ($num == 0) {
  15050. break;
  15051. }
  15052. }
  15053. // echo $c.'</br>';
  15054. $j = 0;
  15055. $slen = strlen ( $c );
  15056. while ( $j < $slen ) {
  15057. // utf8一个汉字相当3个字符
  15058. $m = substr ( $c, $j, 6 );
  15059. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  15060. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  15061. $left = substr ( $c, 0, $j );
  15062. $right = substr ( $c, $j + 3 );
  15063. $c = $left . $right;
  15064. $j = $j - 3;
  15065. $slen = $slen - 3;
  15066. }
  15067. $j = $j + 3;
  15068. }
  15069. // 这个是为了去掉类似23.0中最后一个“零”字
  15070. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  15071. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  15072. }
  15073. // 将处理的汉字加上“整”
  15074. if (empty ( $c )) {
  15075. return "零元整";
  15076. } else {
  15077. return $c . "整";
  15078. }
  15079. }
  15080. /**
  15081. * 获得分页数据
  15082. * @param unknown_type $table
  15083. * @param unknown_type $condition
  15084. * @param unknown_type $on_page
  15085. * @param unknown_type $page_size
  15086. */
  15087. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  15088. $page_c = "";
  15089. $page ['previous'] = $this->get_previous ( $on_page );
  15090. $page ['on_page'] = $on_page;
  15091. $total_count = $this->get_table_count ( $table, $condition );
  15092. $total = intval ( $total_count / $page_size );
  15093. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  15094. $page ['total_data'] = $total_count;
  15095. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  15096. $i = 1;
  15097. $page_max = 1;
  15098. $page_width = 3;
  15099. if ($on_page >= $page_width) {
  15100. $page_max = intval ( $on_page / $page_width ) + 1;
  15101. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  15102. }
  15103. for(; $i <= $page ['total_page']; $i ++) {
  15104. if ($i == $on_page)
  15105. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  15106. else
  15107. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  15108. if ($i == ($page_width * $page_max))
  15109. break;
  15110. }
  15111. $page ['page'] = $page_c;
  15112. $page ['lower'] = (-- $on_page) * $page_size;
  15113. return $page;
  15114. }
  15115. /**
  15116. * 获取总页数
  15117. * @param unknown_type $table
  15118. * @param unknown_type $condition
  15119. */
  15120. public function get_table_count($table = "", $condition = "") {
  15121. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15122. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  15123. // echo $sql;die;
  15124. $query = Doo::db ()->query ( $sql );
  15125. $result = $query->fetch ();
  15126. return $result ['count'];
  15127. }
  15128. /**
  15129. * 获取上一页
  15130. * @param unknown_type $on_page
  15131. */
  15132. function get_previous($on_page = 1) {
  15133. return $on_page != 0 ? $on_page - 1 : $on_page;
  15134. }
  15135. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  15136. // 收入合计
  15137. Doo::loadModel ( 'invoiceTraining' );
  15138. $invoiceTraining = new invoiceTraining ();
  15139. Doo::loadModel ( 'receipt' );
  15140. $receipt = new receipt ();
  15141. $invoiceTrainingDetail = array (
  15142. 'invoiceArriveAmount' => '0.00',
  15143. 'RIAmount' => '0.00',
  15144. 'invoiceTotalAmount' => '0.00',
  15145. 'invoiceCompanyAmount' => '0.00',
  15146. 'invoiceArriveAmountM'=>'0.00',
  15147. 'invoiceCompanyAmountM'=>'0.00'
  15148. );
  15149. if ($invoiceTrainId != 0) {
  15150. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  15151. }
  15152. $invoiceArriveAmount = $RIAmount = 0;
  15153. if (! empty ( $invoiceTrainingDetail )) {
  15154. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  15155. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  15156. }
  15157. // 备用金
  15158. $sum = 0;
  15159. if (! empty ( $trainLoanRid )) {
  15160. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  15161. foreach ($receiptLoanList as $key=>$value){
  15162. $sum+=$value['sum'];
  15163. }
  15164. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  15165. // $sum = $receiptLoanDetailBak ['sum'];
  15166. }
  15167. // 支出项金额详情
  15168. // 项目金额合计
  15169. Doo::loadModel ( 'RItem' );
  15170. $RItem = new RItem ();
  15171. Doo::loadModel ( 'accountItem' );
  15172. $accountItem = new accountItem ();
  15173. // 讲师获得
  15174. Doo::loadModel ( 'RILecturer' );
  15175. $RILecturer = new RILecturer ();
  15176. $RItemList = $RItem->getRItemByRid ($rid );
  15177. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  15178. // 支出项金额详情
  15179. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  15180. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  15181. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  15182. return $payment;
  15183. }
  15184. }
  15185. ?>