ReceiptController.php 530 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318
  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. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. public function beforeRun($resource, $action) {
  57. Doo::loadClass ( 'XDeode' );
  58. $XDeode = new XDeode ( 5 );
  59. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  60. // 单独判断公司汇总的访问权限
  61. if ($action == 'companyCategoryCollect') {
  62. Doo::loadModel ( "receiptAuthorityManage" );
  63. $invoiceCompanyManage = new receiptAuthorityManage ();
  64. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  65. if (empty ( $icm ))
  66. die ( 'illegal request' );
  67. }
  68. Doo::loadModel ( 'staff' );
  69. $staff = new staff ();
  70. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  71. $accessModular = 'RECEIPTS';
  72. if (empty ( $detail ['cldAccessArray'] ))
  73. die ( 'illegal request' );
  74. else {
  75. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  76. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  77. $flag = true;
  78. } else {
  79. $flag = false;
  80. }
  81. } else {
  82. die ( 'illegal request' );
  83. }
  84. }
  85. if (! $flag)
  86. die ( 'illegal request' );
  87. }
  88. function __construct() {
  89. if (isset ( $_COOKIE ["staff"] )) {
  90. if (! empty ( $_COOKIE ["staff"] )) {
  91. Doo::loadModel ( 'staff' );
  92. Doo::loadModel ( 'verify' );
  93. $verify = new verify ();
  94. $staff = new staff ();
  95. Doo::loadModel ( "execute" );
  96. $execute = new execute ();
  97. $verifyList = $verify->find ( array (
  98. 'select' => 'staff',
  99. 'asArray' => true
  100. ) );
  101. $list = array ();
  102. // 判断角色的审批权限
  103. foreach ( $verifyList as $key => $value ) {
  104. $ver = json_decode ( $value ['staff'] );
  105. foreach ( $ver as $k => $v ) {
  106. if ($v [1] == 'ROLE') {
  107. $roleList = json_decode ( $v [3] );
  108. foreach ( $roleList as $t => $g ) {
  109. $gList = explode ( "_", $g );
  110. array_push ( $list, $gList [0] );
  111. // print_r($list);
  112. }
  113. } else
  114. array_push ( $list, $v [0] );
  115. }
  116. }
  117. // 判断执行人的审批权限
  118. $executeList = $execute->find ( array (
  119. 'where'=>'mold !="日常收支"',
  120. 'select' => 'staff',
  121. 'asArray' => true
  122. ) );
  123. $list2 = array ();
  124. foreach ( $executeList as $key => $value ) {
  125. $ver = json_decode ( $value ['staff'] );
  126. foreach ( $ver as $k => $v ) {
  127. array_push ( $list2, $v [0] );
  128. }
  129. }
  130. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  131. $eidList = array_filter ( explode ( ",", $eidList ) );
  132. $this->executeId = array_merge ( $list2, $eidList );
  133. $this->verifyId = $list;
  134. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  135. // 检测用户信息完成
  136. $this->data ['isStaffCompleteMsg'] = false;
  137. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  138. if (! empty ( $detail ))
  139. $this->data ['isStaffCompleteMsg'] = true;
  140. return "/";
  141. }
  142. }
  143. Doo::loadCore ( 'uri/DooUriRouter' );
  144. $router = new DooUriRouter ();
  145. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  146. if ($routeRs ['1'] != "login") {
  147. header ( 'Content-Type:text/html;charset=utf-8' );
  148. @header ( "Location: /login" );
  149. }
  150. }
  151. function saeaBorad() {
  152. Doo::loadModel ( 'receipt' );
  153. $receipt = new receipt ();
  154. Doo::loadModel ( 'verify' );
  155. $verify = new verify ();
  156. Doo::loadModel ( 'L_category' );
  157. $lCategory = new L_category ();
  158. Doo::loadModel ( "role" );
  159. $role = new role ();
  160. Doo::loadModel ( "receiptLog" );
  161. $receiptLog = new receiptLog ();
  162. Doo::loadClass ( 'XDeode' );
  163. $XDeode = new XDeode ( 7 );
  164. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  165. $receiptDetail = $receipt->find ( array (
  166. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  167. 'desc' => 'rid',
  168. 'asArray' => true
  169. ) );
  170. foreach ( $receiptDetail as $key => $value ) {
  171. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  172. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  173. $veList = $verify->getOne ( array (
  174. 'where' => 'vid=' . $value ['verify'],
  175. 'asArray' => true
  176. ) );
  177. $v = json_decode ( $veList ['staff'] );
  178. array_push ( $v [0], $veList ['description'] );
  179. foreach ( $v as $n => $m ) {
  180. if ($m ['1'] == 'ROLE') {
  181. $roleInfo = $role->getOne ( array (
  182. 'where' => 'rid=' . $m [0],
  183. 'asArray' => true
  184. ) );
  185. $v [$n] [1] = $roleInfo ['name'];
  186. }
  187. }
  188. $receiptDetail [$key] ['staff'] = $v;
  189. $category = $lCategory->getOne ( array (
  190. 'where' => 'cid=' . $value ['cid'],
  191. 'asArray' => true
  192. ) );
  193. $receiptDetail [$key] ['category'] = $category ['title'];
  194. }
  195. // print_r($receiptLogList);
  196. Doo::loadModel ( 'RAssist' );
  197. $RAssist = new RAssist ();
  198. $receiptExtendList=$RAssist->getRAssistBySid($this->staff[0]['sid']);
  199. $data ['receiptExtendList'] = $receiptExtendList;
  200. $data ['receiptLogList'] = $receiptLogList;
  201. $data ['receiptDetail'] = $receiptDetail;
  202. $data ['memu'] = "receipt";
  203. $data ['staff'] = $this->staff;
  204. $data ['receiptMemu'] = 'saeaBorad';
  205. $data ['verifyId'] = $this->verifyId;
  206. $data ['executeId'] = $this->executeId;
  207. $this->render ( "/admin/saeaBorad", $data );
  208. }
  209. function remitAdd() {
  210. Doo::loadModel ( 'accountItem' );
  211. Doo::loadModel ( 'verify' );
  212. Doo::loadModel ( 'receipt' );
  213. Doo::loadModel ( 'L_category' );
  214. $lCategory = new L_category ();
  215. $receipt = new receipt ();
  216. $verify = new verify ();
  217. $accountItem = new accountItem ();
  218. Doo::loadModel ( "role" );
  219. $role = new role ();
  220. $acItem = $accountItem->find ( array (
  221. 'asArray' => true
  222. ) );
  223. $veList = $verify->getVerifyBySubordinate('REMIT');
  224. $data ['category'] = $lCategory->find ( array (
  225. 'asArray' => true
  226. ) );
  227. $data ['veList'] = $veList;
  228. $data ['acItem'] = $acItem;
  229. $data ['memu'] = "receipt";
  230. $data ['staff'] = $this->staff;
  231. $data ['receiptMemu'] = 'saeaBorad';
  232. $data ['verifyId'] = $this->verifyId;
  233. $data ['executeId'] = $this->executeId;
  234. $this->render ( "/admin/remitAdd", $data );
  235. }
  236. function remitAddDo() {
  237. $agency = $this->get_args ( 'agency' );
  238. $travel = $this->get_args ( 'travel' );
  239. $train = $this->get_args ( 'train' );
  240. $other = $this->get_args ( 'other' );
  241. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  242. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  243. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  244. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  245. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  246. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  247. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  248. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  249. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  250. // print_r($agency);die;
  251. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  252. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  253. header ( 'Content-Type:text/html;charset=utf-8' );
  254. die ( '请填写联行号' );
  255. }
  256. Doo::loadModel ( 'receipt' );
  257. Doo::loadModel ( 'receiptDetail' );
  258. Doo::loadModel ( 'accountItem' );
  259. $accountItem = new accountItem ();
  260. $receipt = new receipt ();
  261. Doo::loadModel ( 'enclosur' );
  262. Doo::loadModel ( 'execute' );
  263. $execute = new execute ();
  264. $executeDetail = $execute->getOne ( array (
  265. 'where' => 'mold="对公汇款执行人"',
  266. 'asArray' => true
  267. ) );
  268. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  269. $aItem = $accountItem->find ( array (
  270. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  271. 'asArray' => true
  272. ) );
  273. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  274. $ag = $tr = $ta = $ot = 0;
  275. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  276. foreach ( $aItem as $key => $value ) {
  277. if ($value ['category'] == $this->AGENCY) {
  278. if (isset ( $agency [$ag] )) {
  279. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  280. array_push ( $accountJson [$this->AGENCY], array (
  281. 'aid' => $value ['aid'],
  282. 'name' => $value ['name'],
  283. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  284. ) );
  285. $sum += $agency [$ag];
  286. $agencySum += $agency [$ag];
  287. }
  288. }
  289. $ag ++;
  290. }
  291. }
  292. $accountJson ['cSum'] = array (
  293. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  294. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  295. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  296. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  297. );
  298. // 报销单
  299. $receipt->accountItem = json_encode ( $accountJson );
  300. $receipt->staff = $this->staff [0] ['sid'];
  301. $receipt->sum = number_format ( $sum, 2, '.', '' );
  302. $receipt->date = date ( "Y-m-d" );
  303. $receipt->cid = $cid;
  304. $receipt->status = 5;
  305. $receipt->Rtype = 2;
  306. // 修改审批流程加入角色
  307. $receipt->verify = $verify;
  308. $receipt->executeCopy = $executeDetail ['staff'];
  309. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  310. $order = array (
  311. "\r\n",
  312. "\n",
  313. "\r"
  314. );
  315. $replace = '<br/>';
  316. $explanation = str_replace ( $order, $replace, $explanation );
  317. $receipt->explanation = $explanation;
  318. $receipt->remittanceName = $remittanceName;
  319. $receipt->bankName = $bankName;
  320. $receipt->bankNumber = $bankNumber;
  321. $receipt->remittanceBankType = $remittanceBankType;
  322. if ($remittanceBankType == 1)
  323. $receipt->coupletNumber = $coupletNumber;
  324. $rid = $receipt->insert ();
  325. // 附件
  326. if (! empty ( $enclosurName )) {
  327. $enclosurArray = explode ( '-', $enclosurName );
  328. foreach ( $enclosurArray as $value ) {
  329. $enclosur = new enclosur ();
  330. $enclosur->name = $value;
  331. $enclosur->rid = $rid;
  332. $enclosur->insert ();
  333. }
  334. // print_r($enclosurArray);die;
  335. }
  336. // 报销详情
  337. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  338. $receiptDetail = new receiptDetail ();
  339. $receiptDetail->staff = $this->staff [0] ['sid'];
  340. $receiptDetail->item = $value ['name'];
  341. $receiptDetail->itemCategory = $this->AGENCY;
  342. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  343. $receiptDetail->date = date ( "Y-m-d" );
  344. $receiptDetail->cid = $cid;
  345. $receiptDetail->rid = $rid;
  346. $receiptDetail->status = 4;
  347. $receiptDetail->insert ();
  348. }
  349. return "/saeaBorad";
  350. } else
  351. die ( 'illegal request' );
  352. }
  353. function remitEdit() {
  354. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  355. Doo::loadClass ( 'XDeode' );
  356. $XDeode = new XDeode ( 7 );
  357. $rid = $XDeode->decode ( $ridKey );
  358. if (! is_numeric ( $rid ))
  359. die ( 'illegal request' );
  360. Doo::loadModel ( 'accountItem' );
  361. Doo::loadModel ( 'verify' );
  362. Doo::loadModel ( 'receipt' );
  363. $receipt = new receipt ();
  364. $verify = new verify ();
  365. $accountItem = new accountItem ();
  366. Doo::loadModel ( 'L_category' );
  367. $lCategory = new L_category ();
  368. Doo::loadModel ( "role" );
  369. $role = new role ();
  370. Doo::loadModel ( 'enclosur' );
  371. $enclosur = new enclosur ();
  372. $receiptDetail = $receipt->getOne ( array (
  373. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  374. 'asArray' => true
  375. ) );
  376. if (empty ( $receiptDetail ))
  377. return "/saeaCreate";
  378. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  379. $acItem = $accountItem->find ( array (
  380. 'asArray' => true
  381. ) );
  382. $veList = $verify->getVerifyBySubordinate('REMIT');
  383. // 配置编辑信息
  384. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  385. foreach ( $acItem as $key => $value ) {
  386. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  387. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  388. $acItem [$key] ['price'] = $v ['price'];
  389. }
  390. }
  391. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  392. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  393. $acItem [$key] ['price'] = $v ['price'];
  394. }
  395. }
  396. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  397. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  398. $acItem [$key] ['price'] = $v ['price'];
  399. }
  400. }
  401. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  402. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  403. $acItem [$key] ['price'] = $v ['price'];
  404. }
  405. }
  406. }
  407. $data ['category'] = $lCategory->find ( array (
  408. 'asArray' => true
  409. ) );
  410. $data ['enclosurList'] = $enclosurList;
  411. $data ['cSum'] = $accountItemList ['cSum'];
  412. $data ['sum'] = $receiptDetail ['sum'];
  413. $data ['receiptDetail'] = $receiptDetail;
  414. $data ['veList'] = $veList;
  415. $data ['acItem'] = $acItem;
  416. $data ['memu'] = "receipt";
  417. $data ['staff'] = $this->staff;
  418. $data ['receiptMemu'] = 'saeaBorad';
  419. $data ['verify'] = $receiptDetail ['verify'];
  420. $data ['verifyId'] = $this->verifyId;
  421. $data ['executeId'] = $this->executeId;
  422. $data ['rid'] = $rid;
  423. $data ['ridKey'] = $ridKey;
  424. $this->render ( "/admin/remitEdit", $data );
  425. }
  426. function remitEdiDo() {
  427. $agency = $this->get_args ( 'agency' );
  428. $travel = $this->get_args ( 'travel' );
  429. $train = $this->get_args ( 'train' );
  430. $other = $this->get_args ( 'other' );
  431. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  432. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  433. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  434. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  435. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  436. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  437. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  438. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  439. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  440. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  441. Doo::loadClass ( 'XDeode' );
  442. $XDeode = new XDeode ( 7 );
  443. $rid = $XDeode->decode ( $ridKey );
  444. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  445. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  446. header ( 'Content-Type:text/html;charset=utf-8' );
  447. die ( '请填写联行号' );
  448. }
  449. Doo::loadModel ( 'receipt' );
  450. Doo::loadModel ( 'receiptDetail' );
  451. Doo::loadModel ( 'accountItem' );
  452. $accountItem = new accountItem ();
  453. $receipt = new receipt ();
  454. Doo::loadModel ( 'enclosur' );
  455. $enclosur = new enclosur ();
  456. Doo::loadModel ( 'execute' );
  457. $execute = new execute ();
  458. $executeDetail = $execute->getOne ( array (
  459. 'where' => 'mold="对公汇款执行人"',
  460. 'asArray' => true
  461. ) );
  462. $receiptDetail = $receipt->getOne ( array (
  463. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  464. 'asArray' => true
  465. ) );
  466. if (empty ( $receiptDetail ))
  467. return "/saeaBorad";
  468. $aItem = $accountItem->find ( array (
  469. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  470. 'asArray' => true
  471. ) );
  472. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  473. $ag = $tr = $ta = $ot = 0;
  474. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  475. foreach ( $aItem as $key => $value ) {
  476. if ($value ['category'] == $this->AGENCY) {
  477. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  478. array_push ( $accountJson [$this->AGENCY], array (
  479. 'aid' => $value ['aid'],
  480. 'name' => $value ['name'],
  481. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  482. ) );
  483. $sum += $agency [$ag];
  484. $agencySum += $agency [$ag];
  485. }
  486. $ag ++;
  487. }
  488. }
  489. $accountJson ['cSum'] = array (
  490. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  491. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  492. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  493. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  494. );
  495. // 报销单
  496. $rid = $receipt->rid = $receiptDetail ['rid'];
  497. $receipt->accountItem = json_encode ( $accountJson );
  498. $receipt->staff = $this->staff [0] ['sid'];
  499. $receipt->sum = number_format ( $sum, 2, '.', '' );
  500. $receipt->date = date ( "Y-m-d" );
  501. $receipt->cid = $cid;
  502. if ($receiptDetail ['Rtype'] == 1)
  503. $receipt->status = 7;
  504. else
  505. $receipt->status = 5;
  506. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  507. $receipt->verify = $verify;
  508. $receipt->executeCopy = $executeDetail ['staff'];
  509. $order = array (
  510. "\r\n",
  511. "\n",
  512. "\r"
  513. );
  514. $replace = '<br/>';
  515. $explanation = str_replace ( $order, $replace, $explanation );
  516. $receipt->explanation = $explanation;
  517. $receipt->remittanceName = $remittanceName;
  518. $receipt->bankName = $bankName;
  519. $receipt->bankNumber = $bankNumber;
  520. $receipt->remittanceBankType = $remittanceBankType;
  521. if ($remittanceBankType == 1)
  522. $receipt->coupletNumber = $coupletNumber;
  523. $receipt->update ();
  524. $receiptDetail = new receiptDetail ();
  525. $receiptDetail->delete ( array (
  526. 'where' => 'rid=' . $rid
  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. // 附件
  542. if (! empty ( $enclosurName )) {
  543. $enclosurArray = explode ( '-', $enclosurName );
  544. foreach ( $enclosurArray as $value ) {
  545. $enclosur = new enclosur ();
  546. $enclosur->name = $value;
  547. $enclosur->rid = $rid;
  548. $enclosur->insert ();
  549. }
  550. }
  551. }
  552. return "/saeaBorad";
  553. }
  554. function remitApproval() {
  555. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  556. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  557. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  558. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  559. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  560. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  561. if (empty ( $status ))
  562. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  563. $vidList = array ();
  564. $button = 0;
  565. Doo::loadModel ( 'verify' );
  566. Doo::loadModel ( 'receipt' );
  567. Doo::loadModel ( 'staff' );
  568. $staff = new staff ();
  569. $receipt = new receipt ();
  570. $verify = new verify ();
  571. Doo::loadModel ( 'L_category' );
  572. $Lcategory = new L_category ();
  573. Doo::loadModel ( 'enclosur' );
  574. $enclosur = new enclosur ();
  575. // user verify ID
  576. $verifyDetail = $verify->find ( array (
  577. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  578. 'asArray' => true
  579. ) );
  580. foreach ( $verifyDetail as $key => $value ) {
  581. array_push ( $vidList, $value ['vid'] );
  582. }
  583. $vid = implode ( ",", $vidList );
  584. if (empty ( $verifyDetail ))
  585. $vid = 0;
  586. $categoryList = $Lcategory->find ( array (
  587. 'asArray' => true
  588. ) );
  589. $staffList = $staff->find ( array (
  590. 'where' => 'cid=' . $cid,
  591. 'asArray' => true
  592. ) );
  593. $ap = "";
  594. if ($status == 4) {
  595. $ap = 4;
  596. $status = 2;
  597. }
  598. // get Receipt By verifyID status 2
  599. $receiptList = $receipt->find ( array (
  600. 'where' => 'rid =' . $rid . ' and status=2',
  601. 'desc' => 'rid',
  602. 'asArray' => true
  603. ) );
  604. if (empty ( $receiptList )) {
  605. die ( 'illegal request' );
  606. }
  607. $Locate = 0;
  608. $roleId = 0;
  609. if ($ap == 4)
  610. $status = 4;
  611. foreach ( $receiptList as $key => $value ) {
  612. $receiptList [$key] ['Locate'] = $Locate;
  613. $Locate ++;
  614. $receiptList [$key] ['reviseDetail'] = array ();
  615. if (! empty ( $value ['reviseDetail'] ))
  616. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  617. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  618. $categoryDetil = $Lcategory->getOne ( array (
  619. 'where' => 'cid=' . $value ['cid'],
  620. 'asArray' => true
  621. ) );
  622. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  623. // 检测编辑状态
  624. $verifyList = $verify->getOne ( array (
  625. 'where' => 'vid=' . $value ['verify'],
  626. 'asArray' => true
  627. ) );
  628. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  629. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  630. Doo::loadModel ( 'role' );
  631. $role = new role ();
  632. // print_r($verifyList);
  633. $flag = true;
  634. $roleKey = 0;
  635. $endStaffArray = array ();
  636. $roleArrayCopy = array ();
  637. foreach ( $verifyList as $k => $v ) {
  638. // init verifyStaff
  639. if ($v [1] == 'ROLE') {
  640. if (! empty ( $verifyStaff )) {
  641. $endStaffArray = end ( $verifyStaff );
  642. if ($v [0] == $endStaffArray ['nextStaff']) {
  643. $roleId = $v [0];
  644. }
  645. }
  646. $roleVerify = json_decode ( $v [3], true );
  647. $roleKey = $k;
  648. $roleArray = array ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $v [0],
  651. 'asArray' => true
  652. ) );
  653. foreach ( $roleVerify as $o => $p ) {
  654. $staffID = explode ( '_', $p );
  655. $staffInfo = $staff->getOne ( array (
  656. 'where' => 'sid=' . $staffID [0],
  657. 'asArray' => true
  658. ) );
  659. // print_r($staffID);
  660. $exp = array (
  661. 0 => $staffInfo ['sid'],
  662. 1 => $staffID [1],
  663. 2 => $staffInfo ['avatar'],
  664. 'date' => '',
  665. 'date' => '',
  666. 'opinion' => '',
  667. 'status' => '',
  668. 'rolename' => $rolename ['name']
  669. );
  670. array_push ( $roleArray, $exp );
  671. }
  672. $roleArrayCopy [$v [0]] = $roleArray;
  673. // $verifyList[$k]['roleArray']=$roleArray;
  674. }
  675. // print_r($roleArray);
  676. $verifyList [$k] ['date'] = "";
  677. $verifyList [$k] ['opinion'] = "";
  678. $verifyList [$k] ['status'] = "";
  679. if (empty ( $verifyStaff )) {
  680. $verifyList [$k] ['date'] = "";
  681. $verifyList [$k] ['opinion'] = "";
  682. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  683. $verifyList [$k] ['status'] = 4;
  684. $button = 4;
  685. $flag = false;
  686. }
  687. } else {
  688. foreach ( $verifyStaff as $m => $u ) {
  689. if ($v [0] == $m) {
  690. $verifyList [$k] ['date'] = $u ['date'];
  691. $verifyList [$k] ['opinion'] = $u ['opinion'];
  692. $verifyList [$k] ['status'] = $u ['status'];
  693. $flag = false;
  694. break;
  695. }
  696. }
  697. $endStaffArray = end ( $verifyStaff );
  698. if (isset ( $endStaffArray ['ROLE'] )) {
  699. } else {
  700. $endKey = key ( $verifyStaff );
  701. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  702. $button = 4;
  703. $verifyList [$k] ['status'] = 4;
  704. }
  705. }
  706. }
  707. }
  708. $rolename ['name'] = '';
  709. if (! empty ( $roleId )) {
  710. Doo::loadModel ( 'role' );
  711. $role = new role ();
  712. $rolename = $role->getOne ( array (
  713. 'where' => 'rid=' . $roleId,
  714. 'asArray' => true
  715. ) );
  716. }
  717. if (! empty ( $verifyStaff ))
  718. $endStaffArray = end ( $verifyStaff );
  719. $KOP = false;
  720. foreach ( $roleArrayCopy as $P => $A ) {
  721. foreach ( $A as $MKI => $AVL ) {
  722. if (! empty ( $verifyStaff )) {
  723. // &&$rolename['rid']==$endStaffArray['nextStaff']
  724. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  725. $button = 4;
  726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  727. }
  728. foreach ( $verifyStaff as $m => $u ) {
  729. $AVLFK = $AVL [0] . '_R';
  730. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  731. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  732. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  733. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  734. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  735. break;
  736. }
  737. }
  738. } else {
  739. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  740. $button = 4;
  741. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  742. }
  743. }
  744. // $roleArray[$MKI]['rolename']=$rolename['name'];
  745. $KOP = true;
  746. }
  747. }
  748. foreach ( $roleArrayCopy as $k => $v ) {
  749. foreach ( $verifyList as $m => $n ) {
  750. if ($n [0] == $k) {
  751. array_splice ( $verifyList, $m, 1, $v );
  752. }
  753. }
  754. }
  755. $receiptList [$key] ['verifyList'] = $verifyList;
  756. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  757. 'where' => 'sid=' . $value ['staff'],
  758. 'asArray' => true
  759. ) );
  760. $receiptList [$key] ['button'] = $button;
  761. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  762. }
  763. $mothHtml = "";
  764. for($i = 1; $i <= 12; $i ++) {
  765. if ($month == $i)
  766. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  767. else
  768. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  769. }
  770. // 获取审批日志
  771. Doo::loadModel ( 'receiptLog' );
  772. $receiptLog = new receiptLog ();
  773. $rlList = array ();
  774. $rlInfo = $receiptLog->getOne ( array (
  775. 'where' => 'rid=' . $rid . ' and status=4',
  776. 'asArray' => true
  777. ) );
  778. $tijdate = $receiptLog->getOne ( array (
  779. 'where' => 'rid=' . $rid . ' and status=2',
  780. 'asc' => 'rlid',
  781. 'asArray' => true
  782. ) );
  783. if (! empty ( $rlInfo )) {
  784. $rlList = $receiptLog->find ( array (
  785. 'where' => 'rid=' . $rid,
  786. 'asc' => 'rlid',
  787. 'asArray' => true
  788. ) );
  789. }
  790. $receiptList [0] ['rlList'] = $rlList;
  791. $enclosurList = $enclosur->find ( array (
  792. 'where' => 'rid=' . $rid,
  793. 'asArray' => true
  794. ) );
  795. $enclosurHtml = '';
  796. foreach ( $enclosurList as $value ) {
  797. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  798. }
  799. // print_r($receiptList);
  800. $data ['enclosurHtml'] = $enclosurHtml;
  801. $data ['rolename'] = $rolename ['name'];
  802. $data ['datetij'] = $tijdate ['date'];
  803. $data ['mothHtml'] = $mothHtml;
  804. $data ['rid'] = $rid;
  805. $data ['receiptList'] = $receiptList;
  806. $data ['receiptApprovalCount'] = count ( $receiptList );
  807. $data ['status'] = $status;
  808. $data ['year'] = $year;
  809. $data ['categoryList'] = $categoryList;
  810. $data ['staffList'] = $staffList;
  811. $data ['cid'] = $cid;
  812. $data ['sid'] = $sid;
  813. $data ['ap'] = $ap;
  814. $data ['memu'] = "receipt";
  815. $data ['staff'] = $this->staff;
  816. $data ['receiptMemu'] = 'approvalExpenses';
  817. $data ['verifyId'] = $this->verifyId;
  818. $data ['executeId'] = $this->executeId;
  819. $this->render ( "/admin/remitApproval", $data );
  820. }
  821. function saeaLoanAdd() {
  822. Doo::loadModel ( 'verify' );
  823. $verify = new verify ();
  824. Doo::loadModel ( "role" );
  825. $role = new role ();
  826. Doo::loadModel ( 'L_category' );
  827. $lCategory = new L_category ();
  828. $veList = $verify->getVerifyBySubordinate('LOAN');
  829. $data ['category'] = $lCategory->find ( array (
  830. 'asArray' => true
  831. ) );
  832. $data ['veList'] = $veList;
  833. $data ['memu'] = "receipt";
  834. $data ['staff'] = $this->staff;
  835. $data ['receiptMemu'] = 'saeaBorad';
  836. $data ['verifyId'] = $this->verifyId;
  837. $data ['executeId'] = $this->executeId;
  838. $this->render ( "/admin/saeaLoanAdd", $data );
  839. }
  840. function saeaLoanAddDo() {
  841. $agency = $this->get_args ( 'agency' );
  842. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  843. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  844. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  845. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  846. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  847. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  848. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  849. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  850. // die;
  851. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  852. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  853. header ( 'Content-Type:text/html;charset=utf-8' );
  854. die ( '请填写联行号' );
  855. }
  856. Doo::loadModel ( 'receipt' );
  857. Doo::loadModel ( 'receiptDetail' );
  858. Doo::loadModel ( 'accountItem' );
  859. $accountItem = new accountItem ();
  860. $receipt = new receipt ();
  861. Doo::loadModel ( 'loanReceipt' );
  862. $loanReceipt = new loanReceipt ();
  863. Doo::loadModel ( 'execute' );
  864. $execute = new execute ();
  865. Doo::loadModel ( 'enclosur' );
  866. $executeDetail = $execute->getOne ( array (
  867. 'where' => 'mold="借款执行人"',
  868. 'asArray' => true
  869. ) );
  870. $aItem = $accountItem->find ( array (
  871. 'asArray' => true
  872. ) );
  873. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  874. $ag = $tr = $ta = $ot = 0;
  875. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  876. array_push ( $accountJson ['借款费用'], array (
  877. 'aid' => 0,
  878. 'name' => '申请金额',
  879. 'price' => number_format ( $agency, 2, '.', '' )
  880. ) );
  881. $sum += $agency;
  882. $agencySum += $agency;
  883. $accountJson ['cSum'] = array (
  884. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  885. 'agencySum' => number_format ( 0, 2, '.', '' ),
  886. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  887. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  888. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  889. );
  890. // 借款数据备份
  891. $loanReceipt->loanItem = json_encode ( $accountJson );
  892. $loanReceipt->staff = $this->staff [0] ['sid'];
  893. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  894. $loanReceipt->date = date ( "Y-m-d" );
  895. $loanReceipt->cid = $cid;
  896. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  897. $loanReceipt->status = 5;
  898. $loanReceipt->Rtype = 1;
  899. $loanReceipt->verify = $verify;
  900. $receipt->receiptOrder = $receipt->receiptOrder;
  901. // 添加HTML换行符
  902. // var_dump($explanation);
  903. $order = array (
  904. "\r\n",
  905. "\n",
  906. "\r"
  907. );
  908. $replace = '<br/>';
  909. $explanation = str_replace ( $order, $replace, $explanation );
  910. // $explanation=str_replace('\r',"<br/>",$explanation);
  911. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  912. $loanReceipt->explanation = $explanation;
  913. $loanRid = $loanReceipt->insert ();
  914. // 报销单
  915. $receipt->loanItem = json_encode ( $accountJson );
  916. $receipt->staff = $this->staff [0] ['sid'];
  917. $receipt->sum = number_format ( $sum, 2, '.', '' );
  918. $receipt->date = date ( "Y-m-d" );
  919. $receipt->cid = $cid;
  920. // 特殊状态
  921. $receipt->status = 5;
  922. $receipt->Rtype = 1;
  923. $receipt->loanRid = $loanRid;
  924. // 修改审批流程加入角色
  925. $receipt->verify = $verify;
  926. $receipt->executeCopy = $executeDetail ['staff'];
  927. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  928. $receipt->explanation = $explanation;
  929. $receipt->remittanceName = $remittanceName;
  930. $receipt->bankName = $bankName;
  931. $receipt->bankNumber = $bankNumber;
  932. $receipt->remittanceBankType = $remittanceBankType;
  933. if ($remittanceBankType == 1)
  934. $receipt->coupletNumber = $coupletNumber;
  935. $rid = $receipt->insert ();
  936. return "/saeaBorad";
  937. } else
  938. die ( 'illegal request' );
  939. }
  940. function saeaLoanEdi() {
  941. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  942. Doo::loadClass ( 'XDeode' );
  943. $XDeode = new XDeode ( 7 );
  944. $rid = $XDeode->decode ( $ridKey );
  945. if (! is_numeric ( $rid ))
  946. die ( 'illegal request' );
  947. Doo::loadModel ( 'verify' );
  948. $verify = new verify ();
  949. Doo::loadModel ( "role" );
  950. $role = new role ();
  951. Doo::loadModel ( 'L_category' );
  952. $lCategory = new L_category ();
  953. Doo::loadModel ( 'receipt' );
  954. $receipt = new receipt ();
  955. $receiptInfo = $receipt->getOne ( array (
  956. 'where' => 'rid=' . $rid,
  957. 'asArray' => true
  958. ) );
  959. $veList = $verify->find ( array (
  960. 'where'=>'subordinate like "%LOAN%"',
  961. 'asArray' => true
  962. ) );
  963. foreach ( $veList as $key => $value ) {
  964. $v = json_decode ( $value ['staff'] );
  965. $list = array ();
  966. foreach ( $v as $n => $m ) {
  967. if ($m ['1'] == 'ROLE') {
  968. $roleInfo = $role->getOne ( array (
  969. 'where' => 'rid=' . $m [0],
  970. 'asArray' => true
  971. ) );
  972. $v [$n] [1] = $roleInfo ['name'];
  973. array_push ( $list, $roleInfo ['name'] );
  974. } else {
  975. array_push ( $list, $v [$n] [1] );
  976. }
  977. }
  978. $veList [$key] ['staff'] = implode ( '>', $list );
  979. }
  980. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  981. // print_r($receiptInfo);
  982. $data ['receiptInfo'] = $receiptInfo;
  983. $data ['category'] = $lCategory->find ( array (
  984. 'asArray' => true
  985. ) );
  986. $data ['veList'] = $veList;
  987. $data ['ridKey'] = $ridKey;
  988. $data ['memu'] = "receipt";
  989. $data ['staff'] = $this->staff;
  990. $data ['receiptMemu'] = 'saeaBorad';
  991. $data ['verifyId'] = $this->verifyId;
  992. $data ['executeId'] = $this->executeId;
  993. $this->render ( "/admin/saeaLoanEdi", $data );
  994. }
  995. function saeaLoanEdiDo() {
  996. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  997. $agency = $this->get_args ( 'agency' );
  998. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  999. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1000. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1001. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1002. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1003. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1004. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1005. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1006. // die;
  1007. Doo::loadClass ( 'XDeode' );
  1008. $XDeode = new XDeode ( 7 );
  1009. $rid = $XDeode->decode ( $ridKey );
  1010. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1011. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1012. header ( 'Content-Type:text/html;charset=utf-8' );
  1013. die ( '请填写联行号' );
  1014. }
  1015. Doo::loadModel ( 'receipt' );
  1016. Doo::loadModel ( 'receiptDetail' );
  1017. Doo::loadModel ( 'accountItem' );
  1018. $accountItem = new accountItem ();
  1019. $receipt = new receipt ();
  1020. Doo::loadModel ( 'loanReceipt' );
  1021. $loanReceipt = new loanReceipt ();
  1022. Doo::loadModel ( 'enclosur' );
  1023. Doo::loadModel ( 'execute' );
  1024. $execute = new execute ();
  1025. $executeDetail = $execute->getOne ( array (
  1026. 'where' => 'mold="借款执行人"',
  1027. 'asArray' => true
  1028. ) );
  1029. $receiptDetail = $receipt->getOne ( array (
  1030. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1031. 'asArray' => true
  1032. ) );
  1033. if (empty ( $receiptDetail ))
  1034. die ( '参数错误' );
  1035. $aItem = $accountItem->find ( array (
  1036. 'asArray' => true
  1037. ) );
  1038. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1039. $ag = $tr = $ta = $ot = 0;
  1040. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1041. array_push ( $accountJson ['借款费用'], array (
  1042. 'aid' => 0,
  1043. 'name' => '申请金额',
  1044. 'price' => number_format ( $agency, 2, '.', '' )
  1045. ) );
  1046. $sum += $agency;
  1047. $agencySum += $agency;
  1048. $accountJson ['cSum'] = array (
  1049. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1050. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1051. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1052. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1053. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1054. );
  1055. // 报销单
  1056. $receipt->loanItem = json_encode ( $accountJson );
  1057. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1058. $receipt->cid = $cid;
  1059. // 特殊状态
  1060. // 修改审批流程加入角色
  1061. if ($receiptDetail ['status'] != 4)
  1062. $receipt->verify = $verify;
  1063. $order = array (
  1064. "\r\n",
  1065. "\n",
  1066. "\r"
  1067. );
  1068. $replace = '<br/>';
  1069. $explanation = str_replace ( $order, $replace, $explanation );
  1070. $receipt->explanation = $explanation;
  1071. $receipt->remittanceName = $remittanceName;
  1072. $receipt->bankName = $bankName;
  1073. $receipt->bankNumber = $bankNumber;
  1074. $receipt->remittanceBankType = $remittanceBankType;
  1075. if ($remittanceBankType == 1)
  1076. $receipt->coupletNumber = $coupletNumber;
  1077. $receipt->update ( array (
  1078. 'where' => 'rid=' . $rid
  1079. ) );
  1080. // 借款数据更新
  1081. $loanReceipt->loanItem = json_encode ( $accountJson );
  1082. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1083. $loanReceipt->cid = $cid;
  1084. if ($receiptDetail ['status'] != 4)
  1085. $loanReceipt->verify = $verify;
  1086. $loanReceipt->explanation = $explanation;
  1087. $receipt->executeCopy = $executeDetail ['staff'];
  1088. $loanReceipt->update ( array (
  1089. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1090. ) );
  1091. }
  1092. return "/saeaBorad";
  1093. }
  1094. function saeaLoanReceiptAdd() {
  1095. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1096. Doo::loadModel ( 'receipt' );
  1097. $receipt = new receipt ();
  1098. Doo::loadModel ( 'loanReceipt' );
  1099. $loanReceipt = new loanReceipt ();
  1100. Doo::loadModel ( 'L_category' );
  1101. $Lcategory = new L_category ();
  1102. Doo::loadModel ( 'verify' );
  1103. Doo::loadModel ( 'statistics' );
  1104. $statistics = new statistics ();
  1105. $verify = new verify ();
  1106. Doo::loadModel ( 'staff' );
  1107. $staff = new staff ();
  1108. $receiptDetail = $receipt->getOne ( array (
  1109. 'where' => 'rid=' . $rid,
  1110. 'desc' => 'rid',
  1111. 'asArray' => true
  1112. ) );
  1113. $receiptList = $loanReceipt->find ( array (
  1114. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1115. 'desc' => 'rid',
  1116. 'asArray' => true
  1117. ) );
  1118. $Locate = 0;
  1119. $roleId = 0;
  1120. $button = 0;
  1121. foreach ( $receiptList as $key => $value ) {
  1122. $receiptList [$key] ['Locate'] = $Locate;
  1123. $Locate ++;
  1124. $receiptList [$key] ['reviseDetail'] = array ();
  1125. if (! empty ( $value ['reviseDetail'] ))
  1126. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1127. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1128. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1129. $categoryDetil = $Lcategory->getOne ( array (
  1130. 'where' => 'cid=' . $value ['cid'],
  1131. 'asArray' => true
  1132. ) );
  1133. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1134. // 检测编辑状态
  1135. $verifyList = $verify->getOne ( array (
  1136. 'where' => 'vid=' . $value ['verify'],
  1137. 'asArray' => true
  1138. ) );
  1139. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1140. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1141. Doo::loadModel ( 'role' );
  1142. $role = new role ();
  1143. $flag = true;
  1144. $roleKey = 0;
  1145. $endStaffArray = array ();
  1146. $roleArrayCopy = array ();
  1147. foreach ( $verifyList as $k => $v ) {
  1148. // init verifyStaff
  1149. if ($v [1] == 'ROLE') {
  1150. if (! empty ( $verifyStaff )) {
  1151. $endStaffArray = end ( $verifyStaff );
  1152. // if ($v[0]==$endStaffArray['nextStaff']){
  1153. // $roleId=$v[0];
  1154. // }
  1155. }
  1156. $roleVerify = json_decode ( $v [3], true );
  1157. $roleKey = $k;
  1158. $roleArray = array ();
  1159. $rolename = $role->getOne ( array (
  1160. 'where' => 'rid=' . $v [0],
  1161. 'asArray' => true
  1162. ) );
  1163. foreach ( $roleVerify as $o => $p ) {
  1164. $staffID = explode ( '_', $p );
  1165. $staffInfo = $staff->getOne ( array (
  1166. 'where' => 'sid=' . $staffID [0],
  1167. 'asArray' => true
  1168. ) );
  1169. // print_r($staffID);
  1170. $exp = array (
  1171. 0 => $staffInfo ['sid'],
  1172. 1 => $staffID [1],
  1173. 2 => $staffInfo ['avatar'],
  1174. 'date' => '',
  1175. 'date' => '',
  1176. 'opinion' => '',
  1177. 'status' => '',
  1178. 'rolename' => $rolename ['name']
  1179. );
  1180. array_push ( $roleArray, $exp );
  1181. }
  1182. $roleArrayCopy [$v [0]] = $roleArray;
  1183. // $verifyList[$k]['roleArray']=$roleArray;
  1184. }
  1185. $verifyList [$k] ['date'] = "";
  1186. $verifyList [$k] ['opinion'] = "";
  1187. $verifyList [$k] ['status'] = "";
  1188. if (empty ( $verifyStaff )) {
  1189. $verifyList [$k] ['date'] = "";
  1190. $verifyList [$k] ['opinion'] = "";
  1191. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1192. $verifyList [$k] ['status'] = 4;
  1193. $flag = false;
  1194. }
  1195. } else {
  1196. foreach ( $verifyStaff as $m => $u ) {
  1197. if ($v [0] == $m) {
  1198. $verifyList [$k] ['date'] = $u ['date'];
  1199. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1200. $verifyList [$k] ['status'] = $u ['status'];
  1201. $flag = false;
  1202. break;
  1203. }
  1204. }
  1205. $endStaffArray = end ( $verifyStaff );
  1206. if (isset ( $endStaffArray ['ROLE'] )) {
  1207. } else {
  1208. // $endKey=key($verifyStaff);
  1209. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1210. // $button=4;
  1211. // $verifyList[$k]['status']=4;
  1212. // }
  1213. }
  1214. }
  1215. }
  1216. $rolename ['name'] = '';
  1217. if (! empty ( $roleId )) {
  1218. Doo::loadModel ( 'role' );
  1219. $role = new role ();
  1220. $rolename = $role->getOne ( array (
  1221. 'where' => 'rid=' . $roleId,
  1222. 'asArray' => true
  1223. ) );
  1224. }
  1225. if (! empty ( $verifyStaff ))
  1226. $endStaffArray = end ( $verifyStaff );
  1227. $KOP = false;
  1228. foreach ( $roleArrayCopy as $P => $A ) {
  1229. foreach ( $A as $MKI => $AVL ) {
  1230. if (! empty ( $verifyStaff )) {
  1231. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1232. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1233. $button = 4;
  1234. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1235. }
  1236. foreach ( $verifyStaff as $m => $u ) {
  1237. $AVLFK = $AVL [0] . '_R';
  1238. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1239. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1240. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1241. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1242. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1243. break;
  1244. }
  1245. }
  1246. } else {
  1247. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1248. $button = 4;
  1249. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1250. }
  1251. }
  1252. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1253. $KOP = true;
  1254. }
  1255. }
  1256. foreach ( $roleArrayCopy as $k => $v ) {
  1257. foreach ( $verifyList as $m => $n ) {
  1258. if ($n [0] == $k) {
  1259. array_splice ( $verifyList, $m, 1, $v );
  1260. }
  1261. }
  1262. }
  1263. $receiptList [$key] ['verifyList'] = $verifyList;
  1264. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1265. 'where' => 'sid=' . $value ['staff'],
  1266. 'asArray' => true
  1267. ) );
  1268. $receiptList [$key] ['button'] = $button;
  1269. //
  1270. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1271. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1272. }
  1273. $data ['receiptList'] = $receiptList;
  1274. $data ['receiptDetail'] = $receiptDetail;
  1275. Doo::loadModel ( 'L_category' );
  1276. $lCategory = new L_category ();
  1277. Doo::loadModel ( 'accountItem' );
  1278. $accountItem = new accountItem ();
  1279. $acItem = $accountItem->find ( array (
  1280. 'asArray' => true
  1281. ) );
  1282. $veList = $verify->getVerifyBySubordinate('RECEIPT','LOAN');
  1283. $data ['rid'] = $rid;
  1284. $data ['category'] = $lCategory->find ( array (
  1285. 'asArray' => true
  1286. ) );
  1287. $data ['veList'] = $veList;
  1288. $data ['acItem'] = $acItem;
  1289. $data ['memu'] = "receipt";
  1290. $data ['staff'] = $this->staff;
  1291. $data ['receiptMemu'] = 'saeaBorad';
  1292. $data ['verifyId'] = $this->verifyId;
  1293. $data ['executeId'] = $this->executeId;
  1294. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1295. }
  1296. function saeaLoanReceiptAddDo() {
  1297. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1298. $agency = $this->get_args ( 'agency' );
  1299. $travel = $this->get_args ( 'travel' );
  1300. $train = $this->get_args ( 'train' );
  1301. $other = $this->get_args ( 'other' );
  1302. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1303. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1304. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1305. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1306. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1307. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1308. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1309. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1310. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1311. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1312. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1313. header ( 'Content-Type:text/html;charset=utf-8' );
  1314. die ( '请填写联行号' );
  1315. }
  1316. Doo::loadModel ( 'receipt' );
  1317. Doo::loadModel ( 'receiptDetail' );
  1318. Doo::loadModel ( 'accountItem' );
  1319. $accountItem = new accountItem ();
  1320. $receipt = new receipt ();
  1321. Doo::loadModel ( 'enclosur' );
  1322. Doo::loadModel ( 'execute' );
  1323. $execute = new execute ();
  1324. $executeDetail = $execute->getOne ( array (
  1325. 'where' => 'mold="借款费用执行人"',
  1326. 'asArray' => true
  1327. ) );
  1328. $receiptDet = $receipt->getOne ( array (
  1329. 'where' => 'rid=' . $rid,
  1330. 'asArray' => true
  1331. ) );
  1332. // if(!empty($receiptDetail))
  1333. // return "/referReceipt/".$receiptDetail['rid'];
  1334. $aItem = $accountItem->find ( array (
  1335. 'asArray' => true
  1336. ) );
  1337. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1338. $ag = $tr = $ta = $ot = 0;
  1339. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1340. foreach ( $aItem as $key => $value ) {
  1341. if ($value ['category'] == $this->AGENCY) {
  1342. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1343. array_push ( $accountJson [$this->AGENCY], array (
  1344. 'aid' => $value ['aid'],
  1345. 'name' => $value ['name'],
  1346. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1347. ) );
  1348. $sum += $agency [$ag];
  1349. $agencySum += $agency [$ag];
  1350. }
  1351. $ag ++;
  1352. }
  1353. if ($value ['category'] == $this->TRAVEL) {
  1354. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1355. array_push ( $accountJson [$this->TRAVEL], array (
  1356. 'aid' => $value ['aid'],
  1357. 'name' => $value ['name'],
  1358. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1359. ) );
  1360. $sum += $travel [$tr];
  1361. $travelSum += $travel [$tr];
  1362. }
  1363. $tr ++;
  1364. }
  1365. if ($value ['category'] == $this->TRAIN) {
  1366. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1367. array_push ( $accountJson [$this->TRAIN], array (
  1368. 'aid' => $value ['aid'],
  1369. 'name' => $value ['name'],
  1370. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1371. ) );
  1372. $sum += $train [$ta];
  1373. $trainSum += $train [$ta];
  1374. }
  1375. $ta ++;
  1376. }
  1377. if ($value ['category'] == $this->OTHER) {
  1378. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1379. array_push ( $accountJson [$this->OTHER], array (
  1380. 'aid' => $value ['aid'],
  1381. 'name' => $value ['name'],
  1382. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1383. ) );
  1384. $sum += $other [$ot];
  1385. $otherSum += $other [$ot];
  1386. }
  1387. $ot ++;
  1388. }
  1389. }
  1390. $accountJson ['cSum'] = array (
  1391. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1392. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1393. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1394. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1395. );
  1396. // 报销单
  1397. $receipt->accountItem = json_encode ( $accountJson );
  1398. $receipt->staff = $this->staff [0] ['sid'];
  1399. $receipt->loanSum = $receiptDet ['sum'];
  1400. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1401. $receipt->date = date ( "Y-m-d" );
  1402. $receipt->pastDate = '';
  1403. $receipt->cid = $cid;
  1404. $receipt->status = 7;
  1405. // 修改审批流程加入角色
  1406. $receipt->verify = $verify;
  1407. $receipt->verifyStaff = '';
  1408. $receipt->executeStaff = '';
  1409. $receipt->executeCopy = $executeDetail ['staff'];
  1410. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1411. $receipt->explanation = $explanation;
  1412. $receipt->remittanceName = $remittanceName;
  1413. $receipt->bankName = $bankName;
  1414. $receipt->bankNumber = $bankNumber;
  1415. $receipt->remittanceBankType = $remittanceBankType;
  1416. if ($remittanceBankType == 1)
  1417. $receipt->coupletNumber = $coupletNumber;
  1418. $receipt->update ( array (
  1419. 'where' => 'rid=' . $rid
  1420. ) );
  1421. // 附件
  1422. if (! empty ( $enclosurName )) {
  1423. $enclosurArray = explode ( '-', $enclosurName );
  1424. foreach ( $enclosurArray as $value ) {
  1425. $enclosur = new enclosur ();
  1426. $enclosur->name = $value;
  1427. $enclosur->rid = $rid;
  1428. $enclosur->insert ();
  1429. }
  1430. // print_r($enclosurArray);die;
  1431. }
  1432. // 报销详情
  1433. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1434. $receiptDetail = new receiptDetail ();
  1435. $receiptDetail->staff = $this->staff [0] ['sid'];
  1436. $receiptDetail->item = $value ['name'];
  1437. $receiptDetail->itemCategory = $this->AGENCY;
  1438. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1439. $receiptDetail->date = date ( "Y-m-d" );
  1440. $receiptDetail->cid = $cid;
  1441. $receiptDetail->rid = $rid;
  1442. $receiptDetail->status = 4;
  1443. $receiptDetail->insert ();
  1444. }
  1445. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1446. $receiptDetail = new receiptDetail ();
  1447. $receiptDetail->staff = $this->staff [0] ['sid'];
  1448. $receiptDetail->item = $value ['name'];
  1449. $receiptDetail->itemCategory = $this->TRAVEL;
  1450. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1451. $receiptDetail->date = date ( "Y-m-d" );
  1452. $receiptDetail->cid = $cid;
  1453. $receiptDetail->rid = $rid;
  1454. $receiptDetail->status = 4;
  1455. $receiptDetail->insert ();
  1456. }
  1457. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1458. $receiptDetail = new receiptDetail ();
  1459. $receiptDetail->staff = $this->staff [0] ['sid'];
  1460. $receiptDetail->item = $value ['name'];
  1461. $receiptDetail->itemCategory = $this->TRAIN;
  1462. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1463. $receiptDetail->date = date ( "Y-m-d" );
  1464. $receiptDetail->cid = $cid;
  1465. $receiptDetail->rid = $rid;
  1466. $receiptDetail->status = 4;
  1467. $receiptDetail->insert ();
  1468. }
  1469. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1470. $receiptDetail = new receiptDetail ();
  1471. $receiptDetail->staff = $this->staff [0] ['sid'];
  1472. $receiptDetail->item = $value ['name'];
  1473. $receiptDetail->itemCategory = $this->OTHER;
  1474. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1475. $receiptDetail->date = date ( "Y-m-d" );
  1476. $receiptDetail->cid = $cid;
  1477. $receiptDetail->rid = $rid;
  1478. $receiptDetail->status = 4;
  1479. $receiptDetail->insert ();
  1480. }
  1481. return "/saeaBorad";
  1482. }
  1483. return "/saeaLoanReceiptAdd/" . $rid;
  1484. }
  1485. function saeaLoanReceiptEdi() {
  1486. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1487. Doo::loadClass ( 'XDeode' );
  1488. $XDeode = new XDeode ( 7 );
  1489. $rid = $XDeode->decode ( $ridKey );
  1490. if (! is_numeric ( $rid ))
  1491. die ( 'illegal request' );
  1492. Doo::loadModel ( 'accountItem' );
  1493. Doo::loadModel ( 'verify' );
  1494. Doo::loadModel ( 'receipt' );
  1495. $receipt = new receipt ();
  1496. $verify = new verify ();
  1497. $accountItem = new accountItem ();
  1498. Doo::loadModel ( 'L_category' );
  1499. $Lcategory = new L_category ();
  1500. Doo::loadModel ( "role" );
  1501. $role = new role ();
  1502. Doo::loadModel ( 'loanReceipt' );
  1503. $loanReceipt = new loanReceipt ();
  1504. Doo::loadModel ( 'staff' );
  1505. $staff = new staff ();
  1506. $receiptDetail = $receipt->getOne ( array (
  1507. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1508. 'asArray' => true
  1509. ) );
  1510. if (empty ( $receiptDetail ))
  1511. return "/saeaBorad";
  1512. $receiptList = $loanReceipt->find ( array (
  1513. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1514. 'desc' => 'rid',
  1515. 'asArray' => true
  1516. ) );
  1517. $Locate = 0;
  1518. $roleId = 0;
  1519. $button = 0;
  1520. foreach ( $receiptList as $key => $value ) {
  1521. $receiptList [$key] ['Locate'] = $Locate;
  1522. $Locate ++;
  1523. $receiptList [$key] ['reviseDetail'] = array ();
  1524. if (! empty ( $value ['reviseDetail'] ))
  1525. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1526. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1527. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1528. $categoryDetil = $Lcategory->getOne ( array (
  1529. 'where' => 'cid=' . $value ['cid'],
  1530. 'asArray' => true
  1531. ) );
  1532. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1533. // 检测编辑状态
  1534. $verifyList = $verify->getOne ( array (
  1535. 'where' => 'vid=' . $value ['verify'],
  1536. 'asArray' => true
  1537. ) );
  1538. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1539. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1540. Doo::loadModel ( 'role' );
  1541. $role = new role ();
  1542. $flag = true;
  1543. $roleKey = 0;
  1544. $endStaffArray = array ();
  1545. $roleArrayCopy = array ();
  1546. foreach ( $verifyList as $k => $v ) {
  1547. // init verifyStaff
  1548. if ($v [1] == 'ROLE') {
  1549. if (! empty ( $verifyStaff )) {
  1550. $endStaffArray = end ( $verifyStaff );
  1551. // if ($v[0]==$endStaffArray['nextStaff']){
  1552. // $roleId=$v[0];
  1553. // }
  1554. }
  1555. $roleVerify = json_decode ( $v [3], true );
  1556. $roleKey = $k;
  1557. $roleArray = array ();
  1558. $rolename = $role->getOne ( array (
  1559. 'where' => 'rid=' . $v [0],
  1560. 'asArray' => true
  1561. ) );
  1562. foreach ( $roleVerify as $o => $p ) {
  1563. $staffID = explode ( '_', $p );
  1564. $staffInfo = $staff->getOne ( array (
  1565. 'where' => 'sid=' . $staffID [0],
  1566. 'asArray' => true
  1567. ) );
  1568. // print_r($staffID);
  1569. $exp = array (
  1570. 0 => $staffInfo ['sid'],
  1571. 1 => $staffID [1],
  1572. 2 => $staffInfo ['avatar'],
  1573. 'date' => '',
  1574. 'date' => '',
  1575. 'opinion' => '',
  1576. 'status' => '',
  1577. 'rolename' => $rolename ['name']
  1578. );
  1579. array_push ( $roleArray, $exp );
  1580. }
  1581. $roleArrayCopy [$v [0]] = $roleArray;
  1582. // $verifyList[$k]['roleArray']=$roleArray;
  1583. }
  1584. $verifyList [$k] ['date'] = "";
  1585. $verifyList [$k] ['opinion'] = "";
  1586. $verifyList [$k] ['status'] = "";
  1587. if (empty ( $verifyStaff )) {
  1588. $verifyList [$k] ['date'] = "";
  1589. $verifyList [$k] ['opinion'] = "";
  1590. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1591. $verifyList [$k] ['status'] = 4;
  1592. $flag = false;
  1593. }
  1594. } else {
  1595. foreach ( $verifyStaff as $m => $u ) {
  1596. if ($v [0] == $m) {
  1597. $verifyList [$k] ['date'] = $u ['date'];
  1598. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1599. $verifyList [$k] ['status'] = $u ['status'];
  1600. $flag = false;
  1601. break;
  1602. }
  1603. }
  1604. $endStaffArray = end ( $verifyStaff );
  1605. if (isset ( $endStaffArray ['ROLE'] )) {
  1606. } else {
  1607. // $endKey=key($verifyStaff);
  1608. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1609. // $button=4;
  1610. // $verifyList[$k]['status']=4;
  1611. // }
  1612. }
  1613. }
  1614. }
  1615. $rolename ['name'] = '';
  1616. if (! empty ( $roleId )) {
  1617. Doo::loadModel ( 'role' );
  1618. $role = new role ();
  1619. $rolename = $role->getOne ( array (
  1620. 'where' => 'rid=' . $roleId,
  1621. 'asArray' => true
  1622. ) );
  1623. }
  1624. if (! empty ( $verifyStaff ))
  1625. $endStaffArray = end ( $verifyStaff );
  1626. $KOP = false;
  1627. foreach ( $roleArrayCopy as $P => $A ) {
  1628. foreach ( $A as $MKI => $AVL ) {
  1629. if (! empty ( $verifyStaff )) {
  1630. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1631. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1632. $button = 4;
  1633. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1634. }
  1635. foreach ( $verifyStaff as $m => $u ) {
  1636. $AVLFK = $AVL [0] . '_R';
  1637. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1638. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1639. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1640. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1641. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1642. break;
  1643. }
  1644. }
  1645. } else {
  1646. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1647. $button = 4;
  1648. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1649. }
  1650. }
  1651. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1652. $KOP = true;
  1653. }
  1654. }
  1655. foreach ( $roleArrayCopy as $k => $v ) {
  1656. foreach ( $verifyList as $m => $n ) {
  1657. if ($n [0] == $k) {
  1658. array_splice ( $verifyList, $m, 1, $v );
  1659. }
  1660. }
  1661. }
  1662. $receiptList [$key] ['verifyList'] = $verifyList;
  1663. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1664. 'where' => 'sid=' . $value ['staff'],
  1665. 'asArray' => true
  1666. ) );
  1667. $receiptList [$key] ['button'] = $button;
  1668. //
  1669. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1670. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1671. }
  1672. $data ['receiptList'] = $receiptList;
  1673. $acItem = $accountItem->find ( array (
  1674. 'asArray' => true
  1675. ) );
  1676. $veList = $verify->find ( array (
  1677. 'asArray' => true
  1678. ) );
  1679. foreach ( $veList as $key => $value ) {
  1680. $v = json_decode ( $value ['staff'] );
  1681. $list = array ();
  1682. foreach ( $v as $n => $m ) {
  1683. if ($m ['1'] == 'ROLE') {
  1684. $roleInfo = $role->getOne ( array (
  1685. 'where' => 'rid=' . $m [0],
  1686. 'asArray' => true
  1687. ) );
  1688. $v [$n] [1] = $roleInfo ['name'];
  1689. array_push ( $list, $roleInfo ['name'] );
  1690. } else {
  1691. array_push ( $list, $v [$n] [1] );
  1692. }
  1693. }
  1694. $veList [$key] ['staff'] = implode ( '>', $list );
  1695. }
  1696. // 配置编辑信息
  1697. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1698. foreach ( $acItem as $key => $value ) {
  1699. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1700. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1701. $acItem [$key] ['price'] = $v ['price'];
  1702. }
  1703. }
  1704. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1705. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1706. $acItem [$key] ['price'] = $v ['price'];
  1707. }
  1708. }
  1709. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1710. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1711. $acItem [$key] ['price'] = $v ['price'];
  1712. }
  1713. }
  1714. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1715. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1716. $acItem [$key] ['price'] = $v ['price'];
  1717. }
  1718. }
  1719. }
  1720. $data ['category'] = $Lcategory->find ( array (
  1721. 'asArray' => true
  1722. ) );
  1723. $data ['ridKey'] = $ridKey;
  1724. $data ['cSum'] = $accountItemList ['cSum'];
  1725. $data ['sum'] = $receiptDetail ['sum'];
  1726. $data ['receiptDetail'] = $receiptDetail;
  1727. $data ['veList'] = $veList;
  1728. $data ['acItem'] = $acItem;
  1729. $data ['memu'] = "receipt";
  1730. $data ['staff'] = $this->staff;
  1731. $data ['receiptMemu'] = 'saeaBorad';
  1732. $data ['verify'] = $receiptDetail ['verify'];
  1733. $data ['verifyId'] = $this->verifyId;
  1734. $data ['executeId'] = $this->executeId;
  1735. $data ['rid'] = $rid;
  1736. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1737. }
  1738. /**
  1739. * 培训班结算
  1740. */
  1741. function receiptTrainAdd() {
  1742. Doo::loadModel ( 'accountItem' );
  1743. $accountItem = new accountItem ();
  1744. $acItem = $accountItem->find ( array (
  1745. 'asArray' => true
  1746. ) );
  1747. // 审批组
  1748. Doo::loadModel ( 'verify' );
  1749. $verify = new verify ();
  1750. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1751. // 办事处
  1752. Doo::loadModel ( 'L_category' );
  1753. $lCategory = new L_category ();
  1754. $data ['category'] = $lCategory->getCategory ();
  1755. $data ['veList'] = $veList;
  1756. $data ['memu'] = "receipt";
  1757. $data ['staff'] = $this->staff;
  1758. $data ['acItem'] = $acItem;
  1759. $data ['receiptMemu'] = 'saeaBorad';
  1760. $data ['verifyId'] = $this->verifyId;
  1761. $data ['executeId'] = $this->executeId;
  1762. $this->render ( "/receipt/receiptTrainAdd", $data );
  1763. }
  1764. /**
  1765. * 添加培训班结算
  1766. */
  1767. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1768. // 培训班信息
  1769. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1770. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1771. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1772. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1773. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1774. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1775. // 发票信息
  1776. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1777. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1778. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1779. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1780. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1781. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1782. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1783. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  1784. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1785. header ( 'Content-Type:text/html;charset=utf-8' );
  1786. die ( '请填写联行号' );
  1787. }
  1788. Doo::loadModel ( 'execute' );
  1789. $execute = new execute ();
  1790. $executeDetail = $execute->getOne ( array (
  1791. 'where' => 'mold="培训班结算"',
  1792. 'asArray' => true
  1793. ) );
  1794. if (empty ( $executeDetail )) {
  1795. header ( 'Content-Type:text/html;charset=utf-8' );
  1796. die ( '未设置执行人' );
  1797. }
  1798. Doo::loadClass ( 'XDeode' );
  1799. $XDeode = new XDeode ( 5 );
  1800. $cid = $XDeode->decode ( $cid );
  1801. Doo::loadModel ( 'receipt' );
  1802. $receipt = new receipt ();
  1803. Doo::loadModel ( 'receiptTraining' );
  1804. $receiptTraining = new receiptTraining ();
  1805. // 创建费用培训班
  1806. $item = array (
  1807. 'cid' => $this->staff [0] ['cid'],
  1808. 'categoryName' => $this->staff [0] ['category'],
  1809. 'trainName' => $trainName,
  1810. 'trainStartDate' => $trainStartDate,
  1811. 'trainEndDate' => $trainEndDate,
  1812. 'participants' => $participants,
  1813. 'trainAddress' => $trainAddress,
  1814. 'trainRemarks' => $trainRemarks,
  1815. 'creator' => $this->staff [0] ['sid'],
  1816. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1817. );
  1818. $irid = $receiptTraining->addReceiptTraining ( $item );
  1819. // 报销单
  1820. $receipt->status = 5;
  1821. $receipt->trainId = $irid;
  1822. $receipt->Rtype = 3;
  1823. $receipt->staff = $this->staff [0] ['sid'];
  1824. $receipt->cid = $cid;
  1825. $receipt->verify = $verify;
  1826. $receipt->date = date ( "Y-m-d" );
  1827. $receipt->executeCopy = $executeDetail ['staff'];
  1828. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1829. $receipt->remittanceName = $remittanceName;
  1830. $receipt->bankName = $bankName;
  1831. $receipt->bankNumber = $bankNumber;
  1832. $receipt->remittanceBankType = $remittanceBankType;
  1833. if ($remittanceBankType == 1)
  1834. $receipt->coupletNumber = $coupletNumber;
  1835. $rid = $receipt->insert ();
  1836. $XDeode = new XDeode ( 7 );
  1837. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1838. } else
  1839. die ( 'illegal request' );
  1840. }
  1841. /**
  1842. * 培训班编辑
  1843. */
  1844. function receiptTrainEdi() {
  1845. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1846. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1847. Doo::loadClass ( 'XDeode' );
  1848. $XDeode = new XDeode ( 7 );
  1849. $rid = $XDeode->decode ( $ridKey );
  1850. if (! is_numeric ( $rid ))
  1851. die ( 'illegal request' );
  1852. Doo::loadModel ( 'receipt' );
  1853. $receipt = new receipt ();
  1854. Doo::loadModel ( 'receiptTraining' );
  1855. $receiptTraining = new receiptTraining ();
  1856. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1857. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1858. die ('illegal request--status');
  1859. }
  1860. //如有已入账已收款的发票,自动取消办事处已收款
  1861. // Doo::loadModel ( 'RIExtend' );
  1862. // $RIExtend = new RIExtend ();
  1863. // $RIExtendList=$RIExtend->getRIExtendByRid($rid);
  1864. // if (!empty($RIExtendList)){
  1865. // foreach ($RIExtendList as $key=>$value){
  1866. // $RIExtend = new RIExtend ();
  1867. // $RIExtend->delete(array (
  1868. // 'where' => 'iid=' . $value['iid'],
  1869. // 'limit' => 1
  1870. // ));
  1871. // }
  1872. // }
  1873. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1874. // 汇总表合计
  1875. // 收入合计--加入开票合计
  1876. Doo::loadModel ( 'invoiceTraining' );
  1877. $invoiceTraining = new invoiceTraining ();
  1878. $invoiceTrainingDetail = array (
  1879. 'invoiceArriveAmount' => 0,
  1880. 'RIAmount' => 0,
  1881. 'invoiceTotalAmount' => 0,
  1882. 'invoiceCompanyAmount'=>0
  1883. );
  1884. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1885. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1886. }
  1887. // print_r($invoiceTrainingDetail);
  1888. $invoiceArriveAmount = $RIAmount = 0;
  1889. if (! empty ( $invoiceTrainingDetail )) {
  1890. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1891. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1892. }
  1893. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1894. //print_r($invoiceTrainingDetail);
  1895. // 支出项目
  1896. Doo::loadModel ( 'accountItem' );
  1897. $accountItem = new accountItem ();
  1898. // 项目金额合计
  1899. Doo::loadModel ( 'RItem' );
  1900. $RItem = new RItem ();
  1901. // 讲师获得
  1902. Doo::loadModel ( 'RILecturer' );
  1903. $RILecturer = new RILecturer ();
  1904. $RItemList = $RItem->getRItemByRid ( $rid );
  1905. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1906. // 支出项金额详情
  1907. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1908. // print_r($aiData);
  1909. // 利润
  1910. $profit=$invoiceArriveAmount - $aiData ['total'];
  1911. $companyProfit=$profit * 0.6;
  1912. $categoryProfit=$profit * 0.4;
  1913. $data ['profit'] = sprintf("%.2f",$profit);
  1914. $data ['companyProfit'] = sprintf("%.2f",$companyProfit);
  1915. $data ['categoryProfit'] = sprintf("%.2f",$categoryProfit);
  1916. //发票利润
  1917. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1918. //发票公司利润
  1919. $invoiceCompanyProfit=$data ['invoiceProfit'] * 0.6;
  1920. $data ['invoiceCompanyProfit'] = sprintf("%.2f",$invoiceCompanyProfit);
  1921. //办事处利润
  1922. $invoiceCategoryProfit=$data ['invoiceProfit'] * 0.4;
  1923. $data ['invoiceCategoryProfit'] = sprintf("%.2f",$invoiceCategoryProfit);
  1924. // print_r($aiData['dataList']);
  1925. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1926. $data ['categoryActualExpenditure'] = sprintf("%.2f",$categoryActualExpenditure);
  1927. // 备用金
  1928. $sum = 0;
  1929. $data ['receiptLoanDetail'] = array (
  1930. 'sum' => '0.00'
  1931. );
  1932. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1933. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1934. $sum = $data ['receiptLoanDetail'] ['sum'];
  1935. }
  1936. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1937. $data ['payment'] = sprintf("%.2f",$payment);
  1938. $data ['total'] = sprintf("%.2f",$aiData ['total']);
  1939. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1940. $data ['aiList'] = $aiData ['dataList'];
  1941. // 占比计算
  1942. if ($invoiceArriveAmount != 0) {
  1943. $data ['totalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceArriveAmount* 100) ;
  1944. $data ['profitProportion'] = sprintf("%.2f",$profit / $invoiceArriveAmount*100) ; //number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1945. $data ['sumProportion'] = sprintf("%.2f",$sum / $invoiceArriveAmount*100) ; //number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  1946. $data ['invoiceTotalAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount*100) ;
  1947. $data ['RIAmountProportion'] = sprintf("%.2f",$data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount*100) ;
  1948. $data ['companyProfitProportion'] = sprintf("%.2f",$companyProfit / $invoiceArriveAmount*100) ;
  1949. $data ['categoryProportion'] = sprintf("%.2f",$categoryProfit / $invoiceArriveAmount*100) ;
  1950. $data ['categoryActualExpenditureProportion'] = sprintf("%.2f",$categoryActualExpenditure / $invoiceArriveAmount*100) ;
  1951. $data ['paymentProportion'] = sprintf("%.2f",$payment / $invoiceArriveAmount*100) ;
  1952. } else {
  1953. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  1954. }
  1955. //发票金额占比计算
  1956. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  1957. //支出
  1958. $data ['invoicetotalProportion'] = sprintf("%.2f",$aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1959. //利润
  1960. $data ['invoiceprofitProportion'] = sprintf("%.2f",$data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1961. //公司利润
  1962. $data ['invoicecompanyProfitProportion'] = sprintf("%.2f", $invoiceCompanyProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1963. //办事处利润
  1964. $data ['invoicecategoryProportion'] = sprintf("%.2f", $invoiceCategoryProfit / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1965. //公司收款
  1966. $data ['invoiceTotalAmountProportionB'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1967. //备用金
  1968. $data ['invoicesumProportion'] = sprintf("%.2f", $sum / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1969. //办事处收款
  1970. $data ['invoiceRIAmountProportion'] = sprintf("%.2f", $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1971. //办事处实际支出
  1972. $data ['ICAEP'] = sprintf("%.2f", $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1973. //付总部款
  1974. $data ['invoicepaymentProportion'] = sprintf("%.2f", $payment / $invoiceTrainingDetail ['invoiceTotalAmount']* 100) ;
  1975. }else{
  1976. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  1977. }
  1978. //讲师人数
  1979. Doo::loadModel ( 'RILecturer' );
  1980. $RILecturer = new RILecturer ();
  1981. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1982. $data['lectureCount']=count($RILecturerList);
  1983. // 审批组
  1984. Doo::loadModel ( 'verify' );
  1985. $verify = new verify ();
  1986. $veList = $verify->getVerifyBySubordinate('TRAIN');
  1987. // 办事处
  1988. Doo::loadModel ( 'L_category' );
  1989. $lCategory = new L_category ();
  1990. $data ['category'] = $lCategory->getCategory ();
  1991. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  1992. $data ['receiptDetail'] = $receiptDetail;
  1993. $data ['veList'] = $veList;
  1994. $data ['trainEdiType'] = $trainEdiType;
  1995. $data ['ridKey'] = $ridKey;
  1996. $data ['memu'] = "receipt";
  1997. $data ['staff'] = $this->staff;
  1998. $data ['receiptMemu'] = 'saeaBorad';
  1999. $data ['verifyId'] = $this->verifyId;
  2000. $data ['executeId'] = $this->executeId;
  2001. $this->render ( "/receipt/receiptTrainEdi", $data );
  2002. }
  2003. /**
  2004. * 培训班借款编辑
  2005. */
  2006. function receiptTrainLoanEdi() {
  2007. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2008. Doo::loadClass ( 'XDeode' );
  2009. $XDeode = new XDeode ( 7 );
  2010. $rid = $XDeode->decode ( $ridKey );
  2011. if (! is_numeric ( $rid ))
  2012. die ( 'illegal request' );
  2013. Doo::loadModel ( 'receipt' );
  2014. $receipt = new receipt ();
  2015. Doo::loadModel ( 'receiptTraining' );
  2016. $receiptTraining = new receiptTraining ();
  2017. Doo::loadModel ( 'verify' );
  2018. $verify = new verify ();
  2019. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2020. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2021. die ();
  2022. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2023. // 借款详情HTML
  2024. // 获得借款信息
  2025. $receiptLoanHtml = '';
  2026. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2027. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2028. // 获得某费用单审批信息
  2029. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2030. Doo::loadClass ( 'receipt.func' );
  2031. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2032. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2033. }
  2034. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2035. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2036. $data ['receiptDetail'] = $receiptDetail;
  2037. $data ['trainEdiType'] = "LOAN";
  2038. $data ['ridKey'] = $ridKey;
  2039. $data ['memu'] = "receipt";
  2040. $data ['staff'] = $this->staff;
  2041. $data ['receiptMemu'] = 'saeaBorad';
  2042. $data ['verifyId'] = $this->verifyId;
  2043. $data ['executeId'] = $this->executeId;
  2044. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2045. }
  2046. /**
  2047. * 更新培训班结算基本信息
  2048. */
  2049. function receiptTrainInfoEdiDo() {
  2050. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2051. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2052. // 培训班信息
  2053. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2054. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2055. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2056. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2057. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2058. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2059. // 发票信息
  2060. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2061. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2062. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2063. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2064. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2065. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2066. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2067. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2068. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2069. header ( 'Content-Type:text/html;charset=utf-8' );
  2070. die ( '请填写联行号' );
  2071. }
  2072. Doo::loadClass ( 'XDeode' );
  2073. $XDeode = new XDeode ( 5 );
  2074. $cid = $XDeode->decode ( $cid );
  2075. $rtid = $XDeode->decode ( $rtid );
  2076. $rid = $XDeode->decode ( $rid );
  2077. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2078. die ( 'illegal request-IdError' );
  2079. }
  2080. Doo::loadModel ( 'receipt' );
  2081. $receipt = new receipt ();
  2082. Doo::loadModel ( 'receiptTraining' );
  2083. $receiptTraining = new receiptTraining ();
  2084. // 更新费用培训班
  2085. $item = array (
  2086. 'rtid' => $rtid,
  2087. 'trainName' => $trainName,
  2088. 'trainStartDate' => $trainStartDate,
  2089. 'trainEndDate' => $trainEndDate,
  2090. 'participants' => $participants,
  2091. 'trainAddress' => $trainAddress,
  2092. 'trainRemarks' => $trainRemarks
  2093. );
  2094. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2095. // 报销单
  2096. $receipt->rid = $rid;
  2097. $receipt->cid = $cid;
  2098. $receipt->verify = $verify;
  2099. $receipt->remittanceName = $remittanceName;
  2100. $receipt->bankName = $bankName;
  2101. $receipt->bankNumber = $bankNumber;
  2102. $receipt->remittanceBankType = $remittanceBankType;
  2103. if ($remittanceBankType == 1)
  2104. $receipt->coupletNumber = $coupletNumber;
  2105. $receipt->update ();
  2106. $XDeode = new XDeode ( 7 );
  2107. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2108. } else
  2109. die ( 'illegal request' );
  2110. }
  2111. /**
  2112. * 编辑培训班结算---更新借款
  2113. */
  2114. function receiptTrainLoanEdiDo() {
  2115. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2116. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2117. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2118. Doo::loadModel ( 'receipt' );
  2119. $receipt = new receipt ();
  2120. Doo::loadClass ( 'XDeode' );
  2121. $XDeode = new XDeode ( 5 );
  2122. $rid = $XDeode->decode ( $ridKey );
  2123. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2124. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2125. die ( 'illegal request-ridError' );
  2126. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2127. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2128. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2129. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2130. die ( 'illegal request-receiptError' );
  2131. }
  2132. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2133. die ( 'illegal request-receipLoantError' );
  2134. }
  2135. // 培训班结算挂钩借款
  2136. $receipt = new receipt ();
  2137. $item = array (
  2138. 'rid' => $rid,
  2139. 'trainLoanRid' => $ridLoan
  2140. );
  2141. $receipt->setReceiptByCondition ( $item );
  2142. // 更新借款状态变成已挂钩
  2143. $receipt = new receipt ();
  2144. $item = array (
  2145. 'rid' => $ridLoan,
  2146. 'status' => 10,
  2147. 'statusTrain' => 1
  2148. );
  2149. $receipt->setReceiptByCondition ( $item );
  2150. $XDeode = new XDeode ( 7 );
  2151. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2152. } else
  2153. die ( 'illegal request' );
  2154. }
  2155. /**
  2156. * 编辑培训班结算--移除借款
  2157. */
  2158. function receiptTrainLoanRemoveDo() {
  2159. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2160. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2161. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2162. Doo::loadModel ( 'receipt' );
  2163. $receipt = new receipt ();
  2164. Doo::loadClass ( 'XDeode' );
  2165. $XDeode = new XDeode ( 5 );
  2166. $rid = $XDeode->decode ( $ridKey );
  2167. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2168. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2169. die ( 'illegal request-ridError' );
  2170. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2171. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2172. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2173. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2174. die ( 'illegal request-receiptError' );
  2175. }
  2176. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2177. die ( 'illegal request-receipLoantError' );
  2178. }
  2179. // 培训班结算挂钩借款
  2180. $receipt = new receipt ();
  2181. $item = array (
  2182. 'rid' => $rid,
  2183. 'trainLoanRid' => 0
  2184. );
  2185. $receipt->setReceiptByCondition ( $item );
  2186. // 更新借款状态变成已挂钩
  2187. $receipt = new receipt ();
  2188. $item = array (
  2189. 'rid' => $ridLoan,
  2190. 'status' => 8,
  2191. 'statusTrain' => 0
  2192. );
  2193. $receipt->setReceiptByCondition ( $item );
  2194. $XDeode = new XDeode ( 7 );
  2195. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2196. } else
  2197. die ( 'illegal request' );
  2198. }
  2199. /**
  2200. * 编辑培训班结算 ---开票
  2201. */
  2202. function receiptTrainInvoiceEdi() {
  2203. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2204. Doo::loadClass ( 'XDeode' );
  2205. $XDeode = new XDeode ( 7 );
  2206. $rid = $XDeode->decode ( $ridKey );
  2207. if (! is_numeric ( $rid ))
  2208. die ( 'illegal request' );
  2209. Doo::loadModel ( 'receipt' );
  2210. $receipt = new receipt ();
  2211. Doo::loadModel ( 'receiptTraining' );
  2212. $receiptTraining = new receiptTraining ();
  2213. Doo::loadModel ( 'invoice' );
  2214. $invoice = new invoice ();
  2215. Doo::loadModel ( 'invoiceTraining' );
  2216. $invoiceTraining = new invoiceTraining ();
  2217. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2218. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2219. die ();
  2220. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2221. $invoiceList = $invoiceTrainingDetail = array ();
  2222. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2223. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2224. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2225. }
  2226. //print_r($invoiceList);
  2227. $data ['invoiceList'] = $invoiceList;
  2228. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2229. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2230. $data ['receiptDetail'] = $receiptDetail;
  2231. $data ['trainEdiType'] = "INVOICE";
  2232. $data ['ridKey'] = $ridKey;
  2233. $data ['memu'] = "receipt";
  2234. $data ['staff'] = $this->staff;
  2235. $data ['receiptMemu'] = 'saeaBorad';
  2236. $data ['verifyId'] = $this->verifyId;
  2237. $data ['executeId'] = $this->executeId;
  2238. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2239. }
  2240. /**
  2241. * 编辑培训班结算---更新开票
  2242. */
  2243. function receiptTrainInvoiceEdiDo() {
  2244. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2245. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2246. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2247. Doo::loadModel ( 'receipt' );
  2248. $receipt = new receipt ();
  2249. Doo::loadModel ( 'invoiceTraining' );
  2250. $invoiceTraining = new invoiceTraining ();
  2251. Doo::loadClass ( 'XDeode' );
  2252. $XDeode = new XDeode ( 5 );
  2253. $rid = $XDeode->decode ( $ridKey );
  2254. $itid = $XDeode->decode ( $itidKey );
  2255. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2256. die ( 'illegal request-idError' );
  2257. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2258. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2259. // 不合法的数据
  2260. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2261. die ( 'illegal request-receiptError' );
  2262. }
  2263. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2264. die ( 'illegal request-receipLoantError' );
  2265. }
  2266. // 培训班结算挂钩借款
  2267. $receipt = new receipt ();
  2268. $item = array (
  2269. 'rid' => $rid,
  2270. 'invoiceTrainId' => $itid
  2271. );
  2272. $receipt->setReceiptByCondition ( $item );
  2273. $invoiceTraining = new invoiceTraining ();
  2274. $item = array (
  2275. 'bindReceipt' => 1,
  2276. 'itid' => $itid
  2277. );
  2278. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2279. $XDeode = new XDeode ( 7 );
  2280. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2281. } else
  2282. die ( 'illegal request' );
  2283. }
  2284. /**
  2285. * 更新培训班结算 收款和取消收款
  2286. */
  2287. function receiptTrainReceivables() {
  2288. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2289. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2290. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2291. Doo::loadClass ( 'XDeode' );
  2292. $XDeode = new XDeode ( 5 );
  2293. $rid = $XDeode->decode ( $ridKey );
  2294. $iid = $XDeode->decode ( $iidKey );
  2295. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2296. die ( 'illegal request-iid' );
  2297. Doo::loadModel ( 'RIExtend' );
  2298. $RIExtend = new RIExtend ();
  2299. if ($doType == 'CONFIRM') {
  2300. $RIExtend->rid = $rid;
  2301. $RIExtend->iid = $iid;
  2302. $RIExtend->RIstatus = 1;
  2303. $RIExtend->insert ();
  2304. echo json_encode ( array (
  2305. 'status' => 1,
  2306. ) );
  2307. die ( );
  2308. } elseif ($doType == 'CANCEL') {
  2309. $RIExtend->delete ( array (
  2310. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2311. 'limit' => 1
  2312. ) );
  2313. echo json_encode ( array (
  2314. 'status' => 1,
  2315. ) );
  2316. die ( );
  2317. } else {
  2318. echo json_encode ( array (
  2319. 'status' => 2,
  2320. ) );
  2321. die ( );
  2322. }
  2323. }
  2324. /**
  2325. * 移除挂钩的培训班发票
  2326. */
  2327. function receiptTrainReceivablesDelDo() {
  2328. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2329. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2330. Doo::loadModel ( 'receipt' );
  2331. $receipt = new receipt ();
  2332. Doo::loadModel ( 'RIExtend' );
  2333. $RIExtend = new RIExtend ();
  2334. Doo::loadClass ( 'XDeode' );
  2335. $XDeode = new XDeode ( 5 );
  2336. $rid = $XDeode->decode ( $ridKey );
  2337. $itid = $XDeode->decode ( $itidKey );
  2338. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2339. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2340. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2341. die ( 'illegal request-status' );
  2342. }
  2343. $receipt = new receipt ();
  2344. $receipt->rid = $rid;
  2345. $receipt->invoiceTrainId = 0;
  2346. $receipt->update ();
  2347. Doo::loadModel ( 'invoiceTraining' );
  2348. $invoiceTraining = new invoiceTraining ();
  2349. $item = array (
  2350. 'bindReceipt' => 0,
  2351. 'itid' => $itid
  2352. );
  2353. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2354. $RIExtend->delete ( array (
  2355. 'where' => 'rid=' . $rid
  2356. ) );
  2357. $XDeode = new XDeode ( 7 );
  2358. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2359. } else
  2360. die ( 'illegal request-iid' );
  2361. }
  2362. /**
  2363. * 编辑培训班结算
  2364. */
  2365. function receiptTrainItemEdi() {
  2366. //include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  2367. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2368. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : '';
  2369. Doo::loadClass ( 'XDeode' );
  2370. $XDeode = new XDeode ( 7 );
  2371. $rid = $XDeode->decode ( $ridKey );
  2372. if (! is_numeric ( $rid ))
  2373. die ( 'illegal request' );
  2374. Doo::loadModel ( 'receipt' );
  2375. $receipt = new receipt ();
  2376. Doo::loadModel ( 'receiptTraining' );
  2377. $receiptTraining = new receiptTraining ();
  2378. Doo::loadModel ( 'RItem' );
  2379. $RItem = new RItem ();
  2380. Doo::loadModel ( 'accountItem' );
  2381. $accountItem = new accountItem ();
  2382. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2383. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2384. die ();
  2385. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2386. $RItemList = $RItem->getRItemByRid ( $rid,$name );
  2387. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );//print_r($aiList);
  2388. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2389. // if($value['name']=='税款'){
  2390. // unset($aiList[$key]);break;
  2391. // }
  2392. // }
  2393. //print_r($RItemList);
  2394. $data ['name'] = $name;
  2395. $data ['RItemList'] = $RItemList;
  2396. $data ['aiList'] = $aiList;
  2397. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2398. $data ['receiptDetail'] = $receiptDetail;
  2399. $data ['trainEdiType'] = "ITEM";
  2400. $data ['ridKey'] = $ridKey;
  2401. $data ['memu'] = "receipt";
  2402. $data ['staff'] = $this->staff;
  2403. $data ['receiptMemu'] = 'saeaBorad';
  2404. $data ['verifyId'] = $this->verifyId;
  2405. $data ['executeId'] = $this->executeId;
  2406. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2407. }
  2408. /**
  2409. * 添加支出项 需要修改 费用金额合计
  2410. */
  2411. function receiptTrainItemAddDo() {
  2412. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2413. // 支出项信息
  2414. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2415. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2416. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2417. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2418. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2419. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2420. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2421. Doo::loadClass ( 'XDeode' );
  2422. $XDeode = new XDeode ( 5 );
  2423. Doo::loadModel ( 'RItem' );
  2424. $RItem = new RItem ();
  2425. $rid = $XDeode->decode ( $ridKey );
  2426. if (! is_numeric ( $rid ))
  2427. die ( 'illegal request' );
  2428. if($payType=='company'){
  2429. $RItem->payType = 1;
  2430. }
  2431. $RItem->rid = $rid;
  2432. $RItem->item = $item;
  2433. $RItem->price = $price;
  2434. $RItem->date = $date;
  2435. $RItem->inputer = $inputer;
  2436. $order = array (
  2437. "\r\n",
  2438. "\n",
  2439. "\r"
  2440. );
  2441. $replace = '<br/>';
  2442. $describe = str_replace ( $order, $replace, $describe );
  2443. $RItem->describe = $describe;
  2444. $RItem->creater=$this->staff['0']['username'];
  2445. $RItem->createrId=$this->staff['0']['sid'];
  2446. $RItem->creatDate=date ( "Y-m-d H:i:s" ) ;
  2447. $RItem->insert ();
  2448. // 添加公司汇总
  2449. // 报销详情
  2450. Doo::loadModel ( 'receiptDetail' );
  2451. $receiptDetail = new receiptDetail ();
  2452. Doo::loadModel ( 'receipt' );
  2453. $receipt = new receipt ();
  2454. $rInfo = $receipt->getReceiptByRid ( $rid );
  2455. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
  2456. if (empty ( $rdInfo )) {
  2457. $receiptDetail = new receiptDetail ();
  2458. $receiptDetail->staff = $rInfo ['staff'];
  2459. $receiptDetail->item = $item;
  2460. $receiptDetail->itemCategory = '培训班费用';
  2461. $receiptDetail->price = $price;
  2462. $receiptDetail->date = date ( "Y-m-d" );
  2463. $receiptDetail->cid = $rInfo ['cid'];
  2464. $receiptDetail->rid = $rid;
  2465. $receiptDetail->status = 4;
  2466. $receiptDetail->insert ();
  2467. } else {
  2468. $receiptDetail = new receiptDetail ();
  2469. $rdInfo ['price'] += $price;
  2470. $receiptDetail->price = $rdInfo ['price'];
  2471. $receiptDetail->update ( array (
  2472. 'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'
  2473. ) );
  2474. }
  2475. //更新费用合计金额
  2476. $receipt = new receipt ();
  2477. $receipt->sum=$rInfo['sum']+ $price;
  2478. $receipt->update ( array (
  2479. 'where' => 'rid=' . $rid
  2480. ) );
  2481. //汇总金额--提交审批之后有 支出项时 需要更新汇总
  2482. if($payType=='company'){
  2483. Doo::loadModel ( "statistics" );
  2484. $statistics = new statistics ();
  2485. $dateArray = explode ( "-", $rInfo ['date'] );
  2486. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2487. $stat = $statistics->getOne ( array (
  2488. 'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,
  2489. 'asArray' => true
  2490. ) );
  2491. if (!empty($stat)){
  2492. //$statistics->agPrice = $stat ['agPrice'] + $price;
  2493. $statistics->rePrice = $stat ['rePrice'] + $price;
  2494. $statistics->update ( array (
  2495. 'where' => 'sid=' . $stat ['sid']
  2496. ) );
  2497. }
  2498. // Doo::loadModel ( "itemStatistics" );
  2499. // $itemStatistics = new itemStatistics ();
  2500. // $iStatistics = $itemStatistics->getOne ( array (
  2501. // 'where' => 'staff=' . $rInfo ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  2502. // 'asArray' => true
  2503. // ) );
  2504. // if (!empty($iStatistics)){
  2505. // $itemStatistics->price = $iStatistics ['price']+$price;
  2506. // $itemStatistics->update ( array (
  2507. // 'where' => 'sid=' . $iStatistics ['sid']
  2508. // ) );
  2509. // }
  2510. }
  2511. $XDeode = new XDeode ( 7 );
  2512. if($payType=='company'){
  2513. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2514. }else{
  2515. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2516. }
  2517. } else
  2518. die ( 'illegal request-dataError' );
  2519. }
  2520. /**
  2521. * 培训班结算-讲师
  2522. */
  2523. function receiptTrainLecturerEdi() {
  2524. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2525. Doo::loadClass ( 'XDeode' );
  2526. $XDeode = new XDeode ( 7 );
  2527. $rid = $XDeode->decode ( $ridKey );
  2528. if (! is_numeric ( $rid ))
  2529. die ( 'illegal request' );
  2530. Doo::loadModel ( 'receipt' );
  2531. $receipt = new receipt ();
  2532. Doo::loadModel ( 'receiptTraining' );
  2533. $receiptTraining = new receiptTraining ();
  2534. Doo::loadModel ( 'RILecturer' );
  2535. $RILecturer = new RILecturer ();
  2536. Doo::loadModel ( 'lecturer' );
  2537. $lecturer = new lecturer ();
  2538. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2539. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2540. die ();
  2541. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2542. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2543. $lecturerList = $lecturer->getLecturerAll ();
  2544. $INSIDEhtml = $OUTSIDEhtml = '';
  2545. foreach ( $lecturerList as $key => $value ) {
  2546. if ($value ['ltype'] == 'INSIDE') {
  2547. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2548. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2549. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2550. }
  2551. }
  2552. $data ['INSIDEhtml'] = $INSIDEhtml;
  2553. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2554. // print_r($RItemList);
  2555. $data ['RILecturerList'] = $RILecturerList;
  2556. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2557. $data ['receiptDetail'] = $receiptDetail;
  2558. $data ['trainEdiType'] = "LECTURER";
  2559. $data ['ridKey'] = $ridKey;
  2560. $data ['memu'] = "receipt";
  2561. $data ['staff'] = $this->staff;
  2562. $data ['receiptMemu'] = 'saeaBorad';
  2563. $data ['verifyId'] = $this->verifyId;
  2564. $data ['executeId'] = $this->executeId;
  2565. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2566. }
  2567. /**
  2568. * 添加讲师
  2569. */
  2570. function receiptTrainLecturerAddDo() {
  2571. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2572. // 支出项信息
  2573. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2574. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2575. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2576. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2577. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2578. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2579. Doo::loadClass ( 'XDeode' );
  2580. $XDeode = new XDeode ( 5 );
  2581. Doo::loadModel ( 'RILecturer' );
  2582. $RILecturer = new RILecturer ();
  2583. $rid = $XDeode->decode ( $ridKey );
  2584. if (! is_numeric ( $rid ))
  2585. die ( 'illegal request' );
  2586. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2587. die ( 'illegal request-taxationError' );
  2588. $RILecturer->rid = $rid;
  2589. $RILecturer->ltype = $ltype;
  2590. if ($ltype == 'OUTSIDE') {
  2591. if ($taxation == 'TAXATION') {
  2592. $RILecturer->taxation = 1;
  2593. } elseif ($taxation == 'NOTAXATION') {
  2594. $RILecturer->taxation = 0;
  2595. }
  2596. }
  2597. $RILecturer->lecturerName = $lecturerName;
  2598. $RILecturer->schoolDay = $schoolDay;
  2599. $RILecturer->price = $price;
  2600. $RILecturer->insert ();
  2601. // 添加公司汇总
  2602. // 报销详情
  2603. Doo::loadModel ( 'receiptDetail' );
  2604. $receiptDetail = new receiptDetail ();
  2605. Doo::loadModel ( 'receipt' );
  2606. $receipt = new receipt ();
  2607. // 金额总计
  2608. $price = $price * $schoolDay;
  2609. $rInfo = $receipt->getReceiptByRid ( $rid );
  2610. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2611. if (empty ( $rdInfo )) {
  2612. $receiptDetail = new receiptDetail ();
  2613. $receiptDetail->staff = $rInfo ['staff'];
  2614. $receiptDetail->item = '讲课费';
  2615. $receiptDetail->itemCategory = '培训班费用';
  2616. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2617. $receiptDetail->date = date ( "Y-m-d" );
  2618. $receiptDetail->cid = $rInfo ['cid'];
  2619. $receiptDetail->rid = $rid;
  2620. $receiptDetail->status = 4;
  2621. $receiptDetail->insert ();
  2622. } else {
  2623. $receiptDetail = new receiptDetail ();
  2624. $rdInfo ['price'] += $price;
  2625. $receiptDetail->price = $rdInfo ['price'];
  2626. $receiptDetail->update ( array (
  2627. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2628. ) );
  2629. }
  2630. $receipt = new receipt ();
  2631. $receipt->sum=$rInfo['sum']+$price;
  2632. $receipt->update ( array (
  2633. 'where' => 'rid=' . $rid
  2634. ) );
  2635. $XDeode = new XDeode ( 7 );
  2636. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2637. } else
  2638. die ( 'illegal request' );
  2639. }
  2640. /**
  2641. * 移除讲师
  2642. */
  2643. function receiptTrainLecturerDelDo() {
  2644. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2645. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2646. Doo::loadModel ( 'receipt' );
  2647. $receipt = new receipt ();
  2648. Doo::loadModel ( 'RILecturer' );
  2649. $RILecturer = new RILecturer ();
  2650. Doo::loadClass ( 'XDeode' );
  2651. $XDeode = new XDeode ( 5 );
  2652. $rid = $XDeode->decode ( $ridKey );
  2653. $rlid = $XDeode->decode ( $rlidKey );
  2654. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2655. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2656. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2657. die ( 'illegal request-status' );
  2658. }
  2659. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2660. if (empty($detail)){
  2661. die ( 'illegal request-data' );
  2662. }
  2663. $RILecturer->delete ( array (
  2664. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2665. ) );
  2666. //更新费用合计金额
  2667. $rInfo = $receipt->getReceiptByRid ( $rid );
  2668. $receipt = new receipt ();
  2669. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2670. $receipt->update ( array (
  2671. 'where' => 'rid=' . $rid
  2672. ) );
  2673. Doo::loadModel ( 'receiptDetail' );
  2674. $receiptDetail = new receiptDetail ();
  2675. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2676. $receiptDetail = new receiptDetail ();
  2677. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2678. $receiptDetail->price = $rdInfo ['price'];
  2679. $receiptDetail->update ( array (
  2680. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2681. ) );
  2682. $XDeode = new XDeode ( 7 );
  2683. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2684. } else
  2685. die ( 'illegal request-iid' );
  2686. }
  2687. /**
  2688. * 培训班提交审批
  2689. */
  2690. function receiptTrainDo() {
  2691. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2692. Doo::loadClass ( 'XDeode' );
  2693. $XDeode = new XDeode ( 7 );
  2694. $rid = $XDeode->decode ( $ridKey );
  2695. Doo::loadModel ( 'receipt' );
  2696. $receipt = new receipt ();
  2697. Doo::loadModel ( 'receiptDetail' );
  2698. $receiptDetail = new receiptDetail ();
  2699. Doo::loadModel ( 'statistics' );
  2700. $statistics = new statistics ();
  2701. Doo::loadModel ( "verify" );
  2702. $verify = new verify ();
  2703. // 审批状态的判定
  2704. $receiptDetailList = $receipt->getOne ( array (
  2705. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2706. 'asArray' => true
  2707. ) );
  2708. if (empty ( $receiptDetailList ))
  2709. return "/saeaBorad";
  2710. $verifyDetail = $verify->getOne ( array (
  2711. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2712. 'asArray' => true
  2713. ) );
  2714. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2715. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2716. $nowStaff = "";
  2717. $nowStaffList = array ();
  2718. if ($verifyDetail [0] [1] == 'ROLE') {
  2719. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2720. foreach ( $vStaffString as $key => $value ) {
  2721. $staffK = explode ( "_", $value );
  2722. array_push ( $nowStaffList, $staffK [0] );
  2723. }
  2724. $nowStaff = implode ( ',', $nowStaffList );
  2725. } else {
  2726. $nowStaff = $verifyDetail [0] [0];
  2727. }
  2728. $receipt->nowStaff = $nowStaff;
  2729. }
  2730. // echo $nowStaff;
  2731. // print_r($verifyDetail);die;
  2732. $receipt->rid = $receiptDetailList ['rid'];
  2733. $receipt->date = date ( "Y-m-d" );
  2734. $receipt->status = 2;
  2735. $receipt->update ();
  2736. $receiptDetail->status = 2;
  2737. $receiptDetail->update ( array (
  2738. 'where' => 'rid=' . $receiptDetailList ['rid']
  2739. ) );
  2740. Doo::loadModel ( "receiptLog" );
  2741. $receiptLog = new receiptLog ();
  2742. Doo::loadModel ( "verify" );
  2743. $verify = new verify ();
  2744. $vr = $verify->getOne ( array (
  2745. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2746. 'asArray' => true
  2747. ) );
  2748. $jd = json_decode ( $vr ['staff'] );
  2749. $roleId = 0;
  2750. foreach ( $jd as $key => $value ) {
  2751. if ($value [1] == 'ROLE') {
  2752. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2753. if ($pos !== false) {
  2754. $roleId = $value [0];
  2755. }
  2756. }
  2757. }
  2758. // 审批日志
  2759. // echo $roleId;die;
  2760. if (! empty ( $roleId )) {
  2761. Doo::loadModel ( "role" );
  2762. $role = new role ();
  2763. $roleInfo = $role->getOne ( array (
  2764. 'where' => 'rid=' . $roleId,
  2765. 'asArray' => true
  2766. ) );
  2767. // $receiptLog->rolename = $roleInfo ['name'];
  2768. }
  2769. $receiptLog->username = $this->staff [0] ['username'];
  2770. $receiptLog->uid = $this->staff [0] ['sid'];
  2771. $receiptLog->date = date ( "Y-m-d" );
  2772. $receiptLog->opinion = '提交审批';
  2773. $receiptLog->img = $this->staff [0] ['avatar'];
  2774. $receiptLog->status = 2;
  2775. $receiptLog->rid = $rid;
  2776. $receiptLog->insert ();
  2777. // 写入列表项
  2778. Doo::loadModel ( 'accountItem' );
  2779. $accountItem = new accountItem ();
  2780. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2781. // 项目金额合计
  2782. Doo::loadModel ( 'RItem' );
  2783. $RItem = new RItem ();
  2784. // 讲师获得
  2785. Doo::loadModel ( 'RILecturer' );
  2786. $RILecturer = new RILecturer ();
  2787. $RItemList = $RItem->getRItemByRid ( $rid );
  2788. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2789. // 支出项金额详情
  2790. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2791. // print_r($aItem);
  2792. // print_r($aiData);
  2793. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2794. $ag = $tr = $ta = $ot = 0;
  2795. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2796. foreach ( $aItem as $key => $value ) {
  2797. if ($value ['category'] == $this->TRAIN) {
  2798. foreach ( $aiData ['dataList'] as $k => $v ) {
  2799. if ($value ['name'] == $v ['name']) {
  2800. array_push ( $accountJson [$this->TRAIN], array (
  2801. 'aid' => $value ['aid'],
  2802. 'name' => $value ['name'],
  2803. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2804. ) );
  2805. $sum += $v ['price'];
  2806. $trainSum += $v ['price'];
  2807. unset ( $aiData ['dataList'] [$k] );
  2808. break;
  2809. }
  2810. }
  2811. }
  2812. }
  2813. $accountJson ['cSum'] = array (
  2814. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2815. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2816. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2817. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2818. );
  2819. // 报销单
  2820. $receipt = new receipt ();
  2821. $receipt->accountItem = json_encode ( $accountJson );
  2822. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2823. $receipt->update ( array (
  2824. 'where' => 'rid=' . $rid
  2825. ) );
  2826. // print_r($accountJson);
  2827. // statistics item 统计写入
  2828. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2829. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2830. $accountItem = $accountJson;
  2831. $stat = $statistics->getOne ( array (
  2832. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2833. 'asArray' => true
  2834. ) );
  2835. if (empty ( $stat )) {
  2836. $statistics->date = date ( "Y-m-d" );
  2837. $statistics->cid = $this->staff [0] ['cid'];
  2838. $statistics->staff = $this->staff [0] ['sid'];
  2839. $statistics->agPrice = 0;
  2840. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2841. $statistics->insert ();
  2842. } else {
  2843. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2844. $statistics->update ( array (
  2845. 'where' => 'sid=' . $stat ['sid']
  2846. ) );
  2847. }
  2848. return "/saeaBorad";
  2849. }
  2850. function confirmation() {
  2851. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2852. Doo::loadModel ( 'receipt' );
  2853. Doo::loadModel ( 'receiptDetail' );
  2854. $receipt = new receipt ();
  2855. $receiptDetail = new receiptDetail ();
  2856. Doo::loadModel ( 'statistics' );
  2857. Doo::loadModel ( 'itemStatistics' );
  2858. $statistics = new statistics ();
  2859. $itemStatistics = new itemStatistics ();
  2860. Doo::loadModel ( "verify" );
  2861. $verify = new verify ();
  2862. $receiptDetailList = $receipt->getOne ( array (
  2863. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2864. 'asArray' => true
  2865. ) );
  2866. if (empty ( $receiptDetailList ))
  2867. return "/saeaBorad";
  2868. $verifyDetail = $verify->getOne ( array (
  2869. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2870. 'asArray' => true
  2871. ) );
  2872. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2873. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2874. $nowStaff = "";
  2875. $nowStaffList = array ();
  2876. if ($verifyDetail [0] [1] == 'ROLE') {
  2877. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2878. foreach ( $vStaffString as $key => $value ) {
  2879. $staffK = explode ( "_", $value );
  2880. array_push ( $nowStaffList, $staffK [0] );
  2881. }
  2882. $nowStaff = implode ( ',', $nowStaffList );
  2883. } else {
  2884. $nowStaff = $verifyDetail [0] [0];
  2885. }
  2886. $receipt->nowStaff = $nowStaff;
  2887. }
  2888. // echo $nowStaff;
  2889. // print_r($verifyDetail);die;
  2890. $receipt->rid = $receiptDetailList ['rid'];
  2891. $receipt->status = 2;
  2892. $receipt->update ();
  2893. // 操作日志
  2894. Doo::loadModel ( "receiptLog" );
  2895. $receiptLog = new receiptLog ();
  2896. $verify = new verify ();
  2897. $receiptInfo = $receipt->getOne ( array (
  2898. 'where' => 'rid=' . $rid,
  2899. 'asArray' => true
  2900. ) );
  2901. $vr = $verify->getOne ( array (
  2902. 'where' => 'vid=' . $receiptInfo ['verify'],
  2903. 'asArray' => true
  2904. ) );
  2905. $jd = json_decode ( $vr ['staff'] );
  2906. $roleId = 0;
  2907. foreach ( $jd as $key => $value ) {
  2908. if ($value [1] == 'ROLE') {
  2909. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2910. if ($pos !== false) {
  2911. $roleId = $value [0];
  2912. }
  2913. }
  2914. }
  2915. // 审批日志
  2916. // echo $roleId;die;
  2917. if (! empty ( $roleId )) {
  2918. Doo::loadModel ( "role" );
  2919. $role = new role ();
  2920. $roleInfo = $role->getOne ( array (
  2921. 'where' => 'rid=' . $roleId,
  2922. 'asArray' => true
  2923. ) );
  2924. // $receiptLog->rolename = $roleInfo ['name'];
  2925. }
  2926. $receiptLog->username = $this->staff [0] ['username'];
  2927. $receiptLog->uid = $this->staff [0] ['sid'];
  2928. $receiptLog->date = date ( "Y-m-d" );
  2929. $receiptLog->opinion = '提交审批';
  2930. $receiptLog->img = $this->staff [0] ['avatar'];
  2931. $receiptLog->status = 2;
  2932. $receiptLog->rid = $rid;
  2933. $receiptLog->insert ();
  2934. return "/expenses";
  2935. }
  2936. function expenses() {
  2937. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2938. if (empty ( $item ))
  2939. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2940. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2941. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2942. Doo::loadClass ( 'XDeode' );
  2943. $XDeode = new XDeode ( 7 );
  2944. Doo::loadModel ( 'receipt' );
  2945. $receipt = new receipt ();
  2946. Doo::loadModel ( 'L_category' );
  2947. $Lcategory = new L_category ();
  2948. Doo::loadModel ( 'verify' );
  2949. Doo::loadModel ( 'statistics' );
  2950. $statistics = new statistics ();
  2951. $verify = new verify ();
  2952. Doo::loadModel ( 'staff' );
  2953. $staff = new staff ();
  2954. $condition = "";
  2955. if ($item == "expenses")
  2956. $condition = " and Rtype=1 ";
  2957. elseif ($item == "receipts")
  2958. $condition = " and Rtype=0 ";
  2959. elseif ($item == "remits")
  2960. $condition = " and Rtype=2 ";
  2961. elseif ($item == "train")
  2962. $condition = " and Rtype=3 ";
  2963. $dateCondition = " and Year(date) =" . $year;
  2964. if (! empty ( $moth )) {
  2965. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  2966. $stList = $statistics->getOne ( array (
  2967. 'select' => 'rePrice ,agPrice',
  2968. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2969. 'asArray' => true
  2970. ) );
  2971. } else
  2972. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  2973. if (empty ( $stList ))
  2974. $stList = array (
  2975. 'rePrice' => 0,
  2976. 'agPrice' => 0
  2977. );
  2978. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  2979. if (! isset ( $noPassSum ['sum'] ))
  2980. $noPassSum ['sum'] = 0;
  2981. $data ['stList'] = array (
  2982. 'rePrice' => $stList ['rePrice'],
  2983. 'agPrice' => $stList ['agPrice'],
  2984. 'skPrice' => ($noPassSum ['sum'])
  2985. );
  2986. $receiptList = $receipt->find ( array (
  2987. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  2988. 'desc' => 'rid',
  2989. 'asArray' => true
  2990. ) );
  2991. $Locate = 0;
  2992. $roleId = 0;
  2993. $button = 0;
  2994. foreach ( $receiptList as $key => $value ) {
  2995. $receiptList [$key] ['Locate'] = $Locate;
  2996. $Locate ++;
  2997. $receiptList [$key] ['reviseDetail'] = array ();
  2998. if (! empty ( $value ['reviseDetail'] ))
  2999. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3000. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3001. $categoryDetil = $Lcategory->getOne ( array (
  3002. 'where' => 'cid=' . $value ['cid'],
  3003. 'asArray' => true
  3004. ) );
  3005. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3006. // 检测编辑状态
  3007. $verifyList = $verify->getOne ( array (
  3008. 'where' => 'vid=' . $value ['verify'],
  3009. 'asArray' => true
  3010. ) );
  3011. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3012. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3013. Doo::loadModel ( 'role' );
  3014. $role = new role ();
  3015. $flag = true;
  3016. $roleKey = 0;
  3017. $endStaffArray = array ();
  3018. $roleArrayCopy = array ();
  3019. foreach ( $verifyList as $k => $v ) {
  3020. // init verifyStaff
  3021. if ($v [1] == 'ROLE') {
  3022. if (! empty ( $verifyStaff )) {
  3023. $endStaffArray = end ( $verifyStaff );
  3024. // if ($v[0]==$endStaffArray['nextStaff']){
  3025. // $roleId=$v[0];
  3026. // }
  3027. }
  3028. $roleVerify = json_decode ( $v [3], true );
  3029. $roleKey = $k;
  3030. $roleArray = array ();
  3031. $rolename = $role->getOne ( array (
  3032. 'where' => 'rid=' . $v [0],
  3033. 'asArray' => true
  3034. ) );
  3035. foreach ( $roleVerify as $o => $p ) {
  3036. $staffID = explode ( '_', $p );
  3037. $staffInfo = $staff->getOne ( array (
  3038. 'where' => 'sid=' . $staffID [0],
  3039. 'asArray' => true
  3040. ) );
  3041. // print_r($staffID);
  3042. $exp = array (
  3043. 0 => $staffInfo ['sid'],
  3044. 1 => $staffID [1],
  3045. 2 => $staffInfo ['avatar'],
  3046. 'date' => '',
  3047. 'date' => '',
  3048. 'opinion' => '',
  3049. 'status' => '',
  3050. 'rolename' => $rolename ['name']
  3051. );
  3052. array_push ( $roleArray, $exp );
  3053. }
  3054. $roleArrayCopy [$v [0]] = $roleArray;
  3055. // $verifyList[$k]['roleArray']=$roleArray;
  3056. }
  3057. $verifyList [$k] ['date'] = "";
  3058. $verifyList [$k] ['opinion'] = "";
  3059. $verifyList [$k] ['status'] = "";
  3060. if (empty ( $verifyStaff )) {
  3061. $verifyList [$k] ['date'] = "";
  3062. $verifyList [$k] ['opinion'] = "";
  3063. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3064. $verifyList [$k] ['status'] = 4;
  3065. $flag = false;
  3066. }
  3067. } else {
  3068. foreach ( $verifyStaff as $m => $u ) {
  3069. if ($v [0] == $m) {
  3070. $verifyList [$k] ['date'] = $u ['date'];
  3071. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3072. $verifyList [$k] ['status'] = $u ['status'];
  3073. $flag = false;
  3074. break;
  3075. }
  3076. }
  3077. $endStaffArray = end ( $verifyStaff );
  3078. if (isset ( $endStaffArray ['ROLE'] )) {
  3079. } else {
  3080. // $endKey=key($verifyStaff);
  3081. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3082. // $button=4;
  3083. // $verifyList[$k]['status']=4;
  3084. // }
  3085. }
  3086. }
  3087. }
  3088. $rolename ['name'] = '';
  3089. if (! empty ( $roleId )) {
  3090. Doo::loadModel ( 'role' );
  3091. $role = new role ();
  3092. $rolename = $role->getOne ( array (
  3093. 'where' => 'rid=' . $roleId,
  3094. 'asArray' => true
  3095. ) );
  3096. }
  3097. if (! empty ( $verifyStaff ))
  3098. $endStaffArray = end ( $verifyStaff );
  3099. $KOP = false;
  3100. foreach ( $roleArrayCopy as $P => $A ) {
  3101. foreach ( $A as $MKI => $AVL ) {
  3102. if (! empty ( $verifyStaff )) {
  3103. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3104. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3105. $button = 4;
  3106. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3107. }
  3108. foreach ( $verifyStaff as $m => $u ) {
  3109. $AVLFK = $AVL [0] . '_R';
  3110. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3111. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3112. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3113. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3114. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3115. break;
  3116. }
  3117. }
  3118. } else {
  3119. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3120. $button = 4;
  3121. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3122. }
  3123. }
  3124. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3125. $KOP = true;
  3126. }
  3127. }
  3128. foreach ( $roleArrayCopy as $k => $v ) {
  3129. foreach ( $verifyList as $m => $n ) {
  3130. if ($n [0] == $k) {
  3131. array_splice ( $verifyList, $m, 1, $v );
  3132. }
  3133. }
  3134. }
  3135. $receiptList [$key] ['verifyList'] = $verifyList;
  3136. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3137. 'where' => 'sid=' . $value ['staff'],
  3138. 'asArray' => true
  3139. ) );
  3140. $receiptList [$key] ['button'] = $button;
  3141. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3142. }
  3143. // print_r($receiptList);die;
  3144. $mothHtml = "";
  3145. for($i = 1; $i <= 12; $i ++) {
  3146. if ($moth == $i)
  3147. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3148. else
  3149. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3150. }
  3151. $dateHtml = "";
  3152. $now = date ( "Y" );
  3153. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3154. if ($YEARD <= $now) {
  3155. $dateHtml .= '<option ';
  3156. if ($year == $YEARD) {
  3157. $dateHtml .= 'selected ';
  3158. }
  3159. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3160. }
  3161. }
  3162. $data ['dateHtml'] = $dateHtml;
  3163. $data ['mothHtml'] = $mothHtml;
  3164. $data ['receiptList'] = $receiptList;
  3165. $data ['memu'] = "receipt";
  3166. $data ['staff'] = $this->staff;
  3167. $data ['receiptMemu'] = 'expenses';
  3168. $data ['verifyId'] = $this->verifyId;
  3169. $data ['executeId'] = $this->executeId;
  3170. $data ['item'] = $item;
  3171. $data ['year'] = $year;
  3172. $this->render ( "/admin/expenses", $data );
  3173. }
  3174. function expensesCollect() {
  3175. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3176. Doo::loadModel ( 'receipt' );
  3177. $receipt = new receipt ();
  3178. Doo::loadModel ( 'L_category' );
  3179. $Lcategory = new L_category ();
  3180. Doo::loadModel ( 'verify' );
  3181. Doo::loadModel ( 'statistics' );
  3182. $statistics = new statistics ();
  3183. $verify = new verify ();
  3184. Doo::loadModel ( 'staff' );
  3185. $staff = new staff ();
  3186. Doo::loadModel ( 'loanReceipt' );
  3187. $loanReceipt = new loanReceipt ();
  3188. $receiptList = $receipt->find ( array (//去掉
  3189. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3190. 'desc' => 'rid',
  3191. 'asArray' => true
  3192. ) );
  3193. $loanList = $loanReceipt->find ( array (
  3194. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3195. 'desc' => 'rid',
  3196. 'asArray' => true
  3197. ) );
  3198. /*
  3199. * $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;
  3200. */
  3201. $data ['explanation'] = '';
  3202. if (! empty ( $loanList ))
  3203. $data ['explanation'] = $loanList [0] ['explanation'];
  3204. $Locate = 0;
  3205. $roleId = 0;
  3206. $button = 0;
  3207. foreach ( $receiptList as $key => $value ) {
  3208. $receiptList [$key] ['Locate'] = $Locate;
  3209. $Locate ++;
  3210. $receiptList [$key] ['reviseDetail'] = array ();
  3211. if (! empty ( $value ['reviseDetail'] ))
  3212. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3213. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3214. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3215. $categoryDetil = $Lcategory->getOne ( array (
  3216. 'where' => 'cid=' . $value ['cid'],
  3217. 'asArray' => true
  3218. ) );
  3219. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3220. // 检测编辑状态
  3221. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3222. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3223. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3224. else
  3225. $verifyList ['staff'] = $value ['verifyBreakup'];
  3226. } else
  3227. $verifyList = $verify->getOne ( array (
  3228. 'where' => 'vid=' . $value ['verify'],
  3229. 'asArray' => true
  3230. ) );
  3231. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3232. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3233. Doo::loadModel ( 'role' );
  3234. $role = new role ();
  3235. $flag = true;
  3236. $roleKey = 0;
  3237. $endStaffArray = array ();
  3238. $roleArrayCopy = array ();
  3239. foreach ( $verifyList as $k => $v ) {
  3240. // init verifyStaff
  3241. if ($v [1] == 'ROLE') {
  3242. if (! empty ( $verifyStaff )) {
  3243. $endStaffArray = end ( $verifyStaff );
  3244. // if ($v[0]==$endStaffArray['nextStaff']){
  3245. // $roleId=$v[0];
  3246. // }
  3247. }
  3248. $roleVerify = json_decode ( $v [3], true );
  3249. $roleKey = $k;
  3250. $roleArray = array ();
  3251. $rolename = $role->getOne ( array (
  3252. 'where' => 'rid=' . $v [0],
  3253. 'asArray' => true
  3254. ) );
  3255. foreach ( $roleVerify as $o => $p ) {
  3256. $staffID = explode ( '_', $p );
  3257. $staffInfo = $staff->getOne ( array (
  3258. 'where' => 'sid=' . $staffID [0],
  3259. 'asArray' => true
  3260. ) );
  3261. // print_r($staffID);
  3262. $exp = array (
  3263. 0 => $staffInfo ['sid'],
  3264. 1 => $staffID [1],
  3265. 2 => $staffInfo ['avatar'],
  3266. 'date' => '',
  3267. 'date' => '',
  3268. 'opinion' => '',
  3269. 'status' => '',
  3270. 'rolename' => $rolename ['name']
  3271. );
  3272. array_push ( $roleArray, $exp );
  3273. }
  3274. $roleArrayCopy [$v [0]] = $roleArray;
  3275. // $verifyList[$k]['roleArray']=$roleArray;
  3276. }
  3277. $verifyList [$k] ['date'] = "";
  3278. $verifyList [$k] ['opinion'] = "";
  3279. $verifyList [$k] ['status'] = "";
  3280. if (empty ( $verifyStaff )) {
  3281. $verifyList [$k] ['date'] = "";
  3282. $verifyList [$k] ['opinion'] = "";
  3283. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3284. $verifyList [$k] ['status'] = 4;
  3285. $flag = false;
  3286. }
  3287. } else {
  3288. foreach ( $verifyStaff as $m => $u ) {
  3289. if ($v [0] == $m) {
  3290. $verifyList [$k] ['date'] = $u ['date'];
  3291. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3292. $verifyList [$k] ['status'] = $u ['status'];
  3293. $flag = false;
  3294. break;
  3295. }
  3296. }
  3297. $endStaffArray = end ( $verifyStaff );
  3298. if (isset ( $endStaffArray ['ROLE'] )) {
  3299. } else {
  3300. // $endKey=key($verifyStaff);
  3301. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3302. // $button=4;
  3303. // $verifyList[$k]['status']=4;
  3304. // }
  3305. }
  3306. }
  3307. }
  3308. $rolename ['name'] = '';
  3309. if (! empty ( $roleId )) {
  3310. Doo::loadModel ( 'role' );
  3311. $role = new role ();
  3312. $rolename = $role->getOne ( array (
  3313. 'where' => 'rid=' . $roleId,
  3314. 'asArray' => true
  3315. ) );
  3316. }
  3317. if (! empty ( $verifyStaff ))
  3318. $endStaffArray = end ( $verifyStaff );
  3319. $KOP = false;
  3320. foreach ( $roleArrayCopy as $P => $A ) {
  3321. foreach ( $A as $MKI => $AVL ) {
  3322. if (! empty ( $verifyStaff )) {
  3323. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3324. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3325. $button = 4;
  3326. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3327. }
  3328. foreach ( $verifyStaff as $m => $u ) {
  3329. $AVLFK = $AVL [0] . '_R';
  3330. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3331. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3332. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3333. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3334. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3335. break;
  3336. }
  3337. }
  3338. } else {
  3339. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3340. $button = 4;
  3341. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3342. }
  3343. }
  3344. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3345. $KOP = true;
  3346. }
  3347. }
  3348. foreach ( $roleArrayCopy as $k => $v ) {
  3349. foreach ( $verifyList as $m => $n ) {
  3350. if ($n [0] == $k) {
  3351. array_splice ( $verifyList, $m, 1, $v );
  3352. }
  3353. }
  3354. }
  3355. // 费用执行人相关数据
  3356. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3357. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3358. foreach ( $executeCopy as $k => $v ) {
  3359. $executeCopy [$k] ['date'] = '';
  3360. $executeCopy [$k] ['opinion'] = '';
  3361. $executeCopy [$k] ['status'] = '';
  3362. if (! empty ( $executeStaff ))
  3363. foreach ( $executeStaff as $m => $u ) {
  3364. if ($v [0] == $m) {
  3365. $executeCopy [$k] ['date'] = $u ['date'];
  3366. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3367. $executeCopy [$k] ['status'] = $u ['status'];
  3368. break;
  3369. }
  3370. }
  3371. }
  3372. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3373. $receiptList [$key] ['verifyList'] = $verifyList;
  3374. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3375. 'where' => 'sid=' . $value ['staff'],
  3376. 'asArray' => true
  3377. ) );
  3378. $receiptList [$key] ['button'] = $button;
  3379. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3380. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3381. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3382. $receiptList [$key] ['relust'] = $relust;
  3383. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3384. }
  3385. Doo::loadModel ( 'enclosur' );
  3386. $enclosur = new enclosur ();
  3387. $enclosurList = $enclosur->find ( array (
  3388. 'where' => 'rid=' . $rid,
  3389. 'asArray' => true
  3390. ) );
  3391. $enclosurHtml = '';
  3392. foreach ( $enclosurList as $value ) {
  3393. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3394. }
  3395. $data ['enclosurHtml'] = $enclosurHtml;
  3396. // print_r($receiptList);
  3397. $data ['receiptList'] = $receiptList;
  3398. $data ['memu'] = "receipt";
  3399. $data ['staff'] = $this->staff;
  3400. $data ['receiptMemu'] = 'expenses';
  3401. $data ['verifyId'] = $this->verifyId;
  3402. $data ['executeId'] = $this->executeId;
  3403. $this->render ( "/admin/expensesCollect", $data );
  3404. }
  3405. function approvalExpenses() {
  3406. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3407. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3408. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3409. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3410. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3411. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3412. // echo $rdate;
  3413. if (empty ( $status ))
  3414. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3415. $page_size = 8;
  3416. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3417. $vidList = array ();
  3418. $button = 0;
  3419. Doo::loadModel ( 'verify' );
  3420. $verify = new verify ();
  3421. Doo::loadModel ( 'receipt' );
  3422. $receipt = new receipt ();
  3423. Doo::loadModel ( 'staff' );
  3424. $staff = new staff ();
  3425. Doo::loadModel ( 'L_category' );
  3426. $Lcategory = new L_category ();
  3427. // user verify ID
  3428. $verifyDetail = $verify->find ( array (
  3429. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3430. 'asArray' => true
  3431. ) );
  3432. foreach ( $verifyDetail as $key => $value ) {
  3433. array_push ( $vidList, $value ['vid'] );
  3434. }
  3435. $vid = implode ( ",", $vidList );
  3436. if (empty ( $verifyDetail ))
  3437. $vid = 0;
  3438. // if ($status==0)
  3439. // $dateCondition="";
  3440. // else
  3441. $dateCondition = " ";
  3442. // if (! empty ( $month ))
  3443. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3444. if ($status == 'done' || $status == 'termination') {
  3445. if (! empty ( $year )) {
  3446. $dateCondition = " and Year(pastDate) =" . $year;
  3447. if (! empty ( $month ))
  3448. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3449. }
  3450. } elseif ($status == 'finish') {
  3451. if (! empty ( $year )) {
  3452. $dateCondition = " and Year(pastDate) =" . $year;
  3453. if (! empty ( $month ))
  3454. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3455. }
  3456. }
  3457. // date ( 'Y-m' )
  3458. // if (! empty ( $rdate ) && $status == 'done')
  3459. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3460. // elseif (! empty ( $rdate ))
  3461. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3462. $categoryList = $Lcategory->find ( array (
  3463. 'asArray' => true
  3464. ) );
  3465. $staffList = $staff->find ( array (
  3466. 'where' => 'cid=' . $cid,
  3467. 'asArray' => true
  3468. ) );
  3469. $cateCondition = "";
  3470. $staffCondition = "";
  3471. $approvalCondition = "";
  3472. if (! empty ( $cid )) {
  3473. $cateCondition = ' and cid=' . $cid;
  3474. }
  3475. if (! empty ( $sid )) {
  3476. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3477. $cateCondition = "";
  3478. }
  3479. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3480. if ($status == 'pendApproval') {
  3481. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3482. }
  3483. if ($status == 'ongoing') {
  3484. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3485. }
  3486. if ($status == 'done') {
  3487. $approvalCondition = ' and (status=8 or status=9 ) ';
  3488. }
  3489. if ($status == 'termination') {
  3490. $approvalCondition = " and status=3";
  3491. }
  3492. if ($status == 'finish') {
  3493. $approvalCondition = " and (status=1 or status=8 or status=9)";
  3494. }
  3495. $pageinfo ['page'] = array (
  3496. 'previous' => ''
  3497. );
  3498. if(!empty($receiptOrder)){
  3499. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3500. $receiptList = $receipt->find ( array ( // $dateCondition
  3501. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3502. 'desc' => 'rid',
  3503. 'asArray' => true
  3504. ) );
  3505. }else{
  3506. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3507. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3508. $receiptList = $receipt->find ( array ( // $dateCondition.
  3509. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3510. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3511. 'desc' => 'rid',
  3512. 'asArray' => true
  3513. ) );
  3514. } else {
  3515. $receiptList = $receipt->find ( array ( // $dateCondition
  3516. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3517. 'desc' => 'rid',
  3518. 'asArray' => true
  3519. ) );
  3520. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3521. }
  3522. }
  3523. $rLRes = $receipt->find ( array (
  3524. '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 . ')',
  3525. 'desc' => 'rid',
  3526. 'asArray' => true
  3527. ) );
  3528. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3529. // print_r($receiptList);
  3530. Doo::loadClass ( 'XDeode' );
  3531. $XDeode = new XDeode ( 7 );
  3532. $Locate = 0;
  3533. $reportList = $reportCateList = array ();
  3534. foreach ( $receiptList as $key => $value ) {
  3535. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3536. $receiptList [$key] ['Locate'] = $Locate;
  3537. $Locate ++;
  3538. $receiptList [$key] ['reviseDetail'] = array ();
  3539. if (! empty ( $value ['reviseDetail'] ))
  3540. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3541. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3542. $categoryDetil = $Lcategory->getOne ( array (
  3543. 'where' => 'cid=' . $value ['cid'],
  3544. 'asArray' => true
  3545. ) );
  3546. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3547. $verifyList = $verify->getOne ( array (
  3548. 'where' => 'vid=' . $value ['verify'],
  3549. 'asArray' => true
  3550. ) );
  3551. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3552. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3553. foreach ( $verifyList as $k => $v ) {
  3554. // init verifyStaff
  3555. $verifyList [$k] ['date'] = "";
  3556. $verifyList [$k] ['opinion'] = "";
  3557. $verifyList [$k] ['status'] = "";
  3558. if (empty ( $verifyStaff )) {
  3559. $verifyList [$k] ['date'] = "";
  3560. $verifyList [$k] ['opinion'] = "";
  3561. if ($v [0] == $this->staff [0] ['sid']) {
  3562. $verifyList [$k] ['status'] = 4;
  3563. $button = 4;
  3564. }
  3565. } else {
  3566. $flag = true;
  3567. foreach ( $verifyStaff as $m => $u ) {
  3568. if ($v [0] == $m) {
  3569. $verifyList [$k] ['date'] = $u ['date'];
  3570. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3571. $verifyList [$k] ['status'] = $u ['status'];
  3572. $flag = false;
  3573. break;
  3574. }
  3575. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3576. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3577. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3578. }
  3579. if ($flag) { // 检测可编辑
  3580. if ($v [0] == $this->staff [0] ['sid']) {
  3581. $verifyList [$k] ['status'] = 4;
  3582. $button = 4;
  3583. }
  3584. }
  3585. }
  3586. }
  3587. $receiptList [$key] ['verifyList'] = $verifyList;
  3588. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3589. 'where' => 'sid=' . $value ['staff'],
  3590. 'asArray' => true
  3591. ) );
  3592. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3593. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3594. $receiptList [$key] ['button'] = $button;
  3595. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3596. }
  3597. $reportList = array_unique ( $reportList );
  3598. $reportHtml = '';
  3599. foreach ( $reportList as $key => $value ) {
  3600. $v = explode ( "-", $value );
  3601. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3602. }
  3603. // print_r($reportList)
  3604. $data ['reportHtml'] = $reportHtml;
  3605. $reportCateList = array_unique ( $reportCateList );
  3606. $reportCateHtml = '';
  3607. foreach ( $reportCateList as $key => $value ) {
  3608. $v = explode ( "-", $value );
  3609. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3610. }
  3611. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3612. $data ['reportCateHtml'] = $reportCateHtml;
  3613. // print_r($receiptList);die;
  3614. // $data['verifyDetail']=$verifyDetail;
  3615. $mothHtml = "";
  3616. for($i = 1; $i <= 12; $i ++) {
  3617. if ($month == $i)
  3618. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3619. else
  3620. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3621. }
  3622. $data ['mothHtml'] = $mothHtml;
  3623. $dateHtml = "";
  3624. $now = date ( "Y" );
  3625. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3626. if ($YEARD <= $now) {
  3627. $dateHtml .= '<option ';
  3628. if ($year == $YEARD) {
  3629. $dateHtml .= 'selected ';
  3630. }
  3631. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3632. }
  3633. }
  3634. $data ['dateHtml'] = $dateHtml;
  3635. $data ['page'] = $pageinfo;
  3636. $data ['receiptList'] = $receiptList;
  3637. $data ['receiptApprovalCount'] = count ( $rLRes );
  3638. $data ['status'] = $status;
  3639. $data ['year'] = $year;
  3640. $data ['month'] = $month;
  3641. $data ['categoryList'] = $categoryList;
  3642. $data ['staffList'] = $staffList;
  3643. $data ['cid'] = $cid;
  3644. $data ['sid'] = $sid;
  3645. // print_r($receiptList);
  3646. $data['receiptOrder']=$receiptOrder;
  3647. $data ['memu'] = "receipt";
  3648. $data ['staff'] = $this->staff;
  3649. $data ['receiptMemu'] = 'approvalExpenses';
  3650. $data ['verifyId'] = $this->verifyId;
  3651. $data ['executeId'] = $this->executeId;
  3652. $this->render ( "/admin/approvalExpenses", $data );
  3653. }
  3654. function expensesDoc() {
  3655. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3656. Doo::loadClass ( 'XDeode' );
  3657. $XDeode = new XDeode ( 5 );
  3658. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3659. $rid = $XDeode->decode ( $rid );
  3660. if (! is_numeric ( $rid ))
  3661. die ( 'illegal request' );
  3662. Doo::loadModel ( 'receipt' );
  3663. $receipt = new receipt ();
  3664. Doo::loadModel ( 'L_category' );
  3665. $Lcategory = new L_category ();
  3666. Doo::loadModel ( 'verify' );
  3667. Doo::loadModel ( 'statistics' );
  3668. $statistics = new statistics ();
  3669. $verify = new verify ();
  3670. Doo::loadModel ( 'staff' );
  3671. $staff = new staff ();
  3672. Doo::loadModel ( 'loanReceipt' );
  3673. $loanReceipt = new loanReceipt ();
  3674. $receiptList = $receipt->find ( array (
  3675. 'where' => ' rid=' . $rid,
  3676. 'desc' => 'rid',
  3677. 'asArray' => true
  3678. ) );
  3679. $loanList = array ();
  3680. if (! empty ( $receiptList ))
  3681. $loanList = $loanReceipt->find ( array (
  3682. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3683. 'desc' => 'rid',
  3684. 'asArray' => true
  3685. ) );
  3686. $Locate = 0;
  3687. $roleId = 0;
  3688. $button = 0;
  3689. foreach ( $loanList as $key => $value ) {
  3690. $loanList [$key] ['Locate'] = $Locate;
  3691. $Locate ++;
  3692. $loanList [$key] ['reviseDetail'] = array ();
  3693. if (! empty ( $value ['reviseDetail'] ))
  3694. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3695. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3696. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3697. $categoryDetil = $Lcategory->getOne ( array (
  3698. 'where' => 'cid=' . $value ['cid'],
  3699. 'asArray' => true
  3700. ) );
  3701. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3702. // 检测编辑状态
  3703. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3704. $verifyList ['staff'] = $value ['verifyBreakup'];
  3705. else
  3706. $verifyList = $verify->getOne ( array (
  3707. 'where' => 'vid=' . $value ['verify'],
  3708. 'asArray' => true
  3709. ) );
  3710. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3711. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3712. Doo::loadModel ( 'role' );
  3713. $role = new role ();
  3714. $flag = true;
  3715. $roleKey = 0;
  3716. $endStaffArray = array ();
  3717. $roleArrayCopy = array ();
  3718. foreach ( $verifyList as $k => $v ) {
  3719. // init verifyStaff
  3720. if ($v [1] == 'ROLE') {
  3721. if (! empty ( $verifyStaff )) {
  3722. $endStaffArray = end ( $verifyStaff );
  3723. // if ($v[0]==$endStaffArray['nextStaff']){
  3724. // $roleId=$v[0];
  3725. // }
  3726. }
  3727. $roleVerify = json_decode ( $v [3], true );
  3728. $roleKey = $k;
  3729. $roleArray = array ();
  3730. $rolename = $role->getOne ( array (
  3731. 'where' => 'rid=' . $v [0],
  3732. 'asArray' => true
  3733. ) );
  3734. foreach ( $roleVerify as $o => $p ) {
  3735. $staffID = explode ( '_', $p );
  3736. $staffInfo = $staff->getOne ( array (
  3737. 'where' => 'sid=' . $staffID [0],
  3738. 'asArray' => true
  3739. ) );
  3740. // print_r($staffID);
  3741. $exp = array (
  3742. 0 => $staffInfo ['sid'],
  3743. 1 => $staffID [1],
  3744. 2 => $staffInfo ['avatar'],
  3745. 'date' => '',
  3746. 'date' => '',
  3747. 'opinion' => '',
  3748. 'status' => '',
  3749. 'rolename' => $rolename ['name']
  3750. );
  3751. array_push ( $roleArray, $exp );
  3752. }
  3753. $roleArrayCopy [$v [0]] = $roleArray;
  3754. // $verifyList[$k]['roleArray']=$roleArray;
  3755. }
  3756. $verifyList [$k] ['date'] = "";
  3757. $verifyList [$k] ['opinion'] = "";
  3758. $verifyList [$k] ['status'] = "";
  3759. if (empty ( $verifyStaff )) {
  3760. $verifyList [$k] ['date'] = "";
  3761. $verifyList [$k] ['opinion'] = "";
  3762. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3763. $verifyList [$k] ['status'] = 4;
  3764. $flag = false;
  3765. }
  3766. } else {
  3767. foreach ( $verifyStaff as $m => $u ) {
  3768. if ($v [0] == $m) {
  3769. $verifyList [$k] ['date'] = $u ['date'];
  3770. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3771. $verifyList [$k] ['status'] = $u ['status'];
  3772. $flag = false;
  3773. break;
  3774. }
  3775. }
  3776. $endStaffArray = end ( $verifyStaff );
  3777. if (isset ( $endStaffArray ['ROLE'] )) {
  3778. } else {
  3779. // $endKey=key($verifyStaff);
  3780. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3781. // $button=4;
  3782. // $verifyList[$k]['status']=4;
  3783. // }
  3784. }
  3785. }
  3786. }
  3787. $rolename ['name'] = '';
  3788. if (! empty ( $roleId )) {
  3789. Doo::loadModel ( 'role' );
  3790. $role = new role ();
  3791. $rolename = $role->getOne ( array (
  3792. 'where' => 'rid=' . $roleId,
  3793. 'asArray' => true
  3794. ) );
  3795. }
  3796. if (! empty ( $verifyStaff ))
  3797. $endStaffArray = end ( $verifyStaff );
  3798. $KOP = false;
  3799. foreach ( $roleArrayCopy as $P => $A ) {
  3800. foreach ( $A as $MKI => $AVL ) {
  3801. if (! empty ( $verifyStaff )) {
  3802. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3803. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3804. $button = 4;
  3805. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3806. }
  3807. foreach ( $verifyStaff as $m => $u ) {
  3808. $AVLFK = $AVL [0] . '_R';
  3809. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3810. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3811. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3812. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3813. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3814. break;
  3815. }
  3816. }
  3817. } else {
  3818. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3819. $button = 4;
  3820. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3821. }
  3822. }
  3823. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3824. $KOP = true;
  3825. }
  3826. }
  3827. foreach ( $roleArrayCopy as $k => $v ) {
  3828. foreach ( $verifyList as $m => $n ) {
  3829. if ($n [0] == $k) {
  3830. array_splice ( $verifyList, $m, 1, $v );
  3831. }
  3832. }
  3833. }
  3834. $loanList [$key] ['verifyList'] = $verifyList;
  3835. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3836. 'where' => 'sid=' . $value ['staff'],
  3837. 'asArray' => true
  3838. ) );
  3839. $loanList [$key] ['button'] = $button;
  3840. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3841. }
  3842. $data ['loanList'] = $loanList;
  3843. // print_r($loanList);
  3844. $Locate = 0;
  3845. $roleId = 0;
  3846. $button = 0;
  3847. foreach ( $receiptList as $key => $value ) {
  3848. $receiptList [$key] ['Locate'] = $Locate;
  3849. $Locate ++;
  3850. $receiptList [$key] ['reviseDetail'] = array ();
  3851. if (! empty ( $value ['reviseDetail'] ))
  3852. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3853. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3854. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3855. $categoryDetil = $Lcategory->getOne ( array (
  3856. 'where' => 'cid=' . $value ['cid'],
  3857. 'asArray' => true
  3858. ) );
  3859. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3860. // 检测编辑状态
  3861. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3862. $verifyList ['staff'] = $value ['verifyBreakup'];
  3863. } else
  3864. $verifyList = $verify->getOne ( array (
  3865. 'where' => 'vid=' . $value ['verify'],
  3866. 'asArray' => true
  3867. ) );
  3868. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3869. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3870. Doo::loadModel ( 'role' );
  3871. $role = new role ();
  3872. if ($verifyList == NULL)
  3873. $verifyList = array ();
  3874. $flag = true;
  3875. $roleKey = 0;
  3876. $endStaffArray = array ();
  3877. $roleArrayCopy = array ();
  3878. foreach ( $verifyList as $k => $v ) {
  3879. // init verifyStaff
  3880. if ($v [1] == 'ROLE') {
  3881. if (! empty ( $verifyStaff )) {
  3882. $endStaffArray = end ( $verifyStaff );
  3883. // if ($v[0]==$endStaffArray['nextStaff']){
  3884. // $roleId=$v[0];
  3885. // }
  3886. }
  3887. $roleVerify = json_decode ( $v [3], true );
  3888. $roleKey = $k;
  3889. $roleArray = array ();
  3890. $rolename = $role->getOne ( array (
  3891. 'where' => 'rid=' . $v [0],
  3892. 'asArray' => true
  3893. ) );
  3894. foreach ( $roleVerify as $o => $p ) {
  3895. $staffID = explode ( '_', $p );
  3896. $staffInfo = $staff->getOne ( array (
  3897. 'where' => 'sid=' . $staffID [0],
  3898. 'asArray' => true
  3899. ) );
  3900. // print_r($staffID);
  3901. $exp = array (
  3902. 0 => $staffInfo ['sid'],
  3903. 1 => $staffID [1],
  3904. 2 => $staffInfo ['avatar'],
  3905. 'date' => '',
  3906. 'date' => '',
  3907. 'opinion' => '',
  3908. 'status' => '',
  3909. 'rolename' => $rolename ['name']
  3910. );
  3911. array_push ( $roleArray, $exp );
  3912. }
  3913. $roleArrayCopy [$v [0]] = $roleArray;
  3914. // $verifyList[$k]['roleArray']=$roleArray;
  3915. }
  3916. $verifyList [$k] ['date'] = "";
  3917. $verifyList [$k] ['opinion'] = "";
  3918. $verifyList [$k] ['status'] = "";
  3919. if (empty ( $verifyStaff )) {
  3920. $verifyList [$k] ['date'] = "";
  3921. $verifyList [$k] ['opinion'] = "";
  3922. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3923. $verifyList [$k] ['status'] = 4;
  3924. $flag = false;
  3925. }
  3926. } else {
  3927. foreach ( $verifyStaff as $m => $u ) {
  3928. if ($v [0] == $m) {
  3929. $verifyList [$k] ['date'] = $u ['date'];
  3930. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3931. $verifyList [$k] ['status'] = $u ['status'];
  3932. $flag = false;
  3933. break;
  3934. }
  3935. }
  3936. $endStaffArray = end ( $verifyStaff );
  3937. if (isset ( $endStaffArray ['ROLE'] )) {
  3938. } else {
  3939. // $endKey=key($verifyStaff);
  3940. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3941. // $button=4;
  3942. // $verifyList[$k]['status']=4;
  3943. // }
  3944. }
  3945. }
  3946. }
  3947. $FC = @$rolename ['name'];
  3948. $rolename ['name'] = '';
  3949. if (! empty ( $roleId )) {
  3950. Doo::loadModel ( 'role' );
  3951. $role = new role ();
  3952. $rolename = $role->getOne ( array (
  3953. 'where' => 'rid=' . $roleId,
  3954. 'asArray' => true
  3955. ) );
  3956. }
  3957. if (! empty ( $verifyStaff ))
  3958. $endStaffArray = end ( $verifyStaff );
  3959. $KOP = false;
  3960. foreach ( $roleArrayCopy as $P => $A ) {
  3961. foreach ( $A as $MKI => $AVL ) {
  3962. if (! empty ( $verifyStaff )) {
  3963. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3964. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3965. $button = 4;
  3966. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3967. }
  3968. foreach ( $verifyStaff as $m => $u ) {
  3969. $AVLFK = $AVL [0] . '_R';
  3970. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3971. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3972. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3973. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3974. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3975. break;
  3976. }
  3977. }
  3978. } else {
  3979. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3980. $button = 4;
  3981. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3982. }
  3983. }
  3984. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3985. $KOP = true;
  3986. }
  3987. }
  3988. foreach ( $roleArrayCopy as $k => $v ) {
  3989. foreach ( $verifyList as $m => $n ) {
  3990. if ($n [0] == $k) {
  3991. array_splice ( $verifyList, $m, 1, $v );
  3992. }
  3993. }
  3994. }
  3995. // 费用执行人相关数据
  3996. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3997. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3998. foreach ( $executeCopy as $k => $v ) {
  3999. $executeCopy [$k] ['date'] = '';
  4000. $executeCopy [$k] ['opinion'] = '';
  4001. $executeCopy [$k] ['status'] = '';
  4002. if (! empty ( $executeStaff ))
  4003. foreach ( $executeStaff as $m => $u ) {
  4004. if ($v [0] == $m) {
  4005. $executeCopy [$k] ['date'] = $u ['date'];
  4006. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4007. $executeCopy [$k] ['status'] = $u ['status'];
  4008. break;
  4009. }
  4010. }
  4011. }
  4012. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4013. // print_r($verifyList);
  4014. $receiptList [$key] ['verifyList'] = $verifyList;
  4015. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4016. 'where' => 'sid=' . $value ['staff'],
  4017. 'asArray' => true
  4018. ) );
  4019. $receiptList [$key] ['button'] = $button;
  4020. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4021. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4022. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4023. $receiptList [$key] ['relust'] = $relust;
  4024. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4025. }
  4026. // print_r($receiptList);
  4027. // 获取审批日志
  4028. Doo::loadModel ( 'receiptLog' );
  4029. $receiptLog = new receiptLog ();
  4030. $rlList = array ();
  4031. $rlInfo = $receiptLog->getOne ( array (
  4032. 'where' => 'rid=' . $rid . ' and status=4',
  4033. 'asArray' => true
  4034. ) );
  4035. $tijdate = $receiptLog->getOne ( array (
  4036. 'where' => 'rid=' . $rid . ' and status=2',
  4037. 'asc' => 'rlid',
  4038. 'asArray' => true
  4039. ) );
  4040. if (! empty ( $rlInfo )) {
  4041. $rlList = $receiptLog->find ( array (
  4042. 'where' => 'rid=' . $rid,
  4043. 'asc' => 'rlid',
  4044. 'asArray' => true
  4045. ) );
  4046. }
  4047. $RN = @json_decode ( $rolename ['staff'] );
  4048. //
  4049. foreach ( $rlList as $key => $value ) {
  4050. $rlList [$key] ['rolename'] = '';
  4051. foreach ( $RN as $k => $v ) {
  4052. $id = explode ( "_", $v );
  4053. if ($id [0] == $value ['uid']) {
  4054. $rlList [$key] ['rolename'] = $FC;
  4055. break;
  4056. }
  4057. }
  4058. }
  4059. Doo::loadModel ( 'enclosur' );
  4060. $enclosur = new enclosur ();
  4061. $enclosurList = $enclosur->find ( array (
  4062. 'where' => 'rid=' . $rid,
  4063. 'asArray' => true
  4064. ) );
  4065. $enclosurHtml = '';
  4066. foreach ( $enclosurList as $value ) {
  4067. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4068. }
  4069. $data ['enclosurHtml'] = $enclosurHtml;
  4070. $receiptList [0] ['rlList'] = $rlList;
  4071. $data ['receiptList'] = $receiptList;
  4072. // print_r($receiptList);
  4073. $data ['memu'] = "receipt";
  4074. $data ['staff'] = $this->staff;
  4075. $data ['receiptMemu'] = 'approvalExpenses';
  4076. $data ['verifyId'] = $this->verifyId;
  4077. $data ['executeId'] = $this->executeId;
  4078. $this->render ( "/admin/expensesDoc", $data );
  4079. }
  4080. function expensesEdi() {
  4081. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4082. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4083. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4084. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4085. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4086. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4087. if (empty ( $status ))
  4088. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4089. $vidList = array ();
  4090. $button = 0;
  4091. Doo::loadModel ( 'verify' );
  4092. Doo::loadModel ( 'receipt' );
  4093. Doo::loadModel ( 'staff' );
  4094. $staff = new staff ();
  4095. $receipt = new receipt ();
  4096. $verify = new verify ();
  4097. Doo::loadModel ( 'L_category' );
  4098. $Lcategory = new L_category ();
  4099. Doo::loadModel ( 'enclosur' );
  4100. $enclosur = new enclosur ();
  4101. // user verify ID
  4102. $verifyDetail = $verify->find ( array (
  4103. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4104. 'asArray' => true
  4105. ) );
  4106. foreach ( $verifyDetail as $key => $value ) {
  4107. array_push ( $vidList, $value ['vid'] );
  4108. }
  4109. $vid = implode ( ",", $vidList );
  4110. if (empty ( $verifyDetail ))
  4111. $vid = 0;
  4112. $categoryList = $Lcategory->find ( array (
  4113. 'asArray' => true
  4114. ) );
  4115. $staffList = $staff->find ( array (
  4116. 'where' => 'cid=' . $cid,
  4117. 'asArray' => true
  4118. ) );
  4119. $ap = "";
  4120. if ($status == 4) {
  4121. $ap = 4;
  4122. $status = 2;
  4123. }
  4124. // get Receipt By verifyID status 2
  4125. $receiptList = $receipt->find ( array (
  4126. 'where' => 'rid =' . $rid . ' and status=2',
  4127. 'desc' => 'rid',
  4128. 'asArray' => true
  4129. ) );
  4130. if (empty ( $receiptList )) {
  4131. die ( 'illegal request' );
  4132. }
  4133. $Locate = 0;
  4134. $roleId = 0;
  4135. if ($ap == 4)
  4136. $status = 4;
  4137. foreach ( $receiptList as $key => $value ) {
  4138. $receiptList [$key] ['Locate'] = $Locate;
  4139. $Locate ++;
  4140. $receiptList [$key] ['reviseDetail'] = array ();
  4141. if (! empty ( $value ['reviseDetail'] ))
  4142. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4143. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4144. $categoryDetil = $Lcategory->getOne ( array (
  4145. 'where' => 'cid=' . $value ['cid'],
  4146. 'asArray' => true
  4147. ) );
  4148. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4149. // 检测编辑状态
  4150. $verifyList = $verify->getOne ( array (
  4151. 'where' => 'vid=' . $value ['verify'],
  4152. 'asArray' => true
  4153. ) );
  4154. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4155. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4156. Doo::loadModel ( 'role' );
  4157. $role = new role ();
  4158. // print_r($verifyList);
  4159. $flag = true;
  4160. $roleKey = 0;
  4161. $endStaffArray = array ();
  4162. $roleArrayCopy = array ();
  4163. foreach ( $verifyList as $k => $v ) {
  4164. // init verifyStaff
  4165. if ($v [1] == 'ROLE') {
  4166. if (! empty ( $verifyStaff )) {
  4167. $endStaffArray = end ( $verifyStaff );
  4168. if ($v [0] == $endStaffArray ['nextStaff']) {
  4169. $roleId = $v [0];
  4170. }
  4171. }
  4172. $roleVerify = json_decode ( $v [3], true );
  4173. $roleKey = $k;
  4174. $roleArray = array ();
  4175. $rolename = $role->getOne ( array (
  4176. 'where' => 'rid=' . $v [0],
  4177. 'asArray' => true
  4178. ) );
  4179. foreach ( $roleVerify as $o => $p ) {
  4180. $staffID = explode ( '_', $p );
  4181. $staffInfo = $staff->getOne ( array (
  4182. 'where' => 'sid=' . $staffID [0],
  4183. 'asArray' => true
  4184. ) );
  4185. // print_r($staffID);
  4186. $exp = array (
  4187. 0 => $staffInfo ['sid'],
  4188. 1 => $staffID [1],
  4189. 2 => $staffInfo ['avatar'],
  4190. 'date' => '',
  4191. 'date' => '',
  4192. 'opinion' => '',
  4193. 'status' => '',
  4194. 'rolename' => $rolename ['name']
  4195. );
  4196. array_push ( $roleArray, $exp );
  4197. }
  4198. $roleArrayCopy [$v [0]] = $roleArray;
  4199. // $verifyList[$k]['roleArray']=$roleArray;
  4200. }
  4201. // print_r($roleArray);
  4202. $verifyList [$k] ['date'] = "";
  4203. $verifyList [$k] ['opinion'] = "";
  4204. $verifyList [$k] ['status'] = "";
  4205. if (empty ( $verifyStaff )) {
  4206. $verifyList [$k] ['date'] = "";
  4207. $verifyList [$k] ['opinion'] = "";
  4208. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4209. $verifyList [$k] ['status'] = 4;
  4210. $button = 4;
  4211. $flag = false;
  4212. }
  4213. } else {
  4214. foreach ( $verifyStaff as $m => $u ) {
  4215. if ($v [0] == $m) {
  4216. $verifyList [$k] ['date'] = $u ['date'];
  4217. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4218. $verifyList [$k] ['status'] = $u ['status'];
  4219. $flag = false;
  4220. break;
  4221. }
  4222. }
  4223. $endStaffArray = end ( $verifyStaff );
  4224. if (isset ( $endStaffArray ['ROLE'] )) {
  4225. } else {
  4226. $endKey = key ( $verifyStaff );
  4227. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4228. $button = 4;
  4229. $verifyList [$k] ['status'] = 4;
  4230. }
  4231. }
  4232. }
  4233. }
  4234. $rolename ['name'] = '';
  4235. if (! empty ( $roleId )) {
  4236. Doo::loadModel ( 'role' );
  4237. $role = new role ();
  4238. $rolename = $role->getOne ( array (
  4239. 'where' => 'rid=' . $roleId,
  4240. 'asArray' => true
  4241. ) );
  4242. }
  4243. if (! empty ( $verifyStaff ))
  4244. $endStaffArray = end ( $verifyStaff );
  4245. $KOP = false;
  4246. foreach ( $roleArrayCopy as $P => $A ) {
  4247. foreach ( $A as $MKI => $AVL ) {
  4248. if (! empty ( $verifyStaff )) {
  4249. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4250. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4251. $button = 4;
  4252. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4253. }
  4254. foreach ( $verifyStaff as $m => $u ) {
  4255. $AVLFK = $AVL [0] . '_R';
  4256. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4257. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4258. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4259. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4260. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4261. break;
  4262. }
  4263. }
  4264. } else {
  4265. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4266. $button = 4;
  4267. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4268. }
  4269. }
  4270. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4271. $KOP = true;
  4272. }
  4273. }
  4274. // print_r($roleArrayCopy);
  4275. // echo $roleKey;
  4276. foreach ( $roleArrayCopy as $k => $v ) {
  4277. foreach ( $verifyList as $m => $n ) {
  4278. if ($n [0] == $k) {
  4279. array_splice ( $verifyList, $m, 1, $v );
  4280. }
  4281. }
  4282. }
  4283. $receiptList [$key] ['verifyList'] = $verifyList;
  4284. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4285. 'where' => 'sid=' . $value ['staff'],
  4286. 'asArray' => true
  4287. ) );
  4288. $receiptList [$key] ['button'] = $button;
  4289. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4290. }
  4291. // $data['verifyDetail']=$verifyDetail;
  4292. $mothHtml = "";
  4293. for($i = 1; $i <= 12; $i ++) {
  4294. if ($month == $i)
  4295. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4296. else
  4297. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4298. }
  4299. // 获取审批日志
  4300. Doo::loadModel ( 'receiptLog' );
  4301. $receiptLog = new receiptLog ();
  4302. $rlList = array ();
  4303. $rlInfo = $receiptLog->getOne ( array (
  4304. 'where' => 'rid=' . $rid . ' and status=4',
  4305. 'asArray' => true
  4306. ) );
  4307. $tijdate = $receiptLog->getOne ( array (
  4308. 'where' => 'rid=' . $rid . ' and status=2',
  4309. 'asc' => 'rlid',
  4310. 'asArray' => true
  4311. ) );
  4312. if (! empty ( $rlInfo )) {
  4313. $rlList = $receiptLog->find ( array (
  4314. 'where' => 'rid=' . $rid,
  4315. 'asc' => 'rlid',
  4316. 'asArray' => true
  4317. ) );
  4318. }
  4319. $receiptList [0] ['rlList'] = $rlList;
  4320. $enclosurList = $enclosur->find ( array (
  4321. 'where' => 'rid=' . $rid,
  4322. 'asArray' => true
  4323. ) );
  4324. $enclosurHtml = '';
  4325. foreach ( $enclosurList as $value ) {
  4326. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4327. }
  4328. // print_r($receiptList);
  4329. $data ['rid'] = $rid;
  4330. $data ['enclosurHtml'] = $enclosurHtml;
  4331. $data ['rolename'] = $rolename ['name'];
  4332. $data ['datetij'] = $tijdate ['date'];
  4333. $data ['mothHtml'] = $mothHtml;
  4334. $data ['receiptList'] = $receiptList;
  4335. $data ['receiptApprovalCount'] = count ( $receiptList );
  4336. $data ['status'] = $status;
  4337. $data ['year'] = $year;
  4338. $data ['categoryList'] = $categoryList;
  4339. $data ['staffList'] = $staffList;
  4340. $data ['cid'] = $cid;
  4341. $data ['sid'] = $sid;
  4342. $data ['ap'] = $ap;
  4343. $data ['memu'] = "receipt";
  4344. $data ['staff'] = $this->staff;
  4345. $data ['receiptMemu'] = 'approvalExpenses';
  4346. $data ['verifyId'] = $this->verifyId;
  4347. $data ['executeId'] = $this->executeId;
  4348. $this->render ( "/admin/expensesEdi", $data );
  4349. }
  4350. function expensesDefray() {
  4351. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4352. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4353. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4354. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4355. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4356. if (! empty ( $rid )) {
  4357. Doo::loadModel ( "verify" );
  4358. $verify = new verify ();
  4359. Doo::loadModel ( "receiptDetail" );
  4360. $receiptDetailObj = new receiptDetail ();
  4361. Doo::loadModel ( "itemStatistics" );
  4362. Doo::loadModel ( "statistics" );
  4363. $statistics = new statistics ();
  4364. $itemStatistics = new itemStatistics ();
  4365. Doo::loadModel ( "receipt" );
  4366. $receipt = new receipt ();
  4367. Doo::loadModel ( "loanReceipt" );
  4368. $loanReceipt = new loanReceipt ();
  4369. $receiptDetail = $receipt->getOne ( array (
  4370. 'where' => 'rid=' . $rid . ' and status=2 ',
  4371. 'asArray' => true
  4372. ) );
  4373. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4374. $nsflag = true;
  4375. foreach ( $nslist as $value ) {
  4376. if ($value == $this->staff ['0'] ['sid']) {
  4377. $nsflag = false;
  4378. break;
  4379. }
  4380. }
  4381. // print_r($nslist);die;
  4382. if (empty ( $receiptDetail ) || $nsflag)
  4383. return "/approvalExpenses/pendApproval";
  4384. $verifyDetail = $verify->getOne ( array (
  4385. 'where' => ' vid =' . $receiptDetail ['verify'],
  4386. 'asArray' => true
  4387. ) );
  4388. $verifyString = $verifyDetail ['staff'];
  4389. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4390. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4391. if (empty ( $opinion )) {
  4392. if ($status == 3)
  4393. $opinion = "终止";
  4394. else
  4395. $opinion = "同意支付";
  4396. }
  4397. $nowStaff = 0;
  4398. $nowStaffList = array ();
  4399. if (empty ( $verifyStaff )) {
  4400. // 还需加入是否已经进入角色审批
  4401. if ($verifyDetail [0] [1] == 'ROLE') {
  4402. // print_r($verifyDetail);echo "ddd";
  4403. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4404. foreach ( $vStaffString as $key => $value ) {
  4405. $staffK = explode ( "_", $value );
  4406. if ($staffK [0] != $this->staff [0] ['sid'])
  4407. array_push ( $nowStaffList, $staffK [0] );
  4408. }
  4409. // print_r($verifyDetail);
  4410. // die;
  4411. if (! empty ( $nowStaffList )) {
  4412. $nowStaff = implode ( ',', $nowStaffList );
  4413. $verifyStaff = array (
  4414. $this->staff [0] ['sid'] . "_R" => array (
  4415. 'date' => date ( 'Y-m-d' ),
  4416. 'opinion' => $opinion,
  4417. 'status' => $status,
  4418. 'nextStaff' => $verifyDetail [0] [0],
  4419. 'ROLE' => 1
  4420. )
  4421. );
  4422. } else {
  4423. $nowStaff = $verifyDetail [1] [0];
  4424. $verifyStaff = array (
  4425. $this->staff [0] ['sid'] . "_R" => array (
  4426. 'date' => date ( 'Y-m-d' ),
  4427. 'opinion' => $opinion,
  4428. 'status' => $status,
  4429. 'nextStaff' => $verifyDetail [1] [0]
  4430. )
  4431. );
  4432. }
  4433. } else {
  4434. if ($verifyDetail [1] [1] == 'ROLE') {
  4435. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4436. // echo "dd";
  4437. foreach ( $vStaffString as $key => $value ) {
  4438. $staffK = explode ( "_", $value );
  4439. array_push ( $nowStaffList, $staffK [0] );
  4440. }
  4441. $nowStaff = implode ( ',', $nowStaffList );
  4442. $verifyStaff = array (
  4443. $this->staff [0] ['sid'] => array (
  4444. 'date' => date ( 'Y-m-d' ),
  4445. 'opinion' => $opinion,
  4446. 'status' => $status,
  4447. 'nextStaff' => $verifyDetail [1] [0],
  4448. 'ROLE' => 1
  4449. )
  4450. );
  4451. } else {
  4452. $nowStaff = $verifyDetail [1] [0];
  4453. $verifyStaff = array (
  4454. $this->staff [0] ['sid'] => array (
  4455. 'date' => date ( 'Y-m-d' ),
  4456. 'opinion' => $opinion,
  4457. 'status' => $status,
  4458. 'nextStaff' => $verifyDetail [1] [0]
  4459. )
  4460. );
  4461. }
  4462. }
  4463. if ($status == 3)
  4464. $verifyStaff = array (
  4465. 'final' => $status,
  4466. $this->staff [0] ['sid'] => array (
  4467. 'date' => date ( 'Y-m-d' ),
  4468. 'opinion' => $opinion,
  4469. 'status' => $status
  4470. )
  4471. );
  4472. $vStaffString = json_encode ( $verifyStaff );
  4473. $receipt->nowStaff = $nowStaff;
  4474. $receipt->verifyStaff = $vStaffString;
  4475. $loanReceipt->nowStaff = $nowStaff;
  4476. $loanReceipt->verifyStaff = $vStaffString;
  4477. } else {
  4478. $VS = end ( $verifyStaff );
  4479. // 非角色审批
  4480. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4481. $nextStaff = 0;
  4482. $roleSTF = false;
  4483. foreach ( $verifyDetail as $key => $value ) {
  4484. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4485. if (isset ( $verifyDetail [$key + 1] )) {
  4486. $nextStaff = $verifyDetail [$key + 1] [0];
  4487. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4488. $roleSTF = true;
  4489. }
  4490. break;
  4491. }
  4492. }
  4493. if (! $roleSTF) {
  4494. $nowStaff = $nextStaff;
  4495. $verifyStaff [$this->staff [0] ['sid']] = array (
  4496. 'date' => date ( 'Y-m-d' ),
  4497. 'opinion' => $opinion,
  4498. 'status' => $status,
  4499. 'nextStaff' => $nextStaff
  4500. );
  4501. } else {
  4502. // 获取角色下的所有用户ID
  4503. $nowStaffList = array ();
  4504. foreach ( $verifyDetail as $vfk ) {
  4505. if ($vfk [1] == 'ROLE') {
  4506. $vStaffString = json_decode ( $vfk [3] );
  4507. foreach ( $vStaffString as $key => $value ) {
  4508. $staffK = explode ( "_", $value );
  4509. array_push ( $nowStaffList, $staffK [0] );
  4510. }
  4511. }
  4512. }
  4513. $nowStaff = implode ( ',', $nowStaffList );
  4514. $verifyStaff [$this->staff [0] ['sid']] = array (
  4515. 'date' => date ( 'Y-m-d' ),
  4516. 'opinion' => $opinion,
  4517. 'status' => $status,
  4518. 'nextStaff' => $nextStaff,
  4519. 'ROLE' => 0
  4520. );
  4521. }
  4522. if ($status == 3) {
  4523. $verifyStaff ['final'] = $status;
  4524. $verifyStaff [$this->staff [0] ['sid']] = array (
  4525. 'date' => date ( 'Y-m-d' ),
  4526. 'opinion' => $opinion,
  4527. 'status' => $status
  4528. );
  4529. }
  4530. $vStaffString = json_encode ( $verifyStaff );
  4531. $receipt->nowStaff = $nowStaff;
  4532. $receipt->verifyStaff = $vStaffString;
  4533. $loanReceipt->nowStaff = $nowStaff;
  4534. $loanReceipt->verifyStaff = $vStaffString;
  4535. }
  4536. // 角色审批
  4537. if (isset ( $VS ['ROLE'] )) {
  4538. // 找出角色人 当前审批角色组
  4539. $verifyJSStaff = array ();
  4540. $nowStaffList2 = array ();
  4541. foreach ( $verifyDetail as $key => $value ) {
  4542. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4543. $verifyJSStaff = json_decode ( $value [3] );
  4544. foreach ( $verifyJSStaff as $m ) {
  4545. $staffK = explode ( "_", $m );
  4546. array_push ( $nowStaffList2, $staffK [0] );
  4547. }
  4548. // print_r($nowStaffList2);
  4549. }
  4550. }
  4551. $RoleVerifyStaff = array ();
  4552. foreach ( $verifyStaff as $key => $value ) {
  4553. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4554. foreach ( $nowStaffList2 as $m ) {
  4555. if ($key == $m . "_R")
  4556. $RoleVerifyStaff [$key] = $value;
  4557. }
  4558. }
  4559. }
  4560. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4561. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4562. // 下一个审批人ID
  4563. $nextStaff = 0;
  4564. $falg = false;
  4565. foreach ( $verifyDetail as $key => $value ) {
  4566. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4567. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4568. $falg = true;
  4569. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4570. $nowStaffList = array ();
  4571. foreach ( $vStaffString as $v ) {
  4572. $staffK = explode ( "_", $v );
  4573. array_push ( $nowStaffList, $staffK [0] );
  4574. }
  4575. $nowStaff = implode ( ',', $nowStaffList );
  4576. $nextStaff = $verifyDetail [$key + 1] [0];
  4577. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4578. $nextStaff = $verifyDetail [$key + 1] [0];
  4579. $nowStaff = $nextStaff;
  4580. } else
  4581. $nowStaff = '';
  4582. break;
  4583. }
  4584. }
  4585. if ($falg)
  4586. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4587. 'date' => date ( 'Y-m-d' ),
  4588. 'opinion' => $opinion,
  4589. 'status' => $status,
  4590. 'nextStaff' => $nextStaff,
  4591. 'ROLE' => 1
  4592. );
  4593. else
  4594. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4595. 'date' => date ( 'Y-m-d' ),
  4596. 'opinion' => $opinion,
  4597. 'status' => $status,
  4598. 'nextStaff' => $nextStaff
  4599. );
  4600. // print_r($verifyStaff);
  4601. // echo $nowStaff;die;
  4602. } else { // 进入下一个角色或者审批人
  4603. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  4604. //
  4605. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4606. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4607. 'date' => date ( 'Y-m-d' ),
  4608. 'opinion' => $opinion,
  4609. 'status' => $status,
  4610. 'nextStaff' => $VS ['nextStaff'],
  4611. 'ROLE' => 1
  4612. );
  4613. // print_r($verifyStaff);
  4614. // die;
  4615. }
  4616. if ($status == 3) {
  4617. $verifyStaff ['final'] = $status;
  4618. $verifyStaff [$this->staff [0] ['sid']] = array (
  4619. 'date' => date ( 'Y-m-d' ),
  4620. 'opinion' => $opinion,
  4621. 'status' => $status
  4622. );
  4623. }
  4624. $vStaffString = json_encode ( $verifyStaff );
  4625. $receipt->verifyStaff = $vStaffString;
  4626. $receipt->nowStaff = $nowStaff;
  4627. $loanReceipt->nowStaff = $nowStaff;
  4628. $loanReceipt->verifyStaff = $vStaffString;
  4629. // die;
  4630. // }
  4631. // print_r($verifyStaff);
  4632. // die;
  4633. }
  4634. // print_r($verifyStaff);die;
  4635. }
  4636. // print_r($verifyDetail);
  4637. $roleKey = 0;
  4638. $roleId = 0;
  4639. $verifyDetailCopy = array ();
  4640. foreach ( $verifyDetail as $k => $v ) {
  4641. if ($v [1] == 'ROLE') {
  4642. $roleId = $v [0];
  4643. $roleVerify = json_decode ( $v [3], true );
  4644. $roleKey = $k;
  4645. $roleArray = array ();
  4646. foreach ( $roleVerify as $o => $p ) {
  4647. $staffID = explode ( '_', $p );
  4648. $exp = array (
  4649. 0 => $staffID [0],
  4650. 1 => $staffID [1]
  4651. );
  4652. array_push ( $roleArray, $exp );
  4653. }
  4654. $verifyDetailCopy [$v [0]] = $roleArray;
  4655. }
  4656. }
  4657. // print_r($verifyDetail);
  4658. foreach ( $verifyDetailCopy as $k => $v ) {
  4659. foreach ( $verifyDetail as $m => $n ) {
  4660. if ($n [0] == $k) {
  4661. array_splice ( $verifyDetail, $m, 1, $v );
  4662. }
  4663. }
  4664. }
  4665. // 审批日志
  4666. if (! isset ( $verifyStaff ['final'] )) {
  4667. Doo::loadModel ( "receiptLog" );
  4668. $receiptLog = new receiptLog ();
  4669. if (! empty ( $roleId )) {
  4670. Doo::loadModel ( "role" );
  4671. $role = new role ();
  4672. $roleInfo = $role->getOne ( array (
  4673. 'where' => 'rid=' . $roleId,
  4674. 'asArray' => true
  4675. ) );
  4676. $receiptLog->rolename = $roleInfo ['name'];
  4677. }
  4678. $receiptLog->username = $this->staff [0] ['username'];
  4679. $receiptLog->uid = $this->staff [0] ['sid'];
  4680. $receiptLog->date = date ( "Y-m-d" );
  4681. $receiptLog->opinion = $opinion;
  4682. $receiptLog->img = $this->staff [0] ['avatar'];
  4683. $receiptLog->status = 1;
  4684. $receiptLog->rid = $rid;
  4685. $receiptLog->insert ();
  4686. }
  4687. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4688. $receipt->status = 3;
  4689. $receipt->verifyBreakup = $verifyString;
  4690. $receiptDetailObj->status = 3;
  4691. $receiptDetailObj->update ( array (
  4692. 'where' => 'rid=' . $rid
  4693. ) );
  4694. // 微信企业号通知
  4695. $this->setWXMsg ( $rid, 3 );
  4696. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4697. $receipt->status = 6;
  4698. $receipt->pastDate = date ( "Y-m-d" );
  4699. $receipt->isBK = 1;
  4700. $loanReceipt->verifyBreakup = $verifyString;
  4701. $loanReceipt->status = 1;
  4702. $loanReceipt->pastDate = date ( "Y-m-d" );
  4703. //生成流水后 不更新汇款金额
  4704. Doo::loadModel ( 'wasteBook' );
  4705. $wasteBook = new wasteBook ();
  4706. $wbDetail = $wasteBook->getWateBookByAD ( 1, $rid );
  4707. if (empty($wbDetail)){
  4708. $loanReceipt->amount = $receiptDetail ['amount'];
  4709. }
  4710. $loanReceipt->update ( array (
  4711. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4712. ) );
  4713. // 微信企业号通知
  4714. $this->setWXMsg ( $rid, 1 );
  4715. }
  4716. $receipt->amount = $amount;
  4717. $receipt->update ( array (
  4718. 'where' => ' rid = ' . $rid
  4719. ) );
  4720. // 进入下一条审批费用新加需求
  4721. $vidList = array ();
  4722. $verifyDetail = $verify->find ( array (
  4723. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4724. 'asArray' => true
  4725. ) );
  4726. foreach ( $verifyDetail as $key => $value ) {
  4727. array_push ( $vidList, $value ['vid'] );
  4728. }
  4729. $vid = implode ( ",", $vidList );
  4730. if (empty ( $verifyDetail ))
  4731. $vid = 0;
  4732. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4733. $receipt = new receipt ();
  4734. $rd = $receipt->getOne ( array (
  4735. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4736. 'asc' => 'rid',
  4737. 'asArray' => true
  4738. ) );
  4739. if (empty ( $rd )) {
  4740. return '/approvalExpenses/pendApproval';
  4741. }
  4742. if ($rd ['Rtype'] == 1) {
  4743. if ($rd ['isBK'] == 1) {
  4744. return '/receiptburEdi/' . $rd ['rid'];
  4745. } else {
  4746. return '/expensesEdi/' . $rd ['rid'];
  4747. }
  4748. } elseif ($rd ['Rtype'] == 2) {
  4749. return '/remitApproval/' . $rd ['rid'];
  4750. } else {
  4751. return '/receiptburEdi/' . $rd ['rid'];
  4752. }
  4753. // return "/approvalExpenses/pendApproval";
  4754. }
  4755. }
  4756. function ajaxExamineExe() {
  4757. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4758. Doo::loadModel ( 'receipt' );
  4759. $receipt = new receipt ();
  4760. Doo::loadClass ( 'XDeode' );
  4761. $XDeode = new XDeode ( 5 );
  4762. if (! empty ( $rid )) {
  4763. $rLRes = $receipt->find ( array (
  4764. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4765. 'asArray' => true
  4766. ) );
  4767. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4768. echo json_encode ( array (
  4769. 'status' => 1,
  4770. 'receipt' => $rLRes [0]
  4771. ) );
  4772. die ();
  4773. }
  4774. echo json_encode ( array (
  4775. 'status' => 0,
  4776. 'receipt' => array ()
  4777. ) );
  4778. die ();
  4779. }
  4780. function implement() {
  4781. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4782. Doo::loadClass ( 'XDeode' );
  4783. $XDeode = new XDeode ( 5 );
  4784. Doo::loadModel ( 'receipt' );
  4785. $receipt = new receipt ();
  4786. Doo::loadModel ( 'L_category' );
  4787. $Lcategory = new L_category ();
  4788. Doo::loadModel ( 'verify' );
  4789. $verify = new verify ();
  4790. Doo::loadModel ( 'staff' );
  4791. $staff = new staff ();
  4792. Doo::loadModel ( "execute" );
  4793. $execute = new execute ();
  4794. $rid = $XDeode->decode ( $rid );
  4795. $receiptList = $receipt->find ( array (
  4796. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4797. 'desc' => 'rid',
  4798. 'asArray' => true
  4799. ) );
  4800. Doo::loadModel ( 'loanReceipt' );
  4801. $loanReceipt = new loanReceipt ();
  4802. // print_r($receiptList);
  4803. $loanList = array ();
  4804. if (! isset ( $receiptList ))
  4805. $loanList = $loanReceipt->find ( array (
  4806. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4807. 'desc' => 'rid',
  4808. 'asArray' => true
  4809. ) );
  4810. $Locate = 0;
  4811. $roleId = 0;
  4812. $button = 0;
  4813. foreach ( $loanList as $key => $value ) {
  4814. $loanList [$key] ['Locate'] = $Locate;
  4815. $Locate ++;
  4816. $loanList [$key] ['reviseDetail'] = array ();
  4817. if (! empty ( $value ['reviseDetail'] ))
  4818. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4819. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4820. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4821. $categoryDetil = $Lcategory->getOne ( array (
  4822. 'where' => 'cid=' . $value ['cid'],
  4823. 'asArray' => true
  4824. ) );
  4825. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4826. // 检测编辑状态
  4827. $verifyList = $verify->getOne ( array (
  4828. 'where' => 'vid=' . $value ['verify'],
  4829. 'asArray' => true
  4830. ) );
  4831. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4832. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4833. Doo::loadModel ( 'role' );
  4834. $role = new role ();
  4835. $flag = true;
  4836. $roleKey = 0;
  4837. $endStaffArray = array ();
  4838. $roleArrayCopy = array ();
  4839. foreach ( $verifyList as $k => $v ) {
  4840. // init verifyStaff
  4841. if ($v [1] == 'ROLE') {
  4842. if (! empty ( $verifyStaff )) {
  4843. $endStaffArray = end ( $verifyStaff );
  4844. // if ($v[0]==$endStaffArray['nextStaff']){
  4845. // $roleId=$v[0];
  4846. // }
  4847. }
  4848. $roleVerify = json_decode ( $v [3], true );
  4849. $roleKey = $k;
  4850. $roleArray = array ();
  4851. $rolename = $role->getOne ( array (
  4852. 'where' => 'rid=' . $v [0],
  4853. 'asArray' => true
  4854. ) );
  4855. foreach ( $roleVerify as $o => $p ) {
  4856. $staffID = explode ( '_', $p );
  4857. $staffInfo = $staff->getOne ( array (
  4858. 'where' => 'sid=' . $staffID [0],
  4859. 'asArray' => true
  4860. ) );
  4861. // print_r($staffID);
  4862. $exp = array (
  4863. 0 => $staffInfo ['sid'],
  4864. 1 => $staffID [1],
  4865. 2 => $staffInfo ['avatar'],
  4866. 'date' => '',
  4867. 'date' => '',
  4868. 'opinion' => '',
  4869. 'status' => '',
  4870. 'rolename' => $rolename ['name']
  4871. );
  4872. array_push ( $roleArray, $exp );
  4873. }
  4874. $roleArrayCopy [$v [0]] = $roleArray;
  4875. // $verifyList[$k]['roleArray']=$roleArray;
  4876. }
  4877. $verifyList [$k] ['date'] = "";
  4878. $verifyList [$k] ['opinion'] = "";
  4879. $verifyList [$k] ['status'] = "";
  4880. if (empty ( $verifyStaff )) {
  4881. $verifyList [$k] ['date'] = "";
  4882. $verifyList [$k] ['opinion'] = "";
  4883. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4884. $verifyList [$k] ['status'] = 4;
  4885. $flag = false;
  4886. }
  4887. } else {
  4888. foreach ( $verifyStaff as $m => $u ) {
  4889. if ($v [0] == $m) {
  4890. $verifyList [$k] ['date'] = $u ['date'];
  4891. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4892. $verifyList [$k] ['status'] = $u ['status'];
  4893. $flag = false;
  4894. break;
  4895. }
  4896. }
  4897. $endStaffArray = end ( $verifyStaff );
  4898. if (isset ( $endStaffArray ['ROLE'] )) {
  4899. } else {
  4900. // $endKey=key($verifyStaff);
  4901. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4902. // $button=4;
  4903. // $verifyList[$k]['status']=4;
  4904. // }
  4905. }
  4906. }
  4907. }
  4908. $rolename ['name'] = '';
  4909. if (! empty ( $roleId )) {
  4910. Doo::loadModel ( 'role' );
  4911. $role = new role ();
  4912. $rolename = $role->getOne ( array (
  4913. 'where' => 'rid=' . $roleId,
  4914. 'asArray' => true
  4915. ) );
  4916. }
  4917. if (! empty ( $verifyStaff ))
  4918. $endStaffArray = end ( $verifyStaff );
  4919. $KOP = false;
  4920. foreach ( $roleArrayCopy as $P => $A ) {
  4921. foreach ( $A as $MKI => $AVL ) {
  4922. if (! empty ( $verifyStaff )) {
  4923. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4924. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4925. $button = 4;
  4926. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4927. }
  4928. foreach ( $verifyStaff as $m => $u ) {
  4929. $AVLFK = $AVL [0] . '_R';
  4930. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4931. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4932. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4933. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4934. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4935. break;
  4936. }
  4937. }
  4938. } else {
  4939. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4940. $button = 4;
  4941. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4942. }
  4943. }
  4944. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4945. $KOP = true;
  4946. }
  4947. }
  4948. foreach ( $roleArrayCopy as $k => $v ) {
  4949. foreach ( $verifyList as $m => $n ) {
  4950. if ($n [0] == $k) {
  4951. array_splice ( $verifyList, $m, 1, $v );
  4952. }
  4953. }
  4954. }
  4955. $loanList [$key] ['verifyList'] = $verifyList;
  4956. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4957. 'where' => 'sid=' . $value ['staff'],
  4958. 'asArray' => true
  4959. ) );
  4960. }
  4961. $data ['loanList'] = $loanList;
  4962. $Locate = 0;
  4963. $roleId = 0;
  4964. $button = 0;
  4965. Doo::loadClass ( 'XDeode' );
  4966. $XDeode = new XDeode ( 5 );
  4967. foreach ( $receiptList as $key => $value ) {
  4968. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  4969. $button2 = 0;
  4970. $receiptList [$key] ['Locate'] = $Locate;
  4971. $Locate ++;
  4972. $receiptList [$key] ['reviseDetail'] = array ();
  4973. if (! empty ( $value ['reviseDetail'] ))
  4974. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4975. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4976. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4977. $categoryDetil = $Lcategory->getOne ( array (
  4978. 'where' => 'cid=' . $value ['cid'],
  4979. 'asArray' => true
  4980. ) );
  4981. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4982. $executeList = json_decode ( $value ['executeCopy'], true );
  4983. $executeStaff = array ();
  4984. if (! empty ( $value ['executeStaff'] ))
  4985. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4986. if (isset ( $executeList )) {
  4987. foreach ( $executeList as $op => $lo ) {
  4988. $executeList [$op] ['date'] = "";
  4989. $executeList [$op] ['opinion'] = "";
  4990. $executeList [$op] ['status'] = "";
  4991. foreach ( $executeStaff as $m => $u ) {
  4992. if ($lo [0] == $m) {
  4993. $executeList [$op] ['date'] = $u ['date'];
  4994. $executeList [$op] ['opinion'] = $u ['opinion'];
  4995. $executeList [$op] ['status'] = $u ['status'];
  4996. break;
  4997. }
  4998. }
  4999. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5000. $button2 = 1;
  5001. $executeList [$op] ['status'] = 4;
  5002. }
  5003. }
  5004. }
  5005. // 检测编辑状态
  5006. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5007. $verifyList ['staff'] = $value ['verifyBreakup'];
  5008. } else
  5009. $verifyList = $verify->getOne ( array (
  5010. 'where' => 'vid=' . $value ['verify'],
  5011. 'asArray' => true
  5012. ) );
  5013. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5014. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5015. Doo::loadModel ( 'role' );
  5016. $role = new role ();
  5017. if ($verifyList == NULL)
  5018. $verifyList = array ();
  5019. $flag = true;
  5020. $roleKey = 0;
  5021. $endStaffArray = array ();
  5022. $roleArrayCopy = array ();
  5023. foreach ( $verifyList as $k => $v ) {
  5024. // init verifyStaff
  5025. if ($v [1] == 'ROLE') {
  5026. if (! empty ( $verifyStaff )) {
  5027. $endStaffArray = end ( $verifyStaff );
  5028. // if ($v[0]==$endStaffArray['nextStaff']){
  5029. // $roleId=$v[0];
  5030. // }
  5031. }
  5032. $roleVerify = json_decode ( $v [3], true );
  5033. $roleKey = $k;
  5034. $roleArray = array ();
  5035. $rolename = $role->getOne ( array (
  5036. 'where' => 'rid=' . $v [0],
  5037. 'asArray' => true
  5038. ) );
  5039. foreach ( $roleVerify as $o => $p ) {
  5040. $staffID = explode ( '_', $p );
  5041. $staffInfo = $staff->getOne ( array (
  5042. 'where' => 'sid=' . $staffID [0],
  5043. 'asArray' => true
  5044. ) );
  5045. // print_r($staffID);
  5046. $exp = array (
  5047. 0 => $staffInfo ['sid'],
  5048. 1 => $staffID [1],
  5049. 2 => $staffInfo ['avatar'],
  5050. 'date' => '',
  5051. 'date' => '',
  5052. 'opinion' => '',
  5053. 'status' => '',
  5054. 'rolename' => $rolename ['name']
  5055. );
  5056. array_push ( $roleArray, $exp );
  5057. }
  5058. $roleArrayCopy [$v [0]] = $roleArray;
  5059. // $verifyList[$k]['roleArray']=$roleArray;
  5060. }
  5061. $verifyList [$k] ['date'] = "";
  5062. $verifyList [$k] ['opinion'] = "";
  5063. $verifyList [$k] ['status'] = "";
  5064. if (empty ( $verifyStaff )) {
  5065. $verifyList [$k] ['date'] = "";
  5066. $verifyList [$k] ['opinion'] = "";
  5067. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5068. $verifyList [$k] ['status'] = 4;
  5069. $flag = false;
  5070. }
  5071. } else {
  5072. foreach ( $verifyStaff as $m => $u ) {
  5073. if ($v [0] == $m) {
  5074. $verifyList [$k] ['date'] = $u ['date'];
  5075. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5076. $verifyList [$k] ['status'] = $u ['status'];
  5077. $flag = false;
  5078. break;
  5079. }
  5080. }
  5081. $endStaffArray = end ( $verifyStaff );
  5082. if (isset ( $endStaffArray ['ROLE'] )) {
  5083. } else {
  5084. // $endKey=key($verifyStaff);
  5085. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5086. // $button=4;
  5087. // $verifyList[$k]['status']=4;
  5088. // }
  5089. }
  5090. }
  5091. }
  5092. $rolename ['name'] = '';
  5093. if (! empty ( $roleId )) {
  5094. Doo::loadModel ( 'role' );
  5095. $role = new role ();
  5096. $rolename = $role->getOne ( array (
  5097. 'where' => 'rid=' . $roleId,
  5098. 'asArray' => true
  5099. ) );
  5100. }
  5101. if (! empty ( $verifyStaff ))
  5102. $endStaffArray = end ( $verifyStaff );
  5103. $KOP = false;
  5104. foreach ( $roleArrayCopy as $P => $A ) {
  5105. foreach ( $A as $MKI => $AVL ) {
  5106. if (! empty ( $verifyStaff )) {
  5107. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5108. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5109. $button = 4;
  5110. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5111. }
  5112. foreach ( $verifyStaff as $m => $u ) {
  5113. $AVLFK = $AVL [0] . '_R';
  5114. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5115. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5116. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5117. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5118. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5119. break;
  5120. }
  5121. }
  5122. } else {
  5123. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5124. $button = 4;
  5125. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5126. }
  5127. }
  5128. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5129. $KOP = true;
  5130. }
  5131. }
  5132. foreach ( $roleArrayCopy as $k => $v ) {
  5133. foreach ( $verifyList as $m => $n ) {
  5134. if ($n [0] == $k) {
  5135. array_splice ( $verifyList, $m, 1, $v );
  5136. }
  5137. }
  5138. }
  5139. $receiptList [$key] ['verifyList'] = $verifyList;
  5140. $receiptList [$key] ['executeList'] = $executeList;
  5141. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5142. 'where' => 'sid=' . $value ['staff'],
  5143. 'asArray' => true
  5144. ) );
  5145. $receiptList [$key] ['button2'] = $button2;
  5146. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5147. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5148. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5149. $receiptList [$key] ['relust'] = $relust;
  5150. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5151. }
  5152. // 是否写入过流水
  5153. $accountType = 0;
  5154. if ($receiptList [0] ['Rtype'] == 0) {
  5155. $accountType = 3;
  5156. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5157. if (!empty($receiptList [0]['accountItem']) )
  5158. $accountType = 2;
  5159. else
  5160. $accountType = 1;
  5161. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5162. $accountType = 4;
  5163. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5164. $accountType = 12;
  5165. }
  5166. Doo::loadModel ( 'wasteBook' );
  5167. $wasteBook = new wasteBook ();
  5168. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5169. $data ['wbDetail'] = $wbDetail;
  5170. $wbDetailLoan=array();
  5171. if ($accountType==2){
  5172. $wbDetailLoan = $wasteBook->getWateBookByAD ( 1, $receiptList [0] ['rid'] );
  5173. }
  5174. $data ['wbDetailLoan'] = $wbDetailLoan;
  5175. //print_r($receiptList);
  5176. $data ['receiptList'] = $receiptList;
  5177. $data ['memu'] = "receipt";
  5178. $data ['staff'] = $this->staff;
  5179. $data ['receiptMemu'] = 'implement';
  5180. $data ['verifyId'] = $this->verifyId;
  5181. $data ['executeId'] = $this->executeId;
  5182. $this->render ( "/admin/implement", $data );
  5183. }
  5184. function implementDo() {
  5185. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5186. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5187. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5188. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5189. // $ab = '';
  5190. // if ($accountBank == 'CGBDeposit')
  5191. // $ab = '纵横广发';
  5192. // elseif ($accountBank == 'ICBCDeposit')
  5193. // $ab = '纵横工行';
  5194. // elseif ($accountBank == 'HUADeposit')
  5195. // $ab = '华润银行';
  5196. // elseif ($accountBank == 'PersonalDeposit')
  5197. // $ab = '个人广发';
  5198. // if (empty ( $ab ))
  5199. // die ( 'illegal request--22' );
  5200. if (! empty ( $rid )) {
  5201. Doo::loadModel ( 'receipt' );
  5202. $receipt = new receipt ();
  5203. // Doo::loadClass ( 'XDeode' );
  5204. // $XDeode = new XDeode ( 5 );
  5205. // $rinfo = $receipt->getOne ( array (
  5206. // 'where' => 'rid=' . $rid,
  5207. // 'asArray' => true
  5208. // ) );
  5209. $rinfo = $receipt->getReceiptByRid ( $rid );
  5210. // $accountType = '';
  5211. // if ($rinfo ['Rtype'] == 1) {
  5212. // if ($rinfo ['loanRid'] != 0)//判断有问题
  5213. // $accountType = 2;
  5214. // else
  5215. // $accountType = 1;
  5216. // } elseif ($rinfo ['Rtype'] == 2) {
  5217. // $accountType = 4;
  5218. // } elseif ($rinfo ['Rtype'] == 0)
  5219. // $accountType = 3;
  5220. // if (empty ( $accountType ))
  5221. // die ( 'illegal request' );
  5222. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5223. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5224. if (empty ( $executeStaff )) {
  5225. $executeStaff = array (
  5226. $this->staff [0] ['sid'] => array (
  5227. 'date' => date ( 'Y-m-d' ),
  5228. 'opinion' => $implementOpinions,
  5229. 'status' => 1
  5230. )
  5231. );
  5232. } else {
  5233. $executeStaff [$this->staff [0] ['sid']] = array (
  5234. 'date' => date ( 'Y-m-d' ),
  5235. 'opinion' => $implementOpinions,
  5236. 'status' => 1
  5237. );
  5238. }
  5239. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5240. $receipt->executeStaff = json_encode ( $executeStaff );
  5241. $receipt->status = 8;
  5242. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5243. $receipt->status = 9;
  5244. if ($rinfo ['status'] == 6) {
  5245. $receipt->loanDate = date ( "Y-m-d" );
  5246. }
  5247. $receipt->executeDate = date ( "Y-m-d" );
  5248. } else {
  5249. $receipt->executeStaff = json_encode ( $executeStaff );
  5250. }
  5251. //$receipt->amount = $amount;
  5252. $receipt->update ( array (
  5253. 'where' => 'rid=' . $rid
  5254. ) );
  5255. // 公司流水记录
  5256. // Doo::loadModel ( 'wasteBook' );
  5257. // $wasteBook = new wasteBook ();
  5258. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5259. // // 银行
  5260. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5261. // $item = array (
  5262. // 'dataID' => $rid,
  5263. // 'expensesType' => 2,
  5264. // 'accountType' => $accountType,
  5265. // 'accountPriceShow' => $amount,
  5266. // 'accountPrice' => - $amount,
  5267. // 'accountBank' => $accountBank,
  5268. // 'category' => $rinfo ['category'] [0] ['title'],
  5269. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5270. // 'name' => $rinfo ['staffDetail'] ['username'],
  5271. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5272. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5273. // );
  5274. // $wasteBook->setAccountBookStatistics ( $item );
  5275. // }
  5276. }
  5277. //$ridKey = $XDeode->encode ( $rid );
  5278. return "/hisImplement";
  5279. // return "/implement/" . $ridKey . ".html";
  5280. }
  5281. function receiptburEdi() {
  5282. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5283. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5284. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5285. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5286. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5287. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5288. if (empty ( $status ))
  5289. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5290. $vidList = array ();
  5291. $button = 0;
  5292. Doo::loadModel ( 'verify' );
  5293. Doo::loadModel ( 'receipt' );
  5294. Doo::loadModel ( 'staff' );
  5295. $staff = new staff ();
  5296. $receipt = new receipt ();
  5297. $verify = new verify ();
  5298. Doo::loadModel ( 'L_category' );
  5299. $Lcategory = new L_category ();
  5300. Doo::loadModel ( 'enclosur' );
  5301. $enclosur = new enclosur ();
  5302. Doo::loadModel ( 'loanReceipt' );
  5303. $loanReceipt = new loanReceipt ();
  5304. // user verify ID
  5305. $verifyDetail = $verify->find ( array (
  5306. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5307. 'asArray' => true
  5308. ) );
  5309. foreach ( $verifyDetail as $key => $value ) {
  5310. array_push ( $vidList, $value ['vid'] );
  5311. }
  5312. $vid = implode ( ",", $vidList );
  5313. if (empty ( $verifyDetail ))
  5314. $vid = 0;
  5315. $categoryList = $Lcategory->find ( array (
  5316. 'asArray' => true
  5317. ) );
  5318. $staffList = $staff->find ( array (
  5319. 'where' => 'cid=' . $cid,
  5320. 'asArray' => true
  5321. ) );
  5322. $ap = "";
  5323. if ($status == 4) {
  5324. $ap = 4;
  5325. $status = 2;
  5326. }
  5327. // get Receipt By verifyID status 2
  5328. $receiptList = $receipt->find ( array (
  5329. 'where' => 'rid =' . $rid . ' and status=2',
  5330. 'desc' => 'rid',
  5331. 'asArray' => true
  5332. ) );
  5333. if (empty ( $receiptList )) {
  5334. die ( 'illegal request' );
  5335. }
  5336. $loanList = $loanReceipt->find ( array (
  5337. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5338. 'desc' => 'rid',
  5339. 'asArray' => true
  5340. ) );
  5341. $data ['explanation'] = '';
  5342. if (! empty ( $loanList ))
  5343. $data ['explanation'] = $loanList [0] ['explanation'];
  5344. $Locate = 0;
  5345. $roleId = 0;
  5346. $button = 0;
  5347. foreach ( $loanList as $key => $value ) {
  5348. $loanList [$key] ['Locate'] = $Locate;
  5349. $Locate ++;
  5350. $loanList [$key] ['reviseDetail'] = array ();
  5351. if (! empty ( $value ['reviseDetail'] ))
  5352. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5353. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5354. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5355. $categoryDetil = $Lcategory->getOne ( array (
  5356. 'where' => 'cid=' . $value ['cid'],
  5357. 'asArray' => true
  5358. ) );
  5359. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5360. // 检测编辑状态
  5361. $verifyList = $verify->getOne ( array (
  5362. 'where' => 'vid=' . $value ['verify'],
  5363. 'asArray' => true
  5364. ) );
  5365. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5366. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5367. Doo::loadModel ( 'role' );
  5368. $role = new role ();
  5369. $flag = true;
  5370. $roleKey = 0;
  5371. $endStaffArray = array ();
  5372. $roleArrayCopy = array ();
  5373. foreach ( $verifyList as $k => $v ) {
  5374. // init verifyStaff
  5375. if ($v [1] == 'ROLE') {
  5376. if (! empty ( $verifyStaff )) {
  5377. $endStaffArray = end ( $verifyStaff );
  5378. }
  5379. $roleVerify = json_decode ( $v [3], true );
  5380. $roleKey = $k;
  5381. $roleArray = array ();
  5382. $rolename = $role->getOne ( array (
  5383. 'where' => 'rid=' . $v [0],
  5384. 'asArray' => true
  5385. ) );
  5386. foreach ( $roleVerify as $o => $p ) {
  5387. $staffID = explode ( '_', $p );
  5388. $staffInfo = $staff->getOne ( array (
  5389. 'where' => 'sid=' . $staffID [0],
  5390. 'asArray' => true
  5391. ) );
  5392. // print_r($staffID);
  5393. $exp = array (
  5394. 0 => $staffInfo ['sid'],
  5395. 1 => $staffID [1],
  5396. 2 => $staffInfo ['avatar'],
  5397. 'date' => '',
  5398. 'date' => '',
  5399. 'opinion' => '',
  5400. 'status' => '',
  5401. 'rolename' => $rolename ['name']
  5402. );
  5403. array_push ( $roleArray, $exp );
  5404. }
  5405. $roleArrayCopy [$v [0]] = $roleArray;
  5406. // $verifyList[$k]['roleArray']=$roleArray;
  5407. }
  5408. $verifyList [$k] ['date'] = "";
  5409. $verifyList [$k] ['opinion'] = "";
  5410. $verifyList [$k] ['status'] = "";
  5411. if (empty ( $verifyStaff )) {
  5412. $verifyList [$k] ['date'] = "";
  5413. $verifyList [$k] ['opinion'] = "";
  5414. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5415. $verifyList [$k] ['status'] = 4;
  5416. $flag = false;
  5417. }
  5418. } else {
  5419. foreach ( $verifyStaff as $m => $u ) {
  5420. if ($v [0] == $m) {
  5421. $verifyList [$k] ['date'] = $u ['date'];
  5422. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5423. $verifyList [$k] ['status'] = $u ['status'];
  5424. $flag = false;
  5425. break;
  5426. }
  5427. }
  5428. $endStaffArray = end ( $verifyStaff );
  5429. if (isset ( $endStaffArray ['ROLE'] )) {
  5430. } else {
  5431. }
  5432. }
  5433. }
  5434. $rolename ['name'] = '';
  5435. if (! empty ( $roleId )) {
  5436. Doo::loadModel ( 'role' );
  5437. $role = new role ();
  5438. $rolename = $role->getOne ( array (
  5439. 'where' => 'rid=' . $roleId,
  5440. 'asArray' => true
  5441. ) );
  5442. }
  5443. if (! empty ( $verifyStaff ))
  5444. $endStaffArray = end ( $verifyStaff );
  5445. $KOP = false;
  5446. foreach ( $roleArrayCopy as $P => $A ) {
  5447. foreach ( $A as $MKI => $AVL ) {
  5448. if (! empty ( $verifyStaff )) {
  5449. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5450. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5451. $button = 4;
  5452. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5453. }
  5454. foreach ( $verifyStaff as $m => $u ) {
  5455. $AVLFK = $AVL [0] . '_R';
  5456. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5457. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5458. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5459. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5460. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5461. break;
  5462. }
  5463. }
  5464. } else {
  5465. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5466. $button = 4;
  5467. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5468. }
  5469. }
  5470. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5471. $KOP = true;
  5472. }
  5473. }
  5474. foreach ( $roleArrayCopy as $k => $v ) {
  5475. foreach ( $verifyList as $m => $n ) {
  5476. if ($n [0] == $k) {
  5477. array_splice ( $verifyList, $m, 1, $v );
  5478. }
  5479. }
  5480. }
  5481. $loanList [$key] ['verifyList'] = $verifyList;
  5482. }
  5483. $htmlLoan = '';
  5484. $data ['loanReceiptDate'] = '';
  5485. if (isset ( $loanList [0] )) {
  5486. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5487. if ($value ['status'] == 1)
  5488. $htmlLoan .= '<li class="done" >';
  5489. elseif ($value ['status'] == 3)
  5490. $htmlLoan .= '<li class="undone" >';
  5491. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5492. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5493. if (isset ( $value ['rolename'] ))
  5494. $htmlLoan .= $value ['rolename'];
  5495. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5496. }
  5497. $data ['loanDate'] = $loanList [0] ['date'];
  5498. } else {
  5499. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5500. }
  5501. $data ['htmlLoan'] = $htmlLoan;
  5502. // $data ['LoanReceipt']=$loanList[0];
  5503. // print_r($loanList);
  5504. $Locate = 0;
  5505. $roleId = 0;
  5506. $button = 0;
  5507. if ($ap == 4)
  5508. $status = 4;
  5509. Doo::loadClass ( 'XDeode' );
  5510. $XDeode = new XDeode ( 5 );
  5511. foreach ( $receiptList as $key => $value ) {
  5512. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5513. $receiptList [$key] ['Locate'] = $Locate;
  5514. $Locate ++;
  5515. $receiptList [$key] ['reviseDetail'] = array ();
  5516. // 调整金额 代码调整
  5517. if (! empty ( $value ['reviseDetail'] )) {
  5518. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5519. foreach ( $reviseDetail as $ry => $re ) {
  5520. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5521. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5522. }
  5523. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5524. // print_r($reviseDetail);
  5525. }
  5526. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5527. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5528. $categoryDetil = $Lcategory->getOne ( array (
  5529. 'where' => 'cid=' . $value ['cid'],
  5530. 'asArray' => true
  5531. ) );
  5532. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5533. // 检测编辑状态
  5534. $verifyList = $verify->getOne ( array (
  5535. 'where' => 'vid=' . $value ['verify'],
  5536. 'asArray' => true
  5537. ) );
  5538. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5539. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5540. Doo::loadModel ( 'role' );
  5541. $role = new role ();
  5542. // print_r($verifyList);
  5543. $flag = true;
  5544. $roleKey = 0;
  5545. $endStaffArray = array ();
  5546. $roleArrayCopy = array ();
  5547. foreach ( $verifyList as $k => $v ) {
  5548. // init verifyStaff
  5549. if ($v [1] == 'ROLE') {
  5550. if (! empty ( $verifyStaff )) {
  5551. $endStaffArray = end ( $verifyStaff );
  5552. if ($v [0] == $endStaffArray ['nextStaff']) {
  5553. $roleId = $v [0];
  5554. }
  5555. }
  5556. $roleVerify = json_decode ( $v [3], true );
  5557. $roleKey = $k;
  5558. $roleArray = array ();
  5559. $rolename = $role->getOne ( array (
  5560. 'where' => 'rid=' . $v [0],
  5561. 'asArray' => true
  5562. ) );
  5563. foreach ( $roleVerify as $o => $p ) {
  5564. $staffID = explode ( '_', $p );
  5565. $staffInfo = $staff->getOne ( array (
  5566. 'where' => 'sid=' . $staffID [0],
  5567. 'asArray' => true
  5568. ) );
  5569. // print_r($staffID);
  5570. $exp = array (
  5571. 0 => $staffInfo ['sid'],
  5572. 1 => $staffID [1],
  5573. 2 => $staffInfo ['avatar'],
  5574. 'date' => '',
  5575. 'date' => '',
  5576. 'opinion' => '',
  5577. 'status' => '',
  5578. 'rolename' => $rolename ['name']
  5579. );
  5580. array_push ( $roleArray, $exp );
  5581. }
  5582. $roleArrayCopy [$v [0]] = $roleArray;
  5583. // $verifyList[$k]['roleArray']=$roleArray;
  5584. }
  5585. // print_r($roleArray);
  5586. $verifyList [$k] ['date'] = "";
  5587. $verifyList [$k] ['opinion'] = "";
  5588. $verifyList [$k] ['status'] = "";
  5589. if (empty ( $verifyStaff )) {
  5590. $verifyList [$k] ['date'] = "";
  5591. $verifyList [$k] ['opinion'] = "";
  5592. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5593. $verifyList [$k] ['status'] = 4;
  5594. $button = 4;
  5595. $flag = false;
  5596. }
  5597. } else {
  5598. foreach ( $verifyStaff as $m => $u ) {
  5599. if ($v [0] == $m) {
  5600. $verifyList [$k] ['date'] = $u ['date'];
  5601. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5602. $verifyList [$k] ['status'] = $u ['status'];
  5603. $flag = false;
  5604. break;
  5605. }
  5606. }
  5607. $endStaffArray = end ( $verifyStaff );
  5608. if (isset ( $endStaffArray ['ROLE'] )) {
  5609. } else {
  5610. $endKey = key ( $verifyStaff );
  5611. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5612. $button = 4;
  5613. $verifyList [$k] ['status'] = 4;
  5614. }
  5615. }
  5616. }
  5617. }
  5618. $rolename ['name'] = '';
  5619. if (! empty ( $roleId )) {
  5620. Doo::loadModel ( 'role' );
  5621. $role = new role ();
  5622. $rolename = $role->getOne ( array (
  5623. 'where' => 'rid=' . $roleId,
  5624. 'asArray' => true
  5625. ) );
  5626. }
  5627. if (! empty ( $verifyStaff ))
  5628. $endStaffArray = end ( $verifyStaff );
  5629. $KOP = false;
  5630. foreach ( $roleArrayCopy as $P => $A ) {
  5631. foreach ( $A as $MKI => $AVL ) {
  5632. if (! empty ( $verifyStaff )) {
  5633. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5634. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5635. $button = 4;
  5636. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5637. }
  5638. foreach ( $verifyStaff as $m => $u ) {
  5639. $AVLFK = $AVL [0] . '_R';
  5640. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5641. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5642. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5643. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5644. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5645. break;
  5646. }
  5647. }
  5648. } else {
  5649. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5650. $button = 4;
  5651. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5652. }
  5653. }
  5654. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5655. $KOP = true;
  5656. }
  5657. }
  5658. foreach ( $roleArrayCopy as $k => $v ) {
  5659. foreach ( $verifyList as $m => $n ) {
  5660. if ($n [0] == $k) {
  5661. array_splice ( $verifyList, $m, 1, $v );
  5662. }
  5663. }
  5664. }
  5665. // print_r($verifyList);
  5666. $receiptList [$key] ['verifyList'] = $verifyList;
  5667. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5668. 'where' => 'sid=' . $value ['staff'],
  5669. 'asArray' => true
  5670. ) );
  5671. $receiptList [$key] ['button'] = $button;
  5672. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5673. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5674. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5675. $receiptList [$key] ['relust'] = $relust;
  5676. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5677. }
  5678. // print_r($receiptList);die;
  5679. // $data['verifyDetail']=$verifyDetail;
  5680. $mothHtml = "";
  5681. for($i = 1; $i <= 12; $i ++) {
  5682. if ($month == $i)
  5683. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5684. else
  5685. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5686. }
  5687. // 获取审批日志
  5688. Doo::loadModel ( 'receiptLog' );
  5689. $receiptLog = new receiptLog ();
  5690. $rlList = array ();
  5691. $rlInfo = $receiptLog->getOne ( array (
  5692. 'where' => 'rid=' . $rid . ' and status=4',
  5693. 'asArray' => true
  5694. ) );
  5695. $tijdate = $receiptLog->getOne ( array (
  5696. 'where' => 'rid=' . $rid . ' and status=2',
  5697. 'asc' => 'rlid',
  5698. 'asArray' => true
  5699. ) );
  5700. if (! empty ( $rlInfo )) {
  5701. $rlList = $receiptLog->find ( array (
  5702. 'where' => 'rid=' . $rid,
  5703. 'asc' => 'rlid',
  5704. 'asArray' => true
  5705. ) );
  5706. }
  5707. // echo $rid;
  5708. // print_r($receiptList);
  5709. $receiptList [0] ['rlList'] = $rlList;
  5710. // print_r($receiptList);
  5711. $enclosurList = $enclosur->find ( array (
  5712. 'where' => 'rid=' . $rid,
  5713. 'asArray' => true
  5714. ) );
  5715. $enclosurHtml = '';
  5716. foreach ( $enclosurList as $value ) {
  5717. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5718. }
  5719. $data ['enclosurHtml'] = $enclosurHtml;
  5720. $data ['rolename'] = $rolename ['name'];
  5721. $data ['mothHtml'] = $mothHtml;
  5722. // print_r($receiptList);
  5723. $data ['rid'] = $rid;
  5724. $data ['tijdate'] = $tijdate ['date'];
  5725. $data ['receiptList'] = $receiptList;
  5726. $data ['receiptApprovalCount'] = count ( $receiptList );
  5727. $data ['status'] = $status;
  5728. $data ['year'] = $year;
  5729. $data ['categoryList'] = $categoryList;
  5730. $data ['staffList'] = $staffList;
  5731. $data ['cid'] = $cid;
  5732. $data ['sid'] = $sid;
  5733. $data ['ap'] = $ap;
  5734. $data ['memu'] = "receipt";
  5735. $data ['staff'] = $this->staff;
  5736. $data ['receiptMemu'] = 'approvalExpenses';
  5737. $data ['verifyId'] = $this->verifyId;
  5738. $data ['executeId'] = $this->executeId;
  5739. $this->render ( "/admin/receiptburEdi", $data );
  5740. }
  5741. function hisImplement() {
  5742. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5743. if (empty ( $item ))
  5744. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5745. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5746. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5747. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5748. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5749. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5750. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5751. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5752. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5753. Doo::loadClass ( 'XDeode' );
  5754. $XDeode = new XDeode ( 5 );
  5755. Doo::loadModel ( 'receipt' );
  5756. $receipt = new receipt ();
  5757. Doo::loadModel ( 'L_category' );
  5758. $Lcategory = new L_category ();
  5759. Doo::loadModel ( 'verify' );
  5760. Doo::loadModel ( 'statistics' );
  5761. $statistics = new statistics ();
  5762. $verify = new verify ();
  5763. Doo::loadModel ( 'staff' );
  5764. $staff = new staff ();
  5765. Doo::loadClass ( 'XDeode' );
  5766. $XDeode = new XDeode ( 5 );
  5767. $XDeode7 = new XDeode ( 7 );
  5768. $cid = $XDeode->decode ( $cidKey );
  5769. $condition = "";
  5770. if ($item == "expenses")
  5771. $condition = " and Rtype=1 ";
  5772. elseif ($item == "receipts")
  5773. $condition = " and Rtype=0 ";
  5774. elseif ($item == "remits")
  5775. $condition = " and Rtype=2 ";
  5776. elseif($item == "train")
  5777. $condition = " and Rtype=3 ";
  5778. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5779. $sopString = $cidString = "";
  5780. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5781. if (empty ( $rdate ))
  5782. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5783. else
  5784. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5785. if ($status == 'pendImplement') {
  5786. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5787. } elseif ($status == 'alerpts') {
  5788. $statusCon = '(status=8 or status=9 )';
  5789. if (empty ( $rdate ))
  5790. $dateCondition .= " and Year(date) =" . $year;
  5791. else
  5792. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5793. }
  5794. if ($sop != 'SOP')
  5795. $sopString = " and staff=" . $sop;
  5796. if ($cidKey != 'ALL')
  5797. $cidString = " and cid=" . $cid;
  5798. if(!empty($receiptOrder)){
  5799. $receiptList = $receipt->find ( array (
  5800. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5801. 'desc' => 'rid',
  5802. 'asArray' => true
  5803. ) );
  5804. // 员工筛选
  5805. $receiptList2 = $receipt->find ( array (
  5806. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5807. 'desc' => 'rid',
  5808. 'asArray' => true
  5809. ) );
  5810. }else{
  5811. $receiptList = $receipt->find ( array (
  5812. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5813. 'desc' => 'rid',
  5814. 'asArray' => true
  5815. ) );
  5816. // 员工筛选
  5817. $receiptList2 = $receipt->find ( array (
  5818. 'where' => $statusCon . $condition . $dateCondition,
  5819. 'desc' => 'rid',
  5820. 'asArray' => true
  5821. ) );
  5822. }
  5823. $sopStaff = array ();
  5824. foreach ( $receiptList2 as $key => $value ) {
  5825. $staffDetail = $staff->getOne ( array (
  5826. 'select' => 'username',
  5827. 'where' => 'sid=' . $value ['staff'],
  5828. 'asArray' => true
  5829. ) );
  5830. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5831. }
  5832. // 办事处筛选
  5833. $categoryScreen = array ();
  5834. $categorList = $Lcategory->getCategory ();
  5835. foreach ( $receiptList2 as $key => $value ) {
  5836. foreach ( $categorList as $k => $v ) {
  5837. if ($value ['cid'] == $v ['cid']) {
  5838. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5839. break;
  5840. }
  5841. }
  5842. }
  5843. $categoryScreenHtml = "";
  5844. foreach ( $categoryScreen as $key => $value ) {
  5845. if ($cidKey == $key)
  5846. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5847. else
  5848. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5849. }
  5850. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5851. $data ['cidKey'] = $cidKey;
  5852. $Locate = 0;
  5853. $roleId = 0;
  5854. $button = 0;
  5855. $staffBatchNumber = 100001;
  5856. $remittanceList = array ();
  5857. foreach ( $receiptList as $key => $value ) {
  5858. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5859. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5860. $receiptList [$key] ['Texe'] = 'false';
  5861. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5862. $receiptList [$key] ['Texe'] = 'true';
  5863. }
  5864. $receiptList [$key] ['TRexe'] = 'true';
  5865. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5866. $receiptList [$key] ['TRexe'] = 'false';
  5867. }
  5868. $receiptList [$key] ['Locate'] = $Locate;
  5869. $Locate ++;
  5870. $receiptList [$key] ['reviseDetail'] = array ();
  5871. if (! empty ( $value ['reviseDetail'] ))
  5872. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5873. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5874. $categoryDetil = $Lcategory->getOne ( array (
  5875. 'where' => 'cid=' . $value ['cid'],
  5876. 'asArray' => true
  5877. ) );
  5878. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5879. // 检测编辑状态
  5880. $verifyList = $verify->getOne ( array (
  5881. 'where' => 'vid=' . $value ['verify'],
  5882. 'asArray' => true
  5883. ) );
  5884. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5885. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5886. Doo::loadModel ( 'role' );
  5887. $role = new role ();
  5888. $flag = true;
  5889. $roleKey = 0;
  5890. $endStaffArray = array ();
  5891. $roleArrayCopy = array ();
  5892. foreach ( $verifyList as $k => $v ) {
  5893. // init verifyStaff
  5894. if ($v [1] == 'ROLE') {
  5895. if (! empty ( $verifyStaff )) {
  5896. $endStaffArray = end ( $verifyStaff );
  5897. }
  5898. $roleVerify = json_decode ( $v [3], true );
  5899. $roleKey = $k;
  5900. $roleArray = array ();
  5901. $rolename = $role->getOne ( array (
  5902. 'where' => 'rid=' . $v [0],
  5903. 'asArray' => true
  5904. ) );
  5905. foreach ( $roleVerify as $o => $p ) {
  5906. $staffID = explode ( '_', $p );
  5907. $staffInfo = $staff->getOne ( array (
  5908. 'where' => 'sid=' . $staffID [0],
  5909. 'asArray' => true
  5910. ) );
  5911. $exp = array (
  5912. 0 => $staffInfo ['sid'],
  5913. 1 => $staffID [1],
  5914. 2 => $staffInfo ['avatar'],
  5915. 'date' => '',
  5916. 'date' => '',
  5917. 'opinion' => '',
  5918. 'status' => '',
  5919. 'rolename' => $rolename ['name']
  5920. );
  5921. array_push ( $roleArray, $exp );
  5922. }
  5923. $roleArrayCopy [$v [0]] = $roleArray;
  5924. }
  5925. $verifyList [$k] ['date'] = "";
  5926. $verifyList [$k] ['opinion'] = "";
  5927. $verifyList [$k] ['status'] = "";
  5928. if (empty ( $verifyStaff )) {
  5929. $verifyList [$k] ['date'] = "";
  5930. $verifyList [$k] ['opinion'] = "";
  5931. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5932. $verifyList [$k] ['status'] = 4;
  5933. $flag = false;
  5934. }
  5935. } else {
  5936. foreach ( $verifyStaff as $m => $u ) {
  5937. if ($v [0] == $m) {
  5938. $verifyList [$k] ['date'] = $u ['date'];
  5939. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5940. $verifyList [$k] ['status'] = $u ['status'];
  5941. $flag = false;
  5942. break;
  5943. }
  5944. }
  5945. $endStaffArray = end ( $verifyStaff );
  5946. }
  5947. }
  5948. $rolename ['name'] = '';
  5949. if (! empty ( $roleId )) {
  5950. Doo::loadModel ( 'role' );
  5951. $role = new role ();
  5952. $rolename = $role->getOne ( array (
  5953. 'where' => 'rid=' . $roleId,
  5954. 'asArray' => true
  5955. ) );
  5956. }
  5957. if (! empty ( $verifyStaff ))
  5958. $endStaffArray = end ( $verifyStaff );
  5959. $KOP = false;
  5960. foreach ( $roleArrayCopy as $P => $A ) {
  5961. foreach ( $A as $MKI => $AVL ) {
  5962. if (! empty ( $verifyStaff )) {
  5963. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5964. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5965. $button = 4;
  5966. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5967. }
  5968. foreach ( $verifyStaff as $m => $u ) {
  5969. $AVLFK = $AVL [0] . '_R';
  5970. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5971. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5972. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5973. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5974. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5975. break;
  5976. }
  5977. }
  5978. } else {
  5979. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5980. $button = 4;
  5981. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5982. }
  5983. }
  5984. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5985. $KOP = true;
  5986. }
  5987. }
  5988. foreach ( $roleArrayCopy as $k => $v ) {
  5989. foreach ( $verifyList as $m => $n ) {
  5990. if ($n [0] == $k) {
  5991. array_splice ( $verifyList, $m, 1, $v );
  5992. }
  5993. }
  5994. }
  5995. $receiptList [$key] ['verifyList'] = $verifyList;
  5996. $staffDetail = $staff->getOne ( array (
  5997. 'where' => 'sid=' . $value ['staff'],
  5998. 'asArray' => true
  5999. ) );
  6000. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6001. $receiptList [$key] ['button'] = $button;
  6002. // 设置导出汇款execl
  6003. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6004. $remittanceDetail = array (
  6005. $staffBatchNumber,
  6006. $value ['remittanceName'],
  6007. $value ['bankNumber'],
  6008. $value ['bankName'],
  6009. $value ['remittanceBankType'],
  6010. $value ['coupletNumber'],
  6011. $value ['sum']
  6012. );
  6013. array_push ( $remittanceList, $remittanceDetail );
  6014. $staffBatchNumber ++;
  6015. }
  6016. }
  6017. $data ['remittanceList'] = json_encode ( $remittanceList );
  6018. // print_r($receiptList);
  6019. $mothHtml = "";
  6020. for($i = 1; $i <= 12; $i ++) {
  6021. if ($moth == $i)
  6022. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6023. else
  6024. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6025. }
  6026. $dayHtml = "";
  6027. if ($day != "DAY" || $moth != "MONTH") {
  6028. for($i = 1; $i <= 31; $i ++) {
  6029. if ($day == $i)
  6030. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6031. else
  6032. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6033. }
  6034. }
  6035. $sopHtml = "";
  6036. foreach ( $sopStaff as $key => $value ) {
  6037. if ($sop == $key)
  6038. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6039. else
  6040. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6041. }
  6042. $data ['status'] = $status;
  6043. $data ['rdate'] = $rdate;
  6044. $data ['sopHtml'] = $sopHtml;
  6045. $data ['dayHtml'] = $dayHtml;
  6046. $data ['mothHtml'] = $mothHtml;
  6047. $data ['receiptList'] = $receiptList;
  6048. $data ['memu'] = "receipt";
  6049. $data ['staff'] = $this->staff;
  6050. $data ['receiptMemu'] = 'implement';
  6051. $data ['verifyId'] = $this->verifyId;
  6052. $data ['executeId'] = $this->executeId;
  6053. $data ['item'] = $item;
  6054. $data ['year'] = $year;
  6055. $data ['moth'] = $moth;
  6056. $data['receiptOrder']=$receiptOrder;
  6057. $data ['day'] = $day;
  6058. $data ['sop'] = $sop;
  6059. $this->render ( "/admin/hisImplement", $data );
  6060. }
  6061. /**
  6062. * 导出汇款信息的exelc
  6063. */
  6064. function exportRemittance() {
  6065. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6066. if (empty ( $remittanceInfo ))
  6067. die ( 'illegal request' );
  6068. $title = array (
  6069. '员工编号',
  6070. '姓名',
  6071. '员工账号',
  6072. '员工账户开户行',
  6073. '转账类型',
  6074. '联行号',
  6075. '金额'
  6076. );
  6077. $data = json_decode ( $remittanceInfo, true );
  6078. if (empty ( $data ))
  6079. die ( 'illegal request' );
  6080. Doo::loadClass ( 'receipt.func' );
  6081. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6082. header ( 'Content-Type:text/html;charset=utf-8' );
  6083. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6084. }
  6085. function ajaxExamine() {
  6086. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6087. Doo::loadModel ( 'receipt' );
  6088. $receipt = new receipt ();
  6089. if (! empty ( $rid )) {
  6090. $rLRes = $receipt->find ( array (
  6091. '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,
  6092. 'asArray' => true
  6093. ) );
  6094. echo json_encode ( array (
  6095. 'status' => 1,
  6096. 'receipt' => $rLRes [0]
  6097. ) );
  6098. die ();
  6099. }
  6100. echo json_encode ( array (
  6101. 'status' => 0,
  6102. 'receipt' => array ()
  6103. ) );
  6104. die ();
  6105. }
  6106. /*
  6107. * 废弃
  6108. */
  6109. function myReceipt() {
  6110. // all approval past withdraw
  6111. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6112. if (empty ( $item ))
  6113. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6114. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6115. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6116. Doo::loadModel ( 'receipt' );
  6117. $receipt = new receipt ();
  6118. // pre-loaded
  6119. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6120. // have cache
  6121. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6122. if (! empty ( $moth )) // yearPage
  6123. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6124. $this->showCache ( $path );
  6125. }
  6126. Doo::loadModel ( 'L_category' );
  6127. $Lcategory = new L_category ();
  6128. Doo::loadModel ( 'verify' );
  6129. Doo::loadModel ( 'statistics' );
  6130. $statistics = new statistics ();
  6131. $verify = new verify ();
  6132. Doo::loadModel ( 'staff' );
  6133. $staff = new staff ();
  6134. $condition = " and status!=0 ";
  6135. if ($item == "approval")
  6136. $condition = " and status=2 ";
  6137. elseif ($item == "withdraw")
  6138. $condition = " and status=3 ";
  6139. elseif ($item == "past")
  6140. $condition = " and status=1 ";
  6141. elseif ($item == "whdw")
  6142. $condition = " and status=4 ";
  6143. $dateCondition = " and Year(date) =" . $year;
  6144. if (! empty ( $moth )) {
  6145. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6146. $stList = $statistics->getOne ( array (
  6147. 'select' => 'rePrice ,agPrice',
  6148. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6149. 'asArray' => true
  6150. ) );
  6151. } else
  6152. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6153. if (empty ( $stList ))
  6154. $stList = array (
  6155. 'rePrice' => 0,
  6156. 'agPrice' => 0
  6157. );
  6158. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6159. $data ['stList'] = array (
  6160. 'rePrice' => $stList ['rePrice'],
  6161. 'agPrice' => $stList ['agPrice'],
  6162. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6163. );
  6164. $receiptList = $receipt->find ( array (
  6165. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6166. 'desc' => 'rid',
  6167. 'asArray' => true
  6168. ) );
  6169. $Locate = 0;
  6170. $roleId = 0;
  6171. $button = 0;
  6172. foreach ( $receiptList as $key => $value ) {
  6173. $receiptList [$key] ['Locate'] = $Locate;
  6174. $Locate ++;
  6175. $receiptList [$key] ['reviseDetail'] = array ();
  6176. if (! empty ( $value ['reviseDetail'] ))
  6177. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6178. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6179. $categoryDetil = $Lcategory->getOne ( array (
  6180. 'where' => 'cid=' . $value ['cid'],
  6181. 'asArray' => true
  6182. ) );
  6183. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6184. // 检测编辑状态
  6185. $verifyList = $verify->getOne ( array (
  6186. 'where' => 'vid=' . $value ['verify'],
  6187. 'asArray' => true
  6188. ) );
  6189. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6190. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6191. Doo::loadModel ( 'role' );
  6192. $role = new role ();
  6193. $flag = true;
  6194. $roleKey = 0;
  6195. $endStaffArray = array ();
  6196. $roleArrayCopy = array ();
  6197. foreach ( $verifyList as $k => $v ) {
  6198. // init verifyStaff
  6199. if ($v [1] == 'ROLE') {
  6200. if (! empty ( $verifyStaff )) {
  6201. $endStaffArray = end ( $verifyStaff );
  6202. // if ($v[0]==$endStaffArray['nextStaff']){
  6203. // $roleId=$v[0];
  6204. // }
  6205. }
  6206. $roleVerify = json_decode ( $v [3], true );
  6207. $roleKey = $k;
  6208. $roleArray = array ();
  6209. $rolename = $role->getOne ( array (
  6210. 'where' => 'rid=' . $v [0],
  6211. 'asArray' => true
  6212. ) );
  6213. foreach ( $roleVerify as $o => $p ) {
  6214. $staffID = explode ( '_', $p );
  6215. $staffInfo = $staff->getOne ( array (
  6216. 'where' => 'sid=' . $staffID [0],
  6217. 'asArray' => true
  6218. ) );
  6219. // print_r($staffID);
  6220. $exp = array (
  6221. 0 => $staffInfo ['sid'],
  6222. 1 => $staffID [1],
  6223. 2 => $staffInfo ['avatar'],
  6224. 'date' => '',
  6225. 'date' => '',
  6226. 'opinion' => '',
  6227. 'status' => '',
  6228. 'rolename' => $rolename ['name']
  6229. );
  6230. array_push ( $roleArray, $exp );
  6231. }
  6232. $roleArrayCopy [$v [0]] = $roleArray;
  6233. // $verifyList[$k]['roleArray']=$roleArray;
  6234. }
  6235. $verifyList [$k] ['date'] = "";
  6236. $verifyList [$k] ['opinion'] = "";
  6237. $verifyList [$k] ['status'] = "";
  6238. if (empty ( $verifyStaff )) {
  6239. $verifyList [$k] ['date'] = "";
  6240. $verifyList [$k] ['opinion'] = "";
  6241. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6242. $verifyList [$k] ['status'] = 4;
  6243. $flag = false;
  6244. }
  6245. } else {
  6246. foreach ( $verifyStaff as $m => $u ) {
  6247. if ($v [0] == $m) {
  6248. $verifyList [$k] ['date'] = $u ['date'];
  6249. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6250. $verifyList [$k] ['status'] = $u ['status'];
  6251. $flag = false;
  6252. break;
  6253. }
  6254. }
  6255. $endStaffArray = end ( $verifyStaff );
  6256. if (isset ( $endStaffArray ['ROLE'] )) {
  6257. } else {
  6258. // $endKey=key($verifyStaff);
  6259. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6260. // $button=4;
  6261. // $verifyList[$k]['status']=4;
  6262. // }
  6263. }
  6264. }
  6265. }
  6266. $rolename ['name'] = '';
  6267. if (! empty ( $roleId )) {
  6268. Doo::loadModel ( 'role' );
  6269. $role = new role ();
  6270. $rolename = $role->getOne ( array (
  6271. 'where' => 'rid=' . $roleId,
  6272. 'asArray' => true
  6273. ) );
  6274. }
  6275. if (! empty ( $verifyStaff ))
  6276. $endStaffArray = end ( $verifyStaff );
  6277. $KOP = false;
  6278. foreach ( $roleArrayCopy as $P => $A ) {
  6279. foreach ( $A as $MKI => $AVL ) {
  6280. if (! empty ( $verifyStaff )) {
  6281. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6282. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6283. $button = 4;
  6284. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6285. }
  6286. foreach ( $verifyStaff as $m => $u ) {
  6287. $AVLFK = $AVL [0] . '_R';
  6288. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6289. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6290. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6291. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6292. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6293. break;
  6294. }
  6295. }
  6296. } else {
  6297. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6298. $button = 4;
  6299. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6300. }
  6301. }
  6302. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6303. $KOP = true;
  6304. }
  6305. }
  6306. foreach ( $roleArrayCopy as $k => $v ) {
  6307. foreach ( $verifyList as $m => $n ) {
  6308. if ($n [0] == $k) {
  6309. array_splice ( $verifyList, $m, 1, $v );
  6310. }
  6311. }
  6312. }
  6313. $receiptList [$key] ['verifyList'] = $verifyList;
  6314. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6315. 'where' => 'sid=' . $value ['staff'],
  6316. 'asArray' => true
  6317. ) );
  6318. $receiptList [$key] ['button'] = $button;
  6319. }
  6320. // print_r($receiptList);die;
  6321. $mothHtml = "";
  6322. for($i = 1; $i <= 12; $i ++) {
  6323. if ($moth == $i)
  6324. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6325. else
  6326. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6327. }
  6328. $data ['mothHtml'] = $mothHtml;
  6329. $data ['receiptList'] = $receiptList;
  6330. $data ['memu'] = "receipt";
  6331. $data ['staff'] = $this->staff;
  6332. $data ['receiptMemu'] = 'receipt';
  6333. $data ['verifyId'] = $this->verifyId;
  6334. $data ['executeId'] = $this->executeId;
  6335. $data ['item'] = $item;
  6336. $data ['year'] = $year;
  6337. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6338. // sufficient condition to generate cache
  6339. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6340. $receiptList = $receipt->find ( array (
  6341. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6342. 'asArray' => true
  6343. ) );
  6344. if (empty ( $receiptList )) { // generated files
  6345. ob_start ();
  6346. $this->render ( "/admin/saea_myList", $data );
  6347. $this->cacheFile ( $path );
  6348. die ();
  6349. // $content = ob_get_contents();
  6350. // $fp = fopen($path, "w");
  6351. // fwrite($fp, $content);
  6352. // fclose($fp);
  6353. }
  6354. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6355. $receiptList = $receipt->find ( array (
  6356. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6357. 'asArray' => true
  6358. ) );
  6359. if (empty ( $receiptList )) { // generated files
  6360. ob_start ();
  6361. $this->render ( "/admin/saea_myList", $data );
  6362. $this->cacheFile ( $path );
  6363. die ();
  6364. }
  6365. }
  6366. }
  6367. $this->render ( "/admin/saea_myList", $data );
  6368. }
  6369. function saeaCreate() {
  6370. Doo::loadModel ( 'accountItem' );
  6371. Doo::loadModel ( 'verify' );
  6372. Doo::loadModel ( 'receipt' );
  6373. Doo::loadModel ( 'L_category' );
  6374. $lCategory = new L_category ();
  6375. $receipt = new receipt ();
  6376. $verify = new verify ();
  6377. $accountItem = new accountItem ();
  6378. Doo::loadModel ( "role" );
  6379. $role = new role ();
  6380. $acItem = $accountItem->find ( array (
  6381. 'asArray' => true
  6382. ) );
  6383. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6384. $data ['category'] = $lCategory->find ( array (
  6385. 'asArray' => true
  6386. ) );
  6387. $data ['veList'] = $veList;
  6388. $data ['acItem'] = $acItem;
  6389. $data ['memu'] = "receipt";
  6390. $data ['staff'] = $this->staff;
  6391. $data ['receiptMemu'] = 'saeaBorad';
  6392. $data ['verifyId'] = $this->verifyId;
  6393. $data ['executeId'] = $this->executeId;
  6394. $this->render ( "/admin/saea_create", $data );
  6395. }
  6396. function addReceipt() {
  6397. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6398. $agency = $this->get_args ( 'agency' );
  6399. $travel = $this->get_args ( 'travel' );
  6400. $train = $this->get_args ( 'train' );
  6401. $other = $this->get_args ( 'other' );
  6402. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6403. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6404. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6405. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6406. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6407. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6408. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6409. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6410. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6411. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6412. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6413. header ( 'Content-Type:text/html;charset=utf-8' );
  6414. die ( '请填写联行号' );
  6415. }
  6416. Doo::loadModel ( 'receipt' );
  6417. Doo::loadModel ( 'receiptDetail' );
  6418. Doo::loadModel ( 'accountItem' );
  6419. $accountItem = new accountItem ();
  6420. $receipt = new receipt ();
  6421. Doo::loadModel ( 'enclosur' );
  6422. Doo::loadModel ( 'execute' );
  6423. $execute = new execute ();
  6424. $executeDetail = $execute->getOne ( array (
  6425. 'where' => 'mold="报销单执行人"',
  6426. 'asArray' => true
  6427. ) );
  6428. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6429. // if(!empty($receiptDetail))
  6430. // return "/referReceipt/".$receiptDetail['rid'];
  6431. $aItem = $accountItem->find ( array (
  6432. 'asArray' => true
  6433. ) );
  6434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6435. $ag = $tr = $ta = $ot = 0;
  6436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6437. foreach ( $aItem as $key => $value ) {
  6438. if ($value ['category'] == $this->AGENCY) {
  6439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6440. array_push ( $accountJson [$this->AGENCY], array (
  6441. 'aid' => $value ['aid'],
  6442. 'name' => $value ['name'],
  6443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6444. ) );
  6445. $sum += $agency [$ag];
  6446. $agencySum += $agency [$ag];
  6447. }
  6448. $ag ++;
  6449. }
  6450. if ($value ['category'] == $this->TRAVEL) {
  6451. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6452. array_push ( $accountJson [$this->TRAVEL], array (
  6453. 'aid' => $value ['aid'],
  6454. 'name' => $value ['name'],
  6455. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6456. ) );
  6457. $sum += $travel [$tr];
  6458. $travelSum += $travel [$tr];
  6459. }
  6460. $tr ++;
  6461. }
  6462. if ($value ['category'] == $this->TRAIN) {
  6463. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6464. array_push ( $accountJson [$this->TRAIN], array (
  6465. 'aid' => $value ['aid'],
  6466. 'name' => $value ['name'],
  6467. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6468. ) );
  6469. $sum += $train [$ta];
  6470. $trainSum += $train [$ta];
  6471. }
  6472. $ta ++;
  6473. }
  6474. if ($value ['category'] == $this->OTHER) {
  6475. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6476. array_push ( $accountJson [$this->OTHER], array (
  6477. 'aid' => $value ['aid'],
  6478. 'name' => $value ['name'],
  6479. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6480. ) );
  6481. $sum += $other [$ot];
  6482. $otherSum += $other [$ot];
  6483. }
  6484. $ot ++;
  6485. }
  6486. }
  6487. $accountJson ['cSum'] = array (
  6488. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6489. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6490. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6491. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6492. );
  6493. // 报销单
  6494. $receipt->accountItem = json_encode ( $accountJson );
  6495. $receipt->staff = $this->staff [0] ['sid'];
  6496. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6497. $receipt->date = date ( "Y-m-d" );
  6498. $receipt->cid = $cid;
  6499. $receipt->status = 5;
  6500. // 修改审批流程加入角色
  6501. $receipt->verify = $verify;
  6502. $receipt->executeCopy = $executeDetail ['staff'];
  6503. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6504. $order = array (
  6505. "\r\n",
  6506. "\n",
  6507. "\r"
  6508. );
  6509. $replace = '<br/>';
  6510. $explanation = str_replace ( $order, $replace, $explanation );
  6511. $receipt->explanation = $explanation;
  6512. $receipt->remittanceName = $remittanceName;
  6513. $receipt->bankName = $bankName;
  6514. $receipt->bankNumber = $bankNumber;
  6515. $receipt->remittanceBankType = $remittanceBankType;
  6516. if ($remittanceBankType == 1)
  6517. $receipt->coupletNumber = $coupletNumber;
  6518. $rid = $receipt->insert ();
  6519. // 附件
  6520. if (! empty ( $enclosurName )) {
  6521. $enclosurArray = explode ( '-', $enclosurName );
  6522. foreach ( $enclosurArray as $value ) {
  6523. $enclosur = new enclosur ();
  6524. $enclosur->name = $value;
  6525. $enclosur->rid = $rid;
  6526. $enclosur->insert ();
  6527. }
  6528. // print_r($enclosurArray);die;
  6529. }
  6530. // 报销详情
  6531. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6532. $receiptDetail = new receiptDetail ();
  6533. $receiptDetail->staff = $this->staff [0] ['sid'];
  6534. $receiptDetail->item = $value ['name'];
  6535. $receiptDetail->itemCategory = $this->AGENCY;
  6536. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6537. $receiptDetail->date = date ( "Y-m-d" );
  6538. $receiptDetail->cid = $cid;
  6539. $receiptDetail->rid = $rid;
  6540. $receiptDetail->status = 4;
  6541. $receiptDetail->insert ();
  6542. }
  6543. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6544. $receiptDetail = new receiptDetail ();
  6545. $receiptDetail->staff = $this->staff [0] ['sid'];
  6546. $receiptDetail->item = $value ['name'];
  6547. $receiptDetail->itemCategory = $this->TRAVEL;
  6548. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6549. $receiptDetail->date = date ( "Y-m-d" );
  6550. $receiptDetail->cid = $cid;
  6551. $receiptDetail->rid = $rid;
  6552. $receiptDetail->status = 4;
  6553. $receiptDetail->insert ();
  6554. }
  6555. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6556. $receiptDetail = new receiptDetail ();
  6557. $receiptDetail->staff = $this->staff [0] ['sid'];
  6558. $receiptDetail->item = $value ['name'];
  6559. $receiptDetail->itemCategory = $this->TRAIN;
  6560. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6561. $receiptDetail->date = date ( "Y-m-d" );
  6562. $receiptDetail->cid = $cid;
  6563. $receiptDetail->rid = $rid;
  6564. $receiptDetail->status = 4;
  6565. $receiptDetail->insert ();
  6566. }
  6567. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6568. $receiptDetail = new receiptDetail ();
  6569. $receiptDetail->staff = $this->staff [0] ['sid'];
  6570. $receiptDetail->item = $value ['name'];
  6571. $receiptDetail->itemCategory = $this->OTHER;
  6572. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6573. $receiptDetail->date = date ( "Y-m-d" );
  6574. $receiptDetail->cid = $cid;
  6575. $receiptDetail->rid = $rid;
  6576. $receiptDetail->status = 4;
  6577. $receiptDetail->insert ();
  6578. }
  6579. return "/saeaBorad";
  6580. } else
  6581. die ( 'illegal request' );
  6582. }
  6583. function referReceipt() {
  6584. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6585. Doo::loadModel ( 'receipt' );
  6586. Doo::loadModel ( 'verify' );
  6587. $verify = new verify ();
  6588. $receipt = new receipt ();
  6589. Doo::loadModel ( 'L_category' );
  6590. $lCategory = new L_category ();
  6591. Doo::loadModel ( "role" );
  6592. $role = new role ();
  6593. $receiptDetail = $receipt->find ( array (
  6594. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6595. 'asArray' => true
  6596. ) );
  6597. if (empty ( $receiptDetail ))
  6598. return "/addReceipt";
  6599. foreach ( $receiptDetail as $key => $value ) {
  6600. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6601. $veList = $verify->getOne ( array (
  6602. 'where' => 'vid=' . $value ['verify'],
  6603. 'asArray' => true
  6604. ) );
  6605. $v = json_decode ( $veList ['staff'] );
  6606. array_push ( $v [0], $veList ['description'] );
  6607. foreach ( $v as $n => $m ) {
  6608. if ($m ['1'] == 'ROLE') {
  6609. $roleInfo = $role->getOne ( array (
  6610. 'where' => 'rid=' . $m [0],
  6611. 'asArray' => true
  6612. ) );
  6613. $v [$n] [1] = $roleInfo ['name'];
  6614. }
  6615. }
  6616. $receiptDetail [$key] ['staff'] = $v;
  6617. $category = $lCategory->getOne ( array (
  6618. 'where' => 'cid=' . $value ['cid'],
  6619. 'asArray' => true
  6620. ) );
  6621. $receiptDetail [$key] ['category'] = $category ['title'];
  6622. }
  6623. // print_r($receiptDetail);
  6624. $data ['receiptDetail'] = $receiptDetail;
  6625. $data ['memu'] = "receipt";
  6626. $data ['staff'] = $this->staff;
  6627. $data ['receiptMemu'] = 'saeaCreate';
  6628. $data ['verifyId'] = $this->verifyId;
  6629. $data ['executeId'] = $this->executeId;
  6630. $this->render ( "/admin/saea_confirm", $data );
  6631. }
  6632. function editReceipt() {
  6633. // edit status 4
  6634. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6635. Doo::loadClass ( 'XDeode' );
  6636. $XDeode = new XDeode ( 7 );
  6637. $rid = $XDeode->decode ( $ridKey );
  6638. if (empty ( $rid ))
  6639. die ( 'illegal request' );
  6640. // echo $rid.'sd';
  6641. Doo::loadModel ( 'accountItem' );
  6642. Doo::loadModel ( 'verify' );
  6643. Doo::loadModel ( 'receipt' );
  6644. $receipt = new receipt ();
  6645. $verify = new verify ();
  6646. $accountItem = new accountItem ();
  6647. Doo::loadModel ( 'L_category' );
  6648. $lCategory = new L_category ();
  6649. Doo::loadModel ( "role" );
  6650. $role = new role ();
  6651. Doo::loadModel ( 'enclosur' );
  6652. $enclosur = new enclosur ();
  6653. $receiptDetail = $receipt->getOne ( array (
  6654. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6655. 'asArray' => true
  6656. ) );
  6657. if (empty ( $receiptDetail ))
  6658. die ( 'illegal request' );
  6659. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6660. $acItem = $accountItem->find ( array (
  6661. 'asArray' => true
  6662. ) );
  6663. $veList = $verify->getVerifyBySubordinate('RECEIPT');
  6664. // 配置编辑信息
  6665. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6666. foreach ( $acItem as $key => $value ) {
  6667. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6668. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6669. $acItem [$key] ['price'] = $v ['price'];
  6670. }
  6671. }
  6672. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6673. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6674. $acItem [$key] ['price'] = $v ['price'];
  6675. }
  6676. }
  6677. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6678. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6679. $acItem [$key] ['price'] = $v ['price'];
  6680. }
  6681. }
  6682. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6683. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6684. $acItem [$key] ['price'] = $v ['price'];
  6685. }
  6686. }
  6687. }
  6688. $data ['category'] = $lCategory->find ( array (
  6689. 'asArray' => true
  6690. ) );
  6691. $data ['cSum'] = $accountItemList ['cSum'];
  6692. $data ['sum'] = $receiptDetail ['sum'];
  6693. $data ['enclosurList'] = $enclosurList;
  6694. $data ['receiptDetail'] = $receiptDetail;
  6695. $data ['veList'] = $veList;
  6696. $data ['acItem'] = $acItem;
  6697. $data ['memu'] = "receipt";
  6698. $data ['staff'] = $this->staff;
  6699. $data ['receiptMemu'] = 'saeaBorad';
  6700. $data ['verify'] = $receiptDetail ['verify'];
  6701. $data ['verifyId'] = $this->verifyId;
  6702. $data ['executeId'] = $this->executeId;
  6703. $data ['rid'] = $ridKey;
  6704. $this->render ( "/admin/saea_edit", $data );
  6705. }
  6706. function updateReceipt() {
  6707. $agency = $this->get_args ( 'agency' );
  6708. $travel = $this->get_args ( 'travel' );
  6709. $train = $this->get_args ( 'train' );
  6710. $other = $this->get_args ( 'other' );
  6711. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6712. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6713. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6714. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6715. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6716. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6717. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6718. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6719. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6720. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6721. Doo::loadClass ( 'XDeode' );
  6722. $XDeode = new XDeode ( 7 );
  6723. $rid = $XDeode->decode ( $ridKey );
  6724. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6725. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6726. header ( 'Content-Type:text/html;charset=utf-8' );
  6727. die ( '请填写联行号' );
  6728. }
  6729. Doo::loadModel ( 'receipt' );
  6730. Doo::loadModel ( 'receiptDetail' );
  6731. Doo::loadModel ( 'accountItem' );
  6732. $accountItem = new accountItem ();
  6733. $receipt = new receipt ();
  6734. Doo::loadModel ( 'enclosur' );
  6735. Doo::loadModel ( 'execute' );
  6736. $execute = new execute ();
  6737. $receiptDetail = $receipt->getOne ( array (
  6738. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6739. 'asArray' => true
  6740. ) );
  6741. if (empty ( $receiptDetail ))
  6742. return "/saeaBorad";
  6743. if ($receiptDetail ['Rtype'] == 1)
  6744. $executeDetail = $execute->getOne ( array (
  6745. 'where' => 'mold="借款费用执行人"',
  6746. 'asArray' => true
  6747. ) );
  6748. else
  6749. $executeDetail = $execute->getOne ( array (
  6750. 'where' => 'mold="报销单执行人"',
  6751. 'asArray' => true
  6752. ) );
  6753. $aItem = $accountItem->find ( array (
  6754. 'asArray' => true
  6755. ) );
  6756. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6757. $ag = $tr = $ta = $ot = 0;
  6758. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6759. foreach ( $aItem as $key => $value ) {
  6760. if ($value ['category'] == $this->AGENCY) {
  6761. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6762. array_push ( $accountJson [$this->AGENCY], array (
  6763. 'aid' => $value ['aid'],
  6764. 'name' => $value ['name'],
  6765. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6766. ) );
  6767. $sum += $agency [$ag];
  6768. $agencySum += $agency [$ag];
  6769. }
  6770. $ag ++;
  6771. }
  6772. if ($value ['category'] == $this->TRAVEL) {
  6773. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6774. array_push ( $accountJson [$this->TRAVEL], array (
  6775. 'aid' => $value ['aid'],
  6776. 'name' => $value ['name'],
  6777. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6778. ) );
  6779. $sum += $travel [$tr];
  6780. $travelSum += $travel [$tr];
  6781. }
  6782. $tr ++;
  6783. }
  6784. if ($value ['category'] == $this->TRAIN) {
  6785. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6786. array_push ( $accountJson [$this->TRAIN], array (
  6787. 'aid' => $value ['aid'],
  6788. 'name' => $value ['name'],
  6789. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6790. ) );
  6791. $sum += $train [$ta];
  6792. $trainSum += $train [$ta];
  6793. }
  6794. $ta ++;
  6795. }
  6796. if ($value ['category'] == $this->OTHER) {
  6797. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6798. array_push ( $accountJson [$this->OTHER], array (
  6799. 'aid' => $value ['aid'],
  6800. 'name' => $value ['name'],
  6801. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6802. ) );
  6803. $sum += $other [$ot];
  6804. $otherSum += $other [$ot];
  6805. }
  6806. $ot ++;
  6807. }
  6808. }
  6809. $accountJson ['cSum'] = array (
  6810. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6811. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6812. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6813. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6814. );
  6815. // 报销单
  6816. $rid = $receipt->rid = $receiptDetail ['rid'];
  6817. $receipt->accountItem = json_encode ( $accountJson );
  6818. $receipt->staff = $this->staff [0] ['sid'];
  6819. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6820. $receipt->date = date ( "Y-m-d" );
  6821. $receipt->cid = $cid;
  6822. if (($receiptDetail ['status'] != 4)) {
  6823. if ($receiptDetail ['Rtype'] == 1)
  6824. $receipt->status = 7;
  6825. else
  6826. $receipt->status = 5;
  6827. }
  6828. if ($receiptDetail != 4 && ! empty ( $verify ))
  6829. $receipt->verify = $verify;
  6830. $receipt->executeCopy = $executeDetail ['staff'];
  6831. $order = array (
  6832. "\r\n",
  6833. "\n",
  6834. "\r"
  6835. );
  6836. $replace = '<br/>';
  6837. $explanation = str_replace ( $order, $replace, $explanation );
  6838. $receipt->explanation = $explanation;
  6839. $receipt->remittanceName = $remittanceName;
  6840. $receipt->bankName = $bankName;
  6841. $receipt->bankNumber = $bankNumber;
  6842. $receipt->remittanceBankType = $remittanceBankType;
  6843. if ($remittanceBankType == 1)
  6844. $receipt->coupletNumber = $coupletNumber;
  6845. $receipt->update ();
  6846. $receiptDetail = new receiptDetail ();
  6847. $receiptDetail->delete ( array (
  6848. 'where' => 'rid=' . $rid
  6849. ) );
  6850. // 报销详情
  6851. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6852. $receiptDetail = new receiptDetail ();
  6853. $receiptDetail->staff = $this->staff [0] ['sid'];
  6854. $receiptDetail->item = $value ['name'];
  6855. $receiptDetail->itemCategory = $this->AGENCY;
  6856. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6857. $receiptDetail->date = date ( "Y-m-d" );
  6858. $receiptDetail->cid = $cid;
  6859. $receiptDetail->rid = $rid;
  6860. $receiptDetail->status = 4;
  6861. $receiptDetail->insert ();
  6862. }
  6863. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6864. $receiptDetail = new receiptDetail ();
  6865. $receiptDetail->staff = $this->staff [0] ['sid'];
  6866. $receiptDetail->item = $value ['name'];
  6867. $receiptDetail->itemCategory = $this->TRAVEL;
  6868. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6869. $receiptDetail->date = date ( "Y-m-d" );
  6870. $receiptDetail->cid = $cid;
  6871. $receiptDetail->rid = $rid;
  6872. $receiptDetail->status = 4;
  6873. $receiptDetail->insert ();
  6874. }
  6875. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6876. $receiptDetail = new receiptDetail ();
  6877. $receiptDetail->staff = $this->staff [0] ['sid'];
  6878. $receiptDetail->item = $value ['name'];
  6879. $receiptDetail->itemCategory = $this->TRAIN;
  6880. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6881. $receiptDetail->date = date ( "Y-m-d" );
  6882. $receiptDetail->cid = $cid;
  6883. $receiptDetail->rid = $rid;
  6884. $receiptDetail->status = 4;
  6885. $receiptDetail->insert ();
  6886. }
  6887. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6888. $receiptDetail = new receiptDetail ();
  6889. $receiptDetail->staff = $this->staff [0] ['sid'];
  6890. $receiptDetail->item = $value ['name'];
  6891. $receiptDetail->itemCategory = $this->OTHER;
  6892. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6893. $receiptDetail->date = date ( "Y-m-d" );
  6894. $receiptDetail->cid = $cid;
  6895. $receiptDetail->rid = $rid;
  6896. $receiptDetail->status = 4;
  6897. $receiptDetail->insert ();
  6898. }
  6899. // 附件
  6900. if (! empty ( $enclosurName )) {
  6901. $enclosurArray = explode ( '-', $enclosurName );
  6902. foreach ( $enclosurArray as $value ) {
  6903. $enclosur = new enclosur ();
  6904. $enclosur->name = $value;
  6905. $enclosur->rid = $rid;
  6906. $enclosur->insert ();
  6907. }
  6908. }
  6909. // return "/referReceipt/".$rid;
  6910. }
  6911. return "/saeaBorad";
  6912. }
  6913. function approvedReceipt() {
  6914. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6915. Doo::loadModel ( 'receipt' );
  6916. Doo::loadModel ( 'receiptDetail' );
  6917. $receipt = new receipt ();
  6918. $receiptDetail = new receiptDetail ();
  6919. Doo::loadModel ( 'statistics' );
  6920. Doo::loadModel ( 'itemStatistics' );
  6921. $statistics = new statistics ();
  6922. $itemStatistics = new itemStatistics ();
  6923. Doo::loadModel ( "verify" );
  6924. $verify = new verify ();
  6925. // 审批状态的判定
  6926. $receiptDetailList = $receipt->getOne ( array (
  6927. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  6928. 'asArray' => true
  6929. ) );
  6930. if (empty ( $receiptDetailList ))
  6931. return "/saeaBorad";
  6932. $verifyDetail = $verify->getOne ( array (
  6933. 'where' => ' vid =' . $receiptDetailList ['verify'],
  6934. 'asArray' => true
  6935. ) );
  6936. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6937. if (empty ( $receiptDetailList ['nowStaff'] )) {
  6938. $nowStaff = "";
  6939. $nowStaffList = array ();
  6940. if ($verifyDetail [0] [1] == 'ROLE') {
  6941. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6942. foreach ( $vStaffString as $key => $value ) {
  6943. $staffK = explode ( "_", $value );
  6944. array_push ( $nowStaffList, $staffK [0] );
  6945. }
  6946. $nowStaff = implode ( ',', $nowStaffList );
  6947. } else {
  6948. $nowStaff = $verifyDetail [0] [0];
  6949. }
  6950. $receipt->nowStaff = $nowStaff;
  6951. }
  6952. // echo $nowStaff;
  6953. // print_r($verifyDetail);die;
  6954. $receipt->rid = $receiptDetailList ['rid'];
  6955. $receipt->date = date ( "Y-m-d" );
  6956. $receipt->status = 2;
  6957. $receipt->update ();
  6958. $receiptDetail->status = 2;
  6959. $receiptDetail->update ( array (
  6960. 'where' => 'rid=' . $receiptDetailList ['rid']
  6961. ) );
  6962. Doo::loadModel ( "receiptLog" );
  6963. $receiptLog = new receiptLog ();
  6964. Doo::loadModel ( "verify" );
  6965. $verify = new verify ();
  6966. $receiptInfo = $receipt->getOne ( array (
  6967. 'where' => 'rid=' . $rid,
  6968. 'asArray' => true
  6969. ) );
  6970. $vr = $verify->getOne ( array (
  6971. 'where' => 'vid=' . $receiptInfo ['verify'],
  6972. 'asArray' => true
  6973. ) );
  6974. $jd = json_decode ( $vr ['staff'] );
  6975. $roleId = 0;
  6976. foreach ( $jd as $key => $value ) {
  6977. if ($value [1] == 'ROLE') {
  6978. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6979. if ($pos !== false) {
  6980. $roleId = $value [0];
  6981. }
  6982. }
  6983. }
  6984. // 审批日志
  6985. // echo $roleId;die;
  6986. if (! empty ( $roleId )) {
  6987. Doo::loadModel ( "role" );
  6988. $role = new role ();
  6989. $roleInfo = $role->getOne ( array (
  6990. 'where' => 'rid=' . $roleId,
  6991. 'asArray' => true
  6992. ) );
  6993. // $receiptLog->rolename = $roleInfo ['name'];
  6994. }
  6995. $receiptLog->username = $this->staff [0] ['username'];
  6996. $receiptLog->uid = $this->staff [0] ['sid'];
  6997. $receiptLog->date = date ( "Y-m-d" );
  6998. $receiptLog->opinion = '提交审批';
  6999. $receiptLog->img = $this->staff [0] ['avatar'];
  7000. $receiptLog->status = 2;
  7001. $receiptLog->rid = $rid;
  7002. $receiptLog->insert ();
  7003. // statistics item
  7004. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7005. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7006. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7007. $stat = $statistics->getOne ( array (
  7008. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7009. 'asArray' => true
  7010. ) );
  7011. if (empty ( $stat )) {
  7012. $statistics->date = date ( "Y-m-d" );
  7013. $statistics->cid = $this->staff [0] ['cid'];
  7014. $statistics->staff = $this->staff [0] ['sid'];
  7015. $statistics->agPrice = 0;
  7016. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7017. $statistics->insert ();
  7018. } else {
  7019. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7020. $statistics->update ( array (
  7021. 'where' => 'sid=' . $stat ['sid']
  7022. ) );
  7023. }
  7024. return "/expenses";
  7025. }
  7026. function approval() {
  7027. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7028. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7029. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7030. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7031. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7032. if (empty ( $status ))
  7033. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7034. $vidList = array ();
  7035. $button = 0;
  7036. Doo::loadModel ( 'verify' );
  7037. $verify = new verify ();
  7038. Doo::loadModel ( 'receipt' );
  7039. $receipt = new receipt ();
  7040. Doo::loadModel ( 'staff' );
  7041. $staff = new staff ();
  7042. Doo::loadModel ( 'L_category' );
  7043. $Lcategory = new L_category ();
  7044. // user verify ID
  7045. $verifyDetail = $verify->find ( array (
  7046. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7047. 'asArray' => true
  7048. ) );
  7049. foreach ( $verifyDetail as $key => $value ) {
  7050. array_push ( $vidList, $value ['vid'] );
  7051. }
  7052. $vid = implode ( ",", $vidList );
  7053. if (empty ( $verifyDetail ))
  7054. $vid = 0;
  7055. /*
  7056. */
  7057. $dateCondition = " and Year(date) =" . $year;
  7058. if (! empty ( $month ))
  7059. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7060. $categoryList = $Lcategory->find ( array (
  7061. 'asArray' => true
  7062. ) );
  7063. $staffList = $staff->find ( array (
  7064. 'where' => 'cid=' . $cid,
  7065. 'asArray' => true
  7066. ) );
  7067. $cateCondition = "";
  7068. $staffCondition = "";
  7069. $approvalCondition = "";
  7070. if (! empty ( $cid ))
  7071. $cateCondition = ' and cid=' . $cid;
  7072. if (! empty ( $sid )) {
  7073. $staffCondition = ' and staff=' . $sid;
  7074. $cateCondition = "";
  7075. }
  7076. // elseif($status==1){
  7077. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7078. // }
  7079. if ($status == 2) {
  7080. // 查找角色审批人
  7081. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7082. }
  7083. $ap = "";
  7084. if ($status == 4) {
  7085. $ap = 4;
  7086. $status = 2;
  7087. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7088. }
  7089. if ($status == 5) {
  7090. $status = 4;
  7091. $ap = 5;
  7092. }
  7093. // echo $vid;
  7094. // get Receipt By verifyID status 2 .$approvalCondition
  7095. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7096. $receiptList = $receipt->find ( array (
  7097. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7098. 'desc' => 'rid',
  7099. 'asArray' => true
  7100. ) );
  7101. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7102. $Locate = 0;
  7103. if ($ap == 4)
  7104. $status = 4;
  7105. elseif ($ap == 5)
  7106. $status = 5;
  7107. foreach ( $receiptList as $key => $value ) {
  7108. $receiptList [$key] ['Locate'] = $Locate;
  7109. $Locate ++;
  7110. $receiptList [$key] ['reviseDetail'] = array ();
  7111. if (! empty ( $value ['reviseDetail'] ))
  7112. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7113. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7114. $categoryDetil = $Lcategory->getOne ( array (
  7115. 'where' => 'cid=' . $value ['cid'],
  7116. 'asArray' => true
  7117. ) );
  7118. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7119. $verifyList = $verify->getOne ( array (
  7120. 'where' => 'vid=' . $value ['verify'],
  7121. 'asArray' => true
  7122. ) );
  7123. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7124. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7125. foreach ( $verifyList as $k => $v ) {
  7126. // init verifyStaff
  7127. $verifyList [$k] ['date'] = "";
  7128. $verifyList [$k] ['opinion'] = "";
  7129. $verifyList [$k] ['status'] = "";
  7130. if (empty ( $verifyStaff )) {
  7131. $verifyList [$k] ['date'] = "";
  7132. $verifyList [$k] ['opinion'] = "";
  7133. if ($v [0] == $this->staff [0] ['sid']) {
  7134. $verifyList [$k] ['status'] = 4;
  7135. $button = 4;
  7136. }
  7137. } else {
  7138. $flag = true;
  7139. foreach ( $verifyStaff as $m => $u ) {
  7140. if ($v [0] == $m) {
  7141. $verifyList [$k] ['date'] = $u ['date'];
  7142. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7143. $verifyList [$k] ['status'] = $u ['status'];
  7144. $flag = false;
  7145. break;
  7146. }
  7147. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7148. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7149. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7150. }
  7151. if ($flag) { // 检测可编辑
  7152. if ($v [0] == $this->staff [0] ['sid']) {
  7153. $verifyList [$k] ['status'] = 4;
  7154. $button = 4;
  7155. }
  7156. }
  7157. }
  7158. }
  7159. $receiptList [$key] ['verifyList'] = $verifyList;
  7160. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7161. 'where' => 'sid=' . $value ['staff'],
  7162. 'asArray' => true
  7163. ) );
  7164. $receiptList [$key] ['button'] = $button;
  7165. }
  7166. // print_r($receiptList);die;
  7167. // $data['verifyDetail']=$verifyDetail;
  7168. $mothHtml = "";
  7169. for($i = 1; $i <= 12; $i ++) {
  7170. if ($month == $i)
  7171. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7172. else
  7173. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7174. }
  7175. $data ['mothHtml'] = $mothHtml;
  7176. $data ['receiptList'] = $receiptList;
  7177. $data ['receiptApprovalCount'] = count ( $receiptList );
  7178. $data ['status'] = $status;
  7179. $data ['year'] = $year;
  7180. $data ['categoryList'] = $categoryList;
  7181. $data ['staffList'] = $staffList;
  7182. $data ['cid'] = $cid;
  7183. $data ['sid'] = $sid;
  7184. $data ['ap'] = $ap;
  7185. $data ['memu'] = "receipt";
  7186. $data ['staff'] = $this->staff;
  7187. $data ['receiptMemu'] = 'approval';
  7188. $data ['verifyId'] = $this->verifyId;
  7189. $data ['executeId'] = $this->executeId;
  7190. $this->render ( "/admin/saea_reportList", $data );
  7191. }
  7192. function approvalDetails() {
  7193. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7194. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7195. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7196. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7197. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7198. Doo::loadModel ( 'verify' );
  7199. $verify = new verify ();
  7200. Doo::loadModel ( 'receipt' );
  7201. $receipt = new receipt ();
  7202. Doo::loadModel ( 'staff' );
  7203. $staff = new staff ();
  7204. Doo::loadModel ( 'L_category' );
  7205. $Lcategory = new L_category ();
  7206. Doo::loadModel ( 'enclosur' );
  7207. $enclosur = new enclosur ();
  7208. $vidList = array ();
  7209. $verifyDetail = $verify->find ( array (
  7210. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7211. 'asArray' => true
  7212. ) );
  7213. foreach ( $verifyDetail as $key => $value ) {
  7214. array_push ( $vidList, $value ['vid'] );
  7215. }
  7216. $vid = implode ( ",", $vidList );
  7217. if (empty ( $verifyDetail ))
  7218. $vid = 0;
  7219. $categoryList = $Lcategory->find ( array (
  7220. 'asArray' => true
  7221. ) );
  7222. $staffList = $staff->find ( array (
  7223. 'where' => 'cid=' . $cid,
  7224. 'asArray' => true
  7225. ) );
  7226. $ap = 0;
  7227. $receiptList = $receipt->find ( array (
  7228. 'where' => 'rid =' . $rid,
  7229. 'desc' => 'rid',
  7230. 'asArray' => true
  7231. ) );
  7232. $Locate = 0;
  7233. $roleId = 0;
  7234. $button = 0;
  7235. foreach ( $receiptList as $key => $value ) {
  7236. $receiptList [$key] ['Locate'] = $Locate;
  7237. $Locate ++;
  7238. $receiptList [$key] ['reviseDetail'] = array ();
  7239. if (! empty ( $value ['reviseDetail'] ))
  7240. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7241. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7242. $categoryDetil = $Lcategory->getOne ( array (
  7243. 'where' => 'cid=' . $value ['cid'],
  7244. 'asArray' => true
  7245. ) );
  7246. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7247. // 检测编辑状态
  7248. $verifyList = $verify->getOne ( array (
  7249. 'where' => 'vid=' . $value ['verify'],
  7250. 'asArray' => true
  7251. ) );
  7252. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7253. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7254. Doo::loadModel ( 'role' );
  7255. $role = new role ();
  7256. // print_r($verifyList);
  7257. $flag = true;
  7258. $roleKey = 0;
  7259. $endStaffArray = array ();
  7260. $roleArrayCopy = array ();
  7261. foreach ( $verifyList as $k => $v ) {
  7262. // init verifyStaff
  7263. if ($v [1] == 'ROLE') {
  7264. if (! empty ( $verifyStaff )) {
  7265. $endStaffArray = end ( $verifyStaff );
  7266. if ($v [0] == $endStaffArray ['nextStaff']) {
  7267. $roleId = $v [0];
  7268. }
  7269. }
  7270. $roleVerify = json_decode ( $v [3], true );
  7271. $roleKey = $k;
  7272. $roleArray = array ();
  7273. $rolename = $role->getOne ( array (
  7274. 'where' => 'rid=' . $v [0],
  7275. 'asArray' => true
  7276. ) );
  7277. foreach ( $roleVerify as $o => $p ) {
  7278. $staffID = explode ( '_', $p );
  7279. $staffInfo = $staff->getOne ( array (
  7280. 'where' => 'sid=' . $staffID [0],
  7281. 'asArray' => true
  7282. ) );
  7283. // print_r($staffID);
  7284. $exp = array (
  7285. 0 => $staffInfo ['sid'],
  7286. 1 => $staffID [1],
  7287. 2 => $staffInfo ['avatar'],
  7288. 'date' => '',
  7289. 'date' => '',
  7290. 'opinion' => '',
  7291. 'status' => '',
  7292. 'rolename' => $rolename ['name']
  7293. );
  7294. array_push ( $roleArray, $exp );
  7295. }
  7296. $roleArrayCopy [$v [0]] = $roleArray;
  7297. // $verifyList[$k]['roleArray']=$roleArray;
  7298. }
  7299. // print_r($roleArray);
  7300. $verifyList [$k] ['date'] = "";
  7301. $verifyList [$k] ['opinion'] = "";
  7302. $verifyList [$k] ['status'] = "";
  7303. if (empty ( $verifyStaff )) {
  7304. $verifyList [$k] ['date'] = "";
  7305. $verifyList [$k] ['opinion'] = "";
  7306. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7307. $verifyList [$k] ['status'] = 4;
  7308. $button = 4;
  7309. $flag = false;
  7310. }
  7311. } else {
  7312. foreach ( $verifyStaff as $m => $u ) {
  7313. if ($v [0] == $m) {
  7314. $verifyList [$k] ['date'] = $u ['date'];
  7315. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7316. $verifyList [$k] ['status'] = $u ['status'];
  7317. $flag = false;
  7318. break;
  7319. }
  7320. }
  7321. $endStaffArray = end ( $verifyStaff );
  7322. if (isset ( $endStaffArray ['ROLE'] )) {
  7323. } else {
  7324. $endKey = key ( $verifyStaff );
  7325. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7326. $button = 4;
  7327. $verifyList [$k] ['status'] = 4;
  7328. }
  7329. }
  7330. }
  7331. }
  7332. $rolename ['name'] = '';
  7333. if (! empty ( $roleId )) {
  7334. Doo::loadModel ( 'role' );
  7335. $role = new role ();
  7336. $rolename = $role->getOne ( array (
  7337. 'where' => 'rid=' . $roleId,
  7338. 'asArray' => true
  7339. ) );
  7340. }
  7341. if (! empty ( $verifyStaff ))
  7342. $endStaffArray = end ( $verifyStaff );
  7343. $KOP = false;
  7344. foreach ( $roleArrayCopy as $P => $A ) {
  7345. foreach ( $A as $MKI => $AVL ) {
  7346. if (! empty ( $verifyStaff )) {
  7347. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7348. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7349. $button = 4;
  7350. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7351. }
  7352. foreach ( $verifyStaff as $m => $u ) {
  7353. $AVLFK = $AVL [0] . '_R';
  7354. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7355. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7356. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7357. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7358. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7359. break;
  7360. }
  7361. }
  7362. } else {
  7363. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7364. $button = 4;
  7365. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7366. }
  7367. }
  7368. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7369. $KOP = true;
  7370. }
  7371. }
  7372. foreach ( $roleArrayCopy as $k => $v ) {
  7373. foreach ( $verifyList as $m => $n ) {
  7374. if ($n [0] == $k) {
  7375. array_splice ( $verifyList, $m, 1, $v );
  7376. }
  7377. }
  7378. }
  7379. $receiptList [$key] ['verifyList'] = $verifyList;
  7380. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7381. 'where' => 'sid=' . $value ['staff'],
  7382. 'asArray' => true
  7383. ) );
  7384. $receiptList [$key] ['button'] = $button;
  7385. }
  7386. $mothHtml = "";
  7387. for($i = 1; $i <= 12; $i ++) {
  7388. if ($month == $i)
  7389. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7390. else
  7391. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7392. }
  7393. // 获取审批日志
  7394. Doo::loadModel ( 'receiptLog' );
  7395. $receiptLog = new receiptLog ();
  7396. $rlList = array ();
  7397. $rlInfo = $receiptLog->getOne ( array (
  7398. 'where' => 'rid=' . $rid . ' and status=4',
  7399. 'asArray' => true
  7400. ) );
  7401. $tijdate = $receiptLog->getOne ( array (
  7402. 'where' => 'rid=' . $rid . ' and status=2',
  7403. 'asc' => 'rlid',
  7404. 'asArray' => true
  7405. ) );
  7406. if (! empty ( $rlInfo )) {
  7407. $rlList = $receiptLog->find ( array (
  7408. 'where' => 'rid=' . $rid,
  7409. 'asc' => 'rlid',
  7410. 'asArray' => true
  7411. ) );
  7412. }
  7413. $receiptList [0] ['rlList'] = $rlList;
  7414. $enclosurList = $enclosur->find ( array (
  7415. 'where' => 'rid=' . $rid,
  7416. 'asArray' => true
  7417. ) );
  7418. $enclosurHtml = '';
  7419. foreach ( $enclosurList as $value ) {
  7420. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7421. }
  7422. $data ['enclosurHtml'] = $enclosurHtml;
  7423. $data ['rolename'] = $rolename ['name'];
  7424. $data ['datetij'] = $tijdate ['date'];
  7425. $data ['mothHtml'] = $mothHtml;
  7426. $data ['receiptList'] = $receiptList;
  7427. $data ['receiptApprovalCount'] = count ( $receiptList );
  7428. $data ['year'] = $year;
  7429. $data ['categoryList'] = $categoryList;
  7430. $data ['staffList'] = $staffList;
  7431. $data ['cid'] = $cid;
  7432. $data ['sid'] = $sid;
  7433. $data ['status'] = 0;
  7434. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7435. $ap = 4;
  7436. } else
  7437. $data ['status'] = $receiptList [0] ['status'];
  7438. if ($receiptList [0] ['status'] == 4) {
  7439. $data ['status'] = 5;
  7440. $ap = 0;
  7441. }
  7442. $data ['ap'] = $ap;
  7443. $data ['memu'] = "receipt";
  7444. $data ['staff'] = $this->staff;
  7445. $data ['receiptMemu'] = 'approval';
  7446. $data ['verifyId'] = $this->verifyId;
  7447. $data ['executeId'] = $this->executeId;
  7448. $this->render ( "/admin/saeaReportListReport", $data );
  7449. }
  7450. function approvalEdi() {
  7451. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7452. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7453. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7454. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7455. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7456. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7457. if (empty ( $status ))
  7458. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7459. $vidList = array ();
  7460. $button = 0;
  7461. Doo::loadModel ( 'verify' );
  7462. Doo::loadModel ( 'receipt' );
  7463. Doo::loadModel ( 'staff' );
  7464. $staff = new staff ();
  7465. $receipt = new receipt ();
  7466. $verify = new verify ();
  7467. Doo::loadModel ( 'L_category' );
  7468. $Lcategory = new L_category ();
  7469. Doo::loadModel ( 'enclosur' );
  7470. $enclosur = new enclosur ();
  7471. // user verify ID
  7472. $verifyDetail = $verify->find ( array (
  7473. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7474. 'asArray' => true
  7475. ) );
  7476. foreach ( $verifyDetail as $key => $value ) {
  7477. array_push ( $vidList, $value ['vid'] );
  7478. }
  7479. $vid = implode ( ",", $vidList );
  7480. if (empty ( $verifyDetail ))
  7481. $vid = 0;
  7482. $categoryList = $Lcategory->find ( array (
  7483. 'asArray' => true
  7484. ) );
  7485. $staffList = $staff->find ( array (
  7486. 'where' => 'cid=' . $cid,
  7487. 'asArray' => true
  7488. ) );
  7489. $ap = "";
  7490. if ($status == 4) {
  7491. $ap = 4;
  7492. $status = 2;
  7493. }
  7494. // get Receipt By verifyID status 2
  7495. $receiptList = $receipt->find ( array (
  7496. 'where' => 'rid =' . $rid,
  7497. 'desc' => 'rid',
  7498. 'asArray' => true
  7499. ) );
  7500. $Locate = 0;
  7501. $roleId = 0;
  7502. if ($ap == 4)
  7503. $status = 4;
  7504. foreach ( $receiptList as $key => $value ) {
  7505. $receiptList [$key] ['Locate'] = $Locate;
  7506. $Locate ++;
  7507. $receiptList [$key] ['reviseDetail'] = array ();
  7508. if (! empty ( $value ['reviseDetail'] ))
  7509. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7510. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7511. $categoryDetil = $Lcategory->getOne ( array (
  7512. 'where' => 'cid=' . $value ['cid'],
  7513. 'asArray' => true
  7514. ) );
  7515. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7516. // 检测编辑状态
  7517. $verifyList = $verify->getOne ( array (
  7518. 'where' => 'vid=' . $value ['verify'],
  7519. 'asArray' => true
  7520. ) );
  7521. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7522. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7523. // print_r($verifyList);
  7524. //
  7525. // if (empty($verifyStaff)){
  7526. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7527. // $verifyList[0]['status']=4;$button=4;
  7528. // }
  7529. //
  7530. // }else{
  7531. //
  7532. // }
  7533. // die;
  7534. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7535. // echo array_search("green",$a);
  7536. //
  7537. Doo::loadModel ( 'role' );
  7538. $role = new role ();
  7539. // print_r($verifyList);
  7540. $flag = true;
  7541. $roleKey = 0;
  7542. $endStaffArray = array ();
  7543. $roleArrayCopy = array ();
  7544. foreach ( $verifyList as $k => $v ) {
  7545. // init verifyStaff
  7546. if ($v [1] == 'ROLE') {
  7547. if (! empty ( $verifyStaff )) {
  7548. $endStaffArray = end ( $verifyStaff );
  7549. if ($v [0] == $endStaffArray ['nextStaff']) {
  7550. $roleId = $v [0];
  7551. }
  7552. }
  7553. $roleVerify = json_decode ( $v [3], true );
  7554. $roleKey = $k;
  7555. $roleArray = array ();
  7556. $rolename = $role->getOne ( array (
  7557. 'where' => 'rid=' . $v [0],
  7558. 'asArray' => true
  7559. ) );
  7560. foreach ( $roleVerify as $o => $p ) {
  7561. $staffID = explode ( '_', $p );
  7562. $staffInfo = $staff->getOne ( array (
  7563. 'where' => 'sid=' . $staffID [0],
  7564. 'asArray' => true
  7565. ) );
  7566. // print_r($staffID);
  7567. $exp = array (
  7568. 0 => $staffInfo ['sid'],
  7569. 1 => $staffID [1],
  7570. 2 => $staffInfo ['avatar'],
  7571. 'date' => '',
  7572. 'date' => '',
  7573. 'opinion' => '',
  7574. 'status' => '',
  7575. 'rolename' => $rolename ['name']
  7576. );
  7577. array_push ( $roleArray, $exp );
  7578. }
  7579. $roleArrayCopy [$v [0]] = $roleArray;
  7580. // $verifyList[$k]['roleArray']=$roleArray;
  7581. }
  7582. // print_r($roleArray);
  7583. $verifyList [$k] ['date'] = "";
  7584. $verifyList [$k] ['opinion'] = "";
  7585. $verifyList [$k] ['status'] = "";
  7586. if (empty ( $verifyStaff )) {
  7587. $verifyList [$k] ['date'] = "";
  7588. $verifyList [$k] ['opinion'] = "";
  7589. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7590. $verifyList [$k] ['status'] = 4;
  7591. $button = 4;
  7592. $flag = false;
  7593. }
  7594. } else {
  7595. foreach ( $verifyStaff as $m => $u ) {
  7596. if ($v [0] == $m) {
  7597. $verifyList [$k] ['date'] = $u ['date'];
  7598. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7599. $verifyList [$k] ['status'] = $u ['status'];
  7600. $flag = false;
  7601. break;
  7602. }
  7603. }
  7604. $endStaffArray = end ( $verifyStaff );
  7605. if (isset ( $endStaffArray ['ROLE'] )) {
  7606. } else {
  7607. $endKey = key ( $verifyStaff );
  7608. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7609. $button = 4;
  7610. $verifyList [$k] ['status'] = 4;
  7611. }
  7612. }
  7613. // print_r($endStaffArray);die;
  7614. // if (empty($verifyStaff)){
  7615. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7616. // $verifyList[$k]['status']=4;$button=4;
  7617. // }
  7618. //
  7619. // }else{
  7620. //
  7621. // }
  7622. // if($flag){//检测可编辑
  7623. // if($v[0]==$this->staff[0]['sid']){
  7624. // $verifyList[$k]['status']=4;$button=4;
  7625. // }
  7626. // }
  7627. }
  7628. }
  7629. $rolename ['name'] = '';
  7630. if (! empty ( $roleId )) {
  7631. Doo::loadModel ( 'role' );
  7632. $role = new role ();
  7633. $rolename = $role->getOne ( array (
  7634. 'where' => 'rid=' . $roleId,
  7635. 'asArray' => true
  7636. ) );
  7637. }
  7638. if (! empty ( $verifyStaff ))
  7639. $endStaffArray = end ( $verifyStaff );
  7640. $KOP = false;
  7641. foreach ( $roleArrayCopy as $P => $A ) {
  7642. foreach ( $A as $MKI => $AVL ) {
  7643. if (! empty ( $verifyStaff )) {
  7644. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7645. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7646. $button = 4;
  7647. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7648. }
  7649. foreach ( $verifyStaff as $m => $u ) {
  7650. $AVLFK = $AVL [0] . '_R';
  7651. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7652. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7653. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7654. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7655. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7656. break;
  7657. }
  7658. }
  7659. } else {
  7660. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7661. $button = 4;
  7662. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7663. }
  7664. }
  7665. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7666. $KOP = true;
  7667. }
  7668. }
  7669. // print_r($roleArrayCopy);
  7670. // echo $roleKey;
  7671. foreach ( $roleArrayCopy as $k => $v ) {
  7672. foreach ( $verifyList as $m => $n ) {
  7673. if ($n [0] == $k) {
  7674. array_splice ( $verifyList, $m, 1, $v );
  7675. }
  7676. }
  7677. }
  7678. // if ($KOP)
  7679. // array_splice($verifyList,$roleKey,1,$roleArray);
  7680. // print_r($verifyList);
  7681. $receiptList [$key] ['verifyList'] = $verifyList;
  7682. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7683. 'where' => 'sid=' . $value ['staff'],
  7684. 'asArray' => true
  7685. ) );
  7686. $receiptList [$key] ['button'] = $button;
  7687. }
  7688. // $data['verifyDetail']=$verifyDetail;
  7689. $mothHtml = "";
  7690. for($i = 1; $i <= 12; $i ++) {
  7691. if ($month == $i)
  7692. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7693. else
  7694. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7695. }
  7696. // 获取审批日志
  7697. Doo::loadModel ( 'receiptLog' );
  7698. $receiptLog = new receiptLog ();
  7699. $rlList = array ();
  7700. $rlInfo = $receiptLog->getOne ( array (
  7701. 'where' => 'rid=' . $rid . ' and status=4',
  7702. 'asArray' => true
  7703. ) );
  7704. $tijdate = $receiptLog->getOne ( array (
  7705. 'where' => 'rid=' . $rid . ' and status=2',
  7706. 'asc' => 'rlid',
  7707. 'asArray' => true
  7708. ) );
  7709. if (! empty ( $rlInfo )) {
  7710. $rlList = $receiptLog->find ( array (
  7711. 'where' => 'rid=' . $rid,
  7712. 'asc' => 'rlid',
  7713. 'asArray' => true
  7714. ) );
  7715. }
  7716. $receiptList [0] ['rlList'] = $rlList;
  7717. $enclosurList = $enclosur->find ( array (
  7718. 'where' => 'rid=' . $rid,
  7719. 'asArray' => true
  7720. ) );
  7721. $enclosurHtml = '';
  7722. foreach ( $enclosurList as $value ) {
  7723. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7724. }
  7725. $data ['enclosurHtml'] = $enclosurHtml;
  7726. $data ['rolename'] = $rolename ['name'];
  7727. $data ['datetij'] = $tijdate ['date'];
  7728. $data ['mothHtml'] = $mothHtml;
  7729. $data ['receiptList'] = $receiptList;
  7730. $data ['receiptApprovalCount'] = count ( $receiptList );
  7731. $data ['status'] = $status;
  7732. $data ['year'] = $year;
  7733. $data ['categoryList'] = $categoryList;
  7734. $data ['staffList'] = $staffList;
  7735. $data ['cid'] = $cid;
  7736. $data ['sid'] = $sid;
  7737. $data ['ap'] = $ap;
  7738. $data ['memu'] = "receipt";
  7739. $data ['staff'] = $this->staff;
  7740. $data ['receiptMemu'] = 'approval';
  7741. $data ['verifyId'] = $this->verifyId;
  7742. $data ['executeId'] = $this->executeId;
  7743. $this->render ( "/admin/saeaReportListReport", $data );
  7744. }
  7745. function remittanceHky() {
  7746. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7747. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7748. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7749. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7750. $page_size = 15;
  7751. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7752. Doo::loadModel ( 'receipt' );
  7753. $receipt = new receipt ();
  7754. Doo::loadModel ( 'staff' );
  7755. $staff = new staff ();
  7756. $dateCondition = " and Year(executeDate) =" . $year;
  7757. if ($moth != 'MONTH')
  7758. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7759. if ($day != 'DAY' && $moth != 'MONTH')
  7760. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7761. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7762. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7763. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7764. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7765. $dayList = $receipt->find ( array (
  7766. 'select' => 'executeDate,sum(amount) as amount',
  7767. 'where' => $sql,
  7768. 'desc' => 'executeDate',
  7769. 'groupby' => 'executeDate',
  7770. 'limit' => $limit,
  7771. 'asArray' => true
  7772. ) );
  7773. // print_r($dayList);
  7774. foreach ( $dayList as $key => $value ) {
  7775. $remitString = "";
  7776. $receiptList = $receipt->find ( array (
  7777. 'select' => 'rid,executeDate,amount,staff,cid',
  7778. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7779. 'desc' => 'executeDate',
  7780. 'asArray' => true
  7781. ) );
  7782. foreach ( $receiptList as $k => $v ) {
  7783. $sinfo = $staff->getOne ( array (
  7784. 'select' => 'username,category',
  7785. 'where' => ' sid=' . $v ['staff'],
  7786. 'asArray' => true
  7787. ) );
  7788. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7789. }
  7790. $dayList [$key] ['staff'] = $remitString;
  7791. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7792. }
  7793. // print_r($dayList);
  7794. $mothHtml = "";
  7795. for($i = 1; $i <= 12; $i ++) {
  7796. if ($moth == $i)
  7797. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7798. else
  7799. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7800. }
  7801. $dayHtml = "";
  7802. if ($day != "DAY" || $moth != "MONTH") {
  7803. for($i = 1; $i <= 31; $i ++) {
  7804. if ($day == $i)
  7805. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7806. else
  7807. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7808. }
  7809. }
  7810. $dateHtml = "";
  7811. $now = date ( "Y" );
  7812. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7813. if ($YEARD <= $now) {
  7814. $dateHtml .= '<option ';
  7815. if ($year == $YEARD) {
  7816. $dateHtml .= 'selected ';
  7817. }
  7818. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7819. }
  7820. }
  7821. $data ['dateHtml'] = $dateHtml;
  7822. $data ['page'] = $pageinfo;
  7823. $data ['year'] = $year;
  7824. $data ['moth'] = $moth;
  7825. $data ['day'] = $day;
  7826. $data ['get'] = $get;
  7827. $data ['dayHtml'] = $dayHtml;
  7828. $data ['mothHtml'] = $mothHtml;
  7829. $data ['receiptList'] = $dayList;
  7830. $data ['memu'] = "receipt";
  7831. $data ['staff'] = $this->staff;
  7832. $data ['receiptMemu'] = 'remittanceHky';
  7833. $data ['verifyId'] = $this->verifyId;
  7834. $data ['executeId'] = $this->executeId;
  7835. $this->render ( "/admin/remittanceHky", $data );
  7836. }
  7837. function remittancep() {
  7838. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7839. Doo::loadModel ( 'receipt' );
  7840. $receipt = new receipt ();
  7841. Doo::loadModel ( 'staff' );
  7842. $staff = new staff ();
  7843. Doo::loadClass ( 'XDeode' );
  7844. $XDeode = new XDeode ( 5 );
  7845. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7846. $rplist = $receipt->find ( array (
  7847. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7848. 'asArray' => true
  7849. ) );
  7850. $dayList = $receipt->find ( array (
  7851. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7852. 'desc' => 'executeDate',
  7853. 'groupby' => 'staff',
  7854. 'asArray' => true
  7855. ) );
  7856. $html = '';
  7857. foreach ( $dayList as $key => $value ) {
  7858. $sinfo = $staff->getOne ( array (
  7859. 'select' => 'username,category',
  7860. 'where' => ' sid=' . $value ['staff'],
  7861. 'asArray' => true
  7862. ) );
  7863. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7864. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7865. $au = 0;
  7866. foreach ( $rplist as $k => $v ) {
  7867. if ($value ['staff'] == $v ['staff']) {
  7868. $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>';
  7869. $au += $v ['amount'];
  7870. }
  7871. }
  7872. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7873. }
  7874. $data ['html'] = $html;
  7875. $data ['memu'] = "receipt";
  7876. $data ['staff'] = $this->staff;
  7877. $data ['receiptMemu'] = 'remittanceHky';
  7878. $data ['verifyId'] = $this->verifyId;
  7879. $data ['executeId'] = $this->executeId;
  7880. $this->render ( "/admin/remittancep", $data );
  7881. }
  7882. function ajaxGetReceiptDetails() {
  7883. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7884. Doo::loadClass ( 'XDeode' );
  7885. $XDeode = new XDeode ( 5 );
  7886. $rid = $XDeode->decode ( $rid );
  7887. if (empty ( $rid )) {
  7888. echo json_encode ( array (
  7889. 'status' => 2,
  7890. 'msg' => 'illegal request'
  7891. ) );
  7892. die ();
  7893. }
  7894. Doo::loadModel ( 'receipt' );
  7895. $receipt = new receipt ();
  7896. Doo::loadModel ( 'staff' );
  7897. $staff = new staff ();
  7898. $rinfo = $receipt->getOne ( array (
  7899. 'where' => 'rid= ' . $rid,
  7900. 'asArray' => true
  7901. ) );
  7902. $sinfo = $staff->getOne ( array (
  7903. 'select' => 'username,category',
  7904. 'where' => ' sid=' . $rinfo ['staff'],
  7905. 'asArray' => true
  7906. ) );
  7907. $rinfo ['reviseDetail'] = array ();
  7908. if (! empty ( $rinfo ['reviseDetail'] ))
  7909. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7910. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7911. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7912. $rinfo ['category'] = $sinfo ['category'];
  7913. $verifyStaff = array ();
  7914. if (! empty ( $rinfo ['verifyStaff'] ))
  7915. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7916. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7917. $rinfo ['relust'] = $relust;
  7918. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7919. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7920. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7921. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7922. // 费用执行人相关数据
  7923. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7924. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  7925. foreach ( $executeCopy as $k => $v ) {
  7926. $executeCopy [$k] ['date'] = '';
  7927. $executeCopy [$k] ['opinion'] = '';
  7928. $executeCopy [$k] ['status'] = '';
  7929. if (! empty ( $executeStaff ))
  7930. foreach ( $executeStaff as $m => $u ) {
  7931. if ($v [0] == $m) {
  7932. $executeCopy [$k] ['date'] = $u ['date'];
  7933. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  7934. $executeCopy [$k] ['status'] = $u ['status'];
  7935. break;
  7936. }
  7937. }
  7938. }
  7939. $rinfo ['executeCopy'] = $executeCopy;
  7940. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  7941. if ($rinfo ['Rtype'] == 1) { // 借款费用
  7942. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  7943. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  7944. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  7945. $html .= '<tr><th>' . $value ['name'] . '</th>
  7946. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7947. }
  7948. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7949. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7950. <tr><th class="taC" colspan="2">费用说明</th>
  7951. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7952. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  7953. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  7954. </tbody></table>';
  7955. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  7956. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  7957. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  7958. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  7959. $html .= '<tr><th>' . $value ['name'] . '</th>
  7960. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7961. }
  7962. $html .= '<tr><th class="taR">合计</th>
  7963. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  7964. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  7965. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  7966. $html .= '<tr><th>' . $value ['name'] . '</th>
  7967. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7968. }
  7969. $html .= '<tr><th class="taR">合计</th>
  7970. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  7971. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  7972. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  7973. $html .= '<tr><th>' . $value ['name'] . '</th>
  7974. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7975. }
  7976. $html .= '<tr><th class="taR">合计</th>
  7977. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  7978. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  7979. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  7980. $html .= '<tr><th>' . $value ['name'] . '</th>
  7981. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  7982. }
  7983. $html .= '<tr><th class="taR">合计</th>
  7984. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  7985. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  7986. foreach ( $rinfo ['reviseDetail'] as $value ) {
  7987. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  7988. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  7989. }
  7990. $html .= '<tr><th class="taR">合计</th>
  7991. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  7992. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  7993. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  7994. <tr><th class="taC" colspan="2">报销说明</th></tr>
  7995. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  7996. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  7997. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  7998. <tr';
  7999. if ($rinfo ['relust'] >= 0) {
  8000. $html .= 'class="success"';
  8001. } else {
  8002. $html .= 'class="error"';
  8003. }
  8004. $html .= '><td class="taR"><b>借款结余</b></td>
  8005. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8006. </tbody></table>
  8007. ';
  8008. }
  8009. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8010. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8011. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8012. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8013. $html .= '<tr><th>' . $value ['name'] . '</th>
  8014. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8015. }
  8016. $html .= '<tr><th class="taR">合计</th>
  8017. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8018. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8019. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8020. <tr><th class="taC" colspan="2">费用说明</th>
  8021. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8022. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8023. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8024. </tbody></table>';
  8025. } else {
  8026. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8027. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8028. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8029. $html .= '<tr><th>' . $value ['name'] . '</th>
  8030. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8031. }
  8032. $html .= '<tr><th class="taR">合计</th>
  8033. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8034. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8035. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8036. $html .= '<tr><th>' . $value ['name'] . '</th>
  8037. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8038. }
  8039. $html .= '<tr><th class="taR">合计</th>
  8040. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8041. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8042. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8043. $html .= '<tr><th>' . $value ['name'] . '</th>
  8044. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8045. }
  8046. $html .= '<tr><th class="taR">合计</th>
  8047. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8048. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8049. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8050. $html .= '<tr><th>' . $value ['name'] . '</th>
  8051. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8052. }
  8053. $html .= '<tr><th class="taR">合计</th>
  8054. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8055. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8056. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8057. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8058. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8059. }
  8060. $html .= '<tr><th class="taR">合计</th>
  8061. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8062. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8063. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8064. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8065. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8066. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8067. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8068. $html .= '</tbody></table>';
  8069. /*
  8070. * <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>
  8071. */
  8072. }
  8073. // print_r($verifyStaff);die;
  8074. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8075. foreach ( $verifyStaff as $key => $value ) {
  8076. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8077. $sinfo = $staff->getOne ( array (
  8078. 'select' => 'username',
  8079. 'where' => ' sid=' . $key,
  8080. 'asArray' => true
  8081. ) );
  8082. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8083. }
  8084. $html .= '</tbody></table>';
  8085. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8086. foreach ( $rinfo ['executeCopy'] as $value ) {
  8087. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8088. }
  8089. $html .= '</tbody></table>';
  8090. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8091. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8092. </tr></table>';
  8093. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8094. echo json_encode ( array (
  8095. 'status' => 1,
  8096. 'html' => $html
  8097. ) );
  8098. die ();
  8099. }
  8100. /**
  8101. * 删除附件
  8102. */
  8103. function ajaxRemEnclousur() {
  8104. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8105. if (empty ( $key ))
  8106. echo json_encode ( array (
  8107. 'status' => 2
  8108. ) );
  8109. Doo::loadModel ( 'enclosur' );
  8110. $enclosur = new enclosur ();
  8111. $enclosur->delEnclosurByEid ( $key );
  8112. echo json_encode ( array (
  8113. 'status' => 1
  8114. ) );
  8115. }
  8116. function remittance() {
  8117. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8118. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8119. Doo::loadModel ( 'receipt' );
  8120. $receipt = new receipt ();
  8121. Doo::loadModel ( 'staff' );
  8122. $staff = new staff ();
  8123. $dateCondition = " and Year(pastDate) =" . $year;
  8124. if (! empty ( $month ))
  8125. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8126. // get Receipt By verifyID status 1
  8127. $receiptList = $receipt->find ( array (
  8128. 'select' => 'sum(sum) as sum,staff,pastDate',
  8129. 'where' => ' status=1' . $dateCondition,
  8130. 'desc' => 'pastDate',
  8131. 'groupby' => 'staff,pastDate',
  8132. 'asArray' => true
  8133. ) );
  8134. $dateList = $receipt->find ( array (
  8135. 'select' => 'pastDate,verifyStaff',
  8136. 'where' => ' status=1' . $dateCondition,
  8137. 'desc' => 'pastDate',
  8138. 'groupby' => 'pastDate',
  8139. 'asArray' => true
  8140. ) );
  8141. $dataList = array ();
  8142. foreach ( $dateList as $d => $a ) {
  8143. $dataList [$a ['pastDate']] = array ();
  8144. $daySum = 0;
  8145. foreach ( $receiptList as $key => $value ) {
  8146. if ($a ['pastDate'] == $value ['pastDate']) {
  8147. $oderList = $receipt->find ( array (
  8148. 'select' => 'receiptOrder',
  8149. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8150. 'asArray' => true
  8151. ) );
  8152. $list = array ();
  8153. $html = "";
  8154. foreach ( $oderList as $v ) {
  8155. array_push ( $list, $v ['receiptOrder'] );
  8156. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8157. }
  8158. $receiptList [$key] ['receiptOrder'] = $html;
  8159. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8160. $sinfo = $staff->getOne ( array (
  8161. 'select' => 'username ',
  8162. 'where' => ' sid=' . $value ['staff'],
  8163. 'asArray' => true
  8164. ) );
  8165. $receiptList [$key] ['username'] = $sinfo ['username'];
  8166. $daySum += $value ['sum'];
  8167. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8168. }
  8169. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8170. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8171. }
  8172. }
  8173. // print_r($dataList);
  8174. $data ['dataList'] = $dataList;
  8175. $mothHtml = "";
  8176. for($i = 1; $i <= 12; $i ++) {
  8177. if ($month == $i)
  8178. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8179. else
  8180. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8181. }
  8182. $data ['year'] = $year;
  8183. $data ['mothHtml'] = $mothHtml;
  8184. $data ['memu'] = "receipt";
  8185. $data ['staff'] = $this->staff;
  8186. $data ['receiptMemu'] = 'approval';
  8187. $data ['verifyId'] = $this->verifyId;
  8188. $data ['executeId'] = $this->executeId;
  8189. $this->render ( "/admin/saeaReportListPay", $data );
  8190. }
  8191. /**
  8192. * 金额调整,提高稳定性
  8193. * @return string
  8194. */
  8195. function revocationAdjustment() {
  8196. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8197. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8198. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8199. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8200. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8201. Doo::loadClass ( 'XDeode' );
  8202. $XDeode = new XDeode ( 5 );
  8203. Doo::loadModel ( 'receipt' );
  8204. $receipt = new receipt ();
  8205. $sid = $XDeode->decode ( $sidKey );
  8206. $rid = $XDeode->decode ( $ridKey );
  8207. $reviseKey = $XDeode->decode ( $reviseKey );
  8208. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8209. die ( 'illegal request' );
  8210. $receiptDetail = $receipt->getOne ( array (
  8211. 'where' => 'rid=' . $rid,
  8212. 'asArray' => true
  8213. ) );
  8214. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8215. die ( 'illegal request' );
  8216. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8217. if (! isset ( $reviseDetail [$reviseKey] ))
  8218. die ( 'illegal request' );
  8219. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8220. unset ( $reviseDetail [$reviseKey] );
  8221. $revisePrice = 0;
  8222. foreach ( $reviseDetail as $key => $value ) {
  8223. $revisePrice += $value ['price'];
  8224. }
  8225. $reviseDetailString = json_encode ( $reviseDetail );
  8226. $receipt->reviseDetail = $reviseDetailString;
  8227. $receipt->sum = $receiptDetail ['sum'] - $price;
  8228. $receipt->revisePrice = $revisePrice;
  8229. $receipt->update ( array (
  8230. 'where' => 'rid=' . $rid
  8231. ) );
  8232. return '/receiptburEdi/' . $rid;
  8233. } else
  8234. die ( 'illegal request2' );
  8235. }
  8236. function updateApprovalReceipt() {
  8237. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8238. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8239. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8240. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8241. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8242. if (! empty ( $rid )) {
  8243. Doo::loadModel ( "verify" );
  8244. $verify = new verify ();
  8245. Doo::loadModel ( "receiptDetail" );
  8246. $receiptDetailObj = new receiptDetail ();
  8247. Doo::loadModel ( "itemStatistics" );
  8248. Doo::loadModel ( "statistics" );
  8249. $statistics = new statistics ();
  8250. $itemStatistics = new itemStatistics ();
  8251. Doo::loadModel ( "receipt" );
  8252. $receipt = new receipt ();
  8253. $receiptDetail = $receipt->getOne ( array (
  8254. 'where' => 'rid=' . $rid . ' and status=2 ',
  8255. 'asArray' => true
  8256. ) );
  8257. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8258. $nsflag = true;
  8259. foreach ( $nslist as $value ) {
  8260. if ($value == $this->staff ['0'] ['sid']) {
  8261. $nsflag = false;
  8262. break;
  8263. }
  8264. }
  8265. if (empty ( $receiptDetail ) || $nsflag)
  8266. return "/approvalExpenses/pendApproval";
  8267. $verifyDetail = $verify->getOne ( array (
  8268. 'where' => ' vid =' . $receiptDetail ['verify'],
  8269. 'asArray' => true
  8270. ) );
  8271. $verifyString = $verifyDetail ['staff'];
  8272. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8273. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8274. if (empty ( $opinion )) {
  8275. if ($status == 3)
  8276. $opinion = "终止";
  8277. else
  8278. $opinion = "同意支付";
  8279. }
  8280. $nowStaff = 0;
  8281. $nowStaffList = array ();
  8282. if (empty ( $verifyStaff )) {
  8283. // 还需加入是否已经进入角色审批
  8284. if ($verifyDetail [0] [1] == 'ROLE') {
  8285. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8286. foreach ( $vStaffString as $key => $value ) {
  8287. $staffK = explode ( "_", $value );
  8288. if ($staffK [0] != $this->staff [0] ['sid'])
  8289. array_push ( $nowStaffList, $staffK [0] );
  8290. }
  8291. // print_r($verifyDetail);
  8292. // die;
  8293. if (! empty ( $nowStaffList )) {
  8294. $nowStaff = implode ( ',', $nowStaffList );
  8295. $verifyStaff = array (
  8296. $this->staff [0] ['sid'] . "_R" => array (
  8297. 'date' => date ( 'Y-m-d' ),
  8298. 'opinion' => $opinion,
  8299. 'status' => $status,
  8300. 'nextStaff' => $verifyDetail [0] [0],
  8301. 'ROLE' => 1
  8302. )
  8303. );
  8304. } else {
  8305. $nowStaff = $verifyDetail [1] [0];
  8306. $verifyStaff = array (
  8307. $this->staff [0] ['sid'] . "_R" => array (
  8308. 'date' => date ( 'Y-m-d' ),
  8309. 'opinion' => $opinion,
  8310. 'status' => $status,
  8311. 'nextStaff' => $verifyDetail [1] [0]
  8312. )
  8313. );
  8314. }
  8315. } else {
  8316. if ($verifyDetail [1] [1] == 'ROLE') {
  8317. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8318. // echo "dd";
  8319. foreach ( $vStaffString as $key => $value ) {
  8320. $staffK = explode ( "_", $value );
  8321. array_push ( $nowStaffList, $staffK [0] );
  8322. }
  8323. $nowStaff = implode ( ',', $nowStaffList );
  8324. $verifyStaff = array (
  8325. $this->staff [0] ['sid'] => array (
  8326. 'date' => date ( 'Y-m-d' ),
  8327. 'opinion' => $opinion,
  8328. 'status' => $status,
  8329. 'nextStaff' => $verifyDetail [1] [0],
  8330. 'ROLE' => 1
  8331. )
  8332. );
  8333. } else {
  8334. $nowStaff = $verifyDetail [1] [0];
  8335. $verifyStaff = array (
  8336. $this->staff [0] ['sid'] => array (
  8337. 'date' => date ( 'Y-m-d' ),
  8338. 'opinion' => $opinion,
  8339. 'status' => $status,
  8340. 'nextStaff' => $verifyDetail [1] [0]
  8341. )
  8342. );
  8343. }
  8344. }
  8345. if ($status == 3)
  8346. $verifyStaff = array (
  8347. 'final' => $status,
  8348. $this->staff [0] ['sid'] => array (
  8349. 'date' => date ( 'Y-m-d' ),
  8350. 'opinion' => $opinion,
  8351. 'status' => $status
  8352. )
  8353. );
  8354. $vStaffString = json_encode ( $verifyStaff );
  8355. $receipt->nowStaff = $nowStaff;
  8356. $receipt->verifyStaff = $vStaffString;
  8357. } else {
  8358. $VS = end ( $verifyStaff );
  8359. // 非角色审批
  8360. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8361. $nextStaff = 0;
  8362. $roleSTF = false;
  8363. foreach ( $verifyDetail as $key => $value ) {
  8364. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8365. if (isset ( $verifyDetail [$key + 1] )) {
  8366. $nextStaff = $verifyDetail [$key + 1] [0];
  8367. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8368. $roleSTF = true;
  8369. }
  8370. break;
  8371. }
  8372. }
  8373. if (! $roleSTF) {
  8374. $nowStaff = $nextStaff;
  8375. $verifyStaff [$this->staff [0] ['sid']] = array (
  8376. 'date' => date ( 'Y-m-d' ),
  8377. 'opinion' => $opinion,
  8378. 'status' => $status,
  8379. 'nextStaff' => $nextStaff
  8380. );
  8381. } else {
  8382. // 获取角色下的所有用户ID
  8383. $nowStaffList = array ();
  8384. foreach ( $verifyDetail as $vfk ) {
  8385. if ($vfk [1] == 'ROLE') {
  8386. $vStaffString = json_decode ( $vfk [3] );
  8387. foreach ( $vStaffString as $key => $value ) {
  8388. $staffK = explode ( "_", $value );
  8389. array_push ( $nowStaffList, $staffK [0] );
  8390. }
  8391. }
  8392. }
  8393. $nowStaff = implode ( ',', $nowStaffList );
  8394. $verifyStaff [$this->staff [0] ['sid']] = array (
  8395. 'date' => date ( 'Y-m-d' ),
  8396. 'opinion' => $opinion,
  8397. 'status' => $status,
  8398. 'nextStaff' => $nextStaff,
  8399. 'ROLE' => 0
  8400. );
  8401. }
  8402. if ($status == 3) {
  8403. $verifyStaff ['final'] = $status;
  8404. $verifyStaff [$this->staff [0] ['sid']] = array (
  8405. 'date' => date ( 'Y-m-d' ),
  8406. 'opinion' => $opinion,
  8407. 'status' => $status
  8408. );
  8409. }
  8410. $vStaffString = json_encode ( $verifyStaff );
  8411. $receipt->nowStaff = $nowStaff;
  8412. $receipt->verifyStaff = $vStaffString;
  8413. }
  8414. // 角色审批
  8415. if (isset ( $VS ['ROLE'] )) {
  8416. // 找出角色人 当前审批角色组
  8417. $verifyJSStaff = array ();
  8418. $nowStaffList2 = array ();
  8419. foreach ( $verifyDetail as $key => $value ) {
  8420. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8421. $verifyJSStaff = json_decode ( $value [3] );
  8422. foreach ( $verifyJSStaff as $m ) {
  8423. $staffK = explode ( "_", $m );
  8424. array_push ( $nowStaffList2, $staffK [0] );
  8425. }
  8426. // print_r($nowStaffList2);
  8427. }
  8428. }
  8429. $RoleVerifyStaff = array ();
  8430. foreach ( $verifyStaff as $key => $value ) {
  8431. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8432. foreach ( $nowStaffList2 as $m ) {
  8433. if ($key == $m . "_R")
  8434. $RoleVerifyStaff [$key] = $value;
  8435. }
  8436. }
  8437. }
  8438. // print_r($verifyStaff);
  8439. // print_r($nowStaffList2);
  8440. // print_r($RoleVerifyStaff);
  8441. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8442. // print_r($verifyJSStaff);
  8443. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8444. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8445. // 下一个审批人ID
  8446. $nextStaff = 0;
  8447. $falg = false;
  8448. foreach ( $verifyDetail as $key => $value ) {
  8449. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8450. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8451. $falg = true;
  8452. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8453. $nowStaffList = array ();
  8454. foreach ( $vStaffString as $v ) {
  8455. $staffK = explode ( "_", $v );
  8456. array_push ( $nowStaffList, $staffK [0] );
  8457. }
  8458. $nowStaff = implode ( ',', $nowStaffList );
  8459. $nextStaff = $verifyDetail [$key + 1] [0];
  8460. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8461. $nextStaff = $verifyDetail [$key + 1] [0];
  8462. $nowStaff = $nextStaff;
  8463. } else
  8464. $nowStaff = '';
  8465. break;
  8466. }
  8467. }
  8468. if ($falg)
  8469. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8470. 'date' => date ( 'Y-m-d' ),
  8471. 'opinion' => $opinion,
  8472. 'status' => $status,
  8473. 'nextStaff' => $nextStaff,
  8474. 'ROLE' => 1
  8475. );
  8476. else
  8477. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8478. 'date' => date ( 'Y-m-d' ),
  8479. 'opinion' => $opinion,
  8480. 'status' => $status,
  8481. 'nextStaff' => $nextStaff
  8482. );
  8483. // print_r($verifyStaff);
  8484. // echo $nowStaff;die;
  8485. } else { // 进入下一个角色或者审批人
  8486. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8487. //
  8488. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8489. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8490. 'date' => date ( 'Y-m-d' ),
  8491. 'opinion' => $opinion,
  8492. 'status' => $status,
  8493. 'nextStaff' => $VS ['nextStaff'],
  8494. 'ROLE' => 1
  8495. );
  8496. // print_r($verifyStaff);
  8497. // die;
  8498. }
  8499. if ($status == 3) {
  8500. $verifyStaff ['final'] = $status;
  8501. $verifyStaff [$this->staff [0] ['sid']] = array (
  8502. 'date' => date ( 'Y-m-d' ),
  8503. 'opinion' => $opinion,
  8504. 'status' => $status
  8505. );
  8506. }
  8507. $vStaffString = json_encode ( $verifyStaff );
  8508. $receipt->verifyStaff = $vStaffString;
  8509. $receipt->nowStaff = $nowStaff;
  8510. // die;
  8511. // }
  8512. // print_r($verifyStaff);
  8513. // die;
  8514. }
  8515. // print_r($verifyStaff);die;
  8516. }
  8517. // print_r($verifyDetail);
  8518. $roleKey = 0;
  8519. $roleId = 0;
  8520. $verifyDetailCopy = array ();
  8521. foreach ( $verifyDetail as $k => $v ) {
  8522. if ($v [1] == 'ROLE') {
  8523. $roleId = $v [0];
  8524. $roleVerify = json_decode ( $v [3], true );
  8525. $roleKey = $k;
  8526. $roleArray = array ();
  8527. foreach ( $roleVerify as $o => $p ) {
  8528. $staffID = explode ( '_', $p );
  8529. $exp = array (
  8530. 0 => $staffID [0],
  8531. 1 => $staffID [1]
  8532. );
  8533. array_push ( $roleArray, $exp );
  8534. }
  8535. $verifyDetailCopy [$v [0]] = $roleArray;
  8536. }
  8537. }
  8538. // print_r($verifyDetail);
  8539. foreach ( $verifyDetailCopy as $k => $v ) {
  8540. foreach ( $verifyDetail as $m => $n ) {
  8541. if ($n [0] == $k) {
  8542. array_splice ( $verifyDetail, $m, 1, $v );
  8543. }
  8544. }
  8545. }
  8546. // die;
  8547. // if (!empty($roleArray))
  8548. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8549. // echo $roleId;
  8550. // print_r($verifyStaff);
  8551. // print_r($verifyDetail);
  8552. // die;
  8553. Doo::loadModel ( "receiptLog" );
  8554. $receiptLog = new receiptLog ();
  8555. // 审批日志
  8556. if (! isset ( $verifyStaff ['final'] )) {
  8557. if (! empty ( $roleId )) {
  8558. Doo::loadModel ( "role" );
  8559. $role = new role ();
  8560. $roleInfo = $role->getOne ( array (
  8561. 'where' => 'rid=' . $roleId,
  8562. 'asArray' => true
  8563. ) );
  8564. $receiptLog->rolename = $roleInfo ['name'];
  8565. }
  8566. $receiptLog->username = $this->staff [0] ['username'];
  8567. $receiptLog->uid = $this->staff [0] ['sid'];
  8568. $receiptLog->date = date ( "Y-m-d" );
  8569. $receiptLog->opinion = $opinion;
  8570. $receiptLog->img = $this->staff [0] ['avatar'];
  8571. $receiptLog->status = 1;
  8572. $receiptLog->rid = $rid;
  8573. $receiptLog->insert ();
  8574. }
  8575. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8576. $receipt->verifyBreakup = $verifyString;
  8577. $receipt->status = 3;
  8578. $receiptDetailObj->status = 3;
  8579. $receiptDetailObj->update ( array (
  8580. 'where' => 'rid=' . $rid
  8581. ) );
  8582. if (! empty ( $roleId )) {
  8583. Doo::loadModel ( "role" );
  8584. $role = new role ();
  8585. $roleInfo = $role->getOne ( array (
  8586. 'where' => 'rid=' . $roleId,
  8587. 'asArray' => true
  8588. ) );
  8589. $receiptLog->rolename = $roleInfo ['name'];
  8590. }
  8591. $receiptLog->username = $this->staff [0] ['username'];
  8592. $receiptLog->uid = $this->staff [0] ['sid'];
  8593. $receiptLog->date = date ( "Y-m-d" );
  8594. $receiptLog->opinion = $opinion;
  8595. $receiptLog->img = $this->staff [0] ['avatar'];
  8596. $receiptLog->status = 3;
  8597. $receiptLog->rid = $rid;
  8598. $receiptLog->insert ();
  8599. // 微信企业号通知
  8600. $this->setWXMsg ( $rid, 3 );
  8601. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8602. $receipt->status = 1;
  8603. $reviseSum = 0;
  8604. $receipt->verifyBreakup = $verifyString;
  8605. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8606. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8607. foreach ( $reviseDetail as $key => $value ) {
  8608. $receiptDetailObj = new receiptDetail ();
  8609. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8610. $receiptDetailObj->item = $value ['description'];
  8611. $receiptDetailObj->itemCategory = "报销金额调整";
  8612. $receiptDetailObj->price = $value ['price'];
  8613. $receiptDetailObj->date = $receiptDetail ['date'];
  8614. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8615. $receiptDetailObj->rid = $rid;
  8616. $receiptDetailObj->status = 1;
  8617. $receiptDetailObj->insert ();
  8618. $reviseSum += $value ['price'];
  8619. }
  8620. $itemStatistics = new itemStatistics ();
  8621. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8622. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8623. $itemStatistics->price = $reviseSum;
  8624. $itemStatistics->itemCategory = "报销金额调整";
  8625. $itemStatistics->date = $receiptDetail ['date'];
  8626. $itemStatistics->insert ();
  8627. }
  8628. $receiptDetailObj = new receiptDetail ();
  8629. $receiptDetailObj->status = 1;
  8630. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8631. $receiptDetailObj->update ( array (
  8632. 'where' => 'rid=' . $rid
  8633. ) );
  8634. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8635. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8636. $stat = $statistics->getOne ( array (
  8637. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8638. 'asArray' => true
  8639. ) );
  8640. if (empty ( $stat )) {
  8641. $statistics->date = $receiptDetail ['date'];
  8642. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8643. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8644. $statistics->agPrice = $receiptDetail ['sum'];
  8645. $statistics->rePrice = $reviseSum;
  8646. $statistics->insert ();
  8647. } else {
  8648. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8649. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8650. $statistics->update ( array (
  8651. 'where' => 'sid=' . $stat ['sid']
  8652. ) );
  8653. }
  8654. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8655. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8656. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8657. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8658. if ($key == "agencySum") {
  8659. $iStatistics = $itemStatistics->getOne ( array (
  8660. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8661. 'asArray' => true
  8662. ) );
  8663. if (empty ( $iStatistics )) {
  8664. $itemStatistics->cid = $receiptDetail ['cid'];
  8665. ;
  8666. $itemStatistics->staff = $receiptDetail ['staff'];
  8667. $itemStatistics->price = $value;
  8668. $itemStatistics->itemCategory = $this->AGENCY;
  8669. $itemStatistics->date = $receiptDetail ['date'];
  8670. $itemStatistics->insert ();
  8671. } else {
  8672. if (! empty ( $value )) {
  8673. $itemStatistics->price = $value + $iStatistics ['price'];
  8674. $itemStatistics->update ( array (
  8675. 'where' => 'sid=' . $iStatistics ['sid']
  8676. ) );
  8677. }
  8678. }
  8679. } elseif ($key == "travelSum") {
  8680. $iStatistics = $itemStatistics->getOne ( array (
  8681. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8682. 'asArray' => true
  8683. ) );
  8684. if (empty ( $iStatistics )) {
  8685. $itemStatistics->cid = $receiptDetail ['cid'];
  8686. $itemStatistics->staff = $receiptDetail ['staff'];
  8687. $itemStatistics->price = $value;
  8688. $itemStatistics->itemCategory = $this->TRAVEL;
  8689. $itemStatistics->date = $receiptDetail ['date'];
  8690. $itemStatistics->insert ();
  8691. } else {
  8692. if (! empty ( $value )) {
  8693. $itemStatistics->price = $value + $iStatistics ['price'];
  8694. $itemStatistics->update ( array (
  8695. 'where' => 'sid=' . $iStatistics ['sid']
  8696. ) );
  8697. }
  8698. }
  8699. } elseif ($key == "trainSum") {
  8700. $iStatistics = $itemStatistics->getOne ( array (
  8701. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8702. 'asArray' => true
  8703. ) );
  8704. if (empty ( $iStatistics )) {
  8705. $itemStatistics->cid = $receiptDetail ['cid'];
  8706. $itemStatistics->staff = $receiptDetail ['staff'];
  8707. $itemStatistics->price = $value;
  8708. $itemStatistics->itemCategory = $this->TRAIN;
  8709. $itemStatistics->date = $receiptDetail ['date'];
  8710. $itemStatistics->insert ();
  8711. } else {
  8712. if (! empty ( $value )) {
  8713. $itemStatistics->price = $value + $iStatistics ['price'];
  8714. $itemStatistics->update ( array (
  8715. 'where' => 'sid=' . $iStatistics ['sid']
  8716. ) );
  8717. }
  8718. }
  8719. } elseif ($key == "otherSum") {
  8720. $iStatistics = $itemStatistics->getOne ( array (
  8721. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8722. 'asArray' => true
  8723. ) );
  8724. if (empty ( $iStatistics )) {
  8725. $itemStatistics->cid = $receiptDetail ['cid'];
  8726. $itemStatistics->staff = $receiptDetail ['staff'];
  8727. $itemStatistics->price = $value;
  8728. $itemStatistics->itemCategory = $this->OTHER;
  8729. $itemStatistics->date = $receiptDetail ['date'];
  8730. $itemStatistics->insert ();
  8731. } else {
  8732. if (! empty ( $value )) {
  8733. $itemStatistics->price = $value + $iStatistics ['price'];
  8734. $itemStatistics->update ( array (
  8735. 'where' => 'sid=' . $iStatistics ['sid']
  8736. ) );
  8737. }
  8738. }
  8739. }
  8740. }
  8741. $receipt->pastDate = date ( "Y-m-d" );
  8742. // 微信企业号通知
  8743. $this->setWXMsg ( $rid, 1 );
  8744. }
  8745. //是否有流水
  8746. Doo::loadModel ( 'wasteBook' );
  8747. $wasteBook = new wasteBook ();
  8748. $accountType=3;
  8749. if ($receiptDetail['Rtype']==1){
  8750. $accountType=2;
  8751. }elseif($receiptDetail['Rtype']==2){
  8752. $accountType=4;
  8753. }
  8754. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $rid );
  8755. if (empty($wbDetail)){
  8756. $receipt->amount = $amount;
  8757. }
  8758. $receipt->update ( array (
  8759. 'where' => ' rid = ' . $rid
  8760. ) );
  8761. // 进入下一条审批费用新加需求
  8762. $vidList = array ();
  8763. $verifyDetail = $verify->find ( array (
  8764. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8765. 'asArray' => true
  8766. ) );
  8767. foreach ( $verifyDetail as $key => $value ) {
  8768. array_push ( $vidList, $value ['vid'] );
  8769. }
  8770. $vid = implode ( ",", $vidList );
  8771. if (empty ( $verifyDetail ))
  8772. $vid = 0;
  8773. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8774. $receipt = new receipt ();
  8775. $rd = $receipt->getOne ( array (
  8776. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8777. 'asc' => 'rid',
  8778. 'asArray' => true
  8779. ) );
  8780. if (empty ( $rd )) {
  8781. return '/approvalExpenses/pendApproval';
  8782. }
  8783. if ($rd ['Rtype'] == 1) {
  8784. if ($rd ['isBK'] == 1) {
  8785. return '/receiptburEdi/' . $rd ['rid'];
  8786. } else {
  8787. return '/expensesEdi/' . $rd ['rid'];
  8788. }
  8789. } elseif ($rd ['Rtype'] == 2) {
  8790. return '/remitApproval/' . $rd ['rid'];
  8791. } else {
  8792. return '/receiptburEdi/' . $rd ['rid'];
  8793. }
  8794. // return "/approvalExpenses/pendApproval";
  8795. }
  8796. }
  8797. function expensesRetreats() {
  8798. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8799. if (! empty ( $rid )) {
  8800. // 操作记录
  8801. Doo::loadModel ( "receipt" );
  8802. $receipt = new receipt ();
  8803. Doo::loadModel ( "receiptLog" );
  8804. $receiptLog = new receiptLog ();
  8805. Doo::loadModel ( "verify" );
  8806. $verify = new verify ();
  8807. $receiptInfo = $receipt->getOne ( array (
  8808. 'where' => 'rid=' . $rid,
  8809. 'asArray' => true
  8810. ) );
  8811. $vr = $verify->getOne ( array (
  8812. 'where' => 'vid=' . $receiptInfo ['verify'],
  8813. 'asArray' => true
  8814. ) );
  8815. $jd = json_decode ( $vr ['staff'] );
  8816. $roleId = 0;
  8817. foreach ( $jd as $key => $value ) {
  8818. if ($value [1] == 'ROLE') {
  8819. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8820. if ($pos !== false) {
  8821. $roleId = $value [0];
  8822. }
  8823. }
  8824. }
  8825. // 审批日志
  8826. // echo $roleId;die;
  8827. if (! empty ( $roleId )) {
  8828. Doo::loadModel ( "role" );
  8829. $role = new role ();
  8830. $roleInfo = $role->getOne ( array (
  8831. 'where' => 'rid=' . $roleId,
  8832. 'asArray' => true
  8833. ) );
  8834. $receiptLog->rolename = $roleInfo ['name'];
  8835. }
  8836. $receiptLog->username = $this->staff [0] ['username'];
  8837. $receiptLog->uid = $this->staff [0] ['sid'];
  8838. $receiptLog->date = date ( "Y-m-d" );
  8839. $receiptLog->opinion = '撤回';
  8840. $receiptLog->img = $this->staff [0] ['avatar'];
  8841. $receiptLog->status = 4;
  8842. $receiptLog->rid = $rid;
  8843. $receiptLog->insert ();
  8844. $receipt->status = 4;
  8845. $receipt->update ( array (
  8846. 'where' => 'rid=' . $rid
  8847. ) );
  8848. // 微信企业号通知
  8849. $this->setWXMsg ( $rid, 2 );
  8850. }
  8851. // echo "ddd";
  8852. return '/approvalExpenses/pendApproval';
  8853. }
  8854. function updateCheReceipt() {
  8855. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8856. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8857. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8858. if (! empty ( $rid )) {
  8859. // 操作记录
  8860. Doo::loadModel ( "receipt" );
  8861. $receipt = new receipt ();
  8862. Doo::loadModel ( "receiptLog" );
  8863. $receiptLog = new receiptLog ();
  8864. Doo::loadModel ( "verify" );
  8865. $verify = new verify ();
  8866. $receiptInfo = $receipt->getOne ( array (
  8867. 'where' => 'rid=' . $rid . ' and status=2',
  8868. 'asArray' => true
  8869. ) );
  8870. if (empty ( $receiptInfo )) {
  8871. echo json_encode ( array (
  8872. 'status' => 2
  8873. ) );
  8874. die ();
  8875. }
  8876. $vr = $verify->getOne ( array (
  8877. 'where' => 'vid=' . $receiptInfo ['verify'],
  8878. 'asArray' => true
  8879. ) );
  8880. $jd = json_decode ( $vr ['staff'] );
  8881. $roleId = 0;
  8882. foreach ( $jd as $key => $value ) {
  8883. if ($value [1] == 'ROLE') {
  8884. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8885. if ($pos !== false) {
  8886. $roleId = $value [0];
  8887. }
  8888. }
  8889. }
  8890. // 审批日志
  8891. // echo $roleId;die;
  8892. if (! empty ( $roleId )) {
  8893. Doo::loadModel ( "role" );
  8894. $role = new role ();
  8895. $roleInfo = $role->getOne ( array (
  8896. 'where' => 'rid=' . $roleId,
  8897. 'asArray' => true
  8898. ) );
  8899. $receiptLog->rolename = $roleInfo ['name'];
  8900. }
  8901. $receiptLog->username = $this->staff [0] ['username'];
  8902. $receiptLog->uid = $this->staff [0] ['sid'];
  8903. $receiptLog->date = date ( "Y-m-d" );
  8904. $receiptLog->opinion = $opinion;
  8905. $receiptLog->img = $this->staff [0] ['avatar'];
  8906. $receiptLog->status = 4;
  8907. $receiptLog->rid = $rid;
  8908. $receiptLog->insert ();
  8909. $receipt->status = 4;
  8910. $receipt->update ( array (
  8911. 'where' => 'rid=' . $rid
  8912. ) );
  8913. // 微信企业号通知
  8914. $this->setWXMsg ( $rid, 2 );
  8915. echo json_encode ( array (
  8916. 'status' => 1
  8917. ) );
  8918. // Header("HTTP/1.1 303 See Other");
  8919. // Header("Location: /approvalExpenses/pendApproval");
  8920. die ();
  8921. }
  8922. echo json_encode ( array (
  8923. 'status' => 2
  8924. ) );
  8925. die ();
  8926. // echo "ddd";
  8927. // return '/saeaBorad';
  8928. }
  8929. function revisePrice() {
  8930. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8931. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8932. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8933. // echo $price;die;
  8934. if (! empty ( $rid )) {
  8935. Doo::loadModel ( "receipt" );
  8936. $receipt = new receipt ();
  8937. $receiptDetail = $receipt->getOne ( array (
  8938. 'where' => 'rid=' . $rid . ' and status=2 ',
  8939. 'asArray' => true
  8940. ) );
  8941. if (empty ( $receiptDetail ))
  8942. die ( 'illegal request' );
  8943. $reviseDetail = array ();
  8944. if (empty ( $receiptDetail ['reviseDetail'] )) {
  8945. array_push ( $reviseDetail, array (
  8946. 'sid' => $this->staff [0] ['sid'],
  8947. 'name' => $this->staff [0] ['username'],
  8948. 'description' => $description,
  8949. 'price' => $price
  8950. ) );
  8951. $reviseDetailString = json_encode ( $reviseDetail );
  8952. $receipt->reviseDetail = $reviseDetailString;
  8953. $receipt->revisePrice = $price;
  8954. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8955. } else {
  8956. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8957. array_push ( $reviseDetail, array (
  8958. 'sid' => $this->staff [0] ['sid'],
  8959. 'name' => $this->staff [0] ['username'],
  8960. 'description' => $description,
  8961. 'price' => $price
  8962. ) );
  8963. $reviseDetailString = json_encode ( $reviseDetail );
  8964. $receipt->reviseDetail = $reviseDetailString;
  8965. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  8966. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  8967. }
  8968. $receipt->update ( array (
  8969. 'where' => 'rid=' . $rid
  8970. ) );
  8971. if ($receiptDetail ['Rtype'] == 1) {
  8972. if ($receiptDetail ['isBK'] == 1) {
  8973. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8974. }
  8975. } elseif ($receiptDetail ['Rtype'] == 2) {
  8976. } else {
  8977. return '/receiptburEdi/' . $receiptDetail ['rid'];
  8978. }
  8979. }
  8980. die ( 'illegal request' );
  8981. }
  8982. function personalCollect() {
  8983. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8984. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  8985. $this->showCache ( $path );
  8986. Doo::loadModel ( "receiptDetail" );
  8987. Doo::loadModel ( "itemStatistics" );
  8988. Doo::loadModel ( 'statistics' );
  8989. $statistics = new statistics ();
  8990. $itemStatistics = new itemStatistics ();
  8991. $receiptDetail = new receiptDetail ();
  8992. $receiptCollectList = $receiptDetail->find ( array (
  8993. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8994. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8995. 'groupby' => 'itemCategory,Month(date)',
  8996. 'asArray' => true
  8997. ) );
  8998. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  8999. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9000. 'asArray' => true
  9001. ) );
  9002. // create collect html
  9003. $collectArray = array (
  9004. '日常相关费用' => array (),
  9005. '差旅相关费用' => array (),
  9006. '培训班费用' => array (),
  9007. '其他' => array ()
  9008. );
  9009. $adjustment = array ();
  9010. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9011. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9012. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9013. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9014. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9015. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9016. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9017. array_push ( $collectArray ['其他'], $collectHtml );
  9018. $data ['collectArray'] = $collectArray;
  9019. // statistics html
  9020. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9021. if (empty ( $stList ))
  9022. $stList = array (
  9023. 'rePrice' => 0,
  9024. 'agPrice' => 0
  9025. );
  9026. $data ['stList'] = array (
  9027. 'rePrice' => $stList ['rePrice'],
  9028. 'agPrice' => $stList ['agPrice'],
  9029. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9030. );
  9031. // Adjustment price html
  9032. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9033. array_push ( $adjustment, $collectHtml );
  9034. $data ['adjustment'] = $adjustment;
  9035. // total price html
  9036. $collectHtml = "";
  9037. $total = 0;
  9038. for($i = 1; $i <= 12; $i ++) {
  9039. $sumPrice = 0;
  9040. foreach ( $receiptCollectList as $key => $value ) {
  9041. if ($value ['month'] == $i) {
  9042. $sumPrice += $value ['price'];
  9043. }
  9044. }
  9045. if ($sumPrice == 0)
  9046. $collectHtml .= '<td class="taR">-</td>';
  9047. else
  9048. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9049. $total += $sumPrice;
  9050. }
  9051. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9052. $data ['totalPrice'] = $collectHtml;
  9053. $dateHtml = "";
  9054. $now = date ( "Y" );
  9055. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9056. if ($YEARD <= $now) {
  9057. $dateHtml .= '<option ';
  9058. if ($year == $YEARD) {
  9059. $dateHtml .= 'selected ';
  9060. }
  9061. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9062. }
  9063. }
  9064. $data ['dateHtml'] = $dateHtml;
  9065. $data ['year'] = $year;
  9066. $data ['totalYear'] = $total;
  9067. $data ['memu'] = "receipt";
  9068. $data ['staff'] = $this->staff;
  9069. $data ['receiptMemu'] = 'personalCollect';
  9070. $data ['verifyId'] = $this->verifyId;
  9071. $data ['executeId'] = $this->executeId;
  9072. // year staff status 2,4
  9073. if ($year < date ( "Y" )) {
  9074. Doo::loadModel ( 'receipt' );
  9075. $receipt = new receipt ();
  9076. $receiptList = $receipt->find ( array (
  9077. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9078. 'asArray' => true
  9079. ) );
  9080. if (empty ( $receiptList )) {
  9081. ob_start ();
  9082. $this->render ( "/admin/saea_slist_collect", $data );
  9083. $this->cacheFile ( $path );
  9084. die ();
  9085. }
  9086. }
  9087. $this->render ( "/admin/saea_slist_collect", $data );
  9088. }
  9089. function personalCollectDetail() {
  9090. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9091. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9092. $this->showCache ( $path );
  9093. Doo::loadModel ( "receiptDetail" );
  9094. Doo::loadModel ( "itemStatistics" );
  9095. Doo::loadModel ( 'statistics' );
  9096. Doo::loadModel ( 'accountItem' );
  9097. $accountItem = new accountItem ();
  9098. $statistics = new statistics ();
  9099. $itemStatistics = new itemStatistics ();
  9100. $receiptDetail = new receiptDetail ();
  9101. $receiptCollectList = $receiptDetail->find ( array (
  9102. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9103. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9104. 'groupby' => 'item,Month(date)',
  9105. 'asArray' => true
  9106. ) );
  9107. $accountList = $accountItem->find ( array (
  9108. 'asArray' => true
  9109. ) );
  9110. // create CollectDetail HTML
  9111. $collectHtml = array ();
  9112. foreach ( $accountList as $key => $value ) {
  9113. $html = "";
  9114. $asum = 0;
  9115. for($i = 1; $i <= 12; $i ++) {
  9116. $falg = true;
  9117. foreach ( $receiptCollectList as $v ) {
  9118. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9119. $asum += $v ['price'];
  9120. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9121. $falg = false;
  9122. break;
  9123. }
  9124. }
  9125. if ($falg)
  9126. $html .= '<td class="taR">-</td>';
  9127. }
  9128. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9129. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9130. }
  9131. $data ['collectHtml'] = $collectHtml;
  9132. // create Adjustment price html
  9133. $receiptCollectList = $receiptDetail->find ( array (
  9134. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9135. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9136. 'groupby' => 'itemCategory,Month(date)',
  9137. 'asArray' => true
  9138. ) );
  9139. $adjustment = array ();
  9140. $collectArray = array (
  9141. '日常相关费用' => array (),
  9142. '差旅相关费用' => array (),
  9143. '培训班费用' => array (),
  9144. '其他' => array ()
  9145. );
  9146. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9147. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9148. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9149. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9150. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9151. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9152. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9153. array_push ( $collectArray ['其他'], $collectHtml );
  9154. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9155. array_push ( $adjustment, $collectHtml );
  9156. // total price html
  9157. $collectHtml = "";
  9158. $total = 0;
  9159. for($i = 1; $i <= 12; $i ++) {
  9160. $sumPrice = 0;
  9161. foreach ( $receiptCollectList as $key => $value ) {
  9162. if ($value ['month'] == $i) {
  9163. $sumPrice += $value ['price'];
  9164. }
  9165. }
  9166. if ($sumPrice == 0)
  9167. $collectHtml .= '<td class="taR">-</td>';
  9168. else
  9169. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9170. $total += $sumPrice;
  9171. }
  9172. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9173. // statistics html
  9174. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9175. if (empty ( $stList ))
  9176. $stList = array (
  9177. 'rePrice' => 0,
  9178. 'agPrice' => 0
  9179. );
  9180. $data ['stList'] = array (
  9181. 'rePrice' => $stList ['rePrice'],
  9182. 'agPrice' => $stList ['agPrice'],
  9183. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9184. );
  9185. $data ['collectArray'] = $collectArray;
  9186. $data ['adjustment'] = $adjustment;
  9187. $data ['totalPrice'] = $collectHtml;
  9188. $data ['totalYear'] = $total;
  9189. $data ['year'] = $year;
  9190. $dateHtml = "";
  9191. $now = date ( "Y" );
  9192. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9193. if ($YEARD <= $now) {
  9194. $dateHtml .= '<option ';
  9195. if ($year == $YEARD) {
  9196. $dateHtml .= 'selected ';
  9197. }
  9198. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9199. }
  9200. }
  9201. $data ['dateHtml'] = $dateHtml;
  9202. $data ['memu'] = "receipt";
  9203. $data ['staff'] = $this->staff;
  9204. $data ['receiptMemu'] = 'personalCollect';
  9205. $data ['verifyId'] = $this->verifyId;
  9206. $data ['executeId'] = $this->executeId;
  9207. // year staff status 2,4
  9208. if ($year < date ( "Y" )) {
  9209. Doo::loadModel ( 'receipt' );
  9210. $receipt = new receipt ();
  9211. $receiptList = $receipt->find ( array (
  9212. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9213. 'asArray' => true
  9214. ) );
  9215. if (empty ( $receiptList )) {
  9216. ob_start ();
  9217. $this->render ( "/admin/saeaCollectArticles", $data );
  9218. $this->cacheFile ( $path );
  9219. die ();
  9220. }
  9221. }
  9222. $this->render ( "/admin/saeaCollectArticles", $data );
  9223. }
  9224. function companyCategoryCollect() {
  9225. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9226. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9227. $this->showCache ( $path );
  9228. Doo::loadModel ( 'L_category' );
  9229. Doo::loadModel ( 'itemStatistics' );
  9230. Doo::loadModel ( 'statistics' );
  9231. $statistics = new statistics ();
  9232. $Lcategory = new L_category ();
  9233. $itemStatistics = new itemStatistics ();
  9234. Doo::loadModel ( "receiptAuthorityManage" );
  9235. $receiptAuthorityManage = new receiptAuthorityManage ();
  9236. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9237. $cidList = array ();
  9238. foreach ( $imcStaff as $key => $value ) {
  9239. array_push ( $cidList, $value ['cid'] );
  9240. }
  9241. $cidString = implode ( ',', $cidList );
  9242. $LcategoryList = $Lcategory->find ( array (
  9243. 'where' => ' cid in (' . $cidString . ')',
  9244. 'asArray' => true
  9245. ) ); // 'staff='.$this->staff[0]['sid']." and
  9246. $itemStatisticsList = $itemStatistics->find ( array (
  9247. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9248. 'where' => " Year(date)=" . $year,
  9249. 'groupby' => 'cid,Month(date)',
  9250. 'asArray' => true
  9251. ) );
  9252. // ceatre companyCollectHtml
  9253. foreach ( $LcategoryList as $value ) {
  9254. $html = "";
  9255. $asum = 0;
  9256. for($i = 1; $i <= 12; $i ++) {
  9257. $falg = true;
  9258. foreach ( $itemStatisticsList as $v ) {
  9259. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9260. $asum += $v ['price'];
  9261. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9262. $falg = false;
  9263. break;
  9264. }
  9265. }
  9266. if ($falg)
  9267. $html .= '<td class="taR">-</td>';
  9268. }
  9269. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9270. $collectHtml [$value ['title']] = array (
  9271. 'html' => $html,
  9272. 'cid' => $value ['cid']
  9273. );
  9274. }
  9275. $data ['companyHtml'] = $collectHtml;
  9276. // total price html
  9277. $collectHtml = "";
  9278. $total = 0;
  9279. for($i = 1; $i <= 12; $i ++) {
  9280. $sumPrice = 0;
  9281. foreach ( $itemStatisticsList as $key => $value ) {
  9282. if ($value ['month'] == $i) {
  9283. $sumPrice += $value ['price'];
  9284. }
  9285. }
  9286. if ($sumPrice == 0)
  9287. $collectHtml .= '<td class="taR">-</td>';
  9288. else
  9289. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9290. $total += $sumPrice;
  9291. }
  9292. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9293. $data ['companyTotalHtml'] = $collectHtml;
  9294. $data ['total'] = $total;
  9295. // statistics html
  9296. // echo $cidString;
  9297. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9298. if (empty ( $stList ))
  9299. $stList = array (
  9300. 'rePrice' => 0,
  9301. 'agPrice' => 0
  9302. );
  9303. $data ['stList'] = array (
  9304. 'rePrice' => $stList ['rePrice'],
  9305. 'agPrice' => $stList ['agPrice'],
  9306. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9307. );
  9308. $data ['year'] = $year;
  9309. $data ['memu'] = "receipt";
  9310. $data ['staff'] = $this->staff;
  9311. $data ['receiptMemu'] = 'companyCategoryCollect';
  9312. $data ['verifyId'] = $this->verifyId;
  9313. $data ['executeId'] = $this->executeId;
  9314. $dateHtml = "";
  9315. $now = date ( "Y" );
  9316. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9317. if ($YEARD <= $now) {
  9318. $dateHtml .= '<option ';
  9319. if ($year == $YEARD) {
  9320. $dateHtml .= 'selected ';
  9321. }
  9322. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9323. }
  9324. }
  9325. $data ['dateHtml'] = $dateHtml;
  9326. // year staff status 2,4
  9327. if ($year < date ( "Y" )) {
  9328. Doo::loadModel ( 'receipt' );
  9329. $receipt = new receipt ();
  9330. $receiptList = $receipt->find ( array (
  9331. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9332. 'asArray' => true
  9333. ) );
  9334. if (empty ( $receiptList )) {
  9335. ob_start ();
  9336. $this->render ( "/admin/saeaCompanyCollect", $data );
  9337. $this->cacheFile ( $path );
  9338. die ();
  9339. }
  9340. }
  9341. $this->render ( "/admin/saeaCompanyCollect", $data );
  9342. }
  9343. function categoryCollectDetail() {
  9344. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9345. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9346. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9347. $this->showCache ( $path );
  9348. Doo::loadModel ( 'statistics' );
  9349. $statistics = new statistics ();
  9350. Doo::loadModel ( "receiptDetail" );
  9351. $receiptDetail = new receiptDetail ();
  9352. Doo::loadModel ( 'L_category' );
  9353. $Lcategory = new L_category ();
  9354. Doo::loadModel ( 'accountItem' );
  9355. $accountItem = new accountItem ();
  9356. Doo::loadModel ( "receiptAuthorityManage" );
  9357. $receiptAuthorityManage = new receiptAuthorityManage ();
  9358. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9359. $cidList = array ();
  9360. foreach ( $imcStaff as $key => $value ) {
  9361. array_push ( $cidList, $value ['cid'] );
  9362. }
  9363. $cidString = implode ( ',', $cidList );
  9364. $LcategoryList = $Lcategory->find ( array (
  9365. 'where' => 'cid in (' . $cidString . ')',
  9366. 'asArray' => true
  9367. ) );
  9368. if ($cid == 0) {
  9369. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9370. if ($cid == 0)
  9371. $cid = $LcategoryList [0] ['cid'];
  9372. }
  9373. $data ['LcategoryList'] = $LcategoryList;
  9374. $receiptCollectList = $receiptDetail->find ( array (
  9375. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9376. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9377. 'groupby' => 'item,Month(pastDate)',
  9378. 'asArray' => true
  9379. ) );
  9380. $accountList = $accountItem->find ( array (
  9381. 'asArray' => true
  9382. ) );
  9383. // create CollectDetail HTML
  9384. $collectHtml = array ();
  9385. foreach ( $accountList as $key => $value ) {
  9386. $html = "";
  9387. $asum = 0;
  9388. for($i = 1; $i <= 12; $i ++) {
  9389. $falg = true;
  9390. foreach ( $receiptCollectList as $v ) {
  9391. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9392. $asum += $v ['price'];
  9393. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9394. $falg = false;
  9395. break;
  9396. }
  9397. }
  9398. if ($falg)
  9399. $html .= '<td class="taR">-</td>';
  9400. }
  9401. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9402. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9403. }
  9404. $data ['collectHtml'] = $collectHtml;
  9405. // create Adjustment price html
  9406. $receiptCollectList = $receiptDetail->find ( array (
  9407. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9408. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9409. 'groupby' => 'itemCategory,Month(pastDate)',
  9410. 'asArray' => true
  9411. ) );
  9412. $adjustment = array ();
  9413. $collectArray = array (
  9414. '日常相关费用' => array (),
  9415. '差旅相关费用' => array (),
  9416. '培训班费用' => array (),
  9417. '其他' => array ()
  9418. );
  9419. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9420. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9421. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9422. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9424. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9425. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9426. array_push ( $collectArray ['其他'], $collectHtml );
  9427. $data ['collectArray'] = $collectArray;
  9428. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9429. array_push ( $adjustment, $collectHtml );
  9430. $data ['adjustment'] = $adjustment;
  9431. // total price html
  9432. $collectHtml = "";
  9433. $total = 0;
  9434. for($i = 1; $i <= 12; $i ++) {
  9435. $sumPrice = 0;
  9436. foreach ( $receiptCollectList as $key => $value ) {
  9437. if ($value ['month'] == $i) {
  9438. $sumPrice += $value ['price'];
  9439. }
  9440. }
  9441. if ($sumPrice == 0)
  9442. $collectHtml .= '<td class="taR">-</td>';
  9443. else
  9444. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9445. $total += $sumPrice;
  9446. }
  9447. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9448. // statistics html
  9449. $stList = $statistics->statisticsByCid ( $year, $cid );
  9450. if (empty ( $stList ))
  9451. $stList = array (
  9452. 'rePrice' => 0,
  9453. 'agPrice' => 0
  9454. );
  9455. $data ['stList'] = array (
  9456. 'rePrice' => $stList ['rePrice'],
  9457. 'agPrice' => $stList ['agPrice'],
  9458. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9459. );
  9460. $data ['totalYear'] = $total;
  9461. $data ['year'] = $year;
  9462. $data ['cid'] = $cid;
  9463. $data ['memu'] = "receipt";
  9464. $data ['staff'] = $this->staff;
  9465. $data ['receiptMemu'] = 'companyCategoryCollect';
  9466. $data ['verifyId'] = $this->verifyId;
  9467. $data ['executeId'] = $this->executeId;
  9468. // year staff status 2,4
  9469. if ($year < date ( "Y" )) {
  9470. Doo::loadModel ( 'receipt' );
  9471. $receipt = new receipt ();
  9472. $receiptList = $receipt->find ( array (
  9473. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9474. 'asArray' => true
  9475. ) );
  9476. if (empty ( $receiptList )) {
  9477. ob_start ();
  9478. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9479. $this->cacheFile ( $path );
  9480. die ();
  9481. }
  9482. }
  9483. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9484. }
  9485. function staffCollect() {
  9486. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9487. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9488. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9489. // $this->showCache($path);
  9490. Doo::loadModel ( 'statistics' );
  9491. $statistics = new statistics ();
  9492. Doo::loadModel ( "receiptDetail" );
  9493. $receiptDetail = new receiptDetail ();
  9494. Doo::loadModel ( 'L_category' );
  9495. $Lcategory = new L_category ();
  9496. Doo::loadModel ( 'accountItem' );
  9497. $accountItem = new accountItem ();
  9498. Doo::loadModel ( 'staff' );
  9499. $staff = new staff ();
  9500. Doo::loadModel ( 'itemStatistics' );
  9501. $itemStatistics = new itemStatistics ();
  9502. Doo::loadModel ( "receiptAuthorityManage" );
  9503. $receiptAuthorityManage = new receiptAuthorityManage ();
  9504. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9505. $cidList = array ();
  9506. foreach ( $imcStaff as $key => $value ) {
  9507. array_push ( $cidList, $value ['cid'] );
  9508. }
  9509. $cidString = implode ( ',', $cidList );
  9510. $naturecon='';
  9511. if ($nature=='ONJOB'){
  9512. $naturecon=' and (nature!=4 )';
  9513. }elseif($nature=='LEAVEJOB'){
  9514. $naturecon=' and (nature=4 )';
  9515. }else{
  9516. die ( 'illegal request--nature' );
  9517. }
  9518. // statistics html
  9519. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9520. if (empty ( $stList ))
  9521. $stList = array (
  9522. 'rePrice' => 0,
  9523. 'agPrice' => 0
  9524. );
  9525. $data ['stList'] = array (
  9526. 'rePrice' => $stList ['rePrice'],
  9527. 'agPrice' => $stList ['agPrice'],
  9528. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9529. );
  9530. // ---
  9531. $staffList = $staff->find ( array (
  9532. 'where' => 'username !="admin" '.$naturecon,
  9533. 'asArray' => true
  9534. ) );
  9535. $LcategoryList = $Lcategory->find ( array (
  9536. 'asArray' => true
  9537. ) ); // 'staff='.$this->staff[0]['sid']." and
  9538. $itemStatisticsList = $itemStatistics->find ( array (
  9539. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9540. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9541. 'groupby' => 'staff,Month(date)',
  9542. 'asArray' => true
  9543. ) );
  9544. $categoryList = $staff->find ( array (
  9545. 'select' => 'COUNT(*) as count,cid,category',
  9546. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9547. 'groupby' => 'cid',
  9548. 'asArray' => true
  9549. ) );
  9550. // print_r($itemStatisticsList);die;
  9551. // ceatre companyCollectHtml
  9552. foreach ( $categoryList as $vlu ) {
  9553. $count = $vlu ['count'] + 1;
  9554. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9555. $m1 = 0;
  9556. $m2 = 0;
  9557. $m3 = 0;
  9558. $m4 = 0;
  9559. $m5 = 0;
  9560. $m6 = 0;
  9561. $m7 = 0;
  9562. $m8 = 0;
  9563. $m9 = 0;
  9564. $m10 = 0;
  9565. $m11 = 0;
  9566. $m12 = 0;
  9567. $m13 = 0;
  9568. foreach ( $staffList as $value ) {
  9569. if ($vlu ['cid'] == $value ['cid']) {
  9570. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9571. $asum = 0;
  9572. for($i = 1; $i <= 12; $i ++) {
  9573. $falg = true;
  9574. foreach ( $itemStatisticsList as $v ) {
  9575. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9576. if ($v ['month'] == 1)
  9577. $m1 += $v ['price'];
  9578. if ($v ['month'] == 2)
  9579. $m2 += $v ['price'];
  9580. if ($v ['month'] == 3)
  9581. $m3 += $v ['price'];
  9582. if ($v ['month'] == 4)
  9583. $m4 += $v ['price'];
  9584. if ($v ['month'] == 5)
  9585. $m5 += $v ['price'];
  9586. if ($v ['month'] == 6)
  9587. $m6 += $v ['price'];
  9588. if ($v ['month'] == 7)
  9589. $m7 += $v ['price'];
  9590. if ($v ['month'] == 8)
  9591. $m8 += $v ['price'];
  9592. if ($v ['month'] == 9)
  9593. $m9 += $v ['price'];
  9594. if ($v ['month'] == 10)
  9595. $m10 += $v ['price'];
  9596. if ($v ['month'] == 11)
  9597. $m11 += $v ['price'];
  9598. if ($v ['month'] == 12)
  9599. $m12 += $v ['price'];
  9600. $asum += $v ['price'];
  9601. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9602. $falg = false;
  9603. break;
  9604. }
  9605. }
  9606. if ($falg)
  9607. $html .= '<td class="taR">-</td>';
  9608. }
  9609. $m13 += $asum;
  9610. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9611. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9612. 'html' => $html,
  9613. 'sid' => $value ['sid']
  9614. );
  9615. $html = "";
  9616. }
  9617. }
  9618. $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>
  9619. <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>
  9620. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9621. $collectHtml [$vlu ['cid']] = array (
  9622. 'html' => $hl,
  9623. 'sid' => ''
  9624. );
  9625. }
  9626. $data ['companyHtml'] = $collectHtml;
  9627. // total price html
  9628. $collectHtml = "";
  9629. $total = 0;
  9630. for($i = 1; $i <= 12; $i ++) {
  9631. $sumPrice = 0;
  9632. foreach ( $itemStatisticsList as $key => $value ) {
  9633. if ($value ['month'] == $i) {
  9634. $sumPrice += $value ['price'];
  9635. }
  9636. }
  9637. if ($sumPrice == 0)
  9638. $collectHtml .= '<td class="taR">-</td>';
  9639. else
  9640. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9641. $total += $sumPrice;
  9642. }
  9643. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9644. $data ['companyTotalHtml'] = $collectHtml;
  9645. $data ['total'] = $total;
  9646. $data ['nature'] =$nature;
  9647. $data ['year'] = $year;
  9648. $data ['memu'] = "receipt";
  9649. $data ['staff'] = $this->staff;
  9650. $data ['receiptMemu'] = 'companyCategoryCollect';
  9651. $data ['verifyId'] = $this->verifyId;
  9652. $data ['executeId'] = $this->executeId;
  9653. if ($year <= date ( "Y" )) {
  9654. Doo::loadModel ( 'receipt' );
  9655. $receipt = new receipt ();
  9656. $receiptList = $receipt->find ( array (
  9657. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9658. 'asArray' => true
  9659. ) );
  9660. if (empty ( $receiptList )) { // generated files
  9661. ob_start ();
  9662. $this->render ( "/admin/saeaStaffCollectB", $data );
  9663. $this->cacheFile ( $path );
  9664. die ();
  9665. }
  9666. }
  9667. $this->render ( "/admin/saeaStaffCollectB", $data );
  9668. }
  9669. function staffCollectBak() {
  9670. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9671. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9672. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9673. $this->showCache ( $path );
  9674. Doo::loadModel ( 'statistics' );
  9675. $statistics = new statistics ();
  9676. Doo::loadModel ( "receiptDetail" );
  9677. $receiptDetail = new receiptDetail ();
  9678. Doo::loadModel ( 'L_category' );
  9679. $Lcategory = new L_category ();
  9680. Doo::loadModel ( 'accountItem' );
  9681. $accountItem = new accountItem ();
  9682. Doo::loadModel ( 'staff' );
  9683. $staff = new staff ();
  9684. Doo::loadModel ( 'itemStatistics' );
  9685. $itemStatistics = new itemStatistics ();
  9686. $itemStatisticsList = $itemStatistics->find ( array (
  9687. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9688. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9689. 'groupby' => 'staff,itemCategory,Month(date)',
  9690. 'asArray' => true
  9691. ) );
  9692. $itemCategoryList = $itemStatistics->find ( array (
  9693. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9694. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9695. 'groupby' => 'cid,itemCategory,Month(date)',
  9696. 'asArray' => true
  9697. ) );
  9698. $LcategoryList = $Lcategory->find ( array (
  9699. 'asArray' => true
  9700. ) );
  9701. $staffList = $staff->find ( array (
  9702. 'asArray' => true
  9703. ) );
  9704. $htmlArray = array ();
  9705. foreach ( $LcategoryList as $value ) {
  9706. $htmlArray [$value ['title']] = array ();
  9707. foreach ( $staffList as $v ) {
  9708. if ($value ['cid'] == $v ['cid']) {
  9709. $html = "";
  9710. $falg = true;
  9711. $staffSumPrice = 0;
  9712. foreach ( $itemStatisticsList as $a ) {
  9713. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9714. if (empty ( $a ['price'] )) {
  9715. $html .= '<td class="taR">-</td>';
  9716. $falg = false;
  9717. break;
  9718. } else {
  9719. $staffSumPrice += $a ['price'];
  9720. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9721. $falg = false;
  9722. break;
  9723. }
  9724. }
  9725. }
  9726. if ($falg) {
  9727. $html .= '<td class="taR">-</td>';
  9728. $falg = true;
  9729. }
  9730. $falg = true;
  9731. foreach ( $itemStatisticsList as $a ) {
  9732. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9733. if (empty ( $a ['price'] )) {
  9734. $html .= '<td class="taR">-</td>';
  9735. $falg = false;
  9736. break;
  9737. } else {
  9738. $staffSumPrice += $a ['price'];
  9739. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9740. $falg = false;
  9741. break;
  9742. }
  9743. }
  9744. }
  9745. if ($falg) {
  9746. $html .= '<td class="taR">-</td>';
  9747. $falg = true;
  9748. }
  9749. $falg = true;
  9750. foreach ( $itemStatisticsList as $a ) {
  9751. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9752. if (empty ( $a ['price'] )) {
  9753. $html .= '<td class="taR">-</td>';
  9754. $falg = false;
  9755. break;
  9756. } else {
  9757. $staffSumPrice += $a ['price'];
  9758. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9759. $falg = false;
  9760. break;
  9761. }
  9762. }
  9763. }
  9764. if ($falg) {
  9765. $html .= '<td class="taR">-</td>';
  9766. $falg = true;
  9767. }
  9768. $falg = true;
  9769. foreach ( $itemStatisticsList as $a ) {
  9770. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9771. if (! empty ( $a ['price'] )) {
  9772. $staffSumPrice += $a ['price'];
  9773. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9774. $falg = false;
  9775. break;
  9776. } else {
  9777. $html .= '<td class="taR">-</td>';
  9778. $falg = false;
  9779. break;
  9780. }
  9781. }
  9782. }
  9783. if ($falg) {
  9784. $html .= '<td class="taR">-</td>';
  9785. $falg = true;
  9786. }
  9787. $falg = true;
  9788. foreach ( $itemStatisticsList as $a ) {
  9789. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9790. if (! empty ( $a ['price'] )) {
  9791. $staffSumPrice += $a ['price'];
  9792. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9793. $falg = false;
  9794. break;
  9795. } else {
  9796. $html .= '<td class="taR">-</td>';
  9797. $falg = false;
  9798. break;
  9799. }
  9800. }
  9801. }
  9802. if ($falg) {
  9803. $html .= '<td class="taR">-</td>';
  9804. $falg = true;
  9805. }
  9806. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9807. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9808. }
  9809. }
  9810. /* -- --- */
  9811. // 合计费用
  9812. $cateHtml = "";
  9813. $catePrice = 0;
  9814. $cateFalg = true;
  9815. foreach ( $itemCategoryList as $l ) {
  9816. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9817. if (empty ( $l ['price'] )) {
  9818. $cateHtml .= '<td class="colGreen taR">-</td>';
  9819. $cateFalg = false;
  9820. break;
  9821. } else {
  9822. $catePrice += $l ['price'];
  9823. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9824. $cateFalg = false;
  9825. break;
  9826. }
  9827. }
  9828. }
  9829. if ($cateFalg) {
  9830. $cateHtml .= '<td class="colGreen taR">-</td>';
  9831. $cateFalg = true;
  9832. }
  9833. $cateFalg = true;
  9834. foreach ( $itemCategoryList as $l ) {
  9835. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9836. if (empty ( $l ['price'] )) {
  9837. $cateHtml .= '<td class="colGreen taR">-</td>';
  9838. $cateFalg = false;
  9839. break;
  9840. } else {
  9841. $catePrice += $l ['price'];
  9842. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9843. $cateFalg = false;
  9844. break;
  9845. }
  9846. }
  9847. }
  9848. if ($cateFalg) {
  9849. $cateHtml .= '<td class="colGreen taR">-</td>';
  9850. $cateFalg = true;
  9851. }
  9852. $cateFalg = true;
  9853. foreach ( $itemCategoryList as $l ) {
  9854. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  9855. if (empty ( $l ['price'] )) {
  9856. $cateHtml .= '<td class="colGreen taR">-</td>';
  9857. $cateFalg = false;
  9858. break;
  9859. } else {
  9860. $catePrice += $l ['price'];
  9861. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9862. $cateFalg = false;
  9863. break;
  9864. }
  9865. }
  9866. }
  9867. if ($cateFalg) {
  9868. $cateHtml .= '<td class="colGreen taR">-</td>';
  9869. $cateFalg = true;
  9870. }
  9871. $cateFalg = true;
  9872. foreach ( $itemCategoryList as $l ) {
  9873. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  9874. if (empty ( $l ['price'] )) {
  9875. $cateHtml .= '<td class="colGreen taR">-</td>';
  9876. $cateFalg = false;
  9877. break;
  9878. } else {
  9879. $catePrice += $l ['price'];
  9880. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9881. $cateFalg = false;
  9882. break;
  9883. }
  9884. }
  9885. }
  9886. if ($cateFalg) {
  9887. $cateHtml .= '<td class="colGreen taR">-</td>';
  9888. $cateFalg = true;
  9889. }
  9890. $cateFalg = true;
  9891. foreach ( $itemCategoryList as $l ) {
  9892. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  9893. if (empty ( $l ['price'] )) {
  9894. $cateHtml .= '<td class="colGreen taR">-</td>';
  9895. $cateFalg = false;
  9896. break;
  9897. } else {
  9898. $catePrice += $l ['price'];
  9899. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9900. $cateFalg = false;
  9901. break;
  9902. }
  9903. }
  9904. }
  9905. if ($cateFalg) {
  9906. $cateHtml .= '<td class="colGreen taR">-</td>';
  9907. $cateFalg = true;
  9908. }
  9909. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9910. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9911. /* -- --- */
  9912. }
  9913. // print_r($htmlArray);die;
  9914. $data ['htmlArray'] = $htmlArray;
  9915. // statistics html
  9916. $stList = $statistics->getOne ( array (
  9917. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9918. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9919. 'groupby' => 'Month(date)',
  9920. 'asArray' => true
  9921. ) );
  9922. if (empty ( $stList ))
  9923. $stList = array (
  9924. 'rePrice' => 0,
  9925. 'agPrice' => 0
  9926. );
  9927. $data ['stList'] = array (
  9928. 'rePrice' => $stList ['rePrice'],
  9929. 'agPrice' => $stList ['agPrice'],
  9930. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9931. );
  9932. $monthHtml = "";
  9933. for($i = 1; $i <= 12; $i ++) {
  9934. if ($i == $month)
  9935. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9936. else
  9937. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9938. }
  9939. $data ['monthHtml'] = $monthHtml;
  9940. $data ['year'] = $year;
  9941. $data ['month'] = $month;
  9942. $data ['memu'] = "receipt";
  9943. $data ['staff'] = $this->staff;
  9944. $data ['receiptMemu'] = 'companyCategoryCollect';
  9945. $data ['verifyId'] = $this->verifyId;
  9946. $data ['executeId'] = $this->executeId;
  9947. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  9948. Doo::loadModel ( 'receipt' );
  9949. $receipt = new receipt ();
  9950. $receiptList = $receipt->find ( array (
  9951. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  9952. 'asArray' => true
  9953. ) );
  9954. if (empty ( $receiptList )) { // generated files
  9955. ob_start ();
  9956. $this->render ( "/admin/saeaStaffCollect", $data );
  9957. $this->cacheFile ( $path );
  9958. die ();
  9959. }
  9960. }
  9961. $this->render ( "/admin/saeaStaffCollect", $data );
  9962. }
  9963. /**
  9964. * 日常收支
  9965. */
  9966. function payments() {
  9967. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  9968. Doo::loadModel ( "execute" );
  9969. $execute = new execute ();
  9970. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  9971. die ( 'illegal request' );
  9972. }
  9973. Doo::loadModel ( "accountBook" );
  9974. $accountBook = new accountBook ();
  9975. Doo::loadModel ( "accountBookStatistics" );
  9976. $accountBookStatistics = new accountBookStatistics ();
  9977. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9978. $list = $accountBook->getAccountBookByLimit ( 10 );
  9979. $data ['date'] = date ( "Y-m-d" );
  9980. $data ['statisticsList'] = $statisticsList;
  9981. $data ['list'] = $list;
  9982. $data ['memu'] = "receipt";
  9983. $data ['staff'] = $this->staff;
  9984. $data ['receiptMemu'] = 'payments';
  9985. $data ['verifyId'] = $this->verifyId;
  9986. $data ['executeId'] = $this->executeId;
  9987. $this->render ( "/expenses/payments", $data );
  9988. }
  9989. function paymentsIncomeDo() {
  9990. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9991. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9992. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9993. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9994. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9995. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9996. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9997. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9998. Doo::loadClass ( 'XDeode' );
  9999. $XDeode = new XDeode ( 5 );
  10000. Doo::loadModel ( "accountBook" );
  10001. Doo::loadModel ( "accountBookStatistics" );
  10002. Doo::loadModel ( 'wasteBook' );
  10003. // 记录流水时银行的转换
  10004. $accountBank = '';
  10005. if ($receivedBank == '纵横广发') {
  10006. $accountBank = 'CGBDeposit';
  10007. } elseif ($receivedBank == '纵横工行') {
  10008. $accountBank = 'ICBCDeposit';
  10009. } elseif ($receivedBank == '华润银行') {
  10010. $accountBank = 'HUADeposit';
  10011. } elseif ($receivedBank == '个人广发') {
  10012. $accountBank = 'PersonalDeposit';
  10013. }
  10014. if (empty ( $accountBank ))
  10015. die ( 'illegal request' );
  10016. // 收入为理财时特殊处理
  10017. if ($accountType == 7 || $accountType == 9) {
  10018. if ($receivedBank == '个人广发') {
  10019. die ( '个人广发 illegal request' );
  10020. }
  10021. // 添加一条收入
  10022. $accountBook = new accountBook ();
  10023. $accountBook->accountType = 10;
  10024. $accountBook->accountMsg = $accountMsg;
  10025. $accountBook->receivedPrice = $receivedPrice;
  10026. $accountBook->receivedMsg = $receivedMsg;
  10027. $accountBook->receivedBank = $receivedBank;
  10028. $accountBook->receivedDate = $receivedDate;
  10029. $accountBook->remarks = $remarks;
  10030. $accountBook->expensesType = 1;
  10031. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10032. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10033. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10034. $inComeId = $accountBook->insert ();
  10035. // 收支汇总-添加一条收入日常汇总
  10036. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10037. $accountBookStatistics = new accountBookStatistics ();
  10038. $item = array (
  10039. 'date' => date ( "Y-m-d" ),
  10040. 'accountType' => $abDetail ['accountType'],
  10041. 'accountMsg' => $abDetail ['accountMsg'],
  10042. 'aid' => $abDetail ['aid'],
  10043. 'inComePrice' => $abDetail ['receivedPrice'],
  10044. 'expensesType' => $abDetail ['expensesType']
  10045. );
  10046. $accountBookStatistics->setAccountBookStatistics ( $item );
  10047. // 添加收入流水
  10048. $wasteBook = new wasteBook ();
  10049. $itemWaste = array (
  10050. 'accountPriceShow' => $receivedPrice,
  10051. 'accountPrice' => $receivedPrice,
  10052. 'expensesType' => 1,
  10053. 'accountType' => 6, // 流水类型
  10054. 'dataID' => $inComeId,
  10055. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10056. 'accountBank' => $accountBank,
  10057. 'category' => $this->staff [0] ['category'],
  10058. 'cid' => $this->staff [0] ['cid'],
  10059. 'name' => $this->staff [0] ['username'],
  10060. 'sid' => $this->staff [0] ['sid'],
  10061. 'inputDate' => date ( "Y-m-d H:i:s" )
  10062. );
  10063. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10064. // 添加一条理财支出
  10065. $accountBank = 'CGBDeposit';
  10066. $expenditureBank = '纵横广发';
  10067. $dailyExpenditureType = 4;
  10068. if ($accountType == 9) {
  10069. $accountBank = 'ICBCDeposit';
  10070. $expenditureBank = '纵横工行';
  10071. $dailyExpenditureType = 6;
  10072. }
  10073. $accountBook = new accountBook ();
  10074. $accountBook->expensesType = 2;
  10075. $accountBook->expenditureType = $dailyExpenditureType;
  10076. $accountBook->expenditureMsg = $accountMsg;
  10077. $accountBook->expenditurePrice = $receivedPrice;
  10078. $accountBook->expenditureBank = $expenditureBank;
  10079. $accountBook->expenditureDate = $receivedDate;
  10080. $accountBook->remarks = $remarks;
  10081. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10082. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10083. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10084. $id = $accountBook->insert ();
  10085. // 收支汇总-添加一条理财支出汇总
  10086. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10087. $accountBookStatistics = new accountBookStatistics ();
  10088. $item = array (
  10089. 'date' => date ( "Y-m-d" ),
  10090. 'accountType' => $abDetail ['accountType'],
  10091. 'accountMsg' => $abDetail ['accountMsg'],
  10092. 'aid' => $abDetail ['aid'],
  10093. 'financingPrice' => - $receivedPrice,
  10094. 'expensesType' => 3
  10095. );
  10096. $accountBookStatistics->setAccountBookStatistics ( $item );
  10097. // 添加一条支出理财流水
  10098. $accountTypeWaste = 5;
  10099. if ($accountMsg == '公司固定') {
  10100. $accountTypeWaste = 9;
  10101. } elseif ($accountMsg == '公司活期') {
  10102. $accountTypeWaste = 10;
  10103. } elseif ($accountMsg == '个人(GR)') {
  10104. $accountBank = 'PersonalDeposit';
  10105. }
  10106. $itemWaste = array (
  10107. 'expensesType' => 2,
  10108. 'accountType' => $accountTypeWaste,
  10109. 'accountPriceShow' => $receivedPrice,
  10110. 'accountPrice' => - $receivedPrice,
  10111. 'dataID' => $id,
  10112. 'dailyExpenditureType' => $dailyExpenditureType,
  10113. 'accountBank' => $accountBank,
  10114. 'category' => $this->staff [0] ['category'],
  10115. 'cid' => $this->staff [0] ['cid'],
  10116. 'name' => $this->staff [0] ['username'],
  10117. 'sid' => $this->staff [0] ['sid'],
  10118. 'inputDate' => date ( "Y-m-d H:i:s" )
  10119. );
  10120. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10121. } elseif ($accountType == 1) {
  10122. if ($receivedBank == '个人广发')
  10123. die ( 'illegal request' );
  10124. // 添加一条收入
  10125. $accountBook = new accountBook ();
  10126. $accountBook->accountType = $accountType;
  10127. $accountBook->accountMsg = $accountMsg;
  10128. $accountBook->receivedPrice = $receivedPrice;
  10129. $accountBook->receivedMsg = $receivedMsg;
  10130. $accountBook->receivedBank = $receivedBank;
  10131. $accountBook->receivedDate = $receivedDate;
  10132. $accountBook->remarks = $remarks;
  10133. $accountBook->expensesType = 1;
  10134. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10135. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10136. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10137. $id = $accountBook->insert ();
  10138. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10139. // 收支汇总-添加一条收入日常汇总
  10140. $accountBookStatistics = new accountBookStatistics ();
  10141. $item = array (
  10142. 'date' => date ( "Y-m-d" ),
  10143. 'accountType' => $abDetail ['accountType'],
  10144. 'accountMsg' => $abDetail ['accountMsg'],
  10145. 'aid' => $abDetail ['aid'],
  10146. 'expensesType' => $abDetail ['expensesType']
  10147. );
  10148. if ($abDetail ['accountType'] == 8) {
  10149. $item += array (
  10150. 'inComePrice' => $abDetail ['receivedPrice']
  10151. );
  10152. } else {
  10153. $item += array (
  10154. 'inComePrice' => $abDetail ['receivedPrice']
  10155. );
  10156. }
  10157. $accountBookStatistics->setAccountBookStatistics ( $item );
  10158. // 流水存储方向
  10159. $itemWaste = array (
  10160. 'accountType' => 6
  10161. ); // 流水类型
  10162. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10163. // }else
  10164. if ($accountMsg == '活期理财收益') {
  10165. $itemWaste = array (
  10166. 'accountType' => 10
  10167. ); // 流水类型
  10168. }
  10169. // 添加收入流水
  10170. $wasteBook = new wasteBook ();
  10171. $itemWaste += array (
  10172. 'accountPrice' => $receivedPrice,
  10173. 'accountPriceShow' => $receivedPrice,
  10174. 'expensesType' => 1,
  10175. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10176. 'dataID' => $id,
  10177. 'accountBank' => $accountBank,
  10178. 'category' => $this->staff [0] ['category'],
  10179. 'cid' => $this->staff [0] ['cid'],
  10180. 'name' => $this->staff [0] ['username'],
  10181. 'sid' => $this->staff [0] ['sid'],
  10182. 'inputDate' => date ( "Y-m-d H:i:s" )
  10183. );
  10184. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10185. } else { // 普通日常收入处理
  10186. // 添加一条收入
  10187. $accountBook = new accountBook ();
  10188. $accountBook->accountType = $accountType;
  10189. $accountBook->accountMsg = $accountMsg;
  10190. $accountBook->receivedPrice = $receivedPrice;
  10191. $accountBook->receivedMsg = $receivedMsg;
  10192. $accountBook->receivedBank = $receivedBank;
  10193. $accountBook->receivedDate = $receivedDate;
  10194. $accountBook->remarks = $remarks;
  10195. $accountBook->expensesType = 1;
  10196. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10197. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10198. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10199. $id = $accountBook->insert ();
  10200. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10201. // 收支汇总-添加一条收入日常汇总
  10202. $accountBookStatistics = new accountBookStatistics ();
  10203. $item = array (
  10204. 'date' => date ( "Y-m-d" ),
  10205. 'accountType' => $abDetail ['accountType'],
  10206. 'accountMsg' => $abDetail ['accountMsg'],
  10207. 'aid' => $abDetail ['aid'],
  10208. 'expensesType' => $abDetail ['expensesType']
  10209. );
  10210. if ($abDetail ['accountType'] == 8) {
  10211. $item += array (
  10212. 'inComePrice' => $abDetail ['receivedPrice']
  10213. );
  10214. } else {
  10215. $item += array (
  10216. 'inComePrice' => $abDetail ['receivedPrice']
  10217. );
  10218. }
  10219. $accountBookStatistics->setAccountBookStatistics ( $item );
  10220. // 添加收入流水
  10221. $itemWaste = array (
  10222. 'accountPrice' => $receivedPrice
  10223. );
  10224. if ($receivedBank == '个人广发') {
  10225. $itemWaste = array (
  10226. 'accountPrice' => - $receivedPrice
  10227. );
  10228. }
  10229. $wasteBook = new wasteBook ();
  10230. $itemWaste += array (
  10231. 'accountPriceShow' => $receivedPrice,
  10232. 'expensesType' => 1,
  10233. 'accountType' => 6, // 流水类型
  10234. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10235. 'dataID' => $id,
  10236. 'accountBank' => $accountBank,
  10237. 'category' => $this->staff [0] ['category'],
  10238. 'cid' => $this->staff [0] ['cid'],
  10239. 'name' => $this->staff [0] ['username'],
  10240. 'sid' => $this->staff [0] ['sid'],
  10241. 'inputDate' => date ( "Y-m-d H:i:s" )
  10242. );
  10243. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10244. }
  10245. }
  10246. return '/payments';
  10247. }
  10248. /**
  10249. * 添加收入
  10250. * @return string
  10251. */
  10252. function paymentsIncomeDo_() {
  10253. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10254. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10255. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10256. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10257. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10258. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10259. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10260. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10261. Doo::loadClass ( 'XDeode' );
  10262. $XDeode = new XDeode ( 5 );
  10263. Doo::loadModel ( "accountBook" );
  10264. $accountBook = new accountBook ();
  10265. $accountBank = '';
  10266. $accountTypeWaste = 6;
  10267. if ($receivedBank == '纵横广发') {
  10268. $accountBank = 'CGBDeposit';
  10269. } elseif ($receivedBank == '纵横工行') {
  10270. $accountBank = 'ICBCDeposit';
  10271. } elseif ($receivedBank == '华润银行') {
  10272. $accountBank = 'HUADeposit';
  10273. } elseif ($receivedBank == '个人广发') {
  10274. $accountBank = 'PersonalDeposit';
  10275. }
  10276. if (empty ( $accountBank ))
  10277. die ( 'illegal request' );
  10278. $dailyIncomeType = '';
  10279. $itemWaste = array (
  10280. 'accountPrice' => $receivedPrice,
  10281. 'expensesType' => 1
  10282. );
  10283. if ($receivedBank == '个人广发') {
  10284. $itemWaste = array (
  10285. 'accountPrice' => - $receivedPrice,
  10286. 'expensesType' => 1
  10287. );
  10288. }
  10289. if ($accountType == 4) {
  10290. $dailyIncomeType = 4;
  10291. } elseif ($accountType == 1) {
  10292. $dailyIncomeType = 1;
  10293. } elseif ($accountType == 2) {
  10294. $dailyIncomeType = 2;
  10295. } elseif ($accountType == 3) {
  10296. $dailyIncomeType = 3;
  10297. } elseif ($accountType == 5) {
  10298. $dailyIncomeType = 5;
  10299. } elseif ($accountType == 6) {
  10300. $dailyIncomeType = 6;
  10301. } elseif ($accountType == 7 || $accountType == 9) {
  10302. $dailyIncomeType = 7;
  10303. if ($accountMsg == '公司固定') {
  10304. $accountTypeWaste = 9;
  10305. } elseif ($accountMsg == '公司活期') {
  10306. $accountTypeWaste = 10;
  10307. } elseif ($accountMsg == '个人(GR)') {
  10308. $accountBank = 'PersonalDeposit';
  10309. }
  10310. $itemWaste = array (
  10311. 'accountPrice' => - $receivedPrice,
  10312. 'expensesType' => 2
  10313. );
  10314. } elseif ($accountType == 8) {
  10315. $dailyIncomeType = 8;
  10316. }
  10317. if (empty ( $dailyIncomeType ))
  10318. die ( 'illegal request' );
  10319. $accountBook->accountType = $accountType;
  10320. $accountBook->accountMsg = $accountMsg;
  10321. $accountBook->receivedPrice = $receivedPrice;
  10322. $accountBook->receivedMsg = $receivedMsg;
  10323. $accountBook->receivedBank = $receivedBank;
  10324. $accountBook->receivedDate = $receivedDate;
  10325. $accountBook->remarks = $remarks;
  10326. $accountBook->expensesType = 1;
  10327. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10328. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10329. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10330. $id = $accountBook->insert ();
  10331. //
  10332. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10333. // 收支汇总
  10334. Doo::loadModel ( "accountBookStatistics" );
  10335. $accountBookStatistics = new accountBookStatistics ();
  10336. $item = array (
  10337. 'date' => date ( "Y-m-d" ),
  10338. 'accountType' => $abDetail ['accountType'],
  10339. 'accountMsg' => $abDetail ['accountMsg'],
  10340. 'aid' => $abDetail ['aid']
  10341. );
  10342. if ($abDetail ['expensesType'] == 1) {
  10343. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10344. $item += array (
  10345. 'financingPrice' => - $receivedPrice,
  10346. 'expensesType' => 3
  10347. );
  10348. } else if ($abDetail ['accountType'] == 8) {
  10349. $item += array (
  10350. 'inComePrice' => - $abDetail ['receivedPrice'],
  10351. 'expensesType' => $abDetail ['expensesType']
  10352. );
  10353. } else {
  10354. $item += array (
  10355. 'inComePrice' => $abDetail ['receivedPrice'],
  10356. 'expensesType' => $abDetail ['expensesType']
  10357. );
  10358. }
  10359. }
  10360. $accountBookStatistics->setAccountBookStatistics ( $item );
  10361. // 为理财时需添加一条日常支出
  10362. if ($accountType == 7 || $accountType == 9) {
  10363. }
  10364. // 公司流水记录
  10365. Doo::loadModel ( 'wasteBook' );
  10366. $wasteBook = new wasteBook ();
  10367. // 银行
  10368. // if (empty($abDetail)){
  10369. $itemWaste += array (
  10370. 'accountPriceShow' => $receivedPrice,
  10371. 'dataID' => $id,
  10372. 'accountType' => $accountTypeWaste,
  10373. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10374. 'accountBank' => $accountBank,
  10375. 'category' => $this->staff [0] ['category'],
  10376. 'cid' => $this->staff [0] ['cid'],
  10377. 'name' => $this->staff [0] ['username'],
  10378. 'sid' => $this->staff [0] ['sid'],
  10379. 'inputDate' => date ( "Y-m-d H:i:s" )
  10380. );
  10381. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10382. // }
  10383. // 类型为理财7或者9 要添加一笔理财支出
  10384. if ($accountType == 7 || $accountType == 9) {
  10385. $accountBank = 'CGBDeposit';
  10386. $expenditureBank = '纵横广发';
  10387. $dailyExpenditureType = 4;
  10388. if ($accountType == 9) {
  10389. $accountBank = 'ICBCDeposit';
  10390. $expenditureBank = '纵横工行';
  10391. $dailyExpenditureType = 6;
  10392. }
  10393. // 添加一条支出
  10394. $accountBook = new accountBook ();
  10395. $accountBook->expenditureType = $dailyExpenditureType;
  10396. $accountBook->expenditureMsg = $accountMsg;
  10397. $accountBook->expenditurePrice = $receivedPrice;
  10398. $accountBook->expenditureBank = $expenditureBank;
  10399. $accountBook->expenditureDate = $receivedDate;
  10400. $accountBook->remarks = $remarks;
  10401. $accountBook->expensesType = 2;
  10402. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10403. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10404. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10405. $id = $accountBook->insert ();
  10406. // 添加一条收入流水
  10407. $itemWaste = array (
  10408. 'accountPriceShow' => $receivedPrice,
  10409. 'accountPrice' => $receivedPrice,
  10410. 'dataID' => $id,
  10411. 'expensesType' => 2,
  10412. 'accountType' => $accountTypeWaste,
  10413. 'dailyExpenditureType' => $dailyExpenditureType,
  10414. 'accountBank' => $accountBank,
  10415. 'category' => $this->staff [0] ['category'],
  10416. 'cid' => $this->staff [0] ['cid'],
  10417. 'name' => $this->staff [0] ['username'],
  10418. 'sid' => $this->staff [0] ['sid'],
  10419. 'inputDate' => date ( "Y-m-d H:i:s" )
  10420. );
  10421. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10422. }
  10423. }
  10424. return '/payments';
  10425. }
  10426. function paymentsExpenditureDo() {
  10427. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10428. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10429. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10430. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10431. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10432. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10433. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10434. // 理财支出特殊处理
  10435. Doo::loadModel ( "accountBook" );
  10436. Doo::loadModel ( "accountBookStatistics" );
  10437. Doo::loadModel ( 'wasteBook' );
  10438. $accountBank = '';
  10439. if ($expenditureBank == '纵横广发') {
  10440. $accountBank = 'CGBDeposit';
  10441. } elseif ($expenditureBank == '纵横工行') {
  10442. $accountBank = 'ICBCDeposit';
  10443. } elseif ($expenditureBank == '华润银行') {
  10444. $accountBank = 'HUADeposit';
  10445. } elseif ($expenditureBank == '个人广发') {
  10446. $accountBank = 'PersonalDeposit';
  10447. }
  10448. if (empty ( $accountBank ))
  10449. die ( 'illegal request' );
  10450. if ($expenditureType == 4 || $expenditureType == 6) {
  10451. if ($expenditureBank == '个人广发') {
  10452. die ( '个人广发 illegal request' );
  10453. }
  10454. // 添加一笔日常支出
  10455. $accountBook = new accountBook ();
  10456. $accountBook->expensesType = 2;
  10457. $accountBook->expenditureType = 7;
  10458. $accountBook->expenditureMsg = $expenditureMsg;
  10459. $accountBook->expenditurePrice = $expenditurePrice;
  10460. $accountBook->expenditureBank = $expenditureBank;
  10461. $accountBook->expenditureDate = $expenditureDate;
  10462. $accountBook->remarks = $remarks;
  10463. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10464. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10465. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10466. $expenditureId = $accountBook->insert ();
  10467. // 添加日常支出汇总
  10468. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10469. $accountBookStatistics = new accountBookStatistics ();
  10470. $item = array (
  10471. 'date' => date ( "Y-m-d" ),
  10472. 'expenditureType' => $abDetail ['expenditureType'],
  10473. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10474. 'aid' => $abDetail ['aid'],
  10475. 'payPrice' => $abDetail ['expenditurePrice'],
  10476. 'expensesType' => $abDetail ['expensesType']
  10477. );
  10478. $accountBookStatistics->setAccountBookStatistics ( $item );
  10479. // 公司日常支出流水
  10480. $wasteBook = new wasteBook ();
  10481. $itemWaste = array (
  10482. 'accountPrice' => - $expenditurePrice
  10483. );
  10484. if ($expenditureBank == '个人广发') {
  10485. $itemWaste = array (
  10486. 'accountPrice' => $expenditurePrice
  10487. );
  10488. }
  10489. $itemWaste += array (
  10490. 'expensesType' => 2,
  10491. 'accountType' => 5,
  10492. 'dailyExpenditureType' => $expenditureType,
  10493. 'accountPriceShow' => $expenditurePrice,
  10494. 'accountPrice' => - $expenditurePrice,
  10495. 'dataID' => $expenditureId,
  10496. 'accountBank' => $accountBank,
  10497. 'category' => $this->staff [0] ['category'],
  10498. 'cid' => $this->staff [0] ['cid'],
  10499. 'name' => $this->staff [0] ['username'],
  10500. 'sid' => $this->staff [0] ['sid'],
  10501. 'inputDate' => date ( "Y-m-d H:i:s" )
  10502. );
  10503. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10504. // 添加一笔理财收入
  10505. $accountBank = 'CGBDeposit';
  10506. $dailyIncomeType = 7;
  10507. $receivedBank = '纵横广发';
  10508. if ($expenditureType == 6) {
  10509. $accountBank = 'ICBCDeposit';
  10510. $receivedBank = '纵横工行';
  10511. $dailyIncomeType = 9;
  10512. }
  10513. $accountBook = new accountBook ();
  10514. $accountBook->expensesType = 1;
  10515. $accountBook->accountType = $dailyIncomeType;
  10516. $accountBook->accountMsg = $expenditureMsg;
  10517. $accountBook->receivedPrice = $expenditurePrice;
  10518. $accountBook->receivedBank = $receivedBank;
  10519. $accountBook->receivedDate = $expenditureDate;
  10520. $accountBook->remarks = $remarks;
  10521. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10522. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10523. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10524. $id = $accountBook->insert ();
  10525. // 添加日常理财收入汇总
  10526. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10527. $accountBookStatistics = new accountBookStatistics ();
  10528. $item = array (
  10529. 'date' => date ( "Y-m-d" ),
  10530. 'expenditureType' => $abDetail ['expenditureType'],
  10531. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10532. 'aid' => $abDetail ['aid'],
  10533. 'financingPrice' => $expenditurePrice,
  10534. 'expensesType' => 3
  10535. );
  10536. $accountBookStatistics->setAccountBookStatistics ( $item );
  10537. // 添加一笔收入流水
  10538. if ($expenditureMsg == '公司固定') {
  10539. $accountTypeWaste = 9;
  10540. } elseif ($expenditureMsg == '公司活期') {
  10541. $accountTypeWaste = 10;
  10542. } elseif ($expenditureMsg == '个人(GR)') {
  10543. $accountBank = 'PersonalDeposit';
  10544. }
  10545. $itemWaste = array (
  10546. 'expensesType' => 1,
  10547. 'accountType' => $accountTypeWaste,
  10548. 'accountPriceShow' => $expenditurePrice,
  10549. 'accountPrice' => $expenditurePrice,
  10550. 'dataID' => $id,
  10551. 'dailyIncomeType' => $dailyIncomeType,
  10552. 'accountBank' => $accountBank,
  10553. 'category' => $this->staff [0] ['category'],
  10554. 'cid' => $this->staff [0] ['cid'],
  10555. 'name' => $this->staff [0] ['username'],
  10556. 'sid' => $this->staff [0] ['sid'],
  10557. 'inputDate' => date ( "Y-m-d H:i:s" )
  10558. );
  10559. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10560. } else {
  10561. // 添加一笔日常支出
  10562. $accountBook = new accountBook ();
  10563. $accountBook->expensesType = 2;
  10564. $accountBook->expenditureType = $expenditureType;
  10565. $accountBook->expenditureMsg = $expenditureMsg;
  10566. $accountBook->expenditurePrice = $expenditurePrice;
  10567. $accountBook->expenditureBank = $expenditureBank;
  10568. $accountBook->expenditureDate = $expenditureDate;
  10569. $accountBook->remarks = $remarks;
  10570. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10571. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10572. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10573. $id = $accountBook->insert ();
  10574. // 添加日常支出汇总
  10575. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10576. $accountBookStatistics = new accountBookStatistics ();
  10577. $item = array (
  10578. 'date' => date ( "Y-m-d" ),
  10579. 'expenditureType' => $abDetail ['expenditureType'],
  10580. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10581. 'aid' => $abDetail ['aid'],
  10582. 'expensesType' => $abDetail ['expensesType']
  10583. );
  10584. if ($expenditureType == 5) {
  10585. $item += array (
  10586. 'payPrice' => - $abDetail ['expenditurePrice']
  10587. );
  10588. } else {
  10589. $item += array (
  10590. 'payPrice' => $abDetail ['expenditurePrice']
  10591. );
  10592. }
  10593. $accountBookStatistics->setAccountBookStatistics ( $item );
  10594. // 公司日常支出流水
  10595. $wasteBook = new wasteBook ();
  10596. $itemWaste = array (
  10597. 'accountPrice' => - $expenditurePrice
  10598. );
  10599. if ($expenditureBank == '个人广发') {
  10600. $itemWaste = array (
  10601. 'accountPrice' => $expenditurePrice
  10602. );
  10603. }
  10604. $itemWaste += array (
  10605. 'expensesType' => 2,
  10606. 'accountType' => 5,
  10607. 'accountPriceShow' => $expenditurePrice,
  10608. 'dataID' => $id,
  10609. 'dailyExpenditureType' => $expenditureType,
  10610. 'accountBank' => $accountBank,
  10611. 'category' => $this->staff [0] ['category'],
  10612. 'cid' => $this->staff [0] ['cid'],
  10613. 'name' => $this->staff [0] ['username'],
  10614. 'sid' => $this->staff [0] ['sid'],
  10615. 'inputDate' => date ( "Y-m-d H:i:s" )
  10616. );
  10617. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10618. }
  10619. }
  10620. return '/payments';
  10621. }
  10622. /**
  10623. * 添加支出
  10624. */
  10625. function paymentsExpenditureDo_() {
  10626. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10627. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10628. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10629. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10630. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10631. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10632. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10633. $dailyExpenditureType = '';
  10634. $accountTypeWaste = 5;
  10635. $accountBank = '';
  10636. if ($expenditureBank == '纵横广发') {
  10637. $accountBank = 'CGBDeposit';
  10638. } elseif ($expenditureBank == '纵横工行') {
  10639. $accountBank = 'ICBCDeposit';
  10640. } elseif ($expenditureBank == '华润银行') {
  10641. $accountBank = 'HUADeposit';
  10642. } elseif ($expenditureBank == '个人广发') {
  10643. $accountBank = 'PersonalDeposit';
  10644. }
  10645. if (empty ( $accountBank ))
  10646. die ( 'illegal request' );
  10647. $itemWaste = array (
  10648. 'accountPrice' => - $expenditurePrice
  10649. );
  10650. if ($expenditureBank == '个人广发') {
  10651. $itemWaste = array (
  10652. 'accountPrice' => $expenditurePrice
  10653. );
  10654. }
  10655. if ($expenditureType == 4 || $expenditureType == 6) {
  10656. $dailyExpenditureType = 4;
  10657. if ($expenditureMsg == '公司固定') {
  10658. $accountTypeWaste = 9;
  10659. } elseif ($expenditureMsg == '公司活期') {
  10660. $accountTypeWaste = 10;
  10661. } elseif ($expenditureMsg == '个人(GR)') {
  10662. $accountBank = 'PersonalDeposit';
  10663. }
  10664. $itemWaste = array (
  10665. 'accountPrice' => $expenditurePrice
  10666. );
  10667. } elseif ($expenditureType == 1) {
  10668. $dailyExpenditureType = 1;
  10669. } elseif ($expenditureType == 2) {
  10670. $dailyExpenditureType = 2;
  10671. } elseif ($expenditureType == 3) {
  10672. $dailyExpenditureType = 3;
  10673. } elseif ($expenditureType == 5) {
  10674. $dailyExpenditureType = 5;
  10675. }
  10676. if (empty ( $dailyExpenditureType ))
  10677. die ( 'illegal request' );
  10678. Doo::loadModel ( "accountBook" );
  10679. $accountBook = new accountBook ();
  10680. $accountBook->expenditureType = $expenditureType;
  10681. $accountBook->expenditureMsg = $expenditureMsg;
  10682. $accountBook->expenditurePrice = $expenditurePrice;
  10683. $accountBook->expenditureBank = $expenditureBank;
  10684. $accountBook->expenditureDate = $expenditureDate;
  10685. $accountBook->remarks = $remarks;
  10686. $accountBook->expensesType = 2;
  10687. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10688. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10689. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10690. $id = $accountBook->insert ();
  10691. //
  10692. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10693. Doo::loadModel ( "accountBookStatistics" );
  10694. $accountBookStatistics = new accountBookStatistics ();
  10695. $item = array (
  10696. 'date' => date ( "Y-m-d" ),
  10697. 'expenditureType' => $abDetail ['expenditureType'],
  10698. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10699. 'aid' => $abDetail ['aid']
  10700. );
  10701. if ($abDetail ['expensesType'] == 2) {
  10702. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10703. $item += array (
  10704. 'financingPrice' => $expenditurePrice,
  10705. 'expensesType' => 3
  10706. );
  10707. } elseif ($abDetail ['expenditureType'] == 5) {
  10708. $item += array (
  10709. 'payPrice' => $abDetail ['expenditurePrice'],
  10710. 'expensesType' => $abDetail ['expensesType']
  10711. );
  10712. } else {
  10713. $item += array (
  10714. 'payPrice' => $abDetail ['expenditurePrice'],
  10715. 'expensesType' => $abDetail ['expensesType']
  10716. );
  10717. }
  10718. }
  10719. $accountBookStatistics->setAccountBookStatistics ( $item );
  10720. // 公司流水记录
  10721. Doo::loadModel ( 'wasteBook' );
  10722. $wasteBook = new wasteBook ();
  10723. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10724. // 银行
  10725. if (empty ( $abDetail )) {
  10726. $itemWaste += array (
  10727. 'accountPriceShow' => $expenditurePrice,
  10728. 'dataID' => $id,
  10729. 'expensesType' => 2,
  10730. 'accountType' => $accountTypeWaste,
  10731. 'dailyExpenditureType' => $expenditureType,
  10732. 'accountBank' => $accountBank,
  10733. 'category' => $this->staff [0] ['category'],
  10734. 'cid' => $this->staff [0] ['cid'],
  10735. 'name' => $this->staff [0] ['username'],
  10736. 'sid' => $this->staff [0] ['sid'],
  10737. 'inputDate' => date ( "Y-m-d H:i:s" )
  10738. );
  10739. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10740. }
  10741. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10742. if ($expenditureType == 4 || $expenditureType == 6) {
  10743. $accountBank = 'CGBDeposit';
  10744. $dailyIncomeType = 7;
  10745. $receivedBank = '纵横广发';
  10746. if ($expenditureType == 6) {
  10747. $accountBank = 'ICBCDeposit';
  10748. $receivedBank = '纵横工行';
  10749. $dailyIncomeType = 9;
  10750. }
  10751. // 添加一笔收入
  10752. $accountBook = new accountBook ();
  10753. $accountBook->accountType = $dailyIncomeType;
  10754. $accountBook->accountMsg = $expenditureMsg;
  10755. $accountBook->receivedPrice = $expenditurePrice;
  10756. $accountBook->receivedBank = $receivedBank;
  10757. $accountBook->receivedDate = $expenditureDate;
  10758. $accountBook->remarks = $remarks;
  10759. $accountBook->expensesType = 1;
  10760. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10761. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10762. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10763. $id = $accountBook->insert ();
  10764. // 添加一笔收入流水
  10765. $itemWaste = array (
  10766. 'accountPriceShow' => $expenditurePrice,
  10767. 'accountPrice' => - $expenditurePrice,
  10768. 'dataID' => $id,
  10769. 'expensesType' => 1,
  10770. 'accountType' => $accountTypeWaste,
  10771. 'dailyIncomeType' => $dailyIncomeType,
  10772. 'accountBank' => $accountBank,
  10773. 'category' => $this->staff [0] ['category'],
  10774. 'cid' => $this->staff [0] ['cid'],
  10775. 'name' => $this->staff [0] ['username'],
  10776. 'sid' => $this->staff [0] ['sid'],
  10777. 'inputDate' => date ( "Y-m-d H:i:s" )
  10778. );
  10779. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10780. }
  10781. }
  10782. return '/payments';
  10783. }
  10784. /**
  10785. * 所有收支
  10786. */
  10787. function paymentsAchieve() {
  10788. $page_size = 12;
  10789. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10790. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10791. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10792. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10793. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10794. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10795. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10796. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10797. Doo::loadModel ( "accountBookStatistics" );
  10798. $accountBookStatistics = new accountBookStatistics ();
  10799. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10800. $data ['statisticsList'] = $statisticsList;
  10801. Doo::loadModel ( "accountBook" );
  10802. $accountBook = new accountBook ();
  10803. $con = '';
  10804. if ($expensesType == 'INCOME')
  10805. $con = ' and expensesType=1 ';
  10806. elseif ($expensesType == 'PAY')
  10807. $con = ' and expensesType=2 ';
  10808. $dateArr = explode ( ':', $date );
  10809. $D1 = $dateString = '';
  10810. $D2 = '';
  10811. if (! empty ( $date )) {
  10812. $D1 = $dateArr [0];
  10813. if (isset ( $dateArr [1] ))
  10814. $D2 = $dateArr [1];
  10815. else
  10816. $D2 = '';
  10817. $dateString = $D1 . " : " . $D2;
  10818. }
  10819. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10820. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10821. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10822. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10823. if (! empty ( $price ))
  10824. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10825. if ($submitType == 1) {
  10826. if ($accountType != '') {
  10827. $expenditureType = '';
  10828. $con .= ' and accountType=' . $accountType;
  10829. if (! empty ( $accountMsg ))
  10830. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10831. }
  10832. } elseif ($submitType == 2) {
  10833. if ($expenditureType != '') {
  10834. $accountType = $accountMsg = '';
  10835. $con .= ' and expenditureType=' . $expenditureType;
  10836. }
  10837. } else {
  10838. $accountType = $accountMsg = $expenditureType = '';
  10839. }
  10840. $sql = "" . $con;
  10841. $action = "paymentsAchieve";
  10842. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10843. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10844. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10845. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10846. $data ['expenditureType'] = $expenditureType;
  10847. $data ['accountMsg'] = $accountMsg;
  10848. $data ['accountType'] = $accountType;
  10849. $data ['inputDate'] = $date;
  10850. $data ['price'] = $price;
  10851. $data ['expensesType'] = $expensesType;
  10852. $data ['page'] = $pageinfo;
  10853. $data ['list'] = $list;
  10854. $data ['memu'] = "receipt";
  10855. $data ['staff'] = $this->staff;
  10856. $data ['receiptMemu'] = 'payments';
  10857. $data ['verifyId'] = $this->verifyId;
  10858. $data ['executeId'] = $this->executeId;
  10859. $this->render ( "/expenses/paymentsAchieve", $data );
  10860. }
  10861. function paymentsIncomeUpdateDo() {
  10862. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10863. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10864. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10865. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10866. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10867. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10868. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10869. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10870. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10871. Doo::loadClass ( 'XDeode' );
  10872. $XDeode = new XDeode ( 5 );
  10873. $aid = $XDeode->decode ( $aidKey );
  10874. Doo::loadModel ( "accountBook" );
  10875. $accountBook = new accountBook ();
  10876. //
  10877. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10878. $price = $receivedPrice - $abDetail [inComePrice];
  10879. Doo::loadModel ( "accountBookStatistics" );
  10880. $accountBookStatistics = new accountBookStatistics ();
  10881. if ($abDetail ['accountType'] == 7) {
  10882. $item += array (
  10883. 'date' => date ( "Y-m-d" ),
  10884. 'financingPrice' => - $price,
  10885. 'expensesType' => 3,
  10886. 'aid' => $abDetail ['aid']
  10887. );
  10888. } elseif ($abDetail ['accountType'] == 8) {
  10889. $item += array (
  10890. 'date' => date ( "Y-m-d" ),
  10891. 'expensesType' => $abDetail ['expensesType'],
  10892. 'inComePrice' => - $price,
  10893. 'aid' => $abDetail ['aid']
  10894. );
  10895. } else {
  10896. $item = array (
  10897. 'date' => date ( "Y-m-d" ),
  10898. 'expensesType' => $abDetail ['expensesType'],
  10899. 'inComePrice' => $price,
  10900. 'aid' => $abDetail ['aid']
  10901. );
  10902. }
  10903. $accountBookStatistics->setAccountBookStatistics ( $item );
  10904. $accountBook->accountType = $accountType;
  10905. $accountBook->accountMsg = $accountMsg;
  10906. $accountBook->receivedPrice = $receivedPrice;
  10907. $accountBook->receivedMsg = $receivedMsg;
  10908. $accountBook->receivedBank = $receivedBank;
  10909. $accountBook->receivedDate = $receivedDate;
  10910. $accountBook->remarks = $remarks;
  10911. $accountBook->aid = $aid;
  10912. $accountBook->update ();
  10913. }
  10914. return '/paymentsAchieve';
  10915. }
  10916. function paymentsExpenditureEdiDo() {
  10917. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10918. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10919. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10920. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10921. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10922. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10923. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10924. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10925. Doo::loadClass ( 'XDeode' );
  10926. $XDeode = new XDeode ( 5 );
  10927. $aid = $XDeode->decode ( $aidKey );
  10928. Doo::loadModel ( "accountBook" );
  10929. $accountBook = new accountBook ();
  10930. // 汇总信息
  10931. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10932. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10933. Doo::loadModel ( "accountBookStatistics" );
  10934. $accountBookStatistics = new accountBookStatistics ();
  10935. if ($abDetail ['expenditureType'] == 4) {
  10936. $item += array (
  10937. 'date' => date ( "Y-m-d" ),
  10938. 'financingPrice' => $price,
  10939. 'expensesType' => 3,
  10940. 'aid' => $abDetail ['aid']
  10941. );
  10942. } elseif ($abDetail ['expenditureType'] == 5) {
  10943. $item += array (
  10944. 'date' => date ( "Y-m-d" ),
  10945. 'expensesType' => $abDetail ['expensesType'],
  10946. 'payPrice' => $price,
  10947. 'aid' => $abDetail ['aid']
  10948. );
  10949. } else {
  10950. $item = array (
  10951. 'date' => date ( "Y-m-d" ),
  10952. 'expensesType' => $abDetail ['expensesType'],
  10953. 'payPrice' => $price,
  10954. 'aid' => $abDetail ['aid']
  10955. );
  10956. }
  10957. $accountBookStatistics->setAccountBookStatistics ( $item );
  10958. //
  10959. $accountBook->expenditureType = $expenditureType;
  10960. $accountBook->expenditureMsg = $expenditureMsg;
  10961. $accountBook->expenditurePrice = $expenditurePrice;
  10962. $accountBook->expenditureBank = $expenditureBank;
  10963. $accountBook->remarks = $remarks;
  10964. $accountBook->expenditureDate = $expenditureDate;
  10965. $accountBook->aid = $aid;
  10966. $id = $accountBook->update ();
  10967. }
  10968. return '/paymentsAchieve';
  10969. }
  10970. function paymentsDelDo() {
  10971. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10972. if (! empty ( $aidKey )) {
  10973. Doo::loadClass ( 'XDeode' );
  10974. $XDeode = new XDeode ( 5 );
  10975. $aid = $XDeode->decode ( $aidKey );
  10976. Doo::loadModel ( "accountBook" );
  10977. $accountBook = new accountBook ();
  10978. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10979. if (empty ( $abDetail ))
  10980. die ( 'illegal request' );
  10981. // 删除收支
  10982. Doo::loadModel ( "accountBookStatistics" );
  10983. $accountBookStatistics = new accountBookStatistics ();
  10984. $item = array (
  10985. 'date' => date ( "Y-m-d" ),
  10986. 'aid' => $abDetail ['aid']
  10987. );
  10988. $accountType = '';
  10989. if ($abDetail ['expensesType'] == 1) {
  10990. $accountType = 6;
  10991. if ($abDetail ['accountType'] != 7) {
  10992. $item += array (
  10993. 'expensesType' => $abDetail ['expensesType'],
  10994. 'inComePrice' => - $abDetail ['receivedPrice']
  10995. );
  10996. } else {
  10997. $item += array (
  10998. 'financingPrice' => $abDetail ['receivedPrice'],
  10999. 'expensesType' => 3
  11000. );
  11001. }
  11002. } elseif ($abDetail ['expensesType'] == 2) {
  11003. $accountType = 5;
  11004. if ($abDetail ['accountType'] != 7) {
  11005. $item += array (
  11006. 'expensesType' => $abDetail ['expensesType'],
  11007. 'payPrice' => - $abDetail ['expenditurePrice']
  11008. );
  11009. } else {
  11010. $item += array (
  11011. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11012. 'expensesType' => 3
  11013. );
  11014. }
  11015. }
  11016. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11017. if ($abDetail ['expenditureMsg'] == '公司固定')
  11018. $accountType = 9;
  11019. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11020. $accountType = 10;
  11021. }
  11022. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11023. if ($abDetail ['accountMsg'] == '公司固定')
  11024. $accountType = 9;
  11025. elseif ($abDetail ['accountMsg'] == '公司活期')
  11026. $accountType = 10;
  11027. }
  11028. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11029. $accountType = 10;
  11030. }
  11031. $accountBookStatistics->setAccountBookStatistics ( $item );
  11032. $accountBook->delete ( array (
  11033. 'where' => 'aid=' . $aid,
  11034. 'limit' => 1
  11035. ) );
  11036. // 删除收入流水
  11037. if (! empty ( $accountType )) {
  11038. Doo::loadModel ( 'wasteBook' );
  11039. $wasteBook = new wasteBook ();
  11040. $wasteBook->delete ( array (
  11041. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11042. 'limit' => 1
  11043. ) );
  11044. }
  11045. }
  11046. return '/paymentsAchieve';
  11047. }
  11048. function paymentsCollect() {
  11049. Doo::loadModel ( "execute" );
  11050. $execute = new execute ();
  11051. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11052. die ( 'illegal request' );
  11053. }
  11054. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11055. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11056. Doo::loadModel ( "accountBookStatistics" );
  11057. $accountBookStatistics = new accountBookStatistics ();
  11058. Doo::loadClass ( 'receipt.func' );
  11059. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11060. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11061. $data ['html'] = $html ['html'];
  11062. $data ['inSum'] = $html ['sum'];
  11063. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11064. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11065. $data ['payHtml'] = $html ['html'];
  11066. $data ['paySum'] = $html ['sum'];
  11067. // 余额统计
  11068. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11069. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11070. include './protected/config/wasteBook.conf.php';
  11071. Doo::loadModel ( 'wasteBook' );
  11072. $wasteBook = new wasteBook ();
  11073. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11074. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11075. // 获得年份之前所有金额
  11076. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11077. // print_r($detail);
  11078. // $waste['total'];
  11079. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11080. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11081. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11082. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11083. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11084. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11085. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11086. if (date ( 'Y' ) > $year) {
  11087. $limitMonth = 12;
  11088. }
  11089. for($i = 1; $i <= 12; $i ++) {
  11090. $inComeA = $payB = 0;
  11091. $falg = true;
  11092. foreach ( $inComePay as $key => $value ) {
  11093. if ($value ['month'] == $i) {
  11094. $falg = false;
  11095. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11096. $inSum += $value ['accountPrice'];
  11097. $showInSum += $value ['accountPriceShow'];
  11098. $inComeA = $value ['accountPrice'];
  11099. break;
  11100. }
  11101. }
  11102. if ($falg)
  11103. $inComeHtml .= '<td class="taR">-</td>';
  11104. $payFalg = true;
  11105. foreach ( $pay as $key => $value ) {
  11106. if ($value ['month'] == $i) {
  11107. $payFalg = false;
  11108. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11109. $paySum += $value ['accountPrice'];
  11110. $showPaySum += $value ['accountPriceShow'];
  11111. $payB = $value ['accountPrice'];
  11112. break;
  11113. }
  11114. }
  11115. if ($payFalg)
  11116. $payHtml .= '<td class="taR">-</td>';
  11117. if (empty ( $balanceC ) || $limitMonth < $i)
  11118. $lastBalanceHtml .= '<td class="taR">-</td>';
  11119. else
  11120. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11121. $balanceC = $balanceC + $inComeA + $payB;
  11122. $balanceSum += $balanceC;
  11123. if (empty ( $balanceC ) || $limitMonth < $i)
  11124. $BalanceHtml .= '<td class="taR">-</td>';
  11125. else
  11126. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11127. // 余额统计
  11128. }
  11129. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11130. $data ['inComeHtml'] = $inComeHtml;
  11131. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11132. $data ['payBalanceHtml'] = $payHtml;
  11133. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11134. $data ['BalanceHtml'] = $BalanceHtml;
  11135. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11136. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11137. $mothHtml = "";
  11138. for($i = 1; $i <= 12; $i ++) {
  11139. if ($moth == $i)
  11140. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11141. else
  11142. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11143. }
  11144. $data ['mothHtml'] = $mothHtml;
  11145. $dateHtml = "";
  11146. $now = date ( "Y" );
  11147. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11148. if ($YEARD <= $now) {
  11149. $dateHtml .= '<option ';
  11150. if ($year == $YEARD) {
  11151. $dateHtml .= 'selected ';
  11152. }
  11153. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11154. }
  11155. }
  11156. $data ['dateHtml'] = $dateHtml;
  11157. $data ['year'] = $year;
  11158. $data ['memu'] = "receipt";
  11159. $data ['staff'] = $this->staff;
  11160. $data ['receiptMemu'] = 'paymentsCollect';
  11161. $data ['verifyId'] = $this->verifyId;
  11162. $data ['executeId'] = $this->executeId;
  11163. $this->render ( "/expenses/paymentsCollect", $data );
  11164. }
  11165. function paymentsCollectDay() {
  11166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11167. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11168. if (empty ( $moth ))
  11169. return 'paymentsCollect';
  11170. Doo::loadModel ( "accountBookStatistics" );
  11171. $accountBookStatistics = new accountBookStatistics ();
  11172. $i = 2;
  11173. $y = 2013;
  11174. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11175. Doo::loadClass ( 'receipt.func' );
  11176. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11177. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11178. $data ['html'] = $html ['html'];
  11179. $data ['inSum'] = $html ['sum'];
  11180. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11181. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11182. $data ['payHtml'] = $html ['html'];
  11183. $data ['paySum'] = $html ['sum'];
  11184. $mothHtml = "";
  11185. for($i = 1; $i <= 12; $i ++) {
  11186. if ($moth == $i)
  11187. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11188. else
  11189. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11190. }
  11191. $data ['mothHtml'] = $mothHtml;
  11192. $data ['year'] = $year;
  11193. // 余额
  11194. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11195. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11196. include './protected/config/wasteBook.conf.php';
  11197. Doo::loadModel ( 'wasteBook' );
  11198. $wasteBook = new wasteBook ();
  11199. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11200. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11201. // 获得年份之前所有金额
  11202. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11203. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11204. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11205. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11206. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11207. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11208. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11209. // $balanceC = 0;
  11210. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11211. $limitDay = date ( 'd' );
  11212. $monthLK = ( int ) date ( 'm' );
  11213. if (date ( 'Y' ) > $year) {
  11214. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11215. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11216. $limitDay = 0;
  11217. }
  11218. for($i = 1; $i <= $day; $i ++) {
  11219. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11220. $inComeA = $payB = 0;
  11221. $falg = true;
  11222. foreach ( $inComePay as $key => $value ) {
  11223. if ($value ['day'] == $i) {
  11224. $falg = false;
  11225. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11226. $inSum += $value ['accountPrice'];
  11227. $showInSum += $value ['accountPriceShow'];
  11228. $inComeA = $value ['accountPrice'];
  11229. break;
  11230. }
  11231. }
  11232. if ($falg)
  11233. $inComeHtml .= '<td class="taR">-</td>';
  11234. $payFalg = true;
  11235. foreach ( $pay as $key => $value ) {
  11236. if ($value ['day'] == $i) {
  11237. $payFalg = false;
  11238. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11239. $paySum += $value ['accountPrice'];
  11240. $showPaySum += $value ['accountPriceShow'];
  11241. $payB = $value ['accountPrice'];
  11242. break;
  11243. }
  11244. }
  11245. if ($payFalg)
  11246. $payHtml .= '<td class="taR">-</td>';
  11247. if (empty ( $balanceC ) || $limitDay < $i)
  11248. $lastBalanceHtml .= '<td class="taR">-</td>';
  11249. else
  11250. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11251. $balanceC = $balanceC + $inComeA + $payB;
  11252. $balanceSum += $balanceC;
  11253. if (empty ( $balanceC ) || $limitDay < $i)
  11254. $BalanceHtml .= '<td class="taR">-</td>';
  11255. else
  11256. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11257. }
  11258. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11259. $data ['inComeHtml'] = $inComeHtml;
  11260. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11261. $data ['payBalanceHtml'] = $payHtml;
  11262. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11263. $data ['BalanceHtml'] = $BalanceHtml;
  11264. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11265. $data ['dayHtml'] = $dayHtml;
  11266. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11267. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11268. $dateHtml = "";
  11269. $now = date ( "Y" );
  11270. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11271. if ($YEARD <= $now) {
  11272. $dateHtml .= '<option ';
  11273. if ($year == $YEARD) {
  11274. $dateHtml .= 'selected ';
  11275. }
  11276. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11277. }
  11278. }
  11279. $data ['dateHtml'] = $dateHtml;
  11280. $data ['memu'] = "receipt";
  11281. $data ['staff'] = $this->staff;
  11282. $data ['receiptMemu'] = 'paymentsCollect';
  11283. $data ['verifyId'] = $this->verifyId;
  11284. $data ['executeId'] = $this->executeId;
  11285. $this->render ( "/expenses/paymentsCollectDay", $data );
  11286. }
  11287. // 公司流水
  11288. function wasteBook() {
  11289. Doo::loadModel ( "execute" );
  11290. $execute = new execute ();
  11291. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11292. die ( 'illegal request' );
  11293. }
  11294. include './protected/config/wasteBook.conf.php';
  11295. Doo::loadModel ( 'wasteBook' );
  11296. $wasteBook = new wasteBook ();
  11297. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11298. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11299. $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'];
  11300. // print_r($waste);
  11301. $data ['waste'] = $waste;
  11302. $data ['total'] = $total;
  11303. // 月流水数据结构
  11304. $monthStatistics = array ();
  11305. $incomeMothStatistics = array ();
  11306. $expenditureMothStatistics = array ();
  11307. for($i = 1; $i <= 12; $i ++) {
  11308. $month = date ( 'Y' ) . '-' . $i;
  11309. if ($i < 10)
  11310. $month = date ( 'Y' ) . '-0' . $i;
  11311. array_push ( $monthStatistics, $month );
  11312. }
  11313. foreach ( $monthStatistics as $value ) {
  11314. $falg = true;
  11315. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11316. if ($value == $v ['inputDate']) {
  11317. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11318. $falg = false;
  11319. }
  11320. }
  11321. if ($falg) {
  11322. array_push ( $incomeMothStatistics, '' );
  11323. }
  11324. $falgEx = true;
  11325. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11326. if ($value == $v ['inputDate']) {
  11327. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11328. $falg = false;
  11329. }
  11330. }
  11331. if ($falgEx) {
  11332. array_push ( $expenditureMothStatistics, '' );
  11333. }
  11334. }
  11335. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11336. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11337. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11338. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11339. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11340. // print_r($incomeList);
  11341. $data ['expenditureList'] = $expenditureList;
  11342. $data ['incomeList'] = $incomeList;
  11343. $data ['memu'] = "receipt";
  11344. $data ['staff'] = $this->staff;
  11345. $data ['receiptMemu'] = 'wasteBook';
  11346. $data ['verifyId'] = $this->verifyId;
  11347. $data ['executeId'] = $this->executeId;
  11348. $this->render ( "/expenses/wasteBook", $data );
  11349. }
  11350. function wasteBookIncome() {
  11351. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11352. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11353. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11354. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11355. $data ['dailyIncomeType'] = $dailyIncomeType;
  11356. Doo::loadModel ( 'wasteBook' );
  11357. $wasteBook = new wasteBook ();
  11358. Doo::loadModel ( 'L_category' );
  11359. $L_category = new L_category ();
  11360. Doo::loadClass ( 'XDeode' );
  11361. $XDeode = new XDeode ( 5 );
  11362. // echo $XDeode->encode(1).'<br>';
  11363. // echo $XDeode->encode(2).'<br>';
  11364. // echo $XDeode->encode(3).'<br>';
  11365. // echo $XDeode->encode(4).'<br>';
  11366. // echo $XDeode->encode(5).'<br>';
  11367. // echo $XDeode->encode(6).'<br>';
  11368. // echo $XDeode->encode(7).'<br>';
  11369. // echo $XDeode->encode(8).'<br>';
  11370. // echo $XDeode->encode(9).'<br>';
  11371. // echo $XDeode->encode(10).'<br>';
  11372. $dateArr = explode ( ':', $date );
  11373. $D1 = '';
  11374. $D2 = '';
  11375. $con = '';
  11376. if (! empty ( $date )) {
  11377. $D1 = $dateArr [0];
  11378. $D2 = $dateArr [1];
  11379. }
  11380. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11381. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11382. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11383. $con = ' and inputDate = "' . $D1 . '"';
  11384. if ($cid != 'ALL') {
  11385. $cid = $XDeode->decode ( $cid );
  11386. $con .= ' and cid = "' . $cid . '"';
  11387. }
  11388. if ($accountType != 'ALL') {
  11389. if ($accountType == 'INVOICE') {
  11390. $con .= ' and (accountType = 7 or accountType = 8)';
  11391. } elseif ($accountType == 'PAYMENTS') {
  11392. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11393. if ($dailyIncomeType != 'ALL') {
  11394. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11395. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11396. }
  11397. }
  11398. }
  11399. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11400. $sum = 0;
  11401. foreach ( $incomeList as $key => $value ) {
  11402. $sum += $value ['accountPrice'];
  11403. }
  11404. // print_r($incomeList);
  11405. // 获得办事和部门
  11406. $categoryList = $L_category->getCategory ();
  11407. $data ['accountType'] = $accountType;
  11408. $data ['cid'] = $cid;
  11409. $data ['categoryList'] = $categoryList;
  11410. $data ['sum'] = $sum;
  11411. $data ['incomeList'] = $incomeList;
  11412. $data ['inputDate'] = $date;
  11413. $data ['memu'] = "receipt";
  11414. $data ['staff'] = $this->staff;
  11415. $data ['receiptMemu'] = 'wasteBook';
  11416. $data ['verifyId'] = $this->verifyId;
  11417. $data ['executeId'] = $this->executeId;
  11418. $this->render ( "/expenses/wasteBookIncome", $data );
  11419. }
  11420. /**
  11421. * 所有支出
  11422. */
  11423. function wasteBookExpenditure() {
  11424. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11425. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11426. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11427. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11428. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11429. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11430. $data ['receiptType'] = $receiptType;
  11431. Doo::loadModel ( 'wasteBook' );
  11432. $wasteBook = new wasteBook ();
  11433. Doo::loadModel ( 'L_category' );
  11434. $L_category = new L_category ();
  11435. Doo::loadClass ( 'XDeode' );
  11436. $XDeode = new XDeode ( 5 );
  11437. $dateArr = explode ( ':', $date );
  11438. $D1 = '';
  11439. $D2 = '';
  11440. $con = '';
  11441. if (! empty ( $date )) {
  11442. $D1 = $dateArr [0];
  11443. $D2 = $dateArr [1];
  11444. }
  11445. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11446. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11447. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11448. $con = ' and inputDate = "' . $D1 . '"';
  11449. if ($cid != 'ALL') {
  11450. $cid = $XDeode->decode ( $cid );
  11451. $con .= ' and cid = "' . $cid . '"';
  11452. }
  11453. if ($accountType != 'ALL') {
  11454. if ($accountType == 'INVOICE') {
  11455. $con .= ' and accountType = 11';
  11456. } elseif ($accountType == 'PAYMENTS') {
  11457. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11458. if ($dailyExpenditureType != 'ALL') {
  11459. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11460. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11461. }
  11462. } elseif ($accountType == 'RECEIPT') {
  11463. if ($receiptType == 'ALL') {
  11464. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11465. } else {
  11466. $receiptType = $XDeode->decode ( $receiptType );
  11467. echo $receiptType;
  11468. if ($receiptType == 1) {
  11469. $con .= ' and (accountType = 1 or accountType=2)';
  11470. } else {
  11471. $con .= ' and accountType = ' . $receiptType;
  11472. }
  11473. }
  11474. }
  11475. }
  11476. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11477. $sum = 0;
  11478. foreach ( $incomeList as $key => $value ) {
  11479. $sum += $value ['accountPriceShow'];
  11480. }
  11481. // print_r($incomeList);
  11482. // 获得办事和部门
  11483. $categoryList = $L_category->getCategory ();
  11484. $data ['accountType'] = $accountType;
  11485. $data ['cid'] = $cid;
  11486. $data ['categoryList'] = $categoryList;
  11487. $data ['sum'] = $sum;
  11488. $data ['incomeList'] = $incomeList;
  11489. $data ['inputDate'] = $date;
  11490. $data ['memu'] = "receipt";
  11491. $data ['staff'] = $this->staff;
  11492. $data ['receiptMemu'] = 'wasteBook';
  11493. $data ['verifyId'] = $this->verifyId;
  11494. $data ['executeId'] = $this->executeId;
  11495. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11496. }
  11497. function ajaxGetWasteinvoiceReceivables() {
  11498. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11499. Doo::loadClass ( 'XDeode' );
  11500. $XDeode = new XDeode ( 5 );
  11501. $irid = $XDeode->decode ( $serial );
  11502. Doo::loadModel ( 'invoiceReceivables' );
  11503. $invoiceReceivables = new invoiceReceivables ();
  11504. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11505. echo json_encode ( array (
  11506. 'status' => 1,
  11507. 'detail' => $detail
  11508. ) );
  11509. }
  11510. function ajaxGetPaymentsByAid() {
  11511. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11512. Doo::loadModel ( "accountBook" );
  11513. $accountBook = new accountBook ();
  11514. $detail = $accountBook->getAccountBookByAid ( $serial );
  11515. echo json_encode ( array (
  11516. 'status' => 1,
  11517. 'detail' => $detail
  11518. ) );
  11519. }
  11520. function ajaxGetWasteInvoice() {
  11521. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11522. Doo::loadModel ( 'invoice' );
  11523. $invoice = new invoice ();
  11524. Doo::loadModel ( 'invoiceReceivables' );
  11525. $invoiceReceivables = new invoiceReceivables ();
  11526. $detail = $invoice->getInvoiceByIid ( $serial );
  11527. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11528. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11529. echo json_encode ( array (
  11530. 'status' => 1,
  11531. 'detail' => $detail
  11532. ) );
  11533. }
  11534. /**
  11535. */
  11536. function ajaxGetWasteReceipt() {
  11537. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11538. $accountTypeKey = $this->get_args ( 'accountTypeKey' ) ? $this->get_args ( 'accountTypeKey' ) : "";
  11539. Doo::loadModel ( 'receipt' );
  11540. $receipt = new receipt ();
  11541. Doo::loadClass ( 'XDeode' );
  11542. $XDeode = new XDeode ( 5 );
  11543. $rid = $XDeode->decode ( $serial );
  11544. $accountType= $XDeode->decode ( $accountTypeKey );
  11545. // 获得个数据
  11546. $detail = $receipt->getReceiptByRid ( $rid );
  11547. // 初始化
  11548. $detail ['reviseDetail'] = array ();
  11549. if (! empty ( $value ['reviseDetail'] ))
  11550. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11551. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11552. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11553. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11554. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11555. // 获得费用html
  11556. $html = $this->getWasteReceiptHtml ( $detail ,$accountType);
  11557. // 获得费用审批人数据
  11558. $detail = $this->getReceiptApproverHtml ( $detail );
  11559. // 审批执行
  11560. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11561. <th class="taC" width="90">审批人</th>
  11562. <th class="taC">审批意见</th></tr>';
  11563. foreach ( $detail ['verifyList'] as $key => $value ) {
  11564. $html .= '<tr>
  11565. <td>' . $value [1] . '</td>
  11566. <td>' . $value ['opinion'] . '</td>
  11567. </tr>
  11568. ';
  11569. }
  11570. $html .= ' </tbody></table>';
  11571. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11572. <th class="taC" width="90">执行人</th>
  11573. <th class="taC">执行意见</th></tr>';
  11574. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11575. $html .= '<tr>
  11576. <td>' . $value [1] . '</td>
  11577. <td>' . $value ['opinion'] . '</td>
  11578. </tr>
  11579. ';
  11580. }
  11581. $html .= ' </tbody></table>';
  11582. if($accountType==1){
  11583. Doo::loadModel ( 'loanReceipt' );
  11584. $loanReceipt = new loanReceipt ();
  11585. $loanList = $loanReceipt->getOne ( array (
  11586. 'where' => 'rid=' . $detail ['loanRid'],
  11587. 'desc' => 'rid',
  11588. 'asArray' => true
  11589. ) );
  11590. $html .= '<table class="table table-bordered table-condensed">
  11591. <tr class="warning">
  11592. <td class="taR"><b>汇款金额</b></td>
  11593. <td width="140" class="taR"><b style="font-size: 24px">¥'.$loanList['amount'].'</b></td>
  11594. </tr>
  11595. </table>';
  11596. }else{
  11597. $html .= '<table class="table table-bordered table-condensed">
  11598. <tr class="warning">
  11599. <td class="taR"><b>汇款金额</b></td>
  11600. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11601. </tr>
  11602. </table>';
  11603. }
  11604. // print_r($detail['verifyList']);
  11605. // header ( 'Content-Type:text/html;charset=utf-8' );
  11606. // echo $html;
  11607. echo json_encode ( array (
  11608. 'status' => 1,
  11609. 'html' => $html,
  11610. 'detail' => $detail
  11611. ) );
  11612. }
  11613. function getReceiptApproverHtml($detail = array()) {
  11614. Doo::loadModel ( 'loanReceipt' );
  11615. $loanReceipt = new loanReceipt ();
  11616. Doo::loadModel ( 'verify' );
  11617. $verify = new verify ();
  11618. Doo::loadModel ( 'staff' );
  11619. $staff = new staff ();
  11620. if (empty ( $detail ))
  11621. return array ();
  11622. $loanList = $loanReceipt->getOne ( array (
  11623. 'where' => 'rid=' . $detail ['loanRid'],
  11624. 'desc' => 'rid',
  11625. 'asArray' => true
  11626. ) );
  11627. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11628. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11629. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11630. else
  11631. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11632. } else
  11633. $verifyList = $verify->getOne ( array (
  11634. 'where' => 'vid=' . $detail ['verify'],
  11635. 'asArray' => true
  11636. ) );
  11637. $verifyList = json_decode ( $verifyList ['staff'], true );
  11638. Doo::loadModel ( 'role' );
  11639. $role = new role ();
  11640. $roleId = 0;
  11641. $flag = true;
  11642. $roleKey = 0;
  11643. $endStaffArray = array ();
  11644. $roleArrayCopy = array ();
  11645. foreach ( $verifyList as $k => $v ) {
  11646. // init verifyStaff
  11647. if ($v [1] == 'ROLE') {
  11648. if (! empty ( $verifyStaff )) {
  11649. $endStaffArray = end ( $verifyStaff );
  11650. }
  11651. $roleVerify = json_decode ( $v [3], true );
  11652. $roleKey = $k;
  11653. $roleArray = array ();
  11654. $rolename = $role->getOne ( array (
  11655. 'where' => 'rid=' . $v [0],
  11656. 'asArray' => true
  11657. ) );
  11658. foreach ( $roleVerify as $o => $p ) {
  11659. $staffID = explode ( '_', $p );
  11660. $staffInfo = $staff->getOne ( array (
  11661. 'where' => 'sid=' . $staffID [0],
  11662. 'asArray' => true
  11663. ) );
  11664. // print_r($staffID);
  11665. $exp = array (
  11666. 0 => $staffInfo ['sid'],
  11667. 1 => $staffID [1],
  11668. 2 => $staffInfo ['avatar'],
  11669. 'date' => '',
  11670. 'date' => '',
  11671. 'opinion' => '',
  11672. 'status' => '',
  11673. 'rolename' => $rolename ['name']
  11674. );
  11675. array_push ( $roleArray, $exp );
  11676. }
  11677. $roleArrayCopy [$v [0]] = $roleArray;
  11678. // $verifyList[$k]['roleArray']=$roleArray;
  11679. }
  11680. $verifyList [$k] ['date'] = "";
  11681. $verifyList [$k] ['opinion'] = "";
  11682. $verifyList [$k] ['status'] = "";
  11683. if (empty ( $verifyStaff )) {
  11684. $verifyList [$k] ['date'] = "";
  11685. $verifyList [$k] ['opinion'] = "";
  11686. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11687. $verifyList [$k] ['status'] = 4;
  11688. $flag = false;
  11689. }
  11690. } else {
  11691. foreach ( $verifyStaff as $m => $u ) {
  11692. if ($v [0] == $m) {
  11693. $verifyList [$k] ['date'] = $u ['date'];
  11694. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11695. $verifyList [$k] ['status'] = $u ['status'];
  11696. $flag = false;
  11697. break;
  11698. }
  11699. }
  11700. $endStaffArray = end ( $verifyStaff );
  11701. }
  11702. }
  11703. $rolename ['name'] = '';
  11704. if (! empty ( $roleId )) {
  11705. Doo::loadModel ( 'role' );
  11706. $role = new role ();
  11707. $rolename = $role->getOne ( array (
  11708. 'where' => 'rid=' . $roleId,
  11709. 'asArray' => true
  11710. ) );
  11711. }
  11712. if (! empty ( $verifyStaff ))
  11713. $endStaffArray = end ( $verifyStaff );
  11714. $KOP = false;
  11715. foreach ( $roleArrayCopy as $P => $A ) {
  11716. foreach ( $A as $MKI => $AVL ) {
  11717. if (! empty ( $verifyStaff )) {
  11718. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11719. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11720. $button = 4;
  11721. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11722. }
  11723. foreach ( $verifyStaff as $m => $u ) {
  11724. $AVLFK = $AVL [0] . '_R';
  11725. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11726. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11727. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11728. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11729. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11730. break;
  11731. }
  11732. }
  11733. } else {
  11734. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11735. $button = 4;
  11736. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11737. }
  11738. }
  11739. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11740. $KOP = true;
  11741. }
  11742. }
  11743. foreach ( $roleArrayCopy as $k => $v ) {
  11744. foreach ( $verifyList as $m => $n ) {
  11745. if ($n [0] == $k) {
  11746. array_splice ( $verifyList, $m, 1, $v );
  11747. }
  11748. }
  11749. }
  11750. // 费用执行人相关数据
  11751. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11752. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11753. foreach ( $executeCopy as $k => $v ) {
  11754. $executeCopy [$k] ['date'] = '';
  11755. $executeCopy [$k] ['opinion'] = '';
  11756. $executeCopy [$k] ['status'] = '';
  11757. if (! empty ( $executeStaff ))
  11758. foreach ( $executeStaff as $m => $u ) {
  11759. if ($v [0] == $m) {
  11760. $executeCopy [$k] ['date'] = $u ['date'];
  11761. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11762. $executeCopy [$k] ['status'] = $u ['status'];
  11763. break;
  11764. }
  11765. }
  11766. }
  11767. $detail ['executeCopy'] = $executeCopy;
  11768. $detail ['verifyList'] = $verifyList;
  11769. return $detail;
  11770. }
  11771. function getWasteReceiptHtml($detail = array(),$accountType=1) {
  11772. if (empty ( $detail ))
  11773. return '';
  11774. $html = '';
  11775. if ($detail ['Rtype'] == 0) { // 报销单
  11776. $html .= '
  11777. <table class="table table-bordered table-condensed">
  11778. <tbody>
  11779. <tr>
  11780. <th colspan="2" class="taC">日常相关费用</th>
  11781. </tr>';
  11782. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11783. $html .= '
  11784. <tr>
  11785. <th>' . $value ['name'] . '</th>
  11786. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11787. </tr>';
  11788. }
  11789. $html .= '
  11790. <tr>
  11791. <th class="taR">合计</th>
  11792. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11793. </tr>';
  11794. $html .= '<tr>
  11795. <th colspan="2" class="taC">差旅相关费用</th>
  11796. </tr>';
  11797. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11798. $html .= '
  11799. <tr>
  11800. <th>' . $value ['name'] . '</th>
  11801. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11802. </tr>';
  11803. }
  11804. $html .= '
  11805. <tr>
  11806. <th class="taR">合计</th>
  11807. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11808. </tr>';
  11809. $html .= '<tr>
  11810. <th colspan="2" class="taC">培训班费用</th>
  11811. </tr>';
  11812. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11813. $html .= '
  11814. <tr>
  11815. <th>' . $value ['name'] . '</th>
  11816. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11817. </tr>';
  11818. }
  11819. $html .= '
  11820. <tr>
  11821. <th class="taR">合计</th>
  11822. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11823. </tr>';
  11824. $html .= '<tr>
  11825. <th colspan="2" class="taC">其他</th>
  11826. </tr>';
  11827. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11828. $html .= '
  11829. <tr>
  11830. <th>' . $value ['name'] . '</th>
  11831. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11832. </tr>';
  11833. }
  11834. $html .= '
  11835. <tr>
  11836. <th class="taR">合计</th>
  11837. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11838. </tr>';
  11839. $html .= '<tr>
  11840. <th colspan="2" class="taC">报销金额调整</th>
  11841. </tr>';
  11842. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11843. $html .= '
  11844. <tr>
  11845. <th>' . $value ['name'] . '</th>
  11846. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11847. </tr>';
  11848. }
  11849. $html .= '
  11850. <tr>
  11851. <th class="taR">合计</th>
  11852. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11853. </tr>';
  11854. $html .= '
  11855. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11856. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11857. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11858. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11859. <tr class="warning">
  11860. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11861. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11862. </tr>
  11863. </tbody>
  11864. </table>';
  11865. } elseif ($detail ['Rtype'] == 2) {//对公汇款
  11866. $html .= '
  11867. <table class="table table-bordered table-condensed">
  11868. <tbody>
  11869. <tr>
  11870. <th colspan="2" class="taC">办事处相关费用</th>
  11871. </tr>';
  11872. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11873. $html .= '
  11874. <tr>
  11875. <th>' . $value ['name'] . '</th>
  11876. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11877. </tr>';
  11878. }
  11879. $html .= '
  11880. <tr>
  11881. <th class="taR">合计</th>
  11882. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11883. </tr>';
  11884. $html .= '
  11885. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11886. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11887. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11888. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11889. <tr class="warning">
  11890. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11891. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11892. </tr>
  11893. </tbody>
  11894. </table>';
  11895. } elseif ($detail ['Rtype'] == 1) {//借款 或者借款报销
  11896. Doo::loadModel ( 'loanReceipt' );
  11897. $loanReceipt = new loanReceipt ();
  11898. $loanList = $loanReceipt->getOne ( array (
  11899. 'where' => 'rid=' . $detail ['loanRid'],
  11900. 'desc' => 'rid',
  11901. 'asArray' => true
  11902. ) );
  11903. // print_r($loanList);
  11904. $loanList ['sumCN']=$this->num_to_rmb($loanList ['sum']);
  11905. $html .= '<table class="table table-bordered table-condensed">
  11906. <tbody>
  11907. <tr>
  11908. <th colspan="2" class="taC">借款费用</th>
  11909. </tr>';
  11910. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  11911. $html .= '<tr>
  11912. <th>' . $value ['name'] . '</th>
  11913. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11914. </tr>';
  11915. }
  11916. $html .= '<tr>
  11917. <th class="taC" colspan="2">产生费用所在办事处</th>
  11918. </tr>
  11919. <tr>
  11920. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  11921. </tr>
  11922. <tr>
  11923. <th class="taC" colspan="2">费用说明</th>
  11924. </tr>
  11925. <tr>
  11926. <td colspan="2">' . $loanList ['explanation'] . '</td>
  11927. </tr>
  11928. <tr class="warning">
  11929. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  11930. <td class="taR"><b style="font-size: 24px">¥' . $loanList ['sum'] . '</b><br>' . $loanList ['sumCN'] . '</td>
  11931. </tr>
  11932. </tbody>
  11933. </table>
  11934. ';
  11935. if ( $accountType==2) {
  11936. $balance=$detail ['sum']-$loanList ['sum'];
  11937. $balanceCN=$this->num_to_rmb($balance);
  11938. $html .= '<table class="table table-bordered table-condensed">
  11939. <tbody>
  11940. <tr>
  11941. <th colspan="2" class="taC">日常相关费用</th>
  11942. </tr>';
  11943. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11944. $html .= '
  11945. <tr>
  11946. <th>' . $value ['name'] . '</th>
  11947. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11948. </tr>';
  11949. }
  11950. $html .= '
  11951. <tr>
  11952. <th class="taR">合计</th>
  11953. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11954. </tr>';
  11955. $html .= '<tr>
  11956. <th colspan="2" class="taC">差旅相关费用</th>
  11957. </tr>';
  11958. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11959. $html .= '
  11960. <tr>
  11961. <th>' . $value ['name'] . '</th>
  11962. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11963. </tr>';
  11964. }
  11965. $html .= '
  11966. <tr>
  11967. <th class="taR">合计</th>
  11968. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11969. </tr>';
  11970. $html .= '<tr>
  11971. <th colspan="2" class="taC">培训班费用</th>
  11972. </tr>';
  11973. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11974. $html .= '
  11975. <tr>
  11976. <th>' . $value ['name'] . '</th>
  11977. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11978. </tr>';
  11979. }
  11980. $html .= '
  11981. <tr>
  11982. <th class="taR">合计</th>
  11983. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11984. </tr>';
  11985. $html .= '<tr>
  11986. <th colspan="2" class="taC">其他</th>
  11987. </tr>';
  11988. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11989. $html .= '
  11990. <tr>
  11991. <th>' . $value ['name'] . '</th>
  11992. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11993. </tr>';
  11994. }
  11995. $html .= '
  11996. <tr>
  11997. <th class="taR">合计</th>
  11998. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  11999. </tr>';
  12000. $html .= '<tr>
  12001. <th colspan="2" class="taC">报销金额调整</th>
  12002. </tr>';
  12003. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12004. $html .= '
  12005. <tr>
  12006. <th>' . $value ['name'] . '</th>
  12007. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12008. </tr>';
  12009. }
  12010. $html .= '
  12011. <tr>
  12012. <th class="taR">合计</th>
  12013. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12014. </tr>';
  12015. $html .= '
  12016. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12017. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12018. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12019. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12020. <tr class="warning">
  12021. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12022. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12023. </tr>
  12024. <tr class="success">
  12025. <td class="taR"><b>借款结余</b></td>
  12026. <td class="taR"><b style="font-size:24px">¥'.$balance.'</b><br>'.$balanceCN.'</td>
  12027. </tr>
  12028. </tbody>
  12029. </table>';
  12030. }
  12031. }
  12032. return $html;
  12033. }
  12034. /**
  12035. * 计算流水
  12036. */
  12037. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12038. $bakWaste ['bank'] = array (
  12039. 'CGBDeposit' => 0,
  12040. 'ICBCDeposit' => 0,
  12041. 'HUADeposit' => 0,
  12042. 'PersonalDeposit' => 0
  12043. );
  12044. $bakWaste ['financial'] = array (
  12045. 'current' => array (
  12046. 'CGBDeposit' => 0,
  12047. 'ICBCDeposit' => 0
  12048. ),
  12049. 'fixed' => array (
  12050. 'CGBDeposit' => 0,
  12051. 'ICBCDeposit' => 0
  12052. )
  12053. );
  12054. // 存款
  12055. foreach ( $waste ['bank'] as $key => $value ) {
  12056. // 收入
  12057. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12058. // 广发
  12059. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12060. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12061. }
  12062. // 工商
  12063. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12064. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12065. }
  12066. // 华润
  12067. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12068. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12069. }
  12070. // 个人
  12071. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12072. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12073. }
  12074. }
  12075. }
  12076. foreach ( $waste ['bank'] as $key => $value ) {
  12077. // 支出
  12078. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12079. // 广发
  12080. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12081. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12082. }
  12083. // 工商
  12084. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12085. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12086. }
  12087. // 华润
  12088. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12089. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12090. }
  12091. // 个人
  12092. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12093. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12094. }
  12095. }
  12096. }
  12097. // 活期
  12098. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12099. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12100. // 广发
  12101. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12102. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12103. }
  12104. // 工商
  12105. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12106. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12107. }
  12108. // 个人
  12109. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12110. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12111. }
  12112. }
  12113. }
  12114. // print_r($inComeStatistics ['fixedStatistics']);
  12115. // 固期
  12116. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12117. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12118. // 广发
  12119. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12120. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12121. }
  12122. // 工商
  12123. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12124. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12125. }
  12126. // 个人
  12127. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12128. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12129. }
  12130. }
  12131. }
  12132. return $waste;
  12133. }
  12134. function lyt() {
  12135. Doo::loadModel ( "receiptDetail" );
  12136. $receiptDetail = new receiptDetail ();
  12137. $receiptCollectList = $receiptDetail->find ( array (
  12138. 'where' => 'status=1 ',
  12139. 'asArray' => true
  12140. ) );
  12141. foreach ( $receiptCollectList as $key => $value ) {
  12142. $receiptDetail = new receiptDetail ();
  12143. $receiptDetail->pastDate = $value ['date'];
  12144. $receiptDetail->update ( array (
  12145. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12146. ) );
  12147. }
  12148. }
  12149. function staffCollectMonthDetail() {
  12150. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12151. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12152. if (! $year)
  12153. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12154. if (! $month)
  12155. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12156. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12157. if (! $nature){
  12158. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12159. }
  12160. Doo::loadModel ( 'staff' );
  12161. $staff = new staff ();
  12162. Doo::loadModel ( "receiptDetail" );
  12163. $receiptDetail = new receiptDetail ();
  12164. Doo::loadModel ( 'accountItem' );
  12165. $accountItem = new accountItem ();
  12166. Doo::loadModel ( 'statistics' );
  12167. $statistics = new statistics ();
  12168. Doo::loadModel ( 'L_category' );
  12169. $lCategory = new L_category ();
  12170. Doo::loadModel ( "receiptAuthorityManage" );
  12171. $receiptAuthorityManage = new receiptAuthorityManage ();
  12172. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12173. $cidList = array ();
  12174. foreach ( $imcStaff as $key => $value ) {
  12175. array_push ( $cidList, $value ['cid'] );
  12176. }
  12177. $cidString = implode ( ',', $cidList );
  12178. $naturecon='';
  12179. if ($nature=='ONJOB'){
  12180. $naturecon=' and (nature!=4 )';
  12181. }elseif($nature=='LEAVEJOB'){
  12182. $naturecon=' and (nature=4 )';
  12183. }else{
  12184. die ( 'illegal request--nature' );
  12185. }
  12186. $staffList = $staff->find ( array (
  12187. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12188. 'asArray' => true
  12189. ) );
  12190. $categoryList = $staff->find ( array (
  12191. 'select' => 'COUNT(*) as count,cid,category',
  12192. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12193. 'groupby' => 'cid',
  12194. 'asArray' => true
  12195. ) );
  12196. $list = array ();
  12197. foreach ( $categoryList as $vlu ) {
  12198. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12199. $r1 = 0;
  12200. $r2 = 0;
  12201. $r3 = 0;
  12202. $r4 = 0;
  12203. $r5 = 0;
  12204. $r6 = 0;
  12205. $r7 = 0;
  12206. $r8 = 0;
  12207. $r9 = 0;
  12208. $r10 = 0;
  12209. $r11 = 0;
  12210. $r12 = 0;
  12211. $r13 = 0;
  12212. $r14 = 0;
  12213. $r15 = 0;
  12214. $r16 = 0;
  12215. $r17 = 0;
  12216. $r18 = 0;
  12217. $c1 = 0;
  12218. $c2 = 0;
  12219. $c3 = 0;
  12220. $c4 = 0;
  12221. $c5 = 0;
  12222. $c6 = 0;
  12223. $p1 = 0;
  12224. $p2 = 0;
  12225. $p3 = 0;
  12226. $p4 = 0;
  12227. $p5 = 0;
  12228. $p6 = 0;
  12229. $p7 = 0;
  12230. $p8 = 0;
  12231. $p9 = 0;
  12232. $p10 = 0;
  12233. $p11 = 0;
  12234. $t1 = 0;
  12235. $t2 = 0;
  12236. $t3 = 0;
  12237. $t4 = 0;
  12238. $t5 = 0;
  12239. $s1 = 0;
  12240. $m1 = 0;
  12241. foreach ( $staffList as $value ) {
  12242. if ($vlu ['cid'] == $value ['cid']) {
  12243. // pastDate
  12244. $receiptCollectList = $receiptDetail->find ( array (
  12245. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12246. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12247. 'groupby' => 'item,Month(pastDate),itemCategory',
  12248. 'asArray' => true
  12249. ) );
  12250. // if ($value['sid']==42){
  12251. // print_r($receiptCollectList);die;
  12252. // }
  12253. if (! empty ( $receiptCollectList )) {
  12254. $receiptL = array (
  12255. '日常相关费用' => array (),
  12256. '差旅相关费用' => array (),
  12257. '培训班费用' => array (),
  12258. '其他' => array ()
  12259. );
  12260. $html = "";
  12261. $psum = 0;
  12262. $item = array (
  12263. '市内交通费',
  12264. '市内出租费',
  12265. '办事处房租',
  12266. '电话费',
  12267. '水费',
  12268. '电费',
  12269. '办公费用',
  12270. '邮寄费',
  12271. '其他费用',
  12272. '车辆费用',
  12273. '广告费',
  12274. '团队建设费',
  12275. '物业管理费',
  12276. '宽带费',
  12277. '人员薪酬',
  12278. '公积金',
  12279. '社保'
  12280. );
  12281. foreach ( $item as $va ) {
  12282. $falg = true;
  12283. foreach ( $receiptCollectList as $v ) {
  12284. if ($v ['itemCategory'] == '日常相关费用') {
  12285. if ($v ['item'] == $va) {
  12286. if ($va == '市内交通费')
  12287. $r1 += $v ['price'];
  12288. if ($va == '市内出租费')
  12289. $r2 += $v ['price'];
  12290. if ($va == '办事处房租')
  12291. $r3 += $v ['price'];
  12292. if ($va == '电话费')
  12293. $r4 += $v ['price'];
  12294. if ($va == '水费')
  12295. $r5 += $v ['price'];
  12296. if ($va == '电费')
  12297. $r6 += $v ['price'];
  12298. if ($va == '办公费用')
  12299. $r7 += $v ['price'];
  12300. if ($va == '邮寄费')
  12301. $r8 += $v ['price'];
  12302. if ($va == '其他费用')
  12303. $r9 += $v ['price'];
  12304. if ($va == '车辆费用')
  12305. $r10 += $v ['price'];
  12306. if ($va == '广告费')
  12307. $r11 += $v ['price'];
  12308. if ($va == '团队建设费')
  12309. $r13 += $v ['price'];
  12310. if ($va == '物业管理费')
  12311. $r14 += $v ['price'];
  12312. if ($va == '宽带费')
  12313. $r15 += $v ['price'];
  12314. if ($va == '公积金')
  12315. $r16 += $v ['price'];
  12316. if ($va == '社保')
  12317. $r17 += $v ['price'];
  12318. if ($va == '人员薪酬')
  12319. $r18 += $v ['price'];
  12320. $psum += $v ['price'];
  12321. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12322. $falg = false;
  12323. break;
  12324. }
  12325. }
  12326. }
  12327. if ($falg)
  12328. $html .= '<td class="taR">-</td>';
  12329. }
  12330. $r12 += $psum;
  12331. if (! empty ( $psum ))
  12332. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12333. else
  12334. $psum = '<td class="colGreen taR">-</td>';
  12335. $receiptL ['日常相关费用'] = $psum . $html;
  12336. /* ----------------------------------- */
  12337. $html = "";
  12338. $psum = 0;
  12339. $item = array (
  12340. '往来交通费',
  12341. '市内交通费',
  12342. '出差住宿费',
  12343. '出差补助',
  12344. '其他费用'
  12345. );
  12346. foreach ( $item as $va ) {
  12347. $falg = true;
  12348. foreach ( $receiptCollectList as $v ) {
  12349. if ($v ['itemCategory'] == '差旅相关费用') {
  12350. if ($v ['item'] == $va) {
  12351. if ($va == '往来交通费')
  12352. $c1 += $v ['price'];
  12353. if ($va == '市内交通费')
  12354. $c2 += $v ['price'];
  12355. if ($va == '出差住宿费')
  12356. $c3 += $v ['price'];
  12357. if ($va == '出差补助')
  12358. $c4 += $v ['price'];
  12359. if ($va == '其他费用')
  12360. $c5 += $v ['price'];
  12361. $psum += $v ['price'];
  12362. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12363. $falg = false;
  12364. break;
  12365. }
  12366. }
  12367. }
  12368. if ($falg)
  12369. $html .= '<td class="taR">-</td>';
  12370. }
  12371. $c6 += $psum;
  12372. if (! empty ( $psum ))
  12373. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12374. else
  12375. $psum = '<td class="colGreen taR">-</td>';
  12376. $receiptL ['差旅相关费用'] = $psum . $html;
  12377. /* ------------------------------------- */
  12378. $html = "";
  12379. $psum = 0;
  12380. $item = array (
  12381. '场租费',
  12382. '薪酬',
  12383. '住宿费',
  12384. '交通费',
  12385. '餐饮费',
  12386. '办公费',
  12387. '公关费',
  12388. '其他',
  12389. '电话费',
  12390. '邮寄费'
  12391. );
  12392. foreach ( $item as $va ) {
  12393. $falg = true;
  12394. foreach ( $receiptCollectList as $v ) {
  12395. if ($v ['itemCategory'] == '培训班费用') {
  12396. if ($v ['item'] == $va) {
  12397. if ($va == '场租费')
  12398. $p1 += $v ['price'];
  12399. if ($va == '薪酬')
  12400. $p2 += $v ['price'];
  12401. if ($va == '住宿费')
  12402. $p3 += $v ['price'];
  12403. if ($va == '交通费')
  12404. $p4 += $v ['price'];
  12405. if ($va == '餐饮费')
  12406. $p5 += $v ['price'];
  12407. if ($va == '办公费')
  12408. $p6 += $v ['price'];
  12409. if ($va == '公关费')
  12410. $p7 += $v ['price'];
  12411. if ($va == '其他')
  12412. $p8 += $v ['price'];
  12413. if ($va == '电话费')
  12414. $p9 += $v ['price'];
  12415. if ($va == '邮寄费')
  12416. $p10 += $v ['price'];
  12417. $psum += $v ['price'];
  12418. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12419. $falg = false;
  12420. break;
  12421. }
  12422. }
  12423. }
  12424. if ($falg)
  12425. $html .= '<td class="taR">-</td>';
  12426. }
  12427. $p11 += $psum;
  12428. if (! empty ( $psum ))
  12429. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12430. else
  12431. $psum = '<td class="colGreen taR">-</td>';
  12432. $receiptL ['培训班费用'] = $psum . $html;
  12433. /* ------------------------------------- */
  12434. $html = "";
  12435. $psum = 0;
  12436. $item = array (
  12437. '公关费',
  12438. '广告费',
  12439. '借款',
  12440. '可自加费用'
  12441. );
  12442. foreach ( $item as $va ) {
  12443. $falg = true;
  12444. foreach ( $receiptCollectList as $v ) {
  12445. if ($v ['itemCategory'] == '其他') {
  12446. // if ($value['sid']==42){
  12447. //
  12448. // echo var_dump($v['item']);
  12449. // echo var_dump($va);
  12450. // echo var_dump($v['item']==" ".$va);
  12451. // echo $v['item']."==".$va."/<br/>";
  12452. // //print_r( $receiptCollectList);//echo $va;
  12453. // }
  12454. if (trim ( $v ['item'] ) == $va) {
  12455. if ($va == '公关费')
  12456. $t1 += $v ['price'];
  12457. if ($va == '广告费') {
  12458. $t2 += $v ['price'];
  12459. }
  12460. if ($va == '借款')
  12461. $t3 += $v ['price'];
  12462. if ($va == '可自加费用')
  12463. $t4 += $v ['price'];
  12464. $psum += $v ['price'];
  12465. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12466. $falg = false;
  12467. break;
  12468. }
  12469. }
  12470. }
  12471. if ($falg)
  12472. $html .= '<td class="taR">-</td>';
  12473. }
  12474. $t5 += $psum;
  12475. if (! empty ( $psum ))
  12476. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12477. else
  12478. $psum = '<td class="colGreen taR">-</td>';
  12479. $receiptL ['其他'] = $psum . $html;
  12480. /* ------------------------------------- */
  12481. $html = "";
  12482. $psum = 0;
  12483. foreach ( $receiptCollectList as $v ) {
  12484. if ($v ['itemCategory'] == '报销金额调整') {
  12485. if (! empty ( $v ['price'] )) {
  12486. $psum += $v ['price'];
  12487. }
  12488. }
  12489. }
  12490. $s1 += $psum;
  12491. if (! empty ( $psum ))
  12492. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12493. else
  12494. $psum = '<td class="taR colOrange">-</td>';
  12495. $receiptL ['报销金额调整'] = $psum . $html;
  12496. } else {
  12497. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12498. <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>
  12499. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12500. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12501. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12502. $receiptL ['培训班费用'] = '<td class="colGreen 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>
  12503. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12504. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12505. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12506. }
  12507. $monthStaffPrice = $receiptDetail->find ( array (
  12508. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12509. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12510. 'groupby' => 'Month(pastDate)',
  12511. 'asArray' => true
  12512. ) );
  12513. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12514. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12515. $m1 += $monthStaffPrice [0] ['price'];
  12516. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12517. } else
  12518. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12519. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12520. $list [$value ['username']] = $receiptL;
  12521. }
  12522. }
  12523. $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>
  12524. <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>
  12525. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  12526. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12527. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12528. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p11 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  12529. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td><td class="taR">' . $p9 . '</td><td class="taR">' . $p10 . '</td>';
  12530. $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>';
  12531. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12532. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12533. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12534. }
  12535. $data ['list'] = $list;
  12536. // print_r($list);
  12537. $receiptCollectList = $receiptDetail->find ( array (
  12538. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12539. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12540. 'groupby' => 'item,Month(pastDate),itemCategory',
  12541. 'asArray' => true
  12542. ) );
  12543. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12544. // statistics html
  12545. $stList = $statistics->getOne ( array (
  12546. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12547. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12548. 'groupby' => 'Month(date)',
  12549. 'asArray' => true
  12550. ) );
  12551. if (empty ( $stList ))
  12552. $stList = array (
  12553. 'rePrice' => 0,
  12554. 'agPrice' => 0
  12555. );
  12556. $data ['stList'] = array (
  12557. 'rePrice' => $stList ['rePrice'],
  12558. 'agPrice' => $stList ['agPrice'],
  12559. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12560. );
  12561. $monthHtml = "";
  12562. for($i = 1; $i <= 12; $i ++) {
  12563. if ($i == $month)
  12564. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12565. else
  12566. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12567. }
  12568. $data ['monthHtml'] = $monthHtml;
  12569. $data ['year'] = $year;
  12570. $data ['month'] = $month;
  12571. $data ['nature'] = $nature;
  12572. $data ['memu'] = "receipt";
  12573. $data ['staff'] = $this->staff;
  12574. $data ['receiptMemu'] = 'companyCategoryCollect';
  12575. $data ['verifyId'] = $this->verifyId;
  12576. $data ['executeId'] = $this->executeId;
  12577. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12578. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12579. }
  12580. function staffCollectMonthDetail2() {
  12581. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12582. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12583. if (! $year)
  12584. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12585. if (! $month)
  12586. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12587. Doo::loadModel ( 'staff' );
  12588. $staff = new staff ();
  12589. Doo::loadModel ( "receiptDetail" );
  12590. $receiptDetail = new receiptDetail ();
  12591. Doo::loadModel ( 'accountItem' );
  12592. $accountItem = new accountItem ();
  12593. Doo::loadModel ( 'statistics' );
  12594. $statistics = new statistics ();
  12595. Doo::loadModel ( 'L_category' );
  12596. $lCategory = new L_category ();
  12597. $staffList = $staff->find ( array (
  12598. 'where' => 'username!="admin"',
  12599. 'asArray' => true
  12600. ) );
  12601. $categoryList = $staff->find ( array (
  12602. 'select' => 'COUNT(*) as count,cid,category',
  12603. 'where' => 'username !="admin"',
  12604. 'groupby' => 'cid',
  12605. 'asArray' => true
  12606. ) );
  12607. $list = array ();
  12608. foreach ( $categoryList as $vlu ) {
  12609. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12610. $r1 = 0;
  12611. $r2 = 0;
  12612. $r3 = 0;
  12613. $r4 = 0;
  12614. $r5 = 0;
  12615. $r6 = 0;
  12616. $r7 = 0;
  12617. $r8 = 0;
  12618. $r9 = 0;
  12619. $r10 = 0;
  12620. $r11 = 0;
  12621. $r12 = 0;
  12622. $r13 = 0;
  12623. $r14 = 0;
  12624. $r15 = 0;
  12625. $c1 = 0;
  12626. $c2 = 0;
  12627. $c3 = 0;
  12628. $c4 = 0;
  12629. $c5 = 0;
  12630. $c6 = 0;
  12631. $p1 = 0;
  12632. $p2 = 0;
  12633. $p3 = 0;
  12634. $p4 = 0;
  12635. $p5 = 0;
  12636. $p6 = 0;
  12637. $p7 = 0;
  12638. $p8 = 0;
  12639. $p9 = 0;
  12640. $t1 = 0;
  12641. $t2 = 0;
  12642. $t3 = 0;
  12643. $t4 = 0;
  12644. $t5 = 0;
  12645. $s1 = 0;
  12646. $m1 = 0;
  12647. foreach ( $staffList as $value ) {
  12648. if ($vlu ['cid'] == $value ['cid']) {
  12649. $receiptCollectList = $receiptDetail->find ( array (
  12650. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12651. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12652. 'groupby' => 'item,Month(date),itemCategory',
  12653. 'asArray' => true
  12654. ) );
  12655. if (! empty ( $receiptCollectList )) {
  12656. $receiptL = array (
  12657. '日常相关费用' => array (),
  12658. '差旅相关费用' => array (),
  12659. '培训班费用' => array (),
  12660. '其他' => array ()
  12661. );
  12662. $html = "";
  12663. $psum = 0;
  12664. $item = array (
  12665. '市内交通费',
  12666. '市内出租费',
  12667. '办事处房租',
  12668. '电话费',
  12669. '水费',
  12670. '电费',
  12671. '办公费用',
  12672. '邮寄费',
  12673. '其他费用',
  12674. '车辆费用',
  12675. '广告费',
  12676. '团队建设费',
  12677. '物业管理费',
  12678. '宽带费'
  12679. );
  12680. foreach ( $item as $va ) {
  12681. $falg = true;
  12682. foreach ( $receiptCollectList as $v ) {
  12683. if ($v ['itemCategory'] == '日常相关费用') {
  12684. if ($v ['item'] == $va) {
  12685. if ($va == '市内交通费')
  12686. $r1 += $v ['price'];
  12687. if ($va == '市内出租费')
  12688. $r2 += $v ['price'];
  12689. if ($va == '办事处房租')
  12690. $r3 += $v ['price'];
  12691. if ($va == '电话费')
  12692. $r4 += $v ['price'];
  12693. if ($va == '水费')
  12694. $r5 += $v ['price'];
  12695. if ($va == '电费')
  12696. $r6 += $v ['price'];
  12697. if ($va == '办公费用')
  12698. $r7 += $v ['price'];
  12699. if ($va == '邮寄费')
  12700. $r8 += $v ['price'];
  12701. if ($va == '其他费用')
  12702. $r9 += $v ['price'];
  12703. if ($va == '车辆费用')
  12704. $r10 += $v ['price'];
  12705. if ($va == '广告费')
  12706. $r11 += $v ['price'];
  12707. if ($va == '团队建设费')
  12708. $r13 += $v ['price'];
  12709. if ($va == '物业管理费')
  12710. $r14 += $v ['price'];
  12711. if ($va == '宽带费')
  12712. $r15 += $v ['price'];
  12713. $psum += $v ['price'];
  12714. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12715. $falg = false;
  12716. break;
  12717. }
  12718. }
  12719. }
  12720. if ($falg)
  12721. $html .= '<td class="taR">-</td>';
  12722. }
  12723. $r12 += $psum;
  12724. if (! empty ( $psum ))
  12725. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12726. else
  12727. $psum = '<td class="colGreen taR">-</td>';
  12728. $receiptL ['日常相关费用'] = $psum . $html;
  12729. /* ----------------------------------- */
  12730. $html = "";
  12731. $psum = 0;
  12732. $item = array (
  12733. '往来交通费',
  12734. '市内交通费',
  12735. '出差住宿费',
  12736. '出差补助',
  12737. '其他费用'
  12738. );
  12739. foreach ( $item as $va ) {
  12740. $falg = true;
  12741. foreach ( $receiptCollectList as $v ) {
  12742. if ($v ['itemCategory'] == '差旅相关费用') {
  12743. if ($v ['item'] == $va) {
  12744. if ($va == '往来交通费')
  12745. $c1 += $v ['price'];
  12746. if ($va == '市内交通费')
  12747. $c2 += $v ['price'];
  12748. if ($va == '出差住宿费')
  12749. $c3 += $v ['price'];
  12750. if ($va == '出差补助')
  12751. $c4 += $v ['price'];
  12752. if ($va == '其他费用')
  12753. $c5 += $v ['price'];
  12754. $psum += $v ['price'];
  12755. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12756. $falg = false;
  12757. break;
  12758. }
  12759. }
  12760. }
  12761. if ($falg)
  12762. $html .= '<td class="taR">-</td>';
  12763. }
  12764. $c6 += $psum;
  12765. if (! empty ( $psum ))
  12766. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12767. else
  12768. $psum = '<td class="colGreen taR">-</td>';
  12769. $receiptL ['差旅相关费用'] = $psum . $html;
  12770. /* ------------------------------------- */
  12771. $html = "";
  12772. $psum = 0;
  12773. $item = array (
  12774. '场租费',
  12775. '薪酬',
  12776. '住宿费',
  12777. '交通费',
  12778. '餐饮费',
  12779. '办公费',
  12780. '公关费',
  12781. '其他'
  12782. );
  12783. foreach ( $item as $va ) {
  12784. $falg = true;
  12785. foreach ( $receiptCollectList as $v ) {
  12786. if ($v ['itemCategory'] == '培训班费用') {
  12787. if ($v ['item'] == $va) {
  12788. if ($va == '场租费')
  12789. $p1 += $v ['price'];
  12790. if ($va == '薪酬')
  12791. $p2 += $v ['price'];
  12792. if ($va == '住宿费')
  12793. $p3 += $v ['price'];
  12794. if ($va == '交通费')
  12795. $p4 += $v ['price'];
  12796. if ($va == '餐饮费')
  12797. $p5 += $v ['price'];
  12798. if ($va == '办公费')
  12799. $p6 += $v ['price'];
  12800. if ($va == '公关费')
  12801. $p7 += $v ['price'];
  12802. if ($va == '其他')
  12803. $p8 += $v ['price'];
  12804. $psum += $v ['price'];
  12805. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12806. $falg = false;
  12807. break;
  12808. }
  12809. }
  12810. }
  12811. if ($falg)
  12812. $html .= '<td class="taR">-</td>';
  12813. }
  12814. $p9 += $psum;
  12815. if (! empty ( $psum ))
  12816. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12817. else
  12818. $psum = '<td class="colGreen taR">-</td>';
  12819. $receiptL ['培训班费用'] = $psum . $html;
  12820. /* ------------------------------------- */
  12821. $html = "";
  12822. $psum = 0;
  12823. $item = array (
  12824. '公关费',
  12825. '广告费',
  12826. '借款',
  12827. '可自加费用'
  12828. );
  12829. foreach ( $item as $va ) {
  12830. $falg = true;
  12831. foreach ( $receiptCollectList as $v ) {
  12832. if ($v ['itemCategory'] == '其他') {
  12833. if ($v ['item'] == $va) {
  12834. if ($va == '公关费')
  12835. $t1 += $v ['price'];
  12836. if ($va == '广告费')
  12837. $t2 += $v ['price'];
  12838. if ($va == '借款')
  12839. $t3 += $v ['price'];
  12840. if ($va == '可自加费用')
  12841. $t4 += $v ['price'];
  12842. $psum += $v ['price'];
  12843. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12844. $falg = false;
  12845. break;
  12846. }
  12847. }
  12848. }
  12849. if ($falg)
  12850. $html .= '<td class="taR">-</td>';
  12851. }
  12852. $t5 += $psum;
  12853. if (! empty ( $psum ))
  12854. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12855. else
  12856. $psum = '<td class="colGreen taR">-</td>';
  12857. $receiptL ['其他'] = $psum . $html;
  12858. /* ------------------------------------- */
  12859. $html = "";
  12860. $psum = 0;
  12861. foreach ( $receiptCollectList as $v ) {
  12862. if ($v ['itemCategory'] == '报销金额调整') {
  12863. if (! empty ( $v ['price'] )) {
  12864. $psum += $v ['price'];
  12865. }
  12866. }
  12867. }
  12868. $s1 += $psum;
  12869. if (! empty ( $psum ))
  12870. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12871. else
  12872. $psum = '<td class="taR colOrange">-</td>';
  12873. $receiptL ['报销金额调整'] = $psum . $html;
  12874. } else {
  12875. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12876. <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>';
  12877. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12878. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12879. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12880. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12881. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12882. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12883. }
  12884. $monthStaffPrice = $receiptDetail->find ( array (
  12885. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12886. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12887. 'asArray' => true
  12888. ) );
  12889. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12890. $m1 += $monthStaffPrice [0] ['price'];
  12891. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12892. } else
  12893. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12894. $list [$value ['username']] = $receiptL;
  12895. }
  12896. }
  12897. $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>
  12898. <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>
  12899. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12900. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12901. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12902. $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>
  12903. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12904. $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>';
  12905. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12906. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12907. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12908. }
  12909. $data ['list'] = $list;
  12910. $receiptCollectList = $receiptDetail->find ( array (
  12911. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12912. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12913. 'groupby' => 'item,Month(date),itemCategory',
  12914. 'asArray' => true
  12915. ) );
  12916. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12917. // statistics html
  12918. $stList = $statistics->getOne ( array (
  12919. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12920. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12921. 'groupby' => 'Month(date)',
  12922. 'asArray' => true
  12923. ) );
  12924. if (empty ( $stList ))
  12925. $stList = array (
  12926. 'rePrice' => 0,
  12927. 'agPrice' => 0
  12928. );
  12929. $data ['stList'] = array (
  12930. 'rePrice' => $stList ['rePrice'],
  12931. 'agPrice' => $stList ['agPrice'],
  12932. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12933. );
  12934. $monthHtml = "";
  12935. for($i = 1; $i <= 12; $i ++) {
  12936. if ($i == $month)
  12937. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12938. else
  12939. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12940. }
  12941. $data ['monthHtml'] = $monthHtml;
  12942. $data ['year'] = $year;
  12943. $data ['month'] = $month;
  12944. $data ['memu'] = "receipt";
  12945. $data ['staff'] = $this->staff;
  12946. $data ['receiptMemu'] = 'companyCategoryCollect';
  12947. $data ['verifyId'] = $this->verifyId;
  12948. $data ['executeId'] = $this->executeId;
  12949. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12950. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12951. }
  12952. /**
  12953. * 用户报销单列表
  12954. */
  12955. function receiptStatisticsStaffDetail() {
  12956. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12957. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12958. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12959. Doo::loadModel ( "receipt" );
  12960. $receipt = new receipt ();
  12961. Doo::loadModel ( "receiptDetail" );
  12962. $receiptDetail = new receiptDetail ();
  12963. Doo::loadModel ( 'staff' );
  12964. $staff = new staff ();
  12965. Doo::loadModel ( 'accountItem' );
  12966. $accountItem = new accountItem ();
  12967. Doo::loadModel ( 'statistics' );
  12968. $statistics = new statistics ();
  12969. if (! empty ( $username )) {
  12970. $username = addslashes ( urldecode ( $username ) );
  12971. $staffDetail = $staff->getStaffByName ( $username );
  12972. if (empty ( $staffDetail ))
  12973. die ( 'illegal request' );
  12974. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  12975. $itemList = $accountItem->getAccountItem ();
  12976. $itemHtml = '';
  12977. $categoryHtml = '';
  12978. $itemKeyList = array_keys ( $itemList );
  12979. $revisePrice = 0;
  12980. // 报销单内容详情
  12981. foreach ( $list as $key => $value ) {
  12982. $accountItemList = json_decode ( $value ['accountItem'], true );
  12983. $list [$key] ['accountItemList'] = $accountItemList;
  12984. $receiptItemHtml = '';
  12985. foreach ( $itemKeyList as $v ) {
  12986. if ($v == '日常相关费用')
  12987. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  12988. elseif ($v == '差旅相关费用')
  12989. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  12990. elseif ($v == '培训班费用')
  12991. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  12992. elseif ($v == '其他')
  12993. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  12994. foreach ( $itemList [$v] as $ke => $va ) {
  12995. $falg = true;
  12996. if (! empty ( $accountItemList [$v] )) {
  12997. foreach ( $accountItemList [$v] as $ve ) {
  12998. if ($va ['name'] == $ve ['name']) {
  12999. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13000. $falg = false;
  13001. break;
  13002. }
  13003. }
  13004. }
  13005. if ($falg)
  13006. $receiptItemHtml .= '<td class="taR"></td>';
  13007. }
  13008. }
  13009. // 金额调整和费用查看
  13010. $revisePrice += $value ['revisePrice'];
  13011. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13012. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13013. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13014. }
  13015. // 报销单合计
  13016. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13017. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13018. $receiptTotalHtml = '';
  13019. // 报销单项目抬头
  13020. foreach ( $itemKeyList as $value ) {
  13021. $count = count ( $itemList [$value] ) + 1;
  13022. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13023. $categoryHtml .= '<th class="taC">合计</th>';
  13024. $sumfalg=true;
  13025. foreach ( $rtl as $rtlValue ) {
  13026. if ($rtlValue ['itemCategory'] == $value) {
  13027. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13028. $sumfalg=false;
  13029. break;
  13030. }
  13031. }
  13032. if ($sumfalg)
  13033. $receiptTotalHtml .= '<th></th>';
  13034. foreach ( $itemList [$value] as $k => $v ) {
  13035. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13036. // 合计
  13037. $falg = true;
  13038. foreach ( $receiptTotalList as $ve ) {
  13039. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13040. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13041. $falg = false;
  13042. break;
  13043. }
  13044. }
  13045. if ($falg)
  13046. $receiptTotalHtml .= '<th></th>';
  13047. }
  13048. }
  13049. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13050. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13051. if (empty ( $stList ))
  13052. $stList = array (
  13053. 'rePrice' => 0,
  13054. 'agPrice' => 0
  13055. );
  13056. $data ['stList'] = array (
  13057. 'rePrice' => $stList ['rePrice'],
  13058. 'agPrice' => $stList ['agPrice'],
  13059. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13060. );
  13061. $monthHtml = "";
  13062. for($i = 1; $i <= 12; $i ++) {
  13063. if ($i == $month)
  13064. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13065. else
  13066. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13067. }
  13068. $data ['username'] = urlencode ( $username );
  13069. $data ['usernameEN'] = $username;
  13070. $data ['monthHtml'] = $monthHtml;
  13071. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13072. $data ['list'] = $list;
  13073. $data ['categoryHtml'] = $categoryHtml;
  13074. $data ['itemHtml'] = $itemHtml;
  13075. $data ['itemList'] = $itemList;
  13076. $data ['year'] = $year;
  13077. $data ['month'] = $month;
  13078. $data ['memu'] = "receipt";
  13079. $data ['staff'] = $this->staff;
  13080. $data ['receiptMemu'] = 'companyCategoryCollect';
  13081. $data ['verifyId'] = $this->verifyId;
  13082. $data ['executeId'] = $this->executeId;
  13083. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13084. }
  13085. die ( 'illegal request' );
  13086. }
  13087. function companyMonthCollectDetail() {
  13088. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13089. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13090. if (! $year)
  13091. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13092. if (! $month)
  13093. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13094. Doo::loadModel ( 'staff' );
  13095. $staff = new staff ();
  13096. Doo::loadModel ( "receiptDetail" );
  13097. $receiptDetail = new receiptDetail ();
  13098. Doo::loadModel ( 'accountItem' );
  13099. $accountItem = new accountItem ();
  13100. Doo::loadModel ( 'statistics' );
  13101. $statistics = new statistics ();
  13102. Doo::loadModel ( 'L_category' );
  13103. $lCategory = new L_category ();
  13104. $staffList = $staff->find ( array (
  13105. 'where' => 'username!="admin"',
  13106. 'asArray' => true
  13107. ) );
  13108. $categoryList = $lCategory->find ( array (
  13109. 'asArray' => true
  13110. ) );
  13111. $list = array ();
  13112. foreach ( $categoryList as $value ) {
  13113. $receiptCollectList = $receiptDetail->find ( array (
  13114. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13115. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13116. 'groupby' => 'item,Month(pastDate),itemCategory',
  13117. 'asArray' => true
  13118. ) );
  13119. if (! empty ( $receiptCollectList )) {
  13120. $receiptL = array (
  13121. '日常相关费用' => array (),
  13122. '差旅相关费用' => array (),
  13123. '培训班费用' => array (),
  13124. '其他' => array ()
  13125. );
  13126. $html = "";
  13127. $psum = 0;
  13128. $item = array (
  13129. '市内交通费',
  13130. '市内出租费',
  13131. '办事处房租',
  13132. '电话费',
  13133. '水费',
  13134. '电费',
  13135. '办公费用',
  13136. '邮寄费',
  13137. '其他费用',
  13138. '车辆费用',
  13139. '广告费',
  13140. '团队建设费'
  13141. );
  13142. foreach ( $item as $va ) {
  13143. $falg = true;
  13144. foreach ( $receiptCollectList as $v ) {
  13145. if ($v ['itemCategory'] == '日常相关费用') {
  13146. if ($v ['item'] == $va) {
  13147. $psum += $v ['price'];
  13148. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13149. $falg = false;
  13150. break;
  13151. }
  13152. }
  13153. }
  13154. if ($falg)
  13155. $html .= '<td class="taR">-</td>';
  13156. }
  13157. if (! empty ( $psum ))
  13158. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13159. else
  13160. $psum = '<td class="colGreen taR">-</td>';
  13161. $receiptL ['日常相关费用'] = $psum . $html;
  13162. /* ----------------------------------- */
  13163. $html = "";
  13164. $psum = 0;
  13165. $item = array (
  13166. '往来交通费',
  13167. '市内交通费',
  13168. '出差住宿费',
  13169. '出差补助',
  13170. '其他费用'
  13171. );
  13172. foreach ( $item as $va ) {
  13173. $falg = true;
  13174. foreach ( $receiptCollectList as $v ) {
  13175. if ($v ['itemCategory'] == '差旅相关费用') {
  13176. if ($v ['item'] == $va) {
  13177. $psum += $v ['price'];
  13178. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13179. $falg = false;
  13180. break;
  13181. }
  13182. }
  13183. }
  13184. if ($falg)
  13185. $html .= '<td class="taR">-</td>';
  13186. }
  13187. if (! empty ( $psum ))
  13188. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13189. else
  13190. $psum = '<td class="colGreen taR">-</td>';
  13191. $receiptL ['差旅相关费用'] = $psum . $html;
  13192. /* ------------------------------------- */
  13193. $html = "";
  13194. $psum = 0;
  13195. $item = array (
  13196. '场租费',
  13197. '薪酬',
  13198. '住宿费',
  13199. '交通费',
  13200. '餐饮费',
  13201. '办公费',
  13202. '公关费',
  13203. '其他'
  13204. );
  13205. foreach ( $item as $va ) {
  13206. $falg = true;
  13207. foreach ( $receiptCollectList as $v ) {
  13208. if ($v ['itemCategory'] == '培训班费用') {
  13209. if ($v ['item'] == $va) {
  13210. $psum += $v ['price'];
  13211. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13212. $falg = false;
  13213. break;
  13214. }
  13215. }
  13216. }
  13217. if ($falg)
  13218. $html .= '<td class="taR">-</td>';
  13219. }
  13220. if (! empty ( $psum ))
  13221. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13222. else
  13223. $psum = '<td class="colGreen taR">-</td>';
  13224. $receiptL ['培训班费用'] = $psum . $html;
  13225. /* ------------------------------------- */
  13226. $html = "";
  13227. $psum = 0;
  13228. $item = array (
  13229. '公关费',
  13230. '广告费',
  13231. '借款',
  13232. '可自加费用'
  13233. );
  13234. foreach ( $item as $va ) {
  13235. $falg = true;
  13236. foreach ( $receiptCollectList as $v ) {
  13237. if ($v ['itemCategory'] == '其他') {
  13238. if ($v ['item'] == $va) {
  13239. $psum += $v ['price'];
  13240. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13241. $falg = false;
  13242. break;
  13243. }
  13244. }
  13245. }
  13246. if ($falg)
  13247. $html .= '<td class="taR">-</td>';
  13248. }
  13249. if (! empty ( $psum ))
  13250. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13251. else
  13252. $psum = '<td class="colGreen taR">-</td>';
  13253. $receiptL ['其他'] = $psum . $html;
  13254. /* ------------------------------------- */
  13255. $html = "";
  13256. $psum = 0;
  13257. foreach ( $receiptCollectList as $v ) {
  13258. if ($v ['itemCategory'] == '报销金额调整') {
  13259. if (! empty ( $v ['price'] ))
  13260. $psum += $v ['price'];
  13261. }
  13262. }
  13263. if (! empty ( $psum ))
  13264. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13265. else
  13266. $psum = '<td class="taR colOrange">-</td>';
  13267. $receiptL ['报销金额调整'] = $psum . $html;
  13268. } else {
  13269. $receiptL ['日常相关费用'] = '<td class="colGreen 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>
  13270. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13271. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13272. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13273. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13274. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13275. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13276. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13277. }
  13278. $monthStaffPrice = $receiptDetail->find ( array (
  13279. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13280. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13281. 'asArray' => true
  13282. ) );
  13283. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13284. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13285. else
  13286. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13287. $list [$value ['title']] = $receiptL;
  13288. }
  13289. $data ['list'] = $list;
  13290. $receiptCollectList = $receiptDetail->find ( array (
  13291. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13292. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13293. 'groupby' => 'item,Month(pastDate),itemCategory',
  13294. 'asArray' => true
  13295. ) );
  13296. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13297. // print_r($data['monthPriceHtml']);
  13298. // foreach ($data['monthPriceHtml'] as $value){
  13299. // echo $value;
  13300. // }
  13301. // die;
  13302. // statistics html
  13303. $stList = $statistics->getOne ( array (
  13304. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13305. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13306. 'groupby' => 'Month(date)',
  13307. 'asArray' => true
  13308. ) );
  13309. if (empty ( $stList ))
  13310. $stList = array (
  13311. 'rePrice' => 0,
  13312. 'agPrice' => 0
  13313. );
  13314. $data ['stList'] = array (
  13315. 'rePrice' => $stList ['rePrice'],
  13316. 'agPrice' => $stList ['agPrice'],
  13317. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13318. );
  13319. $monthHtml = "";
  13320. for($i = 1; $i <= 12; $i ++) {
  13321. if ($i == $month)
  13322. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13323. else
  13324. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13325. }
  13326. $data ['monthHtml'] = $monthHtml;
  13327. $data ['year'] = $year;
  13328. $data ['month'] = $month;
  13329. $data ['memu'] = "receipt";
  13330. $data ['staff'] = $this->staff;
  13331. $data ['receiptMemu'] = 'companyCategoryCollect';
  13332. $data ['verifyId'] = $this->verifyId;
  13333. $data ['executeId'] = $this->executeId;
  13334. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13335. }
  13336. function staffCollectDetail() {
  13337. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13338. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13339. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13340. if (! $staffname) {
  13341. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13342. $staffname = urldecode ( $staffname );
  13343. }
  13344. Doo::loadModel ( 'staff' );
  13345. $staff = new staff ();
  13346. Doo::loadModel ( "receiptDetail" );
  13347. $receiptDetail = new receiptDetail ();
  13348. Doo::loadModel ( 'accountItem' );
  13349. $accountItem = new accountItem ();
  13350. Doo::loadModel ( 'statistics' );
  13351. $statistics = new statistics ();
  13352. Doo::loadModel ( 'L_category' );
  13353. $lCategory = new L_category ();
  13354. Doo::loadModel ( "receiptAuthorityManage" );
  13355. $receiptAuthorityManage = new receiptAuthorityManage ();
  13356. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13357. $cidList = array ();
  13358. foreach ( $imcStaff as $key => $value ) {
  13359. array_push ( $cidList, $value ['cid'] );
  13360. }
  13361. $cidString = implode ( ',', $cidList );
  13362. $staffList = $staff->find ( array (
  13363. 'where' => ' cid in (' . $cidString . ')',
  13364. 'asArray' => true
  13365. ) );
  13366. $stHtml = '';
  13367. $stTitle = "";
  13368. $staffId = 0;
  13369. $cid = 0;
  13370. $ocid = 0;
  13371. foreach ( $staffList as $value ) {
  13372. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13373. $stTitle = $value ['category'] . '-' . $value ['username'];
  13374. $staffId = $value ['sid'];
  13375. $cid = $value ['cid'];
  13376. $ocid = $value ['cid'];
  13377. if (! empty ( $value ['othercid'] ))
  13378. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13379. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13380. } elseif ($value ['username'] != 'admin')
  13381. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13382. }
  13383. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13384. 'where' => 'cid in(' . $cid . ')',
  13385. 'asArray' => true
  13386. ) );
  13387. if (empty ( $pcid ))
  13388. $pcid = $ocid;
  13389. $data ['ocid'] = $pcid;
  13390. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13391. $this->showCache ( $path );
  13392. //
  13393. $receiptCollectList = $receiptDetail->find ( array (
  13394. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13395. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13396. 'groupby' => 'item,Month(pastDate),itemCategory',
  13397. 'asArray' => true
  13398. ) );
  13399. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13400. // print_r($receiptCollectList);
  13401. $accountList = $accountItem->find ( array (
  13402. 'asArray' => true
  13403. ) );
  13404. // create CollectDetail HTML
  13405. $collectHtml = array ();
  13406. foreach ( $accountList as $key => $value ) {
  13407. $html = "";
  13408. $asum = 0;
  13409. for($i = 1; $i <= 12; $i ++) {
  13410. $falg = true;
  13411. foreach ( $receiptCollectList as $v ) {
  13412. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13413. if ($v ['item'] == '可自加费用') {
  13414. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13415. }
  13416. $asum += $v ['price'];
  13417. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13418. $falg = false;
  13419. break;
  13420. }
  13421. }
  13422. if ($falg)
  13423. $html .= '<td class="taR">-</td>';
  13424. }
  13425. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13426. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13427. }
  13428. $data ['collectHtml'] = $collectHtml;
  13429. // print_r($collectHtml);
  13430. // create Adjustment price html
  13431. $receiptCollectList = $receiptDetail->find ( array (
  13432. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13433. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13434. 'groupby' => 'itemCategory,Month(pastDate)',
  13435. 'asArray' => true
  13436. ) );
  13437. $adjustment = array ();
  13438. $collectArray = array (
  13439. '日常相关费用' => array (),
  13440. '差旅相关费用' => array (),
  13441. '培训班费用' => array (),
  13442. '其他' => array ()
  13443. );
  13444. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13445. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13446. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13447. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13448. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13449. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13450. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13451. array_push ( $collectArray ['其他'], $collectHtml );
  13452. $data ['collectArray'] = $collectArray;
  13453. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13454. array_push ( $adjustment, $collectHtml );
  13455. $data ['adjustment'] = $adjustment;
  13456. // total price html
  13457. $collectHtml = "";
  13458. $total = 0;
  13459. for($i = 1; $i <= 12; $i ++) {
  13460. $sumPrice = 0;
  13461. foreach ( $receiptCollectList as $key => $value ) {
  13462. if ($value ['month'] == $i) {
  13463. $sumPrice += $value ['price'];
  13464. }
  13465. }
  13466. if ($sumPrice == 0)
  13467. $collectHtml .= '<td class="taR">-</td>';
  13468. else
  13469. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13470. $total += $sumPrice;
  13471. }
  13472. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13473. // statistics html
  13474. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13475. if (empty ( $stList ))
  13476. $stList = array (
  13477. 'rePrice' => 0,
  13478. 'agPrice' => 0
  13479. );
  13480. $data ['stList'] = array (
  13481. 'rePrice' => $stList ['rePrice'],
  13482. 'agPrice' => $stList ['agPrice'],
  13483. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13484. );
  13485. $data ['totalPrice'] = $collectHtml;
  13486. $data ['totalYear'] = $total;
  13487. $data ['stHtml'] = $stHtml;
  13488. $data ['year'] = $year;
  13489. $data ['stTitle'] = $stTitle;
  13490. $data ['staffname'] = urlencode ( $staffname );
  13491. $data ['memu'] = "receipt";
  13492. $data ['staff'] = $this->staff;
  13493. $data ['receiptMemu'] = 'companyCategoryCollect';
  13494. $data ['verifyId'] = $this->verifyId;
  13495. $data ['executeId'] = $this->executeId;
  13496. if ($year < date ( "Y" )) {
  13497. Doo::loadModel ( 'receipt' );
  13498. $receipt = new receipt ();
  13499. $receiptList = $receipt->find ( array (
  13500. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13501. 'asArray' => true
  13502. ) );
  13503. if (empty ( $receiptList )) { // generated files
  13504. ob_start ();
  13505. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13506. $this->cacheFile ( $path );
  13507. die ();
  13508. }
  13509. }
  13510. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13511. }
  13512. function BUGFLAG() {
  13513. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13514. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13515. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13516. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13517. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13518. if (empty ( $status ))
  13519. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13520. $page_size = 12;
  13521. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13522. $vidList = array ();
  13523. $button = 0;
  13524. Doo::loadModel ( 'verify' );
  13525. $verify = new verify ();
  13526. Doo::loadModel ( 'receipt' );
  13527. $receipt = new receipt ();
  13528. Doo::loadModel ( 'staff' );
  13529. $staff = new staff ();
  13530. Doo::loadModel ( 'L_category' );
  13531. $Lcategory = new L_category ();
  13532. $dateCondition = " and Year(date) =" . $year;
  13533. if (! empty ( $month ))
  13534. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13535. $categoryList = $Lcategory->find ( array (
  13536. 'asArray' => true
  13537. ) );
  13538. $staffList = $staff->find ( array (
  13539. 'where' => 'cid=' . $cid,
  13540. 'asArray' => true
  13541. ) );
  13542. $cateCondition = "";
  13543. $staffCondition = "";
  13544. $approvalCondition = "";
  13545. if (! empty ( $cid ))
  13546. $cateCondition = ' and cid=' . $cid;
  13547. if (! empty ( $sid )) {
  13548. $staffCondition = ' and staff=' . $sid;
  13549. $cateCondition = "";
  13550. }
  13551. $approvalCondition = " and status=" . $status;
  13552. if ($status == 2) {
  13553. // 查找角色审批人
  13554. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13555. }
  13556. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13557. $approvalCondition = ' and status=2 ';
  13558. }
  13559. if ($status == 1) {
  13560. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13561. }
  13562. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13563. $pageinfo ['page'] = array (
  13564. 'previous' => ''
  13565. );
  13566. if ($status == 0) {
  13567. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13568. $receiptList = $receipt->find ( array (
  13569. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13570. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13571. 'desc' => 'rid',
  13572. 'asArray' => true
  13573. ) );
  13574. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13575. } else
  13576. $receiptList = $receipt->find ( array (
  13577. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13578. 'desc' => 'rid',
  13579. 'asArray' => true
  13580. ) );
  13581. $rLRes = $receipt->find ( array (
  13582. '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,
  13583. 'desc' => 'rid',
  13584. 'asArray' => true
  13585. ) );
  13586. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13587. // print_r($pageinfo);
  13588. $Locate = 0;
  13589. foreach ( $receiptList as $key => $value ) {
  13590. $receiptList [$key] ['Locate'] = $Locate;
  13591. $Locate ++;
  13592. $receiptList [$key] ['reviseDetail'] = array ();
  13593. if (! empty ( $value ['reviseDetail'] ))
  13594. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13595. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13596. $categoryDetil = $Lcategory->getOne ( array (
  13597. 'where' => 'cid=' . $value ['cid'],
  13598. 'asArray' => true
  13599. ) );
  13600. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13601. $verifyList = $verify->getOne ( array (
  13602. 'where' => 'vid=' . $value ['verify'],
  13603. 'asArray' => true
  13604. ) );
  13605. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13606. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13607. foreach ( $verifyList as $k => $v ) {
  13608. // init verifyStaff
  13609. $verifyList [$k] ['date'] = "";
  13610. $verifyList [$k] ['opinion'] = "";
  13611. $verifyList [$k] ['status'] = "";
  13612. if (empty ( $verifyStaff )) {
  13613. $verifyList [$k] ['date'] = "";
  13614. $verifyList [$k] ['opinion'] = "";
  13615. if ($v [0] == $this->staff [0] ['sid']) {
  13616. $verifyList [$k] ['status'] = 4;
  13617. $button = 4;
  13618. }
  13619. } else {
  13620. $flag = true;
  13621. foreach ( $verifyStaff as $m => $u ) {
  13622. if ($v [0] == $m) {
  13623. $verifyList [$k] ['date'] = $u ['date'];
  13624. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13625. $verifyList [$k] ['status'] = $u ['status'];
  13626. $flag = false;
  13627. break;
  13628. }
  13629. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13630. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13631. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13632. }
  13633. if ($flag) { // 检测可编辑
  13634. if ($v [0] == $this->staff [0] ['sid']) {
  13635. $verifyList [$k] ['status'] = 4;
  13636. $button = 4;
  13637. }
  13638. }
  13639. }
  13640. }
  13641. $receiptList [$key] ['verifyList'] = $verifyList;
  13642. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13643. 'where' => 'sid=' . $value ['staff'],
  13644. 'asArray' => true
  13645. ) );
  13646. $receiptList [$key] ['button'] = $button;
  13647. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13648. }
  13649. // print_r($receiptList);die;
  13650. // $data['verifyDetail']=$verifyDetail;
  13651. $mothHtml = "";
  13652. for($i = 1; $i <= 12; $i ++) {
  13653. if ($month == $i)
  13654. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13655. else
  13656. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13657. }
  13658. $data ['mothHtml'] = $mothHtml;
  13659. $data ['page'] = $pageinfo;
  13660. $data ['receiptList'] = $receiptList;
  13661. $data ['receiptApprovalCount'] = count ( $rLRes );
  13662. $data ['status'] = $status;
  13663. $data ['year'] = $year;
  13664. $data ['categoryList'] = $categoryList;
  13665. $data ['staffList'] = $staffList;
  13666. $data ['cid'] = $cid;
  13667. $data ['sid'] = $sid;
  13668. // print_r($receiptList);
  13669. $data ['memu'] = "receipt";
  13670. $data ['staff'] = $this->staff;
  13671. $data ['receiptMemu'] = 'approvalExpenses';
  13672. $data ['verifyId'] = $this->verifyId;
  13673. $data ['executeId'] = $this->executeId;
  13674. $this->render ( "/admin/FALG", $data );
  13675. }
  13676. function ajaxGetReceiptOrder() {
  13677. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13678. if (! empty ( $receiptOrder )) {
  13679. Doo::loadModel ( 'receipt' );
  13680. $receipt = new receipt ();
  13681. Doo::loadModel ( 'staff' );
  13682. $staff = new staff ();
  13683. $receiptInfo = $receipt->getOne ( array (
  13684. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13685. 'asArray' => true
  13686. ) );
  13687. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13688. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13689. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13690. </tbody></table><table class="table table table-bordered"><tbody>';
  13691. foreach ( $verifyStaff as $key => $value ) {
  13692. $staffInfo = $staff->getOne ( array (
  13693. 'select' => 'username',
  13694. 'where' => ' sid="' . $key . '"',
  13695. 'asArray' => true
  13696. ) );
  13697. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13698. }
  13699. $html .= '</tbody></table></div></div>';
  13700. echo json_encode ( array (
  13701. 'status' => 1,
  13702. 'receiptHtml' => $html
  13703. ) );
  13704. die ();
  13705. }
  13706. echo json_encode ( array (
  13707. 'status' => 2,
  13708. 'receiptHtml' => ''
  13709. ) );
  13710. die ();
  13711. }
  13712. function _getMonthCollectDetail($receiptCollectList) {
  13713. if (! empty ( $receiptCollectList )) {
  13714. $receiptL = array (
  13715. '日常相关费用' => array (),
  13716. '差旅相关费用' => array (),
  13717. '培训班费用' => array (),
  13718. '其他' => array ()
  13719. );
  13720. $html = "";
  13721. $psum = 0;
  13722. $item = array (
  13723. '市内交通费',
  13724. '市内出租费',
  13725. '办事处房租',
  13726. '电话费',
  13727. '水费',
  13728. '电费',
  13729. '办公费用',
  13730. '邮寄费',
  13731. '其他费用',
  13732. '车辆费用',
  13733. '广告费',
  13734. '团队建设费',
  13735. '物业管理费',
  13736. '宽带费',
  13737. '人员薪酬',
  13738. '公积金',
  13739. '社保'
  13740. );
  13741. foreach ( $item as $value ) {
  13742. $falg = true;
  13743. foreach ( $receiptCollectList as $v ) {
  13744. if ($v ['itemCategory'] == '日常相关费用') {
  13745. if ($v ['item'] == $value) {
  13746. $psum += $v ['price'];
  13747. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13748. $falg = false;
  13749. break;
  13750. }
  13751. }
  13752. }
  13753. if ($falg)
  13754. $html .= '<td class="taR">-</td>';
  13755. }
  13756. if (! empty ( $psum ))
  13757. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13758. else
  13759. $psum = '<td class="colGreen taR">-</td>';
  13760. $receiptL ['日常相关费用'] = $psum . $html;
  13761. /* ----------------------------------- */
  13762. $html = "";
  13763. $psum = 0;
  13764. $item = array (
  13765. '往来交通费',
  13766. '市内交通费',
  13767. '出差住宿费',
  13768. '出差补助',
  13769. '其他费用'
  13770. );
  13771. foreach ( $item as $value ) {
  13772. $falg = true;
  13773. foreach ( $receiptCollectList as $v ) {
  13774. if ($v ['itemCategory'] == '差旅相关费用') {
  13775. if ($v ['item'] == $value) {
  13776. $psum += $v ['price'];
  13777. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13778. $falg = false;
  13779. break;
  13780. }
  13781. }
  13782. }
  13783. if ($falg)
  13784. $html .= '<td class="taR">-</td>';
  13785. }
  13786. if (! empty ( $psum ))
  13787. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13788. else
  13789. $psum = '<td class="colGreen taR">-</td>';
  13790. $receiptL ['差旅相关费用'] = $psum . $html;
  13791. /* ------------------------------------- */
  13792. $html = "";
  13793. $psum = 0;
  13794. $item = array (
  13795. '场租费',
  13796. '薪酬',
  13797. '住宿费',
  13798. '交通费',
  13799. '餐饮费',
  13800. '办公费',
  13801. '公关费',
  13802. '其他',
  13803. '电话费',
  13804. '邮寄费'
  13805. );
  13806. foreach ( $item as $value ) {
  13807. $falg = true;
  13808. foreach ( $receiptCollectList as $v ) {
  13809. if ($v ['itemCategory'] == '培训班费用') {
  13810. if ($v ['item'] == $value) {
  13811. $psum += $v ['price'];
  13812. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13813. $falg = false;
  13814. break;
  13815. }
  13816. }
  13817. }
  13818. if ($falg)
  13819. $html .= '<td class="taR">-</td>';
  13820. }
  13821. if (! empty ( $psum ))
  13822. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13823. else
  13824. $psum = '<td class="colGreen taR">-</td>';
  13825. $receiptL ['培训班费用'] = $psum . $html;
  13826. /* ------------------------------------- */
  13827. $html = "";
  13828. $psum = 0;
  13829. $item = array (
  13830. '公关费',
  13831. '广告费',
  13832. '借款',
  13833. '可自加费用'
  13834. );
  13835. foreach ( $item as $value ) {
  13836. $falg = true;
  13837. foreach ( $receiptCollectList as $v ) {
  13838. if ($v ['itemCategory'] == '其他') {
  13839. if ($v ['item'] == $value) {
  13840. $psum += $v ['price'];
  13841. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13842. $falg = false;
  13843. break;
  13844. }
  13845. }
  13846. }
  13847. if ($falg)
  13848. $html .= '<td class="taR">-</td>';
  13849. }
  13850. if (! empty ( $psum ))
  13851. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13852. else
  13853. $psum = '<td class="colGreen taR">-</td>';
  13854. $receiptL ['其他'] = $psum . $html;
  13855. /* ------------------------------------- */
  13856. $html = "";
  13857. $psum = 0;
  13858. foreach ( $receiptCollectList as $v ) {
  13859. if ($v ['itemCategory'] == '报销金额调整') {
  13860. if (! empty ( $v ['price'] ))
  13861. $psum += $v ['price'];
  13862. }
  13863. }
  13864. if (! empty ( $psum ))
  13865. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13866. else
  13867. $psum = '<td class="taR colOrange">-</td>';
  13868. $receiptL ['报销金额调整'] = $psum . $html;
  13869. } else {
  13870. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13871. <td class="taR">-</td>
  13872. <td class="taR">-</td>
  13873. <td class="taR">-</td>
  13874. <td class="taR">-</td>
  13875. <td class="taR">-</td>
  13876. <td class="taR">-</td>
  13877. <td class="taR">-</td>
  13878. <td class="taR">-</td>
  13879. <td class="taR">-</td>
  13880. <td class="taR">-</td>
  13881. <td class="taR">-</td>
  13882. <td class="taR">-</td>';
  13883. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13884. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13885. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13886. <td class="taR">-</td>
  13887. <td class="taR">-</td>
  13888. <td class="taR">-</td>
  13889. <td class="taR">-</td>
  13890. <td class="taR">-</td>
  13891. <td class="taR">-</td>
  13892. <td class="taR">-</td>
  13893. <td class="taR">-</td>';
  13894. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13895. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13896. }
  13897. return $receiptL;
  13898. }
  13899. function eMail() {
  13900. Doo::loadModel ( 'staff' );
  13901. $staff = new staff ();
  13902. Doo::loadModel ( 'receipt' );
  13903. $receipt = new receipt ();
  13904. Doo::loadModel ( 'L_category' );
  13905. $Lcategory = new L_category ();
  13906. Doo::loadModel ( "verify" );
  13907. $verify = new verify ();
  13908. $staffList = $staff->find ( array (
  13909. 'asArray' => true
  13910. ) );
  13911. foreach ( $staffList as $key => $value ) {
  13912. if ($value ['username'] != 'admin') {
  13913. // 提交人
  13914. $receiptList = $receipt->find ( array (
  13915. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13916. 'asArray' => true
  13917. ) );
  13918. if (! empty ( $receiptList )) {
  13919. $html = '<br><div><style></style>
  13920. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13921. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13922. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13923. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13924. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13925. <tbody><tr>
  13926. <td style="padding: 0 40px;" align="left">
  13927. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13928. </td></tr><tr>
  13929. <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>
  13930. </tr>
  13931. </tbody> </table></td> </tr> <tr><td>
  13932. <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">
  13933. <tbody> <tr><td>
  13934. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13935. 以下报销单完成了审批,等着收款吧:</p>
  13936. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13937. foreach ( $receiptList as $k => $v ) {
  13938. $category = $Lcategory->getOne ( array (
  13939. 'where' => 'cid=' . $v ['cid'],
  13940. 'asArray' => true
  13941. ) );
  13942. $html .= '
  13943. <tr>
  13944. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13945. <td align="left">
  13946. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13947. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13948. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13949. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13950. </tr>';
  13951. }
  13952. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13953. <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>
  13954. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13955. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13956. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13957. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13958. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13959. $receipt = new receipt ();
  13960. $receipt->notice = 1;
  13961. $receipt->update ( array (
  13962. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  13963. ) );
  13964. }
  13965. }
  13966. // 审批人
  13967. $verifyList = $verify->find ( array (
  13968. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  13969. 'asArray' => true
  13970. ) );
  13971. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  13972. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  13973. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13974. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  13975. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13976. <tbody><tr><td style="padding: 0 40px;" align="left">
  13977. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13978. </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>
  13979. </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">
  13980. <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>
  13981. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  13982. foreach ( $verifyList as $k => $v ) {
  13983. $receiptList = $receipt->find ( array (
  13984. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  13985. 'asArray' => true
  13986. ) );
  13987. foreach ( $receiptList as $r => $l ) {
  13988. $category = $Lcategory->getOne ( array (
  13989. 'where' => 'cid=' . $l ['cid'],
  13990. 'asArray' => true
  13991. ) );
  13992. $staffDetile = $staff->getOne ( array (
  13993. 'where' => 'sid=' . $l ['staff'],
  13994. 'asArray' => true
  13995. ) );
  13996. $html .= '
  13997. <tr>
  13998. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13999. <td align="left">
  14000. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14001. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14002. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14003. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14004. </tr>';
  14005. }
  14006. }
  14007. $html .= '
  14008. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14009. <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>
  14010. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14011. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14012. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14013. // $receipt=new receipt();
  14014. // $receipt->notice=1;
  14015. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14016. }
  14017. }
  14018. }
  14019. }
  14020. function setWXMsg($rid, $type) {
  14021. Doo::loadModel ( "receipt" );
  14022. $receipt = new receipt ();
  14023. $receiptDetail = $receipt->getOne ( array (
  14024. 'where' => 'rid=' . $rid,
  14025. 'asArray' => true
  14026. ) );
  14027. if (! empty ( $receiptDetail )) {
  14028. Doo::loadModel ( 'staff' );
  14029. $staff = new staff ();
  14030. $staffmsg = $staff->getOne ( array (
  14031. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14032. 'asArray' => TRUE
  14033. ) );
  14034. if (! empty ( $staffmsg ['wxid'] )) {
  14035. require_once (SITE_PATH . '/protected/class/client.php');
  14036. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14037. $user = $staffmsg ['wxid'];
  14038. $receiptName = '';
  14039. $msg = '';
  14040. switch ($receiptDetail ['Rtype']) {
  14041. case 0 :
  14042. $receiptName = '报销';
  14043. break;
  14044. case 1 :
  14045. $receiptName = '借款';
  14046. break;
  14047. case 2 :
  14048. $receiptName = '对公汇款';
  14049. break;
  14050. }
  14051. switch ($type) {
  14052. case 1 :
  14053. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14054. break;
  14055. case 2 :
  14056. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14057. break;
  14058. case 3 :
  14059. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14060. break;
  14061. }
  14062. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14063. }
  14064. }
  14065. }
  14066. // Email发送函数
  14067. function SMail($toemail, $subject, $contents) {
  14068. Doo::loadClass ( 'class.phpmailer' );
  14069. $mail = new PHPMailer ();
  14070. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14071. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14072. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14073. $mail->Password = "cDO1GjtY1seH"; // 密码
  14074. $mail->CharSet = "UTF8";
  14075. $mail->SMTPAuth = true;
  14076. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14077. $mail->Mailer = "smtp";
  14078. $mail->Port = 25;
  14079. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14080. $mail->MsgHTML ( $contents );
  14081. $mail->AddAddress ( $toemail );
  14082. $mail->CharSet = "UTF-8";
  14083. return $mail->Send ();
  14084. }
  14085. function h5Upload() {
  14086. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14087. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14088. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14089. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14090. header ( "HTTP/1.1 500 Internal Server Error" );
  14091. echo "POST exceeded maximum allowed size.";
  14092. exit ( 0 );
  14093. }
  14094. // Settings
  14095. $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)
  14096. $upload_name = "Filedata";
  14097. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14098. $extension_whitelist = array (
  14099. "doc",
  14100. "txt",
  14101. "jpg",
  14102. "gif",
  14103. "png"
  14104. ); // Allowed file extensions
  14105. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14106. // Other variables
  14107. $MAX_FILENAME_LENGTH = 260;
  14108. $file_name = "";
  14109. $file_extension = "";
  14110. $uploadErrors = array (
  14111. 0 => "文件上传成功",
  14112. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14113. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14114. 3 => "上传的文件仅为部分文件",
  14115. 4 => "没有文件上传",
  14116. 6 => "缺少临时文件夹"
  14117. );
  14118. $nk = time ();
  14119. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14120. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14121. echo "文件无法保存.";
  14122. exit ( 0 );
  14123. }
  14124. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14125. echo json_encode ( array (
  14126. 'filename' => $file_name,
  14127. 'id' => $nk
  14128. ) );
  14129. exit ( 0 );
  14130. }
  14131. function swfupload() {
  14132. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14133. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14134. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14135. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14136. header ( "HTTP/1.1 500 Internal Server Error" );
  14137. echo "POST exceeded maximum allowed size.";
  14138. exit ( 0 );
  14139. }
  14140. // Settings
  14141. $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)
  14142. $upload_name = "Filedata";
  14143. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14144. $extension_whitelist = array (
  14145. "doc",
  14146. "txt",
  14147. "jpg",
  14148. "gif",
  14149. "png"
  14150. ); // Allowed file extensions
  14151. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14152. // Other variables
  14153. $MAX_FILENAME_LENGTH = 260;
  14154. $file_name = "";
  14155. $file_extension = "";
  14156. $uploadErrors = array (
  14157. 0 => "文件上传成功",
  14158. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14159. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14160. 3 => "上传的文件仅为部分文件",
  14161. 4 => "没有文件上传",
  14162. 6 => "缺少临时文件夹"
  14163. );
  14164. $nk = time ();
  14165. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14166. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14167. echo "文件无法保存.";
  14168. exit ( 0 );
  14169. }
  14170. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14171. echo json_encode ( array (
  14172. 'filename' => $file_name,
  14173. 'id' => $nk
  14174. ) );
  14175. exit ( 0 );
  14176. }
  14177. function _GetFileEXT($filename) {
  14178. $pics = explode ( '.', $filename );
  14179. $num = count ( $pics );
  14180. return $pics [$num - 1];
  14181. }
  14182. /**
  14183. * 获取get或者POST值
  14184. * @param string $name 属性名称
  14185. * @return fixed 值
  14186. */
  14187. function get_args($name) {
  14188. if (isset ( $_GET [$name] )) {
  14189. if (is_array ( $_GET [$name] ))
  14190. return $_GET [$name];
  14191. else
  14192. return addslashes ( $_GET [$name] );
  14193. } elseif (isset ( $_POST [$name] )) {
  14194. if (is_array ( $_POST [$name] ))
  14195. return $_POST [$name];
  14196. else
  14197. return addslashes ( $_POST [$name] );
  14198. } else
  14199. return false;
  14200. }
  14201. function num_to_rmb($num) {
  14202. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14203. $c2 = "分角元拾佰仟万拾佰仟亿";
  14204. // 精确到分后面就不要了,所以只留两个小数位
  14205. $num = round ( $num, 2 );
  14206. // 将数字转化为整数
  14207. $num = $num * 100;
  14208. if (strlen ( $num ) > 10) {
  14209. return "金额太大,请检查";
  14210. }
  14211. $i = 0;
  14212. $c = "";
  14213. while ( 1 ) {
  14214. if ($i == 0) {
  14215. // 获取最后一位数字
  14216. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14217. } else {
  14218. $n = $num % 10;
  14219. }
  14220. // 每次将最后一位数字转化为中文
  14221. $p1 = substr ( $c1, 3 * $n, 3 );
  14222. $p2 = substr ( $c2, 3 * $i, 3 );
  14223. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14224. $c = $p1 . $p2 . $c;
  14225. } else {
  14226. $c = $p1 . $c;
  14227. }
  14228. $i = $i + 1;
  14229. // 去掉数字最后一位了
  14230. $num = $num / 10;
  14231. // echo $num.'</br>';
  14232. $num = ( int ) $num;
  14233. // $num =floor($num);
  14234. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14235. // echo $num.'</br>';
  14236. // 结束循环
  14237. if ($num == 0) {
  14238. break;
  14239. }
  14240. }
  14241. // echo $c.'</br>';
  14242. $j = 0;
  14243. $slen = strlen ( $c );
  14244. while ( $j < $slen ) {
  14245. // utf8一个汉字相当3个字符
  14246. $m = substr ( $c, $j, 6 );
  14247. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14248. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14249. $left = substr ( $c, 0, $j );
  14250. $right = substr ( $c, $j + 3 );
  14251. $c = $left . $right;
  14252. $j = $j - 3;
  14253. $slen = $slen - 3;
  14254. }
  14255. $j = $j + 3;
  14256. }
  14257. // 这个是为了去掉类似23.0中最后一个“零”字
  14258. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14259. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14260. }
  14261. // 将处理的汉字加上“整”
  14262. if (empty ( $c )) {
  14263. return "零元整";
  14264. } else {
  14265. return $c . "整";
  14266. }
  14267. }
  14268. /**
  14269. * 获得分页数据
  14270. * @param unknown_type $table
  14271. * @param unknown_type $condition
  14272. * @param unknown_type $on_page
  14273. * @param unknown_type $page_size
  14274. */
  14275. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14276. $page_c = "";
  14277. $page ['previous'] = $this->get_previous ( $on_page );
  14278. $page ['on_page'] = $on_page;
  14279. $total_count = $this->get_table_count ( $table, $condition );
  14280. $total = intval ( $total_count / $page_size );
  14281. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14282. $page ['total_data'] = $total_count;
  14283. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14284. $i = 1;
  14285. $page_max = 1;
  14286. $page_width = 3;
  14287. if ($on_page >= $page_width) {
  14288. $page_max = intval ( $on_page / $page_width ) + 1;
  14289. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14290. }
  14291. for(; $i <= $page ['total_page']; $i ++) {
  14292. if ($i == $on_page)
  14293. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14294. else
  14295. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14296. if ($i == ($page_width * $page_max))
  14297. break;
  14298. }
  14299. $page ['page'] = $page_c;
  14300. $page ['lower'] = (-- $on_page) * $page_size;
  14301. return $page;
  14302. }
  14303. /**
  14304. * 获取总页数
  14305. * @param unknown_type $table
  14306. * @param unknown_type $condition
  14307. */
  14308. public function get_table_count($table = "", $condition = "") {
  14309. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14310. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14311. // echo $sql;die;
  14312. $query = Doo::db ()->query ( $sql );
  14313. $result = $query->fetch ();
  14314. return $result ['count'];
  14315. }
  14316. /**
  14317. * 获取上一页
  14318. * @param unknown_type $on_page
  14319. */
  14320. function get_previous($on_page = 1) {
  14321. return $on_page != 0 ? $on_page - 1 : $on_page;
  14322. }
  14323. }
  14324. ?>