ReceiptController.php 552 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856
  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. public function beforeRun($resource, $action) {
  58. Doo::loadClass ( 'XDeode' );
  59. $XDeode = new XDeode ( 5 );
  60. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  61. // 单独判断公司汇总的访问权限
  62. if ($action == 'companyCategoryCollect') {
  63. Doo::loadModel ( "receiptAuthorityManage" );
  64. $invoiceCompanyManage = new receiptAuthorityManage ();
  65. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  66. if (empty ( $icm ))
  67. die ( 'illegal request-statistics' );
  68. }
  69. Doo::loadModel ( 'staff' );
  70. $staff = new staff ();
  71. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  72. $accessModular = 'RECEIPTS';
  73. if (empty ( $detail ['cldAccessArray'] ))
  74. die ( 'illegal request' );
  75. else {
  76. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  77. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  78. $flag = true;
  79. } else {
  80. $flag = false;
  81. }
  82. } else {
  83. die ( 'illegal request' );
  84. }
  85. }
  86. if (! $flag)
  87. die ( 'illegal request' );
  88. }
  89. function __construct() {
  90. if (isset ( $_COOKIE ["staff"] )) {
  91. if (! empty ( $_COOKIE ["staff"] )) {
  92. Doo::loadModel ( 'staff' );
  93. Doo::loadModel ( 'verify' );
  94. $verify = new verify ();
  95. $staff = new staff ();
  96. Doo::loadModel ( "execute" );
  97. $execute = new execute ();
  98. $verifyList = $verify->find ( array (
  99. 'select' => 'staff',
  100. 'asArray' => true
  101. ) );
  102. $list = array ();
  103. // 判断角色的审批权限
  104. foreach ( $verifyList as $key => $value ) {
  105. $ver = json_decode ( $value ['staff'] );
  106. foreach ( $ver as $k => $v ) {
  107. if ($v [1] == 'ROLE') {
  108. $roleList = json_decode ( $v [3] );
  109. foreach ( $roleList as $t => $g ) {
  110. $gList = explode ( "_", $g );
  111. array_push ( $list, $gList [0] );
  112. // print_r($list);
  113. }
  114. } else
  115. array_push ( $list, $v [0] );
  116. }
  117. }
  118. // 判断执行人的审批权限
  119. $executeList = $execute->find ( array (
  120. 'where'=>'mold !="日常收支"',
  121. 'select' => 'staff',
  122. 'asArray' => true
  123. ) );
  124. $list2 = array ();
  125. foreach ( $executeList as $key => $value ) {
  126. $ver = json_decode ( $value ['staff'] );
  127. foreach ( $ver as $k => $v ) {
  128. array_push ( $list2, $v [0] );
  129. }
  130. }
  131. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  132. $eidList = array_filter ( explode ( ",", $eidList ) );
  133. $this->executeId = array_merge ( $list2, $eidList );
  134. //print_r($this->executeId);
  135. $this->verifyId = $list;
  136. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  137. // 检测用户信息完成
  138. $this->data ['isStaffCompleteMsg'] = false;
  139. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  140. if (! empty ( $detail ))
  141. $this->data ['isStaffCompleteMsg'] = true;
  142. return "/";
  143. }
  144. }
  145. Doo::loadCore ( 'uri/DooUriRouter' );
  146. $router = new DooUriRouter ();
  147. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  148. if ($routeRs ['1'] != "login") {
  149. header ( 'Content-Type:text/html;charset=utf-8' );
  150. @header ( "Location: /login" );
  151. }
  152. }
  153. /**
  154. * 费用首页
  155. */
  156. function saeaBorad() {
  157. $travel= $this->get_args ( 'travel' ) ? $this->get_args ( 'travel' ) : "";
  158. Doo::loadModel ( 'receipt' );
  159. $receipt = new receipt ();
  160. Doo::loadModel ( 'verify' );
  161. $verify = new verify ();
  162. Doo::loadModel ( 'L_category' );
  163. $lCategory = new L_category ();
  164. Doo::loadModel ( "role" );
  165. $role = new role ();
  166. Doo::loadModel ( "receiptLog" );
  167. $receiptLog = new receiptLog ();
  168. Doo::loadModel ( 'accountItem' );
  169. $accountItem = new accountItem ();
  170. Doo::loadClass ( 'XDeode' );
  171. $XDeode = new XDeode ( 7 );
  172. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  173. $receiptDetail = $receipt->find ( array (
  174. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  175. 'desc' => 'rid',
  176. 'asArray' => true
  177. ) );
  178. foreach ( $receiptDetail as $key => $value ) {
  179. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  180. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  181. $veList = $verify->getOne ( array (
  182. 'where' => 'vid=' . $value ['verify'],
  183. 'asArray' => true
  184. ) );
  185. $v = json_decode ( $veList ['staff'] );
  186. array_push ( $v [0], $veList ['description'] );
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. }
  195. }
  196. $receiptDetail [$key] ['staff'] = $v;
  197. $category = $lCategory->getOne ( array (
  198. 'where' => 'cid=' . $value ['cid'],
  199. 'asArray' => true
  200. ) );
  201. $receiptDetail [$key] ['category'] = $category ['title'];
  202. }
  203. // print_r($receiptLogList);
  204. Doo::loadModel ( 'RAssist' );
  205. $RAssist = new RAssist ();
  206. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  207. //费用项目
  208. $acItem = $accountItem->find ( array ('asArray' => true) );
  209. if ($travel=='success'){
  210. $data ['travel'] =true;
  211. }else{
  212. $data ['travel'] =false;
  213. }
  214. $data ['acItem'] = $acItem;
  215. $data ['receiptExtendList'] = $receiptExtendList;
  216. $data ['receiptLogList'] = $receiptLogList;
  217. $data ['receiptDetail'] = $receiptDetail;
  218. $data ['memu'] = "receipt";
  219. $data ['staff'] = $this->staff;
  220. $data ['receiptMemu'] = 'saeaBorad';
  221. $data ['verifyId'] = $this->verifyId;
  222. $data ['executeId'] = $this->executeId;
  223. $this->render ( "/receipt/receiptFee", $data );
  224. }
  225. /**
  226. * 费用报销单-导流入哪个细分类
  227. */
  228. function receiptFeeDiversion(){
  229. $feeType= $this->get_args ( 'feeType' ) ? $this->get_args ( 'feeType' ) : "";
  230. if($feeType==2){
  231. return '/receipt/feeTravel';
  232. }elseif($feeType==3){
  233. return '/receipt/feeInternalTrain';
  234. }else{
  235. return '/receipt/feeAgency';
  236. }
  237. }
  238. private function _feeData(){
  239. Doo::loadModel ( 'L_category' );
  240. $lCategory = new L_category ();
  241. Doo::loadModel ( 'verify' );
  242. $verify = new verify ();
  243. Doo::loadModel ( 'accountItem' );
  244. $accountItem = new accountItem ();
  245. Doo::loadModel ( "role" );
  246. $role = new role ();
  247. $acItem = $accountItem->find ( array (
  248. 'asArray' => true
  249. ) );
  250. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  251. $data ['category'] = $lCategory->find ( array (
  252. 'asArray' => true
  253. ) );
  254. $data ['veList'] = $veList;
  255. $data ['acItem'] = $acItem;
  256. $data ['memu'] = "receipt";
  257. $data ['staff'] = $this->staff;
  258. $data ['receiptMemu'] = 'saeaBorad';
  259. $data ['verifyId'] = $this->verifyId;
  260. $data ['executeId'] = $this->executeId;
  261. return $data;
  262. }
  263. /**
  264. * 办事处相关费用
  265. */
  266. function feeAgency(){
  267. $data=$this->_feeData();
  268. $this->render ( "/receipt/feeAgency", $data );
  269. }
  270. /**
  271. * 办事处
  272. */
  273. function feeTravel(){
  274. $data=$this->_feeData();
  275. $this->render ( "/receipt/feeTravel", $data );
  276. }
  277. function feeInternalTrain(){
  278. $data=$this->_feeData();
  279. $this->render ( "/receipt/feeInternalTrain", $data );
  280. }
  281. /**
  282. * 添加费用报销单页面
  283. */
  284. function saeaCreate() {
  285. Doo::loadModel ( 'accountItem' );
  286. Doo::loadModel ( 'verify' );
  287. Doo::loadModel ( 'receipt' );
  288. Doo::loadModel ( 'L_category' );
  289. $lCategory = new L_category ();
  290. $receipt = new receipt ();
  291. $verify = new verify ();
  292. $accountItem = new accountItem ();
  293. Doo::loadModel ( "role" );
  294. $role = new role ();
  295. $acItem = $accountItem->find ( array (
  296. 'asArray' => true
  297. ) );
  298. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  299. $data ['category'] = $lCategory->find ( array (
  300. 'asArray' => true
  301. ) );
  302. $data ['veList'] = $veList;
  303. $data ['acItem'] = $acItem;
  304. $data ['memu'] = "receipt";
  305. $data ['staff'] = $this->staff;
  306. $data ['receiptMemu'] = 'saeaBorad';
  307. $data ['verifyId'] = $this->verifyId;
  308. $data ['executeId'] = $this->executeId;
  309. $this->render ( "/admin/saea_create", $data );
  310. }
  311. private function _storageItinerary($itinerary,$rid){
  312. Doo::loadModel ( 'itinerary' );
  313. $itineraryJson=json_decode($itinerary,true);
  314. $itinerary = new itinerary ();
  315. $itinerary->delete(array('where' => 'rid=' . $rid ));
  316. foreach ($itineraryJson as $key=>$value){
  317. if($key==0){
  318. $feeTraveItem=json_encode($value['feeTraveItem']);
  319. $itinerary = new itinerary ();
  320. $itinerary->rid=$rid;
  321. $itinerary->sid=$this->staff [0] ['sid'];
  322. $itinerary->itineraryDate=$value['departuredate'];
  323. $itinerary->itineraryCity=$value['departurecity'];
  324. $itinerary->feeTraveItem='';
  325. $itinerary->itineraryIndex=0;
  326. $itinerary->insert ();
  327. $itinerary = new itinerary ();
  328. $itinerary->rid=$rid;
  329. $itinerary->sid=$this->staff [0] ['sid'];
  330. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  331. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  332. $itinerary->feeTraveItem=$feeTraveItem;
  333. $itinerary->itineraryIndex=1;
  334. $itinerary->insert ();
  335. }else{
  336. $feeTraveItem=json_encode($value['feeTraveItem']);
  337. $itinerary = new itinerary ();
  338. $itinerary->rid=$rid;
  339. $itinerary->sid=$this->staff [0] ['sid'];
  340. $itinerary->itineraryDate=substr($value['arrivalsdate'],1);
  341. $itinerary->itineraryCity=substr($value['arrivalscity'],1);
  342. $itinerary->feeTraveItem=$feeTraveItem;
  343. $itinerary->itineraryIndex=$key+1;
  344. $itinerary->insert ();
  345. }
  346. }
  347. }
  348. private function _verificationItinerary($itinerary){
  349. Doo::loadModel ( 'itinerary' );
  350. $itineraryObj = new itinerary ();
  351. $itineraryJson=json_decode($itinerary,true);
  352. $itineraryDate=array();$sql=array();
  353. foreach ($itineraryJson as $key=>$value){
  354. if($key==0){
  355. array_push($itineraryDate, $value['departuredate']);
  356. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  357. array_push($sql,'?');array_push($sql,'?');
  358. }else{
  359. array_push($itineraryDate, substr($value['arrivalsdate'],1));
  360. array_push($sql,'?');
  361. }
  362. }
  363. array_push($itineraryDate, $this->staff [0] ['sid']);
  364. $sql=implode(',',$sql);
  365. $qualification=array(
  366. 'where' => 'itineraryDate in ('.$sql.') and sid=? ',
  367. 'param' => $itineraryDate,
  368. 'asArray' => TRUE);
  369. $itDateList=$itineraryObj->find($qualification);
  370. if(empty($itDateList)){
  371. return false;
  372. }else{
  373. return true;
  374. }
  375. }
  376. private function _buildFeeData($receiptClass=1,$itinerary=''){
  377. $agency = $this->get_args ( 'agency' );
  378. $travel = $this->get_args ( 'travel' );
  379. $train = $this->get_args ( 'train' );
  380. $other = $this->get_args ( 'other' );
  381. $inttrain = $this->get_args ( 'inttrain' );
  382. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  383. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  384. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  385. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  386. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  387. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  388. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  389. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  390. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  391. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  392. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  393. header ( 'Content-Type:text/html;charset=utf-8' );
  394. die ( '请填写联行号' );
  395. }
  396. if($this->_verificationItinerary($itinerary)){
  397. header ( 'Content-Type:text/html;charset=utf-8' );
  398. die ( '已申请过类此日期的行程' );
  399. }
  400. Doo::loadModel ( 'receipt' );
  401. Doo::loadModel ( 'receiptDetail' );
  402. Doo::loadModel ( 'accountItem' );
  403. $accountItem = new accountItem ();
  404. $receipt = new receipt ();
  405. Doo::loadModel ( 'enclosur' );
  406. Doo::loadModel ( 'execute' );
  407. $execute = new execute ();
  408. $executeDetail = $execute->getOne ( array (
  409. 'where' => 'mold="报销单执行人"',
  410. 'asArray' => true
  411. ) );
  412. $aItem = $accountItem->find ( array (
  413. 'asArray' => true
  414. ) );
  415. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  416. $ag = $tr = $ta = $ot= $it = 0;
  417. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  418. foreach ( $aItem as $key => $value ) {
  419. if ($value ['category'] == $this->AGENCY) {
  420. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  421. array_push ( $accountJson [$this->AGENCY], array (
  422. 'aid' => $value ['aid'],
  423. 'name' => $value ['name'],
  424. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  425. ) );
  426. $sum += $agency [$ag];
  427. $agencySum += $agency [$ag];
  428. }
  429. $ag ++;
  430. }
  431. if ($value ['category'] == $this->TRAVEL) {
  432. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  433. array_push ( $accountJson [$this->TRAVEL], array (
  434. 'aid' => $value ['aid'],
  435. 'name' => $value ['name'],
  436. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  437. ) );
  438. $sum += $travel [$tr];
  439. $travelSum += $travel [$tr];
  440. }
  441. $tr ++;
  442. }
  443. if ($value ['category'] == $this->TRAIN) {
  444. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  445. array_push ( $accountJson [$this->TRAIN], array (
  446. 'aid' => $value ['aid'],
  447. 'name' => $value ['name'],
  448. 'price' => number_format ( $train [$ta], 2, '.', '' )
  449. ) );
  450. $sum += $train [$ta];
  451. $trainSum += $train [$ta];
  452. }
  453. $ta ++;
  454. }
  455. if ($value ['category'] == $this->INTTRAIN) {
  456. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  457. array_push ( $accountJson [$this->INTTRAIN], array (
  458. 'aid' => $value ['aid'],
  459. 'name' => $value ['name'],
  460. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  461. ) );
  462. $sum += $inttrain [$it];
  463. $inttrainSum += $inttrain [$it];
  464. }
  465. $it ++;
  466. }
  467. if ($value ['category'] == $this->OTHER) {
  468. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  469. array_push ( $accountJson [$this->OTHER], array (
  470. 'aid' => $value ['aid'],
  471. 'name' => $value ['name'],
  472. 'price' => number_format ( $other [$ot], 2, '.', '' )
  473. ) );
  474. $sum += $other [$ot];
  475. $otherSum += $other [$ot];
  476. }
  477. $ot ++;
  478. }
  479. }
  480. $accountJson ['cSum'] = array (
  481. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  482. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  483. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  484. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  485. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  486. );
  487. // 报销单
  488. $receipt->accountItem = json_encode ( $accountJson );
  489. $receipt->staff = $this->staff [0] ['sid'];
  490. $receipt->sum = number_format ( $sum, 2, '.', '' );
  491. $receipt->date = date ( "Y-m-d" );
  492. $receipt->cid = $cid;
  493. $receipt->status = 5;
  494. // 修改审批流程加入角色
  495. $receipt->verify = $verify;
  496. $receipt->executeCopy = $executeDetail ['staff'];
  497. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  498. $order = array (
  499. "\r\n",
  500. "\n",
  501. "\r"
  502. );
  503. $replace = '<br/>';
  504. $explanation = str_replace ( $order, $replace, $explanation );
  505. $receipt->explanation = $explanation;
  506. $receipt->receiptClass = $receiptClass;
  507. $receipt->itinerary=$itinerary;
  508. $receipt->remittanceName = $remittanceName;
  509. $receipt->bankName = $bankName;
  510. $receipt->bankNumber = $bankNumber;
  511. $receipt->remittanceBankType = $remittanceBankType;
  512. if ($remittanceBankType == 1) {
  513. $receipt->coupletNumber = $coupletNumber;
  514. }
  515. $rid = $receipt->insert ();
  516. //记录行程单
  517. $this->_storageItinerary($itinerary,$rid);
  518. // 附件
  519. if (! empty ( $enclosurName )) {
  520. $enclosurArray = explode ( '-', $enclosurName );
  521. foreach ( $enclosurArray as $value ) {
  522. $enclosur = new enclosur ();
  523. $enclosur->name = $value;
  524. $enclosur->rid = $rid;
  525. $enclosur->insert ();
  526. }
  527. }
  528. // 报销详情
  529. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  530. $receiptDetail = new receiptDetail ();
  531. $receiptDetail->staff = $this->staff [0] ['sid'];
  532. $receiptDetail->item = $value ['name'];
  533. $receiptDetail->itemCategory = $this->AGENCY;
  534. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  535. $receiptDetail->date = date ( "Y-m-d" );
  536. $receiptDetail->cid = $cid;
  537. $receiptDetail->rid = $rid;
  538. $receiptDetail->status = 4;
  539. $receiptDetail->insert ();
  540. }
  541. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  542. $receiptDetail = new receiptDetail ();
  543. $receiptDetail->staff = $this->staff [0] ['sid'];
  544. $receiptDetail->item = $value ['name'];
  545. $receiptDetail->itemCategory = $this->TRAVEL;
  546. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  547. $receiptDetail->date = date ( "Y-m-d" );
  548. $receiptDetail->cid = $cid;
  549. $receiptDetail->rid = $rid;
  550. $receiptDetail->status = 4;
  551. $receiptDetail->insert ();
  552. }
  553. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  554. $receiptDetail = new receiptDetail ();
  555. $receiptDetail->staff = $this->staff [0] ['sid'];
  556. $receiptDetail->item = $value ['name'];
  557. $receiptDetail->itemCategory = $this->TRAIN;
  558. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  559. $receiptDetail->date = date ( "Y-m-d" );
  560. $receiptDetail->cid = $cid;
  561. $receiptDetail->rid = $rid;
  562. $receiptDetail->status = 4;
  563. $receiptDetail->insert ();
  564. }
  565. // 内训
  566. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  567. $receiptDetail = new receiptDetail ();
  568. $receiptDetail->staff = $this->staff [0] ['sid'];
  569. $receiptDetail->item = $value ['name'];
  570. $receiptDetail->itemCategory = $this->INTTRAIN;
  571. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  572. $receiptDetail->date = date ( "Y-m-d" );
  573. $receiptDetail->cid = $cid;
  574. $receiptDetail->rid = $rid;
  575. $receiptDetail->status = 4;
  576. $receiptDetail->insert ();
  577. }
  578. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  579. $receiptDetail = new receiptDetail ();
  580. $receiptDetail->staff = $this->staff [0] ['sid'];
  581. $receiptDetail->item = $value ['name'];
  582. $receiptDetail->itemCategory = $this->OTHER;
  583. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  584. $receiptDetail->date = date ( "Y-m-d" );
  585. $receiptDetail->cid = $cid;
  586. $receiptDetail->rid = $rid;
  587. $receiptDetail->status = 4;
  588. $receiptDetail->insert ();
  589. }
  590. return true;
  591. } else
  592. return false;
  593. }
  594. function addReceipt() {
  595. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  596. if ($this->_buildFeeData(1)) {
  597. return "/saeaBorad";
  598. } else{
  599. die ( 'illegal request' );
  600. }
  601. }
  602. function addFeeTravel(){
  603. $itinerary = $_POST['itinerary'] ? $_POST['itinerary'] : "";
  604. $itineraryList=json_decode($itinerary,true);
  605. foreach ($itineraryList as $key=>$value){
  606. if(empty($value['departuredate'])||empty($value['departurecity'])){
  607. header ( 'Content-Type:text/html;charset=utf-8' );
  608. die ( '请设置出发地和出发日期' );
  609. }
  610. }
  611. if ($this->_buildFeeData(2,$itinerary)) {
  612. return "/saeaBorad?travel=success";
  613. } else{
  614. die ( 'illegal request' );
  615. }
  616. }
  617. function addFeeInternalTrain(){
  618. if ($this->_buildFeeData(3)) {
  619. return "/saeaBorad";
  620. } else{
  621. die ( 'illegal request' );
  622. }
  623. }
  624. function referReceipt() {
  625. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  626. Doo::loadModel ( 'receipt' );
  627. Doo::loadModel ( 'verify' );
  628. $verify = new verify ();
  629. $receipt = new receipt ();
  630. Doo::loadModel ( 'L_category' );
  631. $lCategory = new L_category ();
  632. Doo::loadModel ( "role" );
  633. $role = new role ();
  634. $receiptDetail = $receipt->find ( array (
  635. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  636. 'asArray' => true
  637. ) );
  638. if (empty ( $receiptDetail ))
  639. return "/addReceipt";
  640. foreach ( $receiptDetail as $key => $value ) {
  641. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  642. $veList = $verify->getOne ( array (
  643. 'where' => 'vid=' . $value ['verify'],
  644. 'asArray' => true
  645. ) );
  646. $v = json_decode ( $veList ['staff'] );
  647. array_push ( $v [0], $veList ['description'] );
  648. foreach ( $v as $n => $m ) {
  649. if ($m ['1'] == 'ROLE') {
  650. $roleInfo = $role->getOne ( array (
  651. 'where' => 'rid=' . $m [0],
  652. 'asArray' => true
  653. ) );
  654. $v [$n] [1] = $roleInfo ['name'];
  655. }
  656. }
  657. $receiptDetail [$key] ['staff'] = $v;
  658. $category = $lCategory->getOne ( array (
  659. 'where' => 'cid=' . $value ['cid'],
  660. 'asArray' => true
  661. ) );
  662. $receiptDetail [$key] ['category'] = $category ['title'];
  663. }
  664. // print_r($receiptDetail);
  665. $data ['receiptDetail'] = $receiptDetail;
  666. $data ['memu'] = "receipt";
  667. $data ['staff'] = $this->staff;
  668. $data ['receiptMemu'] = 'saeaCreate';
  669. $data ['verifyId'] = $this->verifyId;
  670. $data ['executeId'] = $this->executeId;
  671. $this->render ( "/admin/saea_confirm", $data );
  672. }
  673. function editReceipt() {
  674. // edit status 4
  675. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  676. Doo::loadClass ( 'XDeode' );
  677. $XDeode = new XDeode ( 7 );
  678. $rid = $XDeode->decode ( $ridKey );
  679. if (empty ( $rid )) {
  680. die ( 'illegal request' );
  681. }
  682. // echo $rid.'sd';
  683. Doo::loadModel ( 'accountItem' );
  684. Doo::loadModel ( 'verify' );
  685. Doo::loadModel ( 'receipt' );
  686. $receipt = new receipt ();
  687. $verify = new verify ();
  688. $accountItem = new accountItem ();
  689. Doo::loadModel ( 'L_category' );
  690. $lCategory = new L_category ();
  691. Doo::loadModel ( "role" );
  692. $role = new role ();
  693. Doo::loadModel ( 'enclosur' );
  694. $enclosur = new enclosur ();
  695. $receiptDetail = $receipt->getOne ( array (
  696. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  697. 'asArray' => true
  698. ) );
  699. if (empty ( $receiptDetail )) {
  700. die ( 'illegal request' );
  701. }
  702. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  703. $acItem = $accountItem->find ( array (
  704. 'asArray' => true
  705. ) );
  706. $veList = $verify->getVerifyBySubordinate ( 'RECEIPT' );
  707. // 配置编辑信息
  708. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  709. foreach ( $acItem as $key => $value ) {
  710. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  711. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  712. $acItem [$key] ['price'] = $v ['price'];
  713. }
  714. }
  715. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  716. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  717. $acItem [$key] ['price'] = $v ['price'];
  718. }
  719. }
  720. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  721. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  722. $acItem [$key] ['price'] = $v ['price'];
  723. }
  724. }
  725. // 内训
  726. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  727. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  728. $acItem [$key] ['price'] = $v ['price'];
  729. }
  730. }
  731. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  732. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  733. $acItem [$key] ['price'] = $v ['price'];
  734. }
  735. }
  736. }
  737. $data ['category'] = $lCategory->find ( array (
  738. 'asArray' => true
  739. ) );
  740. $data ['cSum'] = $accountItemList ['cSum'];
  741. $data ['sum'] = $receiptDetail ['sum'];
  742. $data ['enclosurList'] = $enclosurList;
  743. $data ['receiptDetail'] = $receiptDetail;
  744. $data ['veList'] = $veList;
  745. $data ['acItem'] = $acItem;
  746. $data ['memu'] = "receipt";
  747. $data ['staff'] = $this->staff;
  748. $data ['receiptMemu'] = 'saeaBorad';
  749. $data ['verify'] = $receiptDetail ['verify'];
  750. $data ['verifyId'] = $this->verifyId;
  751. $data ['executeId'] = $this->executeId;
  752. $data ['rid'] = $ridKey;
  753. if($receiptDetail['receiptClass']==1){
  754. $this->render ( "/receipt/feeAgencyEdi", $data );
  755. }elseif($receiptDetail['receiptClass']==2){
  756. $this->render ( "/receipt/feeTravelEdi", $data );
  757. }elseif($receiptDetail['receiptClass']==3){
  758. $this->render ( "/receipt/feeInternalTrainEdi", $data );
  759. }else{
  760. die ( 'illegal request' );
  761. }
  762. }
  763. function updateReceipt() {
  764. $agency = $this->get_args ( 'agency' );
  765. $travel = $this->get_args ( 'travel' );
  766. $train = $this->get_args ( 'train' );
  767. $other = $this->get_args ( 'other' );
  768. $inttrain = $this->get_args ( 'inttrain' );
  769. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  770. $itinerary = $this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  771. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  772. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  773. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  774. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  775. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  776. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  777. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  778. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  779. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  780. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  781. Doo::loadClass ( 'XDeode' );
  782. $XDeode = new XDeode ( 7 );
  783. $rid = $XDeode->decode ( $ridKey );
  784. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  785. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  786. header ( 'Content-Type:text/html;charset=utf-8' );
  787. die ( '请填写联行号' );
  788. }
  789. Doo::loadModel ( 'receipt' );
  790. Doo::loadModel ( 'receiptDetail' );
  791. Doo::loadModel ( 'accountItem' );
  792. $accountItem = new accountItem ();
  793. $receipt = new receipt ();
  794. Doo::loadModel ( 'enclosur' );
  795. Doo::loadModel ( 'execute' );
  796. $execute = new execute ();
  797. $receiptDetail = $receipt->getOne ( array (
  798. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  799. 'asArray' => true
  800. ) );
  801. if (empty ( $receiptDetail )) {
  802. return "/saeaBorad";
  803. }
  804. //行程单
  805. $this->_storageItinerary($itinerary,$rid);
  806. if ($receiptDetail ['Rtype'] == 1) {
  807. $executeDetail = $execute->getOne ( array (
  808. 'where' => 'mold="借款费用执行人"',
  809. 'asArray' => true
  810. ) );
  811. } else {
  812. $executeDetail = $execute->getOne ( array (
  813. 'where' => 'mold="报销单执行人"',
  814. 'asArray' => true
  815. ) );
  816. }
  817. $aItem = $accountItem->find ( array (
  818. 'asArray' => true
  819. ) );
  820. $accountJson [$this->AGENCY] = $accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  821. $ag = $tr = $ta = $ot = $it = 0;
  822. $sum = $agencySum = $travelSum = $trainSum = $inttrainSum = $otherSum = 0;
  823. foreach ( $aItem as $key => $value ) {
  824. if ($value ['category'] == $this->AGENCY) {
  825. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  826. array_push ( $accountJson [$this->AGENCY], array (
  827. 'aid' => $value ['aid'],
  828. 'name' => $value ['name'],
  829. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  830. ) );
  831. $sum += $agency [$ag];
  832. $agencySum += $agency [$ag];
  833. }
  834. $ag ++;
  835. }
  836. if ($value ['category'] == $this->TRAVEL) {
  837. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  838. array_push ( $accountJson [$this->TRAVEL], array (
  839. 'aid' => $value ['aid'],
  840. 'name' => $value ['name'],
  841. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  842. ) );
  843. $sum += $travel [$tr];
  844. $travelSum += $travel [$tr];
  845. }
  846. $tr ++;
  847. }
  848. if ($value ['category'] == $this->TRAIN) {
  849. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  850. array_push ( $accountJson [$this->TRAIN], array (
  851. 'aid' => $value ['aid'],
  852. 'name' => $value ['name'],
  853. 'price' => number_format ( $train [$ta], 2, '.', '' )
  854. ) );
  855. $sum += $train [$ta];
  856. $trainSum += $train [$ta];
  857. }
  858. $ta ++;
  859. }
  860. if ($value ['category'] == $this->INTTRAIN) {
  861. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  862. array_push ( $accountJson [$this->INTTRAIN], array (
  863. 'aid' => $value ['aid'],
  864. 'name' => $value ['name'],
  865. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  866. ) );
  867. $sum += $inttrain [$it];
  868. $inttrainSum += $inttrain [$it];
  869. }
  870. $it ++;
  871. }
  872. if ($value ['category'] == $this->OTHER) {
  873. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  874. array_push ( $accountJson [$this->OTHER], array (
  875. 'aid' => $value ['aid'],
  876. 'name' => $value ['name'],
  877. 'price' => number_format ( $other [$ot], 2, '.', '' )
  878. ) );
  879. $sum += $other [$ot];
  880. $otherSum += $other [$ot];
  881. }
  882. $ot ++;
  883. }
  884. }
  885. $accountJson ['cSum'] = array (
  886. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  887. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  888. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  889. 'inttrainSum' => number_format ( $inttrainSum, 2, '.', '' ),
  890. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  891. );
  892. // 报销单
  893. $rid = $receipt->rid = $receiptDetail ['rid'];
  894. $receipt->accountItem = json_encode ( $accountJson );
  895. $receipt->staff = $this->staff [0] ['sid'];
  896. $receipt->sum = number_format ( $sum, 2, '.', '' );
  897. $receipt->date = date ( "Y-m-d" );
  898. $receipt->cid = $cid;
  899. if (($receiptDetail ['status'] != 4)) {
  900. if ($receiptDetail ['Rtype'] == 1) {
  901. $receipt->status = 7;
  902. } else {
  903. $receipt->status = 5;
  904. }
  905. }
  906. if ($receiptDetail != 4 && ! empty ( $verify ))
  907. $receipt->verify = $verify;
  908. $receipt->executeCopy = $executeDetail ['staff'];
  909. $order = array (
  910. "\r\n",
  911. "\n",
  912. "\r"
  913. );
  914. $replace = '<br/>';
  915. $explanation = str_replace ( $order, $replace, $explanation );
  916. $receipt->explanation = $explanation;
  917. if($receiptClass=='trave'){
  918. $receipt->itinerary=$itinerary;
  919. }
  920. $receipt->remittanceName = $remittanceName;
  921. $receipt->bankName = $bankName;
  922. $receipt->bankNumber = $bankNumber;
  923. $receipt->remittanceBankType = $remittanceBankType;
  924. if ($remittanceBankType == 1)
  925. $receipt->coupletNumber = $coupletNumber;
  926. $receipt->update ();
  927. $receiptDetail = new receiptDetail ();
  928. $receiptDetail->delete ( array (
  929. 'where' => 'rid=' . $rid
  930. ) );
  931. // 报销详情
  932. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  933. $receiptDetail = new receiptDetail ();
  934. $receiptDetail->staff = $this->staff [0] ['sid'];
  935. $receiptDetail->item = $value ['name'];
  936. $receiptDetail->itemCategory = $this->AGENCY;
  937. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  938. $receiptDetail->date = date ( "Y-m-d" );
  939. $receiptDetail->cid = $cid;
  940. $receiptDetail->rid = $rid;
  941. $receiptDetail->status = 4;
  942. $receiptDetail->insert ();
  943. }
  944. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  945. $receiptDetail = new receiptDetail ();
  946. $receiptDetail->staff = $this->staff [0] ['sid'];
  947. $receiptDetail->item = $value ['name'];
  948. $receiptDetail->itemCategory = $this->TRAVEL;
  949. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  950. $receiptDetail->date = date ( "Y-m-d" );
  951. $receiptDetail->cid = $cid;
  952. $receiptDetail->rid = $rid;
  953. $receiptDetail->status = 4;
  954. $receiptDetail->insert ();
  955. }
  956. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  957. $receiptDetail = new receiptDetail ();
  958. $receiptDetail->staff = $this->staff [0] ['sid'];
  959. $receiptDetail->item = $value ['name'];
  960. $receiptDetail->itemCategory = $this->TRAIN;
  961. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  962. $receiptDetail->date = date ( "Y-m-d" );
  963. $receiptDetail->cid = $cid;
  964. $receiptDetail->rid = $rid;
  965. $receiptDetail->status = 4;
  966. $receiptDetail->insert ();
  967. }
  968. // 内训
  969. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  970. $receiptDetail = new receiptDetail ();
  971. $receiptDetail->staff = $this->staff [0] ['sid'];
  972. $receiptDetail->item = $value ['name'];
  973. $receiptDetail->itemCategory = $this->INTTRAIN;
  974. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  975. $receiptDetail->date = date ( "Y-m-d" );
  976. $receiptDetail->cid = $cid;
  977. $receiptDetail->rid = $rid;
  978. $receiptDetail->status = 4;
  979. $receiptDetail->insert ();
  980. }
  981. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  982. $receiptDetail = new receiptDetail ();
  983. $receiptDetail->staff = $this->staff [0] ['sid'];
  984. $receiptDetail->item = $value ['name'];
  985. $receiptDetail->itemCategory = $this->OTHER;
  986. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  987. $receiptDetail->date = date ( "Y-m-d" );
  988. $receiptDetail->cid = $cid;
  989. $receiptDetail->rid = $rid;
  990. $receiptDetail->status = 4;
  991. $receiptDetail->insert ();
  992. }
  993. // 附件
  994. if (! empty ( $enclosurName )) {
  995. $enclosurArray = explode ( '-', $enclosurName );
  996. foreach ( $enclosurArray as $value ) {
  997. $enclosur = new enclosur ();
  998. $enclosur->name = $value;
  999. $enclosur->rid = $rid;
  1000. $enclosur->insert ();
  1001. }
  1002. }
  1003. // return "/referReceipt/".$rid;
  1004. }
  1005. return "/saeaBorad";
  1006. }
  1007. function remitAdd() {
  1008. Doo::loadModel ( 'accountItem' );
  1009. Doo::loadModel ( 'verify' );
  1010. Doo::loadModel ( 'receipt' );
  1011. Doo::loadModel ( 'L_category' );
  1012. $lCategory = new L_category ();
  1013. $receipt = new receipt ();
  1014. $verify = new verify ();
  1015. $accountItem = new accountItem ();
  1016. Doo::loadModel ( "role" );
  1017. $role = new role ();
  1018. $acItem = $accountItem->find ( array (
  1019. 'asArray' => true
  1020. ) );
  1021. $veList = $verify->getVerifyBySubordinate('REMIT');
  1022. $data ['category'] = $lCategory->find ( array (
  1023. 'asArray' => true
  1024. ) );
  1025. $data ['veList'] = $veList;
  1026. $data ['acItem'] = $acItem;
  1027. $data ['memu'] = "receipt";
  1028. $data ['staff'] = $this->staff;
  1029. $data ['receiptMemu'] = 'saeaBorad';
  1030. $data ['verifyId'] = $this->verifyId;
  1031. $data ['executeId'] = $this->executeId;
  1032. $this->render ( "/admin/remitAdd", $data );
  1033. }
  1034. function remitAddDo() {
  1035. $agency = $this->get_args ( 'agency' );
  1036. $travel = $this->get_args ( 'travel' );
  1037. $train = $this->get_args ( 'train' );
  1038. $other = $this->get_args ( 'other' );
  1039. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1040. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1041. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1042. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1043. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1044. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1045. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1046. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1047. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1048. // print_r($agency);die;
  1049. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1050. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1051. header ( 'Content-Type:text/html;charset=utf-8' );
  1052. die ( '请填写联行号' );
  1053. }
  1054. Doo::loadModel ( 'receipt' );
  1055. Doo::loadModel ( 'receiptDetail' );
  1056. Doo::loadModel ( 'accountItem' );
  1057. $accountItem = new accountItem ();
  1058. $receipt = new receipt ();
  1059. Doo::loadModel ( 'enclosur' );
  1060. Doo::loadModel ( 'execute' );
  1061. $execute = new execute ();
  1062. $executeDetail = $execute->getOne ( array (
  1063. 'where' => 'mold="对公汇款执行人"',
  1064. 'asArray' => true
  1065. ) );
  1066. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  1067. $aItem = $accountItem->find ( array (
  1068. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1069. 'asArray' => true
  1070. ) );
  1071. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1072. $ag = $tr = $ta = $ot = 0;
  1073. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1074. print_r($aItem);
  1075. foreach ( $aItem as $key => $value ) {
  1076. if ($value ['category'] == $this->AGENCY) {
  1077. if (isset ( $agency [$ag] )) {
  1078. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1079. array_push ( $accountJson [$this->AGENCY], array (
  1080. 'aid' => $value ['aid'],
  1081. 'name' => $value ['name'],
  1082. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1083. ) );
  1084. $sum += $agency [$ag];
  1085. $agencySum += $agency [$ag];
  1086. }
  1087. }
  1088. $ag ++;
  1089. }
  1090. }
  1091. $accountJson ['cSum'] = array (
  1092. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1093. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1094. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1095. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1096. );
  1097. //die;
  1098. // 报销单
  1099. $receipt->accountItem = json_encode ( $accountJson );
  1100. $receipt->staff = $this->staff [0] ['sid'];
  1101. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1102. $receipt->date = date ( "Y-m-d" );
  1103. $receipt->cid = $cid;
  1104. $receipt->status = 5;
  1105. $receipt->Rtype = 2;
  1106. // 修改审批流程加入角色
  1107. $receipt->verify = $verify;
  1108. $receipt->executeCopy = $executeDetail ['staff'];
  1109. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1110. $order = array (
  1111. "\r\n",
  1112. "\n",
  1113. "\r"
  1114. );
  1115. $replace = '<br/>';
  1116. $explanation = str_replace ( $order, $replace, $explanation );
  1117. $receipt->explanation = $explanation;
  1118. $receipt->remittanceName = $remittanceName;
  1119. $receipt->bankName = $bankName;
  1120. $receipt->bankNumber = $bankNumber;
  1121. $receipt->remittanceBankType = $remittanceBankType;
  1122. if ($remittanceBankType == 1)
  1123. $receipt->coupletNumber = $coupletNumber;
  1124. $rid = $receipt->insert ();
  1125. // 附件
  1126. if (! empty ( $enclosurName )) {
  1127. $enclosurArray = explode ( '-', $enclosurName );
  1128. foreach ( $enclosurArray as $value ) {
  1129. $enclosur = new enclosur ();
  1130. $enclosur->name = $value;
  1131. $enclosur->rid = $rid;
  1132. $enclosur->insert ();
  1133. }
  1134. // print_r($enclosurArray);die;
  1135. }
  1136. // 报销详情
  1137. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1138. $receiptDetail = new receiptDetail ();
  1139. $receiptDetail->staff = $this->staff [0] ['sid'];
  1140. $receiptDetail->item = $value ['name'];
  1141. $receiptDetail->itemCategory = $this->AGENCY;
  1142. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1143. $receiptDetail->date = date ( "Y-m-d" );
  1144. $receiptDetail->cid = $cid;
  1145. $receiptDetail->rid = $rid;
  1146. $receiptDetail->status = 4;
  1147. $receiptDetail->insert ();
  1148. }
  1149. return "/saeaBorad";
  1150. } else
  1151. die ( 'illegal request' );
  1152. }
  1153. function remitEdit() {
  1154. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1155. Doo::loadClass ( 'XDeode' );
  1156. $XDeode = new XDeode ( 7 );
  1157. $rid = $XDeode->decode ( $ridKey );
  1158. if (! is_numeric ( $rid ))
  1159. die ( 'illegal request' );
  1160. Doo::loadModel ( 'accountItem' );
  1161. Doo::loadModel ( 'verify' );
  1162. Doo::loadModel ( 'receipt' );
  1163. $receipt = new receipt ();
  1164. $verify = new verify ();
  1165. $accountItem = new accountItem ();
  1166. Doo::loadModel ( 'L_category' );
  1167. $lCategory = new L_category ();
  1168. Doo::loadModel ( "role" );
  1169. $role = new role ();
  1170. Doo::loadModel ( 'enclosur' );
  1171. $enclosur = new enclosur ();
  1172. $receiptDetail = $receipt->getOne ( array (
  1173. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  1174. 'asArray' => true
  1175. ) );
  1176. if (empty ( $receiptDetail ))
  1177. return "/saeaCreate";
  1178. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  1179. $acItem = $accountItem->find ( array (
  1180. 'asArray' => true
  1181. ) );
  1182. $veList = $verify->getVerifyBySubordinate('REMIT');
  1183. // 配置编辑信息
  1184. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1185. foreach ( $acItem as $key => $value ) {
  1186. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1187. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1188. $acItem [$key] ['price'] = $v ['price'];
  1189. }
  1190. }
  1191. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1192. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1193. $acItem [$key] ['price'] = $v ['price'];
  1194. }
  1195. }
  1196. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1197. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1198. $acItem [$key] ['price'] = $v ['price'];
  1199. }
  1200. }
  1201. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1202. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1203. $acItem [$key] ['price'] = $v ['price'];
  1204. }
  1205. }
  1206. }
  1207. $data ['category'] = $lCategory->find ( array (
  1208. 'asArray' => true
  1209. ) );
  1210. $data ['enclosurList'] = $enclosurList;
  1211. $data ['cSum'] = $accountItemList ['cSum'];
  1212. $data ['sum'] = $receiptDetail ['sum'];
  1213. $data ['receiptDetail'] = $receiptDetail;
  1214. $data ['veList'] = $veList;
  1215. $data ['acItem'] = $acItem;
  1216. $data ['memu'] = "receipt";
  1217. $data ['staff'] = $this->staff;
  1218. $data ['receiptMemu'] = 'saeaBorad';
  1219. $data ['verify'] = $receiptDetail ['verify'];
  1220. $data ['verifyId'] = $this->verifyId;
  1221. $data ['executeId'] = $this->executeId;
  1222. $data ['rid'] = $rid;
  1223. $data ['ridKey'] = $ridKey;
  1224. $this->render ( "/admin/remitEdit", $data );
  1225. }
  1226. function remitEdiDo() {
  1227. $agency = $this->get_args ( 'agency' );
  1228. $travel = $this->get_args ( 'travel' );
  1229. $train = $this->get_args ( 'train' );
  1230. $other = $this->get_args ( 'other' );
  1231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1232. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1233. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1234. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1235. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1236. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1237. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1238. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1239. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1240. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1241. Doo::loadClass ( 'XDeode' );
  1242. $XDeode = new XDeode ( 7 );
  1243. $rid = $XDeode->decode ( $ridKey );
  1244. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1245. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1246. header ( 'Content-Type:text/html;charset=utf-8' );
  1247. die ( '请填写联行号' );
  1248. }
  1249. Doo::loadModel ( 'receipt' );
  1250. Doo::loadModel ( 'receiptDetail' );
  1251. Doo::loadModel ( 'accountItem' );
  1252. $accountItem = new accountItem ();
  1253. $receipt = new receipt ();
  1254. Doo::loadModel ( 'enclosur' );
  1255. $enclosur = new enclosur ();
  1256. Doo::loadModel ( 'execute' );
  1257. $execute = new execute ();
  1258. $executeDetail = $execute->getOne ( array (
  1259. 'where' => 'mold="对公汇款执行人"',
  1260. 'asArray' => true
  1261. ) );
  1262. $receiptDetail = $receipt->getOne ( array (
  1263. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  1264. 'asArray' => true
  1265. ) );
  1266. if (empty ( $receiptDetail ))
  1267. return "/saeaBorad";
  1268. $aItem = $accountItem->find ( array (
  1269. 'where' => '(name like "办公费用" or name like "服务器费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保") and category like "'.$this->AGENCY.'"',
  1270. 'asArray' => true
  1271. ) );
  1272. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1273. $ag = $tr = $ta = $ot = 0;
  1274. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1275. foreach ( $aItem as $key => $value ) {
  1276. if ($value ['category'] == $this->AGENCY) {
  1277. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1278. array_push ( $accountJson [$this->AGENCY], array (
  1279. 'aid' => $value ['aid'],
  1280. 'name' => $value ['name'],
  1281. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1282. ) );
  1283. $sum += $agency [$ag];
  1284. $agencySum += $agency [$ag];
  1285. }
  1286. $ag ++;
  1287. }
  1288. }
  1289. $accountJson ['cSum'] = array (
  1290. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1291. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1292. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1293. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1294. );
  1295. // 报销单
  1296. $rid = $receipt->rid = $receiptDetail ['rid'];
  1297. $receipt->accountItem = json_encode ( $accountJson );
  1298. $receipt->staff = $this->staff [0] ['sid'];
  1299. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1300. $receipt->date = date ( "Y-m-d" );
  1301. $receipt->cid = $cid;
  1302. if ($receiptDetail ['Rtype'] == 1)
  1303. $receipt->status = 7;
  1304. else
  1305. $receipt->status = 5;
  1306. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  1307. $receipt->verify = $verify;
  1308. $receipt->executeCopy = $executeDetail ['staff'];
  1309. $order = array (
  1310. "\r\n",
  1311. "\n",
  1312. "\r"
  1313. );
  1314. $replace = '<br/>';
  1315. $explanation = str_replace ( $order, $replace, $explanation );
  1316. $receipt->explanation = $explanation;
  1317. $receipt->remittanceName = $remittanceName;
  1318. $receipt->bankName = $bankName;
  1319. $receipt->bankNumber = $bankNumber;
  1320. $receipt->remittanceBankType = $remittanceBankType;
  1321. if ($remittanceBankType == 1)
  1322. $receipt->coupletNumber = $coupletNumber;
  1323. $receipt->update ();
  1324. $receiptDetail = new receiptDetail ();
  1325. $receiptDetail->delete ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 报销详情
  1329. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1330. $receiptDetail = new receiptDetail ();
  1331. $receiptDetail->staff = $this->staff [0] ['sid'];
  1332. $receiptDetail->item = $value ['name'];
  1333. $receiptDetail->itemCategory = $this->AGENCY;
  1334. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1335. $receiptDetail->date = date ( "Y-m-d" );
  1336. $receiptDetail->cid = $cid;
  1337. $receiptDetail->rid = $rid;
  1338. $receiptDetail->status = 4;
  1339. $receiptDetail->insert ();
  1340. }
  1341. // 附件
  1342. if (! empty ( $enclosurName )) {
  1343. $enclosurArray = explode ( '-', $enclosurName );
  1344. foreach ( $enclosurArray as $value ) {
  1345. $enclosur = new enclosur ();
  1346. $enclosur->name = $value;
  1347. $enclosur->rid = $rid;
  1348. $enclosur->insert ();
  1349. }
  1350. }
  1351. }
  1352. return "/saeaBorad";
  1353. }
  1354. function remitApproval() {
  1355. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1356. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  1357. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  1358. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  1359. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1360. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  1361. if (empty ( $status ))
  1362. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  1363. $vidList = array ();
  1364. $button = 0;
  1365. Doo::loadModel ( 'verify' );
  1366. Doo::loadModel ( 'receipt' );
  1367. Doo::loadModel ( 'staff' );
  1368. $staff = new staff ();
  1369. $receipt = new receipt ();
  1370. $verify = new verify ();
  1371. Doo::loadModel ( 'L_category' );
  1372. $Lcategory = new L_category ();
  1373. Doo::loadModel ( 'enclosur' );
  1374. $enclosur = new enclosur ();
  1375. // user verify ID
  1376. $verifyDetail = $verify->find ( array (
  1377. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  1378. 'asArray' => true
  1379. ) );
  1380. foreach ( $verifyDetail as $key => $value ) {
  1381. array_push ( $vidList, $value ['vid'] );
  1382. }
  1383. $vid = implode ( ",", $vidList );
  1384. if (empty ( $verifyDetail ))
  1385. $vid = 0;
  1386. $categoryList = $Lcategory->find ( array (
  1387. 'asArray' => true
  1388. ) );
  1389. $staffList = $staff->find ( array (
  1390. 'where' => 'cid=' . $cid,
  1391. 'asArray' => true
  1392. ) );
  1393. $ap = "";
  1394. if ($status == 4) {
  1395. $ap = 4;
  1396. $status = 2;
  1397. }
  1398. // get Receipt By verifyID status 2
  1399. $receiptList = $receipt->find ( array (
  1400. 'where' => 'rid =' . $rid . ' and status=2',
  1401. 'desc' => 'rid',
  1402. 'asArray' => true
  1403. ) );
  1404. if (empty ( $receiptList )) {
  1405. die ( 'illegal request' );
  1406. }
  1407. $Locate = 0;
  1408. $roleId = 0;
  1409. if ($ap == 4)
  1410. $status = 4;
  1411. foreach ( $receiptList as $key => $value ) {
  1412. $receiptList [$key] ['Locate'] = $Locate;
  1413. $Locate ++;
  1414. $receiptList [$key] ['reviseDetail'] = array ();
  1415. if (! empty ( $value ['reviseDetail'] ))
  1416. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1417. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1418. $categoryDetil = $Lcategory->getOne ( array (
  1419. 'where' => 'cid=' . $value ['cid'],
  1420. 'asArray' => true
  1421. ) );
  1422. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1423. // 检测编辑状态
  1424. $verifyList = $verify->getOne ( array (
  1425. 'where' => 'vid=' . $value ['verify'],
  1426. 'asArray' => true
  1427. ) );
  1428. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1429. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1430. Doo::loadModel ( 'role' );
  1431. $role = new role ();
  1432. // print_r($verifyList);
  1433. $flag = true;
  1434. $roleKey = 0;
  1435. $endStaffArray = array ();
  1436. $roleArrayCopy = array ();
  1437. foreach ( $verifyList as $k => $v ) {
  1438. // init verifyStaff
  1439. if ($v [1] == 'ROLE') {
  1440. if (! empty ( $verifyStaff )) {
  1441. $endStaffArray = end ( $verifyStaff );
  1442. if ($v [0] == $endStaffArray ['nextStaff']) {
  1443. $roleId = $v [0];
  1444. }
  1445. }
  1446. $roleVerify = json_decode ( $v [3], true );
  1447. $roleKey = $k;
  1448. $roleArray = array ();
  1449. $rolename = $role->getOne ( array (
  1450. 'where' => 'rid=' . $v [0],
  1451. 'asArray' => true
  1452. ) );
  1453. foreach ( $roleVerify as $o => $p ) {
  1454. $staffID = explode ( '_', $p );
  1455. $staffInfo = $staff->getOne ( array (
  1456. 'where' => 'sid=' . $staffID [0],
  1457. 'asArray' => true
  1458. ) );
  1459. // print_r($staffID);
  1460. $exp = array (
  1461. 0 => $staffInfo ['sid'],
  1462. 1 => $staffID [1],
  1463. 2 => $staffInfo ['avatar'],
  1464. 'date' => '',
  1465. 'date' => '',
  1466. 'opinion' => '',
  1467. 'status' => '',
  1468. 'rolename' => $rolename ['name']
  1469. );
  1470. array_push ( $roleArray, $exp );
  1471. }
  1472. $roleArrayCopy [$v [0]] = $roleArray;
  1473. // $verifyList[$k]['roleArray']=$roleArray;
  1474. }
  1475. // print_r($roleArray);
  1476. $verifyList [$k] ['date'] = "";
  1477. $verifyList [$k] ['opinion'] = "";
  1478. $verifyList [$k] ['status'] = "";
  1479. if (empty ( $verifyStaff )) {
  1480. $verifyList [$k] ['date'] = "";
  1481. $verifyList [$k] ['opinion'] = "";
  1482. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1483. $verifyList [$k] ['status'] = 4;
  1484. $button = 4;
  1485. $flag = false;
  1486. }
  1487. } else {
  1488. foreach ( $verifyStaff as $m => $u ) {
  1489. if ($v [0] == $m) {
  1490. $verifyList [$k] ['date'] = $u ['date'];
  1491. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1492. $verifyList [$k] ['status'] = $u ['status'];
  1493. $flag = false;
  1494. break;
  1495. }
  1496. }
  1497. $endStaffArray = end ( $verifyStaff );
  1498. if (isset ( $endStaffArray ['ROLE'] )) {
  1499. } else {
  1500. $endKey = key ( $verifyStaff );
  1501. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  1502. $button = 4;
  1503. $verifyList [$k] ['status'] = 4;
  1504. }
  1505. }
  1506. }
  1507. }
  1508. $rolename ['name'] = '';
  1509. if (! empty ( $roleId )) {
  1510. Doo::loadModel ( 'role' );
  1511. $role = new role ();
  1512. $rolename = $role->getOne ( array (
  1513. 'where' => 'rid=' . $roleId,
  1514. 'asArray' => true
  1515. ) );
  1516. }
  1517. if (! empty ( $verifyStaff ))
  1518. $endStaffArray = end ( $verifyStaff );
  1519. $KOP = false;
  1520. foreach ( $roleArrayCopy as $P => $A ) {
  1521. foreach ( $A as $MKI => $AVL ) {
  1522. if (! empty ( $verifyStaff )) {
  1523. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1524. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1525. $button = 4;
  1526. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1527. }
  1528. foreach ( $verifyStaff as $m => $u ) {
  1529. $AVLFK = $AVL [0] . '_R';
  1530. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1531. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1532. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1533. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1534. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1535. break;
  1536. }
  1537. }
  1538. } else {
  1539. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1540. $button = 4;
  1541. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1542. }
  1543. }
  1544. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1545. $KOP = true;
  1546. }
  1547. }
  1548. foreach ( $roleArrayCopy as $k => $v ) {
  1549. foreach ( $verifyList as $m => $n ) {
  1550. if ($n [0] == $k) {
  1551. array_splice ( $verifyList, $m, 1, $v );
  1552. }
  1553. }
  1554. }
  1555. $receiptList [$key] ['verifyList'] = $verifyList;
  1556. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1557. 'where' => 'sid=' . $value ['staff'],
  1558. 'asArray' => true
  1559. ) );
  1560. $receiptList [$key] ['button'] = $button;
  1561. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1562. }
  1563. $mothHtml = "";
  1564. for($i = 1; $i <= 12; $i ++) {
  1565. if ($month == $i)
  1566. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1567. else
  1568. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1569. }
  1570. // 获取审批日志
  1571. Doo::loadModel ( 'receiptLog' );
  1572. $receiptLog = new receiptLog ();
  1573. $rlList = array ();
  1574. $rlInfo = $receiptLog->getOne ( array (
  1575. 'where' => 'rid=' . $rid . ' and status=4',
  1576. 'asArray' => true
  1577. ) );
  1578. $tijdate = $receiptLog->getOne ( array (
  1579. 'where' => 'rid=' . $rid . ' and status=2',
  1580. 'asc' => 'rlid',
  1581. 'asArray' => true
  1582. ) );
  1583. if (! empty ( $rlInfo )) {
  1584. $rlList = $receiptLog->find ( array (
  1585. 'where' => 'rid=' . $rid,
  1586. 'asc' => 'rlid',
  1587. 'asArray' => true
  1588. ) );
  1589. }
  1590. $receiptList [0] ['rlList'] = $rlList;
  1591. $enclosurList = $enclosur->find ( array (
  1592. 'where' => 'rid=' . $rid,
  1593. 'asArray' => true
  1594. ) );
  1595. $enclosurHtml = '';
  1596. foreach ( $enclosurList as $value ) {
  1597. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  1598. }
  1599. // print_r($receiptList);
  1600. $data ['enclosurHtml'] = $enclosurHtml;
  1601. $data ['rolename'] = $rolename ['name'];
  1602. $data ['datetij'] = $tijdate ['date'];
  1603. $data ['mothHtml'] = $mothHtml;
  1604. $data ['rid'] = $rid;
  1605. $data ['receiptList'] = $receiptList;
  1606. $data ['receiptApprovalCount'] = count ( $receiptList );
  1607. $data ['status'] = $status;
  1608. $data ['year'] = $year;
  1609. $data ['categoryList'] = $categoryList;
  1610. $data ['staffList'] = $staffList;
  1611. $data ['cid'] = $cid;
  1612. $data ['sid'] = $sid;
  1613. $data ['ap'] = $ap;
  1614. $data ['memu'] = "receipt";
  1615. $data ['staff'] = $this->staff;
  1616. $data ['receiptMemu'] = 'approvalExpenses';
  1617. $data ['verifyId'] = $this->verifyId;
  1618. $data ['executeId'] = $this->executeId;
  1619. $this->render ( "/admin/remitApproval", $data );
  1620. }
  1621. function saeaLoanAdd() {
  1622. Doo::loadModel ( 'verify' );
  1623. $verify = new verify ();
  1624. Doo::loadModel ( "role" );
  1625. $role = new role ();
  1626. Doo::loadModel ( 'L_category' );
  1627. $lCategory = new L_category ();
  1628. $veList = $verify->getVerifyBySubordinate('LOAN');
  1629. $data ['category'] = $lCategory->find ( array (
  1630. 'asArray' => true
  1631. ) );
  1632. $data ['veList'] = $veList;
  1633. $data ['memu'] = "receipt";
  1634. $data ['staff'] = $this->staff;
  1635. $data ['receiptMemu'] = 'saeaBorad';
  1636. $data ['verifyId'] = $this->verifyId;
  1637. $data ['executeId'] = $this->executeId;
  1638. $this->render ( "/admin/saeaLoanAdd", $data );
  1639. }
  1640. function saeaLoanAddDo() {
  1641. $agency = $this->get_args ( 'agency' );
  1642. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1643. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1644. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1645. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1646. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1647. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1648. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1649. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1650. // die;
  1651. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1652. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1653. header ( 'Content-Type:text/html;charset=utf-8' );
  1654. die ( '请填写联行号' );
  1655. }
  1656. Doo::loadModel ( 'receipt' );
  1657. Doo::loadModel ( 'receiptDetail' );
  1658. Doo::loadModel ( 'accountItem' );
  1659. $accountItem = new accountItem ();
  1660. $receipt = new receipt ();
  1661. Doo::loadModel ( 'loanReceipt' );
  1662. $loanReceipt = new loanReceipt ();
  1663. Doo::loadModel ( 'execute' );
  1664. $execute = new execute ();
  1665. Doo::loadModel ( 'enclosur' );
  1666. $executeDetail = $execute->getOne ( array (
  1667. 'where' => 'mold="借款执行人"',
  1668. 'asArray' => true
  1669. ) );
  1670. $aItem = $accountItem->find ( array (
  1671. 'asArray' => true
  1672. ) );
  1673. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1674. $ag = $tr = $ta = $ot = 0;
  1675. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1676. array_push ( $accountJson ['借款费用'], array (
  1677. 'aid' => 0,
  1678. 'name' => '申请金额',
  1679. 'price' => number_format ( $agency, 2, '.', '' )
  1680. ) );
  1681. $sum += $agency;
  1682. $agencySum += $agency;
  1683. $accountJson ['cSum'] = array (
  1684. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1685. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1686. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1687. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1688. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1689. );
  1690. // 借款数据备份
  1691. $loanReceipt->loanItem = json_encode ( $accountJson );
  1692. $loanReceipt->staff = $this->staff [0] ['sid'];
  1693. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1694. $loanReceipt->date = date ( "Y-m-d" );
  1695. $loanReceipt->cid = $cid;
  1696. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1697. $loanReceipt->status = 5;
  1698. $loanReceipt->Rtype = 1;
  1699. $loanReceipt->verify = $verify;
  1700. $receipt->receiptOrder = $receipt->receiptOrder;
  1701. // 添加HTML换行符
  1702. // var_dump($explanation);
  1703. $order = array (
  1704. "\r\n",
  1705. "\n",
  1706. "\r"
  1707. );
  1708. $replace = '<br/>';
  1709. $explanation = str_replace ( $order, $replace, $explanation );
  1710. // $explanation=str_replace('\r',"<br/>",$explanation);
  1711. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  1712. $loanReceipt->explanation = $explanation;
  1713. $loanRid = $loanReceipt->insert ();
  1714. // 报销单
  1715. $receipt->loanItem = json_encode ( $accountJson );
  1716. $receipt->staff = $this->staff [0] ['sid'];
  1717. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1718. $receipt->date = date ( "Y-m-d" );
  1719. $receipt->cid = $cid;
  1720. // 特殊状态
  1721. $receipt->status = 5;
  1722. $receipt->Rtype = 1;
  1723. $receipt->loanRid = $loanRid;
  1724. // 修改审批流程加入角色
  1725. $receipt->verify = $verify;
  1726. $receipt->executeCopy = $executeDetail ['staff'];
  1727. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  1728. $receipt->explanation = $explanation;
  1729. $receipt->remittanceName = $remittanceName;
  1730. $receipt->bankName = $bankName;
  1731. $receipt->bankNumber = $bankNumber;
  1732. $receipt->remittanceBankType = $remittanceBankType;
  1733. if ($remittanceBankType == 1)
  1734. $receipt->coupletNumber = $coupletNumber;
  1735. $rid = $receipt->insert ();
  1736. return "/saeaBorad";
  1737. } else
  1738. die ( 'illegal request' );
  1739. }
  1740. function saeaLoanEdi() {
  1741. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1742. Doo::loadClass ( 'XDeode' );
  1743. $XDeode = new XDeode ( 7 );
  1744. $rid = $XDeode->decode ( $ridKey );
  1745. if (! is_numeric ( $rid ))
  1746. die ( 'illegal request' );
  1747. Doo::loadModel ( 'verify' );
  1748. $verify = new verify ();
  1749. Doo::loadModel ( "role" );
  1750. $role = new role ();
  1751. Doo::loadModel ( 'L_category' );
  1752. $lCategory = new L_category ();
  1753. Doo::loadModel ( 'receipt' );
  1754. $receipt = new receipt ();
  1755. $receiptInfo = $receipt->getOne ( array (
  1756. 'where' => 'rid=' . $rid,
  1757. 'asArray' => true
  1758. ) );
  1759. $veList = $verify->find ( array (
  1760. 'where'=>'subordinate like "%LOAN%"',
  1761. 'asArray' => true
  1762. ) );
  1763. foreach ( $veList as $key => $value ) {
  1764. $v = json_decode ( $value ['staff'] );
  1765. $list = array ();
  1766. foreach ( $v as $n => $m ) {
  1767. if ($m ['1'] == 'ROLE') {
  1768. $roleInfo = $role->getOne ( array (
  1769. 'where' => 'rid=' . $m [0],
  1770. 'asArray' => true
  1771. ) );
  1772. $v [$n] [1] = $roleInfo ['name'];
  1773. array_push ( $list, $roleInfo ['name'] );
  1774. } else {
  1775. array_push ( $list, $v [$n] [1] );
  1776. }
  1777. }
  1778. $veList [$key] ['staff'] = implode ( '>', $list );
  1779. }
  1780. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1781. // print_r($receiptInfo);
  1782. $data ['receiptInfo'] = $receiptInfo;
  1783. $data ['category'] = $lCategory->find ( array (
  1784. 'asArray' => true
  1785. ) );
  1786. $data ['veList'] = $veList;
  1787. $data ['ridKey'] = $ridKey;
  1788. $data ['memu'] = "receipt";
  1789. $data ['staff'] = $this->staff;
  1790. $data ['receiptMemu'] = 'saeaBorad';
  1791. $data ['verifyId'] = $this->verifyId;
  1792. $data ['executeId'] = $this->executeId;
  1793. $this->render ( "/admin/saeaLoanEdi", $data );
  1794. }
  1795. function saeaLoanEdiDo() {
  1796. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1797. $agency = $this->get_args ( 'agency' );
  1798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1801. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1802. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1803. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1804. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1805. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1806. // die;
  1807. Doo::loadClass ( 'XDeode' );
  1808. $XDeode = new XDeode ( 7 );
  1809. $rid = $XDeode->decode ( $ridKey );
  1810. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1811. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1812. header ( 'Content-Type:text/html;charset=utf-8' );
  1813. die ( '请填写联行号' );
  1814. }
  1815. Doo::loadModel ( 'receipt' );
  1816. Doo::loadModel ( 'receiptDetail' );
  1817. Doo::loadModel ( 'accountItem' );
  1818. $accountItem = new accountItem ();
  1819. $receipt = new receipt ();
  1820. Doo::loadModel ( 'loanReceipt' );
  1821. $loanReceipt = new loanReceipt ();
  1822. Doo::loadModel ( 'enclosur' );
  1823. Doo::loadModel ( 'execute' );
  1824. $execute = new execute ();
  1825. $executeDetail = $execute->getOne ( array (
  1826. 'where' => 'mold="借款执行人"',
  1827. 'asArray' => true
  1828. ) );
  1829. $receiptDetail = $receipt->getOne ( array (
  1830. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1831. 'asArray' => true
  1832. ) );
  1833. if (empty ( $receiptDetail ))
  1834. die ( '参数错误' );
  1835. $aItem = $accountItem->find ( array (
  1836. 'asArray' => true
  1837. ) );
  1838. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1839. $ag = $tr = $ta = $ot = 0;
  1840. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1841. array_push ( $accountJson ['借款费用'], array (
  1842. 'aid' => 0,
  1843. 'name' => '申请金额',
  1844. 'price' => number_format ( $agency, 2, '.', '' )
  1845. ) );
  1846. $sum += $agency;
  1847. $agencySum += $agency;
  1848. $accountJson ['cSum'] = array (
  1849. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1850. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1851. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1852. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1853. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1854. );
  1855. // 报销单
  1856. $receipt->loanItem = json_encode ( $accountJson );
  1857. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1858. $receipt->cid = $cid;
  1859. // 特殊状态
  1860. // 修改审批流程加入角色
  1861. if ($receiptDetail ['status'] != 4)
  1862. $receipt->verify = $verify;
  1863. $order = array (
  1864. "\r\n",
  1865. "\n",
  1866. "\r"
  1867. );
  1868. $replace = '<br/>';
  1869. $explanation = str_replace ( $order, $replace, $explanation );
  1870. $receipt->explanation = $explanation;
  1871. $receipt->remittanceName = $remittanceName;
  1872. $receipt->bankName = $bankName;
  1873. $receipt->bankNumber = $bankNumber;
  1874. $receipt->remittanceBankType = $remittanceBankType;
  1875. if ($remittanceBankType == 1)
  1876. $receipt->coupletNumber = $coupletNumber;
  1877. $receipt->update ( array (
  1878. 'where' => 'rid=' . $rid
  1879. ) );
  1880. // 借款数据更新
  1881. $loanReceipt->loanItem = json_encode ( $accountJson );
  1882. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1883. $loanReceipt->cid = $cid;
  1884. if ($receiptDetail ['status'] != 4)
  1885. $loanReceipt->verify = $verify;
  1886. $loanReceipt->explanation = $explanation;
  1887. $receipt->executeCopy = $executeDetail ['staff'];
  1888. $loanReceipt->update ( array (
  1889. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1890. ) );
  1891. }
  1892. return "/saeaBorad";
  1893. }
  1894. function saeaLoanReceiptAdd() {
  1895. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1896. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  1897. Doo::loadModel ( 'receipt' );
  1898. $receipt = new receipt ();
  1899. Doo::loadModel ( 'loanReceipt' );
  1900. $loanReceipt = new loanReceipt ();
  1901. Doo::loadModel ( 'L_category' );
  1902. $Lcategory = new L_category ();
  1903. Doo::loadModel ( 'verify' );
  1904. Doo::loadModel ( 'statistics' );
  1905. $statistics = new statistics ();
  1906. $verify = new verify ();
  1907. Doo::loadModel ( 'staff' );
  1908. $staff = new staff ();
  1909. $receiptDetail = $receipt->getOne ( array (
  1910. 'where' => 'rid=' . $rid,
  1911. 'desc' => 'rid',
  1912. 'asArray' => true
  1913. ) );
  1914. $receiptList = $loanReceipt->find ( array (
  1915. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1916. 'desc' => 'rid',
  1917. 'asArray' => true
  1918. ) );
  1919. $Locate = 0;
  1920. $roleId = 0;
  1921. $button = 0;
  1922. foreach ( $receiptList as $key => $value ) {
  1923. $receiptList [$key] ['Locate'] = $Locate;
  1924. $Locate ++;
  1925. $receiptList [$key] ['reviseDetail'] = array ();
  1926. if (! empty ( $value ['reviseDetail'] ))
  1927. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1928. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1929. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1930. $categoryDetil = $Lcategory->getOne ( array (
  1931. 'where' => 'cid=' . $value ['cid'],
  1932. 'asArray' => true
  1933. ) );
  1934. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1935. // 检测编辑状态
  1936. $verifyList = $verify->getOne ( array (
  1937. 'where' => 'vid=' . $value ['verify'],
  1938. 'asArray' => true
  1939. ) );
  1940. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1941. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1942. Doo::loadModel ( 'role' );
  1943. $role = new role ();
  1944. $flag = true;
  1945. $roleKey = 0;
  1946. $endStaffArray = array ();
  1947. $roleArrayCopy = array ();
  1948. foreach ( $verifyList as $k => $v ) {
  1949. // init verifyStaff
  1950. if ($v [1] == 'ROLE') {
  1951. if (! empty ( $verifyStaff )) {
  1952. $endStaffArray = end ( $verifyStaff );
  1953. // if ($v[0]==$endStaffArray['nextStaff']){
  1954. // $roleId=$v[0];
  1955. // }
  1956. }
  1957. $roleVerify = json_decode ( $v [3], true );
  1958. $roleKey = $k;
  1959. $roleArray = array ();
  1960. $rolename = $role->getOne ( array (
  1961. 'where' => 'rid=' . $v [0],
  1962. 'asArray' => true
  1963. ) );
  1964. foreach ( $roleVerify as $o => $p ) {
  1965. $staffID = explode ( '_', $p );
  1966. $staffInfo = $staff->getOne ( array (
  1967. 'where' => 'sid=' . $staffID [0],
  1968. 'asArray' => true
  1969. ) );
  1970. // print_r($staffID);
  1971. $exp = array (
  1972. 0 => $staffInfo ['sid'],
  1973. 1 => $staffID [1],
  1974. 2 => $staffInfo ['avatar'],
  1975. 'date' => '',
  1976. 'date' => '',
  1977. 'opinion' => '',
  1978. 'status' => '',
  1979. 'rolename' => $rolename ['name']
  1980. );
  1981. array_push ( $roleArray, $exp );
  1982. }
  1983. $roleArrayCopy [$v [0]] = $roleArray;
  1984. // $verifyList[$k]['roleArray']=$roleArray;
  1985. }
  1986. $verifyList [$k] ['date'] = "";
  1987. $verifyList [$k] ['opinion'] = "";
  1988. $verifyList [$k] ['status'] = "";
  1989. if (empty ( $verifyStaff )) {
  1990. $verifyList [$k] ['date'] = "";
  1991. $verifyList [$k] ['opinion'] = "";
  1992. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1993. $verifyList [$k] ['status'] = 4;
  1994. $flag = false;
  1995. }
  1996. } else {
  1997. foreach ( $verifyStaff as $m => $u ) {
  1998. if ($v [0] == $m) {
  1999. $verifyList [$k] ['date'] = $u ['date'];
  2000. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2001. $verifyList [$k] ['status'] = $u ['status'];
  2002. $flag = false;
  2003. break;
  2004. }
  2005. }
  2006. $endStaffArray = end ( $verifyStaff );
  2007. if (isset ( $endStaffArray ['ROLE'] )) {
  2008. } else {
  2009. // $endKey=key($verifyStaff);
  2010. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2011. // $button=4;
  2012. // $verifyList[$k]['status']=4;
  2013. // }
  2014. }
  2015. }
  2016. }
  2017. $rolename ['name'] = '';
  2018. if (! empty ( $roleId )) {
  2019. Doo::loadModel ( 'role' );
  2020. $role = new role ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $roleId,
  2023. 'asArray' => true
  2024. ) );
  2025. }
  2026. if (! empty ( $verifyStaff ))
  2027. $endStaffArray = end ( $verifyStaff );
  2028. $KOP = false;
  2029. foreach ( $roleArrayCopy as $P => $A ) {
  2030. foreach ( $A as $MKI => $AVL ) {
  2031. if (! empty ( $verifyStaff )) {
  2032. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2033. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2034. $button = 4;
  2035. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2036. }
  2037. foreach ( $verifyStaff as $m => $u ) {
  2038. $AVLFK = $AVL [0] . '_R';
  2039. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2040. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2041. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2042. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2043. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2044. break;
  2045. }
  2046. }
  2047. } else {
  2048. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2049. $button = 4;
  2050. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2051. }
  2052. }
  2053. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2054. $KOP = true;
  2055. }
  2056. }
  2057. foreach ( $roleArrayCopy as $k => $v ) {
  2058. foreach ( $verifyList as $m => $n ) {
  2059. if ($n [0] == $k) {
  2060. array_splice ( $verifyList, $m, 1, $v );
  2061. }
  2062. }
  2063. }
  2064. $receiptList [$key] ['verifyList'] = $verifyList;
  2065. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2066. 'where' => 'sid=' . $value ['staff'],
  2067. 'asArray' => true
  2068. ) );
  2069. $receiptList [$key] ['button'] = $button;
  2070. //
  2071. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2072. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2073. }
  2074. $data ['receiptList'] = $receiptList;
  2075. $data ['receiptDetail'] = $receiptDetail;
  2076. Doo::loadModel ( 'L_category' );
  2077. $lCategory = new L_category ();
  2078. Doo::loadModel ( 'accountItem' );
  2079. $accountItem = new accountItem ();
  2080. $acItem = $accountItem->find ( array (
  2081. 'asArray' => true
  2082. ) );
  2083. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  2084. $data ['rid'] = $rid;
  2085. $data ['category'] = $lCategory->find ( array (
  2086. 'asArray' => true
  2087. ) );
  2088. $data ['veList'] = $veList;
  2089. $data ['acItem'] = $acItem;
  2090. $data ['memu'] = "receipt";
  2091. $data ['staff'] = $this->staff;
  2092. $data ['receiptMemu'] = 'saeaBorad';
  2093. $data ['verifyId'] = $this->verifyId;
  2094. $data ['executeId'] = $this->executeId;
  2095. $data['receiptClass']=$receiptClass;
  2096. if($receiptClass=='trave'){
  2097. $this->render ( "/receipt/feeLoanReceiptTrave", $data );
  2098. }else{
  2099. $this->render ( "/receipt/feeLoanReceipt", $data );
  2100. }
  2101. }
  2102. function saeaLoanReceiptAddDo() {
  2103. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  2104. $agency = $this->get_args ( 'agency' );
  2105. $travel = $this->get_args ( 'travel' );
  2106. $train = $this->get_args ( 'train' );
  2107. $other = $this->get_args ( 'other' );
  2108. $inttrain = $this->get_args ( 'inttrain' );
  2109. $itinerary = $this->get_args ( 'itinerary' ) ? $this->get_args ( 'itinerary' ) : "";
  2110. $receiptClass = $this->get_args ( 'receiptClass' ) ? $this->get_args ( 'receiptClass' ) : "";
  2111. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2112. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  2113. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  2114. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  2115. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2116. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2117. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2118. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2119. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2120. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  2121. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2122. header ( 'Content-Type:text/html;charset=utf-8' );
  2123. die ( '请填写联行号' );
  2124. }
  2125. if($receiptClass=='agency'){
  2126. $receiptClass=1;
  2127. }elseif($receiptClass=='trave'){
  2128. $receiptClass=2;
  2129. if($this->_verificationItinerary($itinerary)){
  2130. header ( 'Content-Type:text/html;charset=utf-8' );
  2131. die ( '已申请过类此日期的行程' );
  2132. }
  2133. }elseif($receiptClass=='internalTrain'){
  2134. $receiptClass=3;
  2135. }else{
  2136. header ( 'Content-Type:text/html;charset=utf-8' );
  2137. die ( '借款报销单分类不正确' );
  2138. }
  2139. Doo::loadModel ( 'receipt' );
  2140. Doo::loadModel ( 'receiptDetail' );
  2141. Doo::loadModel ( 'accountItem' );
  2142. $accountItem = new accountItem ();
  2143. $receipt = new receipt ();
  2144. Doo::loadModel ( 'enclosur' );
  2145. Doo::loadModel ( 'execute' );
  2146. $execute = new execute ();
  2147. $executeDetail = $execute->getOne ( array (
  2148. 'where' => 'mold="借款费用执行人"',
  2149. 'asArray' => true
  2150. ) );
  2151. $receiptDet = $receipt->getOne ( array (
  2152. 'where' => 'rid=' . $rid,
  2153. 'asArray' => true
  2154. ) );
  2155. // if(!empty($receiptDetail))
  2156. // return "/referReceipt/".$receiptDetail['rid'];
  2157. $aItem = $accountItem->find ( array (
  2158. 'asArray' => true
  2159. ) );
  2160. $accountJson [$this->AGENCY]=$accountJson [$this->INTTRAIN] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2161. $ag = $tr = $ta = $ot =$it = 0;
  2162. $sum = $agencySum = $travelSum = $trainSum =$inttrainSum= $otherSum = 0;
  2163. foreach ( $aItem as $key => $value ) {
  2164. if ($value ['category'] == $this->AGENCY) {
  2165. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  2166. array_push ( $accountJson [$this->AGENCY], array (
  2167. 'aid' => $value ['aid'],
  2168. 'name' => $value ['name'],
  2169. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  2170. ) );
  2171. $sum += $agency [$ag];
  2172. $agencySum += $agency [$ag];
  2173. }
  2174. $ag ++;
  2175. }
  2176. if ($value ['category'] == $this->TRAVEL) {
  2177. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  2178. array_push ( $accountJson [$this->TRAVEL], array (
  2179. 'aid' => $value ['aid'],
  2180. 'name' => $value ['name'],
  2181. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  2182. ) );
  2183. $sum += $travel [$tr];
  2184. $travelSum += $travel [$tr];
  2185. }
  2186. $tr ++;
  2187. }
  2188. if ($value ['category'] == $this->INTTRAIN) {
  2189. if (is_numeric ( $inttrain [$it] ) && $inttrain [$it] != 0) {
  2190. array_push ( $accountJson [$this->INTTRAIN], array (
  2191. 'aid' => $value ['aid'],
  2192. 'name' => $value ['name'],
  2193. 'price' => number_format ( $inttrain [$it], 2, '.', '' )
  2194. ) );
  2195. $sum += $inttrain [$it];
  2196. $inttrainSum += $inttrain [$it];
  2197. }
  2198. $it ++;
  2199. }
  2200. if ($value ['category'] == $this->TRAIN) {
  2201. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  2202. array_push ( $accountJson [$this->TRAIN], array (
  2203. 'aid' => $value ['aid'],
  2204. 'name' => $value ['name'],
  2205. 'price' => number_format ( $train [$ta], 2, '.', '' )
  2206. ) );
  2207. $sum += $train [$ta];
  2208. $trainSum += $train [$ta];
  2209. }
  2210. $ta ++;
  2211. }
  2212. if ($value ['category'] == $this->OTHER) {
  2213. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  2214. array_push ( $accountJson [$this->OTHER], array (
  2215. 'aid' => $value ['aid'],
  2216. 'name' => $value ['name'],
  2217. 'price' => number_format ( $other [$ot], 2, '.', '' )
  2218. ) );
  2219. $sum += $other [$ot];
  2220. $otherSum += $other [$ot];
  2221. }
  2222. $ot ++;
  2223. }
  2224. }
  2225. $accountJson ['cSum'] = array (
  2226. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2227. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2228. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2229. 'inttrainSum'=>number_format ( $inttrainSum, 2, '.', '' ),
  2230. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2231. );
  2232. // 报销单
  2233. $receipt->accountItem = json_encode ( $accountJson );
  2234. $receipt->staff = $this->staff [0] ['sid'];
  2235. $receipt->loanSum = $receiptDet ['sum'];
  2236. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2237. $receipt->date = date ( "Y-m-d" );
  2238. $receipt->pastDate = '0000-00-00';
  2239. $receipt->cid = $cid;
  2240. $receipt->status = 7;
  2241. $receipt->receiptClass=$receiptClass;
  2242. if($receiptClass==2){
  2243. $receipt->itinerary=$itinerary;
  2244. $this->_storageItinerary($itinerary, $rid);
  2245. }
  2246. // 修改审批流程加入角色
  2247. $receipt->verify = $verify;
  2248. $receipt->verifyStaff = '';
  2249. $receipt->executeStaff = '';
  2250. $receipt->executeCopy = $executeDetail ['staff'];
  2251. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  2252. $receipt->explanation = $explanation;
  2253. $receipt->remittanceName = $remittanceName;
  2254. $receipt->bankName = $bankName;
  2255. $receipt->bankNumber = $bankNumber;
  2256. $receipt->remittanceBankType = $remittanceBankType;
  2257. if ($remittanceBankType == 1)
  2258. $receipt->coupletNumber = $coupletNumber;
  2259. $receipt->update ( array (
  2260. 'where' => 'rid=' . $rid
  2261. ) );
  2262. // 附件
  2263. if (! empty ( $enclosurName )) {
  2264. $enclosurArray = explode ( '-', $enclosurName );
  2265. foreach ( $enclosurArray as $value ) {
  2266. $enclosur = new enclosur ();
  2267. $enclosur->name = $value;
  2268. $enclosur->rid = $rid;
  2269. $enclosur->insert ();
  2270. }
  2271. // print_r($enclosurArray);die;
  2272. }
  2273. // 报销详情
  2274. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  2275. $receiptDetail = new receiptDetail ();
  2276. $receiptDetail->staff = $this->staff [0] ['sid'];
  2277. $receiptDetail->item = $value ['name'];
  2278. $receiptDetail->itemCategory = $this->AGENCY;
  2279. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2280. $receiptDetail->date = date ( "Y-m-d" );
  2281. $receiptDetail->cid = $cid;
  2282. $receiptDetail->rid = $rid;
  2283. $receiptDetail->status = 4;
  2284. $receiptDetail->insert ();
  2285. }
  2286. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  2287. $receiptDetail = new receiptDetail ();
  2288. $receiptDetail->staff = $this->staff [0] ['sid'];
  2289. $receiptDetail->item = $value ['name'];
  2290. $receiptDetail->itemCategory = $this->TRAVEL;
  2291. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2292. $receiptDetail->date = date ( "Y-m-d" );
  2293. $receiptDetail->cid = $cid;
  2294. $receiptDetail->rid = $rid;
  2295. $receiptDetail->status = 4;
  2296. $receiptDetail->insert ();
  2297. }
  2298. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  2299. $receiptDetail = new receiptDetail ();
  2300. $receiptDetail->staff = $this->staff [0] ['sid'];
  2301. $receiptDetail->item = $value ['name'];
  2302. $receiptDetail->itemCategory = $this->TRAIN;
  2303. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2304. $receiptDetail->date = date ( "Y-m-d" );
  2305. $receiptDetail->cid = $cid;
  2306. $receiptDetail->rid = $rid;
  2307. $receiptDetail->status = 4;
  2308. $receiptDetail->insert ();
  2309. }
  2310. //内训
  2311. foreach ( $accountJson [$this->INTTRAIN] as $key => $value ) {
  2312. $receiptDetail = new receiptDetail ();
  2313. $receiptDetail->staff = $this->staff [0] ['sid'];
  2314. $receiptDetail->item = $value ['name'];
  2315. $receiptDetail->itemCategory = $this->INTTRAIN;
  2316. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2317. $receiptDetail->date = date ( "Y-m-d" );
  2318. $receiptDetail->cid = $cid;
  2319. $receiptDetail->rid = $rid;
  2320. $receiptDetail->status = 4;
  2321. $receiptDetail->insert ();
  2322. }
  2323. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  2324. $receiptDetail = new receiptDetail ();
  2325. $receiptDetail->staff = $this->staff [0] ['sid'];
  2326. $receiptDetail->item = $value ['name'];
  2327. $receiptDetail->itemCategory = $this->OTHER;
  2328. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  2329. $receiptDetail->date = date ( "Y-m-d" );
  2330. $receiptDetail->cid = $cid;
  2331. $receiptDetail->rid = $rid;
  2332. $receiptDetail->status = 4;
  2333. $receiptDetail->insert ();
  2334. }
  2335. return "/saeaBorad";
  2336. }
  2337. return "/saeaLoanReceiptAdd/" . $rid;
  2338. }
  2339. function saeaLoanReceiptEdi() {
  2340. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2341. Doo::loadClass ( 'XDeode' );
  2342. $XDeode = new XDeode ( 7 );
  2343. $rid = $XDeode->decode ( $ridKey );
  2344. if (! is_numeric ( $rid ))
  2345. die ( 'illegal request' );
  2346. Doo::loadModel ( 'accountItem' );
  2347. Doo::loadModel ( 'verify' );
  2348. Doo::loadModel ( 'receipt' );
  2349. $receipt = new receipt ();
  2350. $verify = new verify ();
  2351. $accountItem = new accountItem ();
  2352. Doo::loadModel ( 'L_category' );
  2353. $Lcategory = new L_category ();
  2354. Doo::loadModel ( "role" );
  2355. $role = new role ();
  2356. Doo::loadModel ( 'loanReceipt' );
  2357. $loanReceipt = new loanReceipt ();
  2358. Doo::loadModel ( 'staff' );
  2359. $staff = new staff ();
  2360. $receiptDetail = $receipt->getOne ( array (
  2361. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  2362. 'asArray' => true
  2363. ) );
  2364. if (empty ( $receiptDetail ))
  2365. return "/saeaBorad";
  2366. $receiptList = $loanReceipt->find ( array (
  2367. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  2368. 'desc' => 'rid',
  2369. 'asArray' => true
  2370. ) );
  2371. $Locate = 0;
  2372. $roleId = 0;
  2373. $button = 0;
  2374. foreach ( $receiptList as $key => $value ) {
  2375. $receiptList [$key] ['Locate'] = $Locate;
  2376. $Locate ++;
  2377. $receiptList [$key] ['reviseDetail'] = array ();
  2378. if (! empty ( $value ['reviseDetail'] ))
  2379. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2380. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2381. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2382. $categoryDetil = $Lcategory->getOne ( array (
  2383. 'where' => 'cid=' . $value ['cid'],
  2384. 'asArray' => true
  2385. ) );
  2386. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2387. // 检测编辑状态
  2388. $verifyList = $verify->getOne ( array (
  2389. 'where' => 'vid=' . $value ['verify'],
  2390. 'asArray' => true
  2391. ) );
  2392. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2393. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2394. Doo::loadModel ( 'role' );
  2395. $role = new role ();
  2396. $flag = true;
  2397. $roleKey = 0;
  2398. $endStaffArray = array ();
  2399. $roleArrayCopy = array ();
  2400. foreach ( $verifyList as $k => $v ) {
  2401. // init verifyStaff
  2402. if ($v [1] == 'ROLE') {
  2403. if (! empty ( $verifyStaff )) {
  2404. $endStaffArray = end ( $verifyStaff );
  2405. // if ($v[0]==$endStaffArray['nextStaff']){
  2406. // $roleId=$v[0];
  2407. // }
  2408. }
  2409. $roleVerify = json_decode ( $v [3], true );
  2410. $roleKey = $k;
  2411. $roleArray = array ();
  2412. $rolename = $role->getOne ( array (
  2413. 'where' => 'rid=' . $v [0],
  2414. 'asArray' => true
  2415. ) );
  2416. foreach ( $roleVerify as $o => $p ) {
  2417. $staffID = explode ( '_', $p );
  2418. $staffInfo = $staff->getOne ( array (
  2419. 'where' => 'sid=' . $staffID [0],
  2420. 'asArray' => true
  2421. ) );
  2422. // print_r($staffID);
  2423. $exp = array (
  2424. 0 => $staffInfo ['sid'],
  2425. 1 => $staffID [1],
  2426. 2 => $staffInfo ['avatar'],
  2427. 'date' => '',
  2428. 'date' => '',
  2429. 'opinion' => '',
  2430. 'status' => '',
  2431. 'rolename' => $rolename ['name']
  2432. );
  2433. array_push ( $roleArray, $exp );
  2434. }
  2435. $roleArrayCopy [$v [0]] = $roleArray;
  2436. // $verifyList[$k]['roleArray']=$roleArray;
  2437. }
  2438. $verifyList [$k] ['date'] = "";
  2439. $verifyList [$k] ['opinion'] = "";
  2440. $verifyList [$k] ['status'] = "";
  2441. if (empty ( $verifyStaff )) {
  2442. $verifyList [$k] ['date'] = "";
  2443. $verifyList [$k] ['opinion'] = "";
  2444. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2445. $verifyList [$k] ['status'] = 4;
  2446. $flag = false;
  2447. }
  2448. } else {
  2449. foreach ( $verifyStaff as $m => $u ) {
  2450. if ($v [0] == $m) {
  2451. $verifyList [$k] ['date'] = $u ['date'];
  2452. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2453. $verifyList [$k] ['status'] = $u ['status'];
  2454. $flag = false;
  2455. break;
  2456. }
  2457. }
  2458. $endStaffArray = end ( $verifyStaff );
  2459. if (isset ( $endStaffArray ['ROLE'] )) {
  2460. } else {
  2461. // $endKey=key($verifyStaff);
  2462. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2463. // $button=4;
  2464. // $verifyList[$k]['status']=4;
  2465. // }
  2466. }
  2467. }
  2468. }
  2469. $rolename ['name'] = '';
  2470. if (! empty ( $roleId )) {
  2471. Doo::loadModel ( 'role' );
  2472. $role = new role ();
  2473. $rolename = $role->getOne ( array (
  2474. 'where' => 'rid=' . $roleId,
  2475. 'asArray' => true
  2476. ) );
  2477. }
  2478. if (! empty ( $verifyStaff ))
  2479. $endStaffArray = end ( $verifyStaff );
  2480. $KOP = false;
  2481. foreach ( $roleArrayCopy as $P => $A ) {
  2482. foreach ( $A as $MKI => $AVL ) {
  2483. if (! empty ( $verifyStaff )) {
  2484. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2485. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2486. $button = 4;
  2487. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2488. }
  2489. foreach ( $verifyStaff as $m => $u ) {
  2490. $AVLFK = $AVL [0] . '_R';
  2491. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2492. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2493. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2494. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2495. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2496. break;
  2497. }
  2498. }
  2499. } else {
  2500. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2501. $button = 4;
  2502. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2503. }
  2504. }
  2505. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2506. $KOP = true;
  2507. }
  2508. }
  2509. foreach ( $roleArrayCopy as $k => $v ) {
  2510. foreach ( $verifyList as $m => $n ) {
  2511. if ($n [0] == $k) {
  2512. array_splice ( $verifyList, $m, 1, $v );
  2513. }
  2514. }
  2515. }
  2516. $receiptList [$key] ['verifyList'] = $verifyList;
  2517. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2518. 'where' => 'sid=' . $value ['staff'],
  2519. 'asArray' => true
  2520. ) );
  2521. $receiptList [$key] ['button'] = $button;
  2522. //
  2523. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  2524. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2525. }
  2526. $data ['receiptList'] = $receiptList;
  2527. $acItem = $accountItem->find ( array (
  2528. 'asArray' => true
  2529. ) );
  2530. $veList = $verify->find ( array (
  2531. 'asArray' => true
  2532. ) );
  2533. foreach ( $veList as $key => $value ) {
  2534. $v = json_decode ( $value ['staff'] );
  2535. $list = array ();
  2536. foreach ( $v as $n => $m ) {
  2537. if ($m ['1'] == 'ROLE') {
  2538. $roleInfo = $role->getOne ( array (
  2539. 'where' => 'rid=' . $m [0],
  2540. 'asArray' => true
  2541. ) );
  2542. $v [$n] [1] = $roleInfo ['name'];
  2543. array_push ( $list, $roleInfo ['name'] );
  2544. } else {
  2545. array_push ( $list, $v [$n] [1] );
  2546. }
  2547. }
  2548. $veList [$key] ['staff'] = implode ( '>', $list );
  2549. }
  2550. // 配置编辑信息
  2551. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  2552. foreach ( $acItem as $key => $value ) {
  2553. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  2554. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  2555. $acItem [$key] ['price'] = $v ['price'];
  2556. }
  2557. }
  2558. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  2559. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2560. $acItem [$key] ['price'] = $v ['price'];
  2561. }
  2562. }
  2563. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  2564. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  2565. $acItem [$key] ['price'] = $v ['price'];
  2566. }
  2567. }
  2568. //内训
  2569. foreach ( $accountItemList [$this->INTTRAIN] as $k => $v ) {
  2570. if ($acItem [$key] ['category'] == $this->INTTRAIN && $acItem [$key] ['name'] == $v ['name']) {
  2571. $acItem [$key] ['price'] = $v ['price'];
  2572. }
  2573. }
  2574. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  2575. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  2576. $acItem [$key] ['price'] = $v ['price'];
  2577. }
  2578. }
  2579. }
  2580. $data ['category'] = $Lcategory->find ( array (
  2581. 'asArray' => true
  2582. ) );
  2583. $data ['ridKey'] = $ridKey;
  2584. $data ['cSum'] = $accountItemList ['cSum'];
  2585. $data ['sum'] = $receiptDetail ['sum'];
  2586. $data ['receiptDetail'] = $receiptDetail;
  2587. $data ['veList'] = $veList;
  2588. $data ['acItem'] = $acItem;
  2589. $data ['memu'] = "receipt";
  2590. $data ['staff'] = $this->staff;
  2591. $data ['receiptMemu'] = 'saeaBorad';
  2592. $data ['verify'] = $receiptDetail ['verify'];
  2593. $data ['verifyId'] = $this->verifyId;
  2594. $data ['executeId'] = $this->executeId;
  2595. $data ['rid'] = $rid;
  2596. if($receiptDetail['receiptClass']==1){
  2597. $this->render ( "/receipt/feeLoanReceiptAgencyEdi", $data );
  2598. }elseif($receiptDetail['receiptClass']==2){
  2599. $this->render ( "/receipt/feeLoanReceiptTraveEdi", $data );
  2600. }elseif($receiptDetail['receiptClass']==3){
  2601. $this->render ( "/receipt/feeLoanReceiptITEdi", $data );
  2602. }else{
  2603. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  2604. }
  2605. }
  2606. /**
  2607. * 培训班结算
  2608. */
  2609. function receiptTrainAdd() {
  2610. Doo::loadModel ( 'accountItem' );
  2611. $accountItem = new accountItem ();
  2612. $acItem = $accountItem->find ( array (
  2613. 'asArray' => true
  2614. ) );
  2615. // 审批组
  2616. Doo::loadModel ( 'verify' );
  2617. $verify = new verify ();
  2618. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2619. // 办事处
  2620. Doo::loadModel ( 'L_category' );
  2621. $lCategory = new L_category ();
  2622. $data ['category'] = $lCategory->getCategory ();
  2623. $data ['veList'] = $veList;
  2624. $data ['memu'] = "receipt";
  2625. $data ['staff'] = $this->staff;
  2626. $data ['acItem'] = $acItem;
  2627. $data ['receiptMemu'] = 'saeaBorad';
  2628. $data ['verifyId'] = $this->verifyId;
  2629. $data ['executeId'] = $this->executeId;
  2630. $this->render ( "/receipt/receiptTrainAdd", $data );
  2631. }
  2632. /**
  2633. * 添加培训班结算
  2634. */
  2635. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  2636. // 培训班信息
  2637. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2638. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2639. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2640. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2641. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2642. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2643. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2644. // 发票信息
  2645. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2646. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2647. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2648. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2649. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2650. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2651. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2652. //&&! empty ( $participants )
  2653. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2654. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2655. header ( 'Content-Type:text/html;charset=utf-8' );
  2656. die ( '请填写联行号' );
  2657. }
  2658. Doo::loadModel ( 'execute' );
  2659. $execute = new execute ();
  2660. $executeDetail = $execute->getOne ( array (
  2661. 'where' => 'mold="培训班结算"',
  2662. 'asArray' => true
  2663. ) );
  2664. if (empty ( $executeDetail )) {
  2665. header ( 'Content-Type:text/html;charset=utf-8' );
  2666. die ( '未设置执行人' );
  2667. }
  2668. Doo::loadClass ( 'XDeode' );
  2669. $XDeode = new XDeode ( 5 );
  2670. $cid = $XDeode->decode ( $cid );
  2671. Doo::loadModel ( 'receipt' );
  2672. $receipt = new receipt ();
  2673. Doo::loadModel ( 'receiptTraining' );
  2674. $receiptTraining = new receiptTraining ();
  2675. // 创建费用培训班
  2676. $item = array (
  2677. 'cid' => $this->staff [0] ['cid'],
  2678. 'categoryName' => $this->staff [0] ['category'],
  2679. 'trainName' => $trainName,
  2680. 'trainStartDate' => $trainStartDate,
  2681. 'trainEndDate' => $trainEndDate,
  2682. 'participants' => $participants,
  2683. 'freeParticipants'=>$freeParticipants,
  2684. 'trainAddress' => $trainAddress,
  2685. 'trainRemarks' => $trainRemarks,
  2686. 'creator' => $this->staff [0] ['sid'],
  2687. 'creatorDate' => date ( "Y-m-d H:i:s" )
  2688. );
  2689. $irid = $receiptTraining->addReceiptTraining ( $item );
  2690. // 报销单
  2691. $receipt->status = 5;
  2692. $receipt->trainId = $irid;
  2693. $receipt->Rtype = 3;
  2694. $receipt->staff = $this->staff [0] ['sid'];
  2695. $receipt->cid = $cid;
  2696. $receipt->verify = $verify;
  2697. $receipt->date = date ( "Y-m-d" );
  2698. $receipt->executeCopy = $executeDetail ['staff'];
  2699. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  2700. $receipt->remittanceName = $remittanceName;
  2701. $receipt->bankName = $bankName;
  2702. $receipt->bankNumber = $bankNumber;
  2703. $receipt->remittanceBankType = $remittanceBankType;
  2704. if ($remittanceBankType == 1)
  2705. $receipt->coupletNumber = $coupletNumber;
  2706. $rid = $receipt->insert ();
  2707. $XDeode = new XDeode ( 7 );
  2708. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  2709. } else
  2710. die ( 'illegal request' );
  2711. }
  2712. /**
  2713. * 培训班编辑
  2714. */
  2715. function receiptTrainEdi() {
  2716. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2717. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  2718. Doo::loadClass ( 'XDeode' );
  2719. $XDeode = new XDeode ( 7 );
  2720. $rid = $XDeode->decode ( $ridKey );
  2721. if (! is_numeric ( $rid ))
  2722. die ( 'illegal request' );
  2723. Doo::loadModel ( 'receipt' );
  2724. $receipt = new receipt ();
  2725. Doo::loadModel ( 'receiptTraining' );
  2726. $receiptTraining = new receiptTraining ();
  2727. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2728. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  2729. die ('illegal request--status');
  2730. }
  2731. //如有已入账已收款的发票,自动取消办事处已收款
  2732. // Doo::loadModel ( 'RIExtend' );
  2733. // $RIExtend = new RIExtend ();
  2734. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  2735. // if (!empty($RIExtendList)){
  2736. // foreach ($RIExtendList as $key=>$value){
  2737. // $RIExtend = new RIExtend ();
  2738. // $RIExtend->delete(array (
  2739. // 'where' => 'iid=' . $value['iid'],
  2740. // 'limit' => 1
  2741. // ));
  2742. // }
  2743. // }
  2744. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2745. // 汇总表合计
  2746. // 收入合计--加入开票合计
  2747. Doo::loadModel ( 'invoiceTraining' );
  2748. $invoiceTraining = new invoiceTraining ();
  2749. $invoiceTrainingDetail = array (
  2750. 'invoiceArriveAmount' => 0,
  2751. 'RIAmount' => 0,
  2752. 'invoiceTotalAmount' => 0,
  2753. 'invoiceCompanyAmount'=>0
  2754. );
  2755. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2756. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2757. }
  2758. // print_r($invoiceTrainingDetail);
  2759. $invoiceArriveAmount = $RIAmount = 0;
  2760. if (! empty ( $invoiceTrainingDetail )) {
  2761. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  2762. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  2763. }
  2764. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2765. //print_r($invoiceTrainingDetail);
  2766. // 支出项目
  2767. Doo::loadModel ( 'accountItem' );
  2768. $accountItem = new accountItem ();
  2769. // 项目金额合计
  2770. Doo::loadModel ( 'RItem' );
  2771. $RItem = new RItem ();
  2772. // 讲师获得
  2773. Doo::loadModel ( 'RILecturer' );
  2774. $RILecturer = new RILecturer ();
  2775. $RItemList = $RItem->getRItemByRid ( $rid );
  2776. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2777. // 支出项金额详情
  2778. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  2779. // print_r($aiData);
  2780. // 利润
  2781. $profit=$invoiceArriveAmount - $aiData ['total'];
  2782. $companyProfit=$profit * 0.6;
  2783. $categoryProfit=$profit * 0.4;
  2784. $data ['profit'] = sprintf("%.2f",$profit);
  2785. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  2786. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  2787. //发票利润
  2788. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  2789. //发票公司利润
  2790. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  2791. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  2792. //办事处利润
  2793. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  2794. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  2795. // print_r($aiData['dataList']);
  2796. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  2797. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  2798. // 备用金
  2799. $sum = 0;
  2800. $data ['receiptLoanDetail'] = array (
  2801. 'sum' => '0.00'
  2802. );
  2803. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2804. //$data ['receiptLoanDetail'] = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2805. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2806. $sum=0;
  2807. foreach ($receiptLoanList as $key=>$value){
  2808. $sum+=$value['sum'];
  2809. }
  2810. $data ['receiptLoanDetail'] = array (
  2811. 'sum' => $sum
  2812. );
  2813. //$sum = $data ['receiptLoanDetail'] ['sum'];
  2814. }
  2815. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  2816. $data ['payment'] = sprintf("%.2f",$payment);
  2817. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  2818. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  2819. $data ['aiList'] = $aiData ['dataList'];
  2820. // 占比计算
  2821. if ($invoiceArriveAmount != 0) {
  2822. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  2823. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2824. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2825. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  2826. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  2827. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  2828. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  2829. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  2830. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  2831. } else {
  2832. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2833. }
  2834. //发票金额占比计算
  2835. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2836. //支出
  2837. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2838. //利润
  2839. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2840. //公司利润
  2841. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2842. //办事处利润
  2843. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2844. //公司收款
  2845. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2846. //备用金
  2847. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2848. //办事处收款
  2849. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2850. //办事处实际支出
  2851. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2852. //付总部款
  2853. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  2854. }else{
  2855. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2856. }
  2857. //讲师人数
  2858. Doo::loadModel ( 'RILecturer' );
  2859. $RILecturer = new RILecturer ();
  2860. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2861. $data['lectureCount']=count($RILecturerList);
  2862. // 审批组
  2863. Doo::loadModel ( 'verify' );
  2864. $verify = new verify ();
  2865. $veList = $verify->getVerifyBySubordinate('TRAIN');
  2866. // 办事处
  2867. Doo::loadModel ( 'L_category' );
  2868. $lCategory = new L_category ();
  2869. $data ['category'] = $lCategory->getCategory ();
  2870. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2871. $data ['receiptDetail'] = $receiptDetail;
  2872. $data ['veList'] = $veList;
  2873. $data ['trainEdiType'] = $trainEdiType;
  2874. $data ['ridKey'] = $ridKey;
  2875. $data ['memu'] = "receipt";
  2876. $data ['staff'] = $this->staff;
  2877. $data ['receiptMemu'] = 'saeaBorad';
  2878. $data ['verifyId'] = $this->verifyId;
  2879. $data ['executeId'] = $this->executeId;
  2880. $this->render ( "/receipt/receiptTrainEdi", $data );
  2881. }
  2882. /**
  2883. * 培训班借款编辑
  2884. */
  2885. function receiptTrainLoanEdi() {
  2886. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2887. Doo::loadClass ( 'XDeode' );
  2888. $XDeode = new XDeode ( 7 );
  2889. $rid = $XDeode->decode ( $ridKey );
  2890. if (! is_numeric ( $rid ))
  2891. die ( 'illegal request' );
  2892. Doo::loadModel ( 'receipt' );
  2893. $receipt = new receipt ();
  2894. Doo::loadModel ( 'receiptTraining' );
  2895. $receiptTraining = new receiptTraining ();
  2896. Doo::loadModel ( 'verify' );
  2897. $verify = new verify ();
  2898. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2899. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2900. die ();
  2901. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2902. // 借款详情HTML
  2903. // 获得借款信息
  2904. $receiptLoanHtml = '';
  2905. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2906. $receiptLoanList = $receipt->getReceiptInRid ( $receiptDetail ['trainLoanRid'] );
  2907. foreach ($receiptLoanList as $key=>$value){
  2908. // 获得某费用单审批信息
  2909. $verifylist = $verify->getVerifyByRid ( $value ['rid'] );
  2910. Doo::loadClass ( 'receipt.func' );
  2911. $extendHtml = '<p><a class="button"
  2912. href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $value ['ridKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2913. $receiptLoanHtml .= _getReceiptLoanHtml ( $value, $verifylist, $extendHtml );
  2914. }
  2915. }
  2916. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2917. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2918. $data ['receiptDetail'] = $receiptDetail;
  2919. $data ['trainEdiType'] = "LOAN";
  2920. $data ['ridKey'] = $ridKey;
  2921. $data ['memu'] = "receipt";
  2922. $data ['staff'] = $this->staff;
  2923. $data ['receiptMemu'] = 'saeaBorad';
  2924. $data ['verifyId'] = $this->verifyId;
  2925. $data ['executeId'] = $this->executeId;
  2926. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2927. }
  2928. /**
  2929. * 更新培训班结算基本信息
  2930. */
  2931. function receiptTrainInfoEdiDo() {
  2932. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2933. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2934. // 培训班信息
  2935. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2936. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2937. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2938. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2939. $freeParticipants = $this->get_args ( 'freeParticipants' ) && is_numeric ( $this->get_args ( 'freeParticipants' ) ) ? $this->get_args ( 'freeParticipants' ) : 0;
  2940. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2941. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2942. // 发票信息
  2943. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2944. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2945. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2946. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2947. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2948. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2949. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2950. //&& ! empty ( $participants )
  2951. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $trainAddress )) {
  2952. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2953. header ( 'Content-Type:text/html;charset=utf-8' );
  2954. die ( '请填写联行号' );
  2955. }
  2956. Doo::loadClass ( 'XDeode' );
  2957. $XDeode = new XDeode ( 5 );
  2958. $cid = $XDeode->decode ( $cid );
  2959. $rtid = $XDeode->decode ( $rtid );
  2960. $rid = $XDeode->decode ( $rid );
  2961. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2962. die ( 'illegal request-IdError' );
  2963. }
  2964. Doo::loadModel ( 'receipt' );
  2965. $receipt = new receipt ();
  2966. Doo::loadModel ( 'receiptTraining' );
  2967. $receiptTraining = new receiptTraining ();
  2968. // 更新费用培训班
  2969. $item = array (
  2970. 'rtid' => $rtid,
  2971. 'trainName' => $trainName,
  2972. 'trainStartDate' => $trainStartDate,
  2973. 'trainEndDate' => $trainEndDate,
  2974. 'participants' => $participants,
  2975. 'freeParticipants'=>$freeParticipants,
  2976. 'trainAddress' => $trainAddress,
  2977. 'trainRemarks' => $trainRemarks
  2978. );
  2979. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2980. // 报销单
  2981. $receipt->rid = $rid;
  2982. $receipt->cid = $cid;
  2983. $receipt->verify = $verify;
  2984. $receipt->remittanceName = $remittanceName;
  2985. $receipt->bankName = $bankName;
  2986. $receipt->bankNumber = $bankNumber;
  2987. $receipt->remittanceBankType = $remittanceBankType;
  2988. if ($remittanceBankType == 1)
  2989. $receipt->coupletNumber = $coupletNumber;
  2990. $receipt->update ();
  2991. $XDeode = new XDeode ( 7 );
  2992. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2993. } else
  2994. die ( 'illegal request' );
  2995. }
  2996. /**
  2997. * 编辑培训班结算---更新借款
  2998. */
  2999. function receiptTrainLoanEdiDo() {
  3000. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3001. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  3002. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  3003. Doo::loadModel ( 'receipt' );
  3004. $receipt = new receipt ();
  3005. Doo::loadClass ( 'XDeode' );
  3006. $XDeode = new XDeode ( 5 );
  3007. $rid = $XDeode->decode ( $ridKey );
  3008. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3009. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3010. die ( 'illegal request-ridError' );
  3011. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3012. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3013. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3014. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3015. die ( 'illegal request-receiptError' );
  3016. }
  3017. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  3018. die ( 'illegal request-receipLoantError' );
  3019. }
  3020. // 培训班结算挂钩借款
  3021. $receipt = new receipt ();
  3022. $trainLoanRid=$ridLoan;
  3023. if (!empty($receiptDetail['trainLoanRid'])){
  3024. $trainLoanRid=$receiptDetail['trainLoanRid'].','.$ridLoan;
  3025. }
  3026. $item = array (
  3027. 'rid' => $rid,
  3028. 'trainLoanRid' => $trainLoanRid
  3029. );
  3030. $receipt->setReceiptByCondition ( $item );
  3031. // 更新借款状态变成已挂钩
  3032. $receipt = new receipt ();
  3033. $item = array (
  3034. 'rid' => $ridLoan,
  3035. 'status' => 10,
  3036. 'statusTrain' => 1
  3037. );
  3038. $receipt->setReceiptByCondition ( $item );
  3039. $XDeode = new XDeode ( 7 );
  3040. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3041. } else
  3042. die ( 'illegal request' );
  3043. }
  3044. /**
  3045. * 编辑培训班结算--移除借款
  3046. */
  3047. function receiptTrainLoanRemoveDo() {
  3048. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  3049. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  3050. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  3051. Doo::loadModel ( 'receipt' );
  3052. $receipt = new receipt ();
  3053. Doo::loadClass ( 'XDeode' );
  3054. $XDeode = new XDeode ( 5 );
  3055. $rid = $XDeode->decode ( $ridKey );
  3056. $ridLoan = $XDeode->decode ( $ridLoanKey );
  3057. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  3058. die ( 'illegal request-ridError' );
  3059. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3060. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  3061. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  3062. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3063. die ( 'illegal request-receiptError' );
  3064. }
  3065. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  3066. die ( 'illegal request-receipLoantError' );
  3067. }
  3068. // 培训班结算挂钩借款
  3069. $receipt = new receipt ();
  3070. $trainLoanRidArray=explode(",", $receiptDetail['trainLoanRid']);
  3071. foreach ($trainLoanRidArray as $key=>$value){
  3072. if($value==$ridLoan){
  3073. unset($trainLoanRidArray[$key]);
  3074. }
  3075. }
  3076. $trainLoanRidString=implode(",", $trainLoanRidArray);
  3077. $item = array (
  3078. 'rid' => $rid,
  3079. 'trainLoanRid' => $trainLoanRidString
  3080. );
  3081. $receipt->setReceiptByCondition ( $item );
  3082. // 更新借款状态变成已挂钩
  3083. $receipt = new receipt ();
  3084. $item = array (
  3085. 'rid' => $ridLoan,
  3086. 'status' => 8,
  3087. 'statusTrain' => 0
  3088. );
  3089. $receipt->setReceiptByCondition ( $item );
  3090. $XDeode = new XDeode ( 7 );
  3091. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  3092. } else
  3093. die ( 'illegal request' );
  3094. }
  3095. /**
  3096. * 编辑培训班结算 ---开票
  3097. */
  3098. function receiptTrainInvoiceEdi() {
  3099. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3100. Doo::loadClass ( 'XDeode' );
  3101. $XDeode = new XDeode ( 7 );
  3102. $rid = $XDeode->decode ( $ridKey );
  3103. if (! is_numeric ( $rid ))
  3104. die ( 'illegal request' );
  3105. Doo::loadModel ( 'receipt' );
  3106. $receipt = new receipt ();
  3107. Doo::loadModel ( 'receiptTraining' );
  3108. $receiptTraining = new receiptTraining ();
  3109. Doo::loadModel ( 'invoice' );
  3110. $invoice = new invoice ();
  3111. Doo::loadModel ( 'invoiceTraining' );
  3112. $invoiceTraining = new invoiceTraining ();
  3113. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3114. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  3115. die ();
  3116. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3117. $invoiceList = $invoiceTrainingDetail = array ();
  3118. if ($receiptDetail ['invoiceTrainId'] != 0) {
  3119. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  3120. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  3121. }
  3122. //print_r($invoiceList);
  3123. $data ['invoiceList'] = $invoiceList;
  3124. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  3125. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3126. $data ['receiptDetail'] = $receiptDetail;
  3127. $data ['trainEdiType'] = "INVOICE";
  3128. $data ['ridKey'] = $ridKey;
  3129. $data ['memu'] = "receipt";
  3130. $data ['staff'] = $this->staff;
  3131. $data ['receiptMemu'] = 'saeaBorad';
  3132. $data ['verifyId'] = $this->verifyId;
  3133. $data ['executeId'] = $this->executeId;
  3134. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  3135. }
  3136. /**
  3137. * 编辑培训班结算---更新开票
  3138. */
  3139. function receiptTrainInvoiceEdiDo() {
  3140. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3141. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  3142. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  3143. Doo::loadModel ( 'receipt' );
  3144. $receipt = new receipt ();
  3145. Doo::loadModel ( 'invoiceTraining' );
  3146. $invoiceTraining = new invoiceTraining ();
  3147. Doo::loadClass ( 'XDeode' );
  3148. $XDeode = new XDeode ( 5 );
  3149. $rid = $XDeode->decode ( $ridKey );
  3150. $itid = $XDeode->decode ( $itidKey );
  3151. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  3152. die ( 'illegal request-idError' );
  3153. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3154. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  3155. // 不合法的数据
  3156. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  3157. die ( 'illegal request-receiptError' );
  3158. }
  3159. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  3160. die ( 'illegal request-receipLoantError' );
  3161. }
  3162. // 培训班结算挂钩借款
  3163. $receipt = new receipt ();
  3164. $item = array (
  3165. 'rid' => $rid,
  3166. 'invoiceTrainId' => $itid
  3167. );
  3168. $receipt->setReceiptByCondition ( $item );
  3169. $invoiceTraining = new invoiceTraining ();
  3170. $item = array (
  3171. 'bindReceipt' => 1,
  3172. 'itid' => $itid
  3173. );
  3174. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3175. $XDeode = new XDeode ( 7 );
  3176. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  3177. } else
  3178. die ( 'illegal request' );
  3179. }
  3180. /**
  3181. * 更新培训班结算 收款和取消收款
  3182. */
  3183. function receiptTrainReceivables() {
  3184. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  3185. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3186. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  3187. Doo::loadClass ( 'XDeode' );
  3188. $XDeode = new XDeode ( 5 );
  3189. $rid = $XDeode->decode ( $ridKey );
  3190. $iid = $XDeode->decode ( $iidKey );
  3191. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  3192. die ( 'illegal request-iid' );
  3193. Doo::loadModel ( 'RIExtend' );
  3194. $RIExtend = new RIExtend ();
  3195. if ($doType == 'CONFIRM') {
  3196. $RIExtend->rid = $rid;
  3197. $RIExtend->iid = $iid;
  3198. $RIExtend->RIstatus = 1;
  3199. $RIExtend->insert ();
  3200. echo json_encode ( array (
  3201. 'status' => 1,
  3202. ) );
  3203. die ( );
  3204. } elseif ($doType == 'CANCEL') {
  3205. $RIExtend->delete ( array (
  3206. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  3207. 'limit' => 1
  3208. ) );
  3209. echo json_encode ( array (
  3210. 'status' => 1,
  3211. ) );
  3212. die ( );
  3213. } else {
  3214. echo json_encode ( array (
  3215. 'status' => 2,
  3216. ) );
  3217. die ( );
  3218. }
  3219. }
  3220. /**
  3221. * 移除挂钩的培训班发票
  3222. */
  3223. function receiptTrainReceivablesDelDo() {
  3224. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3225. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  3226. Doo::loadModel ( 'receipt' );
  3227. $receipt = new receipt ();
  3228. Doo::loadModel ( 'RIExtend' );
  3229. $RIExtend = new RIExtend ();
  3230. Doo::loadClass ( 'XDeode' );
  3231. $XDeode = new XDeode ( 5 );
  3232. $rid = $XDeode->decode ( $ridKey );
  3233. $itid = $XDeode->decode ( $itidKey );
  3234. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  3235. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3236. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3237. die ( 'illegal request-status' );
  3238. }
  3239. $receipt = new receipt ();
  3240. $receipt->rid = $rid;
  3241. $receipt->invoiceTrainId = 0;
  3242. $receipt->update ();
  3243. Doo::loadModel ( 'invoiceTraining' );
  3244. $invoiceTraining = new invoiceTraining ();
  3245. $item = array (
  3246. 'bindReceipt' => 0,
  3247. 'itid' => $itid
  3248. );
  3249. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  3250. $RIExtend->delete ( array (
  3251. 'where' => 'rid=' . $rid
  3252. ) );
  3253. $XDeode = new XDeode ( 7 );
  3254. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  3255. } else
  3256. die ( 'illegal request-iid' );
  3257. }
  3258. /**
  3259. * 编辑培训班结算
  3260. */
  3261. function receiptTrainItemEdi() {
  3262. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  3263. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3264. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  3265. Doo::loadClass ( 'XDeode' );
  3266. $XDeode = new XDeode ( 7 );
  3267. $rid = $XDeode->decode ( $ridKey );
  3268. if (! is_numeric ( $rid ))
  3269. die ( 'illegal request' );
  3270. Doo::loadModel ( 'receipt' );
  3271. $receipt = new receipt ();
  3272. Doo::loadModel ( 'receiptTraining' );
  3273. $receiptTraining = new receiptTraining ();
  3274. Doo::loadModel ( 'RItem' );
  3275. $RItem = new RItem ();
  3276. Doo::loadModel ( 'accountItem' );
  3277. $accountItem = new accountItem ();
  3278. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3279. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3280. die ();
  3281. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3282. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  3283. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  3284. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  3285. // if($value['name']=='税款'){
  3286. // unset($aiList[$key]);break;
  3287. // }
  3288. // }
  3289. //print_r($RItemList);
  3290. $data ['name'] = $name;
  3291. $data ['RItemList'] = $RItemList;
  3292. $data ['aiList'] = $aiList;
  3293. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3294. $data ['receiptDetail'] = $receiptDetail;
  3295. $data ['trainEdiType'] = "ITEM";
  3296. $data ['ridKey'] = $ridKey;
  3297. $data ['memu'] = "receipt";
  3298. $data ['staff'] = $this->staff;
  3299. $data ['receiptMemu'] = 'saeaBorad';
  3300. $data ['verifyId'] = $this->verifyId;
  3301. $data ['executeId'] = $this->executeId;
  3302. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  3303. }
  3304. /**
  3305. * 添加支出项 需要修改 费用金额合计
  3306. */
  3307. function receiptTrainItemAddDo() {
  3308. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3309. $rtidKey = $this->get_args ( 'rtidKey' ) ? $this->get_args ( 'rtidKey' ) : "";
  3310. // 支出项信息
  3311. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3312. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  3313. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  3314. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  3315. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  3316. //$identifyingTotal = $this->get_args ( 'identifyingTotal' )&&is_numeric($this->get_args ( 'identifyingTotal' )) ? $this->get_args ( 'identifyingTotal' ) : 0;
  3317. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  3318. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  3319. Doo::loadClass ( 'XDeode' );
  3320. $XDeode = new XDeode ( 5 );
  3321. Doo::loadModel ( 'RItem' );
  3322. $RItem = new RItem ();
  3323. $rid = $XDeode->decode ( $ridKey );
  3324. $rtid= $XDeode->decode ( $rtidKey );
  3325. if (! is_numeric ( $rid )){
  3326. die ( 'illegal request' );
  3327. }
  3328. Doo::loadModel ( 'receiptDetail' );
  3329. $receiptDetail = new receiptDetail ();
  3330. Doo::loadModel ( 'receipt' );
  3331. $receipt = new receipt ();
  3332. Doo::loadModel ( 'receiptTraining' );
  3333. $receiptTraining = new receiptTraining ();
  3334. $rtDetail=$receiptTraining->getReceiptTrainingByRtid($rtid);
  3335. $identifyingTotal=$rtDetail['identifyingTotal']+1;
  3336. $order = array (
  3337. "\r\n",
  3338. "\n",
  3339. "\r"
  3340. );
  3341. $replace = '<br/>';
  3342. $describe = str_replace ( $order, $replace, $describe );
  3343. $itemData = array (
  3344. 'rid' => $rid,
  3345. 'item' => $item,
  3346. 'price' => $price,
  3347. 'date' => $date,
  3348. 'inputer' => $inputer,
  3349. 'describe' => $describe,
  3350. 'creater' => $this->staff['0']['username'],
  3351. 'createrId' => $this->staff['0']['sid'],
  3352. 'creatDate' => date ( "Y-m-d H:i:s" ),
  3353. 'identifying'=>$identifyingTotal
  3354. );
  3355. if($payType=='company'){
  3356. $itemData += array (
  3357. 'payType' => 1
  3358. );
  3359. }
  3360. $RItem->addRItem($itemData, $receipt, $receiptDetail, $rid, $item, $price, $payType);
  3361. //更新支出项标识总数
  3362. $itemData = array (
  3363. 'rtid'=>$rtid,
  3364. 'identifyingTotal'=>$identifyingTotal
  3365. );
  3366. $receiptTraining->setReceiptTrainByCondition($itemData);
  3367. $XDeode = new XDeode ( 7 );
  3368. if($payType=='company'){
  3369. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  3370. }else{
  3371. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  3372. }
  3373. } else
  3374. die ( 'illegal request-dataError' );
  3375. }
  3376. /**
  3377. * 培训班结算-讲师
  3378. */
  3379. function receiptTrainLecturerEdi() {
  3380. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3381. Doo::loadClass ( 'XDeode' );
  3382. $XDeode = new XDeode ( 7 );
  3383. $rid = $XDeode->decode ( $ridKey );
  3384. if (! is_numeric ( $rid ))
  3385. die ( 'illegal request' );
  3386. Doo::loadModel ( 'receipt' );
  3387. $receipt = new receipt ();
  3388. Doo::loadModel ( 'receiptTraining' );
  3389. $receiptTraining = new receiptTraining ();
  3390. Doo::loadModel ( 'RILecturer' );
  3391. $RILecturer = new RILecturer ();
  3392. Doo::loadModel ( 'lecturer' );
  3393. $lecturer = new lecturer ();
  3394. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3395. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  3396. die ();
  3397. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  3398. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3399. $lecturerList = $lecturer->getLecturerAll ();
  3400. $INSIDEhtml = $OUTSIDEhtml = '';
  3401. foreach ( $lecturerList as $key => $value ) {
  3402. if ($value ['ltype'] == 'INSIDE') {
  3403. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  3404. } elseif ($value ['ltype'] == 'OUTSIDE') {
  3405. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  3406. }
  3407. }
  3408. $data ['INSIDEhtml'] = $INSIDEhtml;
  3409. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  3410. // print_r($RItemList);
  3411. $data ['RILecturerList'] = $RILecturerList;
  3412. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  3413. $data ['receiptDetail'] = $receiptDetail;
  3414. $data ['trainEdiType'] = "LECTURER";
  3415. $data ['ridKey'] = $ridKey;
  3416. $data ['memu'] = "receipt";
  3417. $data ['staff'] = $this->staff;
  3418. $data ['receiptMemu'] = 'saeaBorad';
  3419. $data ['verifyId'] = $this->verifyId;
  3420. $data ['executeId'] = $this->executeId;
  3421. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  3422. }
  3423. /**
  3424. * 添加讲师
  3425. */
  3426. function receiptTrainLecturerAddDo() {
  3427. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3428. // 支出项信息
  3429. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  3430. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  3431. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  3432. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  3433. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  3434. $fees = $this->get_args ( 'fees' ) ? $this->get_args ( 'fees' ) : "";
  3435. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  3436. Doo::loadClass ( 'XDeode' );
  3437. $XDeode = new XDeode ( 5 );
  3438. Doo::loadModel ( 'RILecturer' );
  3439. $RILecturer = new RILecturer ();
  3440. $rid = $XDeode->decode ( $ridKey );
  3441. if (! is_numeric ( $rid ))
  3442. die ( 'illegal request' );
  3443. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  3444. die ( 'illegal request-taxationError' );
  3445. $RILecturer->rid = $rid;
  3446. $RILecturer->ltype = $ltype;
  3447. if ($ltype == 'OUTSIDE') {
  3448. if ($taxation == 'TAXATION') {
  3449. $RILecturer->taxation = 1;
  3450. } elseif ($taxation == 'NOTAXATION') {
  3451. $RILecturer->taxation = 0;
  3452. }
  3453. }
  3454. $RILecturer->lecturerName = $lecturerName;
  3455. $RILecturer->schoolDay = $schoolDay;
  3456. $RILecturer->price = $price;
  3457. $RILecturer->fees=$fees;
  3458. $RILecturer->insert ();
  3459. // 添加公司汇总
  3460. // 报销详情
  3461. Doo::loadModel ( 'receiptDetail' );
  3462. $receiptDetail = new receiptDetail ();
  3463. Doo::loadModel ( 'receipt' );
  3464. $receipt = new receipt ();
  3465. // 金额总计
  3466. $price = $price * $schoolDay;
  3467. $rInfo = $receipt->getReceiptByRid ( $rid );
  3468. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3469. if (empty ( $rdInfo )) {
  3470. $receiptDetail = new receiptDetail ();
  3471. $receiptDetail->staff = $rInfo ['staff'];
  3472. $receiptDetail->item = '讲课费';
  3473. $receiptDetail->itemCategory = '培训班费用';
  3474. $receiptDetail->price = number_format ( $fees, 2, '.', '' );
  3475. $receiptDetail->date = date ( "Y-m-d" );
  3476. $receiptDetail->cid = $rInfo ['cid'];
  3477. $receiptDetail->rid = $rid;
  3478. $receiptDetail->status = 4;
  3479. $receiptDetail->insert ();
  3480. } else {
  3481. $receiptDetail = new receiptDetail ();
  3482. $rdInfo ['price'] += $fees;
  3483. $receiptDetail->price = $rdInfo ['price'];
  3484. $receiptDetail->update ( array (
  3485. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3486. ) );
  3487. }
  3488. $receipt = new receipt ();
  3489. $receipt->sum=$rInfo['sum']+$fees;
  3490. $receipt->update ( array (
  3491. 'where' => 'rid=' . $rid
  3492. ) );
  3493. $XDeode = new XDeode ( 7 );
  3494. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3495. } else
  3496. die ( 'illegal request' );
  3497. }
  3498. /**
  3499. * 移除讲师
  3500. */
  3501. function receiptTrainLecturerDelDo() {
  3502. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  3503. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  3504. Doo::loadModel ( 'receipt' );
  3505. $receipt = new receipt ();
  3506. Doo::loadModel ( 'RILecturer' );
  3507. $RILecturer = new RILecturer ();
  3508. Doo::loadClass ( 'XDeode' );
  3509. $XDeode = new XDeode ( 5 );
  3510. $rid = $XDeode->decode ( $ridKey );
  3511. $rlid = $XDeode->decode ( $rlidKey );
  3512. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  3513. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  3514. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  3515. die ( 'illegal request-status' );
  3516. }
  3517. $detail=$RILecturer->getRILecturerByRlid($rlid);
  3518. if (empty($detail)){
  3519. die ( 'illegal request-data' );
  3520. }
  3521. $RILecturer->delete ( array (
  3522. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  3523. ) );
  3524. //更新费用合计金额
  3525. $rInfo = $receipt->getReceiptByRid ( $rid );
  3526. $receipt = new receipt ();
  3527. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  3528. $receipt->update ( array (
  3529. 'where' => 'rid=' . $rid
  3530. ) );
  3531. Doo::loadModel ( 'receiptDetail' );
  3532. $receiptDetail = new receiptDetail ();
  3533. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  3534. $receiptDetail = new receiptDetail ();
  3535. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  3536. $receiptDetail->price = $rdInfo ['price'];
  3537. $receiptDetail->update ( array (
  3538. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  3539. ) );
  3540. $XDeode = new XDeode ( 7 );
  3541. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  3542. } else
  3543. die ( 'illegal request-iid' );
  3544. }
  3545. /**
  3546. * 培训班提交审批
  3547. */
  3548. function receiptTrainDo() {
  3549. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  3550. Doo::loadClass ( 'XDeode' );
  3551. $XDeode = new XDeode ( 7 );
  3552. $rid = $XDeode->decode ( $ridKey );
  3553. Doo::loadModel ( 'receipt' );
  3554. $receipt = new receipt ();
  3555. Doo::loadModel ( 'receiptDetail' );
  3556. $receiptDetail = new receiptDetail ();
  3557. Doo::loadModel ( 'statistics' );
  3558. $statistics = new statistics ();
  3559. Doo::loadModel ( "verify" );
  3560. $verify = new verify ();
  3561. // 审批状态的判定
  3562. $receiptDetailList = $receipt->getOne ( array (
  3563. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  3564. 'asArray' => true
  3565. ) );
  3566. if (empty ( $receiptDetailList ))
  3567. return "/saeaBorad";
  3568. $verifyDetail = $verify->getOne ( array (
  3569. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3570. 'asArray' => true
  3571. ) );
  3572. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3573. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3574. $nowStaff = "";
  3575. $nowStaffList = array ();
  3576. if ($verifyDetail [0] [1] == 'ROLE') {
  3577. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3578. foreach ( $vStaffString as $key => $value ) {
  3579. $staffK = explode ( "_", $value );
  3580. array_push ( $nowStaffList, $staffK [0] );
  3581. }
  3582. $nowStaff = implode ( ',', $nowStaffList );
  3583. } else {
  3584. $nowStaff = $verifyDetail [0] [0];
  3585. }
  3586. $receipt->nowStaff = $nowStaff;
  3587. }
  3588. // echo $nowStaff;
  3589. // print_r($verifyDetail);die;
  3590. $receipt->rid = $receiptDetailList ['rid'];
  3591. $receipt->date = date ( "Y-m-d" );
  3592. $receipt->status = 2;
  3593. $receipt->update ();
  3594. $receiptDetail->status = 2;
  3595. $receiptDetail->update ( array (
  3596. 'where' => 'rid=' . $receiptDetailList ['rid']
  3597. ) );
  3598. Doo::loadModel ( "receiptLog" );
  3599. $receiptLog = new receiptLog ();
  3600. Doo::loadModel ( "verify" );
  3601. $verify = new verify ();
  3602. $vr = $verify->getOne ( array (
  3603. 'where' => 'vid=' . $receiptDetailList ['verify'],
  3604. 'asArray' => true
  3605. ) );
  3606. $jd = json_decode ( $vr ['staff'] );
  3607. $roleId = 0;
  3608. foreach ( $jd as $key => $value ) {
  3609. if ($value [1] == 'ROLE') {
  3610. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3611. if ($pos !== false) {
  3612. $roleId = $value [0];
  3613. }
  3614. }
  3615. }
  3616. // 审批日志
  3617. // echo $roleId;die;
  3618. if (! empty ( $roleId )) {
  3619. Doo::loadModel ( "role" );
  3620. $role = new role ();
  3621. $roleInfo = $role->getOne ( array (
  3622. 'where' => 'rid=' . $roleId,
  3623. 'asArray' => true
  3624. ) );
  3625. // $receiptLog->rolename = $roleInfo ['name'];
  3626. }
  3627. $receiptLog->username = $this->staff [0] ['username'];
  3628. $receiptLog->uid = $this->staff [0] ['sid'];
  3629. $receiptLog->date = date ( "Y-m-d" );
  3630. $receiptLog->opinion = '提交审批';
  3631. $receiptLog->img = $this->staff [0] ['avatar'];
  3632. $receiptLog->status = 2;
  3633. $receiptLog->rid = $rid;
  3634. $receiptLog->insert ();
  3635. // 写入列表项
  3636. Doo::loadModel ( 'accountItem' );
  3637. $accountItem = new accountItem ();
  3638. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  3639. // 项目金额合计
  3640. Doo::loadModel ( 'RItem' );
  3641. $RItem = new RItem ();
  3642. // 讲师获得
  3643. Doo::loadModel ( 'RILecturer' );
  3644. $RILecturer = new RILecturer ();
  3645. $RItemList = $RItem->getRItemByRid ( $rid );
  3646. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  3647. // 支出项金额详情
  3648. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  3649. // print_r($aItem);
  3650. // print_r($aiData);
  3651. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  3652. $ag = $tr = $ta = $ot = 0;
  3653. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  3654. foreach ( $aItem as $key => $value ) {
  3655. if ($value ['category'] == $this->TRAIN) {
  3656. foreach ( $aiData ['dataList'] as $k => $v ) {
  3657. if ($value ['name'] == $v ['name']) {
  3658. array_push ( $accountJson [$this->TRAIN], array (
  3659. 'aid' => $value ['aid'],
  3660. 'name' => $value ['name'],
  3661. 'price' => number_format ( $v ['price'], 2, '.', '' )
  3662. ) );
  3663. $sum += $v ['price'];
  3664. $trainSum += $v ['price'];
  3665. unset ( $aiData ['dataList'] [$k] );
  3666. break;
  3667. }
  3668. }
  3669. }
  3670. }
  3671. $accountJson ['cSum'] = array (
  3672. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  3673. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  3674. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  3675. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  3676. );
  3677. // 报销单
  3678. $receipt = new receipt ();
  3679. $receipt->accountItem = json_encode ( $accountJson );
  3680. $receipt->sum = number_format ( $sum, 2, '.', '' );
  3681. $receipt->update ( array (
  3682. 'where' => 'rid=' . $rid
  3683. ) );
  3684. // print_r($accountJson);
  3685. // statistics item 统计写入
  3686. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  3687. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  3688. $accountItem = $accountJson;
  3689. $stat = $statistics->getOne ( array (
  3690. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3691. 'asArray' => true
  3692. ) );
  3693. if (empty ( $stat )) {
  3694. $statistics->date = date ( "Y-m-d" );
  3695. $statistics->cid = $this->staff [0] ['cid'];
  3696. $statistics->staff = $this->staff [0] ['sid'];
  3697. $statistics->agPrice = 0;
  3698. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3699. $statistics->insert ();
  3700. } else {
  3701. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  3702. $statistics->update ( array (
  3703. 'where' => 'sid=' . $stat ['sid']
  3704. ) );
  3705. }
  3706. return "/saeaBorad";
  3707. }
  3708. function confirmation() {
  3709. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3710. Doo::loadModel ( 'receipt' );
  3711. Doo::loadModel ( 'receiptDetail' );
  3712. $receipt = new receipt ();
  3713. $receiptDetail = new receiptDetail ();
  3714. Doo::loadModel ( 'statistics' );
  3715. Doo::loadModel ( 'itemStatistics' );
  3716. $statistics = new statistics ();
  3717. $itemStatistics = new itemStatistics ();
  3718. Doo::loadModel ( "verify" );
  3719. $verify = new verify ();
  3720. $receiptDetailList = $receipt->getOne ( array (
  3721. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  3722. 'asArray' => true
  3723. ) );
  3724. if (empty ( $receiptDetailList ))
  3725. return "/saeaBorad";
  3726. $verifyDetail = $verify->getOne ( array (
  3727. 'where' => ' vid =' . $receiptDetailList ['verify'],
  3728. 'asArray' => true
  3729. ) );
  3730. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3731. if (empty ( $receiptDetailList ['nowStaff'] )) {
  3732. $nowStaff = "";
  3733. $nowStaffList = array ();
  3734. if ($verifyDetail [0] [1] == 'ROLE') {
  3735. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3736. foreach ( $vStaffString as $key => $value ) {
  3737. $staffK = explode ( "_", $value );
  3738. array_push ( $nowStaffList, $staffK [0] );
  3739. }
  3740. $nowStaff = implode ( ',', $nowStaffList );
  3741. } else {
  3742. $nowStaff = $verifyDetail [0] [0];
  3743. }
  3744. $receipt->nowStaff = $nowStaff;
  3745. }
  3746. // echo $nowStaff;
  3747. // print_r($verifyDetail);die;
  3748. $receipt->rid = $receiptDetailList ['rid'];
  3749. $receipt->status = 2;
  3750. $receipt->update ();
  3751. // 操作日志
  3752. Doo::loadModel ( "receiptLog" );
  3753. $receiptLog = new receiptLog ();
  3754. $verify = new verify ();
  3755. $receiptInfo = $receipt->getOne ( array (
  3756. 'where' => 'rid=' . $rid,
  3757. 'asArray' => true
  3758. ) );
  3759. $vr = $verify->getOne ( array (
  3760. 'where' => 'vid=' . $receiptInfo ['verify'],
  3761. 'asArray' => true
  3762. ) );
  3763. $jd = json_decode ( $vr ['staff'] );
  3764. $roleId = 0;
  3765. foreach ( $jd as $key => $value ) {
  3766. if ($value [1] == 'ROLE') {
  3767. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  3768. if ($pos !== false) {
  3769. $roleId = $value [0];
  3770. }
  3771. }
  3772. }
  3773. // 审批日志
  3774. // echo $roleId;die;
  3775. if (! empty ( $roleId )) {
  3776. Doo::loadModel ( "role" );
  3777. $role = new role ();
  3778. $roleInfo = $role->getOne ( array (
  3779. 'where' => 'rid=' . $roleId,
  3780. 'asArray' => true
  3781. ) );
  3782. // $receiptLog->rolename = $roleInfo ['name'];
  3783. }
  3784. $receiptLog->username = $this->staff [0] ['username'];
  3785. $receiptLog->uid = $this->staff [0] ['sid'];
  3786. $receiptLog->date = date ( "Y-m-d" );
  3787. $receiptLog->opinion = '提交审批';
  3788. $receiptLog->img = $this->staff [0] ['avatar'];
  3789. $receiptLog->status = 2;
  3790. $receiptLog->rid = $rid;
  3791. $receiptLog->insert ();
  3792. return "/expenses";
  3793. }
  3794. function expenses() {
  3795. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  3796. if (empty ( $item ))
  3797. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  3798. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  3799. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  3800. Doo::loadClass ( 'XDeode' );
  3801. $XDeode = new XDeode ( 7 );
  3802. Doo::loadModel ( 'receipt' );
  3803. $receipt = new receipt ();
  3804. Doo::loadModel ( 'L_category' );
  3805. $Lcategory = new L_category ();
  3806. Doo::loadModel ( 'verify' );
  3807. Doo::loadModel ( 'statistics' );
  3808. $statistics = new statistics ();
  3809. $verify = new verify ();
  3810. Doo::loadModel ( 'staff' );
  3811. $staff = new staff ();
  3812. $condition = "";
  3813. if ($item == "expenses")
  3814. $condition = " and Rtype=1 ";
  3815. elseif ($item == "receipts")
  3816. $condition = " and Rtype=0 ";
  3817. elseif ($item == "remits")
  3818. $condition = " and Rtype=2 ";
  3819. elseif ($item == "train")
  3820. $condition = " and Rtype=3 ";
  3821. $dateCondition = " and Year(date) =" . $year;
  3822. if (! empty ( $moth )) {
  3823. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3824. $stList = $statistics->getOne ( array (
  3825. 'select' => 'rePrice ,agPrice',
  3826. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3827. 'asArray' => true
  3828. ) );
  3829. } else
  3830. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3831. if (empty ( $stList ))
  3832. $stList = array (
  3833. 'rePrice' => 0,
  3834. 'agPrice' => 0
  3835. );
  3836. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3837. if (! isset ( $noPassSum ['sum'] ))
  3838. $noPassSum ['sum'] = 0;
  3839. $data ['stList'] = array (
  3840. 'rePrice' => $stList ['rePrice'],
  3841. 'agPrice' => $stList ['agPrice'],
  3842. 'skPrice' => ($noPassSum ['sum'])
  3843. );
  3844. $receiptList = $receipt->find ( array (
  3845. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3846. 'desc' => 'rid',
  3847. 'asArray' => true
  3848. ) );
  3849. $Locate = 0;
  3850. $roleId = 0;
  3851. $button = 0;
  3852. foreach ( $receiptList as $key => $value ) {
  3853. $receiptList[$key]['balance']='';
  3854. if($value['Rtype']==1){
  3855. $receiptList[$key]['balance']=$value['sum']-=$value['loanSum'];
  3856. $receiptList[$key]['balanceABS']=abs($receiptList[$key]['balance']);
  3857. }elseif($value['Rtype']==3){
  3858. $payment=$this->_getReceiptTrainPayment($value['invoiceTrainId'],$value['trainLoanRid'],$value['rid']);
  3859. $receiptList[$key]['payment']=$payment;
  3860. $receiptList[$key]['paymentABS']=abs($payment);
  3861. }
  3862. $receiptList [$key] ['Locate'] = $Locate;
  3863. $Locate ++;
  3864. $receiptList [$key] ['reviseDetail'] = array ();
  3865. if (! empty ( $value ['reviseDetail'] ))
  3866. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3867. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3868. $categoryDetil = $Lcategory->getOne ( array (
  3869. 'where' => 'cid=' . $value ['cid'],
  3870. 'asArray' => true
  3871. ) );
  3872. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3873. // 检测编辑状态
  3874. $verifyList = $verify->getOne ( array (
  3875. 'where' => 'vid=' . $value ['verify'],
  3876. 'asArray' => true
  3877. ) );
  3878. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3879. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3880. Doo::loadModel ( 'role' );
  3881. $role = new role ();
  3882. $flag = true;
  3883. $roleKey = 0;
  3884. $endStaffArray = array ();
  3885. $roleArrayCopy = array ();
  3886. foreach ( $verifyList as $k => $v ) {
  3887. // init verifyStaff
  3888. if ($v [1] == 'ROLE') {
  3889. if (! empty ( $verifyStaff )) {
  3890. $endStaffArray = end ( $verifyStaff );
  3891. // if ($v[0]==$endStaffArray['nextStaff']){
  3892. // $roleId=$v[0];
  3893. // }
  3894. }
  3895. $roleVerify = json_decode ( $v [3], true );
  3896. $roleKey = $k;
  3897. $roleArray = array ();
  3898. $rolename = $role->getOne ( array (
  3899. 'where' => 'rid=' . $v [0],
  3900. 'asArray' => true
  3901. ) );
  3902. foreach ( $roleVerify as $o => $p ) {
  3903. $staffID = explode ( '_', $p );
  3904. $staffInfo = $staff->getOne ( array (
  3905. 'where' => 'sid=' . $staffID [0],
  3906. 'asArray' => true
  3907. ) );
  3908. // print_r($staffID);
  3909. $exp = array (
  3910. 0 => $staffInfo ['sid'],
  3911. 1 => $staffID [1],
  3912. 2 => $staffInfo ['avatar'],
  3913. 'date' => '',
  3914. 'date' => '',
  3915. 'opinion' => '',
  3916. 'status' => '',
  3917. 'rolename' => $rolename ['name']
  3918. );
  3919. array_push ( $roleArray, $exp );
  3920. }
  3921. $roleArrayCopy [$v [0]] = $roleArray;
  3922. // $verifyList[$k]['roleArray']=$roleArray;
  3923. }
  3924. $verifyList [$k] ['date'] = "";
  3925. $verifyList [$k] ['opinion'] = "";
  3926. $verifyList [$k] ['status'] = "";
  3927. if (empty ( $verifyStaff )) {
  3928. $verifyList [$k] ['date'] = "";
  3929. $verifyList [$k] ['opinion'] = "";
  3930. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3931. $verifyList [$k] ['status'] = 4;
  3932. $flag = false;
  3933. }
  3934. } else {
  3935. foreach ( $verifyStaff as $m => $u ) {
  3936. if ($v [0] == $m) {
  3937. $verifyList [$k] ['date'] = $u ['date'];
  3938. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3939. $verifyList [$k] ['status'] = $u ['status'];
  3940. $flag = false;
  3941. break;
  3942. }
  3943. }
  3944. $endStaffArray = end ( $verifyStaff );
  3945. if (isset ( $endStaffArray ['ROLE'] )) {
  3946. } else {
  3947. // $endKey=key($verifyStaff);
  3948. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3949. // $button=4;
  3950. // $verifyList[$k]['status']=4;
  3951. // }
  3952. }
  3953. }
  3954. }
  3955. $rolename ['name'] = '';
  3956. if (! empty ( $roleId )) {
  3957. Doo::loadModel ( 'role' );
  3958. $role = new role ();
  3959. $rolename = $role->getOne ( array (
  3960. 'where' => 'rid=' . $roleId,
  3961. 'asArray' => true
  3962. ) );
  3963. }
  3964. if (! empty ( $verifyStaff ))
  3965. $endStaffArray = end ( $verifyStaff );
  3966. $KOP = false;
  3967. foreach ( $roleArrayCopy as $P => $A ) {
  3968. foreach ( $A as $MKI => $AVL ) {
  3969. if (! empty ( $verifyStaff )) {
  3970. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3971. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3972. $button = 4;
  3973. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3974. }
  3975. foreach ( $verifyStaff as $m => $u ) {
  3976. $AVLFK = $AVL [0] . '_R';
  3977. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3978. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3979. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3980. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3981. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3982. break;
  3983. }
  3984. }
  3985. } else {
  3986. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3987. $button = 4;
  3988. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3989. }
  3990. }
  3991. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3992. $KOP = true;
  3993. }
  3994. }
  3995. foreach ( $roleArrayCopy as $k => $v ) {
  3996. foreach ( $verifyList as $m => $n ) {
  3997. if ($n [0] == $k) {
  3998. array_splice ( $verifyList, $m, 1, $v );
  3999. }
  4000. }
  4001. }
  4002. $receiptList [$key] ['verifyList'] = $verifyList;
  4003. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4004. 'where' => 'sid=' . $value ['staff'],
  4005. 'asArray' => true
  4006. ) );
  4007. $receiptList [$key] ['button'] = $button;
  4008. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  4009. }
  4010. // print_r($receiptList);die;
  4011. $mothHtml = "";
  4012. for($i = 1; $i <= 12; $i ++) {
  4013. if ($moth == $i)
  4014. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4015. else
  4016. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4017. }
  4018. $dateHtml = "";
  4019. $now = date ( "Y" );
  4020. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4021. if ($YEARD <= $now) {
  4022. $dateHtml .= '<option ';
  4023. if ($year == $YEARD) {
  4024. $dateHtml .= 'selected ';
  4025. }
  4026. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4027. }
  4028. }
  4029. $data ['dateHtml'] = $dateHtml;
  4030. $data ['mothHtml'] = $mothHtml;
  4031. $data ['receiptList'] = $receiptList;
  4032. $data ['memu'] = "receipt";
  4033. $data ['staff'] = $this->staff;
  4034. $data ['receiptMemu'] = 'expenses';
  4035. $data ['verifyId'] = $this->verifyId;
  4036. $data ['executeId'] = $this->executeId;
  4037. $data ['item'] = $item;
  4038. $data ['year'] = $year;
  4039. $this->render ( "/admin/expenses", $data );
  4040. }
  4041. function expensesCollect() {
  4042. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4043. Doo::loadModel ( 'receipt' );
  4044. $receipt = new receipt ();
  4045. Doo::loadModel ( 'L_category' );
  4046. $Lcategory = new L_category ();
  4047. Doo::loadModel ( 'verify' );
  4048. Doo::loadModel ( 'statistics' );
  4049. $statistics = new statistics ();
  4050. $verify = new verify ();
  4051. Doo::loadModel ( 'staff' );
  4052. $staff = new staff ();
  4053. Doo::loadModel ( 'loanReceipt' );
  4054. $loanReceipt = new loanReceipt ();
  4055. $receiptList = $receipt->find ( array (//去掉
  4056. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  4057. 'desc' => 'rid',
  4058. 'asArray' => true
  4059. ) );
  4060. $loanList = $loanReceipt->find ( array (
  4061. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4062. 'desc' => 'rid',
  4063. 'asArray' => true
  4064. ) );
  4065. /*
  4066. * $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;
  4067. */
  4068. $data ['explanation'] = '';
  4069. if (! empty ( $loanList ))
  4070. $data ['explanation'] = $loanList [0] ['explanation'];
  4071. $Locate = 0;
  4072. $roleId = 0;
  4073. $button = 0;
  4074. foreach ( $receiptList as $key => $value ) {
  4075. $receiptList [$key] ['Locate'] = $Locate;
  4076. $Locate ++;
  4077. $receiptList [$key] ['reviseDetail'] = array ();
  4078. if (! empty ( $value ['reviseDetail'] ))
  4079. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4080. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4081. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4082. $categoryDetil = $Lcategory->getOne ( array (
  4083. 'where' => 'cid=' . $value ['cid'],
  4084. 'asArray' => true
  4085. ) );
  4086. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4087. // 检测编辑状态
  4088. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  4089. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  4090. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  4091. else
  4092. $verifyList ['staff'] = $value ['verifyBreakup'];
  4093. } else
  4094. $verifyList = $verify->getOne ( array (
  4095. 'where' => 'vid=' . $value ['verify'],
  4096. 'asArray' => true
  4097. ) );
  4098. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4099. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4100. Doo::loadModel ( 'role' );
  4101. $role = new role ();
  4102. $flag = true;
  4103. $roleKey = 0;
  4104. $endStaffArray = array ();
  4105. $roleArrayCopy = array ();
  4106. foreach ( $verifyList as $k => $v ) {
  4107. // init verifyStaff
  4108. if ($v [1] == 'ROLE') {
  4109. if (! empty ( $verifyStaff )) {
  4110. $endStaffArray = end ( $verifyStaff );
  4111. // if ($v[0]==$endStaffArray['nextStaff']){
  4112. // $roleId=$v[0];
  4113. // }
  4114. }
  4115. $roleVerify = json_decode ( $v [3], true );
  4116. $roleKey = $k;
  4117. $roleArray = array ();
  4118. $rolename = $role->getOne ( array (
  4119. 'where' => 'rid=' . $v [0],
  4120. 'asArray' => true
  4121. ) );
  4122. foreach ( $roleVerify as $o => $p ) {
  4123. $staffID = explode ( '_', $p );
  4124. $staffInfo = $staff->getOne ( array (
  4125. 'where' => 'sid=' . $staffID [0],
  4126. 'asArray' => true
  4127. ) );
  4128. // print_r($staffID);
  4129. $exp = array (
  4130. 0 => $staffInfo ['sid'],
  4131. 1 => $staffID [1],
  4132. 2 => $staffInfo ['avatar'],
  4133. 'date' => '',
  4134. 'date' => '',
  4135. 'opinion' => '',
  4136. 'status' => '',
  4137. 'rolename' => $rolename ['name']
  4138. );
  4139. array_push ( $roleArray, $exp );
  4140. }
  4141. $roleArrayCopy [$v [0]] = $roleArray;
  4142. // $verifyList[$k]['roleArray']=$roleArray;
  4143. }
  4144. $verifyList [$k] ['date'] = "";
  4145. $verifyList [$k] ['opinion'] = "";
  4146. $verifyList [$k] ['status'] = "";
  4147. if (empty ( $verifyStaff )) {
  4148. $verifyList [$k] ['date'] = "";
  4149. $verifyList [$k] ['opinion'] = "";
  4150. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4151. $verifyList [$k] ['status'] = 4;
  4152. $flag = false;
  4153. }
  4154. } else {
  4155. foreach ( $verifyStaff as $m => $u ) {
  4156. if ($v [0] == $m) {
  4157. $verifyList [$k] ['date'] = $u ['date'];
  4158. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4159. $verifyList [$k] ['status'] = $u ['status'];
  4160. $flag = false;
  4161. break;
  4162. }
  4163. }
  4164. $endStaffArray = end ( $verifyStaff );
  4165. if (isset ( $endStaffArray ['ROLE'] )) {
  4166. } else {
  4167. // $endKey=key($verifyStaff);
  4168. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4169. // $button=4;
  4170. // $verifyList[$k]['status']=4;
  4171. // }
  4172. }
  4173. }
  4174. }
  4175. $rolename ['name'] = '';
  4176. if (! empty ( $roleId )) {
  4177. Doo::loadModel ( 'role' );
  4178. $role = new role ();
  4179. $rolename = $role->getOne ( array (
  4180. 'where' => 'rid=' . $roleId,
  4181. 'asArray' => true
  4182. ) );
  4183. }
  4184. if (! empty ( $verifyStaff ))
  4185. $endStaffArray = end ( $verifyStaff );
  4186. $KOP = false;
  4187. foreach ( $roleArrayCopy as $P => $A ) {
  4188. foreach ( $A as $MKI => $AVL ) {
  4189. if (! empty ( $verifyStaff )) {
  4190. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4191. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4192. $button = 4;
  4193. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4194. }
  4195. foreach ( $verifyStaff as $m => $u ) {
  4196. $AVLFK = $AVL [0] . '_R';
  4197. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4198. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4199. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4200. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4201. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4202. break;
  4203. }
  4204. }
  4205. } else {
  4206. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4207. $button = 4;
  4208. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4209. }
  4210. }
  4211. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4212. $KOP = true;
  4213. }
  4214. }
  4215. foreach ( $roleArrayCopy as $k => $v ) {
  4216. foreach ( $verifyList as $m => $n ) {
  4217. if ($n [0] == $k) {
  4218. array_splice ( $verifyList, $m, 1, $v );
  4219. }
  4220. }
  4221. }
  4222. // 费用执行人相关数据
  4223. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4224. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4225. foreach ( $executeCopy as $k => $v ) {
  4226. $executeCopy [$k] ['date'] = '';
  4227. $executeCopy [$k] ['opinion'] = '';
  4228. $executeCopy [$k] ['status'] = '';
  4229. if (! empty ( $executeStaff ))
  4230. foreach ( $executeStaff as $m => $u ) {
  4231. if ($v [0] == $m) {
  4232. $executeCopy [$k] ['date'] = $u ['date'];
  4233. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4234. $executeCopy [$k] ['status'] = $u ['status'];
  4235. break;
  4236. }
  4237. }
  4238. }
  4239. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4240. $receiptList [$key] ['verifyList'] = $verifyList;
  4241. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4242. 'where' => 'sid=' . $value ['staff'],
  4243. 'asArray' => true
  4244. ) );
  4245. $receiptList [$key] ['button'] = $button;
  4246. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4247. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4248. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4249. $receiptList [$key] ['relust'] = $relust;
  4250. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4251. }
  4252. Doo::loadModel ( 'enclosur' );
  4253. $enclosur = new enclosur ();
  4254. $enclosurList = $enclosur->find ( array (
  4255. 'where' => 'rid=' . $rid,
  4256. 'asArray' => true
  4257. ) );
  4258. $enclosurHtml = '';
  4259. foreach ( $enclosurList as $value ) {
  4260. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4261. }
  4262. $data ['enclosurHtml'] = $enclosurHtml;
  4263. //print_r($receiptList[0]['accountItem']['内部培训费用']);
  4264. $data ['receiptList'] = $receiptList;
  4265. $data ['memu'] = "receipt";
  4266. $data ['staff'] = $this->staff;
  4267. $data ['receiptMemu'] = 'expenses';
  4268. $data ['verifyId'] = $this->verifyId;
  4269. $data ['executeId'] = $this->executeId;
  4270. $this->render ( "/admin/expensesCollect", $data );
  4271. }
  4272. function approvalExpenses() {
  4273. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  4274. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4275. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4276. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4277. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4278. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  4279. // echo $rdate;
  4280. if (empty ( $status ))
  4281. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4282. $page_size = 8;
  4283. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  4284. $vidList = array ();
  4285. $button = 0;
  4286. Doo::loadModel ( 'verify' );
  4287. $verify = new verify ();
  4288. Doo::loadModel ( 'receipt' );
  4289. $receipt = new receipt ();
  4290. Doo::loadModel ( 'staff' );
  4291. $staff = new staff ();
  4292. Doo::loadModel ( 'L_category' );
  4293. $Lcategory = new L_category ();
  4294. // user verify ID
  4295. $verifyDetail = $verify->find ( array (
  4296. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4297. 'asArray' => true
  4298. ) );
  4299. foreach ( $verifyDetail as $key => $value ) {
  4300. array_push ( $vidList, $value ['vid'] );
  4301. }
  4302. $vid = implode ( ",", $vidList );
  4303. if (empty ( $verifyDetail ))
  4304. $vid = 0;
  4305. // if ($status==0)
  4306. // $dateCondition="";
  4307. // else
  4308. $dateCondition = " ";
  4309. // if (! empty ( $month ))
  4310. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  4311. if ($status == 'done' || $status == 'termination') {
  4312. if (! empty ( $year )) {
  4313. $dateCondition = " and Year(pastDate) =" . $year;
  4314. if (! empty ( $month ))
  4315. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4316. }
  4317. } elseif ($status == 'finish') {
  4318. if (! empty ( $year )) {
  4319. $dateCondition = " and Year(pastDate) =" . $year;
  4320. if (! empty ( $month ))
  4321. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  4322. }
  4323. }
  4324. // date ( 'Y-m' )
  4325. // if (! empty ( $rdate ) && $status == 'done')
  4326. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  4327. // elseif (! empty ( $rdate ))
  4328. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  4329. $categoryList = $Lcategory->find ( array (
  4330. 'asArray' => true
  4331. ) );
  4332. $staffList = $staff->find ( array (
  4333. 'where' => 'cid=' . $cid,
  4334. 'asArray' => true
  4335. ) );
  4336. $cateCondition = "";
  4337. $staffCondition = "";
  4338. $approvalCondition = "";
  4339. if (! empty ( $cid )) {
  4340. $cateCondition = ' and cid=' . $cid;
  4341. }
  4342. if (! empty ( $sid )) {
  4343. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  4344. $cateCondition = "";
  4345. }
  4346. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  4347. if ($status == 'pendApproval') {
  4348. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4349. }
  4350. if ($status == 'ongoing') {
  4351. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  4352. }
  4353. if ($status == 'done') {
  4354. $approvalCondition = ' and (status=8 or status=9 ) ';
  4355. }
  4356. if ($status == 'termination') {
  4357. $approvalCondition = " and status=3";
  4358. }
  4359. if ($status == 'finish') {
  4360. $approvalCondition = " and (status=1 or status=8 or status=9 or status=10)";
  4361. }
  4362. $pageinfo ['page'] = array (
  4363. 'previous' => ''
  4364. );
  4365. if(!empty($receiptOrder)){
  4366. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4367. $receiptList = $receipt->find ( array ( // $dateCondition
  4368. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  4369. 'desc' => 'rid',
  4370. 'asArray' => true
  4371. ) );
  4372. }else{
  4373. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  4374. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  4375. $receiptList = $receipt->find ( array ( // $dateCondition.
  4376. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4377. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  4378. 'desc' => 'rid',
  4379. 'asArray' => true
  4380. ) );
  4381. } else {
  4382. $receiptList = $receipt->find ( array ( // $dateCondition
  4383. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  4384. 'desc' => 'rid',
  4385. 'asArray' => true
  4386. ) );
  4387. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4388. }
  4389. }
  4390. $rLRes = $receipt->find ( array (
  4391. '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 . ')',
  4392. 'desc' => 'rid',
  4393. 'asArray' => true
  4394. ) );
  4395. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  4396. // print_r($receiptList);
  4397. Doo::loadClass ( 'XDeode' );
  4398. $XDeode = new XDeode ( 7 );
  4399. $Locate = 0;
  4400. //
  4401. $reportList = $reportCateList = array ();
  4402. foreach ( $receiptList as $key => $value ) {
  4403. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4404. $receiptList [$key] ['Locate'] = $Locate;
  4405. $Locate ++;
  4406. $receiptList [$key] ['reviseDetail'] = array ();
  4407. if (! empty ( $value ['reviseDetail'] ))
  4408. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4409. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4410. $categoryDetil = $Lcategory->getOne ( array (
  4411. 'where' => 'cid=' . $value ['cid'],
  4412. 'asArray' => true
  4413. ) );
  4414. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4415. $verifyList = $verify->getOne ( array (
  4416. 'where' => 'vid=' . $value ['verify'],
  4417. 'asArray' => true
  4418. ) );
  4419. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4420. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4421. foreach ( $verifyList as $k => $v ) {
  4422. // init verifyStaff
  4423. $verifyList [$k] ['date'] = "";
  4424. $verifyList [$k] ['opinion'] = "";
  4425. $verifyList [$k] ['status'] = "";
  4426. if (empty ( $verifyStaff )) {
  4427. $verifyList [$k] ['date'] = "";
  4428. $verifyList [$k] ['opinion'] = "";
  4429. if ($v [0] == $this->staff [0] ['sid']) {
  4430. $verifyList [$k] ['status'] = 4;
  4431. $button = 4;
  4432. }
  4433. } else {
  4434. $flag = true;
  4435. foreach ( $verifyStaff as $m => $u ) {
  4436. if ($v [0] == $m) {
  4437. $verifyList [$k] ['date'] = $u ['date'];
  4438. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4439. $verifyList [$k] ['status'] = $u ['status'];
  4440. $flag = false;
  4441. break;
  4442. }
  4443. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  4444. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  4445. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  4446. }
  4447. if ($flag) { // 检测可编辑
  4448. if ($v [0] == $this->staff [0] ['sid']) {
  4449. $verifyList [$k] ['status'] = 4;
  4450. $button = 4;
  4451. }
  4452. }
  4453. }
  4454. }
  4455. $receiptList [$key] ['verifyList'] = $verifyList;
  4456. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4457. 'where' => 'sid=' . $value ['staff'],
  4458. 'asArray' => true
  4459. ) );
  4460. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4461. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  4462. $receiptList [$key] ['button'] = $button;
  4463. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  4464. //获得培训班结算RID 借款费用--已经锁定
  4465. if($value['status']==10){
  4466. $trainRD=$receipt->getReceiptByTrainLoanRid($value['rid']);
  4467. $receiptList [$key]['trainRidKey7']=$trainRD['ridKey7'];
  4468. }
  4469. }
  4470. $reportList = array_unique ( $reportList );
  4471. $reportHtml = '';
  4472. foreach ( $reportList as $key => $value ) {
  4473. $v = explode ( "-", $value );
  4474. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  4475. }
  4476. // print_r($reportList)
  4477. $data ['reportHtml'] = $reportHtml;
  4478. $reportCateList = array_unique ( $reportCateList );
  4479. $reportCateHtml = '';
  4480. foreach ( $reportCateList as $key => $value ) {
  4481. $v = explode ( "-", $value );
  4482. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  4483. }
  4484. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  4485. $data ['reportCateHtml'] = $reportCateHtml;
  4486. // print_r($receiptList);die;
  4487. // $data['verifyDetail']=$verifyDetail;
  4488. $mothHtml = "";
  4489. for($i = 1; $i <= 12; $i ++) {
  4490. if ($month == $i)
  4491. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  4492. else
  4493. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  4494. }
  4495. $data ['mothHtml'] = $mothHtml;
  4496. $dateHtml = "";
  4497. $now = date ( "Y" );
  4498. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  4499. if ($YEARD <= $now) {
  4500. $dateHtml .= '<option ';
  4501. if ($year == $YEARD) {
  4502. $dateHtml .= 'selected ';
  4503. }
  4504. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  4505. }
  4506. }
  4507. $data ['dateHtml'] = $dateHtml;
  4508. $data ['page'] = $pageinfo;
  4509. $data ['receiptList'] = $receiptList;
  4510. $data ['receiptApprovalCount'] = count ( $rLRes );
  4511. $data ['status'] = $status;
  4512. $data ['year'] = $year;
  4513. $data ['month'] = $month;
  4514. $data ['categoryList'] = $categoryList;
  4515. $data ['staffList'] = $staffList;
  4516. $data ['cid'] = $cid;
  4517. $data ['sid'] = $sid;
  4518. // print_r($receiptList);
  4519. $data['receiptOrder']=$receiptOrder;
  4520. $data ['memu'] = "receipt";
  4521. $data ['staff'] = $this->staff;
  4522. $data ['receiptMemu'] = 'approvalExpenses';
  4523. $data ['verifyId'] = $this->verifyId;
  4524. $data ['executeId'] = $this->executeId;
  4525. $this->render ( "/admin/approvalExpenses", $data );
  4526. }
  4527. function expensesDoc() {
  4528. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  4529. Doo::loadClass ( 'XDeode' );
  4530. $XDeode = new XDeode ( 5 );
  4531. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  4532. $rid = $XDeode->decode ( $rid );
  4533. if (! is_numeric ( $rid ))
  4534. die ( 'illegal request' );
  4535. Doo::loadModel ( 'receipt' );
  4536. $receipt = new receipt ();
  4537. Doo::loadModel ( 'L_category' );
  4538. $Lcategory = new L_category ();
  4539. Doo::loadModel ( 'verify' );
  4540. Doo::loadModel ( 'statistics' );
  4541. $statistics = new statistics ();
  4542. $verify = new verify ();
  4543. Doo::loadModel ( 'staff' );
  4544. $staff = new staff ();
  4545. Doo::loadModel ( 'loanReceipt' );
  4546. $loanReceipt = new loanReceipt ();
  4547. $receiptList = $receipt->find ( array (
  4548. 'where' => ' rid=' . $rid,
  4549. 'desc' => 'rid',
  4550. 'asArray' => true
  4551. ) );
  4552. $loanList = array ();
  4553. if (! empty ( $receiptList ))
  4554. $loanList = $loanReceipt->find ( array (
  4555. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4556. 'desc' => 'rid',
  4557. 'asArray' => true
  4558. ) );
  4559. $Locate = 0;
  4560. $roleId = 0;
  4561. $button = 0;
  4562. foreach ( $loanList as $key => $value ) {
  4563. $loanList [$key] ['Locate'] = $Locate;
  4564. $Locate ++;
  4565. $loanList [$key] ['reviseDetail'] = array ();
  4566. if (! empty ( $value ['reviseDetail'] ))
  4567. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4568. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4569. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4570. $categoryDetil = $Lcategory->getOne ( array (
  4571. 'where' => 'cid=' . $value ['cid'],
  4572. 'asArray' => true
  4573. ) );
  4574. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4575. // 检测编辑状态
  4576. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  4577. $verifyList ['staff'] = $value ['verifyBreakup'];
  4578. else
  4579. $verifyList = $verify->getOne ( array (
  4580. 'where' => 'vid=' . $value ['verify'],
  4581. 'asArray' => true
  4582. ) );
  4583. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4584. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4585. Doo::loadModel ( 'role' );
  4586. $role = new role ();
  4587. $flag = true;
  4588. $roleKey = 0;
  4589. $endStaffArray = array ();
  4590. $roleArrayCopy = array ();
  4591. foreach ( $verifyList as $k => $v ) {
  4592. // init verifyStaff
  4593. if ($v [1] == 'ROLE') {
  4594. if (! empty ( $verifyStaff )) {
  4595. $endStaffArray = end ( $verifyStaff );
  4596. // if ($v[0]==$endStaffArray['nextStaff']){
  4597. // $roleId=$v[0];
  4598. // }
  4599. }
  4600. $roleVerify = json_decode ( $v [3], true );
  4601. $roleKey = $k;
  4602. $roleArray = array ();
  4603. $rolename = $role->getOne ( array (
  4604. 'where' => 'rid=' . $v [0],
  4605. 'asArray' => true
  4606. ) );
  4607. foreach ( $roleVerify as $o => $p ) {
  4608. $staffID = explode ( '_', $p );
  4609. $staffInfo = $staff->getOne ( array (
  4610. 'where' => 'sid=' . $staffID [0],
  4611. 'asArray' => true
  4612. ) );
  4613. // print_r($staffID);
  4614. $exp = array (
  4615. 0 => $staffInfo ['sid'],
  4616. 1 => $staffID [1],
  4617. 2 => $staffInfo ['avatar'],
  4618. 'date' => '',
  4619. 'date' => '',
  4620. 'opinion' => '',
  4621. 'status' => '',
  4622. 'rolename' => $rolename ['name']
  4623. );
  4624. array_push ( $roleArray, $exp );
  4625. }
  4626. $roleArrayCopy [$v [0]] = $roleArray;
  4627. // $verifyList[$k]['roleArray']=$roleArray;
  4628. }
  4629. $verifyList [$k] ['date'] = "";
  4630. $verifyList [$k] ['opinion'] = "";
  4631. $verifyList [$k] ['status'] = "";
  4632. if (empty ( $verifyStaff )) {
  4633. $verifyList [$k] ['date'] = "";
  4634. $verifyList [$k] ['opinion'] = "";
  4635. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4636. $verifyList [$k] ['status'] = 4;
  4637. $flag = false;
  4638. }
  4639. } else {
  4640. foreach ( $verifyStaff as $m => $u ) {
  4641. if ($v [0] == $m) {
  4642. $verifyList [$k] ['date'] = $u ['date'];
  4643. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4644. $verifyList [$k] ['status'] = $u ['status'];
  4645. $flag = false;
  4646. break;
  4647. }
  4648. }
  4649. $endStaffArray = end ( $verifyStaff );
  4650. if (isset ( $endStaffArray ['ROLE'] )) {
  4651. } else {
  4652. // $endKey=key($verifyStaff);
  4653. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4654. // $button=4;
  4655. // $verifyList[$k]['status']=4;
  4656. // }
  4657. }
  4658. }
  4659. }
  4660. $rolename ['name'] = '';
  4661. if (! empty ( $roleId )) {
  4662. Doo::loadModel ( 'role' );
  4663. $role = new role ();
  4664. $rolename = $role->getOne ( array (
  4665. 'where' => 'rid=' . $roleId,
  4666. 'asArray' => true
  4667. ) );
  4668. }
  4669. if (! empty ( $verifyStaff ))
  4670. $endStaffArray = end ( $verifyStaff );
  4671. $KOP = false;
  4672. foreach ( $roleArrayCopy as $P => $A ) {
  4673. foreach ( $A as $MKI => $AVL ) {
  4674. if (! empty ( $verifyStaff )) {
  4675. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4676. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4677. $button = 4;
  4678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4679. }
  4680. foreach ( $verifyStaff as $m => $u ) {
  4681. $AVLFK = $AVL [0] . '_R';
  4682. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4683. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4684. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4685. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4686. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4687. break;
  4688. }
  4689. }
  4690. } else {
  4691. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4692. $button = 4;
  4693. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4694. }
  4695. }
  4696. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4697. $KOP = true;
  4698. }
  4699. }
  4700. foreach ( $roleArrayCopy as $k => $v ) {
  4701. foreach ( $verifyList as $m => $n ) {
  4702. if ($n [0] == $k) {
  4703. array_splice ( $verifyList, $m, 1, $v );
  4704. }
  4705. }
  4706. }
  4707. $loanList [$key] ['verifyList'] = $verifyList;
  4708. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4709. 'where' => 'sid=' . $value ['staff'],
  4710. 'asArray' => true
  4711. ) );
  4712. $loanList [$key] ['button'] = $button;
  4713. //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  4714. }
  4715. $data ['loanList'] = $loanList;
  4716. //print_r($loanList);
  4717. $Locate = 0;
  4718. $roleId = 0;
  4719. $button = 0;
  4720. foreach ( $receiptList as $key => $value ) {
  4721. $receiptList [$key] ['Locate'] = $Locate;
  4722. $Locate ++;
  4723. $receiptList [$key] ['reviseDetail'] = array ();
  4724. if (! empty ( $value ['reviseDetail'] ))
  4725. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4726. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4727. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4728. $categoryDetil = $Lcategory->getOne ( array (
  4729. 'where' => 'cid=' . $value ['cid'],
  4730. 'asArray' => true
  4731. ) );
  4732. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4733. // 检测编辑状态
  4734. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  4735. $verifyList ['staff'] = $value ['verifyBreakup'];
  4736. } else
  4737. $verifyList = $verify->getOne ( array (
  4738. 'where' => 'vid=' . $value ['verify'],
  4739. 'asArray' => true
  4740. ) );
  4741. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4742. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4743. Doo::loadModel ( 'role' );
  4744. $role = new role ();
  4745. if ($verifyList == NULL)
  4746. $verifyList = array ();
  4747. $flag = true;
  4748. $roleKey = 0;
  4749. $endStaffArray = array ();
  4750. $roleArrayCopy = array ();
  4751. foreach ( $verifyList as $k => $v ) {
  4752. // init verifyStaff
  4753. if ($v [1] == 'ROLE') {
  4754. if (! empty ( $verifyStaff )) {
  4755. $endStaffArray = end ( $verifyStaff );
  4756. // if ($v[0]==$endStaffArray['nextStaff']){
  4757. // $roleId=$v[0];
  4758. // }
  4759. }
  4760. $roleVerify = json_decode ( $v [3], true );
  4761. $roleKey = $k;
  4762. $roleArray = array ();
  4763. $rolename = $role->getOne ( array (
  4764. 'where' => 'rid=' . $v [0],
  4765. 'asArray' => true
  4766. ) );
  4767. foreach ( $roleVerify as $o => $p ) {
  4768. $staffID = explode ( '_', $p );
  4769. $staffInfo = $staff->getOne ( array (
  4770. 'where' => 'sid=' . $staffID [0],
  4771. 'asArray' => true
  4772. ) );
  4773. // print_r($staffID);
  4774. $exp = array (
  4775. 0 => $staffInfo ['sid'],
  4776. 1 => $staffID [1],
  4777. 2 => $staffInfo ['avatar'],
  4778. 'date' => '',
  4779. 'date' => '',
  4780. 'opinion' => '',
  4781. 'status' => '',
  4782. 'rolename' => $rolename ['name']
  4783. );
  4784. array_push ( $roleArray, $exp );
  4785. }
  4786. $roleArrayCopy [$v [0]] = $roleArray;
  4787. // $verifyList[$k]['roleArray']=$roleArray;
  4788. }
  4789. $verifyList [$k] ['date'] = "";
  4790. $verifyList [$k] ['opinion'] = "";
  4791. $verifyList [$k] ['status'] = "";
  4792. if (empty ( $verifyStaff )) {
  4793. $verifyList [$k] ['date'] = "";
  4794. $verifyList [$k] ['opinion'] = "";
  4795. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4796. $verifyList [$k] ['status'] = 4;
  4797. $flag = false;
  4798. }
  4799. } else {
  4800. foreach ( $verifyStaff as $m => $u ) {
  4801. if ($v [0] == $m) {
  4802. $verifyList [$k] ['date'] = $u ['date'];
  4803. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4804. $verifyList [$k] ['status'] = $u ['status'];
  4805. $flag = false;
  4806. break;
  4807. }
  4808. }
  4809. $endStaffArray = end ( $verifyStaff );
  4810. if (isset ( $endStaffArray ['ROLE'] )) {
  4811. } else {
  4812. // $endKey=key($verifyStaff);
  4813. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4814. // $button=4;
  4815. // $verifyList[$k]['status']=4;
  4816. // }
  4817. }
  4818. }
  4819. }
  4820. $FC = @$rolename ['name'];
  4821. $rolename ['name'] = '';
  4822. if (! empty ( $roleId )) {
  4823. Doo::loadModel ( 'role' );
  4824. $role = new role ();
  4825. $rolename = $role->getOne ( array (
  4826. 'where' => 'rid=' . $roleId,
  4827. 'asArray' => true
  4828. ) );
  4829. }
  4830. if (! empty ( $verifyStaff ))
  4831. $endStaffArray = end ( $verifyStaff );
  4832. $KOP = false;
  4833. foreach ( $roleArrayCopy as $P => $A ) {
  4834. foreach ( $A as $MKI => $AVL ) {
  4835. if (! empty ( $verifyStaff )) {
  4836. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4837. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4838. $button = 4;
  4839. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4840. }
  4841. foreach ( $verifyStaff as $m => $u ) {
  4842. $AVLFK = $AVL [0] . '_R';
  4843. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4844. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4845. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4846. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4847. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4848. break;
  4849. }
  4850. }
  4851. } else {
  4852. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4853. $button = 4;
  4854. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4855. }
  4856. }
  4857. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4858. $KOP = true;
  4859. }
  4860. }
  4861. foreach ( $roleArrayCopy as $k => $v ) {
  4862. foreach ( $verifyList as $m => $n ) {
  4863. if ($n [0] == $k) {
  4864. array_splice ( $verifyList, $m, 1, $v );
  4865. }
  4866. }
  4867. }
  4868. // 费用执行人相关数据
  4869. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4870. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4871. foreach ( $executeCopy as $k => $v ) {
  4872. $executeCopy [$k] ['date'] = '';
  4873. $executeCopy [$k] ['opinion'] = '';
  4874. $executeCopy [$k] ['status'] = '';
  4875. if (! empty ( $executeStaff ))
  4876. foreach ( $executeStaff as $m => $u ) {
  4877. if ($v [0] == $m) {
  4878. $executeCopy [$k] ['date'] = $u ['date'];
  4879. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4880. $executeCopy [$k] ['status'] = $u ['status'];
  4881. break;
  4882. }
  4883. }
  4884. }
  4885. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4886. // print_r($verifyList);
  4887. $receiptList [$key] ['verifyList'] = $verifyList;
  4888. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4889. 'where' => 'sid=' . $value ['staff'],
  4890. 'asArray' => true
  4891. ) );
  4892. $receiptList [$key] ['button'] = $button;
  4893. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4894. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4895. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4896. $receiptList [$key] ['relust'] = $relust;
  4897. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4898. }
  4899. // print_r($receiptList);
  4900. // 获取审批日志
  4901. Doo::loadModel ( 'receiptLog' );
  4902. $receiptLog = new receiptLog ();
  4903. $rlList = array ();
  4904. $rlInfo = $receiptLog->getOne ( array (
  4905. 'where' => 'rid=' . $rid . ' and status=4',
  4906. 'asArray' => true
  4907. ) );
  4908. // $tijdate = $receiptLog->getOne ( array (
  4909. // 'where' => 'rid=' . $rid . ' and status=2',
  4910. // 'asc' => 'rlid',
  4911. // 'asArray' => true
  4912. // ) );
  4913. if (! empty ( $rlInfo )) {
  4914. $rlList = $receiptLog->find ( array (
  4915. 'where' => 'rid=' . $rid,
  4916. 'asc' => 'rlid',
  4917. 'asArray' => true
  4918. ) );
  4919. }
  4920. $RN=array();
  4921. if (!empty( $rolename ['staff'])){
  4922. $RN = @json_decode ( $rolename ['staff'] );
  4923. }
  4924. //
  4925. foreach ( $rlList as $key => $value ) {
  4926. $rlList [$key] ['rolename'] = '';
  4927. foreach ( $RN as $k => $v ) {
  4928. $id = explode ( "_", $v );
  4929. if ($id [0] == $value ['uid']) {
  4930. $rlList [$key] ['rolename'] = $FC;
  4931. break;
  4932. }
  4933. }
  4934. }
  4935. Doo::loadModel ( 'enclosur' );
  4936. $enclosur = new enclosur ();
  4937. $enclosurList = $enclosur->find ( array (
  4938. 'where' => 'rid=' . $rid,
  4939. 'asArray' => true
  4940. ) );
  4941. $enclosurHtml = '';
  4942. foreach ( $enclosurList as $value ) {
  4943. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4944. }
  4945. $data ['enclosurHtml'] = $enclosurHtml;
  4946. $receiptList [0] ['rlList'] = $rlList;
  4947. $data ['receiptList'] = $receiptList;
  4948. // print_r($receiptList);
  4949. $data ['memu'] = "receipt";
  4950. $data ['staff'] = $this->staff;
  4951. $data ['receiptMemu'] = 'approvalExpenses';
  4952. $data ['verifyId'] = $this->verifyId;
  4953. $data ['executeId'] = $this->executeId;
  4954. $this->render ( "/admin/expensesDoc", $data );
  4955. }
  4956. function expensesEdi() {
  4957. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4958. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4959. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4960. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4961. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4962. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4963. if (empty ( $status ))
  4964. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4965. $vidList = array ();
  4966. $button = 0;
  4967. Doo::loadModel ( 'verify' );
  4968. Doo::loadModel ( 'receipt' );
  4969. Doo::loadModel ( 'staff' );
  4970. $staff = new staff ();
  4971. $receipt = new receipt ();
  4972. $verify = new verify ();
  4973. Doo::loadModel ( 'L_category' );
  4974. $Lcategory = new L_category ();
  4975. Doo::loadModel ( 'enclosur' );
  4976. $enclosur = new enclosur ();
  4977. // user verify ID
  4978. $verifyDetail = $verify->find ( array (
  4979. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4980. 'asArray' => true
  4981. ) );
  4982. foreach ( $verifyDetail as $key => $value ) {
  4983. array_push ( $vidList, $value ['vid'] );
  4984. }
  4985. $vid = implode ( ",", $vidList );
  4986. if (empty ( $verifyDetail ))
  4987. $vid = 0;
  4988. $categoryList = $Lcategory->find ( array (
  4989. 'asArray' => true
  4990. ) );
  4991. $staffList = $staff->find ( array (
  4992. 'where' => 'cid=' . $cid,
  4993. 'asArray' => true
  4994. ) );
  4995. $ap = "";
  4996. if ($status == 4) {
  4997. $ap = 4;
  4998. $status = 2;
  4999. }
  5000. // get Receipt By verifyID status 2
  5001. $receiptList = $receipt->find ( array (
  5002. 'where' => 'rid =' . $rid . ' and status=2',
  5003. 'desc' => 'rid',
  5004. 'asArray' => true
  5005. ) );
  5006. if (empty ( $receiptList )) {
  5007. die ( 'illegal request' );
  5008. }
  5009. $Locate = 0;
  5010. $roleId = 0;
  5011. if ($ap == 4)
  5012. $status = 4;
  5013. foreach ( $receiptList as $key => $value ) {
  5014. $receiptList [$key] ['Locate'] = $Locate;
  5015. $Locate ++;
  5016. $receiptList [$key] ['reviseDetail'] = array ();
  5017. if (! empty ( $value ['reviseDetail'] ))
  5018. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5019. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5020. $categoryDetil = $Lcategory->getOne ( array (
  5021. 'where' => 'cid=' . $value ['cid'],
  5022. 'asArray' => true
  5023. ) );
  5024. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5025. // 检测编辑状态
  5026. $verifyList = $verify->getOne ( array (
  5027. 'where' => 'vid=' . $value ['verify'],
  5028. 'asArray' => true
  5029. ) );
  5030. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5031. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5032. Doo::loadModel ( 'role' );
  5033. $role = new role ();
  5034. // print_r($verifyList);
  5035. $flag = true;
  5036. $roleKey = 0;
  5037. $endStaffArray = array ();
  5038. $roleArrayCopy = array ();
  5039. foreach ( $verifyList as $k => $v ) {
  5040. // init verifyStaff
  5041. if ($v [1] == 'ROLE') {
  5042. if (! empty ( $verifyStaff )) {
  5043. $endStaffArray = end ( $verifyStaff );
  5044. if ($v [0] == $endStaffArray ['nextStaff']) {
  5045. $roleId = $v [0];
  5046. }
  5047. }
  5048. $roleVerify = json_decode ( $v [3], true );
  5049. $roleKey = $k;
  5050. $roleArray = array ();
  5051. $rolename = $role->getOne ( array (
  5052. 'where' => 'rid=' . $v [0],
  5053. 'asArray' => true
  5054. ) );
  5055. foreach ( $roleVerify as $o => $p ) {
  5056. $staffID = explode ( '_', $p );
  5057. $staffInfo = $staff->getOne ( array (
  5058. 'where' => 'sid=' . $staffID [0],
  5059. 'asArray' => true
  5060. ) );
  5061. // print_r($staffID);
  5062. $exp = array (
  5063. 0 => $staffInfo ['sid'],
  5064. 1 => $staffID [1],
  5065. 2 => $staffInfo ['avatar'],
  5066. 'date' => '',
  5067. 'date' => '',
  5068. 'opinion' => '',
  5069. 'status' => '',
  5070. 'rolename' => $rolename ['name']
  5071. );
  5072. array_push ( $roleArray, $exp );
  5073. }
  5074. $roleArrayCopy [$v [0]] = $roleArray;
  5075. // $verifyList[$k]['roleArray']=$roleArray;
  5076. }
  5077. // print_r($roleArray);
  5078. $verifyList [$k] ['date'] = "";
  5079. $verifyList [$k] ['opinion'] = "";
  5080. $verifyList [$k] ['status'] = "";
  5081. if (empty ( $verifyStaff )) {
  5082. $verifyList [$k] ['date'] = "";
  5083. $verifyList [$k] ['opinion'] = "";
  5084. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5085. $verifyList [$k] ['status'] = 4;
  5086. $button = 4;
  5087. $flag = false;
  5088. }
  5089. } else {
  5090. foreach ( $verifyStaff as $m => $u ) {
  5091. if ($v [0] == $m) {
  5092. $verifyList [$k] ['date'] = $u ['date'];
  5093. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5094. $verifyList [$k] ['status'] = $u ['status'];
  5095. $flag = false;
  5096. break;
  5097. }
  5098. }
  5099. $endStaffArray = end ( $verifyStaff );
  5100. if (isset ( $endStaffArray ['ROLE'] )) {
  5101. } else {
  5102. $endKey = key ( $verifyStaff );
  5103. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5104. $button = 4;
  5105. $verifyList [$k] ['status'] = 4;
  5106. }
  5107. }
  5108. }
  5109. }
  5110. $rolename ['name'] = '';
  5111. if (! empty ( $roleId )) {
  5112. Doo::loadModel ( 'role' );
  5113. $role = new role ();
  5114. $rolename = $role->getOne ( array (
  5115. 'where' => 'rid=' . $roleId,
  5116. 'asArray' => true
  5117. ) );
  5118. }
  5119. if (! empty ( $verifyStaff ))
  5120. $endStaffArray = end ( $verifyStaff );
  5121. $KOP = false;
  5122. foreach ( $roleArrayCopy as $P => $A ) {
  5123. foreach ( $A as $MKI => $AVL ) {
  5124. if (! empty ( $verifyStaff )) {
  5125. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5126. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5127. $button = 4;
  5128. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5129. }
  5130. foreach ( $verifyStaff as $m => $u ) {
  5131. $AVLFK = $AVL [0] . '_R';
  5132. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5133. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5134. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5135. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5136. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5137. break;
  5138. }
  5139. }
  5140. } else {
  5141. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5142. $button = 4;
  5143. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5144. }
  5145. }
  5146. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5147. $KOP = true;
  5148. }
  5149. }
  5150. // print_r($roleArrayCopy);
  5151. // echo $roleKey;
  5152. foreach ( $roleArrayCopy as $k => $v ) {
  5153. foreach ( $verifyList as $m => $n ) {
  5154. if ($n [0] == $k) {
  5155. array_splice ( $verifyList, $m, 1, $v );
  5156. }
  5157. }
  5158. }
  5159. $receiptList [$key] ['verifyList'] = $verifyList;
  5160. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5161. 'where' => 'sid=' . $value ['staff'],
  5162. 'asArray' => true
  5163. ) );
  5164. $receiptList [$key] ['button'] = $button;
  5165. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  5166. }
  5167. // $data['verifyDetail']=$verifyDetail;
  5168. $mothHtml = "";
  5169. for($i = 1; $i <= 12; $i ++) {
  5170. if ($month == $i)
  5171. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5172. else
  5173. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5174. }
  5175. // 获取审批日志
  5176. Doo::loadModel ( 'receiptLog' );
  5177. $receiptLog = new receiptLog ();
  5178. $rlList = array ();
  5179. $rlInfo = $receiptLog->getOne ( array (
  5180. 'where' => 'rid=' . $rid . ' and status=4',
  5181. 'asArray' => true
  5182. ) );
  5183. $tijdate = $receiptLog->getOne ( array (
  5184. 'where' => 'rid=' . $rid . ' and status=2',
  5185. 'asc' => 'rlid',
  5186. 'asArray' => true
  5187. ) );
  5188. if (! empty ( $rlInfo )) {
  5189. $rlList = $receiptLog->find ( array (
  5190. 'where' => 'rid=' . $rid,
  5191. 'asc' => 'rlid',
  5192. 'asArray' => true
  5193. ) );
  5194. }
  5195. $receiptList [0] ['rlList'] = $rlList;
  5196. $enclosurList = $enclosur->find ( array (
  5197. 'where' => 'rid=' . $rid,
  5198. 'asArray' => true
  5199. ) );
  5200. $enclosurHtml = '';
  5201. foreach ( $enclosurList as $value ) {
  5202. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5203. }
  5204. // print_r($receiptList);
  5205. $data ['rid'] = $rid;
  5206. $data ['enclosurHtml'] = $enclosurHtml;
  5207. $data ['rolename'] = $rolename ['name'];
  5208. $data ['datetij'] = $tijdate ['date'];
  5209. $data ['mothHtml'] = $mothHtml;
  5210. $data ['receiptList'] = $receiptList;
  5211. $data ['receiptApprovalCount'] = count ( $receiptList );
  5212. $data ['status'] = $status;
  5213. $data ['year'] = $year;
  5214. $data ['categoryList'] = $categoryList;
  5215. $data ['staffList'] = $staffList;
  5216. $data ['cid'] = $cid;
  5217. $data ['sid'] = $sid;
  5218. $data ['ap'] = $ap;
  5219. $data ['memu'] = "receipt";
  5220. $data ['staff'] = $this->staff;
  5221. $data ['receiptMemu'] = 'approvalExpenses';
  5222. $data ['verifyId'] = $this->verifyId;
  5223. $data ['executeId'] = $this->executeId;
  5224. $this->render ( "/admin/expensesEdi", $data );
  5225. }
  5226. function expensesDefray() {
  5227. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5228. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  5229. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5230. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  5231. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  5232. if (! empty ( $rid )) {
  5233. Doo::loadModel ( "verify" );
  5234. $verify = new verify ();
  5235. Doo::loadModel ( "receiptDetail" );
  5236. $receiptDetailObj = new receiptDetail ();
  5237. Doo::loadModel ( "itemStatistics" );
  5238. Doo::loadModel ( "statistics" );
  5239. $statistics = new statistics ();
  5240. $itemStatistics = new itemStatistics ();
  5241. Doo::loadModel ( "receipt" );
  5242. $receipt = new receipt ();
  5243. Doo::loadModel ( "loanReceipt" );
  5244. $loanReceipt = new loanReceipt ();
  5245. $receiptDetail = $receipt->getOne ( array (
  5246. 'where' => 'rid=' . $rid . ' and status=2 ',
  5247. 'asArray' => true
  5248. ) );
  5249. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  5250. $nsflag = true;
  5251. foreach ( $nslist as $value ) {
  5252. if ($value == $this->staff ['0'] ['sid']) {
  5253. $nsflag = false;
  5254. break;
  5255. }
  5256. }
  5257. // print_r($nslist);die;
  5258. if (empty ( $receiptDetail ) || $nsflag)
  5259. return "/approvalExpenses/pendApproval";
  5260. $verifyDetail = $verify->getOne ( array (
  5261. 'where' => ' vid =' . $receiptDetail ['verify'],
  5262. 'asArray' => true
  5263. ) );
  5264. $verifyString = $verifyDetail ['staff'];
  5265. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5266. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  5267. if (empty ( $opinion )) {
  5268. if ($status == 3)
  5269. $opinion = "终止";
  5270. else
  5271. $opinion = "同意支付";
  5272. }
  5273. $nowStaff = 0;
  5274. $nowStaffList = array ();
  5275. if (empty ( $verifyStaff )) {
  5276. // 还需加入是否已经进入角色审批
  5277. if ($verifyDetail [0] [1] == 'ROLE') {
  5278. // print_r($verifyDetail);echo "ddd";
  5279. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5280. foreach ( $vStaffString as $key => $value ) {
  5281. $staffK = explode ( "_", $value );
  5282. if ($staffK [0] != $this->staff [0] ['sid'])
  5283. array_push ( $nowStaffList, $staffK [0] );
  5284. }
  5285. // print_r($verifyDetail);
  5286. // die;
  5287. if (! empty ( $nowStaffList )) {
  5288. $nowStaff = implode ( ',', $nowStaffList );
  5289. $verifyStaff = array (
  5290. $this->staff [0] ['sid'] . "_R" => array (
  5291. 'date' => date ( 'Y-m-d' ),
  5292. 'opinion' => $opinion,
  5293. 'status' => $status,
  5294. 'nextStaff' => $verifyDetail [0] [0],
  5295. 'ROLE' => 1
  5296. )
  5297. );
  5298. } else {
  5299. $nowStaff = $verifyDetail [1] [0];
  5300. $verifyStaff = array (
  5301. $this->staff [0] ['sid'] . "_R" => array (
  5302. 'date' => date ( 'Y-m-d' ),
  5303. 'opinion' => $opinion,
  5304. 'status' => $status,
  5305. 'nextStaff' => $verifyDetail [1] [0]
  5306. )
  5307. );
  5308. }
  5309. } else {
  5310. if ($verifyDetail [1] [1] == 'ROLE') {
  5311. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  5312. // echo "dd";
  5313. foreach ( $vStaffString as $key => $value ) {
  5314. $staffK = explode ( "_", $value );
  5315. array_push ( $nowStaffList, $staffK [0] );
  5316. }
  5317. $nowStaff = implode ( ',', $nowStaffList );
  5318. $verifyStaff = array (
  5319. $this->staff [0] ['sid'] => array (
  5320. 'date' => date ( 'Y-m-d' ),
  5321. 'opinion' => $opinion,
  5322. 'status' => $status,
  5323. 'nextStaff' => $verifyDetail [1] [0],
  5324. 'ROLE' => 1
  5325. )
  5326. );
  5327. } else {
  5328. $nowStaff = $verifyDetail [1] [0];
  5329. $verifyStaff = array (
  5330. $this->staff [0] ['sid'] => array (
  5331. 'date' => date ( 'Y-m-d' ),
  5332. 'opinion' => $opinion,
  5333. 'status' => $status,
  5334. 'nextStaff' => $verifyDetail [1] [0]
  5335. )
  5336. );
  5337. }
  5338. }
  5339. if ($status == 3)
  5340. $verifyStaff = array (
  5341. 'final' => $status,
  5342. $this->staff [0] ['sid'] => array (
  5343. 'date' => date ( 'Y-m-d' ),
  5344. 'opinion' => $opinion,
  5345. 'status' => $status
  5346. )
  5347. );
  5348. $vStaffString = json_encode ( $verifyStaff );
  5349. $receipt->nowStaff = $nowStaff;
  5350. $receipt->verifyStaff = $vStaffString;
  5351. $loanReceipt->nowStaff = $nowStaff;
  5352. $loanReceipt->verifyStaff = $vStaffString;
  5353. } else {
  5354. $VS = end ( $verifyStaff );
  5355. // 非角色审批
  5356. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  5357. $nextStaff = 0;
  5358. $roleSTF = false;
  5359. foreach ( $verifyDetail as $key => $value ) {
  5360. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  5361. if (isset ( $verifyDetail [$key + 1] )) {
  5362. $nextStaff = $verifyDetail [$key + 1] [0];
  5363. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  5364. $roleSTF = true;
  5365. }
  5366. break;
  5367. }
  5368. }
  5369. if (! $roleSTF) {
  5370. $nowStaff = $nextStaff;
  5371. $verifyStaff [$this->staff [0] ['sid']] = array (
  5372. 'date' => date ( 'Y-m-d' ),
  5373. 'opinion' => $opinion,
  5374. 'status' => $status,
  5375. 'nextStaff' => $nextStaff
  5376. );
  5377. } else {
  5378. // 获取角色下的所有用户ID
  5379. $nowStaffList = array ();
  5380. foreach ( $verifyDetail as $vfk ) {
  5381. if ($vfk [1] == 'ROLE') {
  5382. $vStaffString = json_decode ( $vfk [3] );
  5383. foreach ( $vStaffString as $key => $value ) {
  5384. $staffK = explode ( "_", $value );
  5385. array_push ( $nowStaffList, $staffK [0] );
  5386. }
  5387. }
  5388. }
  5389. $nowStaff = implode ( ',', $nowStaffList );
  5390. $verifyStaff [$this->staff [0] ['sid']] = array (
  5391. 'date' => date ( 'Y-m-d' ),
  5392. 'opinion' => $opinion,
  5393. 'status' => $status,
  5394. 'nextStaff' => $nextStaff,
  5395. 'ROLE' => 0
  5396. );
  5397. }
  5398. if ($status == 3) {
  5399. $verifyStaff ['final'] = $status;
  5400. $verifyStaff [$this->staff [0] ['sid']] = array (
  5401. 'date' => date ( 'Y-m-d' ),
  5402. 'opinion' => $opinion,
  5403. 'status' => $status
  5404. );
  5405. }
  5406. $vStaffString = json_encode ( $verifyStaff );
  5407. $receipt->nowStaff = $nowStaff;
  5408. $receipt->verifyStaff = $vStaffString;
  5409. $loanReceipt->nowStaff = $nowStaff;
  5410. $loanReceipt->verifyStaff = $vStaffString;
  5411. }
  5412. // 角色审批
  5413. if (isset ( $VS ['ROLE'] )) {
  5414. // 找出角色人 当前审批角色组
  5415. $verifyJSStaff = array ();
  5416. $nowStaffList2 = array ();
  5417. foreach ( $verifyDetail as $key => $value ) {
  5418. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  5419. $verifyJSStaff = json_decode ( $value [3] );
  5420. foreach ( $verifyJSStaff as $m ) {
  5421. $staffK = explode ( "_", $m );
  5422. array_push ( $nowStaffList2, $staffK [0] );
  5423. }
  5424. // print_r($nowStaffList2);
  5425. }
  5426. }
  5427. $RoleVerifyStaff = array ();
  5428. foreach ( $verifyStaff as $key => $value ) {
  5429. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  5430. foreach ( $nowStaffList2 as $m ) {
  5431. if ($key == $m . "_R")
  5432. $RoleVerifyStaff [$key] = $value;
  5433. }
  5434. }
  5435. }
  5436. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  5437. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  5438. // 下一个审批人ID
  5439. $nextStaff = 0;
  5440. $falg = false;
  5441. foreach ( $verifyDetail as $key => $value ) {
  5442. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  5443. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  5444. $falg = true;
  5445. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  5446. $nowStaffList = array ();
  5447. foreach ( $vStaffString as $v ) {
  5448. $staffK = explode ( "_", $v );
  5449. array_push ( $nowStaffList, $staffK [0] );
  5450. }
  5451. $nowStaff = implode ( ',', $nowStaffList );
  5452. $nextStaff = $verifyDetail [$key + 1] [0];
  5453. } elseif (isset ( $verifyDetail [$key + 1] )) {
  5454. $nextStaff = $verifyDetail [$key + 1] [0];
  5455. $nowStaff = $nextStaff;
  5456. } else
  5457. $nowStaff = '';
  5458. break;
  5459. }
  5460. }
  5461. if ($falg)
  5462. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5463. 'date' => date ( 'Y-m-d' ),
  5464. 'opinion' => $opinion,
  5465. 'status' => $status,
  5466. 'nextStaff' => $nextStaff,
  5467. 'ROLE' => 1
  5468. );
  5469. else
  5470. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5471. 'date' => date ( 'Y-m-d' ),
  5472. 'opinion' => $opinion,
  5473. 'status' => $status,
  5474. 'nextStaff' => $nextStaff
  5475. );
  5476. // print_r($verifyStaff);
  5477. // echo $nowStaff;die;
  5478. } else { // 进入下一个角色或者审批人
  5479. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  5480. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  5481. 'date' => date ( 'Y-m-d' ),
  5482. 'opinion' => $opinion,
  5483. 'status' => $status,
  5484. 'nextStaff' => $VS ['nextStaff'],
  5485. 'ROLE' => 1
  5486. );
  5487. }
  5488. if ($status == 3) {
  5489. $verifyStaff ['final'] = $status;
  5490. $verifyStaff [$this->staff [0] ['sid']] = array (
  5491. 'date' => date ( 'Y-m-d' ),
  5492. 'opinion' => $opinion,
  5493. 'status' => $status
  5494. );
  5495. }
  5496. $vStaffString = json_encode ( $verifyStaff );
  5497. $receipt->verifyStaff = $vStaffString;
  5498. $receipt->nowStaff = $nowStaff;
  5499. $loanReceipt->nowStaff = $nowStaff;
  5500. $loanReceipt->verifyStaff = $vStaffString;
  5501. }
  5502. // print_r($verifyStaff);die;
  5503. }
  5504. $roleKey = 0;
  5505. $roleId = 0;
  5506. $verifyDetailCopy = array ();
  5507. foreach ( $verifyDetail as $k => $v ) {
  5508. if ($v [1] == 'ROLE') {
  5509. $roleId = $v [0];
  5510. $roleVerify = json_decode ( $v [3], true );
  5511. $roleKey = $k;
  5512. $roleArray = array ();
  5513. foreach ( $roleVerify as $o => $p ) {
  5514. $staffID = explode ( '_', $p );
  5515. $exp = array (
  5516. 0 => $staffID [0],
  5517. 1 => $staffID [1]
  5518. );
  5519. array_push ( $roleArray, $exp );
  5520. }
  5521. $verifyDetailCopy [$v [0]] = $roleArray;
  5522. }
  5523. }
  5524. // print_r($verifyDetail);
  5525. foreach ( $verifyDetailCopy as $k => $v ) {
  5526. foreach ( $verifyDetail as $m => $n ) {
  5527. if ($n [0] == $k) {
  5528. array_splice ( $verifyDetail, $m, 1, $v );
  5529. }
  5530. }
  5531. }
  5532. // 审批日志
  5533. if (! isset ( $verifyStaff ['final'] )) {
  5534. Doo::loadModel ( "receiptLog" );
  5535. $receiptLog = new receiptLog ();
  5536. if (! empty ( $roleId )) {
  5537. Doo::loadModel ( "role" );
  5538. $role = new role ();
  5539. $roleInfo = $role->getOne ( array (
  5540. 'where' => 'rid=' . $roleId,
  5541. 'asArray' => true
  5542. ) );
  5543. $receiptLog->rolename = $roleInfo ['name'];
  5544. }
  5545. $receiptLog->username = $this->staff [0] ['username'];
  5546. $receiptLog->uid = $this->staff [0] ['sid'];
  5547. $receiptLog->date = date ( "Y-m-d" );
  5548. $receiptLog->opinion = $opinion;
  5549. $receiptLog->img = $this->staff [0] ['avatar'];
  5550. $receiptLog->status = 1;
  5551. $receiptLog->rid = $rid;
  5552. $receiptLog->insert ();
  5553. }
  5554. if (isset ( $verifyStaff ['final'] )) { // rDetail
  5555. $receipt->status = 3;
  5556. $receipt->verifyBreakup = $verifyString;
  5557. $receiptDetailObj->status = 3;
  5558. $receiptDetailObj->update ( array (
  5559. 'where' => 'rid=' . $rid
  5560. ) );
  5561. // 微信企业号通知
  5562. $this->setWXMsg ( $rid, 3 );
  5563. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  5564. $receipt->status = 6;
  5565. $receipt->pastDate = date ( "Y-m-d" );
  5566. $receipt->isBK = 1;
  5567. $loanReceipt->verifyBreakup = $verifyString;
  5568. $loanReceipt->status = 1;
  5569. $loanReceipt->pastDate = date ( "Y-m-d" );
  5570. //生成流水后 不更新汇款金额
  5571. Doo::loadModel ( 'wasteBook' );
  5572. $wasteBook = new wasteBook ();
  5573. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  5574. if (empty($wbDetail)){
  5575. $loanReceipt->amount = $receiptDetail ['amount'];
  5576. }
  5577. $loanReceipt->update ( array (
  5578. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  5579. ) );
  5580. // 微信企业号通知
  5581. $this->setWXMsg ( $rid, 1 );
  5582. }
  5583. $receipt->amount = $receiptDetail['sum'];
  5584. $receipt->update ( array (
  5585. 'where' => ' rid = ' . $rid
  5586. ) );
  5587. // 进入下一条审批费用新加需求
  5588. $vidList = array ();
  5589. $verifyDetail = $verify->find ( array (
  5590. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  5591. 'asArray' => true
  5592. ) );
  5593. foreach ( $verifyDetail as $key => $value ) {
  5594. array_push ( $vidList, $value ['vid'] );
  5595. }
  5596. $vid = implode ( ",", $vidList );
  5597. if (empty ( $verifyDetail ))
  5598. $vid = 0;
  5599. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  5600. $receipt = new receipt ();
  5601. $rd = $receipt->getOne ( array (
  5602. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  5603. 'asc' => 'rid',
  5604. 'asArray' => true
  5605. ) );
  5606. if (empty ( $rd )) {
  5607. return '/approvalExpenses/pendApproval';
  5608. }
  5609. if ($rd ['Rtype'] == 1) {
  5610. if ($rd ['isBK'] == 1) {
  5611. return '/receiptburEdi/' . $rd ['rid'];
  5612. } else {
  5613. return '/expensesEdi/' . $rd ['rid'];
  5614. }
  5615. } elseif ($rd ['Rtype'] == 2) {
  5616. return '/remitApproval/' . $rd ['rid'];
  5617. } else {
  5618. return '/receiptburEdi/' . $rd ['rid'];
  5619. }
  5620. // return "/approvalExpenses/pendApproval";
  5621. }
  5622. }
  5623. function ajaxExamineExe() {
  5624. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5625. Doo::loadModel ( 'receipt' );
  5626. $receipt = new receipt ();
  5627. Doo::loadClass ( 'XDeode' );
  5628. $XDeode = new XDeode ( 5 );
  5629. if (! empty ( $rid )) {
  5630. $rLRes = $receipt->find ( array (
  5631. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  5632. 'asArray' => true
  5633. ) );
  5634. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  5635. echo json_encode ( array (
  5636. 'status' => 1,
  5637. 'receipt' => $rLRes [0]
  5638. ) );
  5639. die ();
  5640. }
  5641. echo json_encode ( array (
  5642. 'status' => 0,
  5643. 'receipt' => array ()
  5644. ) );
  5645. die ();
  5646. }
  5647. function implement() {
  5648. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5649. $Rtype = isset ( $this->params ['Rtype'] ) ? $this->params ['Rtype'] : '';
  5650. Doo::loadClass ( 'XDeode' );
  5651. $XDeode = new XDeode ( 5 );
  5652. Doo::loadModel ( 'receipt' );
  5653. $receipt = new receipt ();
  5654. Doo::loadModel ( 'L_category' );
  5655. $Lcategory = new L_category ();
  5656. Doo::loadModel ( 'verify' );
  5657. $verify = new verify ();
  5658. Doo::loadModel ( 'staff' );
  5659. $staff = new staff ();
  5660. Doo::loadModel ( "execute" );
  5661. $execute = new execute ();
  5662. $rid = $XDeode->decode ( $rid );
  5663. $receiptList = $receipt->find ( array (
  5664. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  5665. 'desc' => 'rid',
  5666. 'asArray' => true
  5667. ) );
  5668. Doo::loadModel ( 'loanReceipt' );
  5669. $loanReceipt = new loanReceipt ();
  5670. // print_r($receiptList);
  5671. $loanList = array ();
  5672. if (! isset ( $receiptList ))
  5673. $loanList = $loanReceipt->find ( array (
  5674. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5675. 'desc' => 'rid',
  5676. 'asArray' => true
  5677. ) );
  5678. $Locate = 0;
  5679. $roleId = 0;
  5680. $button = 0;
  5681. foreach ( $loanList as $key => $value ) {
  5682. $loanList [$key] ['Locate'] = $Locate;
  5683. $Locate ++;
  5684. $loanList [$key] ['reviseDetail'] = array ();
  5685. if (! empty ( $value ['reviseDetail'] ))
  5686. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5687. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5688. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5689. $categoryDetil = $Lcategory->getOne ( array (
  5690. 'where' => 'cid=' . $value ['cid'],
  5691. 'asArray' => true
  5692. ) );
  5693. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5694. // 检测编辑状态
  5695. $verifyList = $verify->getOne ( array (
  5696. 'where' => 'vid=' . $value ['verify'],
  5697. 'asArray' => true
  5698. ) );
  5699. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5700. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5701. Doo::loadModel ( 'role' );
  5702. $role = new role ();
  5703. $flag = true;
  5704. $roleKey = 0;
  5705. $endStaffArray = array ();
  5706. $roleArrayCopy = array ();
  5707. foreach ( $verifyList as $k => $v ) {
  5708. // init verifyStaff
  5709. if ($v [1] == 'ROLE') {
  5710. if (! empty ( $verifyStaff )) {
  5711. $endStaffArray = end ( $verifyStaff );
  5712. // if ($v[0]==$endStaffArray['nextStaff']){
  5713. // $roleId=$v[0];
  5714. // }
  5715. }
  5716. $roleVerify = json_decode ( $v [3], true );
  5717. $roleKey = $k;
  5718. $roleArray = array ();
  5719. $rolename = $role->getOne ( array (
  5720. 'where' => 'rid=' . $v [0],
  5721. 'asArray' => true
  5722. ) );
  5723. foreach ( $roleVerify as $o => $p ) {
  5724. $staffID = explode ( '_', $p );
  5725. $staffInfo = $staff->getOne ( array (
  5726. 'where' => 'sid=' . $staffID [0],
  5727. 'asArray' => true
  5728. ) );
  5729. // print_r($staffID);
  5730. $exp = array (
  5731. 0 => $staffInfo ['sid'],
  5732. 1 => $staffID [1],
  5733. 2 => $staffInfo ['avatar'],
  5734. 'date' => '',
  5735. 'date' => '',
  5736. 'opinion' => '',
  5737. 'status' => '',
  5738. 'rolename' => $rolename ['name']
  5739. );
  5740. array_push ( $roleArray, $exp );
  5741. }
  5742. $roleArrayCopy [$v [0]] = $roleArray;
  5743. // $verifyList[$k]['roleArray']=$roleArray;
  5744. }
  5745. $verifyList [$k] ['date'] = "";
  5746. $verifyList [$k] ['opinion'] = "";
  5747. $verifyList [$k] ['status'] = "";
  5748. if (empty ( $verifyStaff )) {
  5749. $verifyList [$k] ['date'] = "";
  5750. $verifyList [$k] ['opinion'] = "";
  5751. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5752. $verifyList [$k] ['status'] = 4;
  5753. $flag = false;
  5754. }
  5755. } else {
  5756. foreach ( $verifyStaff as $m => $u ) {
  5757. if ($v [0] == $m) {
  5758. $verifyList [$k] ['date'] = $u ['date'];
  5759. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5760. $verifyList [$k] ['status'] = $u ['status'];
  5761. $flag = false;
  5762. break;
  5763. }
  5764. }
  5765. $endStaffArray = end ( $verifyStaff );
  5766. if (isset ( $endStaffArray ['ROLE'] )) {
  5767. } else {
  5768. // $endKey=key($verifyStaff);
  5769. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5770. // $button=4;
  5771. // $verifyList[$k]['status']=4;
  5772. // }
  5773. }
  5774. }
  5775. }
  5776. $rolename ['name'] = '';
  5777. if (! empty ( $roleId )) {
  5778. Doo::loadModel ( 'role' );
  5779. $role = new role ();
  5780. $rolename = $role->getOne ( array (
  5781. 'where' => 'rid=' . $roleId,
  5782. 'asArray' => true
  5783. ) );
  5784. }
  5785. if (! empty ( $verifyStaff ))
  5786. $endStaffArray = end ( $verifyStaff );
  5787. $KOP = false;
  5788. foreach ( $roleArrayCopy as $P => $A ) {
  5789. foreach ( $A as $MKI => $AVL ) {
  5790. if (! empty ( $verifyStaff )) {
  5791. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5792. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5793. $button = 4;
  5794. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5795. }
  5796. foreach ( $verifyStaff as $m => $u ) {
  5797. $AVLFK = $AVL [0] . '_R';
  5798. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5799. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5800. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5801. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5802. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5803. break;
  5804. }
  5805. }
  5806. } else {
  5807. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5808. $button = 4;
  5809. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5810. }
  5811. }
  5812. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5813. $KOP = true;
  5814. }
  5815. }
  5816. foreach ( $roleArrayCopy as $k => $v ) {
  5817. foreach ( $verifyList as $m => $n ) {
  5818. if ($n [0] == $k) {
  5819. array_splice ( $verifyList, $m, 1, $v );
  5820. }
  5821. }
  5822. }
  5823. $loanList [$key] ['verifyList'] = $verifyList;
  5824. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  5825. 'where' => 'sid=' . $value ['staff'],
  5826. 'asArray' => true
  5827. ) );
  5828. }
  5829. $data ['loanList'] = $loanList;
  5830. $Locate = 0;
  5831. $roleId = 0;
  5832. $button = 0;
  5833. Doo::loadClass ( 'XDeode' );
  5834. $XDeode = new XDeode ( 5 );
  5835. foreach ( $receiptList as $key => $value ) {
  5836. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5837. $button2 = 0;
  5838. $receiptList [$key] ['Locate'] = $Locate;
  5839. $Locate ++;
  5840. $receiptList [$key] ['reviseDetail'] = array ();
  5841. if (! empty ( $value ['reviseDetail'] ))
  5842. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5843. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5844. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5845. $categoryDetil = $Lcategory->getOne ( array (
  5846. 'where' => 'cid=' . $value ['cid'],
  5847. 'asArray' => true
  5848. ) );
  5849. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5850. $executeList = json_decode ( $value ['executeCopy'], true );
  5851. $executeStaff = array ();
  5852. if (! empty ( $value ['executeStaff'] ))
  5853. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5854. if (isset ( $executeList )) {
  5855. foreach ( $executeList as $op => $lo ) {
  5856. $executeList [$op] ['date'] = "";
  5857. $executeList [$op] ['opinion'] = "";
  5858. $executeList [$op] ['status'] = "";
  5859. foreach ( $executeStaff as $m => $u ) {
  5860. if ($lo [0] == $m) {
  5861. $executeList [$op] ['date'] = $u ['date'];
  5862. $executeList [$op] ['opinion'] = $u ['opinion'];
  5863. $executeList [$op] ['status'] = $u ['status'];
  5864. break;
  5865. }
  5866. }
  5867. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5868. $button2 = 1;
  5869. $executeList [$op] ['status'] = 4;
  5870. }
  5871. }
  5872. }
  5873. // 检测编辑状态
  5874. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5875. $verifyList ['staff'] = $value ['verifyBreakup'];
  5876. } else
  5877. $verifyList = $verify->getOne ( array (
  5878. 'where' => 'vid=' . $value ['verify'],
  5879. 'asArray' => true
  5880. ) );
  5881. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5882. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5883. Doo::loadModel ( 'role' );
  5884. $role = new role ();
  5885. if ($verifyList == NULL)
  5886. $verifyList = array ();
  5887. $flag = true;
  5888. $roleKey = 0;
  5889. $endStaffArray = array ();
  5890. $roleArrayCopy = array ();
  5891. foreach ( $verifyList as $k => $v ) {
  5892. // init verifyStaff
  5893. if ($v [1] == 'ROLE') {
  5894. if (! empty ( $verifyStaff )) {
  5895. $endStaffArray = end ( $verifyStaff );
  5896. // if ($v[0]==$endStaffArray['nextStaff']){
  5897. // $roleId=$v[0];
  5898. // }
  5899. }
  5900. $roleVerify = json_decode ( $v [3], true );
  5901. $roleKey = $k;
  5902. $roleArray = array ();
  5903. $rolename = $role->getOne ( array (
  5904. 'where' => 'rid=' . $v [0],
  5905. 'asArray' => true
  5906. ) );
  5907. foreach ( $roleVerify as $o => $p ) {
  5908. $staffID = explode ( '_', $p );
  5909. $staffInfo = $staff->getOne ( array (
  5910. 'where' => 'sid=' . $staffID [0],
  5911. 'asArray' => true
  5912. ) );
  5913. // print_r($staffID);
  5914. $exp = array (
  5915. 0 => $staffInfo ['sid'],
  5916. 1 => $staffID [1],
  5917. 2 => $staffInfo ['avatar'],
  5918. 'date' => '',
  5919. 'date' => '',
  5920. 'opinion' => '',
  5921. 'status' => '',
  5922. 'rolename' => $rolename ['name']
  5923. );
  5924. array_push ( $roleArray, $exp );
  5925. }
  5926. $roleArrayCopy [$v [0]] = $roleArray;
  5927. // $verifyList[$k]['roleArray']=$roleArray;
  5928. }
  5929. $verifyList [$k] ['date'] = "";
  5930. $verifyList [$k] ['opinion'] = "";
  5931. $verifyList [$k] ['status'] = "";
  5932. if (empty ( $verifyStaff )) {
  5933. $verifyList [$k] ['date'] = "";
  5934. $verifyList [$k] ['opinion'] = "";
  5935. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5936. $verifyList [$k] ['status'] = 4;
  5937. $flag = false;
  5938. }
  5939. } else {
  5940. foreach ( $verifyStaff as $m => $u ) {
  5941. if ($v [0] == $m) {
  5942. $verifyList [$k] ['date'] = $u ['date'];
  5943. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5944. $verifyList [$k] ['status'] = $u ['status'];
  5945. $flag = false;
  5946. break;
  5947. }
  5948. }
  5949. $endStaffArray = end ( $verifyStaff );
  5950. if (isset ( $endStaffArray ['ROLE'] )) {
  5951. } else {
  5952. // $endKey=key($verifyStaff);
  5953. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5954. // $button=4;
  5955. // $verifyList[$k]['status']=4;
  5956. // }
  5957. }
  5958. }
  5959. }
  5960. $rolename ['name'] = '';
  5961. if (! empty ( $roleId )) {
  5962. Doo::loadModel ( 'role' );
  5963. $role = new role ();
  5964. $rolename = $role->getOne ( array (
  5965. 'where' => 'rid=' . $roleId,
  5966. 'asArray' => true
  5967. ) );
  5968. }
  5969. if (! empty ( $verifyStaff ))
  5970. $endStaffArray = end ( $verifyStaff );
  5971. $KOP = false;
  5972. foreach ( $roleArrayCopy as $P => $A ) {
  5973. foreach ( $A as $MKI => $AVL ) {
  5974. if (! empty ( $verifyStaff )) {
  5975. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5976. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5977. $button = 4;
  5978. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5979. }
  5980. foreach ( $verifyStaff as $m => $u ) {
  5981. $AVLFK = $AVL [0] . '_R';
  5982. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5983. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5984. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5985. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5986. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5987. break;
  5988. }
  5989. }
  5990. } else {
  5991. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5992. $button = 4;
  5993. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5994. }
  5995. }
  5996. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5997. $KOP = true;
  5998. }
  5999. }
  6000. foreach ( $roleArrayCopy as $k => $v ) {
  6001. foreach ( $verifyList as $m => $n ) {
  6002. if ($n [0] == $k) {
  6003. array_splice ( $verifyList, $m, 1, $v );
  6004. }
  6005. }
  6006. }
  6007. $receiptList [$key] ['verifyList'] = $verifyList;
  6008. $receiptList [$key] ['executeList'] = $executeList;
  6009. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6010. 'where' => 'sid=' . $value ['staff'],
  6011. 'asArray' => true
  6012. ) );
  6013. $receiptList [$key] ['button2'] = $button2;
  6014. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6015. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6016. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6017. $receiptList [$key] ['relust'] = $relust;
  6018. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  6019. $receiptList [$key] ['amountABS'] = abs ( $value ['amount'] );
  6020. }
  6021. //执行人是否是最后一位
  6022. $executeCopy = json_decode ( $receiptList [0] ['executeCopy'], true );
  6023. $executeStaff = json_decode ( $receiptList [0] ['executeStaff'], true );
  6024. $executePrimary=count($executeCopy)-1;
  6025. $lastOne=true;
  6026. if($executePrimary!=count($executeStaff)){
  6027. $lastOne=false;
  6028. }
  6029. $data['lastOne']=$lastOne;
  6030. // 是否写入过流水
  6031. $accountType = 0;
  6032. if ($receiptList [0] ['Rtype'] == 0) {
  6033. $accountType = 3;
  6034. } elseif ($receiptList [0] ['Rtype'] == 1) {
  6035. if (!empty($receiptList [0]['accountItem']) )
  6036. $accountType = 2;
  6037. else
  6038. $accountType = 1;
  6039. } elseif ($receiptList [0] ['Rtype'] == 2) {
  6040. $accountType = 4;
  6041. } elseif ($receiptList [0] ['Rtype'] == 3) {
  6042. $accountType = 12;
  6043. }
  6044. Doo::loadModel ( 'wasteBook' );
  6045. $wasteBook = new wasteBook ();
  6046. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  6047. $data ['wbDetail'] = $wbDetail;
  6048. $wbDetailLoan=array();
  6049. if ($accountType==2){
  6050. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  6051. }
  6052. $data ['wbDetailLoan'] = $wbDetailLoan;
  6053. $data['inputDate']=date ( "Y-m-d H:i:s" );
  6054. //print_r($wbDetail);
  6055. $data ['receiptList'] = $receiptList;
  6056. $data ['memu'] = "receipt";
  6057. $data ['staff'] = $this->staff;
  6058. $data ['receiptMemu'] = 'implement';
  6059. $data ['verifyId'] = $this->verifyId;
  6060. $data ['executeId'] = $this->executeId;
  6061. if ($Rtype=="loan"){
  6062. $this->render ( "/receipt/receiptImplementLoan", $data );
  6063. }elseif($Rtype=="receipt"){
  6064. $this->render ( "/receipt/receiptImplement", $data );
  6065. }elseif($Rtype=="public"){
  6066. $this->render ( "/receipt/receiptImplementPublic", $data );
  6067. }else{
  6068. //$this->render ( "/admin/implement", $data );
  6069. }
  6070. }
  6071. function implementDo() {
  6072. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  6073. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6074. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  6075. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  6076. // $ab = '';
  6077. // if ($accountBank == 'CGBDeposit')
  6078. // $ab = '纵横广发';
  6079. // elseif ($accountBank == 'ICBCDeposit')
  6080. // $ab = '纵横工行';
  6081. // elseif ($accountBank == 'HUADeposit')
  6082. // $ab = '华润银行';
  6083. // elseif ($accountBank == 'PersonalDeposit')
  6084. // $ab = '个人广发';
  6085. // if (empty ( $ab ))
  6086. // die ( 'illegal request--22' );
  6087. if (! empty ( $rid )) {
  6088. Doo::loadModel ( 'receipt' );
  6089. $receipt = new receipt ();
  6090. Doo::loadClass ( 'XDeode' );
  6091. $XDeode = new XDeode ( 5 );
  6092. $rid=$XDeode->decode($rid);
  6093. if (!is_numeric($rid)){
  6094. die;
  6095. }
  6096. // $rinfo = $receipt->getOne ( array (
  6097. // 'where' => 'rid=' . $rid,
  6098. // 'asArray' => true
  6099. // ) );
  6100. $rinfo = $receipt->getReceiptByRid ( $rid );
  6101. // $accountType = '';
  6102. // if ($rinfo ['Rtype'] == 1) {
  6103. // if ($rinfo ['loanRid'] != 0)//判断有问题
  6104. // $accountType = 2;
  6105. // else
  6106. // $accountType = 1;
  6107. // } elseif ($rinfo ['Rtype'] == 2) {
  6108. // $accountType = 4;
  6109. // } elseif ($rinfo ['Rtype'] == 0)
  6110. // $accountType = 3;
  6111. // if (empty ( $accountType ))
  6112. // die ( 'illegal request' );
  6113. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6114. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6115. if (empty ( $executeStaff )) {
  6116. $executeStaff = array (
  6117. $this->staff [0] ['sid'] => array (
  6118. 'date' => date ( 'Y-m-d' ),
  6119. 'opinion' => $implementOpinions,
  6120. 'status' => 1
  6121. )
  6122. );
  6123. } else {
  6124. $executeStaff [$this->staff [0] ['sid']] = array (
  6125. 'date' => date ( 'Y-m-d' ),
  6126. 'opinion' => $implementOpinions,
  6127. 'status' => 1
  6128. );
  6129. }
  6130. if (count ( $executeStaff ) == count ( $executeCopy )) {
  6131. $receipt->executeStaff = json_encode ( $executeStaff );
  6132. $receipt->status = 8;
  6133. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  6134. $receipt->status = 9;
  6135. if ($rinfo ['status'] == 6) {
  6136. $receipt->loanDate = date ( "Y-m-d" );
  6137. }
  6138. $receipt->executeDate = date ( "Y-m-d" );
  6139. } else {
  6140. $receipt->executeStaff = json_encode ( $executeStaff );
  6141. }
  6142. //$receipt->amount = $amount;
  6143. $receipt->update ( array (
  6144. 'where' => 'rid=' . $rid
  6145. ) );
  6146. // 公司流水记录
  6147. // Doo::loadModel ( 'wasteBook' );
  6148. // $wasteBook = new wasteBook ();
  6149. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  6150. // // 银行
  6151. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  6152. // $item = array (
  6153. // 'dataID' => $rid,
  6154. // 'expensesType' => 2,
  6155. // 'accountType' => $accountType,
  6156. // 'accountPriceShow' => $amount,
  6157. // 'accountPrice' => - $amount,
  6158. // 'accountBank' => $accountBank,
  6159. // 'category' => $rinfo ['category'] [0] ['title'],
  6160. // 'cid' => $rinfo ['category'] [0] ['cid'],
  6161. // 'name' => $rinfo ['staffDetail'] ['username'],
  6162. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  6163. // 'inputDate' => date ( "Y-m-d H:i:s" )
  6164. // );
  6165. // $wasteBook->setAccountBookStatistics ( $item );
  6166. // }
  6167. }
  6168. //$ridKey = $XDeode->encode ( $rid );
  6169. return "/hisImplement";
  6170. // return "/implement/" . $ridKey . ".html";
  6171. }
  6172. function receiptburEdi() {
  6173. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6174. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6175. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6176. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6177. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6178. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6179. if (empty ( $status ))
  6180. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6181. $vidList = array ();
  6182. $button = 0;
  6183. Doo::loadModel ( 'verify' );
  6184. Doo::loadModel ( 'receipt' );
  6185. Doo::loadModel ( 'staff' );
  6186. $staff = new staff ();
  6187. $receipt = new receipt ();
  6188. $verify = new verify ();
  6189. Doo::loadModel ( 'L_category' );
  6190. $Lcategory = new L_category ();
  6191. Doo::loadModel ( 'enclosur' );
  6192. $enclosur = new enclosur ();
  6193. Doo::loadModel ( 'loanReceipt' );
  6194. $loanReceipt = new loanReceipt ();
  6195. // user verify ID
  6196. $verifyDetail = $verify->find ( array (
  6197. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6198. 'asArray' => true
  6199. ) );
  6200. foreach ( $verifyDetail as $key => $value ) {
  6201. array_push ( $vidList, $value ['vid'] );
  6202. }
  6203. $vid = implode ( ",", $vidList );
  6204. if (empty ( $verifyDetail ))
  6205. $vid = 0;
  6206. $categoryList = $Lcategory->find ( array (
  6207. 'asArray' => true
  6208. ) );
  6209. $staffList = $staff->find ( array (
  6210. 'where' => 'cid=' . $cid,
  6211. 'asArray' => true
  6212. ) );
  6213. $ap = "";
  6214. if ($status == 4) {
  6215. $ap = 4;
  6216. $status = 2;
  6217. }
  6218. // get Receipt By verifyID status 2
  6219. $receiptList = $receipt->find ( array (
  6220. 'where' => 'rid =' . $rid . ' and status=2',
  6221. 'desc' => 'rid',
  6222. 'asArray' => true
  6223. ) );
  6224. if (empty ( $receiptList )) {
  6225. die ( 'illegal request' );
  6226. }
  6227. $loanList = $loanReceipt->find ( array (
  6228. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  6229. 'desc' => 'rid',
  6230. 'asArray' => true
  6231. ) );
  6232. $data ['explanation'] = '';
  6233. if (! empty ( $loanList ))
  6234. $data ['explanation'] = $loanList [0] ['explanation'];
  6235. $Locate = 0;
  6236. $roleId = 0;
  6237. $button = 0;
  6238. foreach ( $loanList as $key => $value ) {
  6239. $loanList [$key] ['Locate'] = $Locate;
  6240. $Locate ++;
  6241. $loanList [$key] ['reviseDetail'] = array ();
  6242. if (! empty ( $value ['reviseDetail'] ))
  6243. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6244. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6245. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6246. $categoryDetil = $Lcategory->getOne ( array (
  6247. 'where' => 'cid=' . $value ['cid'],
  6248. 'asArray' => true
  6249. ) );
  6250. $loanList [$key] ['category'] = $categoryDetil ['title'];
  6251. // 检测编辑状态
  6252. $verifyList = $verify->getOne ( array (
  6253. 'where' => 'vid=' . $value ['verify'],
  6254. 'asArray' => true
  6255. ) );
  6256. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6257. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6258. Doo::loadModel ( 'role' );
  6259. $role = new role ();
  6260. $flag = true;
  6261. $roleKey = 0;
  6262. $endStaffArray = array ();
  6263. $roleArrayCopy = array ();
  6264. foreach ( $verifyList as $k => $v ) {
  6265. // init verifyStaff
  6266. if ($v [1] == 'ROLE') {
  6267. if (! empty ( $verifyStaff )) {
  6268. $endStaffArray = end ( $verifyStaff );
  6269. }
  6270. $roleVerify = json_decode ( $v [3], true );
  6271. $roleKey = $k;
  6272. $roleArray = array ();
  6273. $rolename = $role->getOne ( array (
  6274. 'where' => 'rid=' . $v [0],
  6275. 'asArray' => true
  6276. ) );
  6277. foreach ( $roleVerify as $o => $p ) {
  6278. $staffID = explode ( '_', $p );
  6279. $staffInfo = $staff->getOne ( array (
  6280. 'where' => 'sid=' . $staffID [0],
  6281. 'asArray' => true
  6282. ) );
  6283. // print_r($staffID);
  6284. $exp = array (
  6285. 0 => $staffInfo ['sid'],
  6286. 1 => $staffID [1],
  6287. 2 => $staffInfo ['avatar'],
  6288. 'date' => '',
  6289. 'date' => '',
  6290. 'opinion' => '',
  6291. 'status' => '',
  6292. 'rolename' => $rolename ['name']
  6293. );
  6294. array_push ( $roleArray, $exp );
  6295. }
  6296. $roleArrayCopy [$v [0]] = $roleArray;
  6297. // $verifyList[$k]['roleArray']=$roleArray;
  6298. }
  6299. $verifyList [$k] ['date'] = "";
  6300. $verifyList [$k] ['opinion'] = "";
  6301. $verifyList [$k] ['status'] = "";
  6302. if (empty ( $verifyStaff )) {
  6303. $verifyList [$k] ['date'] = "";
  6304. $verifyList [$k] ['opinion'] = "";
  6305. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6306. $verifyList [$k] ['status'] = 4;
  6307. $flag = false;
  6308. }
  6309. } else {
  6310. foreach ( $verifyStaff as $m => $u ) {
  6311. if ($v [0] == $m) {
  6312. $verifyList [$k] ['date'] = $u ['date'];
  6313. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6314. $verifyList [$k] ['status'] = $u ['status'];
  6315. $flag = false;
  6316. break;
  6317. }
  6318. }
  6319. $endStaffArray = end ( $verifyStaff );
  6320. if (isset ( $endStaffArray ['ROLE'] )) {
  6321. } else {
  6322. }
  6323. }
  6324. }
  6325. $rolename ['name'] = '';
  6326. if (! empty ( $roleId )) {
  6327. Doo::loadModel ( 'role' );
  6328. $role = new role ();
  6329. $rolename = $role->getOne ( array (
  6330. 'where' => 'rid=' . $roleId,
  6331. 'asArray' => true
  6332. ) );
  6333. }
  6334. if (! empty ( $verifyStaff ))
  6335. $endStaffArray = end ( $verifyStaff );
  6336. $KOP = false;
  6337. foreach ( $roleArrayCopy as $P => $A ) {
  6338. foreach ( $A as $MKI => $AVL ) {
  6339. if (! empty ( $verifyStaff )) {
  6340. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6341. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6342. $button = 4;
  6343. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6344. }
  6345. foreach ( $verifyStaff as $m => $u ) {
  6346. $AVLFK = $AVL [0] . '_R';
  6347. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6348. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6349. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6350. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6351. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6352. break;
  6353. }
  6354. }
  6355. } else {
  6356. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6357. $button = 4;
  6358. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6359. }
  6360. }
  6361. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6362. $KOP = true;
  6363. }
  6364. }
  6365. foreach ( $roleArrayCopy as $k => $v ) {
  6366. foreach ( $verifyList as $m => $n ) {
  6367. if ($n [0] == $k) {
  6368. array_splice ( $verifyList, $m, 1, $v );
  6369. }
  6370. }
  6371. }
  6372. $loanList [$key] ['verifyList'] = $verifyList;
  6373. }
  6374. $htmlLoan = '';
  6375. $data ['loanReceiptDate'] = '';
  6376. if (isset ( $loanList [0] )) {
  6377. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  6378. if ($value ['status'] == 1)
  6379. $htmlLoan .= '<li class="done" >';
  6380. elseif ($value ['status'] == 3)
  6381. $htmlLoan .= '<li class="undone" >';
  6382. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  6383. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  6384. if (isset ( $value ['rolename'] ))
  6385. $htmlLoan .= $value ['rolename'];
  6386. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  6387. }
  6388. $data ['loanDate'] = $loanList [0] ['date'];
  6389. } else {
  6390. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  6391. }
  6392. $data ['htmlLoan'] = $htmlLoan;
  6393. // $data ['LoanReceipt']=$loanList[0];
  6394. // print_r($loanList);
  6395. $Locate = 0;
  6396. $roleId = 0;
  6397. $button = 0;
  6398. if ($ap == 4)
  6399. $status = 4;
  6400. Doo::loadClass ( 'XDeode' );
  6401. $XDeode = new XDeode ( 5 );
  6402. foreach ( $receiptList as $key => $value ) {
  6403. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6404. $receiptList [$key] ['Locate'] = $Locate;
  6405. $Locate ++;
  6406. $receiptList [$key] ['reviseDetail'] = array ();
  6407. // 调整金额 代码调整
  6408. if (! empty ( $value ['reviseDetail'] )) {
  6409. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  6410. foreach ( $reviseDetail as $ry => $re ) {
  6411. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  6412. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  6413. }
  6414. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  6415. // print_r($reviseDetail);
  6416. }
  6417. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6418. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  6419. $categoryDetil = $Lcategory->getOne ( array (
  6420. 'where' => 'cid=' . $value ['cid'],
  6421. 'asArray' => true
  6422. ) );
  6423. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6424. // 检测编辑状态
  6425. $verifyList = $verify->getOne ( array (
  6426. 'where' => 'vid=' . $value ['verify'],
  6427. 'asArray' => true
  6428. ) );
  6429. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6430. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6431. Doo::loadModel ( 'role' );
  6432. $role = new role ();
  6433. // print_r($verifyList);
  6434. $flag = true;
  6435. $roleKey = 0;
  6436. $endStaffArray = array ();
  6437. $roleArrayCopy = array ();
  6438. foreach ( $verifyList as $k => $v ) {
  6439. // init verifyStaff
  6440. if ($v [1] == 'ROLE') {
  6441. if (! empty ( $verifyStaff )) {
  6442. $endStaffArray = end ( $verifyStaff );
  6443. if ($v [0] == $endStaffArray ['nextStaff']) {
  6444. $roleId = $v [0];
  6445. }
  6446. }
  6447. $roleVerify = json_decode ( $v [3], true );
  6448. $roleKey = $k;
  6449. $roleArray = array ();
  6450. $rolename = $role->getOne ( array (
  6451. 'where' => 'rid=' . $v [0],
  6452. 'asArray' => true
  6453. ) );
  6454. foreach ( $roleVerify as $o => $p ) {
  6455. $staffID = explode ( '_', $p );
  6456. $staffInfo = $staff->getOne ( array (
  6457. 'where' => 'sid=' . $staffID [0],
  6458. 'asArray' => true
  6459. ) );
  6460. // print_r($staffID);
  6461. $exp = array (
  6462. 0 => $staffInfo ['sid'],
  6463. 1 => $staffID [1],
  6464. 2 => $staffInfo ['avatar'],
  6465. 'date' => '',
  6466. 'date' => '',
  6467. 'opinion' => '',
  6468. 'status' => '',
  6469. 'rolename' => $rolename ['name']
  6470. );
  6471. array_push ( $roleArray, $exp );
  6472. }
  6473. $roleArrayCopy [$v [0]] = $roleArray;
  6474. // $verifyList[$k]['roleArray']=$roleArray;
  6475. }
  6476. // print_r($roleArray);
  6477. $verifyList [$k] ['date'] = "";
  6478. $verifyList [$k] ['opinion'] = "";
  6479. $verifyList [$k] ['status'] = "";
  6480. if (empty ( $verifyStaff )) {
  6481. $verifyList [$k] ['date'] = "";
  6482. $verifyList [$k] ['opinion'] = "";
  6483. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6484. $verifyList [$k] ['status'] = 4;
  6485. $button = 4;
  6486. $flag = false;
  6487. }
  6488. } else {
  6489. foreach ( $verifyStaff as $m => $u ) {
  6490. if ($v [0] == $m) {
  6491. $verifyList [$k] ['date'] = $u ['date'];
  6492. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6493. $verifyList [$k] ['status'] = $u ['status'];
  6494. $flag = false;
  6495. break;
  6496. }
  6497. }
  6498. $endStaffArray = end ( $verifyStaff );
  6499. if (isset ( $endStaffArray ['ROLE'] )) {
  6500. } else {
  6501. $endKey = key ( $verifyStaff );
  6502. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6503. $button = 4;
  6504. $verifyList [$k] ['status'] = 4;
  6505. }
  6506. }
  6507. }
  6508. }
  6509. $rolename ['name'] = '';
  6510. if (! empty ( $roleId )) {
  6511. Doo::loadModel ( 'role' );
  6512. $role = new role ();
  6513. $rolename = $role->getOne ( array (
  6514. 'where' => 'rid=' . $roleId,
  6515. 'asArray' => true
  6516. ) );
  6517. }
  6518. if (! empty ( $verifyStaff ))
  6519. $endStaffArray = end ( $verifyStaff );
  6520. $KOP = false;
  6521. foreach ( $roleArrayCopy as $P => $A ) {
  6522. foreach ( $A as $MKI => $AVL ) {
  6523. if (! empty ( $verifyStaff )) {
  6524. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6525. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6526. $button = 4;
  6527. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6528. }
  6529. foreach ( $verifyStaff as $m => $u ) {
  6530. $AVLFK = $AVL [0] . '_R';
  6531. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6532. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6533. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6534. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6535. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6536. break;
  6537. }
  6538. }
  6539. } else {
  6540. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6541. $button = 4;
  6542. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6543. }
  6544. }
  6545. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6546. $KOP = true;
  6547. }
  6548. }
  6549. foreach ( $roleArrayCopy as $k => $v ) {
  6550. foreach ( $verifyList as $m => $n ) {
  6551. if ($n [0] == $k) {
  6552. array_splice ( $verifyList, $m, 1, $v );
  6553. }
  6554. }
  6555. }
  6556. // print_r($verifyList);
  6557. $receiptList [$key] ['verifyList'] = $verifyList;
  6558. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6559. 'where' => 'sid=' . $value ['staff'],
  6560. 'asArray' => true
  6561. ) );
  6562. $receiptList [$key] ['button'] = $button;
  6563. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  6564. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  6565. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  6566. $receiptList [$key] ['relust'] = $relust;
  6567. $receiptList [$key] ['relustABS'] = abs ( $relust );
  6568. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  6569. }
  6570. //print_r($receiptList);die;
  6571. // $data['verifyDetail']=$verifyDetail;
  6572. $mothHtml = "";
  6573. for($i = 1; $i <= 12; $i ++) {
  6574. if ($month == $i)
  6575. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6576. else
  6577. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6578. }
  6579. // 获取审批日志
  6580. Doo::loadModel ( 'receiptLog' );
  6581. $receiptLog = new receiptLog ();
  6582. $rlList = array ();
  6583. $rlInfo = $receiptLog->getOne ( array (
  6584. 'where' => 'rid=' . $rid . ' and status=4',
  6585. 'asArray' => true
  6586. ) );
  6587. $tijdate = $receiptLog->getOne ( array (
  6588. 'where' => 'rid=' . $rid . ' and status=2',
  6589. 'asc' => 'rlid',
  6590. 'asArray' => true
  6591. ) );
  6592. if (! empty ( $rlInfo )) {
  6593. $rlList = $receiptLog->find ( array (
  6594. 'where' => 'rid=' . $rid,
  6595. 'asc' => 'rlid',
  6596. 'asArray' => true
  6597. ) );
  6598. }
  6599. // echo $rid;
  6600. // print_r($receiptList);
  6601. $receiptList [0] ['rlList'] = $rlList;
  6602. // print_r($receiptList);
  6603. $enclosurList = $enclosur->find ( array (
  6604. 'where' => 'rid=' . $rid,
  6605. 'asArray' => true
  6606. ) );
  6607. $enclosurHtml = '';
  6608. foreach ( $enclosurList as $value ) {
  6609. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6610. }
  6611. $data ['enclosurHtml'] = $enclosurHtml;
  6612. $data ['rolename'] = $rolename ['name'];
  6613. $data ['mothHtml'] = $mothHtml;
  6614. // print_r($receiptList);
  6615. $data ['rid'] = $rid;
  6616. $data ['tijdate'] = $tijdate ['date'];
  6617. $data ['receiptList'] = $receiptList;
  6618. $data ['receiptApprovalCount'] = count ( $receiptList );
  6619. $data ['status'] = $status;
  6620. $data ['year'] = $year;
  6621. $data ['categoryList'] = $categoryList;
  6622. $data ['staffList'] = $staffList;
  6623. $data ['cid'] = $cid;
  6624. $data ['sid'] = $sid;
  6625. $data ['ap'] = $ap;
  6626. $data ['memu'] = "receipt";
  6627. $data ['staff'] = $this->staff;
  6628. $data ['receiptMemu'] = 'approvalExpenses';
  6629. $data ['verifyId'] = $this->verifyId;
  6630. $data ['executeId'] = $this->executeId;
  6631. if($receiptList[0]['receiptClass']==1){
  6632. $this->render ( "/receipt/feeAgencyApproval", $data );
  6633. }elseif($receiptList[0]['receiptClass']==2){
  6634. //$this->render ( "/admin/receiptburEdi", $data );
  6635. $this->render ( "/receipt/feeTraveApproval", $data );
  6636. }elseif($receiptList[0]['receiptClass']==3){
  6637. $this->render ( "/receipt/feeInternalTrainApproval", $data );
  6638. }else{
  6639. $this->render ( "/admin/receiptburEdi", $data );
  6640. }
  6641. }
  6642. function hisImplement() {
  6643. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6644. if (empty ( $item ))
  6645. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  6646. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  6647. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6648. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  6649. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6650. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  6651. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  6652. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  6653. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  6654. Doo::loadClass ( 'XDeode' );
  6655. $XDeode = new XDeode ( 5 );
  6656. Doo::loadModel ( 'receipt' );
  6657. $receipt = new receipt ();
  6658. Doo::loadModel ( 'L_category' );
  6659. $Lcategory = new L_category ();
  6660. Doo::loadModel ( 'verify' );
  6661. Doo::loadModel ( 'statistics' );
  6662. $statistics = new statistics ();
  6663. $verify = new verify ();
  6664. Doo::loadModel ( 'staff' );
  6665. $staff = new staff ();
  6666. Doo::loadClass ( 'XDeode' );
  6667. $XDeode = new XDeode ( 5 );
  6668. $XDeode7 = new XDeode ( 7 );
  6669. $cid = $XDeode->decode ( $cidKey );
  6670. $condition = "";
  6671. if ($item == "expenses")
  6672. $condition = " and Rtype=1 ";
  6673. elseif ($item == "receipts")
  6674. $condition = " and Rtype=0 ";
  6675. elseif ($item == "remits")
  6676. $condition = " and Rtype=2 ";
  6677. elseif($item == "train")
  6678. $condition = " and Rtype=3 ";
  6679. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  6680. $sopString = $cidString = "";
  6681. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  6682. if (empty ( $rdate ))
  6683. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  6684. else
  6685. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  6686. if ($status == 'pendImplement') {
  6687. $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 ) ) ';
  6688. } elseif ($status == 'alerpts') {
  6689. $statusCon = '(status=8 or status=9 )';
  6690. if (empty ( $rdate ))
  6691. $dateCondition .= " and Year(date) =" . $year;
  6692. else
  6693. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  6694. }
  6695. if ($sop != 'SOP')
  6696. $sopString = " and staff=" . $sop;
  6697. if ($cidKey != 'ALL')
  6698. $cidString = " and cid=" . $cid;
  6699. //汇款信息需要提取出来
  6700. if(!empty($receiptOrder)){
  6701. $receiptList = $receipt->find ( array (
  6702. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6703. 'desc' => 'rid',
  6704. 'asArray' => true
  6705. ) );
  6706. // 员工筛选
  6707. $receiptList2 = $receipt->find ( array (
  6708. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  6709. 'desc' => 'rid',
  6710. 'asArray' => true
  6711. ) );
  6712. }else{
  6713. $receiptList = $receipt->find ( array (
  6714. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  6715. 'desc' => 'rid',
  6716. 'asArray' => true
  6717. ) );
  6718. // 员工筛选
  6719. $receiptList2 = $receipt->find ( array (
  6720. 'where' => $statusCon . $condition . $dateCondition,
  6721. 'desc' => 'rid',
  6722. 'asArray' => true
  6723. ) );
  6724. }
  6725. $sopStaff = array ();
  6726. foreach ( $receiptList2 as $key => $value ) {
  6727. $staffDetail = $staff->getOne ( array (
  6728. 'select' => 'username',
  6729. 'where' => 'sid=' . $value ['staff'],
  6730. 'asArray' => true
  6731. ) );
  6732. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  6733. }
  6734. // 办事处筛选
  6735. $categoryScreen = array ();
  6736. $categorList = $Lcategory->getCategory ();
  6737. foreach ( $receiptList2 as $key => $value ) {
  6738. foreach ( $categorList as $k => $v ) {
  6739. if ($value ['cid'] == $v ['cid']) {
  6740. $categoryScreen [$v ['cidKey']] = $v ['title'];
  6741. break;
  6742. }
  6743. }
  6744. }
  6745. $categoryScreenHtml = "";
  6746. foreach ( $categoryScreen as $key => $value ) {
  6747. if ($cidKey == $key)
  6748. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6749. else
  6750. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6751. }
  6752. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  6753. $data ['cidKey'] = $cidKey;
  6754. $Locate = 0;
  6755. $roleId = 0;
  6756. $button = 0;
  6757. $staffBatchNumber = 100001;
  6758. $remittanceList = array ();
  6759. foreach ( $receiptList as $key => $value ) {
  6760. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  6761. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  6762. $receiptList [$key] ['Texe'] = 'false';
  6763. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  6764. $receiptList [$key] ['Texe'] = 'true';
  6765. }
  6766. $receiptList [$key] ['TRexe'] = 'true';
  6767. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  6768. $receiptList [$key] ['TRexe'] = 'false';
  6769. }
  6770. $receiptList [$key] ['Locate'] = $Locate;
  6771. $Locate ++;
  6772. $receiptList [$key] ['reviseDetail'] = array ();
  6773. if (! empty ( $value ['reviseDetail'] ))
  6774. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6775. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6776. $categoryDetil = $Lcategory->getOne ( array (
  6777. 'where' => 'cid=' . $value ['cid'],
  6778. 'asArray' => true
  6779. ) );
  6780. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6781. // 检测编辑状态
  6782. $verifyList = $verify->getOne ( array (
  6783. 'where' => 'vid=' . $value ['verify'],
  6784. 'asArray' => true
  6785. ) );
  6786. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6787. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6788. Doo::loadModel ( 'role' );
  6789. $role = new role ();
  6790. $flag = true;
  6791. $roleKey = 0;
  6792. $endStaffArray = array ();
  6793. $roleArrayCopy = array ();
  6794. foreach ( $verifyList as $k => $v ) {
  6795. // init verifyStaff
  6796. if ($v [1] == 'ROLE') {
  6797. if (! empty ( $verifyStaff )) {
  6798. $endStaffArray = end ( $verifyStaff );
  6799. }
  6800. $roleVerify = json_decode ( $v [3], true );
  6801. $roleKey = $k;
  6802. $roleArray = array ();
  6803. $rolename = $role->getOne ( array (
  6804. 'where' => 'rid=' . $v [0],
  6805. 'asArray' => true
  6806. ) );
  6807. foreach ( $roleVerify as $o => $p ) {
  6808. $staffID = explode ( '_', $p );
  6809. $staffInfo = $staff->getOne ( array (
  6810. 'where' => 'sid=' . $staffID [0],
  6811. 'asArray' => true
  6812. ) );
  6813. $exp = array (
  6814. 0 => $staffInfo ['sid'],
  6815. 1 => $staffID [1],
  6816. 2 => $staffInfo ['avatar'],
  6817. 'date' => '',
  6818. 'date' => '',
  6819. 'opinion' => '',
  6820. 'status' => '',
  6821. 'rolename' => $rolename ['name']
  6822. );
  6823. array_push ( $roleArray, $exp );
  6824. }
  6825. $roleArrayCopy [$v [0]] = $roleArray;
  6826. }
  6827. $verifyList [$k] ['date'] = "";
  6828. $verifyList [$k] ['opinion'] = "";
  6829. $verifyList [$k] ['status'] = "";
  6830. if (empty ( $verifyStaff )) {
  6831. $verifyList [$k] ['date'] = "";
  6832. $verifyList [$k] ['opinion'] = "";
  6833. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6834. $verifyList [$k] ['status'] = 4;
  6835. $flag = false;
  6836. }
  6837. } else {
  6838. foreach ( $verifyStaff as $m => $u ) {
  6839. if ($v [0] == $m) {
  6840. $verifyList [$k] ['date'] = $u ['date'];
  6841. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6842. $verifyList [$k] ['status'] = $u ['status'];
  6843. $flag = false;
  6844. break;
  6845. }
  6846. }
  6847. $endStaffArray = end ( $verifyStaff );
  6848. }
  6849. }
  6850. $rolename ['name'] = '';
  6851. if (! empty ( $roleId )) {
  6852. Doo::loadModel ( 'role' );
  6853. $role = new role ();
  6854. $rolename = $role->getOne ( array (
  6855. 'where' => 'rid=' . $roleId,
  6856. 'asArray' => true
  6857. ) );
  6858. }
  6859. if (! empty ( $verifyStaff ))
  6860. $endStaffArray = end ( $verifyStaff );
  6861. $KOP = false;
  6862. foreach ( $roleArrayCopy as $P => $A ) {
  6863. foreach ( $A as $MKI => $AVL ) {
  6864. if (! empty ( $verifyStaff )) {
  6865. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6866. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6867. $button = 4;
  6868. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6869. }
  6870. foreach ( $verifyStaff as $m => $u ) {
  6871. $AVLFK = $AVL [0] . '_R';
  6872. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6873. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6874. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6875. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6876. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6877. break;
  6878. }
  6879. }
  6880. } else {
  6881. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6882. $button = 4;
  6883. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6884. }
  6885. }
  6886. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6887. $KOP = true;
  6888. }
  6889. }
  6890. foreach ( $roleArrayCopy as $k => $v ) {
  6891. foreach ( $verifyList as $m => $n ) {
  6892. if ($n [0] == $k) {
  6893. array_splice ( $verifyList, $m, 1, $v );
  6894. }
  6895. }
  6896. }
  6897. $receiptList [$key] ['verifyList'] = $verifyList;
  6898. $staffDetail = $staff->getOne ( array (
  6899. 'where' => 'sid=' . $value ['staff'],
  6900. 'asArray' => true
  6901. ) );
  6902. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6903. $receiptList [$key] ['button'] = $button;
  6904. if ($value['Rtype']==1){
  6905. $receiptList [$key] ['relust'] = $value['sum']-$value['loanSum'];
  6906. $receiptList [$key] ['relustABS'] = abs($receiptList [$key] ['relust']);
  6907. }elseif($value['Rtype']==3){
  6908. // 收入合计
  6909. Doo::loadModel ( 'invoiceTraining' );
  6910. $invoiceTraining = new invoiceTraining ();
  6911. $invoiceTrainingDetail = array (
  6912. 'invoiceArriveAmount' => '0.00',
  6913. 'RIAmount' => '0.00',
  6914. 'invoiceTotalAmount' => '0.00',
  6915. 'invoiceCompanyAmount' => '0.00',
  6916. 'invoiceArriveAmountM'=>'0.00',
  6917. 'invoiceCompanyAmountM'=>'0.00'
  6918. );
  6919. if ($value ['invoiceTrainId'] != 0) {
  6920. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $value['invoiceTrainId'] );
  6921. }
  6922. $invoiceArriveAmount = $RIAmount = 0;
  6923. if (! empty ( $invoiceTrainingDetail )) {
  6924. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  6925. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  6926. }
  6927. // 备用金
  6928. $sum = 0;
  6929. if (! empty ( $value ['trainLoanRid'] )) {
  6930. $receiptLoanList = $receipt->getReceiptInRid ( $value ['trainLoanRid'] );
  6931. foreach ($receiptLoanList as $kll=>$vll){
  6932. $sum+=$vll['sum'];
  6933. }
  6934. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $value ['trainLoanRid'] );
  6935. // $sum = $receiptLoanDetailBak ['sum'];
  6936. }
  6937. // 支出项金额详情
  6938. // 项目金额合计
  6939. Doo::loadModel ( 'RItem' );
  6940. $RItem = new RItem ();
  6941. Doo::loadModel ( 'accountItem' );
  6942. $accountItem = new accountItem ();
  6943. // 讲师获得
  6944. Doo::loadModel ( 'RILecturer' );
  6945. $RILecturer = new RILecturer ();
  6946. $RItemList = $RItem->getRItemByRid ( $value['rid'] );
  6947. $RILecturerList = $RILecturer->getRILecturerByRid ( $value['rid'] );
  6948. // 支出项金额详情
  6949. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  6950. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  6951. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  6952. $receiptList [$key] ['payment'] =$payment;
  6953. $receiptList [$key] ['paymentABS'] =sprintf("%.2f",abs($payment));
  6954. }
  6955. // 设置导出汇款execl
  6956. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6957. $remittanceDetail = array (
  6958. $staffBatchNumber,
  6959. $value ['remittanceName'],
  6960. $value ['bankNumber'],
  6961. $value ['bankName'],
  6962. $value ['remittanceBankType'],
  6963. $value ['coupletNumber'],
  6964. $value ['sum']
  6965. );
  6966. array_push ( $remittanceList, $remittanceDetail );
  6967. $staffBatchNumber ++;
  6968. }
  6969. }
  6970. $data ['remittanceList'] = json_encode ( $remittanceList );
  6971. // print_r($receiptList);
  6972. $mothHtml = "";
  6973. for($i = 1; $i <= 12; $i ++) {
  6974. if ($moth == $i)
  6975. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6976. else
  6977. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6978. }
  6979. $dayHtml = "";
  6980. if ($day != "DAY" || $moth != "MONTH") {
  6981. for($i = 1; $i <= 31; $i ++) {
  6982. if ($day == $i)
  6983. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6984. else
  6985. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6986. }
  6987. }
  6988. $sopHtml = "";
  6989. foreach ( $sopStaff as $key => $value ) {
  6990. if ($sop == $key)
  6991. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6992. else
  6993. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6994. }
  6995. $data ['status'] = $status;
  6996. $data ['rdate'] = $rdate;
  6997. $data ['sopHtml'] = $sopHtml;
  6998. $data ['dayHtml'] = $dayHtml;
  6999. $data ['mothHtml'] = $mothHtml;
  7000. $data ['receiptList'] = $receiptList;
  7001. $data ['memu'] = "receipt";
  7002. $data ['staff'] = $this->staff;
  7003. $data ['receiptMemu'] = 'implement';
  7004. $data ['verifyId'] = $this->verifyId;
  7005. $data ['executeId'] = $this->executeId;
  7006. $data ['item'] = $item;
  7007. $data ['year'] = $year;
  7008. $data ['moth'] = $moth;
  7009. $data['receiptOrder']=$receiptOrder;
  7010. $data ['day'] = $day;
  7011. $data ['sop'] = $sop;
  7012. $this->render ( "/admin/hisImplement", $data );
  7013. }
  7014. /**
  7015. * 导出汇款信息的exelc
  7016. */
  7017. function exportRemittance() {
  7018. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  7019. if (empty ( $remittanceInfo ))
  7020. die ( 'illegal request' );
  7021. $title = array (
  7022. '员工编号',
  7023. '姓名',
  7024. '员工账号',
  7025. '员工账户开户行',
  7026. '转账类型',
  7027. '联行号',
  7028. '金额'
  7029. );
  7030. $data = json_decode ( $remittanceInfo, true );
  7031. if (empty ( $data ))
  7032. die ( 'illegal request' );
  7033. Doo::loadClass ( 'receipt.func' );
  7034. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  7035. header ( 'Content-Type:text/html;charset=utf-8' );
  7036. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  7037. }
  7038. function ajaxExamine() {
  7039. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7040. Doo::loadModel ( 'receipt' );
  7041. $receipt = new receipt ();
  7042. if (! empty ( $rid )) {
  7043. $rLRes = $receipt->find ( array (
  7044. '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,
  7045. 'asArray' => true
  7046. ) );
  7047. if(!empty($rLRes)){
  7048. Doo::loadClass ( 'XDeode' );
  7049. $XDeode = new XDeode ( 7 );
  7050. $rLRes [0]['ridKey'] = $XDeode->encode( $rLRes [0]['rid'] );
  7051. echo json_encode ( array (
  7052. 'status' => 1,
  7053. 'receipt' => $rLRes [0]
  7054. ) );
  7055. die ();
  7056. }else{
  7057. echo json_encode ( array (
  7058. 'status' => 1,
  7059. 'receipt' => array ()
  7060. ) );
  7061. die ();
  7062. }
  7063. }
  7064. echo json_encode ( array (
  7065. 'status' => 0,
  7066. 'receipt' => array ()
  7067. ) );
  7068. die ();
  7069. }
  7070. /*
  7071. * 废弃
  7072. */
  7073. function myReceipt() {
  7074. // all approval past withdraw
  7075. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  7076. if (empty ( $item ))
  7077. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  7078. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7079. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  7080. Doo::loadModel ( 'receipt' );
  7081. $receipt = new receipt ();
  7082. // pre-loaded
  7083. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7084. // have cache
  7085. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  7086. if (! empty ( $moth )) // yearPage
  7087. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  7088. $this->showCache ( $path );
  7089. }
  7090. Doo::loadModel ( 'L_category' );
  7091. $Lcategory = new L_category ();
  7092. Doo::loadModel ( 'verify' );
  7093. Doo::loadModel ( 'statistics' );
  7094. $statistics = new statistics ();
  7095. $verify = new verify ();
  7096. Doo::loadModel ( 'staff' );
  7097. $staff = new staff ();
  7098. $condition = " and status!=0 ";
  7099. if ($item == "approval")
  7100. $condition = " and status=2 ";
  7101. elseif ($item == "withdraw")
  7102. $condition = " and status=3 ";
  7103. elseif ($item == "past")
  7104. $condition = " and status=1 ";
  7105. elseif ($item == "whdw")
  7106. $condition = " and status=4 ";
  7107. $dateCondition = " and Year(date) =" . $year;
  7108. if (! empty ( $moth )) {
  7109. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  7110. $stList = $statistics->getOne ( array (
  7111. 'select' => 'rePrice ,agPrice',
  7112. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7113. 'asArray' => true
  7114. ) );
  7115. } else
  7116. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7117. if (empty ( $stList ))
  7118. $stList = array (
  7119. 'rePrice' => 0,
  7120. 'agPrice' => 0
  7121. );
  7122. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  7123. $data ['stList'] = array (
  7124. 'rePrice' => $stList ['rePrice'],
  7125. 'agPrice' => $stList ['agPrice'],
  7126. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  7127. );
  7128. $receiptList = $receipt->find ( array (
  7129. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  7130. 'desc' => 'rid',
  7131. 'asArray' => true
  7132. ) );
  7133. $Locate = 0;
  7134. $roleId = 0;
  7135. $button = 0;
  7136. foreach ( $receiptList as $key => $value ) {
  7137. $receiptList [$key] ['Locate'] = $Locate;
  7138. $Locate ++;
  7139. $receiptList [$key] ['reviseDetail'] = array ();
  7140. if (! empty ( $value ['reviseDetail'] ))
  7141. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7142. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7143. $categoryDetil = $Lcategory->getOne ( array (
  7144. 'where' => 'cid=' . $value ['cid'],
  7145. 'asArray' => true
  7146. ) );
  7147. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7148. // 检测编辑状态
  7149. $verifyList = $verify->getOne ( array (
  7150. 'where' => 'vid=' . $value ['verify'],
  7151. 'asArray' => true
  7152. ) );
  7153. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7154. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7155. Doo::loadModel ( 'role' );
  7156. $role = new role ();
  7157. $flag = true;
  7158. $roleKey = 0;
  7159. $endStaffArray = array ();
  7160. $roleArrayCopy = array ();
  7161. foreach ( $verifyList as $k => $v ) {
  7162. // init verifyStaff
  7163. if ($v [1] == 'ROLE') {
  7164. if (! empty ( $verifyStaff )) {
  7165. $endStaffArray = end ( $verifyStaff );
  7166. // if ($v[0]==$endStaffArray['nextStaff']){
  7167. // $roleId=$v[0];
  7168. // }
  7169. }
  7170. $roleVerify = json_decode ( $v [3], true );
  7171. $roleKey = $k;
  7172. $roleArray = array ();
  7173. $rolename = $role->getOne ( array (
  7174. 'where' => 'rid=' . $v [0],
  7175. 'asArray' => true
  7176. ) );
  7177. foreach ( $roleVerify as $o => $p ) {
  7178. $staffID = explode ( '_', $p );
  7179. $staffInfo = $staff->getOne ( array (
  7180. 'where' => 'sid=' . $staffID [0],
  7181. 'asArray' => true
  7182. ) );
  7183. // print_r($staffID);
  7184. $exp = array (
  7185. 0 => $staffInfo ['sid'],
  7186. 1 => $staffID [1],
  7187. 2 => $staffInfo ['avatar'],
  7188. 'date' => '',
  7189. 'date' => '',
  7190. 'opinion' => '',
  7191. 'status' => '',
  7192. 'rolename' => $rolename ['name']
  7193. );
  7194. array_push ( $roleArray, $exp );
  7195. }
  7196. $roleArrayCopy [$v [0]] = $roleArray;
  7197. // $verifyList[$k]['roleArray']=$roleArray;
  7198. }
  7199. $verifyList [$k] ['date'] = "";
  7200. $verifyList [$k] ['opinion'] = "";
  7201. $verifyList [$k] ['status'] = "";
  7202. if (empty ( $verifyStaff )) {
  7203. $verifyList [$k] ['date'] = "";
  7204. $verifyList [$k] ['opinion'] = "";
  7205. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7206. $verifyList [$k] ['status'] = 4;
  7207. $flag = false;
  7208. }
  7209. } else {
  7210. foreach ( $verifyStaff as $m => $u ) {
  7211. if ($v [0] == $m) {
  7212. $verifyList [$k] ['date'] = $u ['date'];
  7213. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7214. $verifyList [$k] ['status'] = $u ['status'];
  7215. $flag = false;
  7216. break;
  7217. }
  7218. }
  7219. $endStaffArray = end ( $verifyStaff );
  7220. if (isset ( $endStaffArray ['ROLE'] )) {
  7221. } else {
  7222. // $endKey=key($verifyStaff);
  7223. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  7224. // $button=4;
  7225. // $verifyList[$k]['status']=4;
  7226. // }
  7227. }
  7228. }
  7229. }
  7230. $rolename ['name'] = '';
  7231. if (! empty ( $roleId )) {
  7232. Doo::loadModel ( 'role' );
  7233. $role = new role ();
  7234. $rolename = $role->getOne ( array (
  7235. 'where' => 'rid=' . $roleId,
  7236. 'asArray' => true
  7237. ) );
  7238. }
  7239. if (! empty ( $verifyStaff ))
  7240. $endStaffArray = end ( $verifyStaff );
  7241. $KOP = false;
  7242. foreach ( $roleArrayCopy as $P => $A ) {
  7243. foreach ( $A as $MKI => $AVL ) {
  7244. if (! empty ( $verifyStaff )) {
  7245. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7246. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7247. $button = 4;
  7248. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7249. }
  7250. foreach ( $verifyStaff as $m => $u ) {
  7251. $AVLFK = $AVL [0] . '_R';
  7252. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7253. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7254. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7255. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7256. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7257. break;
  7258. }
  7259. }
  7260. } else {
  7261. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7262. $button = 4;
  7263. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7264. }
  7265. }
  7266. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7267. $KOP = true;
  7268. }
  7269. }
  7270. foreach ( $roleArrayCopy as $k => $v ) {
  7271. foreach ( $verifyList as $m => $n ) {
  7272. if ($n [0] == $k) {
  7273. array_splice ( $verifyList, $m, 1, $v );
  7274. }
  7275. }
  7276. }
  7277. $receiptList [$key] ['verifyList'] = $verifyList;
  7278. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7279. 'where' => 'sid=' . $value ['staff'],
  7280. 'asArray' => true
  7281. ) );
  7282. $receiptList [$key] ['button'] = $button;
  7283. }
  7284. // print_r($receiptList);die;
  7285. $mothHtml = "";
  7286. for($i = 1; $i <= 12; $i ++) {
  7287. if ($moth == $i)
  7288. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7289. else
  7290. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7291. }
  7292. $data ['mothHtml'] = $mothHtml;
  7293. $data ['receiptList'] = $receiptList;
  7294. $data ['memu'] = "receipt";
  7295. $data ['staff'] = $this->staff;
  7296. $data ['receiptMemu'] = 'receipt';
  7297. $data ['verifyId'] = $this->verifyId;
  7298. $data ['executeId'] = $this->executeId;
  7299. $data ['item'] = $item;
  7300. $data ['year'] = $year;
  7301. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  7302. // sufficient condition to generate cache
  7303. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  7304. $receiptList = $receipt->find ( array (
  7305. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7306. 'asArray' => true
  7307. ) );
  7308. if (empty ( $receiptList )) { // generated files
  7309. ob_start ();
  7310. $this->render ( "/admin/saea_myList", $data );
  7311. $this->cacheFile ( $path );
  7312. die ();
  7313. // $content = ob_get_contents();
  7314. // $fp = fopen($path, "w");
  7315. // fwrite($fp, $content);
  7316. // fclose($fp);
  7317. }
  7318. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  7319. $receiptList = $receipt->find ( array (
  7320. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  7321. 'asArray' => true
  7322. ) );
  7323. if (empty ( $receiptList )) { // generated files
  7324. ob_start ();
  7325. $this->render ( "/admin/saea_myList", $data );
  7326. $this->cacheFile ( $path );
  7327. die ();
  7328. }
  7329. }
  7330. }
  7331. $this->render ( "/admin/saea_myList", $data );
  7332. }
  7333. function approvedReceipt() {
  7334. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7335. Doo::loadModel ( 'receipt' );
  7336. Doo::loadModel ( 'receiptDetail' );
  7337. $receipt = new receipt ();
  7338. $receiptDetail = new receiptDetail ();
  7339. Doo::loadModel ( 'statistics' );
  7340. Doo::loadModel ( 'itemStatistics' );
  7341. $statistics = new statistics ();
  7342. $itemStatistics = new itemStatistics ();
  7343. Doo::loadModel ( "verify" );
  7344. $verify = new verify ();
  7345. // 审批状态的判定
  7346. $receiptDetailList = $receipt->getOne ( array (
  7347. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7348. 'asArray' => true
  7349. ) );
  7350. if (empty ( $receiptDetailList ))
  7351. return "/saeaBorad";
  7352. $verifyDetail = $verify->getOne ( array (
  7353. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7354. 'asArray' => true
  7355. ) );
  7356. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7357. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7358. $nowStaff = "";
  7359. $nowStaffList = array ();
  7360. if ($verifyDetail [0] [1] == 'ROLE') {
  7361. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7362. foreach ( $vStaffString as $key => $value ) {
  7363. $staffK = explode ( "_", $value );
  7364. array_push ( $nowStaffList, $staffK [0] );
  7365. }
  7366. $nowStaff = implode ( ',', $nowStaffList );
  7367. } else {
  7368. $nowStaff = $verifyDetail [0] [0];
  7369. }
  7370. $receipt->nowStaff = $nowStaff;
  7371. }
  7372. // echo $nowStaff;
  7373. // print_r($verifyDetail);die;
  7374. $receipt->rid = $receiptDetailList ['rid'];
  7375. $receipt->date = date ( "Y-m-d" );
  7376. $receipt->status = 2;
  7377. $receipt->update ();
  7378. $receiptDetail->status = 2;
  7379. $receiptDetail->update ( array (
  7380. 'where' => 'rid=' . $receiptDetailList ['rid']
  7381. ) );
  7382. Doo::loadModel ( "receiptLog" );
  7383. $receiptLog = new receiptLog ();
  7384. Doo::loadModel ( "verify" );
  7385. $verify = new verify ();
  7386. $receiptInfo = $receipt->getOne ( array (
  7387. 'where' => 'rid=' . $rid,
  7388. 'asArray' => true
  7389. ) );
  7390. $vr = $verify->getOne ( array (
  7391. 'where' => 'vid=' . $receiptInfo ['verify'],
  7392. 'asArray' => true
  7393. ) );
  7394. $jd = json_decode ( $vr ['staff'] );
  7395. $roleId = 0;
  7396. foreach ( $jd as $key => $value ) {
  7397. if ($value [1] == 'ROLE') {
  7398. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7399. if ($pos !== false) {
  7400. $roleId = $value [0];
  7401. }
  7402. }
  7403. }
  7404. // 审批日志
  7405. // echo $roleId;die;
  7406. if (! empty ( $roleId )) {
  7407. Doo::loadModel ( "role" );
  7408. $role = new role ();
  7409. $roleInfo = $role->getOne ( array (
  7410. 'where' => 'rid=' . $roleId,
  7411. 'asArray' => true
  7412. ) );
  7413. // $receiptLog->rolename = $roleInfo ['name'];
  7414. }
  7415. $receiptLog->username = $this->staff [0] ['username'];
  7416. $receiptLog->uid = $this->staff [0] ['sid'];
  7417. $receiptLog->date = date ( "Y-m-d" );
  7418. $receiptLog->opinion = '提交审批';
  7419. $receiptLog->img = $this->staff [0] ['avatar'];
  7420. $receiptLog->status = 2;
  7421. $receiptLog->rid = $rid;
  7422. $receiptLog->insert ();
  7423. // statistics item
  7424. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7425. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7426. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7427. $stat = $statistics->getOne ( array (
  7428. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7429. 'asArray' => true
  7430. ) );
  7431. if (empty ( $stat )) {
  7432. $statistics->date = date ( "Y-m-d" );
  7433. $statistics->cid = $this->staff [0] ['cid'];
  7434. $statistics->staff = $this->staff [0] ['sid'];
  7435. $statistics->agPrice = 0;
  7436. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7437. $statistics->insert ();
  7438. } else {
  7439. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7440. $statistics->update ( array (
  7441. 'where' => 'sid=' . $stat ['sid']
  7442. ) );
  7443. }
  7444. return "/expenses";
  7445. }
  7446. function approval() {
  7447. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7448. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7449. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7450. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7451. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7452. if (empty ( $status ))
  7453. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7454. $vidList = array ();
  7455. $button = 0;
  7456. Doo::loadModel ( 'verify' );
  7457. $verify = new verify ();
  7458. Doo::loadModel ( 'receipt' );
  7459. $receipt = new receipt ();
  7460. Doo::loadModel ( 'staff' );
  7461. $staff = new staff ();
  7462. Doo::loadModel ( 'L_category' );
  7463. $Lcategory = new L_category ();
  7464. // user verify ID
  7465. $verifyDetail = $verify->find ( array (
  7466. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7467. 'asArray' => true
  7468. ) );
  7469. foreach ( $verifyDetail as $key => $value ) {
  7470. array_push ( $vidList, $value ['vid'] );
  7471. }
  7472. $vid = implode ( ",", $vidList );
  7473. if (empty ( $verifyDetail ))
  7474. $vid = 0;
  7475. /*
  7476. */
  7477. $dateCondition = " and Year(date) =" . $year;
  7478. if (! empty ( $month ))
  7479. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7480. $categoryList = $Lcategory->find ( array (
  7481. 'asArray' => true
  7482. ) );
  7483. $staffList = $staff->find ( array (
  7484. 'where' => 'cid=' . $cid,
  7485. 'asArray' => true
  7486. ) );
  7487. $cateCondition = "";
  7488. $staffCondition = "";
  7489. $approvalCondition = "";
  7490. if (! empty ( $cid ))
  7491. $cateCondition = ' and cid=' . $cid;
  7492. if (! empty ( $sid )) {
  7493. $staffCondition = ' and staff=' . $sid;
  7494. $cateCondition = "";
  7495. }
  7496. // elseif($status==1){
  7497. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7498. // }
  7499. if ($status == 2) {
  7500. // 查找角色审批人
  7501. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7502. }
  7503. $ap = "";
  7504. if ($status == 4) {
  7505. $ap = 4;
  7506. $status = 2;
  7507. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7508. }
  7509. if ($status == 5) {
  7510. $status = 4;
  7511. $ap = 5;
  7512. }
  7513. // echo $vid;
  7514. // get Receipt By verifyID status 2 .$approvalCondition
  7515. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7516. $receiptList = $receipt->find ( array (
  7517. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7518. 'desc' => 'rid',
  7519. 'asArray' => true
  7520. ) );
  7521. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7522. $Locate = 0;
  7523. if ($ap == 4)
  7524. $status = 4;
  7525. elseif ($ap == 5)
  7526. $status = 5;
  7527. foreach ( $receiptList as $key => $value ) {
  7528. $receiptList [$key] ['Locate'] = $Locate;
  7529. $Locate ++;
  7530. $receiptList [$key] ['reviseDetail'] = array ();
  7531. if (! empty ( $value ['reviseDetail'] ))
  7532. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7533. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7534. $categoryDetil = $Lcategory->getOne ( array (
  7535. 'where' => 'cid=' . $value ['cid'],
  7536. 'asArray' => true
  7537. ) );
  7538. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7539. $verifyList = $verify->getOne ( array (
  7540. 'where' => 'vid=' . $value ['verify'],
  7541. 'asArray' => true
  7542. ) );
  7543. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7544. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7545. foreach ( $verifyList as $k => $v ) {
  7546. // init verifyStaff
  7547. $verifyList [$k] ['date'] = "";
  7548. $verifyList [$k] ['opinion'] = "";
  7549. $verifyList [$k] ['status'] = "";
  7550. if (empty ( $verifyStaff )) {
  7551. $verifyList [$k] ['date'] = "";
  7552. $verifyList [$k] ['opinion'] = "";
  7553. if ($v [0] == $this->staff [0] ['sid']) {
  7554. $verifyList [$k] ['status'] = 4;
  7555. $button = 4;
  7556. }
  7557. } else {
  7558. $flag = true;
  7559. foreach ( $verifyStaff as $m => $u ) {
  7560. if ($v [0] == $m) {
  7561. $verifyList [$k] ['date'] = $u ['date'];
  7562. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7563. $verifyList [$k] ['status'] = $u ['status'];
  7564. $flag = false;
  7565. break;
  7566. }
  7567. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7568. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7569. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7570. }
  7571. if ($flag) { // 检测可编辑
  7572. if ($v [0] == $this->staff [0] ['sid']) {
  7573. $verifyList [$k] ['status'] = 4;
  7574. $button = 4;
  7575. }
  7576. }
  7577. }
  7578. }
  7579. $receiptList [$key] ['verifyList'] = $verifyList;
  7580. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7581. 'where' => 'sid=' . $value ['staff'],
  7582. 'asArray' => true
  7583. ) );
  7584. $receiptList [$key] ['button'] = $button;
  7585. }
  7586. // print_r($receiptList);die;
  7587. // $data['verifyDetail']=$verifyDetail;
  7588. $mothHtml = "";
  7589. for($i = 1; $i <= 12; $i ++) {
  7590. if ($month == $i)
  7591. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7592. else
  7593. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7594. }
  7595. $data ['mothHtml'] = $mothHtml;
  7596. $data ['receiptList'] = $receiptList;
  7597. $data ['receiptApprovalCount'] = count ( $receiptList );
  7598. $data ['status'] = $status;
  7599. $data ['year'] = $year;
  7600. $data ['categoryList'] = $categoryList;
  7601. $data ['staffList'] = $staffList;
  7602. $data ['cid'] = $cid;
  7603. $data ['sid'] = $sid;
  7604. $data ['ap'] = $ap;
  7605. $data ['memu'] = "receipt";
  7606. $data ['staff'] = $this->staff;
  7607. $data ['receiptMemu'] = 'approval';
  7608. $data ['verifyId'] = $this->verifyId;
  7609. $data ['executeId'] = $this->executeId;
  7610. $this->render ( "/admin/saea_reportList", $data );
  7611. }
  7612. function approvalDetails() {
  7613. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7614. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7615. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7616. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7617. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7618. Doo::loadModel ( 'verify' );
  7619. $verify = new verify ();
  7620. Doo::loadModel ( 'receipt' );
  7621. $receipt = new receipt ();
  7622. Doo::loadModel ( 'staff' );
  7623. $staff = new staff ();
  7624. Doo::loadModel ( 'L_category' );
  7625. $Lcategory = new L_category ();
  7626. Doo::loadModel ( 'enclosur' );
  7627. $enclosur = new enclosur ();
  7628. $vidList = array ();
  7629. $verifyDetail = $verify->find ( array (
  7630. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7631. 'asArray' => true
  7632. ) );
  7633. foreach ( $verifyDetail as $key => $value ) {
  7634. array_push ( $vidList, $value ['vid'] );
  7635. }
  7636. $vid = implode ( ",", $vidList );
  7637. if (empty ( $verifyDetail ))
  7638. $vid = 0;
  7639. $categoryList = $Lcategory->find ( array (
  7640. 'asArray' => true
  7641. ) );
  7642. $staffList = $staff->find ( array (
  7643. 'where' => 'cid=' . $cid,
  7644. 'asArray' => true
  7645. ) );
  7646. $ap = 0;
  7647. $receiptList = $receipt->find ( array (
  7648. 'where' => 'rid =' . $rid,
  7649. 'desc' => 'rid',
  7650. 'asArray' => true
  7651. ) );
  7652. $Locate = 0;
  7653. $roleId = 0;
  7654. $button = 0;
  7655. foreach ( $receiptList as $key => $value ) {
  7656. $receiptList [$key] ['Locate'] = $Locate;
  7657. $Locate ++;
  7658. $receiptList [$key] ['reviseDetail'] = array ();
  7659. if (! empty ( $value ['reviseDetail'] ))
  7660. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7661. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7662. $categoryDetil = $Lcategory->getOne ( array (
  7663. 'where' => 'cid=' . $value ['cid'],
  7664. 'asArray' => true
  7665. ) );
  7666. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7667. // 检测编辑状态
  7668. $verifyList = $verify->getOne ( array (
  7669. 'where' => 'vid=' . $value ['verify'],
  7670. 'asArray' => true
  7671. ) );
  7672. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7673. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7674. Doo::loadModel ( 'role' );
  7675. $role = new role ();
  7676. // print_r($verifyList);
  7677. $flag = true;
  7678. $roleKey = 0;
  7679. $endStaffArray = array ();
  7680. $roleArrayCopy = array ();
  7681. foreach ( $verifyList as $k => $v ) {
  7682. // init verifyStaff
  7683. if ($v [1] == 'ROLE') {
  7684. if (! empty ( $verifyStaff )) {
  7685. $endStaffArray = end ( $verifyStaff );
  7686. if ($v [0] == $endStaffArray ['nextStaff']) {
  7687. $roleId = $v [0];
  7688. }
  7689. }
  7690. $roleVerify = json_decode ( $v [3], true );
  7691. $roleKey = $k;
  7692. $roleArray = array ();
  7693. $rolename = $role->getOne ( array (
  7694. 'where' => 'rid=' . $v [0],
  7695. 'asArray' => true
  7696. ) );
  7697. foreach ( $roleVerify as $o => $p ) {
  7698. $staffID = explode ( '_', $p );
  7699. $staffInfo = $staff->getOne ( array (
  7700. 'where' => 'sid=' . $staffID [0],
  7701. 'asArray' => true
  7702. ) );
  7703. // print_r($staffID);
  7704. $exp = array (
  7705. 0 => $staffInfo ['sid'],
  7706. 1 => $staffID [1],
  7707. 2 => $staffInfo ['avatar'],
  7708. 'date' => '',
  7709. 'date' => '',
  7710. 'opinion' => '',
  7711. 'status' => '',
  7712. 'rolename' => $rolename ['name']
  7713. );
  7714. array_push ( $roleArray, $exp );
  7715. }
  7716. $roleArrayCopy [$v [0]] = $roleArray;
  7717. // $verifyList[$k]['roleArray']=$roleArray;
  7718. }
  7719. // print_r($roleArray);
  7720. $verifyList [$k] ['date'] = "";
  7721. $verifyList [$k] ['opinion'] = "";
  7722. $verifyList [$k] ['status'] = "";
  7723. if (empty ( $verifyStaff )) {
  7724. $verifyList [$k] ['date'] = "";
  7725. $verifyList [$k] ['opinion'] = "";
  7726. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7727. $verifyList [$k] ['status'] = 4;
  7728. $button = 4;
  7729. $flag = false;
  7730. }
  7731. } else {
  7732. foreach ( $verifyStaff as $m => $u ) {
  7733. if ($v [0] == $m) {
  7734. $verifyList [$k] ['date'] = $u ['date'];
  7735. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7736. $verifyList [$k] ['status'] = $u ['status'];
  7737. $flag = false;
  7738. break;
  7739. }
  7740. }
  7741. $endStaffArray = end ( $verifyStaff );
  7742. if (isset ( $endStaffArray ['ROLE'] )) {
  7743. } else {
  7744. $endKey = key ( $verifyStaff );
  7745. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7746. $button = 4;
  7747. $verifyList [$k] ['status'] = 4;
  7748. }
  7749. }
  7750. }
  7751. }
  7752. $rolename ['name'] = '';
  7753. if (! empty ( $roleId )) {
  7754. Doo::loadModel ( 'role' );
  7755. $role = new role ();
  7756. $rolename = $role->getOne ( array (
  7757. 'where' => 'rid=' . $roleId,
  7758. 'asArray' => true
  7759. ) );
  7760. }
  7761. if (! empty ( $verifyStaff ))
  7762. $endStaffArray = end ( $verifyStaff );
  7763. $KOP = false;
  7764. foreach ( $roleArrayCopy as $P => $A ) {
  7765. foreach ( $A as $MKI => $AVL ) {
  7766. if (! empty ( $verifyStaff )) {
  7767. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7768. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7769. $button = 4;
  7770. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7771. }
  7772. foreach ( $verifyStaff as $m => $u ) {
  7773. $AVLFK = $AVL [0] . '_R';
  7774. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7775. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7776. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7777. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7778. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7779. break;
  7780. }
  7781. }
  7782. } else {
  7783. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7784. $button = 4;
  7785. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7786. }
  7787. }
  7788. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7789. $KOP = true;
  7790. }
  7791. }
  7792. foreach ( $roleArrayCopy as $k => $v ) {
  7793. foreach ( $verifyList as $m => $n ) {
  7794. if ($n [0] == $k) {
  7795. array_splice ( $verifyList, $m, 1, $v );
  7796. }
  7797. }
  7798. }
  7799. $receiptList [$key] ['verifyList'] = $verifyList;
  7800. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7801. 'where' => 'sid=' . $value ['staff'],
  7802. 'asArray' => true
  7803. ) );
  7804. $receiptList [$key] ['button'] = $button;
  7805. }
  7806. $mothHtml = "";
  7807. for($i = 1; $i <= 12; $i ++) {
  7808. if ($month == $i)
  7809. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7810. else
  7811. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7812. }
  7813. // 获取审批日志
  7814. Doo::loadModel ( 'receiptLog' );
  7815. $receiptLog = new receiptLog ();
  7816. $rlList = array ();
  7817. $rlInfo = $receiptLog->getOne ( array (
  7818. 'where' => 'rid=' . $rid . ' and status=4',
  7819. 'asArray' => true
  7820. ) );
  7821. $tijdate = $receiptLog->getOne ( array (
  7822. 'where' => 'rid=' . $rid . ' and status=2',
  7823. 'asc' => 'rlid',
  7824. 'asArray' => true
  7825. ) );
  7826. if (! empty ( $rlInfo )) {
  7827. $rlList = $receiptLog->find ( array (
  7828. 'where' => 'rid=' . $rid,
  7829. 'asc' => 'rlid',
  7830. 'asArray' => true
  7831. ) );
  7832. }
  7833. $receiptList [0] ['rlList'] = $rlList;
  7834. $enclosurList = $enclosur->find ( array (
  7835. 'where' => 'rid=' . $rid,
  7836. 'asArray' => true
  7837. ) );
  7838. $enclosurHtml = '';
  7839. foreach ( $enclosurList as $value ) {
  7840. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7841. }
  7842. $data ['enclosurHtml'] = $enclosurHtml;
  7843. $data ['rolename'] = $rolename ['name'];
  7844. $data ['datetij'] = $tijdate ['date'];
  7845. $data ['mothHtml'] = $mothHtml;
  7846. $data ['receiptList'] = $receiptList;
  7847. $data ['receiptApprovalCount'] = count ( $receiptList );
  7848. $data ['year'] = $year;
  7849. $data ['categoryList'] = $categoryList;
  7850. $data ['staffList'] = $staffList;
  7851. $data ['cid'] = $cid;
  7852. $data ['sid'] = $sid;
  7853. $data ['status'] = 0;
  7854. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7855. $ap = 4;
  7856. } else
  7857. $data ['status'] = $receiptList [0] ['status'];
  7858. if ($receiptList [0] ['status'] == 4) {
  7859. $data ['status'] = 5;
  7860. $ap = 0;
  7861. }
  7862. $data ['ap'] = $ap;
  7863. $data ['memu'] = "receipt";
  7864. $data ['staff'] = $this->staff;
  7865. $data ['receiptMemu'] = 'approval';
  7866. $data ['verifyId'] = $this->verifyId;
  7867. $data ['executeId'] = $this->executeId;
  7868. $this->render ( "/admin/saeaReportListReport", $data );
  7869. }
  7870. function approvalEdi() {
  7871. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7872. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7873. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7874. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7875. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7876. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7877. if (empty ( $status ))
  7878. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7879. $vidList = array ();
  7880. $button = 0;
  7881. Doo::loadModel ( 'verify' );
  7882. Doo::loadModel ( 'receipt' );
  7883. Doo::loadModel ( 'staff' );
  7884. $staff = new staff ();
  7885. $receipt = new receipt ();
  7886. $verify = new verify ();
  7887. Doo::loadModel ( 'L_category' );
  7888. $Lcategory = new L_category ();
  7889. Doo::loadModel ( 'enclosur' );
  7890. $enclosur = new enclosur ();
  7891. // user verify ID
  7892. $verifyDetail = $verify->find ( array (
  7893. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7894. 'asArray' => true
  7895. ) );
  7896. foreach ( $verifyDetail as $key => $value ) {
  7897. array_push ( $vidList, $value ['vid'] );
  7898. }
  7899. $vid = implode ( ",", $vidList );
  7900. if (empty ( $verifyDetail ))
  7901. $vid = 0;
  7902. $categoryList = $Lcategory->find ( array (
  7903. 'asArray' => true
  7904. ) );
  7905. $staffList = $staff->find ( array (
  7906. 'where' => 'cid=' . $cid,
  7907. 'asArray' => true
  7908. ) );
  7909. $ap = "";
  7910. if ($status == 4) {
  7911. $ap = 4;
  7912. $status = 2;
  7913. }
  7914. // get Receipt By verifyID status 2
  7915. $receiptList = $receipt->find ( array (
  7916. 'where' => 'rid =' . $rid,
  7917. 'desc' => 'rid',
  7918. 'asArray' => true
  7919. ) );
  7920. $Locate = 0;
  7921. $roleId = 0;
  7922. if ($ap == 4)
  7923. $status = 4;
  7924. foreach ( $receiptList as $key => $value ) {
  7925. $receiptList [$key] ['Locate'] = $Locate;
  7926. $Locate ++;
  7927. $receiptList [$key] ['reviseDetail'] = array ();
  7928. if (! empty ( $value ['reviseDetail'] ))
  7929. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7930. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7931. $categoryDetil = $Lcategory->getOne ( array (
  7932. 'where' => 'cid=' . $value ['cid'],
  7933. 'asArray' => true
  7934. ) );
  7935. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7936. // 检测编辑状态
  7937. $verifyList = $verify->getOne ( array (
  7938. 'where' => 'vid=' . $value ['verify'],
  7939. 'asArray' => true
  7940. ) );
  7941. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7942. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7943. // print_r($verifyList);
  7944. //
  7945. // if (empty($verifyStaff)){
  7946. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7947. // $verifyList[0]['status']=4;$button=4;
  7948. // }
  7949. //
  7950. // }else{
  7951. //
  7952. // }
  7953. // die;
  7954. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7955. // echo array_search("green",$a);
  7956. //
  7957. Doo::loadModel ( 'role' );
  7958. $role = new role ();
  7959. // print_r($verifyList);
  7960. $flag = true;
  7961. $roleKey = 0;
  7962. $endStaffArray = array ();
  7963. $roleArrayCopy = array ();
  7964. foreach ( $verifyList as $k => $v ) {
  7965. // init verifyStaff
  7966. if ($v [1] == 'ROLE') {
  7967. if (! empty ( $verifyStaff )) {
  7968. $endStaffArray = end ( $verifyStaff );
  7969. if ($v [0] == $endStaffArray ['nextStaff']) {
  7970. $roleId = $v [0];
  7971. }
  7972. }
  7973. $roleVerify = json_decode ( $v [3], true );
  7974. $roleKey = $k;
  7975. $roleArray = array ();
  7976. $rolename = $role->getOne ( array (
  7977. 'where' => 'rid=' . $v [0],
  7978. 'asArray' => true
  7979. ) );
  7980. foreach ( $roleVerify as $o => $p ) {
  7981. $staffID = explode ( '_', $p );
  7982. $staffInfo = $staff->getOne ( array (
  7983. 'where' => 'sid=' . $staffID [0],
  7984. 'asArray' => true
  7985. ) );
  7986. // print_r($staffID);
  7987. $exp = array (
  7988. 0 => $staffInfo ['sid'],
  7989. 1 => $staffID [1],
  7990. 2 => $staffInfo ['avatar'],
  7991. 'date' => '',
  7992. 'date' => '',
  7993. 'opinion' => '',
  7994. 'status' => '',
  7995. 'rolename' => $rolename ['name']
  7996. );
  7997. array_push ( $roleArray, $exp );
  7998. }
  7999. $roleArrayCopy [$v [0]] = $roleArray;
  8000. // $verifyList[$k]['roleArray']=$roleArray;
  8001. }
  8002. // print_r($roleArray);
  8003. $verifyList [$k] ['date'] = "";
  8004. $verifyList [$k] ['opinion'] = "";
  8005. $verifyList [$k] ['status'] = "";
  8006. if (empty ( $verifyStaff )) {
  8007. $verifyList [$k] ['date'] = "";
  8008. $verifyList [$k] ['opinion'] = "";
  8009. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  8010. $verifyList [$k] ['status'] = 4;
  8011. $button = 4;
  8012. $flag = false;
  8013. }
  8014. } else {
  8015. foreach ( $verifyStaff as $m => $u ) {
  8016. if ($v [0] == $m) {
  8017. $verifyList [$k] ['date'] = $u ['date'];
  8018. $verifyList [$k] ['opinion'] = $u ['opinion'];
  8019. $verifyList [$k] ['status'] = $u ['status'];
  8020. $flag = false;
  8021. break;
  8022. }
  8023. }
  8024. $endStaffArray = end ( $verifyStaff );
  8025. if (isset ( $endStaffArray ['ROLE'] )) {
  8026. } else {
  8027. $endKey = key ( $verifyStaff );
  8028. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  8029. $button = 4;
  8030. $verifyList [$k] ['status'] = 4;
  8031. }
  8032. }
  8033. // print_r($endStaffArray);die;
  8034. // if (empty($verifyStaff)){
  8035. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  8036. // $verifyList[$k]['status']=4;$button=4;
  8037. // }
  8038. //
  8039. // }else{
  8040. //
  8041. // }
  8042. // if($flag){//检测可编辑
  8043. // if($v[0]==$this->staff[0]['sid']){
  8044. // $verifyList[$k]['status']=4;$button=4;
  8045. // }
  8046. // }
  8047. }
  8048. }
  8049. $rolename ['name'] = '';
  8050. if (! empty ( $roleId )) {
  8051. Doo::loadModel ( 'role' );
  8052. $role = new role ();
  8053. $rolename = $role->getOne ( array (
  8054. 'where' => 'rid=' . $roleId,
  8055. 'asArray' => true
  8056. ) );
  8057. }
  8058. if (! empty ( $verifyStaff ))
  8059. $endStaffArray = end ( $verifyStaff );
  8060. $KOP = false;
  8061. foreach ( $roleArrayCopy as $P => $A ) {
  8062. foreach ( $A as $MKI => $AVL ) {
  8063. if (! empty ( $verifyStaff )) {
  8064. // &&$rolename['rid']==$endStaffArray['nextStaff']
  8065. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  8066. $button = 4;
  8067. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8068. }
  8069. foreach ( $verifyStaff as $m => $u ) {
  8070. $AVLFK = $AVL [0] . '_R';
  8071. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  8072. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  8073. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  8074. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  8075. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  8076. break;
  8077. }
  8078. }
  8079. } else {
  8080. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  8081. $button = 4;
  8082. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  8083. }
  8084. }
  8085. // $roleArray[$MKI]['rolename']=$rolename['name'];
  8086. $KOP = true;
  8087. }
  8088. }
  8089. // print_r($roleArrayCopy);
  8090. // echo $roleKey;
  8091. foreach ( $roleArrayCopy as $k => $v ) {
  8092. foreach ( $verifyList as $m => $n ) {
  8093. if ($n [0] == $k) {
  8094. array_splice ( $verifyList, $m, 1, $v );
  8095. }
  8096. }
  8097. }
  8098. // if ($KOP)
  8099. // array_splice($verifyList,$roleKey,1,$roleArray);
  8100. // print_r($verifyList);
  8101. $receiptList [$key] ['verifyList'] = $verifyList;
  8102. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  8103. 'where' => 'sid=' . $value ['staff'],
  8104. 'asArray' => true
  8105. ) );
  8106. $receiptList [$key] ['button'] = $button;
  8107. }
  8108. // $data['verifyDetail']=$verifyDetail;
  8109. $mothHtml = "";
  8110. for($i = 1; $i <= 12; $i ++) {
  8111. if ($month == $i)
  8112. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8113. else
  8114. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8115. }
  8116. // 获取审批日志
  8117. Doo::loadModel ( 'receiptLog' );
  8118. $receiptLog = new receiptLog ();
  8119. $rlList = array ();
  8120. $rlInfo = $receiptLog->getOne ( array (
  8121. 'where' => 'rid=' . $rid . ' and status=4',
  8122. 'asArray' => true
  8123. ) );
  8124. $tijdate = $receiptLog->getOne ( array (
  8125. 'where' => 'rid=' . $rid . ' and status=2',
  8126. 'asc' => 'rlid',
  8127. 'asArray' => true
  8128. ) );
  8129. if (! empty ( $rlInfo )) {
  8130. $rlList = $receiptLog->find ( array (
  8131. 'where' => 'rid=' . $rid,
  8132. 'asc' => 'rlid',
  8133. 'asArray' => true
  8134. ) );
  8135. }
  8136. $receiptList [0] ['rlList'] = $rlList;
  8137. $enclosurList = $enclosur->find ( array (
  8138. 'where' => 'rid=' . $rid,
  8139. 'asArray' => true
  8140. ) );
  8141. $enclosurHtml = '';
  8142. foreach ( $enclosurList as $value ) {
  8143. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  8144. }
  8145. $data ['enclosurHtml'] = $enclosurHtml;
  8146. $data ['rolename'] = $rolename ['name'];
  8147. $data ['datetij'] = $tijdate ['date'];
  8148. $data ['mothHtml'] = $mothHtml;
  8149. $data ['receiptList'] = $receiptList;
  8150. $data ['receiptApprovalCount'] = count ( $receiptList );
  8151. $data ['status'] = $status;
  8152. $data ['year'] = $year;
  8153. $data ['categoryList'] = $categoryList;
  8154. $data ['staffList'] = $staffList;
  8155. $data ['cid'] = $cid;
  8156. $data ['sid'] = $sid;
  8157. $data ['ap'] = $ap;
  8158. $data ['memu'] = "receipt";
  8159. $data ['staff'] = $this->staff;
  8160. $data ['receiptMemu'] = 'approval';
  8161. $data ['verifyId'] = $this->verifyId;
  8162. $data ['executeId'] = $this->executeId;
  8163. $this->render ( "/admin/saeaReportListReport", $data );
  8164. }
  8165. function remittanceHky() {
  8166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8167. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  8168. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  8169. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8170. $page_size = 15;
  8171. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  8172. Doo::loadModel ( 'receipt' );
  8173. $receipt = new receipt ();
  8174. Doo::loadModel ( 'staff' );
  8175. $staff = new staff ();
  8176. $dateCondition = " and Year(executeDate) =" . $year;
  8177. if ($moth != 'MONTH')
  8178. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  8179. if ($day != 'DAY' && $moth != 'MONTH')
  8180. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  8181. $sql = ' (status =8 or status=9 ) and amount>0 ' . $dateCondition;
  8182. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  8183. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  8184. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8185. $dayList = $receipt->find ( array (
  8186. 'select' => 'executeDate,sum(amount) as amount',
  8187. 'where' => $sql,
  8188. 'desc' => 'executeDate',
  8189. 'groupby' => 'executeDate',
  8190. 'limit' => $limit,
  8191. 'asArray' => true
  8192. ) );
  8193. // print_r($dayList);
  8194. foreach ( $dayList as $key => $value ) {
  8195. $remitString = "";
  8196. $receiptList = $receipt->find ( array (
  8197. 'select' => 'rid,executeDate,amount,staff,cid',
  8198. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  8199. 'desc' => 'executeDate',
  8200. 'asArray' => true
  8201. ) );
  8202. foreach ( $receiptList as $k => $v ) {
  8203. $sinfo = $staff->getOne ( array (
  8204. 'select' => 'username,category',
  8205. 'where' => ' sid=' . $v ['staff'],
  8206. 'asArray' => true
  8207. ) );
  8208. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  8209. }
  8210. $dayList [$key] ['staff'] = $remitString;
  8211. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  8212. }
  8213. // print_r($dayList);
  8214. $mothHtml = "";
  8215. for($i = 1; $i <= 12; $i ++) {
  8216. if ($moth == $i)
  8217. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8218. else
  8219. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8220. }
  8221. $dayHtml = "";
  8222. if ($day != "DAY" || $moth != "MONTH") {
  8223. for($i = 1; $i <= 31; $i ++) {
  8224. if ($day == $i)
  8225. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  8226. else
  8227. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  8228. }
  8229. }
  8230. $dateHtml = "";
  8231. $now = date ( "Y" );
  8232. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8233. if ($YEARD <= $now) {
  8234. $dateHtml .= '<option ';
  8235. if ($year == $YEARD) {
  8236. $dateHtml .= 'selected ';
  8237. }
  8238. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8239. }
  8240. }
  8241. $data ['dateHtml'] = $dateHtml;
  8242. $data ['page'] = $pageinfo;
  8243. $data ['year'] = $year;
  8244. $data ['moth'] = $moth;
  8245. $data ['day'] = $day;
  8246. $data ['get'] = $get;
  8247. $data ['dayHtml'] = $dayHtml;
  8248. $data ['mothHtml'] = $mothHtml;
  8249. $data ['receiptList'] = $dayList;
  8250. $data ['memu'] = "receipt";
  8251. $data ['staff'] = $this->staff;
  8252. $data ['receiptMemu'] = 'remittanceHky';
  8253. $data ['verifyId'] = $this->verifyId;
  8254. $data ['executeId'] = $this->executeId;
  8255. $this->render ( "/admin/remittanceHky", $data );
  8256. }
  8257. function remittancep() {
  8258. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  8259. Doo::loadModel ( 'receipt' );
  8260. $receipt = new receipt ();
  8261. Doo::loadModel ( 'staff' );
  8262. $staff = new staff ();
  8263. Doo::loadClass ( 'XDeode' );
  8264. $XDeode = new XDeode ( 5 );
  8265. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  8266. $rplist = $receipt->find ( array (
  8267. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8268. 'asArray' => true
  8269. ) );
  8270. $dayList = $receipt->find ( array (
  8271. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  8272. 'desc' => 'executeDate',
  8273. 'groupby' => 'staff',
  8274. 'asArray' => true
  8275. ) );
  8276. $html = '';
  8277. foreach ( $dayList as $key => $value ) {
  8278. $sinfo = $staff->getOne ( array (
  8279. 'select' => 'username,category',
  8280. 'where' => ' sid=' . $value ['staff'],
  8281. 'asArray' => true
  8282. ) );
  8283. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  8284. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  8285. $au = 0;
  8286. foreach ( $rplist as $k => $v ) {
  8287. if ($value ['staff'] == $v ['staff']) {
  8288. $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>';
  8289. $au += $v ['amount'];
  8290. }
  8291. }
  8292. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  8293. }
  8294. $data ['html'] = $html;
  8295. $data ['memu'] = "receipt";
  8296. $data ['staff'] = $this->staff;
  8297. $data ['receiptMemu'] = 'remittanceHky';
  8298. $data ['verifyId'] = $this->verifyId;
  8299. $data ['executeId'] = $this->executeId;
  8300. $this->render ( "/admin/remittancep", $data );
  8301. }
  8302. function ajaxGetReceiptDetails() {
  8303. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  8304. Doo::loadClass ( 'XDeode' );
  8305. $XDeode = new XDeode ( 5 );
  8306. $rid = $XDeode->decode ( $rid );
  8307. if (empty ( $rid )) {
  8308. echo json_encode ( array (
  8309. 'status' => 2,
  8310. 'msg' => 'illegal request'
  8311. ) );
  8312. die ();
  8313. }
  8314. Doo::loadModel ( 'receipt' );
  8315. $receipt = new receipt ();
  8316. Doo::loadModel ( 'staff' );
  8317. $staff = new staff ();
  8318. $rinfo = $receipt->getOne ( array (
  8319. 'where' => 'rid= ' . $rid,
  8320. 'asArray' => true
  8321. ) );
  8322. $sinfo = $staff->getOne ( array (
  8323. 'select' => 'username,category',
  8324. 'where' => ' sid=' . $rinfo ['staff'],
  8325. 'asArray' => true
  8326. ) );
  8327. $rinfo ['reviseDetail'] = array ();
  8328. if (! empty ( $rinfo ['reviseDetail'] ))
  8329. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  8330. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  8331. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  8332. $rinfo ['category'] = $sinfo ['category'];
  8333. $verifyStaff = array ();
  8334. if (! empty ( $rinfo ['verifyStaff'] ))
  8335. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  8336. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  8337. $rinfo ['relust'] = $relust;
  8338. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  8339. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  8340. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  8341. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  8342. // 费用执行人相关数据
  8343. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  8344. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8345. foreach ( $executeCopy as $k => $v ) {
  8346. $executeCopy [$k] ['date'] = '';
  8347. $executeCopy [$k] ['opinion'] = '';
  8348. $executeCopy [$k] ['status'] = '';
  8349. if (! empty ( $executeStaff ))
  8350. foreach ( $executeStaff as $m => $u ) {
  8351. if ($v [0] == $m) {
  8352. $executeCopy [$k] ['date'] = $u ['date'];
  8353. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8354. $executeCopy [$k] ['status'] = $u ['status'];
  8355. break;
  8356. }
  8357. }
  8358. }
  8359. $rinfo ['executeCopy'] = $executeCopy;
  8360. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8361. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8362. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8363. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8364. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8365. $html .= '<tr><th>' . $value ['name'] . '</th>
  8366. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8367. }
  8368. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8369. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8370. <tr><th class="taC" colspan="2">费用说明</th>
  8371. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8372. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8373. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8374. </tbody></table>';
  8375. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8376. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8377. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8378. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8379. $html .= '<tr><th>' . $value ['name'] . '</th>
  8380. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8381. }
  8382. $html .= '<tr><th class="taR">合计</th>
  8383. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8384. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8385. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8386. $html .= '<tr><th>' . $value ['name'] . '</th>
  8387. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8388. }
  8389. $html .= '<tr><th class="taR">合计</th>
  8390. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8391. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8392. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8393. $html .= '<tr><th>' . $value ['name'] . '</th>
  8394. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8395. }
  8396. $html .= '<tr><th class="taR">合计</th>
  8397. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8398. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8399. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8400. $html .= '<tr><th>' . $value ['name'] . '</th>
  8401. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8402. }
  8403. $html .= '<tr><th class="taR">合计</th>
  8404. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8405. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8406. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8407. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8408. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8409. }
  8410. $html .= '<tr><th class="taR">合计</th>
  8411. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8412. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8413. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8414. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8415. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8416. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8417. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8418. <tr';
  8419. if ($rinfo ['relust'] >= 0) {
  8420. $html .= 'class="success"';
  8421. } else {
  8422. $html .= 'class="error"';
  8423. }
  8424. $html .= '><td class="taR"><b>借款结余</b></td>
  8425. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8426. </tbody></table>
  8427. ';
  8428. }
  8429. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8430. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8431. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8432. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8433. $html .= '<tr><th>' . $value ['name'] . '</th>
  8434. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8435. }
  8436. $html .= '<tr><th class="taR">合计</th>
  8437. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8438. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8439. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8440. <tr><th class="taC" colspan="2">费用说明</th>
  8441. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8442. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8443. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8444. </tbody></table>';
  8445. } else {
  8446. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8447. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8448. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8449. $html .= '<tr><th>' . $value ['name'] . '</th>
  8450. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8451. }
  8452. $html .= '<tr><th class="taR">合计</th>
  8453. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8454. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8455. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8456. $html .= '<tr><th>' . $value ['name'] . '</th>
  8457. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8458. }
  8459. $html .= '<tr><th class="taR">合计</th>
  8460. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8461. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8462. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8463. $html .= '<tr><th>' . $value ['name'] . '</th>
  8464. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8465. }
  8466. $html .= '<tr><th class="taR">合计</th>
  8467. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8468. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8469. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8470. $html .= '<tr><th>' . $value ['name'] . '</th>
  8471. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8472. }
  8473. $html .= '<tr><th class="taR">合计</th>
  8474. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8475. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8476. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8477. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8478. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8479. }
  8480. $html .= '<tr><th class="taR">合计</th>
  8481. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8482. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8483. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8484. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8485. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8486. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8487. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8488. $html .= '</tbody></table>';
  8489. /*
  8490. * <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>
  8491. */
  8492. }
  8493. // print_r($verifyStaff);die;
  8494. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8495. foreach ( $verifyStaff as $key => $value ) {
  8496. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8497. $sinfo = $staff->getOne ( array (
  8498. 'select' => 'username',
  8499. 'where' => ' sid=' . $key,
  8500. 'asArray' => true
  8501. ) );
  8502. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8503. }
  8504. $html .= '</tbody></table>';
  8505. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8506. foreach ( $rinfo ['executeCopy'] as $value ) {
  8507. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8508. }
  8509. $html .= '</tbody></table>';
  8510. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8511. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8512. </tr></table>';
  8513. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8514. echo json_encode ( array (
  8515. 'status' => 1,
  8516. 'html' => $html
  8517. ) );
  8518. die ();
  8519. }
  8520. /**
  8521. * 删除附件
  8522. */
  8523. function ajaxRemEnclousur() {
  8524. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8525. if (empty ( $key ))
  8526. echo json_encode ( array (
  8527. 'status' => 2
  8528. ) );
  8529. Doo::loadModel ( 'enclosur' );
  8530. $enclosur = new enclosur ();
  8531. $enclosur->delEnclosurByEid ( $key );
  8532. echo json_encode ( array (
  8533. 'status' => 1
  8534. ) );
  8535. }
  8536. function remittance() {
  8537. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8538. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8539. Doo::loadModel ( 'receipt' );
  8540. $receipt = new receipt ();
  8541. Doo::loadModel ( 'staff' );
  8542. $staff = new staff ();
  8543. $dateCondition = " and Year(pastDate) =" . $year;
  8544. if (! empty ( $month ))
  8545. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8546. // get Receipt By verifyID status 1
  8547. $receiptList = $receipt->find ( array (
  8548. 'select' => 'sum(sum) as sum,staff,pastDate',
  8549. 'where' => ' status=1' . $dateCondition,
  8550. 'desc' => 'pastDate',
  8551. 'groupby' => 'staff,pastDate',
  8552. 'asArray' => true
  8553. ) );
  8554. $dateList = $receipt->find ( array (
  8555. 'select' => 'pastDate,verifyStaff',
  8556. 'where' => ' status=1' . $dateCondition,
  8557. 'desc' => 'pastDate',
  8558. 'groupby' => 'pastDate',
  8559. 'asArray' => true
  8560. ) );
  8561. $dataList = array ();
  8562. foreach ( $dateList as $d => $a ) {
  8563. $dataList [$a ['pastDate']] = array ();
  8564. $daySum = 0;
  8565. foreach ( $receiptList as $key => $value ) {
  8566. if ($a ['pastDate'] == $value ['pastDate']) {
  8567. $oderList = $receipt->find ( array (
  8568. 'select' => 'receiptOrder',
  8569. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8570. 'asArray' => true
  8571. ) );
  8572. $list = array ();
  8573. $html = "";
  8574. foreach ( $oderList as $v ) {
  8575. array_push ( $list, $v ['receiptOrder'] );
  8576. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8577. }
  8578. $receiptList [$key] ['receiptOrder'] = $html;
  8579. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8580. $sinfo = $staff->getOne ( array (
  8581. 'select' => 'username ',
  8582. 'where' => ' sid=' . $value ['staff'],
  8583. 'asArray' => true
  8584. ) );
  8585. $receiptList [$key] ['username'] = $sinfo ['username'];
  8586. $daySum += $value ['sum'];
  8587. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8588. }
  8589. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8590. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8591. }
  8592. }
  8593. // print_r($dataList);
  8594. $data ['dataList'] = $dataList;
  8595. $mothHtml = "";
  8596. for($i = 1; $i <= 12; $i ++) {
  8597. if ($month == $i)
  8598. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8599. else
  8600. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8601. }
  8602. $data ['year'] = $year;
  8603. $data ['mothHtml'] = $mothHtml;
  8604. $data ['memu'] = "receipt";
  8605. $data ['staff'] = $this->staff;
  8606. $data ['receiptMemu'] = 'approval';
  8607. $data ['verifyId'] = $this->verifyId;
  8608. $data ['executeId'] = $this->executeId;
  8609. $this->render ( "/admin/saeaReportListPay", $data );
  8610. }
  8611. /**
  8612. * 金额调整,提高稳定性
  8613. * @return string
  8614. */
  8615. function revocationAdjustment() {
  8616. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8617. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8618. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8619. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8620. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8621. Doo::loadClass ( 'XDeode' );
  8622. $XDeode = new XDeode ( 5 );
  8623. Doo::loadModel ( 'receipt' );
  8624. $receipt = new receipt ();
  8625. $sid = $XDeode->decode ( $sidKey );
  8626. $rid = $XDeode->decode ( $ridKey );
  8627. $reviseKey = $XDeode->decode ( $reviseKey );
  8628. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8629. die ( 'illegal request' );
  8630. $receiptDetail = $receipt->getOne ( array (
  8631. 'where' => 'rid=' . $rid,
  8632. 'asArray' => true
  8633. ) );
  8634. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8635. die ( 'illegal request' );
  8636. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8637. if (! isset ( $reviseDetail [$reviseKey] ))
  8638. die ( 'illegal request' );
  8639. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8640. unset ( $reviseDetail [$reviseKey] );
  8641. $revisePrice = 0;
  8642. foreach ( $reviseDetail as $key => $value ) {
  8643. $revisePrice += $value ['price'];
  8644. }
  8645. $reviseDetailString = json_encode ( $reviseDetail );
  8646. $receipt->reviseDetail = $reviseDetailString;
  8647. $receipt->sum = $receiptDetail ['sum'] - $price;
  8648. $receipt->revisePrice = $revisePrice;
  8649. $receipt->update ( array (
  8650. 'where' => 'rid=' . $rid
  8651. ) );
  8652. return '/receiptburEdi/' . $rid;
  8653. } else
  8654. die ( 'illegal request2' );
  8655. }
  8656. function updateApprovalReceipt() {
  8657. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8658. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8659. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8660. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8661. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8662. if (! empty ( $rid )) {
  8663. Doo::loadModel ( "verify" );
  8664. $verify = new verify ();
  8665. Doo::loadModel ( "receiptDetail" );
  8666. $receiptDetailObj = new receiptDetail ();
  8667. Doo::loadModel ( "itemStatistics" );
  8668. Doo::loadModel ( "statistics" );
  8669. $statistics = new statistics ();
  8670. $itemStatistics = new itemStatistics ();
  8671. Doo::loadModel ( "receipt" );
  8672. $receipt = new receipt ();
  8673. $receiptDetail = $receipt->getOne ( array (
  8674. 'where' => 'rid=' . $rid . ' and status=2 ',
  8675. 'asArray' => true
  8676. ) );
  8677. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8678. $nsflag = true;
  8679. foreach ( $nslist as $value ) {
  8680. if ($value == $this->staff ['0'] ['sid']) {
  8681. $nsflag = false;
  8682. break;
  8683. }
  8684. }
  8685. if (empty ( $receiptDetail ) || $nsflag)
  8686. return "/approvalExpenses/pendApproval";
  8687. $verifyDetail = $verify->getOne ( array (
  8688. 'where' => ' vid =' . $receiptDetail ['verify'],
  8689. 'asArray' => true
  8690. ) );
  8691. $verifyString = $verifyDetail ['staff'];
  8692. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8693. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8694. if (empty ( $opinion )) {
  8695. if ($status == 3)
  8696. $opinion = "终止";
  8697. else
  8698. $opinion = "同意支付";
  8699. }
  8700. $nowStaff = 0;
  8701. $nowStaffList = array ();
  8702. if (empty ( $verifyStaff )) {
  8703. // 还需加入是否已经进入角色审批
  8704. if ($verifyDetail [0] [1] == 'ROLE') {
  8705. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8706. foreach ( $vStaffString as $key => $value ) {
  8707. $staffK = explode ( "_", $value );
  8708. if ($staffK [0] != $this->staff [0] ['sid'])
  8709. array_push ( $nowStaffList, $staffK [0] );
  8710. }
  8711. // print_r($verifyDetail);
  8712. // die;
  8713. if (! empty ( $nowStaffList )) {
  8714. $nowStaff = implode ( ',', $nowStaffList );
  8715. $verifyStaff = array (
  8716. $this->staff [0] ['sid'] . "_R" => array (
  8717. 'date' => date ( 'Y-m-d' ),
  8718. 'opinion' => $opinion,
  8719. 'status' => $status,
  8720. 'nextStaff' => $verifyDetail [0] [0],
  8721. 'ROLE' => 1
  8722. )
  8723. );
  8724. } else {
  8725. $nowStaff = $verifyDetail [1] [0];
  8726. $verifyStaff = array (
  8727. $this->staff [0] ['sid'] . "_R" => array (
  8728. 'date' => date ( 'Y-m-d' ),
  8729. 'opinion' => $opinion,
  8730. 'status' => $status,
  8731. 'nextStaff' => $verifyDetail [1] [0]
  8732. )
  8733. );
  8734. }
  8735. } else {
  8736. if ($verifyDetail [1] [1] == 'ROLE') {
  8737. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8738. // echo "dd";
  8739. foreach ( $vStaffString as $key => $value ) {
  8740. $staffK = explode ( "_", $value );
  8741. array_push ( $nowStaffList, $staffK [0] );
  8742. }
  8743. $nowStaff = implode ( ',', $nowStaffList );
  8744. $verifyStaff = array (
  8745. $this->staff [0] ['sid'] => array (
  8746. 'date' => date ( 'Y-m-d' ),
  8747. 'opinion' => $opinion,
  8748. 'status' => $status,
  8749. 'nextStaff' => $verifyDetail [1] [0],
  8750. 'ROLE' => 1
  8751. )
  8752. );
  8753. } else {
  8754. $nowStaff = $verifyDetail [1] [0];
  8755. $verifyStaff = array (
  8756. $this->staff [0] ['sid'] => array (
  8757. 'date' => date ( 'Y-m-d' ),
  8758. 'opinion' => $opinion,
  8759. 'status' => $status,
  8760. 'nextStaff' => $verifyDetail [1] [0]
  8761. )
  8762. );
  8763. }
  8764. }
  8765. if ($status == 3)
  8766. $verifyStaff = array (
  8767. 'final' => $status,
  8768. $this->staff [0] ['sid'] => array (
  8769. 'date' => date ( 'Y-m-d' ),
  8770. 'opinion' => $opinion,
  8771. 'status' => $status
  8772. )
  8773. );
  8774. $vStaffString = json_encode ( $verifyStaff );
  8775. $receipt->nowStaff = $nowStaff;
  8776. $receipt->verifyStaff = $vStaffString;
  8777. } else {
  8778. $VS = end ( $verifyStaff );
  8779. // 非角色审批
  8780. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8781. $nextStaff = 0;
  8782. $roleSTF = false;
  8783. foreach ( $verifyDetail as $key => $value ) {
  8784. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8785. if (isset ( $verifyDetail [$key + 1] )) {
  8786. $nextStaff = $verifyDetail [$key + 1] [0];
  8787. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8788. $roleSTF = true;
  8789. }
  8790. break;
  8791. }
  8792. }
  8793. if (! $roleSTF) {
  8794. $nowStaff = $nextStaff;
  8795. $verifyStaff [$this->staff [0] ['sid']] = array (
  8796. 'date' => date ( 'Y-m-d' ),
  8797. 'opinion' => $opinion,
  8798. 'status' => $status,
  8799. 'nextStaff' => $nextStaff
  8800. );
  8801. } else {
  8802. // 获取角色下的所有用户ID
  8803. $nowStaffList = array ();
  8804. foreach ( $verifyDetail as $vfk ) {
  8805. if ($vfk [1] == 'ROLE') {
  8806. $vStaffString = json_decode ( $vfk [3] );
  8807. foreach ( $vStaffString as $key => $value ) {
  8808. $staffK = explode ( "_", $value );
  8809. array_push ( $nowStaffList, $staffK [0] );
  8810. }
  8811. }
  8812. }
  8813. $nowStaff = implode ( ',', $nowStaffList );
  8814. $verifyStaff [$this->staff [0] ['sid']] = array (
  8815. 'date' => date ( 'Y-m-d' ),
  8816. 'opinion' => $opinion,
  8817. 'status' => $status,
  8818. 'nextStaff' => $nextStaff,
  8819. 'ROLE' => 0
  8820. );
  8821. }
  8822. if ($status == 3) {
  8823. $verifyStaff ['final'] = $status;
  8824. $verifyStaff [$this->staff [0] ['sid']] = array (
  8825. 'date' => date ( 'Y-m-d' ),
  8826. 'opinion' => $opinion,
  8827. 'status' => $status
  8828. );
  8829. }
  8830. $vStaffString = json_encode ( $verifyStaff );
  8831. $receipt->nowStaff = $nowStaff;
  8832. $receipt->verifyStaff = $vStaffString;
  8833. }
  8834. // 角色审批
  8835. if (isset ( $VS ['ROLE'] )) {
  8836. // 找出角色人 当前审批角色组
  8837. $verifyJSStaff = array ();
  8838. $nowStaffList2 = array ();
  8839. foreach ( $verifyDetail as $key => $value ) {
  8840. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8841. $verifyJSStaff = json_decode ( $value [3] );
  8842. foreach ( $verifyJSStaff as $m ) {
  8843. $staffK = explode ( "_", $m );
  8844. array_push ( $nowStaffList2, $staffK [0] );
  8845. }
  8846. // print_r($nowStaffList2);
  8847. }
  8848. }
  8849. $RoleVerifyStaff = array ();
  8850. foreach ( $verifyStaff as $key => $value ) {
  8851. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8852. foreach ( $nowStaffList2 as $m ) {
  8853. if ($key == $m . "_R")
  8854. $RoleVerifyStaff [$key] = $value;
  8855. }
  8856. }
  8857. }
  8858. // print_r($verifyStaff);
  8859. // print_r($nowStaffList2);
  8860. // print_r($RoleVerifyStaff);
  8861. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8862. // print_r($verifyJSStaff);
  8863. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8864. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8865. // 下一个审批人ID
  8866. $nextStaff = 0;
  8867. $falg = false;
  8868. foreach ( $verifyDetail as $key => $value ) {
  8869. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8870. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8871. $falg = true;
  8872. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8873. $nowStaffList = array ();
  8874. foreach ( $vStaffString as $v ) {
  8875. $staffK = explode ( "_", $v );
  8876. array_push ( $nowStaffList, $staffK [0] );
  8877. }
  8878. $nowStaff = implode ( ',', $nowStaffList );
  8879. $nextStaff = $verifyDetail [$key + 1] [0];
  8880. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8881. $nextStaff = $verifyDetail [$key + 1] [0];
  8882. $nowStaff = $nextStaff;
  8883. } else
  8884. $nowStaff = '';
  8885. break;
  8886. }
  8887. }
  8888. if ($falg)
  8889. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8890. 'date' => date ( 'Y-m-d' ),
  8891. 'opinion' => $opinion,
  8892. 'status' => $status,
  8893. 'nextStaff' => $nextStaff,
  8894. 'ROLE' => 1
  8895. );
  8896. else
  8897. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8898. 'date' => date ( 'Y-m-d' ),
  8899. 'opinion' => $opinion,
  8900. 'status' => $status,
  8901. 'nextStaff' => $nextStaff
  8902. );
  8903. // print_r($verifyStaff);
  8904. // echo $nowStaff;die;
  8905. } else { // 进入下一个角色或者审批人
  8906. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8907. //
  8908. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8909. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8910. 'date' => date ( 'Y-m-d' ),
  8911. 'opinion' => $opinion,
  8912. 'status' => $status,
  8913. 'nextStaff' => $VS ['nextStaff'],
  8914. 'ROLE' => 1
  8915. );
  8916. // print_r($verifyStaff);
  8917. // die;
  8918. }
  8919. if ($status == 3) {
  8920. $verifyStaff ['final'] = $status;
  8921. $verifyStaff [$this->staff [0] ['sid']] = array (
  8922. 'date' => date ( 'Y-m-d' ),
  8923. 'opinion' => $opinion,
  8924. 'status' => $status
  8925. );
  8926. }
  8927. $vStaffString = json_encode ( $verifyStaff );
  8928. $receipt->verifyStaff = $vStaffString;
  8929. $receipt->nowStaff = $nowStaff;
  8930. // die;
  8931. // }
  8932. // print_r($verifyStaff);
  8933. // die;
  8934. }
  8935. // print_r($verifyStaff);die;
  8936. }
  8937. // print_r($verifyDetail);
  8938. $roleKey = 0;
  8939. $roleId = 0;
  8940. $verifyDetailCopy = array ();
  8941. foreach ( $verifyDetail as $k => $v ) {
  8942. if ($v [1] == 'ROLE') {
  8943. $roleId = $v [0];
  8944. $roleVerify = json_decode ( $v [3], true );
  8945. $roleKey = $k;
  8946. $roleArray = array ();
  8947. foreach ( $roleVerify as $o => $p ) {
  8948. $staffID = explode ( '_', $p );
  8949. $exp = array (
  8950. 0 => $staffID [0],
  8951. 1 => $staffID [1]
  8952. );
  8953. array_push ( $roleArray, $exp );
  8954. }
  8955. $verifyDetailCopy [$v [0]] = $roleArray;
  8956. }
  8957. }
  8958. // print_r($verifyDetail);
  8959. foreach ( $verifyDetailCopy as $k => $v ) {
  8960. foreach ( $verifyDetail as $m => $n ) {
  8961. if ($n [0] == $k) {
  8962. array_splice ( $verifyDetail, $m, 1, $v );
  8963. }
  8964. }
  8965. }
  8966. // die;
  8967. // if (!empty($roleArray))
  8968. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8969. // echo $roleId;
  8970. // print_r($verifyStaff);
  8971. // print_r($verifyDetail);
  8972. // die;
  8973. Doo::loadModel ( "receiptLog" );
  8974. $receiptLog = new receiptLog ();
  8975. // 审批日志
  8976. if (! isset ( $verifyStaff ['final'] )) {
  8977. if (! empty ( $roleId )) {
  8978. Doo::loadModel ( "role" );
  8979. $role = new role ();
  8980. $roleInfo = $role->getOne ( array (
  8981. 'where' => 'rid=' . $roleId,
  8982. 'asArray' => true
  8983. ) );
  8984. $receiptLog->rolename = $roleInfo ['name'];
  8985. }
  8986. $receiptLog->username = $this->staff [0] ['username'];
  8987. $receiptLog->uid = $this->staff [0] ['sid'];
  8988. $receiptLog->date = date ( "Y-m-d" );
  8989. $receiptLog->opinion = $opinion;
  8990. $receiptLog->img = $this->staff [0] ['avatar'];
  8991. $receiptLog->status = 1;
  8992. $receiptLog->rid = $rid;
  8993. $receiptLog->insert ();
  8994. }
  8995. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8996. $receipt->verifyBreakup = $verifyString;
  8997. $receipt->status = 3;
  8998. $receiptDetailObj->status = 3;
  8999. $receiptDetailObj->update ( array (
  9000. 'where' => 'rid=' . $rid
  9001. ) );
  9002. if (! empty ( $roleId )) {
  9003. Doo::loadModel ( "role" );
  9004. $role = new role ();
  9005. $roleInfo = $role->getOne ( array (
  9006. 'where' => 'rid=' . $roleId,
  9007. 'asArray' => true
  9008. ) );
  9009. $receiptLog->rolename = $roleInfo ['name'];
  9010. }
  9011. $receiptLog->username = $this->staff [0] ['username'];
  9012. $receiptLog->uid = $this->staff [0] ['sid'];
  9013. $receiptLog->date = date ( "Y-m-d" );
  9014. $receiptLog->opinion = $opinion;
  9015. $receiptLog->img = $this->staff [0] ['avatar'];
  9016. $receiptLog->status = 3;
  9017. $receiptLog->rid = $rid;
  9018. $receiptLog->insert ();
  9019. // 微信企业号通知
  9020. $this->setWXMsg ( $rid, 3 );
  9021. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  9022. $receipt->status = 1;
  9023. $reviseSum = 0;
  9024. $receipt->verifyBreakup = $verifyString;
  9025. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  9026. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9027. foreach ( $reviseDetail as $key => $value ) {
  9028. $receiptDetailObj = new receiptDetail ();
  9029. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9030. $receiptDetailObj->item = $value ['description'];
  9031. $receiptDetailObj->itemCategory = "报销金额调整";
  9032. $receiptDetailObj->price = $value ['price'];
  9033. $receiptDetailObj->date = $receiptDetail ['date'];
  9034. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  9035. $receiptDetailObj->rid = $rid;
  9036. $receiptDetailObj->status = 1;
  9037. $receiptDetailObj->insert ();
  9038. $reviseSum += $value ['price'];
  9039. }
  9040. $itemStatistics = new itemStatistics ();
  9041. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9042. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9043. $itemStatistics->price = $reviseSum;
  9044. $itemStatistics->itemCategory = "报销金额调整";
  9045. $itemStatistics->date = $receiptDetail ['date'];
  9046. $itemStatistics->insert ();
  9047. }
  9048. $receiptDetailObj = new receiptDetail ();
  9049. $receiptDetailObj->status = 1;
  9050. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  9051. $receiptDetailObj->update ( array (
  9052. 'where' => 'rid=' . $rid
  9053. ) );
  9054. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9055. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9056. $stat = $statistics->getOne ( array (
  9057. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  9058. 'asArray' => true
  9059. ) );
  9060. if (empty ( $stat )) {
  9061. $statistics->date = $receiptDetail ['date'];
  9062. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  9063. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  9064. $statistics->agPrice = $receiptDetail ['sum'];
  9065. $statistics->rePrice = $reviseSum;
  9066. $statistics->insert ();
  9067. } else {
  9068. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  9069. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  9070. $statistics->update ( array (
  9071. 'where' => 'sid=' . $stat ['sid']
  9072. ) );
  9073. }
  9074. $dateArray = explode ( "-", $receiptDetail ['date'] );
  9075. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  9076. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  9077. foreach ( $accountItem ['cSum'] as $key => $value ) {
  9078. if ($key == "agencySum") {
  9079. $iStatistics = $itemStatistics->getOne ( array (
  9080. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  9081. 'asArray' => true
  9082. ) );
  9083. if (empty ( $iStatistics )) {
  9084. $itemStatistics->cid = $receiptDetail ['cid'];
  9085. ;
  9086. $itemStatistics->staff = $receiptDetail ['staff'];
  9087. $itemStatistics->price = $value;
  9088. $itemStatistics->itemCategory = $this->AGENCY;
  9089. $itemStatistics->date = $receiptDetail ['date'];
  9090. $itemStatistics->insert ();
  9091. } else {
  9092. if (! empty ( $value )) {
  9093. $itemStatistics->price = $value + $iStatistics ['price'];
  9094. $itemStatistics->update ( array (
  9095. 'where' => 'sid=' . $iStatistics ['sid']
  9096. ) );
  9097. }
  9098. }
  9099. } elseif ($key == "travelSum") {
  9100. $iStatistics = $itemStatistics->getOne ( array (
  9101. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  9102. 'asArray' => true
  9103. ) );
  9104. if (empty ( $iStatistics )) {
  9105. $itemStatistics->cid = $receiptDetail ['cid'];
  9106. $itemStatistics->staff = $receiptDetail ['staff'];
  9107. $itemStatistics->price = $value;
  9108. $itemStatistics->itemCategory = $this->TRAVEL;
  9109. $itemStatistics->date = $receiptDetail ['date'];
  9110. $itemStatistics->insert ();
  9111. } else {
  9112. if (! empty ( $value )) {
  9113. $itemStatistics->price = $value + $iStatistics ['price'];
  9114. $itemStatistics->update ( array (
  9115. 'where' => 'sid=' . $iStatistics ['sid']
  9116. ) );
  9117. }
  9118. }
  9119. } elseif ($key == "trainSum") {
  9120. $iStatistics = $itemStatistics->getOne ( array (
  9121. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  9122. 'asArray' => true
  9123. ) );
  9124. if (empty ( $iStatistics )) {
  9125. $itemStatistics->cid = $receiptDetail ['cid'];
  9126. $itemStatistics->staff = $receiptDetail ['staff'];
  9127. $itemStatistics->price = $value;
  9128. $itemStatistics->itemCategory = $this->TRAIN;
  9129. $itemStatistics->date = $receiptDetail ['date'];
  9130. $itemStatistics->insert ();
  9131. } else {
  9132. if (! empty ( $value )) {
  9133. $itemStatistics->price = $value + $iStatistics ['price'];
  9134. $itemStatistics->update ( array (
  9135. 'where' => 'sid=' . $iStatistics ['sid']
  9136. ) );
  9137. }
  9138. }
  9139. } elseif ($key == "otherSum") {
  9140. $iStatistics = $itemStatistics->getOne ( array (
  9141. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  9142. 'asArray' => true
  9143. ) );
  9144. if (empty ( $iStatistics )) {
  9145. $itemStatistics->cid = $receiptDetail ['cid'];
  9146. $itemStatistics->staff = $receiptDetail ['staff'];
  9147. $itemStatistics->price = $value;
  9148. $itemStatistics->itemCategory = $this->OTHER;
  9149. $itemStatistics->date = $receiptDetail ['date'];
  9150. $itemStatistics->insert ();
  9151. } else {
  9152. if (! empty ( $value )) {
  9153. $itemStatistics->price = $value + $iStatistics ['price'];
  9154. $itemStatistics->update ( array (
  9155. 'where' => 'sid=' . $iStatistics ['sid']
  9156. ) );
  9157. }
  9158. }
  9159. }
  9160. }
  9161. $receipt->pastDate = date ( "Y-m-d" );
  9162. // 微信企业号通知
  9163. $this->setWXMsg ( $rid, 1 );
  9164. }
  9165. //是否有流水
  9166. Doo::loadModel ( 'wasteBook' );
  9167. $wasteBook = new wasteBook ();
  9168. $accountType=3;
  9169. if ($receiptDetail['Rtype']==1){
  9170. $accountType=2;
  9171. }elseif($receiptDetail['Rtype']==2){
  9172. $accountType=4;
  9173. }
  9174. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  9175. if (empty($wbDetail)){
  9176. $rsum=$receiptDetail['sum']-$receiptDetail['loanSum'];
  9177. $receipt->amount = $rsum;//$amount;
  9178. }
  9179. $receipt->update ( array (
  9180. 'where' => ' rid = ' . $rid
  9181. ) );
  9182. // 进入下一条审批费用新加需求
  9183. $vidList = array ();
  9184. $verifyDetail = $verify->find ( array (
  9185. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  9186. 'asArray' => true
  9187. ) );
  9188. foreach ( $verifyDetail as $key => $value ) {
  9189. array_push ( $vidList, $value ['vid'] );
  9190. }
  9191. $vid = implode ( ",", $vidList );
  9192. if (empty ( $verifyDetail ))
  9193. $vid = 0;
  9194. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9195. $receipt = new receipt ();
  9196. $rd = $receipt->getOne ( array (
  9197. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  9198. 'asc' => 'rid',
  9199. 'asArray' => true
  9200. ) );
  9201. if (empty ( $rd )) {
  9202. return '/approvalExpenses/pendApproval';
  9203. }
  9204. if ($rd ['Rtype'] == 1) {
  9205. if ($rd ['isBK'] == 1) {
  9206. return '/receiptburEdi/' . $rd ['rid'];
  9207. } else {
  9208. return '/expensesEdi/' . $rd ['rid'];
  9209. }
  9210. } elseif ($rd ['Rtype'] == 2) {
  9211. return '/remitApproval/' . $rd ['rid'];
  9212. } else {
  9213. return '/receiptburEdi/' . $rd ['rid'];
  9214. }
  9215. // return "/approvalExpenses/pendApproval";
  9216. }
  9217. }
  9218. function expensesRetreats() {
  9219. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  9220. if (! empty ( $rid )) {
  9221. // 操作记录
  9222. Doo::loadModel ( "receipt" );
  9223. $receipt = new receipt ();
  9224. Doo::loadModel ( "receiptLog" );
  9225. $receiptLog = new receiptLog ();
  9226. Doo::loadModel ( "verify" );
  9227. $verify = new verify ();
  9228. $receiptInfo = $receipt->getOne ( array (
  9229. 'where' => 'rid=' . $rid,
  9230. 'asArray' => true
  9231. ) );
  9232. $vr = $verify->getOne ( array (
  9233. 'where' => 'vid=' . $receiptInfo ['verify'],
  9234. 'asArray' => true
  9235. ) );
  9236. $jd = json_decode ( $vr ['staff'] );
  9237. $roleId = 0;
  9238. foreach ( $jd as $key => $value ) {
  9239. if ($value [1] == 'ROLE') {
  9240. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9241. if ($pos !== false) {
  9242. $roleId = $value [0];
  9243. }
  9244. }
  9245. }
  9246. // 审批日志
  9247. // echo $roleId;die;
  9248. if (! empty ( $roleId )) {
  9249. Doo::loadModel ( "role" );
  9250. $role = new role ();
  9251. $roleInfo = $role->getOne ( array (
  9252. 'where' => 'rid=' . $roleId,
  9253. 'asArray' => true
  9254. ) );
  9255. $receiptLog->rolename = $roleInfo ['name'];
  9256. }
  9257. $receiptLog->username = $this->staff [0] ['username'];
  9258. $receiptLog->uid = $this->staff [0] ['sid'];
  9259. $receiptLog->date = date ( "Y-m-d" );
  9260. $receiptLog->opinion = '撤回';
  9261. $receiptLog->img = $this->staff [0] ['avatar'];
  9262. $receiptLog->status = 4;
  9263. $receiptLog->rid = $rid;
  9264. $receiptLog->insert ();
  9265. $receipt->status = 4;
  9266. $receipt->update ( array (
  9267. 'where' => 'rid=' . $rid
  9268. ) );
  9269. // 微信企业号通知
  9270. $this->setWXMsg ( $rid, 2 );
  9271. }
  9272. // echo "ddd";
  9273. return '/approvalExpenses/pendApproval';
  9274. }
  9275. function updateCheReceipt() {
  9276. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9277. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  9278. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  9279. if (! empty ( $rid )) {
  9280. // 操作记录
  9281. Doo::loadModel ( "receipt" );
  9282. $receipt = new receipt ();
  9283. Doo::loadModel ( "receiptLog" );
  9284. $receiptLog = new receiptLog ();
  9285. Doo::loadModel ( "verify" );
  9286. $verify = new verify ();
  9287. $receiptInfo = $receipt->getOne ( array (
  9288. 'where' => 'rid=' . $rid . ' and status=2',
  9289. 'asArray' => true
  9290. ) );
  9291. if (empty ( $receiptInfo )) {
  9292. echo json_encode ( array (
  9293. 'status' => 2
  9294. ) );
  9295. die ();
  9296. }
  9297. $vr = $verify->getOne ( array (
  9298. 'where' => 'vid=' . $receiptInfo ['verify'],
  9299. 'asArray' => true
  9300. ) );
  9301. $jd = json_decode ( $vr ['staff'] );
  9302. $roleId = 0;
  9303. foreach ( $jd as $key => $value ) {
  9304. if ($value [1] == 'ROLE') {
  9305. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  9306. if ($pos !== false) {
  9307. $roleId = $value [0];
  9308. }
  9309. }
  9310. }
  9311. // 审批日志
  9312. // echo $roleId;die;
  9313. if (! empty ( $roleId )) {
  9314. Doo::loadModel ( "role" );
  9315. $role = new role ();
  9316. $roleInfo = $role->getOne ( array (
  9317. 'where' => 'rid=' . $roleId,
  9318. 'asArray' => true
  9319. ) );
  9320. $receiptLog->rolename = $roleInfo ['name'];
  9321. }
  9322. $receiptLog->username = $this->staff [0] ['username'];
  9323. $receiptLog->uid = $this->staff [0] ['sid'];
  9324. $receiptLog->date = date ( "Y-m-d" );
  9325. $receiptLog->opinion = $opinion;
  9326. $receiptLog->img = $this->staff [0] ['avatar'];
  9327. $receiptLog->status = 4;
  9328. $receiptLog->rid = $rid;
  9329. $receiptLog->insert ();
  9330. $receipt->status = 4;
  9331. $receipt->update ( array (
  9332. 'where' => 'rid=' . $rid
  9333. ) );
  9334. // 微信企业号通知
  9335. $this->setWXMsg ( $rid, 2 );
  9336. echo json_encode ( array (
  9337. 'status' => 1
  9338. ) );
  9339. // Header("HTTP/1.1 303 See Other");
  9340. // Header("Location: /approvalExpenses/pendApproval");
  9341. die ();
  9342. }
  9343. echo json_encode ( array (
  9344. 'status' => 2
  9345. ) );
  9346. die ();
  9347. // echo "ddd";
  9348. // return '/saeaBorad';
  9349. }
  9350. function revisePrice() {
  9351. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  9352. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  9353. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  9354. // echo $price;die;
  9355. if (! empty ( $rid )) {
  9356. Doo::loadModel ( "receipt" );
  9357. $receipt = new receipt ();
  9358. $receiptDetail = $receipt->getOne ( array (
  9359. 'where' => 'rid=' . $rid . ' and status=2 ',
  9360. 'asArray' => true
  9361. ) );
  9362. if (empty ( $receiptDetail ))
  9363. die ( 'illegal request' );
  9364. $reviseDetail = array ();
  9365. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9366. array_push ( $reviseDetail, array (
  9367. 'sid' => $this->staff [0] ['sid'],
  9368. 'name' => $this->staff [0] ['username'],
  9369. 'description' => $description,
  9370. 'price' => $price
  9371. ) );
  9372. $reviseDetailString = json_encode ( $reviseDetail );
  9373. $receipt->reviseDetail = $reviseDetailString;
  9374. $receipt->revisePrice = $price;
  9375. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9376. } else {
  9377. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9378. array_push ( $reviseDetail, array (
  9379. 'sid' => $this->staff [0] ['sid'],
  9380. 'name' => $this->staff [0] ['username'],
  9381. 'description' => $description,
  9382. 'price' => $price
  9383. ) );
  9384. $reviseDetailString = json_encode ( $reviseDetail );
  9385. $receipt->reviseDetail = $reviseDetailString;
  9386. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9387. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9388. }
  9389. $receipt->update ( array (
  9390. 'where' => 'rid=' . $rid
  9391. ) );
  9392. if ($receiptDetail ['Rtype'] == 1) {
  9393. if ($receiptDetail ['isBK'] == 1) {
  9394. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9395. }
  9396. } elseif ($receiptDetail ['Rtype'] == 2) {
  9397. } else {
  9398. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9399. }
  9400. }
  9401. die ( 'illegal request' );
  9402. }
  9403. function personalCollect() {
  9404. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9405. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9406. $this->showCache ( $path );
  9407. Doo::loadModel ( "receiptDetail" );
  9408. Doo::loadModel ( "itemStatistics" );
  9409. Doo::loadModel ( 'statistics' );
  9410. $statistics = new statistics ();
  9411. $itemStatistics = new itemStatistics ();
  9412. $receiptDetail = new receiptDetail ();
  9413. $receiptCollectList = $receiptDetail->find ( array (
  9414. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9415. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9416. 'groupby' => 'itemCategory,Month(date)',
  9417. 'asArray' => true
  9418. ) );
  9419. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9420. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9421. 'asArray' => true
  9422. ) );
  9423. // create collect html
  9424. $collectArray = array (
  9425. '日常相关费用' => array (),
  9426. '差旅相关费用' => array (),
  9427. '培训班费用' => array (),
  9428. '其他' => array ()
  9429. );
  9430. $adjustment = array ();
  9431. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9432. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9433. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9434. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9435. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9436. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9437. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9438. array_push ( $collectArray ['其他'], $collectHtml );
  9439. $data ['collectArray'] = $collectArray;
  9440. // statistics html
  9441. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9442. if (empty ( $stList ))
  9443. $stList = array (
  9444. 'rePrice' => 0,
  9445. 'agPrice' => 0
  9446. );
  9447. $data ['stList'] = array (
  9448. 'rePrice' => $stList ['rePrice'],
  9449. 'agPrice' => $stList ['agPrice'],
  9450. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9451. );
  9452. // Adjustment price html
  9453. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9454. array_push ( $adjustment, $collectHtml );
  9455. $data ['adjustment'] = $adjustment;
  9456. // total price html
  9457. $collectHtml = "";
  9458. $total = 0;
  9459. for($i = 1; $i <= 12; $i ++) {
  9460. $sumPrice = 0;
  9461. foreach ( $receiptCollectList as $key => $value ) {
  9462. if ($value ['month'] == $i) {
  9463. $sumPrice += $value ['price'];
  9464. }
  9465. }
  9466. if ($sumPrice == 0)
  9467. $collectHtml .= '<td class="taR">-</td>';
  9468. else
  9469. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9470. $total += $sumPrice;
  9471. }
  9472. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9473. $data ['totalPrice'] = $collectHtml;
  9474. $dateHtml = "";
  9475. $now = date ( "Y" );
  9476. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9477. if ($YEARD <= $now) {
  9478. $dateHtml .= '<option ';
  9479. if ($year == $YEARD) {
  9480. $dateHtml .= 'selected ';
  9481. }
  9482. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9483. }
  9484. }
  9485. $data ['dateHtml'] = $dateHtml;
  9486. $data ['year'] = $year;
  9487. $data ['totalYear'] = $total;
  9488. $data ['memu'] = "receipt";
  9489. $data ['staff'] = $this->staff;
  9490. $data ['receiptMemu'] = 'personalCollect';
  9491. $data ['verifyId'] = $this->verifyId;
  9492. $data ['executeId'] = $this->executeId;
  9493. // year staff status 2,4
  9494. if ($year < date ( "Y" )) {
  9495. Doo::loadModel ( 'receipt' );
  9496. $receipt = new receipt ();
  9497. $receiptList = $receipt->find ( array (
  9498. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9499. 'asArray' => true
  9500. ) );
  9501. if (empty ( $receiptList )) {
  9502. ob_start ();
  9503. $this->render ( "/admin/saea_slist_collect", $data );
  9504. $this->cacheFile ( $path );
  9505. die ();
  9506. }
  9507. }
  9508. $this->render ( "/admin/saea_slist_collect", $data );
  9509. }
  9510. function personalCollectDetail() {
  9511. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9512. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9513. $this->showCache ( $path );
  9514. Doo::loadModel ( "receiptDetail" );
  9515. Doo::loadModel ( "itemStatistics" );
  9516. Doo::loadModel ( 'statistics' );
  9517. Doo::loadModel ( 'accountItem' );
  9518. $accountItem = new accountItem ();
  9519. $statistics = new statistics ();
  9520. $itemStatistics = new itemStatistics ();
  9521. $receiptDetail = new receiptDetail ();
  9522. $receiptCollectList = $receiptDetail->find ( array (
  9523. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9524. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9525. 'groupby' => 'item,Month(date)',
  9526. 'asArray' => true
  9527. ) );
  9528. $accountList = $accountItem->find ( array (
  9529. 'asArray' => true
  9530. ) );
  9531. // create CollectDetail HTML
  9532. $collectHtml = array ();
  9533. foreach ( $accountList as $key => $value ) {
  9534. $html = "";
  9535. $asum = 0;
  9536. for($i = 1; $i <= 12; $i ++) {
  9537. $falg = true;
  9538. foreach ( $receiptCollectList as $v ) {
  9539. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9540. $asum += $v ['price'];
  9541. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9542. $falg = false;
  9543. break;
  9544. }
  9545. }
  9546. if ($falg)
  9547. $html .= '<td class="taR">-</td>';
  9548. }
  9549. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9550. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9551. }
  9552. $data ['collectHtml'] = $collectHtml;
  9553. // create Adjustment price html
  9554. $receiptCollectList = $receiptDetail->find ( array (
  9555. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9556. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9557. 'groupby' => 'itemCategory,Month(date)',
  9558. 'asArray' => true
  9559. ) );
  9560. $adjustment = array ();
  9561. $collectArray = array (
  9562. '日常相关费用' => array (),
  9563. '差旅相关费用' => array (),
  9564. '培训班费用' => array (),
  9565. '其他' => array ()
  9566. );
  9567. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9568. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9569. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9570. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9571. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9572. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9573. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9574. array_push ( $collectArray ['其他'], $collectHtml );
  9575. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9576. array_push ( $adjustment, $collectHtml );
  9577. // total price html
  9578. $collectHtml = "";
  9579. $total = 0;
  9580. for($i = 1; $i <= 12; $i ++) {
  9581. $sumPrice = 0;
  9582. foreach ( $receiptCollectList as $key => $value ) {
  9583. if ($value ['month'] == $i) {
  9584. $sumPrice += $value ['price'];
  9585. }
  9586. }
  9587. if ($sumPrice == 0)
  9588. $collectHtml .= '<td class="taR">-</td>';
  9589. else
  9590. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9591. $total += $sumPrice;
  9592. }
  9593. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9594. // statistics html
  9595. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9596. if (empty ( $stList ))
  9597. $stList = array (
  9598. 'rePrice' => 0,
  9599. 'agPrice' => 0
  9600. );
  9601. $data ['stList'] = array (
  9602. 'rePrice' => $stList ['rePrice'],
  9603. 'agPrice' => $stList ['agPrice'],
  9604. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9605. );
  9606. $data ['collectArray'] = $collectArray;
  9607. $data ['adjustment'] = $adjustment;
  9608. $data ['totalPrice'] = $collectHtml;
  9609. $data ['totalYear'] = $total;
  9610. $data ['year'] = $year;
  9611. $dateHtml = "";
  9612. $now = date ( "Y" );
  9613. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9614. if ($YEARD <= $now) {
  9615. $dateHtml .= '<option ';
  9616. if ($year == $YEARD) {
  9617. $dateHtml .= 'selected ';
  9618. }
  9619. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9620. }
  9621. }
  9622. $data ['dateHtml'] = $dateHtml;
  9623. $data ['memu'] = "receipt";
  9624. $data ['staff'] = $this->staff;
  9625. $data ['receiptMemu'] = 'personalCollect';
  9626. $data ['verifyId'] = $this->verifyId;
  9627. $data ['executeId'] = $this->executeId;
  9628. // year staff status 2,4
  9629. if ($year < date ( "Y" )) {
  9630. Doo::loadModel ( 'receipt' );
  9631. $receipt = new receipt ();
  9632. $receiptList = $receipt->find ( array (
  9633. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9634. 'asArray' => true
  9635. ) );
  9636. if (empty ( $receiptList )) {
  9637. ob_start ();
  9638. $this->render ( "/admin/saeaCollectArticles", $data );
  9639. $this->cacheFile ( $path );
  9640. die ();
  9641. }
  9642. }
  9643. $this->render ( "/admin/saeaCollectArticles", $data );
  9644. }
  9645. function companyCategoryCollect() {
  9646. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9647. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9648. $this->showCache ( $path );
  9649. Doo::loadModel ( 'L_category' );
  9650. Doo::loadModel ( 'itemStatistics' );
  9651. Doo::loadModel ( 'statistics' );
  9652. $statistics = new statistics ();
  9653. $Lcategory = new L_category ();
  9654. $itemStatistics = new itemStatistics ();
  9655. Doo::loadModel ( "receiptAuthorityManage" );
  9656. $receiptAuthorityManage = new receiptAuthorityManage ();
  9657. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9658. $cidList = array ();
  9659. foreach ( $imcStaff as $key => $value ) {
  9660. array_push ( $cidList, $value ['cid'] );
  9661. }
  9662. $cidString = implode ( ',', $cidList );
  9663. $LcategoryList = $Lcategory->find ( array (
  9664. 'where' => ' cid in (' . $cidString . ')',
  9665. 'asArray' => true
  9666. ) ); // 'staff='.$this->staff[0]['sid']." and
  9667. $itemStatisticsList = $itemStatistics->find ( array (
  9668. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9669. 'where' => " Year(date)=" . $year,
  9670. 'groupby' => 'cid,Month(date)',
  9671. 'asArray' => true
  9672. ) );
  9673. // ceatre companyCollectHtml
  9674. foreach ( $LcategoryList as $value ) {
  9675. $html = "";
  9676. $asum = 0;
  9677. for($i = 1; $i <= 12; $i ++) {
  9678. $falg = true;
  9679. foreach ( $itemStatisticsList as $v ) {
  9680. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9681. $asum += $v ['price'];
  9682. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9683. $falg = false;
  9684. break;
  9685. }
  9686. }
  9687. if ($falg)
  9688. $html .= '<td class="taR">-</td>';
  9689. }
  9690. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9691. $collectHtml [$value ['title']] = array (
  9692. 'html' => $html,
  9693. 'cid' => $value ['cid']
  9694. );
  9695. }
  9696. $data ['companyHtml'] = $collectHtml;
  9697. // total price html
  9698. $collectHtml = "";
  9699. $total = 0;
  9700. for($i = 1; $i <= 12; $i ++) {
  9701. $sumPrice = 0;
  9702. foreach ( $itemStatisticsList as $key => $value ) {
  9703. if ($value ['month'] == $i) {
  9704. $sumPrice += $value ['price'];
  9705. }
  9706. }
  9707. if ($sumPrice == 0)
  9708. $collectHtml .= '<td class="taR">-</td>';
  9709. else
  9710. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9711. $total += $sumPrice;
  9712. }
  9713. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9714. $data ['companyTotalHtml'] = $collectHtml;
  9715. $data ['total'] = $total;
  9716. // statistics html
  9717. // echo $cidString;
  9718. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9719. if (empty ( $stList ))
  9720. $stList = array (
  9721. 'rePrice' => 0,
  9722. 'agPrice' => 0
  9723. );
  9724. $data ['stList'] = array (
  9725. 'rePrice' => $stList ['rePrice'],
  9726. 'agPrice' => $stList ['agPrice'],
  9727. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9728. );
  9729. $data ['year'] = $year;
  9730. $data ['memu'] = "receipt";
  9731. $data ['staff'] = $this->staff;
  9732. $data ['receiptMemu'] = 'companyCategoryCollect';
  9733. $data ['verifyId'] = $this->verifyId;
  9734. $data ['executeId'] = $this->executeId;
  9735. $dateHtml = "";
  9736. $now = date ( "Y" );
  9737. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9738. if ($YEARD <= $now) {
  9739. $dateHtml .= '<option ';
  9740. if ($year == $YEARD) {
  9741. $dateHtml .= 'selected ';
  9742. }
  9743. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9744. }
  9745. }
  9746. $data ['dateHtml'] = $dateHtml;
  9747. // year staff status 2,4
  9748. if ($year < date ( "Y" )) {
  9749. Doo::loadModel ( 'receipt' );
  9750. $receipt = new receipt ();
  9751. $receiptList = $receipt->find ( array (
  9752. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9753. 'asArray' => true
  9754. ) );
  9755. if (empty ( $receiptList )) {
  9756. ob_start ();
  9757. $this->render ( "/admin/saeaCompanyCollect", $data );
  9758. $this->cacheFile ( $path );
  9759. die ();
  9760. }
  9761. }
  9762. $this->render ( "/admin/saeaCompanyCollect", $data );
  9763. }
  9764. function categoryCollectDetail() {
  9765. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9766. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9767. /* $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9768. $this->showCache ( $path ); */
  9769. Doo::loadModel ( 'statistics' );
  9770. $statistics = new statistics ();
  9771. Doo::loadModel ( "receiptDetail" );
  9772. $receiptDetail = new receiptDetail ();
  9773. Doo::loadModel ( 'L_category' );
  9774. $Lcategory = new L_category ();
  9775. Doo::loadModel ( 'accountItem' );
  9776. $accountItem = new accountItem ();
  9777. Doo::loadModel ( "receiptAuthorityManage" );
  9778. $receiptAuthorityManage = new receiptAuthorityManage ();
  9779. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9780. $cidList = array ();
  9781. foreach ( $imcStaff as $key => $value ) {
  9782. array_push ( $cidList, $value ['cid'] );
  9783. }
  9784. $cidString = implode ( ',', $cidList );
  9785. $LcategoryList = $Lcategory->find ( array (
  9786. 'where' => 'cid in (' . $cidString . ')',
  9787. 'asArray' => true
  9788. ) );
  9789. if ($cid == 0) {
  9790. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9791. if ($cid == 0)
  9792. $cid = $LcategoryList [0] ['cid'];
  9793. }
  9794. $data ['LcategoryList'] = $LcategoryList;
  9795. $receiptCollectList = $receiptDetail->find ( array (
  9796. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9797. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9798. 'groupby' => 'item,Month(pastDate)',
  9799. 'asArray' => true
  9800. ) );
  9801. $accountList = $accountItem->find ( array (
  9802. 'asArray' => true
  9803. ) );
  9804. // create CollectDetail HTML
  9805. $collectHtml = array ();
  9806. foreach ( $accountList as $key => $value ) {
  9807. $html = "";
  9808. $asum = 0;
  9809. for($i = 1; $i <= 12; $i ++) {
  9810. $falg = true;
  9811. foreach ( $receiptCollectList as $v ) {
  9812. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9813. $asum += $v ['price'];
  9814. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9815. $falg = false;
  9816. break;
  9817. }
  9818. }
  9819. if ($falg)
  9820. $html .= '<td class="taR">-</td>';
  9821. }
  9822. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9823. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9824. }
  9825. $data ['collectHtml'] = $collectHtml;
  9826. // create Adjustment price html
  9827. $receiptCollectList = $receiptDetail->find ( array (
  9828. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9829. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9830. 'groupby' => 'itemCategory,Month(pastDate)',
  9831. 'asArray' => true
  9832. ) );
  9833. $adjustment = array ();
  9834. $collectArray = array (
  9835. '日常相关费用' => array (),
  9836. '差旅相关费用' => array (),
  9837. '培训班费用' => array (),
  9838. '内部培训费用'=>array(),
  9839. '其他' => array ()
  9840. );
  9841. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9842. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9843. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9844. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9845. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9846. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9847. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  9848. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  9849. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9850. array_push ( $collectArray ['其他'], $collectHtml );
  9851. $data ['collectArray'] = $collectArray;
  9852. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9853. array_push ( $adjustment, $collectHtml );
  9854. $data ['adjustment'] = $adjustment;
  9855. // total price html
  9856. $collectHtml = "";
  9857. $total = 0;
  9858. for($i = 1; $i <= 12; $i ++) {
  9859. $sumPrice = 0;
  9860. foreach ( $receiptCollectList as $key => $value ) {
  9861. if ($value ['month'] == $i) {
  9862. $sumPrice += $value ['price'];
  9863. }
  9864. }
  9865. if ($sumPrice == 0)
  9866. $collectHtml .= '<td class="taR">-</td>';
  9867. else
  9868. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9869. $total += $sumPrice;
  9870. }
  9871. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9872. // statistics html
  9873. $stList = $statistics->statisticsByCid ( $year, $cid );
  9874. if (empty ( $stList ))
  9875. $stList = array (
  9876. 'rePrice' => 0,
  9877. 'agPrice' => 0
  9878. );
  9879. $data ['stList'] = array (
  9880. 'rePrice' => $stList ['rePrice'],
  9881. 'agPrice' => $stList ['agPrice'],
  9882. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9883. );
  9884. $data ['totalYear'] = $total;
  9885. $data ['year'] = $year;
  9886. $data ['cid'] = $cid;
  9887. $data ['memu'] = "receipt";
  9888. $data ['staff'] = $this->staff;
  9889. $data ['receiptMemu'] = 'companyCategoryCollect';
  9890. $data ['verifyId'] = $this->verifyId;
  9891. $data ['executeId'] = $this->executeId;
  9892. // year staff status 2,4
  9893. /* if ($year < date ( "Y" )) {
  9894. Doo::loadModel ( 'receipt' );
  9895. $receipt = new receipt ();
  9896. $receiptList = $receipt->find ( array (
  9897. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9898. 'asArray' => true
  9899. ) );
  9900. if (empty ( $receiptList )) {
  9901. ob_start ();
  9902. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9903. $this->cacheFile ( $path );
  9904. die ();
  9905. }
  9906. } */
  9907. $dateHtml = "";
  9908. $now = date ( "Y" );
  9909. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9910. if ($YEARD <= $now) {
  9911. $dateHtml .= '<option ';
  9912. if ($year == $YEARD) {
  9913. $dateHtml .= 'selected ';
  9914. }
  9915. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9916. }
  9917. }
  9918. $data ['dateHtml'] = $dateHtml;
  9919. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9920. }
  9921. function staffCollect() {
  9922. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9923. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9924. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9925. // $this->showCache($path);
  9926. Doo::loadModel ( 'statistics' );
  9927. $statistics = new statistics ();
  9928. Doo::loadModel ( "receiptDetail" );
  9929. $receiptDetail = new receiptDetail ();
  9930. Doo::loadModel ( 'L_category' );
  9931. $Lcategory = new L_category ();
  9932. Doo::loadModel ( 'accountItem' );
  9933. $accountItem = new accountItem ();
  9934. Doo::loadModel ( 'staff' );
  9935. $staff = new staff ();
  9936. Doo::loadModel ( 'itemStatistics' );
  9937. $itemStatistics = new itemStatistics ();
  9938. Doo::loadModel ( "receiptAuthorityManage" );
  9939. $receiptAuthorityManage = new receiptAuthorityManage ();
  9940. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9941. $cidList = array ();
  9942. foreach ( $imcStaff as $key => $value ) {
  9943. array_push ( $cidList, $value ['cid'] );
  9944. }
  9945. $cidString = implode ( ',', $cidList );
  9946. $naturecon='';
  9947. if ($nature=='ONJOB'){
  9948. $naturecon=' and (nature!=4 )';
  9949. }elseif($nature=='LEAVEJOB'){
  9950. $naturecon=' and (nature=4 )';
  9951. }else{
  9952. die ( 'illegal request--nature' );
  9953. }
  9954. // statistics html
  9955. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9956. if (empty ( $stList ))
  9957. $stList = array (
  9958. 'rePrice' => 0,
  9959. 'agPrice' => 0
  9960. );
  9961. $data ['stList'] = array (
  9962. 'rePrice' => $stList ['rePrice'],
  9963. 'agPrice' => $stList ['agPrice'],
  9964. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9965. );
  9966. // ---
  9967. $staffList = $staff->find ( array (
  9968. 'where' => 'username !="admin" '.$naturecon,
  9969. 'asArray' => true
  9970. ) );
  9971. $LcategoryList = $Lcategory->find ( array (
  9972. 'asArray' => true
  9973. ) ); // 'staff='.$this->staff[0]['sid']." and
  9974. $itemStatisticsList = $itemStatistics->find ( array (
  9975. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9976. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9977. 'groupby' => 'staff,Month(date)',
  9978. 'asArray' => true
  9979. ) );
  9980. $categoryList = $staff->find ( array (
  9981. 'select' => 'COUNT(*) as count,cid,category',
  9982. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9983. 'groupby' => 'cid',
  9984. 'asArray' => true
  9985. ) );
  9986. // print_r($itemStatisticsList);die;
  9987. // ceatre companyCollectHtml
  9988. foreach ( $categoryList as $vlu ) {
  9989. $count = $vlu ['count'] + 1;
  9990. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9991. $m1 = 0;
  9992. $m2 = 0;
  9993. $m3 = 0;
  9994. $m4 = 0;
  9995. $m5 = 0;
  9996. $m6 = 0;
  9997. $m7 = 0;
  9998. $m8 = 0;
  9999. $m9 = 0;
  10000. $m10 = 0;
  10001. $m11 = 0;
  10002. $m12 = 0;
  10003. $m13 = 0;
  10004. foreach ( $staffList as $value ) {
  10005. if ($vlu ['cid'] == $value ['cid']) {
  10006. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  10007. $asum = 0;
  10008. for($i = 1; $i <= 12; $i ++) {
  10009. $falg = true;
  10010. foreach ( $itemStatisticsList as $v ) {
  10011. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  10012. if ($v ['month'] == 1)
  10013. $m1 += $v ['price'];
  10014. if ($v ['month'] == 2)
  10015. $m2 += $v ['price'];
  10016. if ($v ['month'] == 3)
  10017. $m3 += $v ['price'];
  10018. if ($v ['month'] == 4)
  10019. $m4 += $v ['price'];
  10020. if ($v ['month'] == 5)
  10021. $m5 += $v ['price'];
  10022. if ($v ['month'] == 6)
  10023. $m6 += $v ['price'];
  10024. if ($v ['month'] == 7)
  10025. $m7 += $v ['price'];
  10026. if ($v ['month'] == 8)
  10027. $m8 += $v ['price'];
  10028. if ($v ['month'] == 9)
  10029. $m9 += $v ['price'];
  10030. if ($v ['month'] == 10)
  10031. $m10 += $v ['price'];
  10032. if ($v ['month'] == 11)
  10033. $m11 += $v ['price'];
  10034. if ($v ['month'] == 12)
  10035. $m12 += $v ['price'];
  10036. $asum += $v ['price'];
  10037. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  10038. $falg = false;
  10039. break;
  10040. }
  10041. }
  10042. if ($falg)
  10043. $html .= '<td class="taR">-</td>';
  10044. }
  10045. $m13 += $asum;
  10046. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  10047. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  10048. 'html' => $html,
  10049. 'sid' => $value ['sid']
  10050. );
  10051. $html = "";
  10052. }
  10053. }
  10054. $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>
  10055. <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>
  10056. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  10057. $collectHtml [$vlu ['cid']] = array (
  10058. 'html' => $hl,
  10059. 'sid' => ''
  10060. );
  10061. }
  10062. $data ['companyHtml'] = $collectHtml;
  10063. // total price html
  10064. $collectHtml = "";
  10065. $total = 0;
  10066. for($i = 1; $i <= 12; $i ++) {
  10067. $sumPrice = 0;
  10068. foreach ( $itemStatisticsList as $key => $value ) {
  10069. if ($value ['month'] == $i) {
  10070. $sumPrice += $value ['price'];
  10071. }
  10072. }
  10073. if ($sumPrice == 0)
  10074. $collectHtml .= '<td class="taR">-</td>';
  10075. else
  10076. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10077. $total += $sumPrice;
  10078. }
  10079. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10080. $data ['companyTotalHtml'] = $collectHtml;
  10081. $data ['total'] = $total;
  10082. $data ['nature'] =$nature;
  10083. $data ['year'] = $year;
  10084. $data ['memu'] = "receipt";
  10085. $data ['staff'] = $this->staff;
  10086. $data ['receiptMemu'] = 'companyCategoryCollect';
  10087. $data ['verifyId'] = $this->verifyId;
  10088. $data ['executeId'] = $this->executeId;
  10089. if ($year <= date ( "Y" )) {
  10090. Doo::loadModel ( 'receipt' );
  10091. $receipt = new receipt ();
  10092. $receiptList = $receipt->find ( array (
  10093. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  10094. 'asArray' => true
  10095. ) );
  10096. if (empty ( $receiptList )) { // generated files
  10097. ob_start ();
  10098. $this->render ( "/admin/saeaStaffCollectB", $data );
  10099. $this->cacheFile ( $path );
  10100. die ();
  10101. }
  10102. }
  10103. $this->render ( "/admin/saeaStaffCollectB", $data );
  10104. }
  10105. function staffCollectBak() {
  10106. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10107. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  10108. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  10109. $this->showCache ( $path );
  10110. Doo::loadModel ( 'statistics' );
  10111. $statistics = new statistics ();
  10112. Doo::loadModel ( "receiptDetail" );
  10113. $receiptDetail = new receiptDetail ();
  10114. Doo::loadModel ( 'L_category' );
  10115. $Lcategory = new L_category ();
  10116. Doo::loadModel ( 'accountItem' );
  10117. $accountItem = new accountItem ();
  10118. Doo::loadModel ( 'staff' );
  10119. $staff = new staff ();
  10120. Doo::loadModel ( 'itemStatistics' );
  10121. $itemStatistics = new itemStatistics ();
  10122. $itemStatisticsList = $itemStatistics->find ( array (
  10123. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10124. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10125. 'groupby' => 'staff,itemCategory,Month(date)',
  10126. 'asArray' => true
  10127. ) );
  10128. $itemCategoryList = $itemStatistics->find ( array (
  10129. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  10130. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10131. 'groupby' => 'cid,itemCategory,Month(date)',
  10132. 'asArray' => true
  10133. ) );
  10134. $LcategoryList = $Lcategory->find ( array (
  10135. 'asArray' => true
  10136. ) );
  10137. $staffList = $staff->find ( array (
  10138. 'asArray' => true
  10139. ) );
  10140. $htmlArray = array ();
  10141. foreach ( $LcategoryList as $value ) {
  10142. $htmlArray [$value ['title']] = array ();
  10143. foreach ( $staffList as $v ) {
  10144. if ($value ['cid'] == $v ['cid']) {
  10145. $html = "";
  10146. $falg = true;
  10147. $staffSumPrice = 0;
  10148. foreach ( $itemStatisticsList as $a ) {
  10149. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  10150. if (empty ( $a ['price'] )) {
  10151. $html .= '<td class="taR">-</td>';
  10152. $falg = false;
  10153. break;
  10154. } else {
  10155. $staffSumPrice += $a ['price'];
  10156. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10157. $falg = false;
  10158. break;
  10159. }
  10160. }
  10161. }
  10162. if ($falg) {
  10163. $html .= '<td class="taR">-</td>';
  10164. $falg = true;
  10165. }
  10166. $falg = true;
  10167. foreach ( $itemStatisticsList as $a ) {
  10168. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  10169. if (empty ( $a ['price'] )) {
  10170. $html .= '<td class="taR">-</td>';
  10171. $falg = false;
  10172. break;
  10173. } else {
  10174. $staffSumPrice += $a ['price'];
  10175. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10176. $falg = false;
  10177. break;
  10178. }
  10179. }
  10180. }
  10181. if ($falg) {
  10182. $html .= '<td class="taR">-</td>';
  10183. $falg = true;
  10184. }
  10185. $falg = true;
  10186. foreach ( $itemStatisticsList as $a ) {
  10187. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  10188. if (empty ( $a ['price'] )) {
  10189. $html .= '<td class="taR">-</td>';
  10190. $falg = false;
  10191. break;
  10192. } else {
  10193. $staffSumPrice += $a ['price'];
  10194. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10195. $falg = false;
  10196. break;
  10197. }
  10198. }
  10199. }
  10200. if ($falg) {
  10201. $html .= '<td class="taR">-</td>';
  10202. $falg = true;
  10203. }
  10204. $falg = true;
  10205. foreach ( $itemStatisticsList as $a ) {
  10206. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  10207. if (! empty ( $a ['price'] )) {
  10208. $staffSumPrice += $a ['price'];
  10209. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10210. $falg = false;
  10211. break;
  10212. } else {
  10213. $html .= '<td class="taR">-</td>';
  10214. $falg = false;
  10215. break;
  10216. }
  10217. }
  10218. }
  10219. if ($falg) {
  10220. $html .= '<td class="taR">-</td>';
  10221. $falg = true;
  10222. }
  10223. $falg = true;
  10224. foreach ( $itemStatisticsList as $a ) {
  10225. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  10226. if (! empty ( $a ['price'] )) {
  10227. $staffSumPrice += $a ['price'];
  10228. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  10229. $falg = false;
  10230. break;
  10231. } else {
  10232. $html .= '<td class="taR">-</td>';
  10233. $falg = false;
  10234. break;
  10235. }
  10236. }
  10237. }
  10238. if ($falg) {
  10239. $html .= '<td class="taR">-</td>';
  10240. $falg = true;
  10241. }
  10242. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  10243. $htmlArray [$value ['title']] [$v ['username']] = $html;
  10244. }
  10245. }
  10246. /* -- --- */
  10247. // 合计费用
  10248. $cateHtml = "";
  10249. $catePrice = 0;
  10250. $cateFalg = true;
  10251. foreach ( $itemCategoryList as $l ) {
  10252. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  10253. if (empty ( $l ['price'] )) {
  10254. $cateHtml .= '<td class="colGreen taR">-</td>';
  10255. $cateFalg = false;
  10256. break;
  10257. } else {
  10258. $catePrice += $l ['price'];
  10259. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10260. $cateFalg = false;
  10261. break;
  10262. }
  10263. }
  10264. }
  10265. if ($cateFalg) {
  10266. $cateHtml .= '<td class="colGreen taR">-</td>';
  10267. $cateFalg = true;
  10268. }
  10269. $cateFalg = true;
  10270. foreach ( $itemCategoryList as $l ) {
  10271. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  10272. if (empty ( $l ['price'] )) {
  10273. $cateHtml .= '<td class="colGreen taR">-</td>';
  10274. $cateFalg = false;
  10275. break;
  10276. } else {
  10277. $catePrice += $l ['price'];
  10278. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10279. $cateFalg = false;
  10280. break;
  10281. }
  10282. }
  10283. }
  10284. if ($cateFalg) {
  10285. $cateHtml .= '<td class="colGreen taR">-</td>';
  10286. $cateFalg = true;
  10287. }
  10288. $cateFalg = true;
  10289. foreach ( $itemCategoryList as $l ) {
  10290. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  10291. if (empty ( $l ['price'] )) {
  10292. $cateHtml .= '<td class="colGreen taR">-</td>';
  10293. $cateFalg = false;
  10294. break;
  10295. } else {
  10296. $catePrice += $l ['price'];
  10297. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10298. $cateFalg = false;
  10299. break;
  10300. }
  10301. }
  10302. }
  10303. if ($cateFalg) {
  10304. $cateHtml .= '<td class="colGreen taR">-</td>';
  10305. $cateFalg = true;
  10306. }
  10307. $cateFalg = true;
  10308. foreach ( $itemCategoryList as $l ) {
  10309. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  10310. if (empty ( $l ['price'] )) {
  10311. $cateHtml .= '<td class="colGreen taR">-</td>';
  10312. $cateFalg = false;
  10313. break;
  10314. } else {
  10315. $catePrice += $l ['price'];
  10316. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10317. $cateFalg = false;
  10318. break;
  10319. }
  10320. }
  10321. }
  10322. if ($cateFalg) {
  10323. $cateHtml .= '<td class="colGreen taR">-</td>';
  10324. $cateFalg = true;
  10325. }
  10326. $cateFalg = true;
  10327. foreach ( $itemCategoryList as $l ) {
  10328. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  10329. if (empty ( $l ['price'] )) {
  10330. $cateHtml .= '<td class="colGreen taR">-</td>';
  10331. $cateFalg = false;
  10332. break;
  10333. } else {
  10334. $catePrice += $l ['price'];
  10335. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  10336. $cateFalg = false;
  10337. break;
  10338. }
  10339. }
  10340. }
  10341. if ($cateFalg) {
  10342. $cateHtml .= '<td class="colGreen taR">-</td>';
  10343. $cateFalg = true;
  10344. }
  10345. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  10346. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  10347. /* -- --- */
  10348. }
  10349. // print_r($htmlArray);die;
  10350. $data ['htmlArray'] = $htmlArray;
  10351. // statistics html
  10352. $stList = $statistics->getOne ( array (
  10353. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10354. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10355. 'groupby' => 'Month(date)',
  10356. 'asArray' => true
  10357. ) );
  10358. if (empty ( $stList ))
  10359. $stList = array (
  10360. 'rePrice' => 0,
  10361. 'agPrice' => 0
  10362. );
  10363. $data ['stList'] = array (
  10364. 'rePrice' => $stList ['rePrice'],
  10365. 'agPrice' => $stList ['agPrice'],
  10366. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10367. );
  10368. $monthHtml = "";
  10369. for($i = 1; $i <= 12; $i ++) {
  10370. if ($i == $month)
  10371. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10372. else
  10373. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10374. }
  10375. $data ['monthHtml'] = $monthHtml;
  10376. $data ['year'] = $year;
  10377. $data ['month'] = $month;
  10378. $data ['memu'] = "receipt";
  10379. $data ['staff'] = $this->staff;
  10380. $data ['receiptMemu'] = 'companyCategoryCollect';
  10381. $data ['verifyId'] = $this->verifyId;
  10382. $data ['executeId'] = $this->executeId;
  10383. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10384. Doo::loadModel ( 'receipt' );
  10385. $receipt = new receipt ();
  10386. $receiptList = $receipt->find ( array (
  10387. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10388. 'asArray' => true
  10389. ) );
  10390. if (empty ( $receiptList )) { // generated files
  10391. ob_start ();
  10392. $this->render ( "/admin/saeaStaffCollect", $data );
  10393. $this->cacheFile ( $path );
  10394. die ();
  10395. }
  10396. }
  10397. $this->render ( "/admin/saeaStaffCollect", $data );
  10398. }
  10399. /**
  10400. * 日常收支
  10401. */
  10402. function payments() {
  10403. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10404. Doo::loadModel ( "execute" );
  10405. $execute = new execute ();
  10406. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10407. die ( 'illegal request' );
  10408. }
  10409. Doo::loadModel ( "accountBook" );
  10410. $accountBook = new accountBook ();
  10411. Doo::loadModel ( "accountBookStatistics" );
  10412. $accountBookStatistics = new accountBookStatistics ();
  10413. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10414. $list = $accountBook->getAccountBookByLimit ( 10 );
  10415. $data ['date'] = date ( "Y-m-d" );
  10416. $data ['statisticsList'] = $statisticsList;
  10417. $data ['list'] = $list;
  10418. $data ['memu'] = "receipt";
  10419. $data ['staff'] = $this->staff;
  10420. $data ['receiptMemu'] = 'payments';
  10421. $data ['verifyId'] = $this->verifyId;
  10422. $data ['executeId'] = $this->executeId;
  10423. $this->render ( "/expenses/payments", $data );
  10424. }
  10425. function paymentsIncomeDo() {
  10426. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10427. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10428. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10429. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10430. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10431. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10432. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10433. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10434. Doo::loadClass ( 'XDeode' );
  10435. $XDeode = new XDeode ( 5 );
  10436. Doo::loadModel ( "accountBook" );
  10437. Doo::loadModel ( "accountBookStatistics" );
  10438. Doo::loadModel ( 'wasteBook' );
  10439. // 记录流水时银行的转换
  10440. $accountBank = '';
  10441. if ($receivedBank == '纵横广发') {
  10442. $accountBank = 'CGBDeposit';
  10443. } elseif ($receivedBank == '纵横工行') {
  10444. $accountBank = 'ICBCDeposit';
  10445. } elseif ($receivedBank == '华润银行') {
  10446. $accountBank = 'HUADeposit';
  10447. } elseif ($receivedBank == '个人广发') {
  10448. $accountBank = 'PersonalDeposit';
  10449. }
  10450. if (empty ( $accountBank ))
  10451. die ( 'illegal request' );
  10452. if($accountType == 11 || $accountType == 12){
  10453. if($accountType == 11){
  10454. $receivedBank = '纵横广发';
  10455. }elseif($accountType == 12){
  10456. $receivedBank = '纵横工行';
  10457. }
  10458. // 添加一条收入
  10459. $accountBook = new accountBook ();
  10460. $accountBook->accountType = $accountType;
  10461. $accountBook->accountMsg = $accountMsg;
  10462. $accountBook->receivedPrice = $receivedPrice;
  10463. $accountBook->receivedMsg = $receivedMsg;
  10464. $accountBook->receivedBank = $receivedBank;
  10465. $accountBook->receivedDate = $receivedDate;
  10466. $accountBook->remarks = $remarks;
  10467. $accountBook->expensesType = 1;
  10468. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10469. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10470. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10471. $inComeId = $accountBook->insert ();
  10472. // 收支汇总-添加一条收入日常汇总
  10473. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10474. $accountBookStatistics = new accountBookStatistics ();
  10475. $item = array (
  10476. 'date' => date ( "Y-m-d" ),
  10477. 'accountType' => $abDetail ['accountType'],
  10478. 'accountMsg' => $abDetail ['accountMsg'],
  10479. 'aid' => $abDetail ['aid'],
  10480. 'inComePrice' => $abDetail ['receivedPrice'],
  10481. 'expensesType' => $abDetail ['expensesType']
  10482. );
  10483. $accountBookStatistics->setAccountBookStatistics ( $item );
  10484. //流水支出
  10485. // if($accountBank=='CGBDeposit'){
  10486. // $dailyExpenditureType='8';
  10487. // }elseif($accountBank=='ICBCDeposit'){
  10488. // $dailyExpenditureType='9';
  10489. // }elseif($accountBank=='PersonalDeposit'){
  10490. // $dailyExpenditureType='10';
  10491. // }elseif($accountBank=='HUADeposit'){
  10492. // $dailyExpenditureType='11';
  10493. // }
  10494. //
  10495. // $wasteBook = new wasteBook ();
  10496. // $itemWaste = array (
  10497. // 'expensesType' => 2,
  10498. // 'accountType' => 5,
  10499. // 'accountPriceShow' => $receivedPrice,
  10500. // 'accountPrice' => - $receivedPrice,
  10501. // 'dataID' => $inComeId,
  10502. // 'dailyExpenditureType' => $dailyExpenditureType,
  10503. // 'accountBank' => $accountBank,
  10504. // 'category' => $this->staff [0] ['category'],
  10505. // 'cid' => $this->staff [0] ['cid'],
  10506. // 'name' => $this->staff [0] ['username'],
  10507. // 'sid' => $this->staff [0] ['sid'],
  10508. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10509. // );
  10510. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10511. // 添加收入流水
  10512. if($accountType == 11){
  10513. $accountBank = 'CGBDeposit';
  10514. }elseif($accountType == 12){
  10515. $accountBank = 'ICBCDeposit';
  10516. }
  10517. $wasteBook = new wasteBook ();
  10518. $itemWaste = array (
  10519. 'accountPriceShow' => $receivedPrice,
  10520. 'accountPrice' => $receivedPrice,
  10521. 'expensesType' => 1,
  10522. 'accountType' => 6, // 流水类型
  10523. 'dataID' => $inComeId,
  10524. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10525. 'accountBank' => $accountBank,
  10526. 'category' => $this->staff [0] ['category'],
  10527. 'cid' => $this->staff [0] ['cid'],
  10528. 'name' => $this->staff [0] ['username'],
  10529. 'sid' => $this->staff [0] ['sid'],
  10530. 'inputDate' => date ( "Y-m-d H:i:s" )
  10531. );
  10532. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10533. }elseif($accountType == 7 || $accountType == 9) { // 收入为理财时特殊处理
  10534. if ($receivedBank == '个人广发') {
  10535. die ( '个人广发 illegal request' );
  10536. }
  10537. // 添加一条收入
  10538. $accountBook = new accountBook ();
  10539. $accountBook->accountType = 10;
  10540. $accountBook->accountMsg = $accountMsg;
  10541. $accountBook->receivedPrice = $receivedPrice;
  10542. $accountBook->receivedMsg = $receivedMsg;
  10543. $accountBook->receivedBank = $receivedBank;
  10544. $accountBook->receivedDate = $receivedDate;
  10545. $accountBook->remarks = $remarks;
  10546. $accountBook->expensesType = 1;
  10547. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10548. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10549. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10550. $inComeId = $accountBook->insert ();
  10551. // 收支汇总-添加一条收入日常汇总
  10552. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10553. $accountBookStatistics = new accountBookStatistics ();
  10554. $item = array (
  10555. 'date' => date ( "Y-m-d" ),
  10556. 'accountType' => $abDetail ['accountType'],
  10557. 'accountMsg' => $abDetail ['accountMsg'],
  10558. 'aid' => $abDetail ['aid'],
  10559. 'inComePrice' => $abDetail ['receivedPrice'],
  10560. 'expensesType' => $abDetail ['expensesType']
  10561. );
  10562. $accountBookStatistics->setAccountBookStatistics ( $item );
  10563. // 添加收入流水
  10564. $wasteBook = new wasteBook ();
  10565. $itemWaste = array (
  10566. 'accountPriceShow' => $receivedPrice,
  10567. 'accountPrice' => $receivedPrice,
  10568. 'expensesType' => 1,
  10569. 'accountType' => 6, // 流水类型
  10570. 'dataID' => $inComeId,
  10571. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10572. 'accountBank' => $accountBank,
  10573. 'category' => $this->staff [0] ['category'],
  10574. 'cid' => $this->staff [0] ['cid'],
  10575. 'name' => $this->staff [0] ['username'],
  10576. 'sid' => $this->staff [0] ['sid'],
  10577. 'inputDate' => date ( "Y-m-d H:i:s" )
  10578. );
  10579. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10580. // 添加一条理财支出
  10581. $accountBank = 'CGBDeposit';
  10582. $expenditureBank = '纵横广发';
  10583. $dailyExpenditureType = 4;
  10584. if ($accountType == 9) {
  10585. $accountBank = 'ICBCDeposit';
  10586. $expenditureBank = '纵横工行';
  10587. $dailyExpenditureType = 6;
  10588. }
  10589. $accountBook = new accountBook ();
  10590. $accountBook->expensesType = 2;
  10591. $accountBook->expenditureType = $dailyExpenditureType;
  10592. $accountBook->expenditureMsg = $accountMsg;
  10593. $accountBook->expenditurePrice = $receivedPrice;
  10594. $accountBook->expenditureBank = $expenditureBank;
  10595. $accountBook->expenditureDate = $receivedDate;
  10596. $accountBook->remarks = $remarks;
  10597. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10598. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10599. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10600. $id = $accountBook->insert ();
  10601. // 收支汇总-添加一条理财支出汇总
  10602. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10603. $accountBookStatistics = new accountBookStatistics ();
  10604. $item = array (
  10605. 'date' => date ( "Y-m-d" ),
  10606. 'accountType' => $abDetail ['accountType'],
  10607. 'accountMsg' => $abDetail ['accountMsg'],
  10608. 'aid' => $abDetail ['aid'],
  10609. 'financingPrice' => - $receivedPrice,
  10610. 'expensesType' => 3
  10611. );
  10612. $accountBookStatistics->setAccountBookStatistics ( $item );
  10613. // 添加一条支出理财流水
  10614. $accountTypeWaste = 5;
  10615. if ($accountMsg == '公司固定') {
  10616. $accountTypeWaste = 9;
  10617. } elseif ($accountMsg == '公司活期') {
  10618. $accountTypeWaste = 10;
  10619. } elseif ($accountMsg == '个人(GR)') {
  10620. $accountBank = 'PersonalDeposit';
  10621. }
  10622. $itemWaste = array (
  10623. 'expensesType' => 2,
  10624. 'accountType' => $accountTypeWaste,
  10625. 'accountPriceShow' => $receivedPrice,
  10626. 'accountPrice' => - $receivedPrice,
  10627. 'dataID' => $id,
  10628. 'dailyExpenditureType' => $dailyExpenditureType,
  10629. 'accountBank' => $accountBank,
  10630. 'category' => $this->staff [0] ['category'],
  10631. 'cid' => $this->staff [0] ['cid'],
  10632. 'name' => $this->staff [0] ['username'],
  10633. 'sid' => $this->staff [0] ['sid'],
  10634. 'inputDate' => date ( "Y-m-d H:i:s" )
  10635. );
  10636. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10637. } elseif ($accountType == 1) {
  10638. if ($receivedBank == '个人广发')
  10639. die ( 'illegal request' );
  10640. // 添加一条收入
  10641. $accountBook = new accountBook ();
  10642. $accountBook->accountType = $accountType;
  10643. $accountBook->accountMsg = $accountMsg;
  10644. $accountBook->receivedPrice = $receivedPrice;
  10645. $accountBook->receivedMsg = $receivedMsg;
  10646. $accountBook->receivedBank = $receivedBank;
  10647. $accountBook->receivedDate = $receivedDate;
  10648. $accountBook->remarks = $remarks;
  10649. $accountBook->expensesType = 1;
  10650. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10651. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10652. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10653. $id = $accountBook->insert ();
  10654. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10655. // 收支汇总-添加一条收入日常汇总
  10656. $accountBookStatistics = new accountBookStatistics ();
  10657. $item = array (
  10658. 'date' => date ( "Y-m-d" ),
  10659. 'accountType' => $abDetail ['accountType'],
  10660. 'accountMsg' => $abDetail ['accountMsg'],
  10661. 'aid' => $abDetail ['aid'],
  10662. 'expensesType' => $abDetail ['expensesType']
  10663. );
  10664. if ($abDetail ['accountType'] == 8) {
  10665. $item += array (
  10666. 'inComePrice' => $abDetail ['receivedPrice']
  10667. );
  10668. } else {
  10669. $item += array (
  10670. 'inComePrice' => $abDetail ['receivedPrice']
  10671. );
  10672. }
  10673. $accountBookStatistics->setAccountBookStatistics ( $item );
  10674. // 流水存储方向
  10675. $itemWaste = array (
  10676. 'accountType' => 6
  10677. ); // 流水类型
  10678. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10679. // }else
  10680. if ($accountMsg == '活期理财收益') {
  10681. $itemWaste = array (
  10682. 'accountType' => 10
  10683. ); // 流水类型
  10684. }
  10685. // 添加收入流水
  10686. $wasteBook = new wasteBook ();
  10687. $itemWaste += array (
  10688. 'accountPrice' => $receivedPrice,
  10689. 'accountPriceShow' => $receivedPrice,
  10690. 'expensesType' => 1,
  10691. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10692. 'dataID' => $id,
  10693. 'accountBank' => $accountBank,
  10694. 'category' => $this->staff [0] ['category'],
  10695. 'cid' => $this->staff [0] ['cid'],
  10696. 'name' => $this->staff [0] ['username'],
  10697. 'sid' => $this->staff [0] ['sid'],
  10698. 'inputDate' => date ( "Y-m-d H:i:s" )
  10699. );
  10700. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10701. } else { // 普通日常收入处理
  10702. // 添加一条收入
  10703. $accountBook = new accountBook ();
  10704. $accountBook->accountType = $accountType;
  10705. $accountBook->accountMsg = $accountMsg;
  10706. $accountBook->receivedPrice = $receivedPrice;
  10707. $accountBook->receivedMsg = $receivedMsg;
  10708. $accountBook->receivedBank = $receivedBank;
  10709. $accountBook->receivedDate = $receivedDate;
  10710. $accountBook->remarks = $remarks;
  10711. $accountBook->expensesType = 1;
  10712. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10713. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10714. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10715. $id = $accountBook->insert ();
  10716. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10717. // 收支汇总-添加一条收入日常汇总
  10718. $accountBookStatistics = new accountBookStatistics ();
  10719. $item = array (
  10720. 'date' => date ( "Y-m-d" ),
  10721. 'accountType' => $abDetail ['accountType'],
  10722. 'accountMsg' => $abDetail ['accountMsg'],
  10723. 'aid' => $abDetail ['aid'],
  10724. 'expensesType' => $abDetail ['expensesType']
  10725. );
  10726. if ($abDetail ['accountType'] == 8) {
  10727. $item += array (
  10728. 'inComePrice' => $abDetail ['receivedPrice']
  10729. );
  10730. } else {
  10731. $item += array (
  10732. 'inComePrice' => $abDetail ['receivedPrice']
  10733. );
  10734. }
  10735. $accountBookStatistics->setAccountBookStatistics ( $item );
  10736. // 添加收入流水
  10737. $itemWaste = array (
  10738. 'accountPrice' => $receivedPrice
  10739. );
  10740. if ($receivedBank == '个人广发') {
  10741. $itemWaste = array (
  10742. 'accountPrice' => - $receivedPrice
  10743. );
  10744. }
  10745. $wasteBook = new wasteBook ();
  10746. $itemWaste += array (
  10747. 'accountPriceShow' => $receivedPrice,
  10748. 'expensesType' => 1,
  10749. 'accountType' => 6, // 流水类型
  10750. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10751. 'dataID' => $id,
  10752. 'accountBank' => $accountBank,
  10753. 'category' => $this->staff [0] ['category'],
  10754. 'cid' => $this->staff [0] ['cid'],
  10755. 'name' => $this->staff [0] ['username'],
  10756. 'sid' => $this->staff [0] ['sid'],
  10757. 'inputDate' => date ( "Y-m-d H:i:s" )
  10758. );
  10759. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10760. }
  10761. }
  10762. return '/payments';
  10763. }
  10764. function paymentsExpenditureDo() {
  10765. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10766. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10767. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10768. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10769. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10770. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10771. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10772. // 理财支出特殊处理
  10773. Doo::loadModel ( "accountBook" );
  10774. Doo::loadModel ( "accountBookStatistics" );
  10775. Doo::loadModel ( 'wasteBook' );
  10776. $accountBank = '';
  10777. if ($expenditureBank == '纵横广发') {
  10778. $accountBank = 'CGBDeposit';
  10779. } elseif ($expenditureBank == '纵横工行') {
  10780. $accountBank = 'ICBCDeposit';
  10781. } elseif ($expenditureBank == '华润银行') {
  10782. $accountBank = 'HUADeposit';
  10783. } elseif ($expenditureBank == '个人广发') {
  10784. $accountBank = 'PersonalDeposit';
  10785. }
  10786. if (empty ( $accountBank ))
  10787. die ( 'illegal request' );
  10788. if($expenditureType == 8 || $expenditureType == 9){
  10789. if($expenditureType == 8 ){
  10790. $expenditureBank='纵横广发';
  10791. }elseif($expenditureType == 9){
  10792. $expenditureBank='纵横工行';
  10793. }
  10794. // 添加一笔日常支出
  10795. $accountBook = new accountBook ();
  10796. $accountBook->expensesType = 2;
  10797. $accountBook->expenditureType = $expenditureType;
  10798. $accountBook->expenditureMsg = $expenditureMsg;
  10799. $accountBook->expenditurePrice = $expenditurePrice;
  10800. $accountBook->expenditureBank = $expenditureBank;
  10801. $accountBook->expenditureDate = $expenditureDate;
  10802. $accountBook->remarks = $remarks;
  10803. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10804. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10805. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10806. $expenditureId = $accountBook->insert ();
  10807. // 添加日常支出汇总
  10808. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10809. $accountBookStatistics = new accountBookStatistics ();
  10810. $item = array (
  10811. 'date' => date ( "Y-m-d" ),
  10812. 'expenditureType' => $abDetail ['expenditureType'],
  10813. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10814. 'aid' => $abDetail ['aid'],
  10815. 'payPrice' => $abDetail ['expenditurePrice'],
  10816. 'expensesType' => $abDetail ['expensesType']
  10817. );
  10818. $accountBookStatistics->setAccountBookStatistics ( $item );
  10819. // 公司日常支出流水
  10820. if($expenditureType == 8 ){
  10821. $accountBank = 'CGBDeposit';
  10822. }elseif($expenditureType == 9){
  10823. $accountBank = 'ICBCDeposit';
  10824. }
  10825. if($accountBank=='CGBDeposit'){
  10826. $dailyExpenditureType='8';
  10827. }elseif($accountBank=='ICBCDeposit'){
  10828. $dailyExpenditureType='9';
  10829. }elseif($accountBank=='PersonalDeposit'){
  10830. $dailyExpenditureType='10';
  10831. }elseif($accountBank=='HUADeposit'){
  10832. $dailyExpenditureType='11';
  10833. }
  10834. $wasteBook = new wasteBook ();
  10835. $itemWaste = array (
  10836. 'expensesType' => 2,
  10837. 'accountType' => 5,
  10838. 'dailyExpenditureType' => $dailyExpenditureType,
  10839. 'accountPriceShow' => $expenditurePrice,
  10840. 'accountPrice' => - $expenditurePrice,
  10841. 'dataID' => $expenditureId,
  10842. 'accountBank' => $accountBank,
  10843. 'category' => $this->staff [0] ['category'],
  10844. 'cid' => $this->staff [0] ['cid'],
  10845. 'name' => $this->staff [0] ['username'],
  10846. 'sid' => $this->staff [0] ['sid'],
  10847. 'inputDate' => date ( "Y-m-d H:i:s" )
  10848. );
  10849. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10850. // 添加一笔收入流水
  10851. // if($expenditureType==8){
  10852. // $dailyIncomeType='11';
  10853. // }elseif($expenditureType==9){
  10854. // $dailyIncomeType='12';
  10855. // }
  10856. // $wasteBook = new wasteBook ();
  10857. // $itemWaste = array (
  10858. // 'expensesType' => 1,
  10859. // 'accountType' => 6,
  10860. // 'accountPriceShow' => $expenditurePrice,
  10861. // 'accountPrice' => $expenditurePrice,
  10862. // 'dataID' => $expenditureId,
  10863. //
  10864. // 'dailyIncomeType' => $dailyIncomeType,
  10865. // 'accountBank' => $accountBank,
  10866. // 'category' => $this->staff [0] ['category'],
  10867. // 'cid' => $this->staff [0] ['cid'],
  10868. // 'name' => $this->staff [0] ['username'],
  10869. // 'sid' => $this->staff [0] ['sid'],
  10870. // 'inputDate' => date ( "Y-m-d H:i:s" )
  10871. // );
  10872. // $wasteBook->setAccountBookStatistics ( $itemWaste );
  10873. }elseif ($expenditureType == 4 || $expenditureType == 6) {
  10874. if ($expenditureBank == '个人广发') {
  10875. die ( '个人广发 illegal request' );
  10876. }
  10877. // 添加一笔日常支出
  10878. $accountBook = new accountBook ();
  10879. $accountBook->expensesType = 2;
  10880. $accountBook->expenditureType = 7;
  10881. $accountBook->expenditureMsg = $expenditureMsg;
  10882. $accountBook->expenditurePrice = $expenditurePrice;
  10883. $accountBook->expenditureBank = $expenditureBank;
  10884. $accountBook->expenditureDate = $expenditureDate;
  10885. $accountBook->remarks = $remarks;
  10886. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10887. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10888. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10889. $expenditureId = $accountBook->insert ();
  10890. // 添加日常支出汇总
  10891. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10892. $accountBookStatistics = new accountBookStatistics ();
  10893. $item = array (
  10894. 'date' => date ( "Y-m-d" ),
  10895. 'expenditureType' => $abDetail ['expenditureType'],
  10896. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10897. 'aid' => $abDetail ['aid'],
  10898. 'payPrice' => $abDetail ['expenditurePrice'],
  10899. 'expensesType' => $abDetail ['expensesType']
  10900. );
  10901. $accountBookStatistics->setAccountBookStatistics ( $item );
  10902. // 公司日常支出流水
  10903. $wasteBook = new wasteBook ();
  10904. $itemWaste = array (
  10905. 'accountPrice' => - $expenditurePrice
  10906. );
  10907. if ($expenditureBank == '个人广发') {
  10908. $itemWaste = array (
  10909. 'accountPrice' => $expenditurePrice
  10910. );
  10911. }
  10912. $itemWaste += array (
  10913. 'expensesType' => 2,
  10914. 'accountType' => 5,
  10915. 'dailyExpenditureType' => $expenditureType,
  10916. 'accountPriceShow' => $expenditurePrice,
  10917. 'accountPrice' => - $expenditurePrice,
  10918. 'dataID' => $expenditureId,
  10919. 'accountBank' => $accountBank,
  10920. 'category' => $this->staff [0] ['category'],
  10921. 'cid' => $this->staff [0] ['cid'],
  10922. 'name' => $this->staff [0] ['username'],
  10923. 'sid' => $this->staff [0] ['sid'],
  10924. 'inputDate' => date ( "Y-m-d H:i:s" )
  10925. );
  10926. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10927. // 添加一笔理财收入
  10928. $accountBank = 'CGBDeposit';
  10929. $dailyIncomeType = 7;
  10930. $receivedBank = '纵横广发';
  10931. if ($expenditureType == 6) {
  10932. $accountBank = 'ICBCDeposit';
  10933. $receivedBank = '纵横工行';
  10934. $dailyIncomeType = 9;
  10935. }
  10936. $accountBook = new accountBook ();
  10937. $accountBook->expensesType = 1;
  10938. $accountBook->accountType = $dailyIncomeType;
  10939. $accountBook->accountMsg = $expenditureMsg;
  10940. $accountBook->receivedPrice = $expenditurePrice;
  10941. $accountBook->receivedBank = $receivedBank;
  10942. $accountBook->receivedDate = $expenditureDate;
  10943. $accountBook->remarks = $remarks;
  10944. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10945. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10946. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10947. $id = $accountBook->insert ();
  10948. // 添加日常理财收入汇总
  10949. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10950. $accountBookStatistics = new accountBookStatistics ();
  10951. $item = array (
  10952. 'date' => date ( "Y-m-d" ),
  10953. 'expenditureType' => $abDetail ['expenditureType'],
  10954. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10955. 'aid' => $abDetail ['aid'],
  10956. 'financingPrice' => $expenditurePrice,
  10957. 'expensesType' => 3
  10958. );
  10959. $accountBookStatistics->setAccountBookStatistics ( $item );
  10960. // 添加一笔收入流水
  10961. if ($expenditureMsg == '公司固定') {
  10962. $accountTypeWaste = 9;
  10963. } elseif ($expenditureMsg == '公司活期') {
  10964. $accountTypeWaste = 10;
  10965. } elseif ($expenditureMsg == '个人(GR)') {
  10966. $accountBank = 'PersonalDeposit';
  10967. }
  10968. $itemWaste = array (
  10969. 'expensesType' => 1,
  10970. 'accountType' => $accountTypeWaste,
  10971. 'accountPriceShow' => $expenditurePrice,
  10972. 'accountPrice' => $expenditurePrice,
  10973. 'dataID' => $id,
  10974. 'dailyIncomeType' => $dailyIncomeType,
  10975. 'accountBank' => $accountBank,
  10976. 'category' => $this->staff [0] ['category'],
  10977. 'cid' => $this->staff [0] ['cid'],
  10978. 'name' => $this->staff [0] ['username'],
  10979. 'sid' => $this->staff [0] ['sid'],
  10980. 'inputDate' => date ( "Y-m-d H:i:s" )
  10981. );
  10982. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10983. } else {
  10984. // 添加一笔日常支出
  10985. $accountBook = new accountBook ();
  10986. $accountBook->expensesType = 2;
  10987. $accountBook->expenditureType = $expenditureType;
  10988. $accountBook->expenditureMsg = $expenditureMsg;
  10989. $accountBook->expenditurePrice = $expenditurePrice;
  10990. $accountBook->expenditureBank = $expenditureBank;
  10991. $accountBook->expenditureDate = $expenditureDate;
  10992. $accountBook->remarks = $remarks;
  10993. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10994. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10995. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10996. $id = $accountBook->insert ();
  10997. // 添加日常支出汇总
  10998. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10999. $accountBookStatistics = new accountBookStatistics ();
  11000. $item = array (
  11001. 'date' => date ( "Y-m-d" ),
  11002. 'expenditureType' => $abDetail ['expenditureType'],
  11003. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11004. 'aid' => $abDetail ['aid'],
  11005. 'expensesType' => $abDetail ['expensesType']
  11006. );
  11007. if ($expenditureType == 5) {
  11008. $item += array (
  11009. 'payPrice' => - $abDetail ['expenditurePrice']
  11010. );
  11011. } else {
  11012. $item += array (
  11013. 'payPrice' => $abDetail ['expenditurePrice']
  11014. );
  11015. }
  11016. $accountBookStatistics->setAccountBookStatistics ( $item );
  11017. // 公司日常支出流水
  11018. $wasteBook = new wasteBook ();
  11019. $itemWaste = array (
  11020. 'accountPrice' => - $expenditurePrice
  11021. );
  11022. if ($expenditureBank == '个人广发') {
  11023. $itemWaste = array (
  11024. 'accountPrice' => $expenditurePrice
  11025. );
  11026. }
  11027. $itemWaste += array (
  11028. 'expensesType' => 2,
  11029. 'accountType' => 5,
  11030. 'accountPriceShow' => $expenditurePrice,
  11031. 'dataID' => $id,
  11032. 'dailyExpenditureType' => $expenditureType,
  11033. 'accountBank' => $accountBank,
  11034. 'category' => $this->staff [0] ['category'],
  11035. 'cid' => $this->staff [0] ['cid'],
  11036. 'name' => $this->staff [0] ['username'],
  11037. 'sid' => $this->staff [0] ['sid'],
  11038. 'inputDate' => date ( "Y-m-d H:i:s" )
  11039. );
  11040. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11041. }
  11042. }
  11043. return '/payments';
  11044. }
  11045. /**
  11046. * 添加支出
  11047. */
  11048. function paymentsExpenditureDo_() {
  11049. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11050. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11051. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11052. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11053. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11054. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11055. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11056. $dailyExpenditureType = '';
  11057. $accountTypeWaste = 5;
  11058. $accountBank = '';
  11059. if ($expenditureBank == '纵横广发') {
  11060. $accountBank = 'CGBDeposit';
  11061. } elseif ($expenditureBank == '纵横工行') {
  11062. $accountBank = 'ICBCDeposit';
  11063. } elseif ($expenditureBank == '华润银行') {
  11064. $accountBank = 'HUADeposit';
  11065. } elseif ($expenditureBank == '个人广发') {
  11066. $accountBank = 'PersonalDeposit';
  11067. }
  11068. if (empty ( $accountBank ))
  11069. die ( 'illegal request' );
  11070. $itemWaste = array (
  11071. 'accountPrice' => - $expenditurePrice
  11072. );
  11073. if ($expenditureBank == '个人广发') {
  11074. $itemWaste = array (
  11075. 'accountPrice' => $expenditurePrice
  11076. );
  11077. }
  11078. if ($expenditureType == 4 || $expenditureType == 6) {
  11079. $dailyExpenditureType = 4;
  11080. if ($expenditureMsg == '公司固定') {
  11081. $accountTypeWaste = 9;
  11082. } elseif ($expenditureMsg == '公司活期') {
  11083. $accountTypeWaste = 10;
  11084. } elseif ($expenditureMsg == '个人(GR)') {
  11085. $accountBank = 'PersonalDeposit';
  11086. }
  11087. $itemWaste = array (
  11088. 'accountPrice' => $expenditurePrice
  11089. );
  11090. } elseif ($expenditureType == 1) {
  11091. $dailyExpenditureType = 1;
  11092. } elseif ($expenditureType == 2) {
  11093. $dailyExpenditureType = 2;
  11094. } elseif ($expenditureType == 3) {
  11095. $dailyExpenditureType = 3;
  11096. } elseif ($expenditureType == 5) {
  11097. $dailyExpenditureType = 5;
  11098. }
  11099. if (empty ( $dailyExpenditureType ))
  11100. die ( 'illegal request' );
  11101. Doo::loadModel ( "accountBook" );
  11102. $accountBook = new accountBook ();
  11103. $accountBook->expenditureType = $expenditureType;
  11104. $accountBook->expenditureMsg = $expenditureMsg;
  11105. $accountBook->expenditurePrice = $expenditurePrice;
  11106. $accountBook->expenditureBank = $expenditureBank;
  11107. $accountBook->expenditureDate = $expenditureDate;
  11108. $accountBook->remarks = $remarks;
  11109. $accountBook->expensesType = 2;
  11110. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11111. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11112. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11113. $id = $accountBook->insert ();
  11114. //
  11115. $abDetail = $accountBook->getAccountBookByAid ( $id );
  11116. Doo::loadModel ( "accountBookStatistics" );
  11117. $accountBookStatistics = new accountBookStatistics ();
  11118. $item = array (
  11119. 'date' => date ( "Y-m-d" ),
  11120. 'expenditureType' => $abDetail ['expenditureType'],
  11121. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  11122. 'aid' => $abDetail ['aid']
  11123. );
  11124. if ($abDetail ['expensesType'] == 2) {
  11125. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  11126. $item += array (
  11127. 'financingPrice' => $expenditurePrice,
  11128. 'expensesType' => 3
  11129. );
  11130. } elseif ($abDetail ['expenditureType'] == 5) {
  11131. $item += array (
  11132. 'payPrice' => $abDetail ['expenditurePrice'],
  11133. 'expensesType' => $abDetail ['expensesType']
  11134. );
  11135. } else {
  11136. $item += array (
  11137. 'payPrice' => $abDetail ['expenditurePrice'],
  11138. 'expensesType' => $abDetail ['expensesType']
  11139. );
  11140. }
  11141. }
  11142. $accountBookStatistics->setAccountBookStatistics ( $item );
  11143. // 公司流水记录
  11144. Doo::loadModel ( 'wasteBook' );
  11145. $wasteBook = new wasteBook ();
  11146. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  11147. // 银行
  11148. if (empty ( $abDetail )) {
  11149. $itemWaste += array (
  11150. 'accountPriceShow' => $expenditurePrice,
  11151. 'dataID' => $id,
  11152. 'expensesType' => 2,
  11153. 'accountType' => $accountTypeWaste,
  11154. 'dailyExpenditureType' => $expenditureType,
  11155. 'accountBank' => $accountBank,
  11156. 'category' => $this->staff [0] ['category'],
  11157. 'cid' => $this->staff [0] ['cid'],
  11158. 'name' => $this->staff [0] ['username'],
  11159. 'sid' => $this->staff [0] ['sid'],
  11160. 'inputDate' => date ( "Y-m-d H:i:s" )
  11161. );
  11162. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11163. }
  11164. // 支出类型为4或者6 需要添加一笔收入和收入流水
  11165. if ($expenditureType == 4 || $expenditureType == 6) {
  11166. $accountBank = 'CGBDeposit';
  11167. $dailyIncomeType = 7;
  11168. $receivedBank = '纵横广发';
  11169. if ($expenditureType == 6) {
  11170. $accountBank = 'ICBCDeposit';
  11171. $receivedBank = '纵横工行';
  11172. $dailyIncomeType = 9;
  11173. }
  11174. // 添加一笔收入
  11175. $accountBook = new accountBook ();
  11176. $accountBook->accountType = $dailyIncomeType;
  11177. $accountBook->accountMsg = $expenditureMsg;
  11178. $accountBook->receivedPrice = $expenditurePrice;
  11179. $accountBook->receivedBank = $receivedBank;
  11180. $accountBook->receivedDate = $expenditureDate;
  11181. $accountBook->remarks = $remarks;
  11182. $accountBook->expensesType = 1;
  11183. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  11184. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  11185. $accountBook->inputStaff = $this->staff [0] ['sid'];
  11186. $id = $accountBook->insert ();
  11187. // 添加一笔收入流水
  11188. $itemWaste = array (
  11189. 'accountPriceShow' => $expenditurePrice,
  11190. 'accountPrice' => - $expenditurePrice,
  11191. 'dataID' => $id,
  11192. 'expensesType' => 1,
  11193. 'accountType' => $accountTypeWaste,
  11194. 'dailyIncomeType' => $dailyIncomeType,
  11195. 'accountBank' => $accountBank,
  11196. 'category' => $this->staff [0] ['category'],
  11197. 'cid' => $this->staff [0] ['cid'],
  11198. 'name' => $this->staff [0] ['username'],
  11199. 'sid' => $this->staff [0] ['sid'],
  11200. 'inputDate' => date ( "Y-m-d H:i:s" )
  11201. );
  11202. $wasteBook->setAccountBookStatistics ( $itemWaste );
  11203. }
  11204. }
  11205. return '/payments';
  11206. }
  11207. /**
  11208. * 所有收支
  11209. */
  11210. function paymentsAchieve() {
  11211. $page_size = 12;
  11212. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  11213. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  11214. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11215. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  11216. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11217. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11218. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11219. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  11220. Doo::loadModel ( "accountBookStatistics" );
  11221. $accountBookStatistics = new accountBookStatistics ();
  11222. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  11223. $data ['statisticsList'] = $statisticsList;
  11224. Doo::loadModel ( "accountBook" );
  11225. $accountBook = new accountBook ();
  11226. $con = '';
  11227. if ($expensesType == 'INCOME')
  11228. $con = ' and expensesType=1 ';
  11229. elseif ($expensesType == 'PAY')
  11230. $con = ' and expensesType=2 ';
  11231. $dateArr = explode ( ':', $date );
  11232. $D1 = $dateString = '';
  11233. $D2 = '';
  11234. if (! empty ( $date )) {
  11235. $D1 = $dateArr [0];
  11236. if (isset ( $dateArr [1] ))
  11237. $D2 = $dateArr [1];
  11238. else
  11239. $D2 = '';
  11240. $dateString = $D1 . " : " . $D2;
  11241. }
  11242. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11243. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11244. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11245. $con .= ' and inputDate like "%' . $D1 . '%" ';
  11246. if (! empty ( $price ))
  11247. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  11248. if ($submitType == 1) {
  11249. if ($accountType != '') {
  11250. $expenditureType = '';
  11251. $con .= ' and accountType=' . $accountType;
  11252. if (! empty ( $accountMsg ))
  11253. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  11254. }
  11255. } elseif ($submitType == 2) {
  11256. if ($expenditureType != '') {
  11257. $accountType = $accountMsg = '';
  11258. $con .= ' and expenditureType=' . $expenditureType;
  11259. }
  11260. } else {
  11261. $accountType = $accountMsg = $expenditureType = '';
  11262. }
  11263. $sql = "" . $con;
  11264. $action = "paymentsAchieve";
  11265. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  11266. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  11267. $limit = $pageinfo ['lower'] . ',' . $page_size;
  11268. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  11269. $data ['expenditureType'] = $expenditureType;
  11270. $data ['accountMsg'] = $accountMsg;
  11271. $data ['accountType'] = $accountType;
  11272. $data ['inputDate'] = $date;
  11273. $data ['price'] = $price;
  11274. $data ['expensesType'] = $expensesType;
  11275. $data ['page'] = $pageinfo;
  11276. $data ['list'] = $list;
  11277. $data ['memu'] = "receipt";
  11278. $data ['staff'] = $this->staff;
  11279. $data ['receiptMemu'] = 'payments';
  11280. $data ['verifyId'] = $this->verifyId;
  11281. $data ['executeId'] = $this->executeId;
  11282. $this->render ( "/expenses/paymentsAchieve", $data );
  11283. }
  11284. function paymentsIncomeUpdateDo() {
  11285. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11286. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  11287. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  11288. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  11289. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  11290. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  11291. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  11292. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11293. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  11294. Doo::loadClass ( 'XDeode' );
  11295. $XDeode = new XDeode ( 5 );
  11296. $aid = $XDeode->decode ( $aidKey );
  11297. Doo::loadModel ( "accountBook" );
  11298. $accountBook = new accountBook ();
  11299. //
  11300. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11301. $price = $receivedPrice - $abDetail [inComePrice];
  11302. Doo::loadModel ( "accountBookStatistics" );
  11303. $accountBookStatistics = new accountBookStatistics ();
  11304. if ($abDetail ['accountType'] == 7) {
  11305. $item += array (
  11306. 'date' => date ( "Y-m-d" ),
  11307. 'financingPrice' => - $price,
  11308. 'expensesType' => 3,
  11309. 'aid' => $abDetail ['aid']
  11310. );
  11311. } elseif ($abDetail ['accountType'] == 8) {
  11312. $item += array (
  11313. 'date' => date ( "Y-m-d" ),
  11314. 'expensesType' => $abDetail ['expensesType'],
  11315. 'inComePrice' => - $price,
  11316. 'aid' => $abDetail ['aid']
  11317. );
  11318. } else {
  11319. $item = array (
  11320. 'date' => date ( "Y-m-d" ),
  11321. 'expensesType' => $abDetail ['expensesType'],
  11322. 'inComePrice' => $price,
  11323. 'aid' => $abDetail ['aid']
  11324. );
  11325. }
  11326. $accountBookStatistics->setAccountBookStatistics ( $item );
  11327. $accountBook->accountType = $accountType;
  11328. $accountBook->accountMsg = $accountMsg;
  11329. $accountBook->receivedPrice = $receivedPrice;
  11330. $accountBook->receivedMsg = $receivedMsg;
  11331. $accountBook->receivedBank = $receivedBank;
  11332. $accountBook->receivedDate = $receivedDate;
  11333. $accountBook->remarks = $remarks;
  11334. $accountBook->aid = $aid;
  11335. $accountBook->update ();
  11336. }
  11337. return '/paymentsAchieve';
  11338. }
  11339. function paymentsExpenditureEdiDo() {
  11340. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11341. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  11342. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  11343. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  11344. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  11345. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  11346. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  11347. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  11348. Doo::loadClass ( 'XDeode' );
  11349. $XDeode = new XDeode ( 5 );
  11350. $aid = $XDeode->decode ( $aidKey );
  11351. Doo::loadModel ( "accountBook" );
  11352. $accountBook = new accountBook ();
  11353. // 汇总信息
  11354. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11355. $price = $expenditurePrice - $abDetail [expenditurePrice];
  11356. Doo::loadModel ( "accountBookStatistics" );
  11357. $accountBookStatistics = new accountBookStatistics ();
  11358. if ($abDetail ['expenditureType'] == 4) {
  11359. $item += array (
  11360. 'date' => date ( "Y-m-d" ),
  11361. 'financingPrice' => $price,
  11362. 'expensesType' => 3,
  11363. 'aid' => $abDetail ['aid']
  11364. );
  11365. } elseif ($abDetail ['expenditureType'] == 5) {
  11366. $item += array (
  11367. 'date' => date ( "Y-m-d" ),
  11368. 'expensesType' => $abDetail ['expensesType'],
  11369. 'payPrice' => $price,
  11370. 'aid' => $abDetail ['aid']
  11371. );
  11372. } else {
  11373. $item = array (
  11374. 'date' => date ( "Y-m-d" ),
  11375. 'expensesType' => $abDetail ['expensesType'],
  11376. 'payPrice' => $price,
  11377. 'aid' => $abDetail ['aid']
  11378. );
  11379. }
  11380. $accountBookStatistics->setAccountBookStatistics ( $item );
  11381. //
  11382. $accountBook->expenditureType = $expenditureType;
  11383. $accountBook->expenditureMsg = $expenditureMsg;
  11384. $accountBook->expenditurePrice = $expenditurePrice;
  11385. $accountBook->expenditureBank = $expenditureBank;
  11386. $accountBook->remarks = $remarks;
  11387. $accountBook->expenditureDate = $expenditureDate;
  11388. $accountBook->aid = $aid;
  11389. $id = $accountBook->update ();
  11390. }
  11391. return '/paymentsAchieve';
  11392. }
  11393. function paymentsDelDo() {
  11394. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11395. if (! empty ( $aidKey )) {
  11396. Doo::loadClass ( 'XDeode' );
  11397. $XDeode = new XDeode ( 5 );
  11398. $aid = $XDeode->decode ( $aidKey );
  11399. Doo::loadModel ( "accountBook" );
  11400. $accountBook = new accountBook ();
  11401. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11402. if (empty ( $abDetail ))
  11403. die ( 'illegal request' );
  11404. // 删除收支
  11405. Doo::loadModel ( "accountBookStatistics" );
  11406. $accountBookStatistics = new accountBookStatistics ();
  11407. $item = array (
  11408. 'date' => date ( "Y-m-d" ),
  11409. 'aid' => $abDetail ['aid']
  11410. );
  11411. $accountType = '';
  11412. if ($abDetail ['expensesType'] == 1) {
  11413. $accountType = 6;
  11414. if ($abDetail ['accountType'] != 7) {
  11415. $item += array (
  11416. 'expensesType' => $abDetail ['expensesType'],
  11417. 'inComePrice' => - $abDetail ['receivedPrice']
  11418. );
  11419. } else {
  11420. $item += array (
  11421. 'financingPrice' => $abDetail ['receivedPrice'],
  11422. 'expensesType' => 3
  11423. );
  11424. }
  11425. } elseif ($abDetail ['expensesType'] == 2) {
  11426. $accountType = 5;
  11427. if ($abDetail ['accountType'] != 7) {
  11428. $item += array (
  11429. 'expensesType' => $abDetail ['expensesType'],
  11430. 'payPrice' => - $abDetail ['expenditurePrice']
  11431. );
  11432. } else {
  11433. $item += array (
  11434. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11435. 'expensesType' => 3
  11436. );
  11437. }
  11438. }
  11439. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11440. if ($abDetail ['expenditureMsg'] == '公司固定')
  11441. $accountType = 9;
  11442. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11443. $accountType = 10;
  11444. }
  11445. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11446. if ($abDetail ['accountMsg'] == '公司固定')
  11447. $accountType = 9;
  11448. elseif ($abDetail ['accountMsg'] == '公司活期')
  11449. $accountType = 10;
  11450. }
  11451. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11452. $accountType = 10;
  11453. }
  11454. $accountBookStatistics->setAccountBookStatistics ( $item );
  11455. $accountBook->delete ( array (
  11456. 'where' => 'aid=' . $aid,
  11457. 'limit' => 1
  11458. ) );
  11459. // 删除收入流水
  11460. if (! empty ( $accountType )) {
  11461. Doo::loadModel ( 'wasteBook' );
  11462. $wasteBook = new wasteBook ();
  11463. $wasteBook->delete ( array (
  11464. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11465. 'limit' => 1
  11466. ) );
  11467. }
  11468. }
  11469. return '/paymentsAchieve';
  11470. }
  11471. function paymentsCollect() {
  11472. Doo::loadModel ( "execute" );
  11473. $execute = new execute ();
  11474. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11475. die ( 'illegal request' );
  11476. }
  11477. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11478. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11479. Doo::loadModel ( "accountBookStatistics" );
  11480. $accountBookStatistics = new accountBookStatistics ();
  11481. Doo::loadClass ( 'receipt.func' );
  11482. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11483. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11484. $data ['html'] = $html ['html'];
  11485. $data ['inSum'] = $html ['sum'];
  11486. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11487. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11488. $data ['payHtml'] = $html ['html'];
  11489. $data ['paySum'] = $html ['sum'];
  11490. // 余额统计
  11491. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11492. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11493. include './protected/config/wasteBook.conf.php';
  11494. Doo::loadModel ( 'wasteBook' );
  11495. $wasteBook = new wasteBook ();
  11496. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11497. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11498. // 获得年份之前所有金额
  11499. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11500. // print_r($detail);
  11501. // $waste['total'];
  11502. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11503. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11504. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11505. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11506. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11507. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11508. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11509. if (date ( 'Y' ) > $year) {
  11510. $limitMonth = 12;
  11511. }
  11512. for($i = 1; $i <= 12; $i ++) {
  11513. $inComeA = $payB = 0;
  11514. $falg = true;
  11515. foreach ( $inComePay as $key => $value ) {
  11516. if ($value ['month'] == $i) {
  11517. $falg = false;
  11518. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11519. $inSum += $value ['accountPrice'];
  11520. $showInSum += $value ['accountPriceShow'];
  11521. $inComeA = $value ['accountPrice'];
  11522. break;
  11523. }
  11524. }
  11525. if ($falg)
  11526. $inComeHtml .= '<td class="taR">-</td>';
  11527. $payFalg = true;
  11528. foreach ( $pay as $key => $value ) {
  11529. if ($value ['month'] == $i) {
  11530. $payFalg = false;
  11531. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11532. $paySum += $value ['accountPrice'];
  11533. $showPaySum += $value ['accountPriceShow'];
  11534. $payB = $value ['accountPrice'];
  11535. break;
  11536. }
  11537. }
  11538. if ($payFalg)
  11539. $payHtml .= '<td class="taR">-</td>';
  11540. if (empty ( $balanceC ) || $limitMonth < $i)
  11541. $lastBalanceHtml .= '<td class="taR">-</td>';
  11542. else
  11543. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11544. $balanceC = $balanceC + $inComeA + $payB;
  11545. $balanceSum += $balanceC;
  11546. if (empty ( $balanceC ) || $limitMonth < $i)
  11547. $BalanceHtml .= '<td class="taR">-</td>';
  11548. else
  11549. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11550. // 余额统计
  11551. }
  11552. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11553. $data ['inComeHtml'] = $inComeHtml;
  11554. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11555. $data ['payBalanceHtml'] = $payHtml;
  11556. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11557. $data ['BalanceHtml'] = $BalanceHtml;
  11558. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11559. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11560. $mothHtml = "";
  11561. for($i = 1; $i <= 12; $i ++) {
  11562. if ($moth == $i)
  11563. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11564. else
  11565. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11566. }
  11567. $data ['mothHtml'] = $mothHtml;
  11568. $dateHtml = "";
  11569. $now = date ( "Y" );
  11570. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11571. if ($YEARD <= $now) {
  11572. $dateHtml .= '<option ';
  11573. if ($year == $YEARD) {
  11574. $dateHtml .= 'selected ';
  11575. }
  11576. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11577. }
  11578. }
  11579. $data ['dateHtml'] = $dateHtml;
  11580. $data ['year'] = $year;
  11581. $data ['memu'] = "receipt";
  11582. $data ['staff'] = $this->staff;
  11583. $data ['receiptMemu'] = 'paymentsCollect';
  11584. $data ['verifyId'] = $this->verifyId;
  11585. $data ['executeId'] = $this->executeId;
  11586. $this->render ( "/expenses/paymentsCollect", $data );
  11587. }
  11588. function paymentsCollectDay() {
  11589. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11590. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11591. if (empty ( $moth ))
  11592. return 'paymentsCollect';
  11593. Doo::loadModel ( "accountBookStatistics" );
  11594. $accountBookStatistics = new accountBookStatistics ();
  11595. $i = 2;
  11596. $y = 2013;
  11597. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11598. Doo::loadClass ( 'receipt.func' );
  11599. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11600. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11601. $data ['html'] = $html ['html'];
  11602. $data ['inSum'] = $html ['sum'];
  11603. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11604. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11605. $data ['payHtml'] = $html ['html'];
  11606. $data ['paySum'] = $html ['sum'];
  11607. $mothHtml = "";
  11608. for($i = 1; $i <= 12; $i ++) {
  11609. if ($moth == $i)
  11610. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11611. else
  11612. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11613. }
  11614. $data ['mothHtml'] = $mothHtml;
  11615. $data ['year'] = $year;
  11616. // 余额
  11617. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11618. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11619. include './protected/config/wasteBook.conf.php';
  11620. Doo::loadModel ( 'wasteBook' );
  11621. $wasteBook = new wasteBook ();
  11622. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11623. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11624. // 获得年份之前所有金额
  11625. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11626. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11627. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11628. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11629. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11630. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11631. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11632. // $balanceC = 0;
  11633. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11634. $limitDay = date ( 'd' );
  11635. $monthLK = ( int ) date ( 'm' );
  11636. if (date ( 'Y' ) > $year) {
  11637. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11638. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11639. $limitDay = 0;
  11640. }
  11641. for($i = 1; $i <= $day; $i ++) {
  11642. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11643. $inComeA = $payB = 0;
  11644. $falg = true;
  11645. foreach ( $inComePay as $key => $value ) {
  11646. if ($value ['day'] == $i) {
  11647. $falg = false;
  11648. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11649. $inSum += $value ['accountPrice'];
  11650. $showInSum += $value ['accountPriceShow'];
  11651. $inComeA = $value ['accountPrice'];
  11652. break;
  11653. }
  11654. }
  11655. if ($falg)
  11656. $inComeHtml .= '<td class="taR">-</td>';
  11657. $payFalg = true;
  11658. foreach ( $pay as $key => $value ) {
  11659. if ($value ['day'] == $i) {
  11660. $payFalg = false;
  11661. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11662. $paySum += $value ['accountPrice'];
  11663. $showPaySum += $value ['accountPriceShow'];
  11664. $payB = $value ['accountPrice'];
  11665. break;
  11666. }
  11667. }
  11668. if ($payFalg)
  11669. $payHtml .= '<td class="taR">-</td>';
  11670. if (empty ( $balanceC ) || $limitDay < $i)
  11671. $lastBalanceHtml .= '<td class="taR">-</td>';
  11672. else
  11673. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11674. $balanceC = $balanceC + $inComeA + $payB;
  11675. $balanceSum += $balanceC;
  11676. if (empty ( $balanceC ) || $limitDay < $i)
  11677. $BalanceHtml .= '<td class="taR">-</td>';
  11678. else
  11679. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11680. }
  11681. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11682. $data ['inComeHtml'] = $inComeHtml;
  11683. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11684. $data ['payBalanceHtml'] = $payHtml;
  11685. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11686. $data ['BalanceHtml'] = $BalanceHtml;
  11687. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11688. $data ['dayHtml'] = $dayHtml;
  11689. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11690. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11691. $dateHtml = "";
  11692. $now = date ( "Y" );
  11693. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11694. if ($YEARD <= $now) {
  11695. $dateHtml .= '<option ';
  11696. if ($year == $YEARD) {
  11697. $dateHtml .= 'selected ';
  11698. }
  11699. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11700. }
  11701. }
  11702. $data ['dateHtml'] = $dateHtml;
  11703. $data ['memu'] = "receipt";
  11704. $data ['staff'] = $this->staff;
  11705. $data ['receiptMemu'] = 'paymentsCollect';
  11706. $data ['verifyId'] = $this->verifyId;
  11707. $data ['executeId'] = $this->executeId;
  11708. $this->render ( "/expenses/paymentsCollectDay", $data );
  11709. }
  11710. // 公司流水
  11711. function wasteBook() {
  11712. Doo::loadModel ( "execute" );
  11713. $execute = new execute ();
  11714. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11715. die ( 'illegal request' );
  11716. }
  11717. include './protected/config/wasteBook.conf.php';
  11718. Doo::loadModel ( 'wasteBook' );
  11719. $wasteBook = new wasteBook ();
  11720. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11721. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11722. //
  11723. $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'];
  11724. $CGBDeposit_total =$waste ['bank'] ['CGBDeposit']+$waste ['bank'] ['HUADeposit'];
  11725. // print_r($waste);
  11726. $data ['waste'] = $waste;
  11727. $data ['total'] = $total;
  11728. $data ['CGBDeposit_total'] = $CGBDeposit_total;
  11729. $data['cashBalance']= $CGBDeposit_total+$waste ['bank'] ['ICBCDeposit']+$waste ['bank'] ['PersonalDeposit']+$waste ['financial'] ['current'] ['CGBDeposit']+$waste ['financial'] ['current'] ['ICBCDeposit'];
  11730. // 月流水数据结构
  11731. $monthStatistics = array ();
  11732. $incomeMothStatistics = array ();
  11733. $expenditureMothStatistics = array ();
  11734. for($i = 1; $i <= 12; $i ++) {
  11735. $month = date ( 'Y' ) . '-' . $i;
  11736. if ($i < 10)
  11737. $month = date ( 'Y' ) . '-0' . $i;
  11738. array_push ( $monthStatistics, $month );
  11739. }
  11740. foreach ( $monthStatistics as $value ) {
  11741. $falg = true;
  11742. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11743. if ($value == $v ['inputDate']) {
  11744. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11745. $falg = false;
  11746. }
  11747. }
  11748. if ($falg) {
  11749. array_push ( $incomeMothStatistics, '' );
  11750. }
  11751. $falgEx = true;
  11752. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11753. if ($value == $v ['inputDate']) {
  11754. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11755. $falg = false;
  11756. }
  11757. }
  11758. if ($falgEx) {
  11759. array_push ( $expenditureMothStatistics, '' );
  11760. }
  11761. }
  11762. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11763. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11764. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11765. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11766. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11767. // print_r($incomeList);
  11768. $data ['expenditureList'] = $expenditureList;
  11769. $data ['incomeList'] = $incomeList;
  11770. $data ['memu'] = "receipt";
  11771. $data ['staff'] = $this->staff;
  11772. $data ['receiptMemu'] = 'wasteBook';
  11773. $data ['verifyId'] = $this->verifyId;
  11774. $data ['executeId'] = $this->executeId;
  11775. $this->render ( "/expenses/wasteBook", $data );
  11776. }
  11777. function wasteBookIncome() {
  11778. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11779. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11780. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11781. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11782. $data ['dailyIncomeType'] = $dailyIncomeType;
  11783. Doo::loadModel ( 'wasteBook' );
  11784. $wasteBook = new wasteBook ();
  11785. Doo::loadModel ( 'L_category' );
  11786. $L_category = new L_category ();
  11787. Doo::loadClass ( 'XDeode' );
  11788. $XDeode = new XDeode ( 5 );
  11789. // echo $XDeode->encode(1).'<br>';
  11790. // echo $XDeode->encode(2).'<br>';
  11791. // echo $XDeode->encode(3).'<br>';
  11792. // echo $XDeode->encode(4).'<br>';
  11793. // echo $XDeode->encode(5).'<br>';
  11794. // echo $XDeode->encode(6).'<br>';
  11795. // echo $XDeode->encode(7).'<br>';
  11796. // echo $XDeode->encode(8).'<br>';
  11797. // echo $XDeode->encode(9).'<br>';
  11798. // echo $XDeode->encode(10).'<br>';
  11799. $year=date("Y");
  11800. $theDay=date("Y-m-d");
  11801. $dateArr = explode ( ':', $date );
  11802. $D1 = '';
  11803. $D2 = '';
  11804. $con = '';
  11805. if (! empty ( $date )) {
  11806. $D1 = $dateArr [0];
  11807. $D2 = $dateArr [1];
  11808. }
  11809. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11810. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11811. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11812. $con = ' and inputDate = "' . $D1 . '"';
  11813. else{
  11814. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11815. }
  11816. if ($cid != 'ALL') {
  11817. $cid = $XDeode->decode ( $cid );
  11818. $con .= ' and cid = "' . $cid . '"';
  11819. }
  11820. if ($accountType != 'ALL') {
  11821. if ($accountType == 'INVOICE') {
  11822. $con .= ' and (accountType = 7 or accountType = 8)';
  11823. } elseif ($accountType == 'PAYMENTS') {
  11824. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11825. if ($dailyIncomeType != 'ALL') {
  11826. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11827. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11828. }
  11829. }
  11830. }
  11831. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11832. $sum = 0;$thsDaySum=0;
  11833. foreach ( $incomeList as $key => $value ) {
  11834. $sum += $value ['accountPrice'];
  11835. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11836. $thsDaySum+=$value ['accountPrice'];
  11837. }
  11838. }
  11839. // print_r($incomeList);
  11840. // 获得办事和部门
  11841. $categoryList = $L_category->getCategory ();
  11842. $data ['accountType'] = $accountType;
  11843. $data ['cid'] = $cid;
  11844. $data ['categoryList'] = $categoryList;
  11845. $data ['sum'] = $sum;
  11846. $data ['incomeList'] = $incomeList;
  11847. $data ['inputDate'] = $date;
  11848. $data['year']=$year;
  11849. $data ['thsDay'] =$theDay;
  11850. $data ['thsDaySum'] =$thsDaySum;
  11851. $data ['memu'] = "receipt";
  11852. $data ['staff'] = $this->staff;
  11853. $data ['receiptMemu'] = 'wasteBook';
  11854. $data ['verifyId'] = $this->verifyId;
  11855. $data ['executeId'] = $this->executeId;
  11856. $this->render ( "/expenses/wasteBookIncome", $data );
  11857. }
  11858. /**
  11859. * 所有支出
  11860. */
  11861. function wasteBookExpenditure() {
  11862. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11863. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11864. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11865. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11866. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11867. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11868. $data ['receiptType'] = $receiptType;
  11869. Doo::loadModel ( 'wasteBook' );
  11870. $wasteBook = new wasteBook ();
  11871. Doo::loadModel ( 'L_category' );
  11872. $L_category = new L_category ();
  11873. Doo::loadClass ( 'XDeode' );
  11874. $XDeode = new XDeode ( 5 );
  11875. $year=date("Y");
  11876. $theDay=date("Y-m-d");
  11877. $dateArr = explode ( ':', $date );
  11878. $D1 = '';
  11879. $D2 = '';
  11880. $con = '';
  11881. if (! empty ( $date )) {
  11882. $D1 = $dateArr [0];
  11883. $D2 = $dateArr [1];
  11884. }
  11885. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11886. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11887. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11888. $con = ' and inputDate = "' . $D1 . '"';
  11889. else{
  11890. $con = ' and DATE_FORMAT(inputDate,"%Y")= "'.$year.'" ';
  11891. }
  11892. if ($cid != 'ALL') {
  11893. $cid = $XDeode->decode ( $cid );
  11894. $con .= ' and cid = "' . $cid . '"';
  11895. }
  11896. if ($accountType != 'ALL') {
  11897. if ($accountType == 'INVOICE') {
  11898. $con .= ' and accountType = 11';
  11899. } elseif ($accountType == 'PAYMENTS') {
  11900. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11901. if ($dailyExpenditureType != 'ALL') {
  11902. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11903. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11904. }
  11905. } elseif ($accountType == 'RECEIPT') {
  11906. if ($receiptType == 'ALL') {
  11907. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11908. } else {
  11909. $receiptType = $XDeode->decode ( $receiptType );
  11910. echo $receiptType;
  11911. if ($receiptType == 1) {
  11912. $con .= ' and (accountType = 1 or accountType=2)';
  11913. } else {
  11914. $con .= ' and accountType = ' . $receiptType;
  11915. }
  11916. }
  11917. }
  11918. }
  11919. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11920. $sum = 0;$thsDaySum=0;
  11921. foreach ( $incomeList as $key => $value ) {
  11922. $sum += $value ['accountPriceShow'];
  11923. if($theDay==date("Y-m-d",strtotime($value['inputDate']))){
  11924. $thsDaySum+=$value ['accountPriceShow'];
  11925. }
  11926. }
  11927. // print_r($incomeList);
  11928. // 获得办事和部门
  11929. $categoryList = $L_category->getCategory ();
  11930. $data ['accountType'] = $accountType;
  11931. $data ['cid'] = $cid;
  11932. $data ['categoryList'] = $categoryList;
  11933. $data ['sum'] = $sum;
  11934. $data ['incomeList'] = $incomeList;
  11935. $data ['inputDate'] = $date;
  11936. $data['year']=$year;
  11937. $data ['thsDay'] =$theDay;
  11938. $data ['thsDaySum'] =$thsDaySum;
  11939. $data ['memu'] = "receipt";
  11940. $data ['staff'] = $this->staff;
  11941. $data ['receiptMemu'] = 'wasteBook';
  11942. $data ['verifyId'] = $this->verifyId;
  11943. $data ['executeId'] = $this->executeId;
  11944. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11945. }
  11946. function ajaxGetWasteinvoiceReceivables() {
  11947. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11948. Doo::loadClass ( 'XDeode' );
  11949. $XDeode = new XDeode ( 5 );
  11950. $irid = $XDeode->decode ( $serial );
  11951. Doo::loadModel ( 'invoiceReceivables' );
  11952. $invoiceReceivables = new invoiceReceivables ();
  11953. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11954. echo json_encode ( array (
  11955. 'status' => 1,
  11956. 'detail' => $detail
  11957. ) );
  11958. }
  11959. function ajaxGetPaymentsByAid() {
  11960. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11961. Doo::loadModel ( "accountBook" );
  11962. $accountBook = new accountBook ();
  11963. $detail = $accountBook->getAccountBookByAid ( $serial );
  11964. echo json_encode ( array (
  11965. 'status' => 1,
  11966. 'detail' => $detail
  11967. ) );
  11968. }
  11969. function ajaxGetWasteInvoice() {
  11970. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11971. Doo::loadModel ( 'invoice' );
  11972. $invoice = new invoice ();
  11973. Doo::loadModel ( 'invoiceReceivables' );
  11974. $invoiceReceivables = new invoiceReceivables ();
  11975. $detail = $invoice->getInvoiceByIid ( $serial );
  11976. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11977. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11978. echo json_encode ( array (
  11979. 'status' => 1,
  11980. 'detail' => $detail
  11981. ) );
  11982. }
  11983. /**
  11984. */
  11985. function ajaxGetWasteReceipt() {
  11986. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11987. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11988. Doo::loadModel ( 'receipt' );
  11989. $receipt = new receipt ();
  11990. Doo::loadClass ( 'XDeode' );
  11991. $XDeode = new XDeode ( 5 );
  11992. $rid = $XDeode->decode ( $serial );
  11993. $accountType= $XDeode->decode ( $accountTypeKey );
  11994. // 获得个数据
  11995. $detail = $receipt->getReceiptByRid ( $rid );
  11996. // 初始化
  11997. $detail ['reviseDetail'] = array ();
  11998. if (! empty ( $value ['reviseDetail'] ))
  11999. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  12000. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  12001. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  12002. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  12003. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  12004. // 获得费用html
  12005. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  12006. // 获得费用审批人数据
  12007. $detail = $this->getReceiptApproverHtml ( $detail );
  12008. // 审批执行
  12009. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12010. <th class="taC" width="90">审批人</th>
  12011. <th class="taC">审批意见</th></tr>';
  12012. foreach ( $detail ['verifyList'] as $key => $value ) {
  12013. $html .= '<tr>
  12014. <td>' . $value [1] . '</td>
  12015. <td>' . $value ['opinion'] . '</td>
  12016. </tr>
  12017. ';
  12018. }
  12019. $html .= ' </tbody></table>';
  12020. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  12021. <th class="taC" width="90">执行人</th>
  12022. <th class="taC">执行意见</th></tr>';
  12023. foreach ( $detail ['executeCopy'] as $key => $value ) {
  12024. $html .= '<tr>
  12025. <td>' . $value [1] . '</td>
  12026. <td>' . $value ['opinion'] . '</td>
  12027. </tr>
  12028. ';
  12029. }
  12030. $html .= ' </tbody></table>';
  12031. if($accountType==1){
  12032. Doo::loadModel ( 'loanReceipt' );
  12033. $loanReceipt = new loanReceipt ();
  12034. $loanList = $loanReceipt->getOne ( array (
  12035. 'where' => 'rid=' . $detail ['loanRid'],
  12036. 'desc' => 'rid',
  12037. 'asArray' => true
  12038. ) );
  12039. $html .= '<table class="table table-bordered table-condensed">
  12040. <tr class="warning">
  12041. <td class="taR"><b>汇款金额</b></td>
  12042. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  12043. </tr>
  12044. </table>';
  12045. }else{
  12046. $html .= '<table class="table table-bordered table-condensed">
  12047. <tr class="warning">
  12048. <td class="taR"><b>汇款金额</b></td>
  12049. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  12050. </tr>
  12051. </table>';
  12052. }
  12053. // print_r($detail['verifyList']);
  12054. // header ( 'Content-Type:text/html;charset=utf-8' );
  12055. // echo $html;
  12056. echo json_encode ( array (
  12057. 'status' => 1,
  12058. 'html' => $html,
  12059. 'detail' => $detail
  12060. ) );
  12061. }
  12062. function getReceiptApproverHtml($detail = array()) {
  12063. Doo::loadModel ( 'loanReceipt' );
  12064. $loanReceipt = new loanReceipt ();
  12065. Doo::loadModel ( 'verify' );
  12066. $verify = new verify ();
  12067. Doo::loadModel ( 'staff' );
  12068. $staff = new staff ();
  12069. if (empty ( $detail ))
  12070. return array ();
  12071. $loanList = $loanReceipt->getOne ( array (
  12072. 'where' => 'rid=' . $detail ['loanRid'],
  12073. 'desc' => 'rid',
  12074. 'asArray' => true
  12075. ) );
  12076. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  12077. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  12078. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  12079. else
  12080. $verifyList ['staff'] = $detail ['verifyBreakup'];
  12081. } else
  12082. $verifyList = $verify->getOne ( array (
  12083. 'where' => 'vid=' . $detail ['verify'],
  12084. 'asArray' => true
  12085. ) );
  12086. $verifyList = json_decode ( $verifyList ['staff'], true );
  12087. Doo::loadModel ( 'role' );
  12088. $role = new role ();
  12089. $roleId = 0;
  12090. $flag = true;
  12091. $roleKey = 0;
  12092. $endStaffArray = array ();
  12093. $roleArrayCopy = array ();
  12094. foreach ( $verifyList as $k => $v ) {
  12095. // init verifyStaff
  12096. if ($v [1] == 'ROLE') {
  12097. if (! empty ( $verifyStaff )) {
  12098. $endStaffArray = end ( $verifyStaff );
  12099. }
  12100. $roleVerify = json_decode ( $v [3], true );
  12101. $roleKey = $k;
  12102. $roleArray = array ();
  12103. $rolename = $role->getOne ( array (
  12104. 'where' => 'rid=' . $v [0],
  12105. 'asArray' => true
  12106. ) );
  12107. foreach ( $roleVerify as $o => $p ) {
  12108. $staffID = explode ( '_', $p );
  12109. $staffInfo = $staff->getOne ( array (
  12110. 'where' => 'sid=' . $staffID [0],
  12111. 'asArray' => true
  12112. ) );
  12113. // print_r($staffID);
  12114. $exp = array (
  12115. 0 => $staffInfo ['sid'],
  12116. 1 => $staffID [1],
  12117. 2 => $staffInfo ['avatar'],
  12118. 'date' => '',
  12119. 'date' => '',
  12120. 'opinion' => '',
  12121. 'status' => '',
  12122. 'rolename' => $rolename ['name']
  12123. );
  12124. array_push ( $roleArray, $exp );
  12125. }
  12126. $roleArrayCopy [$v [0]] = $roleArray;
  12127. // $verifyList[$k]['roleArray']=$roleArray;
  12128. }
  12129. $verifyList [$k] ['date'] = "";
  12130. $verifyList [$k] ['opinion'] = "";
  12131. $verifyList [$k] ['status'] = "";
  12132. if (empty ( $verifyStaff )) {
  12133. $verifyList [$k] ['date'] = "";
  12134. $verifyList [$k] ['opinion'] = "";
  12135. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  12136. $verifyList [$k] ['status'] = 4;
  12137. $flag = false;
  12138. }
  12139. } else {
  12140. foreach ( $verifyStaff as $m => $u ) {
  12141. if ($v [0] == $m) {
  12142. $verifyList [$k] ['date'] = $u ['date'];
  12143. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12144. $verifyList [$k] ['status'] = $u ['status'];
  12145. $flag = false;
  12146. break;
  12147. }
  12148. }
  12149. $endStaffArray = end ( $verifyStaff );
  12150. }
  12151. }
  12152. $rolename ['name'] = '';
  12153. if (! empty ( $roleId )) {
  12154. Doo::loadModel ( 'role' );
  12155. $role = new role ();
  12156. $rolename = $role->getOne ( array (
  12157. 'where' => 'rid=' . $roleId,
  12158. 'asArray' => true
  12159. ) );
  12160. }
  12161. if (! empty ( $verifyStaff ))
  12162. $endStaffArray = end ( $verifyStaff );
  12163. $KOP = false;
  12164. foreach ( $roleArrayCopy as $P => $A ) {
  12165. foreach ( $A as $MKI => $AVL ) {
  12166. if (! empty ( $verifyStaff )) {
  12167. // &&$rolename['rid']==$endStaffArray['nextStaff']
  12168. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  12169. $button = 4;
  12170. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12171. }
  12172. foreach ( $verifyStaff as $m => $u ) {
  12173. $AVLFK = $AVL [0] . '_R';
  12174. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  12175. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  12176. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  12177. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  12178. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  12179. break;
  12180. }
  12181. }
  12182. } else {
  12183. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  12184. $button = 4;
  12185. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  12186. }
  12187. }
  12188. // $roleArray[$MKI]['rolename']=$rolename['name'];
  12189. $KOP = true;
  12190. }
  12191. }
  12192. foreach ( $roleArrayCopy as $k => $v ) {
  12193. foreach ( $verifyList as $m => $n ) {
  12194. if ($n [0] == $k) {
  12195. array_splice ( $verifyList, $m, 1, $v );
  12196. }
  12197. }
  12198. }
  12199. // 费用执行人相关数据
  12200. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  12201. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  12202. foreach ( $executeCopy as $k => $v ) {
  12203. $executeCopy [$k] ['date'] = '';
  12204. $executeCopy [$k] ['opinion'] = '';
  12205. $executeCopy [$k] ['status'] = '';
  12206. if (! empty ( $executeStaff ))
  12207. foreach ( $executeStaff as $m => $u ) {
  12208. if ($v [0] == $m) {
  12209. $executeCopy [$k] ['date'] = $u ['date'];
  12210. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  12211. $executeCopy [$k] ['status'] = $u ['status'];
  12212. break;
  12213. }
  12214. }
  12215. }
  12216. $detail ['executeCopy'] = $executeCopy;
  12217. $detail ['verifyList'] = $verifyList;
  12218. return $detail;
  12219. }
  12220. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  12221. if (empty ( $detail ))
  12222. return '';
  12223. $html = '';
  12224. if ($detail ['Rtype'] == 0) { // 报销单
  12225. $html .= '<table class="table table-bordered table-condensed">
  12226. <tbody>
  12227. <tr>
  12228. <th colspan="2" class="taC">日常相关费用</th>
  12229. </tr>';
  12230. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12231. $html .= '
  12232. <tr>
  12233. <th>' . $value ['name'] . '</th>
  12234. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12235. </tr>';
  12236. }
  12237. $html .= '
  12238. <tr>
  12239. <th class="taR">合计</th>
  12240. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12241. </tr>';
  12242. $html .= '<tr>
  12243. <th colspan="2" class="taC">差旅相关费用</th>
  12244. </tr>';
  12245. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12246. $html .= '
  12247. <tr>
  12248. <th>' . $value ['name'] . '</th>
  12249. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12250. </tr>';
  12251. }
  12252. $html .= '
  12253. <tr>
  12254. <th class="taR">合计</th>
  12255. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12256. </tr>';
  12257. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12258. $html .= '<tr>
  12259. <th colspan="2" class="taC">内部培训费用</th>
  12260. </tr>';
  12261. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12262. $html .= '
  12263. <tr>
  12264. <th>' . $value ['name'] . '</th>
  12265. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12266. </tr>';
  12267. }
  12268. $html .= '
  12269. <tr>
  12270. <th class="taR">合计</th>
  12271. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12272. </tr>';
  12273. }
  12274. $html .= '<tr>
  12275. <th colspan="2" class="taC">其他</th>
  12276. </tr>';
  12277. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12278. $html .= '
  12279. <tr>
  12280. <th>' . $value ['name'] . '</th>
  12281. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12282. </tr>';
  12283. }
  12284. $html .= '
  12285. <tr>
  12286. <th class="taR">合计</th>
  12287. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12288. </tr>';
  12289. $html .= '<tr>
  12290. <th colspan="2" class="taC">报销金额调整</th>
  12291. </tr>';
  12292. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12293. $html .= '
  12294. <tr>
  12295. <th>' . $value ['name'] . '</th>
  12296. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12297. </tr>';
  12298. }
  12299. $html .= '
  12300. <tr>
  12301. <th class="taR">合计</th>
  12302. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12303. </tr>';
  12304. $html .= '
  12305. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12306. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12307. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12308. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12309. <tr class="warning">
  12310. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12311. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12312. </tr>
  12313. </tbody>
  12314. </table>';
  12315. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  12316. $html .= '
  12317. <table class="table table-bordered table-condensed">
  12318. <tbody>
  12319. <tr>
  12320. <th colspan="2" class="taC">办事处相关费用</th>
  12321. </tr>';
  12322. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12323. $html .= '
  12324. <tr>
  12325. <th>' . $value ['name'] . '</th>
  12326. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12327. </tr>';
  12328. }
  12329. $html .= '
  12330. <tr>
  12331. <th class="taR">合计</th>
  12332. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12333. </tr>';
  12334. $html .= '
  12335. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12336. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12337. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12338. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12339. <tr class="warning">
  12340. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12341. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12342. </tr>
  12343. </tbody>
  12344. </table>';
  12345. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  12346. Doo::loadModel ( 'loanReceipt' );
  12347. $loanReceipt = new loanReceipt ();
  12348. $loanList = $loanReceipt->getOne ( array (
  12349. 'where' => 'rid=' . $detail ['loanRid'],
  12350. 'desc' => 'rid',
  12351. 'asArray' => true
  12352. ) );
  12353. // print_r($loanList);
  12354. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  12355. $html .= '<table class="table table-bordered table-condensed">
  12356. <tbody>
  12357. <tr>
  12358. <th colspan="2" class="taC">借款费用</th>
  12359. </tr>';
  12360. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12361. $html .= '<tr>
  12362. <th>' . $value ['name'] . '</th>
  12363. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12364. </tr>';
  12365. }
  12366. $html .= '<tr>
  12367. <th class="taC" colspan="2">产生费用所在办事处</th>
  12368. </tr>
  12369. <tr>
  12370. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12371. </tr>
  12372. <tr>
  12373. <th class="taC" colspan="2">费用说明</th>
  12374. </tr>
  12375. <tr>
  12376. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12377. </tr>
  12378. <tr class="warning">
  12379. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12380. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  12381. </tr>
  12382. </tbody>
  12383. </table>
  12384. ';
  12385. if ( $accountType==2) {
  12386. $balance=$detail ['sum']-$loanList ['sum'];
  12387. $balanceCN=$this->num_to_rmb($balance);
  12388. $html .= '<table class="table table-bordered table-condensed">
  12389. <tbody>
  12390. <tr>
  12391. <th colspan="2" class="taC">日常相关费用</th>
  12392. </tr>';
  12393. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  12394. $html .= '
  12395. <tr>
  12396. <th>' . $value ['name'] . '</th>
  12397. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12398. </tr>';
  12399. }
  12400. $html .= '
  12401. <tr>
  12402. <th class="taR">合计</th>
  12403. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  12404. </tr>';
  12405. $html .= '<tr>
  12406. <th colspan="2" class="taC">差旅相关费用</th>
  12407. </tr>';
  12408. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  12409. $html .= '
  12410. <tr>
  12411. <th>' . $value ['name'] . '</th>
  12412. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12413. </tr>';
  12414. }
  12415. $html .= '
  12416. <tr>
  12417. <th class="taR">合计</th>
  12418. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  12419. </tr>';
  12420. if(isset($detail ['accountItem'] ['内部培训费用'])){
  12421. $html .= '<tr>
  12422. <th colspan="2" class="taC">内部培训费用</th>
  12423. </tr>';
  12424. foreach ( $detail ['accountItem'] ['内部培训费用'] as $key => $value ) {
  12425. $html .= '
  12426. <tr>
  12427. <th>' . $value ['name'] . '</th>
  12428. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12429. </tr>';
  12430. }
  12431. $html .= '
  12432. <tr>
  12433. <th class="taR">合计</th>
  12434. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['inttrainSum'] . '</td>
  12435. </tr>';
  12436. }
  12437. $html .= '<tr>
  12438. <th colspan="2" class="taC">其他</th>
  12439. </tr>';
  12440. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  12441. $html .= '
  12442. <tr>
  12443. <th>' . $value ['name'] . '</th>
  12444. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12445. </tr>';
  12446. }
  12447. $html .= '
  12448. <tr>
  12449. <th class="taR">合计</th>
  12450. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12451. </tr>';
  12452. $html .= '<tr>
  12453. <th colspan="2" class="taC">报销金额调整</th>
  12454. </tr>';
  12455. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12456. $html .= '
  12457. <tr>
  12458. <th>' . $value ['name'] . '</th>
  12459. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12460. </tr>';
  12461. }
  12462. $html .= '
  12463. <tr>
  12464. <th class="taR">合计</th>
  12465. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12466. </tr>';
  12467. $html .= '
  12468. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12469. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12470. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12471. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12472. <tr class="warning">
  12473. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12474. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12475. </tr>
  12476. <tr class="success">
  12477. <td class="taR"><b>借款结余</b></td>
  12478. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12479. </tr>
  12480. </tbody>
  12481. </table>';
  12482. }
  12483. }
  12484. return $html;
  12485. }
  12486. /**
  12487. * 计算流水
  12488. */
  12489. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12490. $bakWaste ['bank'] = array (
  12491. 'CGBDeposit' => 0,
  12492. 'ICBCDeposit' => 0,
  12493. 'HUADeposit' => 0,
  12494. 'PersonalDeposit' => 0
  12495. );
  12496. $bakWaste ['financial'] = array (
  12497. 'current' => array (
  12498. 'CGBDeposit' => 0,
  12499. 'ICBCDeposit' => 0
  12500. ),
  12501. 'fixed' => array (
  12502. 'CGBDeposit' => 0,
  12503. 'ICBCDeposit' => 0
  12504. )
  12505. );
  12506. // 存款
  12507. foreach ( $waste ['bank'] as $key => $value ) {
  12508. // 收入
  12509. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12510. // 广发
  12511. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12512. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12513. }
  12514. // 工商
  12515. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12516. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12517. }
  12518. // 华润
  12519. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12520. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12521. }
  12522. // 个人
  12523. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12524. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12525. }
  12526. }
  12527. }
  12528. foreach ( $waste ['bank'] as $key => $value ) {
  12529. // 支出
  12530. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12531. // 广发
  12532. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12533. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12534. }
  12535. // 工商
  12536. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12537. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12538. }
  12539. // 华润
  12540. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12541. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12542. }
  12543. // 个人
  12544. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12545. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12546. }
  12547. }
  12548. }
  12549. // 活期
  12550. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12551. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12552. // 广发
  12553. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12554. $waste ['financial'] ['current'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12555. }
  12556. // 工商
  12557. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12558. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12559. }
  12560. // 个人
  12561. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12562. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12563. }
  12564. }
  12565. }
  12566. // print_r($inComeStatistics ['fixedStatistics']);
  12567. // 固期
  12568. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12569. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12570. // 广发
  12571. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12572. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12573. }
  12574. // 工商
  12575. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12576. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12577. }
  12578. // 个人
  12579. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12580. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12581. }
  12582. }
  12583. }
  12584. return $waste;
  12585. }
  12586. function lyt() {
  12587. Doo::loadModel ( "receiptDetail" );
  12588. $receiptDetail = new receiptDetail ();
  12589. $receiptCollectList = $receiptDetail->find ( array (
  12590. 'where' => 'status=1 ',
  12591. 'asArray' => true
  12592. ) );
  12593. foreach ( $receiptCollectList as $key => $value ) {
  12594. $receiptDetail = new receiptDetail ();
  12595. $receiptDetail->pastDate = $value ['date'];
  12596. $receiptDetail->update ( array (
  12597. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12598. ) );
  12599. }
  12600. }
  12601. function staffCollectMonthDetail() {
  12602. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  12603. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12604. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12605. if (! $year)
  12606. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12607. if (! $month)
  12608. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12609. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12610. if (! $nature){
  12611. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12612. }
  12613. Doo::loadModel ( 'staff' );
  12614. $staff = new staff ();
  12615. Doo::loadModel ( "receiptDetail" );
  12616. $receiptDetail = new receiptDetail ();
  12617. Doo::loadModel ( 'accountItem' );
  12618. $accountItem = new accountItem ();
  12619. Doo::loadModel ( 'statistics' );
  12620. $statistics = new statistics ();
  12621. Doo::loadModel ( "receiptAuthorityManage" );
  12622. $receiptAuthorityManage = new receiptAuthorityManage ();
  12623. $aiList=$accountItem->getAccountItem();
  12624. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12625. $cidList = array ();
  12626. foreach ( $imcStaff as $key => $value ) {
  12627. array_push ( $cidList, $value ['cid'] );
  12628. }
  12629. $cidString = implode ( ',', $cidList );
  12630. $naturecon='';
  12631. if ($nature=='ONJOB'){
  12632. $naturecon=' and (nature!=4 )';
  12633. }elseif($nature=='LEAVEJOB'){
  12634. $naturecon=' and (nature=4 )';
  12635. }else{
  12636. die ( 'illegal request--nature' );
  12637. }
  12638. $staffList = $staff->find ( array (
  12639. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12640. 'asArray' => true
  12641. ) );
  12642. $categoryList = $staff->find ( array (
  12643. 'select' => 'COUNT(*) as count,cid,category',
  12644. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12645. 'groupby' => 'cid',
  12646. 'asArray' => true
  12647. ) );
  12648. $list = array ();
  12649. foreach($aiList as $key=>$value){
  12650. foreach ($value as $v){
  12651. $subtotal[$key][$v['name']]=0;
  12652. }
  12653. }
  12654. foreach ( $categoryList as $vlu ) {
  12655. $s1 = 0;
  12656. $m1 = 0;
  12657. $subtotal[$this->AGENCY]['AGENCY']=$subtotal[$this->TRAVEL]['TRAVEL']=$subtotal[$this->INTTRAIN]['INTTRAIN']=$subtotal[$this->TRAIN]['TRAIN']=$subtotal[$this->OTHER]['OTHER']=0;
  12658. foreach ( $staffList as $value ) {
  12659. if ($vlu ['cid'] == $value ['cid']) {
  12660. // pastDate
  12661. $receiptCollectList = $receiptDetail->find ( array (
  12662. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12663. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12664. 'groupby' => 'item,Month(pastDate),itemCategory',
  12665. 'asArray' => true
  12666. ) );
  12667. if (! empty ( $receiptCollectList )) {
  12668. $receiptL = array (
  12669. '日常相关费用' => array (),
  12670. '差旅相关费用' => array (),
  12671. '内部培训费用' => array (),
  12672. '培训班费用' => array (),
  12673. '其他' => array ()
  12674. );
  12675. $html = "";
  12676. $psum = 0;
  12677. foreach ( $aiList[$this->AGENCY] as $va ) {
  12678. $falg = true;
  12679. foreach ( $receiptCollectList as $v ) {
  12680. if ($v ['itemCategory'] == '日常相关费用') {
  12681. if ($v ['item'] == $va['name']) {
  12682. $subtotal[$this->AGENCY][$va['name']]+=$v ['price'];
  12683. $psum += $v ['price'];
  12684. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12685. $falg = false;
  12686. break;
  12687. }
  12688. }
  12689. }
  12690. if ($falg)
  12691. $html .= '<td class="taR">-</td>';
  12692. }
  12693. $subtotal[$this->AGENCY]['AGENCY'] += $psum;
  12694. if (! empty ( $psum ))
  12695. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12696. else
  12697. $psum = '<td class="colGreen taR">-</td>';
  12698. $receiptL ['日常相关费用'] = $psum . $html;
  12699. /* ----------------------------------- */
  12700. $html = "";
  12701. $psum = 0;
  12702. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12703. $falg = true;
  12704. foreach ( $receiptCollectList as $v ) {
  12705. if ($v ['itemCategory'] == '差旅相关费用') {
  12706. if ($v ['item'] == $va['name']) {
  12707. $subtotal[$this->TRAVEL][$va['name']]+=$v ['price'];
  12708. $psum += $v ['price'];
  12709. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12710. $falg = false;
  12711. break;
  12712. }
  12713. }
  12714. }
  12715. if ($falg)
  12716. $html .= '<td class="taR">-</td>';
  12717. }
  12718. $subtotal[$this->TRAVEL]['TRAVEL'] += $psum;
  12719. if (! empty ( $psum ))
  12720. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12721. else
  12722. $psum = '<td class="colGreen taR">-</td>';
  12723. $receiptL ['差旅相关费用'] = $psum . $html;
  12724. /* ------------------------------------- */
  12725. $html = "";
  12726. $psum = 0;
  12727. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12728. $falg = true;
  12729. foreach ( $receiptCollectList as $v ) {
  12730. if ($v ['itemCategory'] == '内部培训费用') {
  12731. if ($v ['item'] == $va['name']) {
  12732. $subtotal[$this->INTTRAIN][$va['name']]+=$v ['price'];
  12733. $psum += $v ['price'];
  12734. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12735. $falg = false;
  12736. break;
  12737. }
  12738. }
  12739. }
  12740. if ($falg)
  12741. $html .= '<td class="taR">-</td>';
  12742. }
  12743. $subtotal[$this->INTTRAIN]['INTTRAIN'] += $psum;
  12744. if (! empty ( $psum ))
  12745. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12746. else
  12747. $psum = '<td class="colGreen taR">-</td>';
  12748. $receiptL ['内部培训费用'] = $psum . $html;
  12749. /* ----------------------------------- */
  12750. $html = "";
  12751. $psum = 0;
  12752. foreach ( $aiList[$this->TRAIN] as $va ) {
  12753. $falg = true;
  12754. foreach ( $receiptCollectList as $v ) {
  12755. if ($v ['itemCategory'] == '培训班费用') {
  12756. if ($v ['item'] == $va['name']) {
  12757. $subtotal[$this->TRAIN][$va['name']]+=$v ['price'];
  12758. $psum += $v ['price'];
  12759. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12760. $falg = false;
  12761. break;
  12762. }
  12763. }
  12764. }
  12765. if ($falg)
  12766. $html .= '<td class="taR">-</td>';
  12767. }
  12768. $subtotal[$this->TRAIN]['TRAIN'] += $psum;
  12769. if (! empty ( $psum ))
  12770. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12771. else
  12772. $psum = '<td class="colGreen taR">-</td>';
  12773. $receiptL ['培训班费用'] = $psum . $html;
  12774. /* ------------------------------------- */
  12775. $html = "";
  12776. $psum = 0;
  12777. foreach ( $aiList[$this->OTHER] as $va ) {
  12778. $falg = true;
  12779. foreach ( $receiptCollectList as $v ) {
  12780. if ($v ['itemCategory'] == '其他') {
  12781. if (trim ( $v ['item'] ) == $va['name']) {
  12782. $subtotal[$this->OTHER][$va['name']]+=$v ['price'];
  12783. $psum += $v ['price'];
  12784. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12785. $falg = false;
  12786. break;
  12787. }
  12788. }
  12789. }
  12790. if ($falg)
  12791. $html .= '<td class="taR">-</td>';
  12792. }
  12793. $subtotal[$this->OTHER]['OTHER'] += $psum;
  12794. if (! empty ( $psum ))
  12795. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12796. else
  12797. $psum = '<td class="colGreen taR">-</td>';
  12798. $receiptL ['其他'] = $psum . $html;
  12799. /* ------------------------------------- */
  12800. $html = "";
  12801. $psum = 0;
  12802. foreach ( $receiptCollectList as $v ) {
  12803. if ($v ['itemCategory'] == '报销金额调整') {
  12804. if (! empty ( $v ['price'] )) {
  12805. $psum += $v ['price'];
  12806. }
  12807. }
  12808. }
  12809. $s1 += $psum;
  12810. if (! empty ( $psum ))
  12811. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12812. else
  12813. $psum = '<td class="taR colOrange">-</td>';
  12814. $receiptL ['报销金额调整'] = $psum . $html;
  12815. } else {
  12816. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  12817. foreach ( $aiList[$this->AGENCY] as $va ) {
  12818. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  12819. }
  12820. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  12821. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12822. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  12823. }
  12824. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  12825. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12826. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  12827. }
  12828. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  12829. foreach ( $aiList[$this->TRAIN] as $va ) {
  12830. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  12831. }
  12832. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  12833. foreach ( $aiList[$this->OTHER] as $va ) {
  12834. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  12835. }
  12836. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12837. }
  12838. $monthStaffPrice = $receiptDetail->find ( array (
  12839. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12840. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12841. 'groupby' => 'Month(pastDate)',
  12842. 'asArray' => true
  12843. ) );
  12844. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12845. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12846. $m1 += $monthStaffPrice [0] ['price'];
  12847. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12848. } else
  12849. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12850. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12851. $list [$value ['username']] = $receiptL;
  12852. }
  12853. }
  12854. $receiptL [$this->AGENCY] ='<td class="colGreen taR">'.$subtotal[$this->AGENCY]['AGENCY'].'</td>';
  12855. foreach ( $aiList[$this->AGENCY] as $va ) {
  12856. $receiptL [$this->AGENCY] .='<td class="taR">' . $subtotal[$this->AGENCY][$va['name']] . '</td>';
  12857. $subtotal[$this->AGENCY][$va['name']]=0;
  12858. }
  12859. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">'.$subtotal[$this->TRAVEL]['TRAVEL'].'</td>';
  12860. foreach ( $aiList[$this->TRAVEL] as $va ) {
  12861. $receiptL [$this->TRAVEL] .='<td class="taR">' . $subtotal[$this->TRAVEL][$va['name']] . '</td>';
  12862. $subtotal[$this->TRAVEL][$va['name']]=0;
  12863. }
  12864. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">'.$subtotal[$this->INTTRAIN]['INTTRAIN'].'</td>';
  12865. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  12866. $receiptL [$this->INTTRAIN] .='<td class="taR">' . $subtotal[$this->INTTRAIN][$va['name']] . '</td>';
  12867. $subtotal[$this->INTTRAIN][$va['name']]=0;
  12868. }
  12869. $receiptL [$this->TRAIN] ='<td class="colGreen taR">'.$subtotal[$this->TRAIN]['TRAIN'].'</td>';
  12870. foreach ( $aiList[$this->TRAIN] as $va ) {
  12871. $receiptL [$this->TRAIN] .='<td class="taR">' . $subtotal[$this->TRAIN][$va['name']] . '</td>';
  12872. $subtotal[$this->TRAIN][$va['name']]=0;
  12873. }
  12874. $receiptL [$this->OTHER] ='<td class="colGreen taR">'.$subtotal[$this->OTHER]['OTHER'].'</td>';
  12875. foreach ( $aiList[$this->OTHER] as $va ) {
  12876. $receiptL [$this->OTHER] .='<td class="taR">' . $subtotal[$this->OTHER][$va['name']] . '</td>';
  12877. $subtotal[$this->OTHER][$va['name']]=0;
  12878. }
  12879. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12880. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12881. $receiptL ['usernameEn'] =false;
  12882. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12883. }
  12884. $data ['list'] = $list;
  12885. // print_r($list);
  12886. $receiptCollectList = $receiptDetail->find ( array (
  12887. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12888. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12889. 'groupby' => 'item,Month(pastDate),itemCategory',
  12890. 'asArray' => true
  12891. ) );
  12892. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  12893. // statistics html
  12894. $stList = $statistics->getOne ( array (
  12895. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12896. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12897. 'groupby' => 'Month(date)',
  12898. 'asArray' => true
  12899. ) );
  12900. if (empty ( $stList ))
  12901. $stList = array (
  12902. 'rePrice' => 0,
  12903. 'agPrice' => 0
  12904. );
  12905. $data ['stList'] = array (
  12906. 'rePrice' => $stList ['rePrice'],
  12907. 'agPrice' => $stList ['agPrice'],
  12908. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12909. );
  12910. $monthHtml = "";
  12911. for($i = 1; $i <= 12; $i ++) {
  12912. if ($i == $month)
  12913. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12914. else
  12915. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12916. }
  12917. $data ['monthHtml'] = $monthHtml;
  12918. $data ['year'] = $year;
  12919. $data ['month'] = $month;
  12920. $data ['nature'] = $nature;
  12921. $data ['aiList'] = $aiList;
  12922. $data ['memu'] = "receipt";
  12923. $data ['staff'] = $this->staff;
  12924. $data ['receiptMemu'] = 'companyCategoryCollect';
  12925. $data ['verifyId'] = $this->verifyId;
  12926. $data ['executeId'] = $this->executeId;
  12927. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12928. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12929. }
  12930. function staffCollectMonthDetail2() {
  12931. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12932. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12933. if (! $year)
  12934. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12935. if (! $month)
  12936. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12937. Doo::loadModel ( 'staff' );
  12938. $staff = new staff ();
  12939. Doo::loadModel ( "receiptDetail" );
  12940. $receiptDetail = new receiptDetail ();
  12941. Doo::loadModel ( 'accountItem' );
  12942. $accountItem = new accountItem ();
  12943. Doo::loadModel ( 'statistics' );
  12944. $statistics = new statistics ();
  12945. Doo::loadModel ( 'L_category' );
  12946. $lCategory = new L_category ();
  12947. $staffList = $staff->find ( array (
  12948. 'where' => 'username!="admin"',
  12949. 'asArray' => true
  12950. ) );
  12951. $categoryList = $staff->find ( array (
  12952. 'select' => 'COUNT(*) as count,cid,category',
  12953. 'where' => 'username !="admin"',
  12954. 'groupby' => 'cid',
  12955. 'asArray' => true
  12956. ) );
  12957. $list = array ();
  12958. foreach ( $categoryList as $vlu ) {
  12959. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12960. $r1 = 0;
  12961. $r2 = 0;
  12962. $r3 = 0;
  12963. $r4 = 0;
  12964. $r5 = 0;
  12965. $r6 = 0;
  12966. $r7 = 0;
  12967. $r8 = 0;
  12968. $r9 = 0;
  12969. $r10 = 0;
  12970. $r11 = 0;
  12971. $r12 = 0;
  12972. $r13 = 0;
  12973. $r14 = 0;
  12974. $r15 = 0;
  12975. $c1 = 0;
  12976. $c2 = 0;
  12977. $c3 = 0;
  12978. $c4 = 0;
  12979. $c5 = 0;
  12980. $c6 = 0;
  12981. $p1 = 0;
  12982. $p2 = 0;
  12983. $p3 = 0;
  12984. $p4 = 0;
  12985. $p5 = 0;
  12986. $p6 = 0;
  12987. $p7 = 0;
  12988. $p8 = 0;
  12989. $p9 = 0;
  12990. $t1 = 0;
  12991. $t2 = 0;
  12992. $t3 = 0;
  12993. $t4 = 0;
  12994. $t5 = 0;
  12995. $s1 = 0;
  12996. $m1 = 0;
  12997. foreach ( $staffList as $value ) {
  12998. if ($vlu ['cid'] == $value ['cid']) {
  12999. $receiptCollectList = $receiptDetail->find ( array (
  13000. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13001. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13002. 'groupby' => 'item,Month(date),itemCategory',
  13003. 'asArray' => true
  13004. ) );
  13005. if (! empty ( $receiptCollectList )) {
  13006. $receiptL = array (
  13007. '日常相关费用' => array (),
  13008. '差旅相关费用' => array (),
  13009. '培训班费用' => array (),
  13010. '其他' => array ()
  13011. );
  13012. $html = "";
  13013. $psum = 0;
  13014. $item = array (
  13015. '市内交通费',
  13016. '市内出租费',
  13017. '办事处房租',
  13018. '电话费',
  13019. '水费',
  13020. '电费',
  13021. '办公费用',
  13022. '邮寄费',
  13023. '其他费用',
  13024. '车辆费用',
  13025. '广告费',
  13026. '团队建设费',
  13027. '物业管理费',
  13028. '宽带费'
  13029. );
  13030. foreach ( $item as $va ) {
  13031. $falg = true;
  13032. foreach ( $receiptCollectList as $v ) {
  13033. if ($v ['itemCategory'] == '日常相关费用') {
  13034. if ($v ['item'] == $va) {
  13035. if ($va == '市内交通费')
  13036. $r1 += $v ['price'];
  13037. if ($va == '市内出租费')
  13038. $r2 += $v ['price'];
  13039. if ($va == '办事处房租')
  13040. $r3 += $v ['price'];
  13041. if ($va == '电话费')
  13042. $r4 += $v ['price'];
  13043. if ($va == '水费')
  13044. $r5 += $v ['price'];
  13045. if ($va == '电费')
  13046. $r6 += $v ['price'];
  13047. if ($va == '办公费用')
  13048. $r7 += $v ['price'];
  13049. if ($va == '邮寄费')
  13050. $r8 += $v ['price'];
  13051. if ($va == '其他费用')
  13052. $r9 += $v ['price'];
  13053. if ($va == '车辆费用')
  13054. $r10 += $v ['price'];
  13055. if ($va == '广告费')
  13056. $r11 += $v ['price'];
  13057. if ($va == '团队建设费')
  13058. $r13 += $v ['price'];
  13059. if ($va == '物业管理费')
  13060. $r14 += $v ['price'];
  13061. if ($va == '宽带费')
  13062. $r15 += $v ['price'];
  13063. $psum += $v ['price'];
  13064. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13065. $falg = false;
  13066. break;
  13067. }
  13068. }
  13069. }
  13070. if ($falg)
  13071. $html .= '<td class="taR">-</td>';
  13072. }
  13073. $r12 += $psum;
  13074. if (! empty ( $psum ))
  13075. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13076. else
  13077. $psum = '<td class="colGreen taR">-</td>';
  13078. $receiptL ['日常相关费用'] = $psum . $html;
  13079. /* ----------------------------------- */
  13080. $html = "";
  13081. $psum = 0;
  13082. $item = array (
  13083. '往来交通费',
  13084. '市内交通费',
  13085. '出差住宿费',
  13086. '出差补助',
  13087. '其他费用'
  13088. );
  13089. foreach ( $item as $va ) {
  13090. $falg = true;
  13091. foreach ( $receiptCollectList as $v ) {
  13092. if ($v ['itemCategory'] == '差旅相关费用') {
  13093. if ($v ['item'] == $va) {
  13094. if ($va == '往来交通费')
  13095. $c1 += $v ['price'];
  13096. if ($va == '市内交通费')
  13097. $c2 += $v ['price'];
  13098. if ($va == '出差住宿费')
  13099. $c3 += $v ['price'];
  13100. if ($va == '出差补助')
  13101. $c4 += $v ['price'];
  13102. if ($va == '其他费用')
  13103. $c5 += $v ['price'];
  13104. $psum += $v ['price'];
  13105. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13106. $falg = false;
  13107. break;
  13108. }
  13109. }
  13110. }
  13111. if ($falg)
  13112. $html .= '<td class="taR">-</td>';
  13113. }
  13114. $c6 += $psum;
  13115. if (! empty ( $psum ))
  13116. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13117. else
  13118. $psum = '<td class="colGreen taR">-</td>';
  13119. $receiptL ['差旅相关费用'] = $psum . $html;
  13120. /* ------------------------------------- */
  13121. $html = "";
  13122. $psum = 0;
  13123. $item = array (
  13124. '场租费',
  13125. '薪酬',
  13126. '住宿费',
  13127. '交通费',
  13128. '餐饮费',
  13129. '办公费',
  13130. '公关费',
  13131. '其他'
  13132. );
  13133. foreach ( $item as $va ) {
  13134. $falg = true;
  13135. foreach ( $receiptCollectList as $v ) {
  13136. if ($v ['itemCategory'] == '培训班费用') {
  13137. if ($v ['item'] == $va) {
  13138. if ($va == '场租费')
  13139. $p1 += $v ['price'];
  13140. if ($va == '薪酬')
  13141. $p2 += $v ['price'];
  13142. if ($va == '住宿费')
  13143. $p3 += $v ['price'];
  13144. if ($va == '交通费')
  13145. $p4 += $v ['price'];
  13146. if ($va == '餐饮费')
  13147. $p5 += $v ['price'];
  13148. if ($va == '办公费')
  13149. $p6 += $v ['price'];
  13150. if ($va == '公关费')
  13151. $p7 += $v ['price'];
  13152. if ($va == '其他')
  13153. $p8 += $v ['price'];
  13154. $psum += $v ['price'];
  13155. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13156. $falg = false;
  13157. break;
  13158. }
  13159. }
  13160. }
  13161. if ($falg)
  13162. $html .= '<td class="taR">-</td>';
  13163. }
  13164. $p9 += $psum;
  13165. if (! empty ( $psum ))
  13166. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13167. else
  13168. $psum = '<td class="colGreen taR">-</td>';
  13169. $receiptL ['培训班费用'] = $psum . $html;
  13170. /* ------------------------------------- */
  13171. $html = "";
  13172. $psum = 0;
  13173. $item = array (
  13174. '公关费',
  13175. '广告费',
  13176. '借款',
  13177. '可自加费用'
  13178. );
  13179. foreach ( $item as $va ) {
  13180. $falg = true;
  13181. foreach ( $receiptCollectList as $v ) {
  13182. if ($v ['itemCategory'] == '其他') {
  13183. if ($v ['item'] == $va) {
  13184. if ($va == '公关费')
  13185. $t1 += $v ['price'];
  13186. if ($va == '广告费')
  13187. $t2 += $v ['price'];
  13188. if ($va == '借款')
  13189. $t3 += $v ['price'];
  13190. if ($va == '可自加费用')
  13191. $t4 += $v ['price'];
  13192. $psum += $v ['price'];
  13193. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13194. $falg = false;
  13195. break;
  13196. }
  13197. }
  13198. }
  13199. if ($falg)
  13200. $html .= '<td class="taR">-</td>';
  13201. }
  13202. $t5 += $psum;
  13203. if (! empty ( $psum ))
  13204. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  13205. else
  13206. $psum = '<td class="colGreen taR">-</td>';
  13207. $receiptL ['其他'] = $psum . $html;
  13208. /* ------------------------------------- */
  13209. $html = "";
  13210. $psum = 0;
  13211. foreach ( $receiptCollectList as $v ) {
  13212. if ($v ['itemCategory'] == '报销金额调整') {
  13213. if (! empty ( $v ['price'] )) {
  13214. $psum += $v ['price'];
  13215. }
  13216. }
  13217. }
  13218. $s1 += $psum;
  13219. if (! empty ( $psum ))
  13220. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  13221. else
  13222. $psum = '<td class="taR colOrange">-</td>';
  13223. $receiptL ['报销金额调整'] = $psum . $html;
  13224. } else {
  13225. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13226. <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>';
  13227. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13228. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13229. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13230. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13231. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13232. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13233. }
  13234. $monthStaffPrice = $receiptDetail->find ( array (
  13235. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13236. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13237. 'asArray' => true
  13238. ) );
  13239. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  13240. $m1 += $monthStaffPrice [0] ['price'];
  13241. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13242. } else
  13243. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13244. $list [$value ['username']] = $receiptL;
  13245. }
  13246. }
  13247. $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>
  13248. <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>
  13249. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  13250. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  13251. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  13252. $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>
  13253. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  13254. $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>';
  13255. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  13256. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  13257. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  13258. }
  13259. $data ['list'] = $list;
  13260. $receiptCollectList = $receiptDetail->find ( array (
  13261. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  13262. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  13263. 'groupby' => 'item,Month(date),itemCategory',
  13264. 'asArray' => true
  13265. ) );
  13266. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13267. // statistics html
  13268. $stList = $statistics->getOne ( array (
  13269. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13270. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13271. 'groupby' => 'Month(date)',
  13272. 'asArray' => true
  13273. ) );
  13274. if (empty ( $stList ))
  13275. $stList = array (
  13276. 'rePrice' => 0,
  13277. 'agPrice' => 0
  13278. );
  13279. $data ['stList'] = array (
  13280. 'rePrice' => $stList ['rePrice'],
  13281. 'agPrice' => $stList ['agPrice'],
  13282. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13283. );
  13284. $monthHtml = "";
  13285. for($i = 1; $i <= 12; $i ++) {
  13286. if ($i == $month)
  13287. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13288. else
  13289. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13290. }
  13291. $data ['monthHtml'] = $monthHtml;
  13292. $data ['year'] = $year;
  13293. $data ['month'] = $month;
  13294. $data ['memu'] = "receipt";
  13295. $data ['staff'] = $this->staff;
  13296. $data ['receiptMemu'] = 'companyCategoryCollect';
  13297. $data ['verifyId'] = $this->verifyId;
  13298. $data ['executeId'] = $this->executeId;
  13299. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  13300. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13301. }
  13302. /**
  13303. * 用户报销单列表
  13304. */
  13305. function receiptStatisticsStaffDetail() {
  13306. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13307. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13308. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13309. Doo::loadModel ( "receipt" );
  13310. $receipt = new receipt ();
  13311. Doo::loadModel ( "receiptDetail" );
  13312. $receiptDetail = new receiptDetail ();
  13313. Doo::loadModel ( 'staff' );
  13314. $staff = new staff ();
  13315. Doo::loadModel ( 'accountItem' );
  13316. $accountItem = new accountItem ();
  13317. Doo::loadModel ( 'statistics' );
  13318. $statistics = new statistics ();
  13319. if (! empty ( $username )) {
  13320. $username = addslashes ( urldecode ( $username ) );
  13321. $staffDetail = $staff->getStaffByName ( $username );
  13322. if (empty ( $staffDetail ))
  13323. die ( 'illegal request' );
  13324. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13325. $itemList = $accountItem->getAccountItem ();
  13326. $itemHtml = '';
  13327. $categoryHtml = '';
  13328. $itemKeyList = array_keys ( $itemList );
  13329. $revisePrice = 0;
  13330. // 报销单内容详情
  13331. foreach ( $list as $key => $value ) {
  13332. $accountItemList = json_decode ( $value ['accountItem'], true );
  13333. $list [$key] ['accountItemList'] = $accountItemList;
  13334. $receiptItemHtml = '';
  13335. foreach ( $itemKeyList as $v ) {
  13336. if ($v == '日常相关费用')
  13337. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13338. elseif ($v == '差旅相关费用')
  13339. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13340. elseif ($v == '培训班费用')
  13341. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13342. elseif ($v == '内部培训费用'){
  13343. if (isset($accountItemList ['cSum'] ['inttrainSum'])){
  13344. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['inttrainSum'] . '</td>';
  13345. }else{
  13346. $receiptItemHtml .= '<td class="colGreen taR">0</td>';
  13347. }
  13348. }elseif ($v == '其他')
  13349. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13350. foreach ( $itemList [$v] as $ke => $va ) {
  13351. $falg = true;
  13352. if (! empty ( $accountItemList [$v] )) {
  13353. foreach ( $accountItemList [$v] as $ve ) {
  13354. if ($va ['name'] == $ve ['name']) {
  13355. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13356. $falg = false;
  13357. break;
  13358. }
  13359. }
  13360. }
  13361. if ($falg)
  13362. $receiptItemHtml .= '<td class="taR"></td>';
  13363. }
  13364. }
  13365. // 金额调整和费用查看
  13366. $revisePrice += $value ['revisePrice'];
  13367. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13368. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13369. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13370. }
  13371. // 报销单合计
  13372. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13373. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13374. $receiptTotalHtml = '';
  13375. // 报销单项目抬头
  13376. foreach ( $itemKeyList as $value ) {
  13377. $count = count ( $itemList [$value] ) + 1;
  13378. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13379. $categoryHtml .= '<th class="taC">合计</th>';
  13380. $sumfalg=true;
  13381. foreach ( $rtl as $rtlValue ) {
  13382. if ($rtlValue ['itemCategory'] == $value) {
  13383. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13384. $sumfalg=false;
  13385. break;
  13386. }
  13387. }
  13388. if ($sumfalg)
  13389. $receiptTotalHtml .= '<th></th>';
  13390. foreach ( $itemList [$value] as $k => $v ) {
  13391. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13392. // 合计
  13393. $falg = true;
  13394. foreach ( $receiptTotalList as $ve ) {
  13395. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13396. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13397. $falg = false;
  13398. break;
  13399. }
  13400. }
  13401. if ($falg)
  13402. $receiptTotalHtml .= '<th></th>';
  13403. }
  13404. }
  13405. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13406. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13407. if (empty ( $stList ))
  13408. $stList = array (
  13409. 'rePrice' => 0,
  13410. 'agPrice' => 0
  13411. );
  13412. $data ['stList'] = array (
  13413. 'rePrice' => $stList ['rePrice'],
  13414. 'agPrice' => $stList ['agPrice'],
  13415. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13416. );
  13417. $monthHtml = "";
  13418. for($i = 1; $i <= 12; $i ++) {
  13419. if ($i == $month)
  13420. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13421. else
  13422. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13423. }
  13424. $data ['username'] = urlencode ( $username );
  13425. $data ['usernameEN'] = $username;
  13426. $data ['monthHtml'] = $monthHtml;
  13427. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13428. $data ['list'] = $list;
  13429. $data ['categoryHtml'] = $categoryHtml;
  13430. $data ['itemHtml'] = $itemHtml;
  13431. $data ['itemList'] = $itemList;
  13432. $data ['year'] = $year;
  13433. $data ['month'] = $month;
  13434. $data ['memu'] = "receipt";
  13435. $data ['staff'] = $this->staff;
  13436. $data ['receiptMemu'] = 'companyCategoryCollect';
  13437. $data ['verifyId'] = $this->verifyId;
  13438. $data ['executeId'] = $this->executeId;
  13439. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13440. }
  13441. die ( 'illegal request' );
  13442. }
  13443. function companyMonthCollectDetail() {
  13444. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13445. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13446. if (! $year)
  13447. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13448. if (! $month)
  13449. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13450. Doo::loadModel ( 'staff' );
  13451. $staff = new staff ();
  13452. Doo::loadModel ( "receiptDetail" );
  13453. $receiptDetail = new receiptDetail ();
  13454. Doo::loadModel ( 'accountItem' );
  13455. $accountItem = new accountItem ();
  13456. Doo::loadModel ( 'statistics' );
  13457. $statistics = new statistics ();
  13458. Doo::loadModel ( 'L_category' );
  13459. $lCategory = new L_category ();
  13460. $staffList = $staff->find ( array (
  13461. 'where' => 'username!="admin"',
  13462. 'asArray' => true
  13463. ) );
  13464. $categoryList = $lCategory->find ( array (
  13465. 'asArray' => true
  13466. ) );
  13467. $aiList=$accountItem->getAccountItem();
  13468. $list = array ();
  13469. foreach ( $categoryList as $value ) {
  13470. $receiptCollectList = $receiptDetail->find ( array (
  13471. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13472. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13473. 'groupby' => 'item,Month(pastDate),itemCategory',
  13474. 'asArray' => true
  13475. ) );
  13476. if (! empty ( $receiptCollectList )) {
  13477. $receiptL = array (
  13478. '日常相关费用' => array (),
  13479. '差旅相关费用' => array (),
  13480. '内部培训费用' => array (),
  13481. '培训班费用' => array (),
  13482. '其他' => array ()
  13483. );
  13484. $html = "";
  13485. $psum = 0;
  13486. foreach ( $aiList[$this->AGENCY] as $va ) {
  13487. $falg = true;
  13488. foreach ( $receiptCollectList as $v ) {
  13489. if ($v ['itemCategory'] == $this->AGENCY) {
  13490. if ($v ['item'] == $va['name']) {
  13491. $psum += $v ['price'];
  13492. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13493. $falg = false;
  13494. break;
  13495. }
  13496. }
  13497. }
  13498. if ($falg)
  13499. $html .= '<td class="taR">-</td>';
  13500. }
  13501. if (! empty ( $psum ))
  13502. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13503. else
  13504. $psum = '<td class="colGreen taR">-</td>';
  13505. $receiptL [$this->AGENCY] = $psum . $html;
  13506. /* ----------------------------------- */
  13507. $html = "";
  13508. $psum = 0;
  13509. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13510. $falg = true;
  13511. foreach ( $receiptCollectList as $v ) {
  13512. if ($v ['itemCategory'] == $this->TRAVEL) {
  13513. if ($v ['item'] == $va['name']) {
  13514. $psum += $v ['price'];
  13515. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13516. $falg = false;
  13517. break;
  13518. }
  13519. }
  13520. }
  13521. if ($falg)
  13522. $html .= '<td class="taR">-</td>';
  13523. }
  13524. if (! empty ( $psum ))
  13525. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13526. else
  13527. $psum = '<td class="colGreen taR">-</td>';
  13528. $receiptL [$this->TRAVEL] = $psum . $html;
  13529. /* ------------------------------------- */
  13530. $html = "";
  13531. $psum = 0;
  13532. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13533. $falg = true;
  13534. foreach ( $receiptCollectList as $v ) {
  13535. if ($v ['itemCategory'] == $this->INTTRAIN) {
  13536. if ($v ['item'] == $va['name']) {
  13537. $psum += $v ['price'];
  13538. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13539. $falg = false;
  13540. break;
  13541. }
  13542. }
  13543. }
  13544. if ($falg)
  13545. $html .= '<td class="taR">-</td>';
  13546. }
  13547. if (! empty ( $psum ))
  13548. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13549. else
  13550. $psum = '<td class="colGreen taR">-</td>';
  13551. $receiptL [$this->INTTRAIN] = $psum . $html;
  13552. /* ------------------------------------- */
  13553. $html = "";
  13554. $psum = 0;
  13555. foreach ( $aiList[$this->TRAIN] as $va ) {
  13556. $falg = true;
  13557. foreach ( $receiptCollectList as $v ) {
  13558. if ($v ['itemCategory'] == $this->TRAIN) {
  13559. if ($v ['item'] == $va['name']) {
  13560. $psum += $v ['price'];
  13561. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13562. $falg = false;
  13563. break;
  13564. }
  13565. }
  13566. }
  13567. if ($falg)
  13568. $html .= '<td class="taR">-</td>';
  13569. }
  13570. if (! empty ( $psum ))
  13571. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13572. else
  13573. $psum = '<td class="colGreen taR">-</td>';
  13574. $receiptL [$this->TRAIN] = $psum . $html;
  13575. /* ------------------------------------- */
  13576. $html = "";
  13577. $psum = 0;
  13578. foreach ( $aiList[$this->OTHER] as $va ) {
  13579. $falg = true;
  13580. foreach ( $receiptCollectList as $v ) {
  13581. if ($v ['itemCategory'] == $this->OTHER) {
  13582. if ($v ['item'] == $va['name']) {
  13583. $psum += $v ['price'];
  13584. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13585. $falg = false;
  13586. break;
  13587. }
  13588. }
  13589. }
  13590. if ($falg)
  13591. $html .= '<td class="taR">-</td>';
  13592. }
  13593. if (! empty ( $psum ))
  13594. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13595. else
  13596. $psum = '<td class="colGreen taR">-</td>';
  13597. $receiptL [$this->OTHER] = $psum . $html;
  13598. /* ------------------------------------- */
  13599. $html = "";
  13600. $psum = 0;
  13601. foreach ( $receiptCollectList as $v ) {
  13602. if ($v ['itemCategory'] == '报销金额调整') {
  13603. if (! empty ( $v ['price'] ))
  13604. $psum += $v ['price'];
  13605. }
  13606. }
  13607. if (! empty ( $psum ))
  13608. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13609. else
  13610. $psum = '<td class="taR colOrange">-</td>';
  13611. $receiptL ['报销金额调整'] = $psum . $html;
  13612. } else {
  13613. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  13614. foreach ( $aiList[$this->AGENCY] as $va ) {
  13615. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  13616. }
  13617. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  13618. foreach ( $aiList[$this->TRAVEL] as $va ) {
  13619. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  13620. }
  13621. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  13622. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  13623. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  13624. }
  13625. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  13626. foreach ( $aiList[$this->TRAIN] as $va ) {
  13627. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  13628. }
  13629. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  13630. foreach ( $aiList[$this->OTHER] as $va ) {
  13631. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  13632. }
  13633. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13634. }
  13635. $monthStaffPrice = $receiptDetail->find ( array (
  13636. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13637. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13638. 'asArray' => true
  13639. ) );
  13640. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13641. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13642. else
  13643. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13644. $list [$value ['title']] = $receiptL;
  13645. }
  13646. $data ['list'] = $list;
  13647. $receiptCollectList = $receiptDetail->find ( array (
  13648. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13649. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13650. 'groupby' => 'item,Month(pastDate),itemCategory',
  13651. 'asArray' => true
  13652. ) );
  13653. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList,$aiList );
  13654. //print_r($data['monthPriceHtml']);
  13655. // foreach ($data['monthPriceHtml'] as $value){
  13656. // echo $value;
  13657. // }
  13658. // die;
  13659. // statistics html
  13660. $stList = $statistics->getOne ( array (
  13661. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13662. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13663. 'groupby' => 'Month(date)',
  13664. 'asArray' => true
  13665. ) );
  13666. if (empty ( $stList ))
  13667. $stList = array (
  13668. 'rePrice' => 0,
  13669. 'agPrice' => 0
  13670. );
  13671. $data ['stList'] = array (
  13672. 'rePrice' => $stList ['rePrice'],
  13673. 'agPrice' => $stList ['agPrice'],
  13674. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13675. );
  13676. $monthHtml = "";
  13677. for($i = 1; $i <= 12; $i ++) {
  13678. if ($i == $month)
  13679. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13680. else
  13681. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13682. }
  13683. $data ['aiList'] = $aiList;
  13684. $dateHtml = "";
  13685. $now = date ( "Y" );
  13686. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  13687. if ($YEARD <= $now) {
  13688. $dateHtml .= '<option ';
  13689. if ($year == $YEARD) {
  13690. $dateHtml .= 'selected ';
  13691. }
  13692. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  13693. }
  13694. }
  13695. $data ['dateHtml'] = $dateHtml;
  13696. $data ['monthHtml'] = $monthHtml;
  13697. $data ['year'] = $year;
  13698. $data ['month'] = $month;
  13699. $data ['memu'] = "receipt";
  13700. $data ['staff'] = $this->staff;
  13701. $data ['receiptMemu'] = 'companyCategoryCollect';
  13702. $data ['verifyId'] = $this->verifyId;
  13703. $data ['executeId'] = $this->executeId;
  13704. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13705. }
  13706. function staffCollectDetail() {
  13707. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13708. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13709. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13710. if (! $staffname) {
  13711. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13712. $staffname = urldecode ( $staffname );
  13713. }
  13714. Doo::loadModel ( 'staff' );
  13715. $staff = new staff ();
  13716. Doo::loadModel ( "receiptDetail" );
  13717. $receiptDetail = new receiptDetail ();
  13718. Doo::loadModel ( 'accountItem' );
  13719. $accountItem = new accountItem ();
  13720. Doo::loadModel ( 'statistics' );
  13721. $statistics = new statistics ();
  13722. Doo::loadModel ( 'L_category' );
  13723. $lCategory = new L_category ();
  13724. Doo::loadModel ( "receiptAuthorityManage" );
  13725. $receiptAuthorityManage = new receiptAuthorityManage ();
  13726. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13727. $cidList = array ();
  13728. foreach ( $imcStaff as $key => $value ) {
  13729. array_push ( $cidList, $value ['cid'] );
  13730. }
  13731. $cidString = implode ( ',', $cidList );
  13732. $staffList = $staff->find ( array (
  13733. 'where' => ' cid in (' . $cidString . ')',
  13734. 'asArray' => true
  13735. ) );
  13736. $stHtml = '';
  13737. $stTitle = "";
  13738. $staffId = 0;
  13739. $cid = 0;
  13740. $ocid = 0;
  13741. foreach ( $staffList as $value ) {
  13742. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13743. $stTitle = $value ['category'] . '-' . $value ['username'];
  13744. $staffId = $value ['sid'];
  13745. $cid = $value ['cid'];
  13746. $ocid = $value ['cid'];
  13747. if (! empty ( $value ['othercid'] ))
  13748. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13749. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13750. } elseif ($value ['username'] != 'admin')
  13751. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13752. }
  13753. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13754. 'where' => 'cid in(' . $cid . ')',
  13755. 'asArray' => true
  13756. ) );
  13757. if (empty ( $pcid ))
  13758. $pcid = $ocid;
  13759. $data ['ocid'] = $pcid;
  13760. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13761. $this->showCache ( $path );
  13762. //
  13763. $receiptCollectList = $receiptDetail->find ( array (
  13764. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13765. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13766. 'groupby' => 'item,Month(pastDate),itemCategory',
  13767. 'asArray' => true
  13768. ) );
  13769. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13770. // print_r($receiptCollectList);
  13771. $accountList = $accountItem->find ( array (
  13772. 'asArray' => true
  13773. ) );
  13774. // create CollectDetail HTML
  13775. $collectHtml = array ();
  13776. foreach ( $accountList as $key => $value ) {
  13777. $html = "";
  13778. $asum = 0;
  13779. for($i = 1; $i <= 12; $i ++) {
  13780. $falg = true;
  13781. foreach ( $receiptCollectList as $v ) {
  13782. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13783. if ($v ['item'] == '可自加费用') {
  13784. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13785. }
  13786. $asum += $v ['price'];
  13787. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13788. $falg = false;
  13789. break;
  13790. }
  13791. }
  13792. if ($falg)
  13793. $html .= '<td class="taR">-</td>';
  13794. }
  13795. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13796. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13797. }
  13798. $data ['collectHtml'] = $collectHtml;
  13799. // print_r($collectHtml);
  13800. // create Adjustment price html
  13801. $receiptCollectList = $receiptDetail->find ( array (
  13802. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13803. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13804. 'groupby' => 'itemCategory,Month(pastDate)',
  13805. 'asArray' => true
  13806. ) );
  13807. $adjustment = array ();
  13808. $collectArray = array (
  13809. '日常相关费用' => array (),
  13810. '差旅相关费用' => array (),
  13811. '培训班费用' => array (),
  13812. '内部培训费用'=>array(),
  13813. '其他' => array ()
  13814. );
  13815. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13816. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13817. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13818. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13819. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13820. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13821. $collectHtml = $this->collectHtml ( $receiptCollectList, '内部培训费用', 'b' );
  13822. array_push ( $collectArray ['内部培训费用'], $collectHtml );
  13823. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13824. array_push ( $collectArray ['其他'], $collectHtml );
  13825. $data ['collectArray'] = $collectArray;
  13826. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13827. array_push ( $adjustment, $collectHtml );
  13828. $data ['adjustment'] = $adjustment;
  13829. // total price html
  13830. $collectHtml = "";
  13831. $total = 0;
  13832. for($i = 1; $i <= 12; $i ++) {
  13833. $sumPrice = 0;
  13834. foreach ( $receiptCollectList as $key => $value ) {
  13835. if ($value ['month'] == $i) {
  13836. $sumPrice += $value ['price'];
  13837. }
  13838. }
  13839. if ($sumPrice == 0)
  13840. $collectHtml .= '<td class="taR">-</td>';
  13841. else
  13842. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13843. $total += $sumPrice;
  13844. }
  13845. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13846. // statistics html
  13847. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13848. if (empty ( $stList ))
  13849. $stList = array (
  13850. 'rePrice' => 0,
  13851. 'agPrice' => 0
  13852. );
  13853. $data ['stList'] = array (
  13854. 'rePrice' => $stList ['rePrice'],
  13855. 'agPrice' => $stList ['agPrice'],
  13856. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13857. );
  13858. $data ['totalPrice'] = $collectHtml;
  13859. $data ['totalYear'] = $total;
  13860. $data ['stHtml'] = $stHtml;
  13861. $data ['year'] = $year;
  13862. $data ['stTitle'] = $stTitle;
  13863. $data ['staffname'] = urlencode ( $staffname );
  13864. $data ['memu'] = "receipt";
  13865. $data ['staff'] = $this->staff;
  13866. $data ['receiptMemu'] = 'companyCategoryCollect';
  13867. $data ['verifyId'] = $this->verifyId;
  13868. $data ['executeId'] = $this->executeId;
  13869. if ($year < date ( "Y" )) {
  13870. Doo::loadModel ( 'receipt' );
  13871. $receipt = new receipt ();
  13872. $receiptList = $receipt->find ( array (
  13873. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13874. 'asArray' => true
  13875. ) );
  13876. if (empty ( $receiptList )) { // generated files
  13877. ob_start ();
  13878. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13879. $this->cacheFile ( $path );
  13880. die ();
  13881. }
  13882. }
  13883. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13884. }
  13885. function BUGFLAG() {
  13886. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13887. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13888. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13889. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13890. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13891. if (empty ( $status ))
  13892. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13893. $page_size = 12;
  13894. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13895. $vidList = array ();
  13896. $button = 0;
  13897. Doo::loadModel ( 'verify' );
  13898. $verify = new verify ();
  13899. Doo::loadModel ( 'receipt' );
  13900. $receipt = new receipt ();
  13901. Doo::loadModel ( 'staff' );
  13902. $staff = new staff ();
  13903. Doo::loadModel ( 'L_category' );
  13904. $Lcategory = new L_category ();
  13905. $dateCondition = " and Year(date) =" . $year;
  13906. if (! empty ( $month ))
  13907. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13908. $categoryList = $Lcategory->find ( array (
  13909. 'asArray' => true
  13910. ) );
  13911. $staffList = $staff->find ( array (
  13912. 'where' => 'cid=' . $cid,
  13913. 'asArray' => true
  13914. ) );
  13915. $cateCondition = "";
  13916. $staffCondition = "";
  13917. $approvalCondition = "";
  13918. if (! empty ( $cid ))
  13919. $cateCondition = ' and cid=' . $cid;
  13920. if (! empty ( $sid )) {
  13921. $staffCondition = ' and staff=' . $sid;
  13922. $cateCondition = "";
  13923. }
  13924. $approvalCondition = " and status=" . $status;
  13925. if ($status == 2) {
  13926. // 查找角色审批人
  13927. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13928. }
  13929. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13930. $approvalCondition = ' and status=2 ';
  13931. }
  13932. if ($status == 1) {
  13933. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13934. }
  13935. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13936. $pageinfo ['page'] = array (
  13937. 'previous' => ''
  13938. );
  13939. if ($status == 0) {
  13940. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13941. $receiptList = $receipt->find ( array (
  13942. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13943. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13944. 'desc' => 'rid',
  13945. 'asArray' => true
  13946. ) );
  13947. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13948. } else
  13949. $receiptList = $receipt->find ( array (
  13950. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13951. 'desc' => 'rid',
  13952. 'asArray' => true
  13953. ) );
  13954. $rLRes = $receipt->find ( array (
  13955. '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,
  13956. 'desc' => 'rid',
  13957. 'asArray' => true
  13958. ) );
  13959. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13960. // print_r($pageinfo);
  13961. $Locate = 0;
  13962. foreach ( $receiptList as $key => $value ) {
  13963. $receiptList [$key] ['Locate'] = $Locate;
  13964. $Locate ++;
  13965. $receiptList [$key] ['reviseDetail'] = array ();
  13966. if (! empty ( $value ['reviseDetail'] ))
  13967. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13968. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13969. $categoryDetil = $Lcategory->getOne ( array (
  13970. 'where' => 'cid=' . $value ['cid'],
  13971. 'asArray' => true
  13972. ) );
  13973. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13974. $verifyList = $verify->getOne ( array (
  13975. 'where' => 'vid=' . $value ['verify'],
  13976. 'asArray' => true
  13977. ) );
  13978. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13979. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13980. foreach ( $verifyList as $k => $v ) {
  13981. // init verifyStaff
  13982. $verifyList [$k] ['date'] = "";
  13983. $verifyList [$k] ['opinion'] = "";
  13984. $verifyList [$k] ['status'] = "";
  13985. if (empty ( $verifyStaff )) {
  13986. $verifyList [$k] ['date'] = "";
  13987. $verifyList [$k] ['opinion'] = "";
  13988. if ($v [0] == $this->staff [0] ['sid']) {
  13989. $verifyList [$k] ['status'] = 4;
  13990. $button = 4;
  13991. }
  13992. } else {
  13993. $flag = true;
  13994. foreach ( $verifyStaff as $m => $u ) {
  13995. if ($v [0] == $m) {
  13996. $verifyList [$k] ['date'] = $u ['date'];
  13997. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13998. $verifyList [$k] ['status'] = $u ['status'];
  13999. $flag = false;
  14000. break;
  14001. }
  14002. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  14003. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  14004. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  14005. }
  14006. if ($flag) { // 检测可编辑
  14007. if ($v [0] == $this->staff [0] ['sid']) {
  14008. $verifyList [$k] ['status'] = 4;
  14009. $button = 4;
  14010. }
  14011. }
  14012. }
  14013. }
  14014. $receiptList [$key] ['verifyList'] = $verifyList;
  14015. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  14016. 'where' => 'sid=' . $value ['staff'],
  14017. 'asArray' => true
  14018. ) );
  14019. $receiptList [$key] ['button'] = $button;
  14020. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  14021. }
  14022. // print_r($receiptList);die;
  14023. // $data['verifyDetail']=$verifyDetail;
  14024. $mothHtml = "";
  14025. for($i = 1; $i <= 12; $i ++) {
  14026. if ($month == $i)
  14027. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  14028. else
  14029. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  14030. }
  14031. $data ['mothHtml'] = $mothHtml;
  14032. $data ['page'] = $pageinfo;
  14033. $data ['receiptList'] = $receiptList;
  14034. $data ['receiptApprovalCount'] = count ( $rLRes );
  14035. $data ['status'] = $status;
  14036. $data ['year'] = $year;
  14037. $data ['categoryList'] = $categoryList;
  14038. $data ['staffList'] = $staffList;
  14039. $data ['cid'] = $cid;
  14040. $data ['sid'] = $sid;
  14041. // print_r($receiptList);
  14042. $data ['memu'] = "receipt";
  14043. $data ['staff'] = $this->staff;
  14044. $data ['receiptMemu'] = 'approvalExpenses';
  14045. $data ['verifyId'] = $this->verifyId;
  14046. $data ['executeId'] = $this->executeId;
  14047. $this->render ( "/admin/FALG", $data );
  14048. }
  14049. function ajaxGetReceiptOrder() {
  14050. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  14051. if (! empty ( $receiptOrder )) {
  14052. Doo::loadModel ( 'receipt' );
  14053. $receipt = new receipt ();
  14054. Doo::loadModel ( 'staff' );
  14055. $staff = new staff ();
  14056. $receiptInfo = $receipt->getOne ( array (
  14057. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  14058. 'asArray' => true
  14059. ) );
  14060. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  14061. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  14062. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  14063. </tbody></table><table class="table table table-bordered"><tbody>';
  14064. foreach ( $verifyStaff as $key => $value ) {
  14065. $staffInfo = $staff->getOne ( array (
  14066. 'select' => 'username',
  14067. 'where' => ' sid="' . $key . '"',
  14068. 'asArray' => true
  14069. ) );
  14070. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  14071. }
  14072. $html .= '</tbody></table></div></div>';
  14073. echo json_encode ( array (
  14074. 'status' => 1,
  14075. 'receiptHtml' => $html
  14076. ) );
  14077. die ();
  14078. }
  14079. echo json_encode ( array (
  14080. 'status' => 2,
  14081. 'receiptHtml' => ''
  14082. ) );
  14083. die ();
  14084. }
  14085. function _getMonthCollectDetail($receiptCollectList,$aiList) {
  14086. if (! empty ( $receiptCollectList )) {
  14087. $receiptL = array (
  14088. '日常相关费用' => array (),
  14089. '差旅相关费用' => array (),
  14090. '内部培训费用'=>array(),
  14091. '培训班费用' => array (),
  14092. '其他' => array ()
  14093. );
  14094. $html = "";
  14095. $psum = 0;
  14096. foreach ( $aiList[$this->AGENCY] as $value ) {
  14097. $falg = true;
  14098. foreach ( $receiptCollectList as $v ) {
  14099. if ($v ['itemCategory'] == '日常相关费用') {
  14100. if ($v ['item'] == $value['name']) {
  14101. $psum += $v ['price'];
  14102. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14103. $falg = false;
  14104. break;
  14105. }
  14106. }
  14107. }
  14108. if ($falg)
  14109. $html .= '<td class="taR">-</td>';
  14110. }
  14111. if (! empty ( $psum ))
  14112. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14113. else
  14114. $psum = '<td class="colGreen taR">-</td>';
  14115. $receiptL ['日常相关费用'] = $psum . $html;
  14116. /* ----------------------------------- */
  14117. $html = "";
  14118. $psum = 0;
  14119. foreach ( $aiList[$this->TRAVEL] as $value ) {
  14120. $falg = true;
  14121. foreach ( $receiptCollectList as $v ) {
  14122. if ($v ['itemCategory'] == '差旅相关费用') {
  14123. if ($v ['item'] == $value['name']) {
  14124. $psum += $v ['price'];
  14125. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14126. $falg = false;
  14127. break;
  14128. }
  14129. }
  14130. }
  14131. if ($falg)
  14132. $html .= '<td class="taR">-</td>';
  14133. }
  14134. if (! empty ( $psum ))
  14135. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14136. else
  14137. $psum = '<td class="colGreen taR">-</td>';
  14138. $receiptL ['差旅相关费用'] = $psum . $html;
  14139. /* ----------------------------------- */
  14140. $html = "";
  14141. $psum = 0;
  14142. foreach ( $aiList[$this->INTTRAIN] as $value ) {
  14143. $falg = true;
  14144. foreach ( $receiptCollectList as $v ) {
  14145. if ($v ['itemCategory'] == '内部培训费用') {
  14146. if ($v ['item'] == $value['name']) {
  14147. $psum += $v ['price'];
  14148. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14149. $falg = false;
  14150. break;
  14151. }
  14152. }
  14153. }
  14154. if ($falg)
  14155. $html .= '<td class="taR">-</td>';
  14156. }
  14157. if (! empty ( $psum ))
  14158. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14159. else
  14160. $psum = '<td class="colGreen taR">-</td>';
  14161. $receiptL ['内部培训费用'] = $psum . $html;
  14162. /* ------------------------------------- */
  14163. $html = "";
  14164. $psum = 0;
  14165. foreach ( $aiList[$this->TRAIN] as $value ) {
  14166. $falg = true;
  14167. foreach ( $receiptCollectList as $v ) {
  14168. if ($v ['itemCategory'] == '培训班费用') {
  14169. if ($v ['item'] == $value['name']) {
  14170. $psum += $v ['price'];
  14171. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14172. $falg = false;
  14173. break;
  14174. }
  14175. }
  14176. }
  14177. if ($falg)
  14178. $html .= '<td class="taR">-</td>';
  14179. }
  14180. if (! empty ( $psum ))
  14181. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14182. else
  14183. $psum = '<td class="colGreen taR">-</td>';
  14184. $receiptL ['培训班费用'] = $psum . $html;
  14185. /* ------------------------------------- */
  14186. $html = "";
  14187. $psum = 0;
  14188. foreach ( $aiList[$this->OTHER] as $value ) {
  14189. $falg = true;
  14190. foreach ( $receiptCollectList as $v ) {
  14191. if ($v ['itemCategory'] == '其他') {
  14192. if ($v ['item'] == $value['name']) {
  14193. $psum += $v ['price'];
  14194. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  14195. $falg = false;
  14196. break;
  14197. }
  14198. }
  14199. }
  14200. if ($falg)
  14201. $html .= '<td class="taR">-</td>';
  14202. }
  14203. if (! empty ( $psum ))
  14204. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  14205. else
  14206. $psum = '<td class="colGreen taR">-</td>';
  14207. $receiptL ['其他'] = $psum . $html;
  14208. /* ------------------------------------- */
  14209. $html = "";
  14210. $psum = 0;
  14211. foreach ( $receiptCollectList as $v ) {
  14212. if ($v ['itemCategory'] == '报销金额调整') {
  14213. if (! empty ( $v ['price'] ))
  14214. $psum += $v ['price'];
  14215. }
  14216. }
  14217. if (! empty ( $psum ))
  14218. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  14219. else
  14220. $psum = '<td class="taR colOrange">-</td>';
  14221. $receiptL ['报销金额调整'] = $psum . $html;
  14222. } else {
  14223. $receiptL [$this->AGENCY] ='<td class="colGreen taR">-</td>';
  14224. foreach ( $aiList[$this->AGENCY] as $va ) {
  14225. $receiptL [$this->AGENCY] .='<td class="taR">-</td>';
  14226. }
  14227. $receiptL [$this->TRAVEL] ='<td class="colGreen taR">-</td>';
  14228. foreach ( $aiList[$this->TRAVEL] as $va ) {
  14229. $receiptL [$this->TRAVEL] .='<td class="taR">-</td>';
  14230. }
  14231. $receiptL [$this->INTTRAIN] ='<td class="colGreen taR">-</td>';
  14232. foreach ( $aiList[$this->INTTRAIN] as $va ) {
  14233. $receiptL [$this->INTTRAIN] .='<td class="taR">-</td>';
  14234. }
  14235. $receiptL [$this->TRAIN] ='<td class="colGreen taR">-</td>';
  14236. foreach ( $aiList[$this->TRAIN] as $va ) {
  14237. $receiptL [$this->TRAIN] .='<td class="taR">-</td>';
  14238. }
  14239. $receiptL [$this->OTHER] ='<td class="colGreen taR">-</td>';
  14240. foreach ( $aiList[$this->OTHER] as $va ) {
  14241. $receiptL [$this->OTHER] .='<td class="taR">-</td>';
  14242. }
  14243. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  14244. }
  14245. return $receiptL;
  14246. }
  14247. function eMail() {
  14248. Doo::loadModel ( 'staff' );
  14249. $staff = new staff ();
  14250. Doo::loadModel ( 'receipt' );
  14251. $receipt = new receipt ();
  14252. Doo::loadModel ( 'L_category' );
  14253. $Lcategory = new L_category ();
  14254. Doo::loadModel ( "verify" );
  14255. $verify = new verify ();
  14256. $staffList = $staff->find ( array (
  14257. 'asArray' => true
  14258. ) );
  14259. foreach ( $staffList as $key => $value ) {
  14260. if ($value ['username'] != 'admin') {
  14261. // 提交人
  14262. $receiptList = $receipt->find ( array (
  14263. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  14264. 'asArray' => true
  14265. ) );
  14266. if (! empty ( $receiptList )) {
  14267. $html = '<br><div><style></style>
  14268. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  14269. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  14270. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14271. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  14272. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14273. <tbody><tr>
  14274. <td style="padding: 0 40px;" align="left">
  14275. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14276. </td></tr><tr>
  14277. <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>
  14278. </tr>
  14279. </tbody> </table></td> </tr> <tr><td>
  14280. <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">
  14281. <tbody> <tr><td>
  14282. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  14283. 以下报销单完成了审批,等着收款吧:</p>
  14284. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  14285. foreach ( $receiptList as $k => $v ) {
  14286. $category = $Lcategory->getOne ( array (
  14287. 'where' => 'cid=' . $v ['cid'],
  14288. 'asArray' => true
  14289. ) );
  14290. $html .= '
  14291. <tr>
  14292. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14293. <td align="left">
  14294. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  14295. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  14296. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  14297. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  14298. </tr>';
  14299. }
  14300. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  14301. <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>
  14302. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  14303. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  14304. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  14305. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14306. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  14307. $receipt = new receipt ();
  14308. $receipt->notice = 1;
  14309. $receipt->update ( array (
  14310. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14311. ) );
  14312. }
  14313. }
  14314. // 审批人
  14315. $verifyList = $verify->find ( array (
  14316. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14317. 'asArray' => true
  14318. ) );
  14319. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14320. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14321. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14322. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14323. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14324. <tbody><tr><td style="padding: 0 40px;" align="left">
  14325. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14326. </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>
  14327. </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">
  14328. <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>
  14329. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14330. foreach ( $verifyList as $k => $v ) {
  14331. $receiptList = $receipt->find ( array (
  14332. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14333. 'asArray' => true
  14334. ) );
  14335. foreach ( $receiptList as $r => $l ) {
  14336. $category = $Lcategory->getOne ( array (
  14337. 'where' => 'cid=' . $l ['cid'],
  14338. 'asArray' => true
  14339. ) );
  14340. $staffDetile = $staff->getOne ( array (
  14341. 'where' => 'sid=' . $l ['staff'],
  14342. 'asArray' => true
  14343. ) );
  14344. $html .= '
  14345. <tr>
  14346. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14347. <td align="left">
  14348. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14349. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14350. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14351. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14352. </tr>';
  14353. }
  14354. }
  14355. $html .= '
  14356. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14357. <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>
  14358. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14359. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14360. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14361. // $receipt=new receipt();
  14362. // $receipt->notice=1;
  14363. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14364. }
  14365. }
  14366. }
  14367. }
  14368. function setWXMsg($rid, $type) {
  14369. Doo::loadModel ( "receipt" );
  14370. $receipt = new receipt ();
  14371. $receiptDetail = $receipt->getOne ( array (
  14372. 'where' => 'rid=' . $rid,
  14373. 'asArray' => true
  14374. ) );
  14375. if (! empty ( $receiptDetail )) {
  14376. Doo::loadModel ( 'staff' );
  14377. $staff = new staff ();
  14378. $staffmsg = $staff->getOne ( array (
  14379. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14380. 'asArray' => TRUE
  14381. ) );
  14382. if (! empty ( $staffmsg ['wxid'] )) {
  14383. require_once (SITE_PATH . '/protected/class/client.php');
  14384. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14385. $user = $staffmsg ['wxid'];
  14386. $receiptName = '';
  14387. $msg = '';
  14388. switch ($receiptDetail ['Rtype']) {
  14389. case 0 :
  14390. $receiptName = '报销';
  14391. break;
  14392. case 1 :
  14393. $receiptName = '借款';
  14394. break;
  14395. case 2 :
  14396. $receiptName = '对公汇款';
  14397. break;
  14398. }
  14399. switch ($type) {
  14400. case 1 :
  14401. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14402. break;
  14403. case 2 :
  14404. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14405. break;
  14406. case 3 :
  14407. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14408. break;
  14409. }
  14410. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14411. }
  14412. }
  14413. }
  14414. // Email发送函数
  14415. function SMail($toemail, $subject, $contents) {
  14416. Doo::loadClass ( 'class.phpmailer' );
  14417. $mail = new PHPMailer ();
  14418. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14419. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14420. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14421. $mail->Password = "cDO1GjtY1seH"; // 密码
  14422. $mail->CharSet = "UTF8";
  14423. $mail->SMTPAuth = true;
  14424. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14425. $mail->Mailer = "smtp";
  14426. $mail->Port = 25;
  14427. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14428. $mail->MsgHTML ( $contents );
  14429. $mail->AddAddress ( $toemail );
  14430. $mail->CharSet = "UTF-8";
  14431. return $mail->Send ();
  14432. }
  14433. function h5Upload() {
  14434. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14435. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14436. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14437. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14438. header ( "HTTP/1.1 500 Internal Server Error" );
  14439. echo "POST exceeded maximum allowed size.";
  14440. exit ( 0 );
  14441. }
  14442. // Settings
  14443. $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)
  14444. $upload_name = "Filedata";
  14445. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14446. $extension_whitelist = array (
  14447. "doc",
  14448. "txt",
  14449. "jpg",
  14450. "gif",
  14451. "png"
  14452. ); // Allowed file extensions
  14453. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14454. // Other variables
  14455. $MAX_FILENAME_LENGTH = 260;
  14456. $file_name = "";
  14457. $file_extension = "";
  14458. $uploadErrors = array (
  14459. 0 => "文件上传成功",
  14460. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14461. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14462. 3 => "上传的文件仅为部分文件",
  14463. 4 => "没有文件上传",
  14464. 6 => "缺少临时文件夹"
  14465. );
  14466. $nk = time ();
  14467. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14468. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14469. echo "文件无法保存.";
  14470. exit ( 0 );
  14471. }
  14472. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14473. echo json_encode ( array (
  14474. 'filename' => $file_name,
  14475. 'id' => $nk
  14476. ) );
  14477. exit ( 0 );
  14478. }
  14479. function swfupload() {
  14480. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14481. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14482. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14483. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14484. header ( "HTTP/1.1 500 Internal Server Error" );
  14485. echo "POST exceeded maximum allowed size.";
  14486. exit ( 0 );
  14487. }
  14488. // Settings
  14489. $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)
  14490. $upload_name = "Filedata";
  14491. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14492. $extension_whitelist = array (
  14493. "doc",
  14494. "txt",
  14495. "jpg",
  14496. "gif",
  14497. "png"
  14498. ); // Allowed file extensions
  14499. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14500. // Other variables
  14501. $MAX_FILENAME_LENGTH = 260;
  14502. $file_name = "";
  14503. $file_extension = "";
  14504. $uploadErrors = array (
  14505. 0 => "文件上传成功",
  14506. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14507. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14508. 3 => "上传的文件仅为部分文件",
  14509. 4 => "没有文件上传",
  14510. 6 => "缺少临时文件夹"
  14511. );
  14512. $nk = time ();
  14513. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14514. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14515. echo "文件无法保存.";
  14516. exit ( 0 );
  14517. }
  14518. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14519. echo json_encode ( array (
  14520. 'filename' => $file_name,
  14521. 'id' => $nk
  14522. ) );
  14523. exit ( 0 );
  14524. }
  14525. function _GetFileEXT($filename) {
  14526. $pics = explode ( '.', $filename );
  14527. $num = count ( $pics );
  14528. return $pics [$num - 1];
  14529. }
  14530. /**
  14531. * 获取get或者POST值
  14532. * @param string $name 属性名称
  14533. * @return fixed 值
  14534. */
  14535. function get_args($name) {
  14536. if (isset ( $_GET [$name] )) {
  14537. if (is_array ( $_GET [$name] ))
  14538. return $_GET [$name];
  14539. else
  14540. return addslashes ( $_GET [$name] );
  14541. } elseif (isset ( $_POST [$name] )) {
  14542. if (is_array ( $_POST [$name] ))
  14543. return $_POST [$name];
  14544. else
  14545. return addslashes ( $_POST [$name] );
  14546. } else
  14547. return false;
  14548. }
  14549. function num_to_rmb($num) {
  14550. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14551. $c2 = "分角元拾佰仟万拾佰仟亿";
  14552. // 精确到分后面就不要了,所以只留两个小数位
  14553. $num = round ( $num, 2 );
  14554. // 将数字转化为整数
  14555. $num = $num * 100;
  14556. if (strlen ( $num ) > 10) {
  14557. return "金额太大,请检查";
  14558. }
  14559. $i = 0;
  14560. $c = "";
  14561. while ( 1 ) {
  14562. if ($i == 0) {
  14563. // 获取最后一位数字
  14564. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14565. } else {
  14566. $n = $num % 10;
  14567. }
  14568. // 每次将最后一位数字转化为中文
  14569. $p1 = substr ( $c1, 3 * $n, 3 );
  14570. $p2 = substr ( $c2, 3 * $i, 3 );
  14571. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14572. $c = $p1 . $p2 . $c;
  14573. } else {
  14574. $c = $p1 . $c;
  14575. }
  14576. $i = $i + 1;
  14577. // 去掉数字最后一位了
  14578. $num = $num / 10;
  14579. // echo $num.'</br>';
  14580. $num = ( int ) $num;
  14581. // $num =floor($num);
  14582. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14583. // echo $num.'</br>';
  14584. // 结束循环
  14585. if ($num == 0) {
  14586. break;
  14587. }
  14588. }
  14589. // echo $c.'</br>';
  14590. $j = 0;
  14591. $slen = strlen ( $c );
  14592. while ( $j < $slen ) {
  14593. // utf8一个汉字相当3个字符
  14594. $m = substr ( $c, $j, 6 );
  14595. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14596. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14597. $left = substr ( $c, 0, $j );
  14598. $right = substr ( $c, $j + 3 );
  14599. $c = $left . $right;
  14600. $j = $j - 3;
  14601. $slen = $slen - 3;
  14602. }
  14603. $j = $j + 3;
  14604. }
  14605. // 这个是为了去掉类似23.0中最后一个“零”字
  14606. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14607. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14608. }
  14609. // 将处理的汉字加上“整”
  14610. if (empty ( $c )) {
  14611. return "零元整";
  14612. } else {
  14613. return $c . "整";
  14614. }
  14615. }
  14616. /**
  14617. * 获得分页数据
  14618. * @param unknown_type $table
  14619. * @param unknown_type $condition
  14620. * @param unknown_type $on_page
  14621. * @param unknown_type $page_size
  14622. */
  14623. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14624. $page_c = "";
  14625. $page ['previous'] = $this->get_previous ( $on_page );
  14626. $page ['on_page'] = $on_page;
  14627. $total_count = $this->get_table_count ( $table, $condition );
  14628. $total = intval ( $total_count / $page_size );
  14629. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14630. $page ['total_data'] = $total_count;
  14631. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14632. $i = 1;
  14633. $page_max = 1;
  14634. $page_width = 3;
  14635. if ($on_page >= $page_width) {
  14636. $page_max = intval ( $on_page / $page_width ) + 1;
  14637. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14638. }
  14639. for(; $i <= $page ['total_page']; $i ++) {
  14640. if ($i == $on_page)
  14641. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14642. else
  14643. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14644. if ($i == ($page_width * $page_max))
  14645. break;
  14646. }
  14647. $page ['page'] = $page_c;
  14648. $page ['lower'] = (-- $on_page) * $page_size;
  14649. return $page;
  14650. }
  14651. /**
  14652. * 获取总页数
  14653. * @param unknown_type $table
  14654. * @param unknown_type $condition
  14655. */
  14656. public function get_table_count($table = "", $condition = "") {
  14657. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14658. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14659. // echo $sql;die;
  14660. $query = Doo::db ()->query ( $sql );
  14661. $result = $query->fetch ();
  14662. return $result ['count'];
  14663. }
  14664. /**
  14665. * 获取上一页
  14666. * @param unknown_type $on_page
  14667. */
  14668. function get_previous($on_page = 1) {
  14669. return $on_page != 0 ? $on_page - 1 : $on_page;
  14670. }
  14671. function _getReceiptTrainPayment($invoiceTrainId,$trainLoanRid,$rid){
  14672. // 收入合计
  14673. Doo::loadModel ( 'invoiceTraining' );
  14674. $invoiceTraining = new invoiceTraining ();
  14675. Doo::loadModel ( 'receipt' );
  14676. $receipt = new receipt ();
  14677. $invoiceTrainingDetail = array (
  14678. 'invoiceArriveAmount' => '0.00',
  14679. 'RIAmount' => '0.00',
  14680. 'invoiceTotalAmount' => '0.00',
  14681. 'invoiceCompanyAmount' => '0.00',
  14682. 'invoiceArriveAmountM'=>'0.00',
  14683. 'invoiceCompanyAmountM'=>'0.00'
  14684. );
  14685. if ($invoiceTrainId != 0) {
  14686. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $invoiceTrainId );
  14687. }
  14688. $invoiceArriveAmount = $RIAmount = 0;
  14689. if (! empty ( $invoiceTrainingDetail )) {
  14690. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  14691. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  14692. }
  14693. // 备用金
  14694. $sum = 0;
  14695. if (! empty ( $trainLoanRid )) {
  14696. $receiptLoanList = $receipt->getReceiptInRid ( $trainLoanRid );
  14697. foreach ($receiptLoanList as $key=>$value){
  14698. $sum+=$value['sum'];
  14699. }
  14700. // $receiptLoanDetailBak = $receipt->getReceiptByRid ( $trainLoanRid );
  14701. // $sum = $receiptLoanDetailBak ['sum'];
  14702. }
  14703. // 支出项金额详情
  14704. // 项目金额合计
  14705. Doo::loadModel ( 'RItem' );
  14706. $RItem = new RItem ();
  14707. Doo::loadModel ( 'accountItem' );
  14708. $accountItem = new accountItem ();
  14709. // 讲师获得
  14710. Doo::loadModel ( 'RILecturer' );
  14711. $RILecturer = new RILecturer ();
  14712. $RItemList = $RItem->getRItemByRid ($rid );
  14713. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  14714. // 支出项金额详情
  14715. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  14716. $categoryActualExpenditure = $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  14717. $payment = $sum + $RIAmount - $categoryActualExpenditure;
  14718. return $payment;
  14719. }
  14720. }
  14721. ?>