ReceiptController.php 531 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337
  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. Doo::loadModel ( 'verify' );
  154. $verify = new verify ();
  155. $receipt = new receipt ();
  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->find ( array (
  224. 'asArray' => true
  225. ) );
  226. foreach ( $veList as $key => $value ) {
  227. $v = json_decode ( $value ['staff'] );
  228. $list = array ();
  229. foreach ( $v as $n => $m ) {
  230. if ($m ['1'] == 'ROLE') {
  231. $roleInfo = $role->getOne ( array (
  232. 'where' => 'rid=' . $m [0],
  233. 'asArray' => true
  234. ) );
  235. $v [$n] [1] = $roleInfo ['name'];
  236. array_push ( $list, $roleInfo ['name'] );
  237. } else {
  238. array_push ( $list, $v [$n] [1] );
  239. }
  240. }
  241. $veList [$key] ['staff'] = implode ( '>', $list );
  242. }
  243. $data ['category'] = $lCategory->find ( array (
  244. 'asArray' => true
  245. ) );
  246. $data ['veList'] = $veList;
  247. $data ['acItem'] = $acItem;
  248. $data ['memu'] = "receipt";
  249. $data ['staff'] = $this->staff;
  250. $data ['receiptMemu'] = 'saeaBorad';
  251. $data ['verifyId'] = $this->verifyId;
  252. $data ['executeId'] = $this->executeId;
  253. $this->render ( "/admin/remitAdd", $data );
  254. }
  255. function remitAddDo() {
  256. $agency = $this->get_args ( 'agency' );
  257. $travel = $this->get_args ( 'travel' );
  258. $train = $this->get_args ( 'train' );
  259. $other = $this->get_args ( 'other' );
  260. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  261. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  262. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  263. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  264. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  265. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  266. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  267. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  268. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  269. // print_r($agency);die;
  270. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  271. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  272. header ( 'Content-Type:text/html;charset=utf-8' );
  273. die ( '请填写联行号' );
  274. }
  275. Doo::loadModel ( 'receipt' );
  276. Doo::loadModel ( 'receiptDetail' );
  277. Doo::loadModel ( 'accountItem' );
  278. $accountItem = new accountItem ();
  279. $receipt = new receipt ();
  280. Doo::loadModel ( 'enclosur' );
  281. Doo::loadModel ( 'execute' );
  282. $execute = new execute ();
  283. $executeDetail = $execute->getOne ( array (
  284. 'where' => 'mold="对公汇款执行人"',
  285. 'asArray' => true
  286. ) );
  287. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  288. $aItem = $accountItem->find ( array (
  289. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  290. 'asArray' => true
  291. ) );
  292. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  293. $ag = $tr = $ta = $ot = 0;
  294. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  295. foreach ( $aItem as $key => $value ) {
  296. if ($value ['category'] == $this->AGENCY) {
  297. if (isset ( $agency [$ag] )) {
  298. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  299. array_push ( $accountJson [$this->AGENCY], array (
  300. 'aid' => $value ['aid'],
  301. 'name' => $value ['name'],
  302. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  303. ) );
  304. $sum += $agency [$ag];
  305. $agencySum += $agency [$ag];
  306. }
  307. }
  308. $ag ++;
  309. }
  310. }
  311. $accountJson ['cSum'] = array (
  312. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  313. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  314. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  315. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  316. );
  317. // 报销单
  318. $receipt->accountItem = json_encode ( $accountJson );
  319. $receipt->staff = $this->staff [0] ['sid'];
  320. $receipt->sum = number_format ( $sum, 2, '.', '' );
  321. $receipt->date = date ( "Y-m-d" );
  322. $receipt->cid = $cid;
  323. $receipt->status = 5;
  324. $receipt->Rtype = 2;
  325. // 修改审批流程加入角色
  326. $receipt->verify = $verify;
  327. $receipt->executeCopy = $executeDetail ['staff'];
  328. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  329. $order = array (
  330. "\r\n",
  331. "\n",
  332. "\r"
  333. );
  334. $replace = '<br/>';
  335. $explanation = str_replace ( $order, $replace, $explanation );
  336. $receipt->explanation = $explanation;
  337. $receipt->remittanceName = $remittanceName;
  338. $receipt->bankName = $bankName;
  339. $receipt->bankNumber = $bankNumber;
  340. $receipt->remittanceBankType = $remittanceBankType;
  341. if ($remittanceBankType == 1)
  342. $receipt->coupletNumber = $coupletNumber;
  343. $rid = $receipt->insert ();
  344. // 附件
  345. if (! empty ( $enclosurName )) {
  346. $enclosurArray = explode ( '-', $enclosurName );
  347. foreach ( $enclosurArray as $value ) {
  348. $enclosur = new enclosur ();
  349. $enclosur->name = $value;
  350. $enclosur->rid = $rid;
  351. $enclosur->insert ();
  352. }
  353. // print_r($enclosurArray);die;
  354. }
  355. // 报销详情
  356. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  357. $receiptDetail = new receiptDetail ();
  358. $receiptDetail->staff = $this->staff [0] ['sid'];
  359. $receiptDetail->item = $value ['name'];
  360. $receiptDetail->itemCategory = $this->AGENCY;
  361. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  362. $receiptDetail->date = date ( "Y-m-d" );
  363. $receiptDetail->cid = $cid;
  364. $receiptDetail->rid = $rid;
  365. $receiptDetail->status = 4;
  366. $receiptDetail->insert ();
  367. }
  368. return "/saeaBorad";
  369. } else
  370. die ( 'illegal request' );
  371. }
  372. function remitEdit() {
  373. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  374. Doo::loadClass ( 'XDeode' );
  375. $XDeode = new XDeode ( 7 );
  376. $rid = $XDeode->decode ( $ridKey );
  377. if (! is_numeric ( $rid ))
  378. die ( 'illegal request' );
  379. Doo::loadModel ( 'accountItem' );
  380. Doo::loadModel ( 'verify' );
  381. Doo::loadModel ( 'receipt' );
  382. $receipt = new receipt ();
  383. $verify = new verify ();
  384. $accountItem = new accountItem ();
  385. Doo::loadModel ( 'L_category' );
  386. $lCategory = new L_category ();
  387. Doo::loadModel ( "role" );
  388. $role = new role ();
  389. Doo::loadModel ( 'enclosur' );
  390. $enclosur = new enclosur ();
  391. $receiptDetail = $receipt->getOne ( array (
  392. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  393. 'asArray' => true
  394. ) );
  395. if (empty ( $receiptDetail ))
  396. return "/saeaCreate";
  397. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  398. $acItem = $accountItem->find ( array (
  399. 'asArray' => true
  400. ) );
  401. $veList = $verify->find ( array (
  402. 'asArray' => true
  403. ) );
  404. foreach ( $veList as $key => $value ) {
  405. $v = json_decode ( $value ['staff'] );
  406. $list = array ();
  407. foreach ( $v as $n => $m ) {
  408. if ($m ['1'] == 'ROLE') {
  409. $roleInfo = $role->getOne ( array (
  410. 'where' => 'rid=' . $m [0],
  411. 'asArray' => true
  412. ) );
  413. $v [$n] [1] = $roleInfo ['name'];
  414. array_push ( $list, $roleInfo ['name'] );
  415. } else {
  416. array_push ( $list, $v [$n] [1] );
  417. }
  418. }
  419. $veList [$key] ['staff'] = implode ( '>', $list );
  420. }
  421. // 配置编辑信息
  422. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  423. foreach ( $acItem as $key => $value ) {
  424. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  425. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  426. $acItem [$key] ['price'] = $v ['price'];
  427. }
  428. }
  429. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  430. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  431. $acItem [$key] ['price'] = $v ['price'];
  432. }
  433. }
  434. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  435. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  436. $acItem [$key] ['price'] = $v ['price'];
  437. }
  438. }
  439. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  440. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  441. $acItem [$key] ['price'] = $v ['price'];
  442. }
  443. }
  444. }
  445. $data ['category'] = $lCategory->find ( array (
  446. 'asArray' => true
  447. ) );
  448. $data ['enclosurList'] = $enclosurList;
  449. $data ['cSum'] = $accountItemList ['cSum'];
  450. $data ['sum'] = $receiptDetail ['sum'];
  451. $data ['receiptDetail'] = $receiptDetail;
  452. $data ['veList'] = $veList;
  453. $data ['acItem'] = $acItem;
  454. $data ['memu'] = "receipt";
  455. $data ['staff'] = $this->staff;
  456. $data ['receiptMemu'] = 'saeaBorad';
  457. $data ['verify'] = $receiptDetail ['verify'];
  458. $data ['verifyId'] = $this->verifyId;
  459. $data ['executeId'] = $this->executeId;
  460. $data ['rid'] = $rid;
  461. $data ['ridKey'] = $ridKey;
  462. $this->render ( "/admin/remitEdit", $data );
  463. }
  464. function remitEdiDo() {
  465. $agency = $this->get_args ( 'agency' );
  466. $travel = $this->get_args ( 'travel' );
  467. $train = $this->get_args ( 'train' );
  468. $other = $this->get_args ( 'other' );
  469. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  470. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  471. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  472. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  473. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  474. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  475. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  476. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  477. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  478. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  479. Doo::loadClass ( 'XDeode' );
  480. $XDeode = new XDeode ( 7 );
  481. $rid = $XDeode->decode ( $ridKey );
  482. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  483. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  484. header ( 'Content-Type:text/html;charset=utf-8' );
  485. die ( '请填写联行号' );
  486. }
  487. Doo::loadModel ( 'receipt' );
  488. Doo::loadModel ( 'receiptDetail' );
  489. Doo::loadModel ( 'accountItem' );
  490. $accountItem = new accountItem ();
  491. $receipt = new receipt ();
  492. Doo::loadModel ( 'enclosur' );
  493. $enclosur = new enclosur ();
  494. Doo::loadModel ( 'execute' );
  495. $execute = new execute ();
  496. $executeDetail = $execute->getOne ( array (
  497. 'where' => 'mold="对公汇款执行人"',
  498. 'asArray' => true
  499. ) );
  500. $receiptDetail = $receipt->getOne ( array (
  501. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  502. 'asArray' => true
  503. ) );
  504. if (empty ( $receiptDetail ))
  505. return "/saeaBorad";
  506. $aItem = $accountItem->find ( array (
  507. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  508. 'asArray' => true
  509. ) );
  510. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  511. $ag = $tr = $ta = $ot = 0;
  512. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  513. foreach ( $aItem as $key => $value ) {
  514. if ($value ['category'] == $this->AGENCY) {
  515. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  516. array_push ( $accountJson [$this->AGENCY], array (
  517. 'aid' => $value ['aid'],
  518. 'name' => $value ['name'],
  519. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  520. ) );
  521. $sum += $agency [$ag];
  522. $agencySum += $agency [$ag];
  523. }
  524. $ag ++;
  525. }
  526. }
  527. $accountJson ['cSum'] = array (
  528. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  529. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  530. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  531. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  532. );
  533. // 报销单
  534. $rid = $receipt->rid = $receiptDetail ['rid'];
  535. $receipt->accountItem = json_encode ( $accountJson );
  536. $receipt->staff = $this->staff [0] ['sid'];
  537. $receipt->sum = number_format ( $sum, 2, '.', '' );
  538. $receipt->date = date ( "Y-m-d" );
  539. $receipt->cid = $cid;
  540. if ($receiptDetail ['Rtype'] == 1)
  541. $receipt->status = 7;
  542. else
  543. $receipt->status = 5;
  544. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  545. $receipt->verify = $verify;
  546. $receipt->executeCopy = $executeDetail ['staff'];
  547. $order = array (
  548. "\r\n",
  549. "\n",
  550. "\r"
  551. );
  552. $replace = '<br/>';
  553. $explanation = str_replace ( $order, $replace, $explanation );
  554. $receipt->explanation = $explanation;
  555. $receipt->remittanceName = $remittanceName;
  556. $receipt->bankName = $bankName;
  557. $receipt->bankNumber = $bankNumber;
  558. $receipt->remittanceBankType = $remittanceBankType;
  559. if ($remittanceBankType == 1)
  560. $receipt->coupletNumber = $coupletNumber;
  561. $receipt->update ();
  562. $receiptDetail = new receiptDetail ();
  563. $receiptDetail->delete ( array (
  564. 'where' => 'rid=' . $rid
  565. ) );
  566. // 报销详情
  567. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  568. $receiptDetail = new receiptDetail ();
  569. $receiptDetail->staff = $this->staff [0] ['sid'];
  570. $receiptDetail->item = $value ['name'];
  571. $receiptDetail->itemCategory = $this->AGENCY;
  572. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  573. $receiptDetail->date = date ( "Y-m-d" );
  574. $receiptDetail->cid = $cid;
  575. $receiptDetail->rid = $rid;
  576. $receiptDetail->status = 4;
  577. $receiptDetail->insert ();
  578. }
  579. // 附件
  580. if (! empty ( $enclosurName )) {
  581. $enclosurArray = explode ( '-', $enclosurName );
  582. foreach ( $enclosurArray as $value ) {
  583. $enclosur = new enclosur ();
  584. $enclosur->name = $value;
  585. $enclosur->rid = $rid;
  586. $enclosur->insert ();
  587. }
  588. }
  589. }
  590. return "/saeaBorad";
  591. }
  592. function remitApproval() {
  593. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  594. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  595. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  596. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  597. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  598. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  599. if (empty ( $status ))
  600. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  601. $vidList = array ();
  602. $button = 0;
  603. Doo::loadModel ( 'verify' );
  604. Doo::loadModel ( 'receipt' );
  605. Doo::loadModel ( 'staff' );
  606. $staff = new staff ();
  607. $receipt = new receipt ();
  608. $verify = new verify ();
  609. Doo::loadModel ( 'L_category' );
  610. $Lcategory = new L_category ();
  611. Doo::loadModel ( 'enclosur' );
  612. $enclosur = new enclosur ();
  613. // user verify ID
  614. $verifyDetail = $verify->find ( array (
  615. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  616. 'asArray' => true
  617. ) );
  618. foreach ( $verifyDetail as $key => $value ) {
  619. array_push ( $vidList, $value ['vid'] );
  620. }
  621. $vid = implode ( ",", $vidList );
  622. if (empty ( $verifyDetail ))
  623. $vid = 0;
  624. $categoryList = $Lcategory->find ( array (
  625. 'asArray' => true
  626. ) );
  627. $staffList = $staff->find ( array (
  628. 'where' => 'cid=' . $cid,
  629. 'asArray' => true
  630. ) );
  631. $ap = "";
  632. if ($status == 4) {
  633. $ap = 4;
  634. $status = 2;
  635. }
  636. // get Receipt By verifyID status 2
  637. $receiptList = $receipt->find ( array (
  638. 'where' => 'rid =' . $rid . ' and status=2',
  639. 'desc' => 'rid',
  640. 'asArray' => true
  641. ) );
  642. if (empty ( $receiptList )) {
  643. die ( 'illegal request' );
  644. }
  645. $Locate = 0;
  646. $roleId = 0;
  647. if ($ap == 4)
  648. $status = 4;
  649. foreach ( $receiptList as $key => $value ) {
  650. $receiptList [$key] ['Locate'] = $Locate;
  651. $Locate ++;
  652. $receiptList [$key] ['reviseDetail'] = array ();
  653. if (! empty ( $value ['reviseDetail'] ))
  654. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  655. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  656. $categoryDetil = $Lcategory->getOne ( array (
  657. 'where' => 'cid=' . $value ['cid'],
  658. 'asArray' => true
  659. ) );
  660. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  661. // 检测编辑状态
  662. $verifyList = $verify->getOne ( array (
  663. 'where' => 'vid=' . $value ['verify'],
  664. 'asArray' => true
  665. ) );
  666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  668. Doo::loadModel ( 'role' );
  669. $role = new role ();
  670. // print_r($verifyList);
  671. $flag = true;
  672. $roleKey = 0;
  673. $endStaffArray = array ();
  674. $roleArrayCopy = array ();
  675. foreach ( $verifyList as $k => $v ) {
  676. // init verifyStaff
  677. if ($v [1] == 'ROLE') {
  678. if (! empty ( $verifyStaff )) {
  679. $endStaffArray = end ( $verifyStaff );
  680. if ($v [0] == $endStaffArray ['nextStaff']) {
  681. $roleId = $v [0];
  682. }
  683. }
  684. $roleVerify = json_decode ( $v [3], true );
  685. $roleKey = $k;
  686. $roleArray = array ();
  687. $rolename = $role->getOne ( array (
  688. 'where' => 'rid=' . $v [0],
  689. 'asArray' => true
  690. ) );
  691. foreach ( $roleVerify as $o => $p ) {
  692. $staffID = explode ( '_', $p );
  693. $staffInfo = $staff->getOne ( array (
  694. 'where' => 'sid=' . $staffID [0],
  695. 'asArray' => true
  696. ) );
  697. // print_r($staffID);
  698. $exp = array (
  699. 0 => $staffInfo ['sid'],
  700. 1 => $staffID [1],
  701. 2 => $staffInfo ['avatar'],
  702. 'date' => '',
  703. 'date' => '',
  704. 'opinion' => '',
  705. 'status' => '',
  706. 'rolename' => $rolename ['name']
  707. );
  708. array_push ( $roleArray, $exp );
  709. }
  710. $roleArrayCopy [$v [0]] = $roleArray;
  711. // $verifyList[$k]['roleArray']=$roleArray;
  712. }
  713. // print_r($roleArray);
  714. $verifyList [$k] ['date'] = "";
  715. $verifyList [$k] ['opinion'] = "";
  716. $verifyList [$k] ['status'] = "";
  717. if (empty ( $verifyStaff )) {
  718. $verifyList [$k] ['date'] = "";
  719. $verifyList [$k] ['opinion'] = "";
  720. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  721. $verifyList [$k] ['status'] = 4;
  722. $button = 4;
  723. $flag = false;
  724. }
  725. } else {
  726. foreach ( $verifyStaff as $m => $u ) {
  727. if ($v [0] == $m) {
  728. $verifyList [$k] ['date'] = $u ['date'];
  729. $verifyList [$k] ['opinion'] = $u ['opinion'];
  730. $verifyList [$k] ['status'] = $u ['status'];
  731. $flag = false;
  732. break;
  733. }
  734. }
  735. $endStaffArray = end ( $verifyStaff );
  736. if (isset ( $endStaffArray ['ROLE'] )) {
  737. } else {
  738. $endKey = key ( $verifyStaff );
  739. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  740. $button = 4;
  741. $verifyList [$k] ['status'] = 4;
  742. }
  743. }
  744. }
  745. }
  746. $rolename ['name'] = '';
  747. if (! empty ( $roleId )) {
  748. Doo::loadModel ( 'role' );
  749. $role = new role ();
  750. $rolename = $role->getOne ( array (
  751. 'where' => 'rid=' . $roleId,
  752. 'asArray' => true
  753. ) );
  754. }
  755. if (! empty ( $verifyStaff ))
  756. $endStaffArray = end ( $verifyStaff );
  757. $KOP = false;
  758. foreach ( $roleArrayCopy as $P => $A ) {
  759. foreach ( $A as $MKI => $AVL ) {
  760. if (! empty ( $verifyStaff )) {
  761. // &&$rolename['rid']==$endStaffArray['nextStaff']
  762. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  763. $button = 4;
  764. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  765. }
  766. foreach ( $verifyStaff as $m => $u ) {
  767. $AVLFK = $AVL [0] . '_R';
  768. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  769. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  770. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  771. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  772. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  773. break;
  774. }
  775. }
  776. } else {
  777. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  778. $button = 4;
  779. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  780. }
  781. }
  782. // $roleArray[$MKI]['rolename']=$rolename['name'];
  783. $KOP = true;
  784. }
  785. }
  786. foreach ( $roleArrayCopy as $k => $v ) {
  787. foreach ( $verifyList as $m => $n ) {
  788. if ($n [0] == $k) {
  789. array_splice ( $verifyList, $m, 1, $v );
  790. }
  791. }
  792. }
  793. $receiptList [$key] ['verifyList'] = $verifyList;
  794. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  795. 'where' => 'sid=' . $value ['staff'],
  796. 'asArray' => true
  797. ) );
  798. $receiptList [$key] ['button'] = $button;
  799. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  800. }
  801. $mothHtml = "";
  802. for($i = 1; $i <= 12; $i ++) {
  803. if ($month == $i)
  804. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  805. else
  806. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  807. }
  808. // 获取审批日志
  809. Doo::loadModel ( 'receiptLog' );
  810. $receiptLog = new receiptLog ();
  811. $rlList = array ();
  812. $rlInfo = $receiptLog->getOne ( array (
  813. 'where' => 'rid=' . $rid . ' and status=4',
  814. 'asArray' => true
  815. ) );
  816. $tijdate = $receiptLog->getOne ( array (
  817. 'where' => 'rid=' . $rid . ' and status=2',
  818. 'asc' => 'rlid',
  819. 'asArray' => true
  820. ) );
  821. if (! empty ( $rlInfo )) {
  822. $rlList = $receiptLog->find ( array (
  823. 'where' => 'rid=' . $rid,
  824. 'asc' => 'rlid',
  825. 'asArray' => true
  826. ) );
  827. }
  828. $receiptList [0] ['rlList'] = $rlList;
  829. $enclosurList = $enclosur->find ( array (
  830. 'where' => 'rid=' . $rid,
  831. 'asArray' => true
  832. ) );
  833. $enclosurHtml = '';
  834. foreach ( $enclosurList as $value ) {
  835. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  836. }
  837. // print_r($receiptList);
  838. $data ['enclosurHtml'] = $enclosurHtml;
  839. $data ['rolename'] = $rolename ['name'];
  840. $data ['datetij'] = $tijdate ['date'];
  841. $data ['mothHtml'] = $mothHtml;
  842. $data ['rid'] = $rid;
  843. $data ['receiptList'] = $receiptList;
  844. $data ['receiptApprovalCount'] = count ( $receiptList );
  845. $data ['status'] = $status;
  846. $data ['year'] = $year;
  847. $data ['categoryList'] = $categoryList;
  848. $data ['staffList'] = $staffList;
  849. $data ['cid'] = $cid;
  850. $data ['sid'] = $sid;
  851. $data ['ap'] = $ap;
  852. $data ['memu'] = "receipt";
  853. $data ['staff'] = $this->staff;
  854. $data ['receiptMemu'] = 'approvalExpenses';
  855. $data ['verifyId'] = $this->verifyId;
  856. $data ['executeId'] = $this->executeId;
  857. $this->render ( "/admin/remitApproval", $data );
  858. }
  859. function saeaLoanAdd() {
  860. Doo::loadModel ( 'verify' );
  861. $verify = new verify ();
  862. Doo::loadModel ( "role" );
  863. $role = new role ();
  864. Doo::loadModel ( 'L_category' );
  865. $lCategory = new L_category ();
  866. $veList = $verify->find ( array (
  867. 'asArray' => true
  868. ) );
  869. foreach ( $veList as $key => $value ) {
  870. $v = json_decode ( $value ['staff'] );
  871. $list = array ();
  872. foreach ( $v as $n => $m ) {
  873. if ($m ['1'] == 'ROLE') {
  874. $roleInfo = $role->getOne ( array (
  875. 'where' => 'rid=' . $m [0],
  876. 'asArray' => true
  877. ) );
  878. $v [$n] [1] = $roleInfo ['name'];
  879. array_push ( $list, $roleInfo ['name'] );
  880. } else {
  881. array_push ( $list, $v [$n] [1] );
  882. }
  883. }
  884. $veList [$key] ['staff'] = implode ( '>', $list );
  885. }
  886. $data ['category'] = $lCategory->find ( array (
  887. 'asArray' => true
  888. ) );
  889. $data ['veList'] = $veList;
  890. $data ['memu'] = "receipt";
  891. $data ['staff'] = $this->staff;
  892. $data ['receiptMemu'] = 'saeaBorad';
  893. $data ['verifyId'] = $this->verifyId;
  894. $data ['executeId'] = $this->executeId;
  895. $this->render ( "/admin/saeaLoanAdd", $data );
  896. }
  897. function saeaLoanAddDo() {
  898. $agency = $this->get_args ( 'agency' );
  899. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  900. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  901. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  902. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  903. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  904. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  905. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  906. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  907. // die;
  908. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  909. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  910. header ( 'Content-Type:text/html;charset=utf-8' );
  911. die ( '请填写联行号' );
  912. }
  913. Doo::loadModel ( 'receipt' );
  914. Doo::loadModel ( 'receiptDetail' );
  915. Doo::loadModel ( 'accountItem' );
  916. $accountItem = new accountItem ();
  917. $receipt = new receipt ();
  918. Doo::loadModel ( 'loanReceipt' );
  919. $loanReceipt = new loanReceipt ();
  920. Doo::loadModel ( 'execute' );
  921. $execute = new execute ();
  922. Doo::loadModel ( 'enclosur' );
  923. $executeDetail = $execute->getOne ( array (
  924. 'where' => 'mold="借款执行人"',
  925. 'asArray' => true
  926. ) );
  927. $aItem = $accountItem->find ( array (
  928. 'asArray' => true
  929. ) );
  930. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  931. $ag = $tr = $ta = $ot = 0;
  932. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  933. array_push ( $accountJson ['借款费用'], array (
  934. 'aid' => 0,
  935. 'name' => '申请金额',
  936. 'price' => number_format ( $agency, 2, '.', '' )
  937. ) );
  938. $sum += $agency;
  939. $agencySum += $agency;
  940. $accountJson ['cSum'] = array (
  941. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  942. 'agencySum' => number_format ( 0, 2, '.', '' ),
  943. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  944. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  945. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  946. );
  947. // 借款数据备份
  948. $loanReceipt->loanItem = json_encode ( $accountJson );
  949. $loanReceipt->staff = $this->staff [0] ['sid'];
  950. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  951. $loanReceipt->date = date ( "Y-m-d" );
  952. $loanReceipt->cid = $cid;
  953. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  954. $loanReceipt->status = 5;
  955. $loanReceipt->Rtype = 1;
  956. $loanReceipt->verify = $verify;
  957. $receipt->receiptOrder = $receipt->receiptOrder;
  958. // 添加HTML换行符
  959. // var_dump($explanation);
  960. $order = array (
  961. "\r\n",
  962. "\n",
  963. "\r"
  964. );
  965. $replace = '<br/>';
  966. $explanation = str_replace ( $order, $replace, $explanation );
  967. // $explanation=str_replace('\r',"<br/>",$explanation);
  968. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  969. $loanReceipt->explanation = $explanation;
  970. $loanRid = $loanReceipt->insert ();
  971. // 报销单
  972. $receipt->loanItem = json_encode ( $accountJson );
  973. $receipt->staff = $this->staff [0] ['sid'];
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->date = date ( "Y-m-d" );
  976. $receipt->cid = $cid;
  977. // 特殊状态
  978. $receipt->status = 5;
  979. $receipt->Rtype = 1;
  980. $receipt->loanRid = $loanRid;
  981. // 修改审批流程加入角色
  982. $receipt->verify = $verify;
  983. $receipt->executeCopy = $executeDetail ['staff'];
  984. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  985. $receipt->explanation = $explanation;
  986. $receipt->remittanceName = $remittanceName;
  987. $receipt->bankName = $bankName;
  988. $receipt->bankNumber = $bankNumber;
  989. $receipt->remittanceBankType = $remittanceBankType;
  990. if ($remittanceBankType == 1)
  991. $receipt->coupletNumber = $coupletNumber;
  992. $rid = $receipt->insert ();
  993. return "/saeaBorad";
  994. } else
  995. die ( 'illegal request' );
  996. }
  997. function saeaLoanEdi() {
  998. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  999. Doo::loadClass ( 'XDeode' );
  1000. $XDeode = new XDeode ( 7 );
  1001. $rid = $XDeode->decode ( $ridKey );
  1002. if (! is_numeric ( $rid ))
  1003. die ( 'illegal request' );
  1004. Doo::loadModel ( 'verify' );
  1005. $verify = new verify ();
  1006. Doo::loadModel ( "role" );
  1007. $role = new role ();
  1008. Doo::loadModel ( 'L_category' );
  1009. $lCategory = new L_category ();
  1010. Doo::loadModel ( 'receipt' );
  1011. $receipt = new receipt ();
  1012. $receiptInfo = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'asArray' => true
  1015. ) );
  1016. $veList = $verify->find ( array (
  1017. 'asArray' => true
  1018. ) );
  1019. foreach ( $veList as $key => $value ) {
  1020. $v = json_decode ( $value ['staff'] );
  1021. $list = array ();
  1022. foreach ( $v as $n => $m ) {
  1023. if ($m ['1'] == 'ROLE') {
  1024. $roleInfo = $role->getOne ( array (
  1025. 'where' => 'rid=' . $m [0],
  1026. 'asArray' => true
  1027. ) );
  1028. $v [$n] [1] = $roleInfo ['name'];
  1029. array_push ( $list, $roleInfo ['name'] );
  1030. } else {
  1031. array_push ( $list, $v [$n] [1] );
  1032. }
  1033. }
  1034. $veList [$key] ['staff'] = implode ( '>', $list );
  1035. }
  1036. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1037. // print_r($receiptInfo);
  1038. $data ['receiptInfo'] = $receiptInfo;
  1039. $data ['category'] = $lCategory->find ( array (
  1040. 'asArray' => true
  1041. ) );
  1042. $data ['veList'] = $veList;
  1043. $data ['ridKey'] = $ridKey;
  1044. $data ['memu'] = "receipt";
  1045. $data ['staff'] = $this->staff;
  1046. $data ['receiptMemu'] = 'saeaBorad';
  1047. $data ['verifyId'] = $this->verifyId;
  1048. $data ['executeId'] = $this->executeId;
  1049. $this->render ( "/admin/saeaLoanEdi", $data );
  1050. }
  1051. function saeaLoanEdiDo() {
  1052. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1053. $agency = $this->get_args ( 'agency' );
  1054. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1055. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1056. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1057. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1058. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1059. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1060. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1061. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1062. // die;
  1063. Doo::loadClass ( 'XDeode' );
  1064. $XDeode = new XDeode ( 7 );
  1065. $rid = $XDeode->decode ( $ridKey );
  1066. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1067. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1068. header ( 'Content-Type:text/html;charset=utf-8' );
  1069. die ( '请填写联行号' );
  1070. }
  1071. Doo::loadModel ( 'receipt' );
  1072. Doo::loadModel ( 'receiptDetail' );
  1073. Doo::loadModel ( 'accountItem' );
  1074. $accountItem = new accountItem ();
  1075. $receipt = new receipt ();
  1076. Doo::loadModel ( 'loanReceipt' );
  1077. $loanReceipt = new loanReceipt ();
  1078. Doo::loadModel ( 'enclosur' );
  1079. Doo::loadModel ( 'execute' );
  1080. $execute = new execute ();
  1081. $executeDetail = $execute->getOne ( array (
  1082. 'where' => 'mold="借款执行人"',
  1083. 'asArray' => true
  1084. ) );
  1085. $receiptDetail = $receipt->getOne ( array (
  1086. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1087. 'asArray' => true
  1088. ) );
  1089. if (empty ( $receiptDetail ))
  1090. die ( '参数错误' );
  1091. $aItem = $accountItem->find ( array (
  1092. 'asArray' => true
  1093. ) );
  1094. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1095. $ag = $tr = $ta = $ot = 0;
  1096. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1097. array_push ( $accountJson ['借款费用'], array (
  1098. 'aid' => 0,
  1099. 'name' => '申请金额',
  1100. 'price' => number_format ( $agency, 2, '.', '' )
  1101. ) );
  1102. $sum += $agency;
  1103. $agencySum += $agency;
  1104. $accountJson ['cSum'] = array (
  1105. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1106. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1107. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1108. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1109. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1110. );
  1111. // 报销单
  1112. $receipt->loanItem = json_encode ( $accountJson );
  1113. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1114. $receipt->cid = $cid;
  1115. // 特殊状态
  1116. // 修改审批流程加入角色
  1117. if ($receiptDetail ['status'] != 4)
  1118. $receipt->verify = $verify;
  1119. $order = array (
  1120. "\r\n",
  1121. "\n",
  1122. "\r"
  1123. );
  1124. $replace = '<br/>';
  1125. $explanation = str_replace ( $order, $replace, $explanation );
  1126. $receipt->explanation = $explanation;
  1127. $receipt->remittanceName = $remittanceName;
  1128. $receipt->bankName = $bankName;
  1129. $receipt->bankNumber = $bankNumber;
  1130. $receipt->remittanceBankType = $remittanceBankType;
  1131. if ($remittanceBankType == 1)
  1132. $receipt->coupletNumber = $coupletNumber;
  1133. $receipt->update ( array (
  1134. 'where' => 'rid=' . $rid
  1135. ) );
  1136. // 借款数据更新
  1137. $loanReceipt->loanItem = json_encode ( $accountJson );
  1138. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1139. $loanReceipt->cid = $cid;
  1140. if ($receiptDetail ['status'] != 4)
  1141. $loanReceipt->verify = $verify;
  1142. $loanReceipt->explanation = $explanation;
  1143. $receipt->executeCopy = $executeDetail ['staff'];
  1144. $loanReceipt->update ( array (
  1145. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1146. ) );
  1147. }
  1148. return "/saeaBorad";
  1149. }
  1150. function saeaLoanReceiptAdd() {
  1151. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1152. Doo::loadModel ( 'receipt' );
  1153. $receipt = new receipt ();
  1154. Doo::loadModel ( 'loanReceipt' );
  1155. $loanReceipt = new loanReceipt ();
  1156. Doo::loadModel ( 'L_category' );
  1157. $Lcategory = new L_category ();
  1158. Doo::loadModel ( 'verify' );
  1159. Doo::loadModel ( 'statistics' );
  1160. $statistics = new statistics ();
  1161. $verify = new verify ();
  1162. Doo::loadModel ( 'staff' );
  1163. $staff = new staff ();
  1164. $receiptDetail = $receipt->getOne ( array (
  1165. 'where' => 'rid=' . $rid,
  1166. 'desc' => 'rid',
  1167. 'asArray' => true
  1168. ) );
  1169. $receiptList = $loanReceipt->find ( array (
  1170. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1171. 'desc' => 'rid',
  1172. 'asArray' => true
  1173. ) );
  1174. $Locate = 0;
  1175. $roleId = 0;
  1176. $button = 0;
  1177. foreach ( $receiptList as $key => $value ) {
  1178. $receiptList [$key] ['Locate'] = $Locate;
  1179. $Locate ++;
  1180. $receiptList [$key] ['reviseDetail'] = array ();
  1181. if (! empty ( $value ['reviseDetail'] ))
  1182. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1183. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1184. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1185. $categoryDetil = $Lcategory->getOne ( array (
  1186. 'where' => 'cid=' . $value ['cid'],
  1187. 'asArray' => true
  1188. ) );
  1189. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1190. // 检测编辑状态
  1191. $verifyList = $verify->getOne ( array (
  1192. 'where' => 'vid=' . $value ['verify'],
  1193. 'asArray' => true
  1194. ) );
  1195. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1196. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1197. Doo::loadModel ( 'role' );
  1198. $role = new role ();
  1199. $flag = true;
  1200. $roleKey = 0;
  1201. $endStaffArray = array ();
  1202. $roleArrayCopy = array ();
  1203. foreach ( $verifyList as $k => $v ) {
  1204. // init verifyStaff
  1205. if ($v [1] == 'ROLE') {
  1206. if (! empty ( $verifyStaff )) {
  1207. $endStaffArray = end ( $verifyStaff );
  1208. // if ($v[0]==$endStaffArray['nextStaff']){
  1209. // $roleId=$v[0];
  1210. // }
  1211. }
  1212. $roleVerify = json_decode ( $v [3], true );
  1213. $roleKey = $k;
  1214. $roleArray = array ();
  1215. $rolename = $role->getOne ( array (
  1216. 'where' => 'rid=' . $v [0],
  1217. 'asArray' => true
  1218. ) );
  1219. foreach ( $roleVerify as $o => $p ) {
  1220. $staffID = explode ( '_', $p );
  1221. $staffInfo = $staff->getOne ( array (
  1222. 'where' => 'sid=' . $staffID [0],
  1223. 'asArray' => true
  1224. ) );
  1225. // print_r($staffID);
  1226. $exp = array (
  1227. 0 => $staffInfo ['sid'],
  1228. 1 => $staffID [1],
  1229. 2 => $staffInfo ['avatar'],
  1230. 'date' => '',
  1231. 'date' => '',
  1232. 'opinion' => '',
  1233. 'status' => '',
  1234. 'rolename' => $rolename ['name']
  1235. );
  1236. array_push ( $roleArray, $exp );
  1237. }
  1238. $roleArrayCopy [$v [0]] = $roleArray;
  1239. // $verifyList[$k]['roleArray']=$roleArray;
  1240. }
  1241. $verifyList [$k] ['date'] = "";
  1242. $verifyList [$k] ['opinion'] = "";
  1243. $verifyList [$k] ['status'] = "";
  1244. if (empty ( $verifyStaff )) {
  1245. $verifyList [$k] ['date'] = "";
  1246. $verifyList [$k] ['opinion'] = "";
  1247. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1248. $verifyList [$k] ['status'] = 4;
  1249. $flag = false;
  1250. }
  1251. } else {
  1252. foreach ( $verifyStaff as $m => $u ) {
  1253. if ($v [0] == $m) {
  1254. $verifyList [$k] ['date'] = $u ['date'];
  1255. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1256. $verifyList [$k] ['status'] = $u ['status'];
  1257. $flag = false;
  1258. break;
  1259. }
  1260. }
  1261. $endStaffArray = end ( $verifyStaff );
  1262. if (isset ( $endStaffArray ['ROLE'] )) {
  1263. } else {
  1264. // $endKey=key($verifyStaff);
  1265. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1266. // $button=4;
  1267. // $verifyList[$k]['status']=4;
  1268. // }
  1269. }
  1270. }
  1271. }
  1272. $rolename ['name'] = '';
  1273. if (! empty ( $roleId )) {
  1274. Doo::loadModel ( 'role' );
  1275. $role = new role ();
  1276. $rolename = $role->getOne ( array (
  1277. 'where' => 'rid=' . $roleId,
  1278. 'asArray' => true
  1279. ) );
  1280. }
  1281. if (! empty ( $verifyStaff ))
  1282. $endStaffArray = end ( $verifyStaff );
  1283. $KOP = false;
  1284. foreach ( $roleArrayCopy as $P => $A ) {
  1285. foreach ( $A as $MKI => $AVL ) {
  1286. if (! empty ( $verifyStaff )) {
  1287. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1288. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1289. $button = 4;
  1290. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1291. }
  1292. foreach ( $verifyStaff as $m => $u ) {
  1293. $AVLFK = $AVL [0] . '_R';
  1294. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1295. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1296. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1297. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1298. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1299. break;
  1300. }
  1301. }
  1302. } else {
  1303. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1304. $button = 4;
  1305. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1306. }
  1307. }
  1308. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1309. $KOP = true;
  1310. }
  1311. }
  1312. foreach ( $roleArrayCopy as $k => $v ) {
  1313. foreach ( $verifyList as $m => $n ) {
  1314. if ($n [0] == $k) {
  1315. array_splice ( $verifyList, $m, 1, $v );
  1316. }
  1317. }
  1318. }
  1319. $receiptList [$key] ['verifyList'] = $verifyList;
  1320. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1321. 'where' => 'sid=' . $value ['staff'],
  1322. 'asArray' => true
  1323. ) );
  1324. $receiptList [$key] ['button'] = $button;
  1325. //
  1326. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1327. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1328. }
  1329. $data ['receiptList'] = $receiptList;
  1330. $data ['receiptDetail'] = $receiptDetail;
  1331. Doo::loadModel ( 'L_category' );
  1332. $lCategory = new L_category ();
  1333. Doo::loadModel ( 'accountItem' );
  1334. $accountItem = new accountItem ();
  1335. $acItem = $accountItem->find ( array (
  1336. 'asArray' => true
  1337. ) );
  1338. $veList = $verify->find ( array (
  1339. 'asArray' => true
  1340. ) );
  1341. foreach ( $veList as $key => $value ) {
  1342. $v = json_decode ( $value ['staff'] );
  1343. $list = array ();
  1344. foreach ( $v as $n => $m ) {
  1345. if ($m ['1'] == 'ROLE') {
  1346. $roleInfo = $role->getOne ( array (
  1347. 'where' => 'rid=' . $m [0],
  1348. 'asArray' => true
  1349. ) );
  1350. $v [$n] [1] = $roleInfo ['name'];
  1351. array_push ( $list, $roleInfo ['name'] );
  1352. } else {
  1353. array_push ( $list, $v [$n] [1] );
  1354. }
  1355. }
  1356. $veList [$key] ['staff'] = implode ( '>', $list );
  1357. }
  1358. $data ['rid'] = $rid;
  1359. $data ['category'] = $lCategory->find ( array (
  1360. 'asArray' => true
  1361. ) );
  1362. $data ['veList'] = $veList;
  1363. $data ['acItem'] = $acItem;
  1364. $data ['memu'] = "receipt";
  1365. $data ['staff'] = $this->staff;
  1366. $data ['receiptMemu'] = 'saeaBorad';
  1367. $data ['verifyId'] = $this->verifyId;
  1368. $data ['executeId'] = $this->executeId;
  1369. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1370. }
  1371. function saeaLoanReceiptAddDo() {
  1372. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1373. $agency = $this->get_args ( 'agency' );
  1374. $travel = $this->get_args ( 'travel' );
  1375. $train = $this->get_args ( 'train' );
  1376. $other = $this->get_args ( 'other' );
  1377. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1378. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1379. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1380. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1381. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1382. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1383. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1384. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1385. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1386. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1387. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1388. header ( 'Content-Type:text/html;charset=utf-8' );
  1389. die ( '请填写联行号' );
  1390. }
  1391. Doo::loadModel ( 'receipt' );
  1392. Doo::loadModel ( 'receiptDetail' );
  1393. Doo::loadModel ( 'accountItem' );
  1394. $accountItem = new accountItem ();
  1395. $receipt = new receipt ();
  1396. Doo::loadModel ( 'enclosur' );
  1397. Doo::loadModel ( 'execute' );
  1398. $execute = new execute ();
  1399. $executeDetail = $execute->getOne ( array (
  1400. 'where' => 'mold="借款费用执行人"',
  1401. 'asArray' => true
  1402. ) );
  1403. $receiptDet = $receipt->getOne ( array (
  1404. 'where' => 'rid=' . $rid,
  1405. 'asArray' => true
  1406. ) );
  1407. // if(!empty($receiptDetail))
  1408. // return "/referReceipt/".$receiptDetail['rid'];
  1409. $aItem = $accountItem->find ( array (
  1410. 'asArray' => true
  1411. ) );
  1412. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1413. $ag = $tr = $ta = $ot = 0;
  1414. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1415. foreach ( $aItem as $key => $value ) {
  1416. if ($value ['category'] == $this->AGENCY) {
  1417. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1418. array_push ( $accountJson [$this->AGENCY], array (
  1419. 'aid' => $value ['aid'],
  1420. 'name' => $value ['name'],
  1421. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1422. ) );
  1423. $sum += $agency [$ag];
  1424. $agencySum += $agency [$ag];
  1425. }
  1426. $ag ++;
  1427. }
  1428. if ($value ['category'] == $this->TRAVEL) {
  1429. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1430. array_push ( $accountJson [$this->TRAVEL], array (
  1431. 'aid' => $value ['aid'],
  1432. 'name' => $value ['name'],
  1433. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1434. ) );
  1435. $sum += $travel [$tr];
  1436. $travelSum += $travel [$tr];
  1437. }
  1438. $tr ++;
  1439. }
  1440. if ($value ['category'] == $this->TRAIN) {
  1441. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1442. array_push ( $accountJson [$this->TRAIN], array (
  1443. 'aid' => $value ['aid'],
  1444. 'name' => $value ['name'],
  1445. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1446. ) );
  1447. $sum += $train [$ta];
  1448. $trainSum += $train [$ta];
  1449. }
  1450. $ta ++;
  1451. }
  1452. if ($value ['category'] == $this->OTHER) {
  1453. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1454. array_push ( $accountJson [$this->OTHER], array (
  1455. 'aid' => $value ['aid'],
  1456. 'name' => $value ['name'],
  1457. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1458. ) );
  1459. $sum += $other [$ot];
  1460. $otherSum += $other [$ot];
  1461. }
  1462. $ot ++;
  1463. }
  1464. }
  1465. $accountJson ['cSum'] = array (
  1466. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1467. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1468. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1469. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1470. );
  1471. // 报销单
  1472. $receipt->accountItem = json_encode ( $accountJson );
  1473. $receipt->staff = $this->staff [0] ['sid'];
  1474. $receipt->loanSum = $receiptDet ['sum'];
  1475. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1476. $receipt->date = date ( "Y-m-d" );
  1477. $receipt->pastDate = '';
  1478. $receipt->cid = $cid;
  1479. $receipt->status = 7;
  1480. // 修改审批流程加入角色
  1481. $receipt->verify = $verify;
  1482. $receipt->verifyStaff = '';
  1483. $receipt->executeStaff = '';
  1484. $receipt->executeCopy = $executeDetail ['staff'];
  1485. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1486. $receipt->explanation = $explanation;
  1487. $receipt->remittanceName = $remittanceName;
  1488. $receipt->bankName = $bankName;
  1489. $receipt->bankNumber = $bankNumber;
  1490. $receipt->remittanceBankType = $remittanceBankType;
  1491. if ($remittanceBankType == 1)
  1492. $receipt->coupletNumber = $coupletNumber;
  1493. $receipt->update ( array (
  1494. 'where' => 'rid=' . $rid
  1495. ) );
  1496. // 附件
  1497. if (! empty ( $enclosurName )) {
  1498. $enclosurArray = explode ( '-', $enclosurName );
  1499. foreach ( $enclosurArray as $value ) {
  1500. $enclosur = new enclosur ();
  1501. $enclosur->name = $value;
  1502. $enclosur->rid = $rid;
  1503. $enclosur->insert ();
  1504. }
  1505. // print_r($enclosurArray);die;
  1506. }
  1507. // 报销详情
  1508. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1509. $receiptDetail = new receiptDetail ();
  1510. $receiptDetail->staff = $this->staff [0] ['sid'];
  1511. $receiptDetail->item = $value ['name'];
  1512. $receiptDetail->itemCategory = $this->AGENCY;
  1513. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1514. $receiptDetail->date = date ( "Y-m-d" );
  1515. $receiptDetail->cid = $cid;
  1516. $receiptDetail->rid = $rid;
  1517. $receiptDetail->status = 4;
  1518. $receiptDetail->insert ();
  1519. }
  1520. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1521. $receiptDetail = new receiptDetail ();
  1522. $receiptDetail->staff = $this->staff [0] ['sid'];
  1523. $receiptDetail->item = $value ['name'];
  1524. $receiptDetail->itemCategory = $this->TRAVEL;
  1525. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1526. $receiptDetail->date = date ( "Y-m-d" );
  1527. $receiptDetail->cid = $cid;
  1528. $receiptDetail->rid = $rid;
  1529. $receiptDetail->status = 4;
  1530. $receiptDetail->insert ();
  1531. }
  1532. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1533. $receiptDetail = new receiptDetail ();
  1534. $receiptDetail->staff = $this->staff [0] ['sid'];
  1535. $receiptDetail->item = $value ['name'];
  1536. $receiptDetail->itemCategory = $this->TRAIN;
  1537. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1538. $receiptDetail->date = date ( "Y-m-d" );
  1539. $receiptDetail->cid = $cid;
  1540. $receiptDetail->rid = $rid;
  1541. $receiptDetail->status = 4;
  1542. $receiptDetail->insert ();
  1543. }
  1544. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1545. $receiptDetail = new receiptDetail ();
  1546. $receiptDetail->staff = $this->staff [0] ['sid'];
  1547. $receiptDetail->item = $value ['name'];
  1548. $receiptDetail->itemCategory = $this->OTHER;
  1549. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1550. $receiptDetail->date = date ( "Y-m-d" );
  1551. $receiptDetail->cid = $cid;
  1552. $receiptDetail->rid = $rid;
  1553. $receiptDetail->status = 4;
  1554. $receiptDetail->insert ();
  1555. }
  1556. return "/saeaBorad";
  1557. }
  1558. return "/saeaLoanReceiptAdd/" . $rid;
  1559. }
  1560. function saeaLoanReceiptEdi() {
  1561. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1562. Doo::loadClass ( 'XDeode' );
  1563. $XDeode = new XDeode ( 7 );
  1564. $rid = $XDeode->decode ( $ridKey );
  1565. if (! is_numeric ( $rid ))
  1566. die ( 'illegal request' );
  1567. Doo::loadModel ( 'accountItem' );
  1568. Doo::loadModel ( 'verify' );
  1569. Doo::loadModel ( 'receipt' );
  1570. $receipt = new receipt ();
  1571. $verify = new verify ();
  1572. $accountItem = new accountItem ();
  1573. Doo::loadModel ( 'L_category' );
  1574. $Lcategory = new L_category ();
  1575. Doo::loadModel ( "role" );
  1576. $role = new role ();
  1577. Doo::loadModel ( 'loanReceipt' );
  1578. $loanReceipt = new loanReceipt ();
  1579. Doo::loadModel ( 'staff' );
  1580. $staff = new staff ();
  1581. $receiptDetail = $receipt->getOne ( array (
  1582. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1583. 'asArray' => true
  1584. ) );
  1585. if (empty ( $receiptDetail ))
  1586. return "/saeaBorad";
  1587. $receiptList = $loanReceipt->find ( array (
  1588. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1589. 'desc' => 'rid',
  1590. 'asArray' => true
  1591. ) );
  1592. $Locate = 0;
  1593. $roleId = 0;
  1594. $button = 0;
  1595. foreach ( $receiptList as $key => $value ) {
  1596. $receiptList [$key] ['Locate'] = $Locate;
  1597. $Locate ++;
  1598. $receiptList [$key] ['reviseDetail'] = array ();
  1599. if (! empty ( $value ['reviseDetail'] ))
  1600. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1601. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1602. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1603. $categoryDetil = $Lcategory->getOne ( array (
  1604. 'where' => 'cid=' . $value ['cid'],
  1605. 'asArray' => true
  1606. ) );
  1607. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1608. // 检测编辑状态
  1609. $verifyList = $verify->getOne ( array (
  1610. 'where' => 'vid=' . $value ['verify'],
  1611. 'asArray' => true
  1612. ) );
  1613. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1614. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1615. Doo::loadModel ( 'role' );
  1616. $role = new role ();
  1617. $flag = true;
  1618. $roleKey = 0;
  1619. $endStaffArray = array ();
  1620. $roleArrayCopy = array ();
  1621. foreach ( $verifyList as $k => $v ) {
  1622. // init verifyStaff
  1623. if ($v [1] == 'ROLE') {
  1624. if (! empty ( $verifyStaff )) {
  1625. $endStaffArray = end ( $verifyStaff );
  1626. // if ($v[0]==$endStaffArray['nextStaff']){
  1627. // $roleId=$v[0];
  1628. // }
  1629. }
  1630. $roleVerify = json_decode ( $v [3], true );
  1631. $roleKey = $k;
  1632. $roleArray = array ();
  1633. $rolename = $role->getOne ( array (
  1634. 'where' => 'rid=' . $v [0],
  1635. 'asArray' => true
  1636. ) );
  1637. foreach ( $roleVerify as $o => $p ) {
  1638. $staffID = explode ( '_', $p );
  1639. $staffInfo = $staff->getOne ( array (
  1640. 'where' => 'sid=' . $staffID [0],
  1641. 'asArray' => true
  1642. ) );
  1643. // print_r($staffID);
  1644. $exp = array (
  1645. 0 => $staffInfo ['sid'],
  1646. 1 => $staffID [1],
  1647. 2 => $staffInfo ['avatar'],
  1648. 'date' => '',
  1649. 'date' => '',
  1650. 'opinion' => '',
  1651. 'status' => '',
  1652. 'rolename' => $rolename ['name']
  1653. );
  1654. array_push ( $roleArray, $exp );
  1655. }
  1656. $roleArrayCopy [$v [0]] = $roleArray;
  1657. // $verifyList[$k]['roleArray']=$roleArray;
  1658. }
  1659. $verifyList [$k] ['date'] = "";
  1660. $verifyList [$k] ['opinion'] = "";
  1661. $verifyList [$k] ['status'] = "";
  1662. if (empty ( $verifyStaff )) {
  1663. $verifyList [$k] ['date'] = "";
  1664. $verifyList [$k] ['opinion'] = "";
  1665. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1666. $verifyList [$k] ['status'] = 4;
  1667. $flag = false;
  1668. }
  1669. } else {
  1670. foreach ( $verifyStaff as $m => $u ) {
  1671. if ($v [0] == $m) {
  1672. $verifyList [$k] ['date'] = $u ['date'];
  1673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1674. $verifyList [$k] ['status'] = $u ['status'];
  1675. $flag = false;
  1676. break;
  1677. }
  1678. }
  1679. $endStaffArray = end ( $verifyStaff );
  1680. if (isset ( $endStaffArray ['ROLE'] )) {
  1681. } else {
  1682. // $endKey=key($verifyStaff);
  1683. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1684. // $button=4;
  1685. // $verifyList[$k]['status']=4;
  1686. // }
  1687. }
  1688. }
  1689. }
  1690. $rolename ['name'] = '';
  1691. if (! empty ( $roleId )) {
  1692. Doo::loadModel ( 'role' );
  1693. $role = new role ();
  1694. $rolename = $role->getOne ( array (
  1695. 'where' => 'rid=' . $roleId,
  1696. 'asArray' => true
  1697. ) );
  1698. }
  1699. if (! empty ( $verifyStaff ))
  1700. $endStaffArray = end ( $verifyStaff );
  1701. $KOP = false;
  1702. foreach ( $roleArrayCopy as $P => $A ) {
  1703. foreach ( $A as $MKI => $AVL ) {
  1704. if (! empty ( $verifyStaff )) {
  1705. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1706. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1707. $button = 4;
  1708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1709. }
  1710. foreach ( $verifyStaff as $m => $u ) {
  1711. $AVLFK = $AVL [0] . '_R';
  1712. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1713. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1714. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1715. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1716. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1717. break;
  1718. }
  1719. }
  1720. } else {
  1721. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1722. $button = 4;
  1723. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1724. }
  1725. }
  1726. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1727. $KOP = true;
  1728. }
  1729. }
  1730. foreach ( $roleArrayCopy as $k => $v ) {
  1731. foreach ( $verifyList as $m => $n ) {
  1732. if ($n [0] == $k) {
  1733. array_splice ( $verifyList, $m, 1, $v );
  1734. }
  1735. }
  1736. }
  1737. $receiptList [$key] ['verifyList'] = $verifyList;
  1738. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1739. 'where' => 'sid=' . $value ['staff'],
  1740. 'asArray' => true
  1741. ) );
  1742. $receiptList [$key] ['button'] = $button;
  1743. //
  1744. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1745. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1746. }
  1747. $data ['receiptList'] = $receiptList;
  1748. $acItem = $accountItem->find ( array (
  1749. 'asArray' => true
  1750. ) );
  1751. $veList = $verify->find ( array (
  1752. 'asArray' => true
  1753. ) );
  1754. foreach ( $veList as $key => $value ) {
  1755. $v = json_decode ( $value ['staff'] );
  1756. $list = array ();
  1757. foreach ( $v as $n => $m ) {
  1758. if ($m ['1'] == 'ROLE') {
  1759. $roleInfo = $role->getOne ( array (
  1760. 'where' => 'rid=' . $m [0],
  1761. 'asArray' => true
  1762. ) );
  1763. $v [$n] [1] = $roleInfo ['name'];
  1764. array_push ( $list, $roleInfo ['name'] );
  1765. } else {
  1766. array_push ( $list, $v [$n] [1] );
  1767. }
  1768. }
  1769. $veList [$key] ['staff'] = implode ( '>', $list );
  1770. }
  1771. // 配置编辑信息
  1772. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1773. foreach ( $acItem as $key => $value ) {
  1774. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1775. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1776. $acItem [$key] ['price'] = $v ['price'];
  1777. }
  1778. }
  1779. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1780. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1781. $acItem [$key] ['price'] = $v ['price'];
  1782. }
  1783. }
  1784. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1785. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1786. $acItem [$key] ['price'] = $v ['price'];
  1787. }
  1788. }
  1789. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1790. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1791. $acItem [$key] ['price'] = $v ['price'];
  1792. }
  1793. }
  1794. }
  1795. $data ['category'] = $Lcategory->find ( array (
  1796. 'asArray' => true
  1797. ) );
  1798. $data ['ridKey'] = $ridKey;
  1799. $data ['cSum'] = $accountItemList ['cSum'];
  1800. $data ['sum'] = $receiptDetail ['sum'];
  1801. $data ['receiptDetail'] = $receiptDetail;
  1802. $data ['veList'] = $veList;
  1803. $data ['acItem'] = $acItem;
  1804. $data ['memu'] = "receipt";
  1805. $data ['staff'] = $this->staff;
  1806. $data ['receiptMemu'] = 'saeaBorad';
  1807. $data ['verify'] = $receiptDetail ['verify'];
  1808. $data ['verifyId'] = $this->verifyId;
  1809. $data ['executeId'] = $this->executeId;
  1810. $data ['rid'] = $rid;
  1811. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1812. }
  1813. /**
  1814. * 培训班结算
  1815. */
  1816. function receiptTrainAdd() {
  1817. Doo::loadModel ( 'accountItem' );
  1818. $accountItem = new accountItem ();
  1819. $acItem = $accountItem->find ( array (
  1820. 'asArray' => true
  1821. ) );
  1822. // 审批组
  1823. Doo::loadModel ( 'verify' );
  1824. $verify = new verify ();
  1825. $veList = $verify->getVerifyByAll ();
  1826. // 办事处
  1827. Doo::loadModel ( 'L_category' );
  1828. $lCategory = new L_category ();
  1829. $data ['category'] = $lCategory->getCategory ();
  1830. $data ['veList'] = $veList;
  1831. $data ['memu'] = "receipt";
  1832. $data ['staff'] = $this->staff;
  1833. $data ['acItem'] = $acItem;
  1834. $data ['receiptMemu'] = 'saeaBorad';
  1835. $data ['verifyId'] = $this->verifyId;
  1836. $data ['executeId'] = $this->executeId;
  1837. $this->render ( "/receipt/receiptTrainAdd", $data );
  1838. }
  1839. /**
  1840. * 添加培训班结算
  1841. */
  1842. function receiptTrainAddDo() {//include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1843. // 培训班信息
  1844. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  1845. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  1846. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  1847. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  1848. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  1849. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  1850. // 发票信息
  1851. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1852. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  1853. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1854. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1855. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1856. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1857. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1858. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  1859. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1860. header ( 'Content-Type:text/html;charset=utf-8' );
  1861. die ( '请填写联行号' );
  1862. }
  1863. Doo::loadModel ( 'execute' );
  1864. $execute = new execute ();
  1865. $executeDetail = $execute->getOne ( array (
  1866. 'where' => 'mold="培训班结算"',
  1867. 'asArray' => true
  1868. ) );
  1869. if (empty ( $executeDetail )) {
  1870. header ( 'Content-Type:text/html;charset=utf-8' );
  1871. die ( '未设置执行人' );
  1872. }
  1873. Doo::loadClass ( 'XDeode' );
  1874. $XDeode = new XDeode ( 5 );
  1875. $cid = $XDeode->decode ( $cid );
  1876. Doo::loadModel ( 'receipt' );
  1877. $receipt = new receipt ();
  1878. Doo::loadModel ( 'receiptTraining' );
  1879. $receiptTraining = new receiptTraining ();
  1880. // 创建费用培训班
  1881. $item = array (
  1882. 'cid' => $this->staff [0] ['cid'],
  1883. 'categoryName' => $this->staff [0] ['category'],
  1884. 'trainName' => $trainName,
  1885. 'trainStartDate' => $trainStartDate,
  1886. 'trainEndDate' => $trainEndDate,
  1887. 'participants' => $participants,
  1888. 'trainAddress' => $trainAddress,
  1889. 'trainRemarks' => $trainRemarks,
  1890. 'creator' => $this->staff [0] ['sid'],
  1891. 'creatorDate' => date ( "Y-m-d H:i:s" )
  1892. );
  1893. $irid = $receiptTraining->addReceiptTraining ( $item );
  1894. // 报销单
  1895. $receipt->status = 5;
  1896. $receipt->trainId = $irid;
  1897. $receipt->Rtype = 3;
  1898. $receipt->staff = $this->staff [0] ['sid'];
  1899. $receipt->cid = $cid;
  1900. $receipt->verify = $verify;
  1901. $receipt->date = date ( "Y-m-d" );
  1902. $receipt->executeCopy = $executeDetail ['staff'];
  1903. $receipt->receiptOrder = "#P" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  1904. $receipt->remittanceName = $remittanceName;
  1905. $receipt->bankName = $bankName;
  1906. $receipt->bankNumber = $bankNumber;
  1907. $receipt->remittanceBankType = $remittanceBankType;
  1908. if ($remittanceBankType == 1)
  1909. $receipt->coupletNumber = $coupletNumber;
  1910. $rid = $receipt->insert ();
  1911. $XDeode = new XDeode ( 7 );
  1912. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html";
  1913. } else
  1914. die ( 'illegal request' );
  1915. }
  1916. /**
  1917. * 培训班编辑
  1918. */
  1919. function receiptTrainEdi() {
  1920. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  1921. $trainEdiType = $this->get_args ( 'trainEdiType' ) ? $this->get_args ( 'trainEdiType' ) : "INFO";
  1922. Doo::loadClass ( 'XDeode' );
  1923. $XDeode = new XDeode ( 7 );
  1924. $rid = $XDeode->decode ( $ridKey );
  1925. if (! is_numeric ( $rid ))
  1926. die ( 'illegal request' );
  1927. Doo::loadModel ( 'receipt' );
  1928. $receipt = new receipt ();
  1929. Doo::loadModel ( 'receiptTraining' );
  1930. $receiptTraining = new receiptTraining ();
  1931. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  1932. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)){
  1933. die ('illegal request--status');
  1934. }
  1935. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  1936. // 汇总表合计
  1937. // 收入合计--加入开票合计
  1938. Doo::loadModel ( 'invoiceTraining' );
  1939. $invoiceTraining = new invoiceTraining ();
  1940. $invoiceTrainingDetail = array (
  1941. 'invoiceArriveAmount' => 0,
  1942. 'RIAmount' => 0,
  1943. 'invoiceTotalAmount' => 0,
  1944. 'invoiceCompanyAmount'=>0
  1945. );
  1946. if ($receiptDetail ['invoiceTrainId'] != 0) {
  1947. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  1948. }
  1949. // print_r($invoiceTrainingDetail);
  1950. $invoiceArriveAmount = $RIAmount = 0;
  1951. if (! empty ( $invoiceTrainingDetail )) {
  1952. $invoiceArriveAmount = $invoiceTrainingDetail ['invoiceArriveAmount'];
  1953. $RIAmount = $invoiceTrainingDetail ['RIAmount'];
  1954. }
  1955. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  1956. //print_r($invoiceTrainingDetail);
  1957. // 支出项目
  1958. Doo::loadModel ( 'accountItem' );
  1959. $accountItem = new accountItem ();
  1960. // 项目金额合计
  1961. Doo::loadModel ( 'RItem' );
  1962. $RItem = new RItem ();
  1963. // 讲师获得
  1964. Doo::loadModel ( 'RILecturer' );
  1965. $RILecturer = new RILecturer ();
  1966. $RItemList = $RItem->getRItemByRid ( $rid );
  1967. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  1968. // 支出项金额详情
  1969. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, $invoiceArriveAmount );
  1970. // print_r($aiData);
  1971. // 利润
  1972. $profit=$invoiceArriveAmount - $aiData ['total'];
  1973. $companyProfit=$profit * 0.6;
  1974. $categoryProfit=$profit * 0.4;
  1975. $data ['profit'] = number_format ( $profit, 2 );
  1976. $data ['companyProfit'] = number_format ($companyProfit, 2, '.', '' );
  1977. $data ['categoryProfit'] = number_format ( $categoryProfit, 2, '.', '' );
  1978. //发票利润
  1979. $data ['invoiceProfit'] = $invoiceTrainingDetail ['invoiceTotalAmount'] - $aiData ['total'];
  1980. $data ['invoiceCompanyProfit'] = $data ['invoiceProfit'] * 0.6;//发票公司利润
  1981. $data ['invoiceCategoryProfit'] = $data ['invoiceProfit'] * 0.4;
  1982. // print_r($aiData['dataList']);
  1983. $categoryActualExpenditure= $aiData ['total'] - $aiData ['categoryActualExpenditure'];
  1984. $data ['categoryActualExpenditure'] = number_format ( $categoryActualExpenditure, 2 );
  1985. // 备用金
  1986. $sum = 0;
  1987. $data ['receiptLoanDetail'] = array (
  1988. 'sum' => '0.00'
  1989. );
  1990. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  1991. $data ['receiptLoanDetail'] = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  1992. $sum = $data ['receiptLoanDetail'] ['sum'];
  1993. }
  1994. $payment=$sum + $RIAmount - $categoryActualExpenditure;
  1995. $data ['payment'] = number_format ( $payment, 2 );
  1996. $data ['total'] = number_format ( $aiData ['total'], 2 );
  1997. $data ['aiCount'] = count ( $aiData ['dataList'] ) + 5;
  1998. $data ['aiList'] = $aiData ['dataList'];
  1999. // 占比计算
  2000. if ($invoiceArriveAmount != 0) {
  2001. $data ['totalProportion'] = number_format ( $aiData ['total'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2002. $data ['profitProportion'] = number_format ( $profit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2003. $data ['sumProportion'] = number_format ( $sum / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2004. $data ['invoiceTotalAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2005. $data ['RIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2006. $data ['companyProfitProportion'] = number_format ( $companyProfit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2007. $data ['categoryProportion'] = number_format ( $categoryProfit / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2008. $data ['categoryActualExpenditureProportion'] = number_format ( $categoryActualExpenditure / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2009. $data ['paymentProportion'] = number_format ( $payment / $invoiceArriveAmount, 2, '.', '' ) * 100;
  2010. } else {
  2011. $data ['totalProportion'] = $data ['profitProportion'] = $data ['sumProportion'] = $data ['invoiceTotalAmountProportion'] = $data ['RIAmountProportion'] = $data ['companyProfitProportion'] = $data ['categoryActualExpenditureProportion'] = $data ['paymentProportion'] = $data ['categoryProportion'] = 0;
  2012. }
  2013. //发票金额占比计算
  2014. if ($invoiceTrainingDetail ['invoiceTotalAmount'] != 0) {
  2015. //支出
  2016. $data ['invoicetotalProportion'] = number_format ( $aiData ['total'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100;
  2017. //利润
  2018. $data ['invoiceprofitProportion'] = number_format ( $data ['invoiceProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100;
  2019. //公司利润
  2020. $data ['invoicecompanyProfitProportion'] = number_format ( $data ['invoiceCompanyProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100;
  2021. //办事处利润
  2022. $data ['invoicecategoryProportion'] = number_format ( $data ['invoiceCategoryProfit'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 4, '.', '' ) * 100;
  2023. //公司收款
  2024. $data ['invoiceTotalAmountProportionB'] = number_format ( $data ['invoiceTrainingDetail'] ['invoiceCompanyAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100;
  2025. //备用金
  2026. $data ['invoicesumProportion'] = number_format ( $sum / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100;
  2027. //办事处收款
  2028. $data ['invoiceRIAmountProportion'] = number_format ( $data ['invoiceTrainingDetail'] ['RIAmount'] / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100;
  2029. //办事处实际支出
  2030. $data ['ICAEP'] = number_format ( $categoryActualExpenditure / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100;
  2031. //付总部款
  2032. $data ['invoicepaymentProportion'] = number_format ( $payment / $invoiceTrainingDetail ['invoiceTotalAmount'], 2, '.', '' ) * 100;
  2033. }else{
  2034. $data ['invoiceprofitProportion'] =$data ['invoiceRIAmountProportion'] =$data ['invoicetotalProportion'] =$data ['invoiceTotalAmountProportionB'] =$data ['invoicesumProportion'] =$data ['ICAEP'] =$data ['invoicepaymentProportion'] =$data ['invoicecompanyProfitProportion'] =$data ['invoicecategoryProportion'] =0;
  2035. }
  2036. //讲师人数
  2037. Doo::loadModel ( 'RILecturer' );
  2038. $RILecturer = new RILecturer ();
  2039. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2040. $data['lectureCount']=count($RILecturerList);
  2041. // 审批组
  2042. Doo::loadModel ( 'verify' );
  2043. $verify = new verify ();
  2044. $veList = $verify->getVerifyByAll ();
  2045. // 办事处
  2046. Doo::loadModel ( 'L_category' );
  2047. $lCategory = new L_category ();
  2048. $data ['category'] = $lCategory->getCategory ();
  2049. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2050. $data ['receiptDetail'] = $receiptDetail;
  2051. $data ['veList'] = $veList;
  2052. $data ['trainEdiType'] = $trainEdiType;
  2053. $data ['ridKey'] = $ridKey;
  2054. $data ['memu'] = "receipt";
  2055. $data ['staff'] = $this->staff;
  2056. $data ['receiptMemu'] = 'saeaBorad';
  2057. $data ['verifyId'] = $this->verifyId;
  2058. $data ['executeId'] = $this->executeId;
  2059. $this->render ( "/receipt/receiptTrainEdi", $data );
  2060. }
  2061. /**
  2062. * 培训班借款编辑
  2063. */
  2064. function receiptTrainLoanEdi() {
  2065. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2066. Doo::loadClass ( 'XDeode' );
  2067. $XDeode = new XDeode ( 7 );
  2068. $rid = $XDeode->decode ( $ridKey );
  2069. if (! is_numeric ( $rid ))
  2070. die ( 'illegal request' );
  2071. Doo::loadModel ( 'receipt' );
  2072. $receipt = new receipt ();
  2073. Doo::loadModel ( 'receiptTraining' );
  2074. $receiptTraining = new receiptTraining ();
  2075. Doo::loadModel ( 'verify' );
  2076. $verify = new verify ();
  2077. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2078. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2079. die ();
  2080. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2081. // 借款详情HTML
  2082. // 获得借款信息
  2083. $receiptLoanHtml = '';
  2084. if (! empty ( $receiptDetail ['trainLoanRid'] )) {
  2085. $receiptLoanDetail = $receipt->getReceiptByRid ( $receiptDetail ['trainLoanRid'] );
  2086. // 获得某费用单审批信息
  2087. $verifylist = $verify->getVerifyByRid ( $receiptDetail ['trainLoanRid'] );
  2088. Doo::loadClass ( 'receipt.func' );
  2089. $extendHtml = '<p><a class="button" href="javascript:if(window.confirm(\'确认移除?\'))window.location=\'/receiptTrainLoanRemoveDo/' . $receiptDetail ['ridKey'] . '/' . $receiptDetail ['trainLoanRidKey'] . '.html\'" data-toggle="modal">移除借款</a></p>';
  2090. $receiptLoanHtml = _getReceiptLoanHtml ( $receiptLoanDetail, $verifylist, $extendHtml );
  2091. }
  2092. $data ['receiptLoanHtml'] = $receiptLoanHtml;
  2093. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2094. $data ['receiptDetail'] = $receiptDetail;
  2095. $data ['trainEdiType'] = "LOAN";
  2096. $data ['ridKey'] = $ridKey;
  2097. $data ['memu'] = "receipt";
  2098. $data ['staff'] = $this->staff;
  2099. $data ['receiptMemu'] = 'saeaBorad';
  2100. $data ['verifyId'] = $this->verifyId;
  2101. $data ['executeId'] = $this->executeId;
  2102. $this->render ( "/receipt/receiptTrainLoanEdi", $data );
  2103. }
  2104. /**
  2105. * 更新培训班结算基本信息
  2106. */
  2107. function receiptTrainInfoEdiDo() {
  2108. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  2109. $rtid = $this->get_args ( 'rtid' ) ? $this->get_args ( 'rtid' ) : "";
  2110. // 培训班信息
  2111. $trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
  2112. $trainStartDate = $this->get_args ( 'trainStartDate' ) ? $this->get_args ( 'trainStartDate' ) : "";
  2113. $trainEndDate = $this->get_args ( 'trainEndDate' ) ? $this->get_args ( 'trainEndDate' ) : "";
  2114. $participants = $this->get_args ( 'participants' ) && is_numeric ( $this->get_args ( 'participants' ) ) ? $this->get_args ( 'participants' ) : 0;
  2115. $trainAddress = $this->get_args ( 'trainAddress' ) ? $this->get_args ( 'trainAddress' ) : "";
  2116. $trainRemarks = $this->get_args ( 'trainRemarks' ) ? $this->get_args ( 'trainRemarks' ) : "";
  2117. // 发票信息
  2118. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  2119. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2120. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  2121. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  2122. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  2123. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  2124. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  2125. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber ) && ! empty ( $trainName ) && ! empty ( $trainStartDate ) && ! empty ( $trainEndDate ) && ! empty ( $participants ) && ! empty ( $trainAddress )) {
  2126. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  2127. header ( 'Content-Type:text/html;charset=utf-8' );
  2128. die ( '请填写联行号' );
  2129. }
  2130. Doo::loadClass ( 'XDeode' );
  2131. $XDeode = new XDeode ( 5 );
  2132. $cid = $XDeode->decode ( $cid );
  2133. $rtid = $XDeode->decode ( $rtid );
  2134. $rid = $XDeode->decode ( $rid );
  2135. if (! is_numeric ( $rtid ) || ! is_numeric ( $rid )) {
  2136. die ( 'illegal request-IdError' );
  2137. }
  2138. Doo::loadModel ( 'receipt' );
  2139. $receipt = new receipt ();
  2140. Doo::loadModel ( 'receiptTraining' );
  2141. $receiptTraining = new receiptTraining ();
  2142. // 更新费用培训班
  2143. $item = array (
  2144. 'rtid' => $rtid,
  2145. 'trainName' => $trainName,
  2146. 'trainStartDate' => $trainStartDate,
  2147. 'trainEndDate' => $trainEndDate,
  2148. 'participants' => $participants,
  2149. 'trainAddress' => $trainAddress,
  2150. 'trainRemarks' => $trainRemarks
  2151. );
  2152. $irid = $receiptTraining->setReceiptTrainByCondition ( $item );
  2153. // 报销单
  2154. $receipt->rid = $rid;
  2155. $receipt->cid = $cid;
  2156. $receipt->verify = $verify;
  2157. $receipt->remittanceName = $remittanceName;
  2158. $receipt->bankName = $bankName;
  2159. $receipt->bankNumber = $bankNumber;
  2160. $receipt->remittanceBankType = $remittanceBankType;
  2161. if ($remittanceBankType == 1)
  2162. $receipt->coupletNumber = $coupletNumber;
  2163. $receipt->update ();
  2164. $XDeode = new XDeode ( 7 );
  2165. return "/receiptTrainEdi/" . $XDeode->encode ( $rid ) . ".html?trainEdiType=INFO";
  2166. } else
  2167. die ( 'illegal request' );
  2168. }
  2169. /**
  2170. * 编辑培训班结算---更新借款
  2171. */
  2172. function receiptTrainLoanEdiDo() {
  2173. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2174. $ridLoanKey = $this->get_args ( 'ridLoanKey' ) ? $this->get_args ( 'ridLoanKey' ) : "";
  2175. if (! empty ( $ridKey ) && ! empty ( $ridLoanKey )) {
  2176. Doo::loadModel ( 'receipt' );
  2177. $receipt = new receipt ();
  2178. Doo::loadClass ( 'XDeode' );
  2179. $XDeode = new XDeode ( 5 );
  2180. $rid = $XDeode->decode ( $ridKey );
  2181. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2182. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2183. die ( 'illegal request-ridError' );
  2184. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2185. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2186. // 不合法的数据if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2187. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2188. die ( 'illegal request-receiptError' );
  2189. }
  2190. if ($receiptLoanDetail ['status'] != 8 || $receiptLoanDetail ['Rtype'] != 1) {
  2191. die ( 'illegal request-receipLoantError' );
  2192. }
  2193. // 培训班结算挂钩借款
  2194. $receipt = new receipt ();
  2195. $item = array (
  2196. 'rid' => $rid,
  2197. 'trainLoanRid' => $ridLoan
  2198. );
  2199. $receipt->setReceiptByCondition ( $item );
  2200. // 更新借款状态变成已挂钩
  2201. $receipt = new receipt ();
  2202. $item = array (
  2203. 'rid' => $ridLoan,
  2204. 'status' => 10,
  2205. 'statusTrain' => 1
  2206. );
  2207. $receipt->setReceiptByCondition ( $item );
  2208. $XDeode = new XDeode ( 7 );
  2209. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2210. } else
  2211. die ( 'illegal request' );
  2212. }
  2213. /**
  2214. * 编辑培训班结算--移除借款
  2215. */
  2216. function receiptTrainLoanRemoveDo() {
  2217. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : 0;
  2218. $ridLoanKey = isset ( $this->params ['ridLoanKey'] ) ? $this->params ['ridLoanKey'] : 0;
  2219. if (! empty ( $ridKey ) || ! empty ( $ridLoanKey )) {
  2220. Doo::loadModel ( 'receipt' );
  2221. $receipt = new receipt ();
  2222. Doo::loadClass ( 'XDeode' );
  2223. $XDeode = new XDeode ( 5 );
  2224. $rid = $XDeode->decode ( $ridKey );
  2225. $ridLoan = $XDeode->decode ( $ridLoanKey );
  2226. if (! is_numeric ( $rid ) || ! is_numeric ( $ridLoan ))
  2227. die ( 'illegal request-ridError' );
  2228. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2229. $receiptLoanDetail = $receipt->getReceiptByRid ( $ridLoan );
  2230. // 不合法的数据 !($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)
  2231. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2232. die ( 'illegal request-receiptError' );
  2233. }
  2234. if ($receiptLoanDetail ['status'] != 10 || $receiptLoanDetail ['Rtype'] != 1) {
  2235. die ( 'illegal request-receipLoantError' );
  2236. }
  2237. // 培训班结算挂钩借款
  2238. $receipt = new receipt ();
  2239. $item = array (
  2240. 'rid' => $rid,
  2241. 'trainLoanRid' => 0
  2242. );
  2243. $receipt->setReceiptByCondition ( $item );
  2244. // 更新借款状态变成已挂钩
  2245. $receipt = new receipt ();
  2246. $item = array (
  2247. 'rid' => $ridLoan,
  2248. 'status' => 8,
  2249. 'statusTrain' => 0
  2250. );
  2251. $receipt->setReceiptByCondition ( $item );
  2252. $XDeode = new XDeode ( 7 );
  2253. return "/receiptTrainLoanEdi/" . $XDeode->encode ( $rid ) . ".html";
  2254. } else
  2255. die ( 'illegal request' );
  2256. }
  2257. /**
  2258. * 编辑培训班结算 ---开票
  2259. */
  2260. function receiptTrainInvoiceEdi() {
  2261. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2262. Doo::loadClass ( 'XDeode' );
  2263. $XDeode = new XDeode ( 7 );
  2264. $rid = $XDeode->decode ( $ridKey );
  2265. if (! is_numeric ( $rid ))
  2266. die ( 'illegal request' );
  2267. Doo::loadModel ( 'receipt' );
  2268. $receipt = new receipt ();
  2269. Doo::loadModel ( 'receiptTraining' );
  2270. $receiptTraining = new receiptTraining ();
  2271. Doo::loadModel ( 'invoice' );
  2272. $invoice = new invoice ();
  2273. Doo::loadModel ( 'invoiceTraining' );
  2274. $invoiceTraining = new invoiceTraining ();
  2275. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2276. if (! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4))
  2277. die ();
  2278. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2279. $invoiceList = $invoiceTrainingDetail = array ();
  2280. if ($receiptDetail ['invoiceTrainId'] != 0) {
  2281. $invoiceList = $invoice->getInvoicePrintedByItid ( $receiptDetail ['invoiceTrainId'] );
  2282. $invoiceTrainingDetail = $invoiceTraining->getInvoiceTrainingByItid ( $receiptDetail ['invoiceTrainId'] );
  2283. }
  2284. // print_r($invoiceList);
  2285. $data ['invoiceList'] = $invoiceList;
  2286. $data ['invoiceTrainingDetail'] = $invoiceTrainingDetail;
  2287. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2288. $data ['receiptDetail'] = $receiptDetail;
  2289. $data ['trainEdiType'] = "INVOICE";
  2290. $data ['ridKey'] = $ridKey;
  2291. $data ['memu'] = "receipt";
  2292. $data ['staff'] = $this->staff;
  2293. $data ['receiptMemu'] = 'saeaBorad';
  2294. $data ['verifyId'] = $this->verifyId;
  2295. $data ['executeId'] = $this->executeId;
  2296. $this->render ( "/receipt/receiptTrainInvoiceEdi", $data );
  2297. }
  2298. /**
  2299. * 编辑培训班结算---更新开票
  2300. */
  2301. function receiptTrainInvoiceEdiDo() {
  2302. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2303. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : "";
  2304. if (! empty ( $ridKey ) && ! empty ( $itidKey )) {
  2305. Doo::loadModel ( 'receipt' );
  2306. $receipt = new receipt ();
  2307. Doo::loadModel ( 'invoiceTraining' );
  2308. $invoiceTraining = new invoiceTraining ();
  2309. Doo::loadClass ( 'XDeode' );
  2310. $XDeode = new XDeode ( 5 );
  2311. $rid = $XDeode->decode ( $ridKey );
  2312. $itid = $XDeode->decode ( $itidKey );
  2313. if (! is_numeric ( $rid ) || ! is_numeric ( $itid ))
  2314. die ( 'illegal request-idError' );
  2315. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2316. $invoiceTrainDetail = $invoiceTraining->getInvoiceTrainingByItid ( $itid );
  2317. // 不合法的数据
  2318. if ((! ($receiptDetail ['status'] == 5 || $receiptDetail ['status'] == 4)) || $receiptDetail ['Rtype'] != 3) {
  2319. die ( 'illegal request-receiptError' );
  2320. }
  2321. if (empty ( $invoiceTrainDetail ) || $invoiceTrainDetail ['bindReceipt'] == 1) {
  2322. die ( 'illegal request-receipLoantError' );
  2323. }
  2324. // 培训班结算挂钩借款
  2325. $receipt = new receipt ();
  2326. $item = array (
  2327. 'rid' => $rid,
  2328. 'invoiceTrainId' => $itid
  2329. );
  2330. $receipt->setReceiptByCondition ( $item );
  2331. $invoiceTraining = new invoiceTraining ();
  2332. $item = array (
  2333. 'bindReceipt' => 1,
  2334. 'itid' => $itid
  2335. );
  2336. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2337. $XDeode = new XDeode ( 7 );
  2338. return "/receiptTrainInvoiceEdi/" . $XDeode->encode ( $rid ) . ".html";
  2339. } else
  2340. die ( 'illegal request' );
  2341. }
  2342. /**
  2343. * 更新培训班结算 收款和取消收款
  2344. */
  2345. function receiptTrainReceivables() {
  2346. $doType = isset ( $this->params ['doType'] ) ? $this->params ['doType'] : '';
  2347. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2348. $iidKey = $this->get_args ( 'iidKey' ) ? $this->get_args ( 'iidKey' ) : "";
  2349. Doo::loadClass ( 'XDeode' );
  2350. $XDeode = new XDeode ( 5 );
  2351. $rid = $XDeode->decode ( $ridKey );
  2352. $iid = $XDeode->decode ( $iidKey );
  2353. if (! is_numeric ( $rid ) || ! is_numeric ( $iid ))
  2354. die ( 'illegal request-iid' );
  2355. Doo::loadModel ( 'RIExtend' );
  2356. $RIExtend = new RIExtend ();
  2357. if ($doType == 'CONFIRM') {
  2358. $RIExtend->rid = $rid;
  2359. $RIExtend->iid = $iid;
  2360. $RIExtend->RIstatus = 1;
  2361. $RIExtend->insert ();
  2362. $XDeode = new XDeode ( 7 );
  2363. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2364. } elseif ($doType == 'CANCEL') {
  2365. $RIExtend->delete ( array (
  2366. 'where' => 'rid=' . $rid . ' and iid=' . $iid,
  2367. 'limit' => 1
  2368. ) );
  2369. $XDeode = new XDeode ( 7 );
  2370. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2371. } else {
  2372. die ( 'illegal request' );
  2373. }
  2374. }
  2375. /**
  2376. * 移除挂钩的培训班发票
  2377. */
  2378. function receiptTrainReceivablesDelDo() {
  2379. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2380. $itidKey = $this->get_args ( 'itidKey' ) ? $this->get_args ( 'itidKey' ) : ""; // 发票培训班
  2381. Doo::loadModel ( 'receipt' );
  2382. $receipt = new receipt ();
  2383. Doo::loadModel ( 'RIExtend' );
  2384. $RIExtend = new RIExtend ();
  2385. Doo::loadClass ( 'XDeode' );
  2386. $XDeode = new XDeode ( 5 );
  2387. $rid = $XDeode->decode ( $ridKey );
  2388. $itid = $XDeode->decode ( $itidKey );
  2389. if (is_numeric ( $rid ) && is_numeric ( $itid )) {
  2390. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2391. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2392. die ( 'illegal request-status' );
  2393. }
  2394. $receipt = new receipt ();
  2395. $receipt->rid = $rid;
  2396. $receipt->invoiceTrainId = 0;
  2397. $receipt->update ();
  2398. Doo::loadModel ( 'invoiceTraining' );
  2399. $invoiceTraining = new invoiceTraining ();
  2400. $item = array (
  2401. 'bindReceipt' => 0,
  2402. 'itid' => $itid
  2403. );
  2404. $invoiceTraining->setInvoiceTrainByCondition ( $item );
  2405. $RIExtend->delete ( array (
  2406. 'where' => 'rid=' . $rid
  2407. ) );
  2408. $XDeode = new XDeode ( 7 );
  2409. return '/receiptTrainInvoiceEdi/' . $XDeode->encode ( $rid ) . '.html';
  2410. } else
  2411. die ( 'illegal request-iid' );
  2412. }
  2413. /**
  2414. * 编辑培训班结算
  2415. */
  2416. function receiptTrainItemEdi() {
  2417. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2418. Doo::loadClass ( 'XDeode' );
  2419. $XDeode = new XDeode ( 7 );
  2420. $rid = $XDeode->decode ( $ridKey );
  2421. if (! is_numeric ( $rid ))
  2422. die ( 'illegal request' );
  2423. Doo::loadModel ( 'receipt' );
  2424. $receipt = new receipt ();
  2425. Doo::loadModel ( 'receiptTraining' );
  2426. $receiptTraining = new receiptTraining ();
  2427. Doo::loadModel ( 'RItem' );
  2428. $RItem = new RItem ();
  2429. Doo::loadModel ( 'accountItem' );
  2430. $accountItem = new accountItem ();
  2431. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2432. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2433. die ();
  2434. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2435. $RItemList = $RItem->getRItemByRid ( $rid );
  2436. $aiList = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2437. // foreach ($aiList as $key=>$value){//不需要添加税款,在添加收入时自动添加
  2438. // if($value['name']=='税款'){
  2439. // unset($aiList[$key]);break;
  2440. // }
  2441. // }
  2442. //print_r($aiList);
  2443. $data ['RItemList'] = $RItemList;
  2444. $data ['aiList'] = $aiList;
  2445. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2446. $data ['receiptDetail'] = $receiptDetail;
  2447. $data ['trainEdiType'] = "ITEM";
  2448. $data ['ridKey'] = $ridKey;
  2449. $data ['memu'] = "receipt";
  2450. $data ['staff'] = $this->staff;
  2451. $data ['receiptMemu'] = 'saeaBorad';
  2452. $data ['verifyId'] = $this->verifyId;
  2453. $data ['executeId'] = $this->executeId;
  2454. $this->render ( "/receipt/receiptTrainItemEdi", $data );
  2455. }
  2456. /**
  2457. * 添加支出项 需要修改 费用金额合计
  2458. */
  2459. function receiptTrainItemAddDo() {
  2460. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2461. // 支出项信息
  2462. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2463. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : 0;
  2464. $date = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2465. $inputer = $this->get_args ( 'inputer' ) ? $this->get_args ( 'inputer' ) : "";
  2466. $describe = $this->get_args ( 'describe' ) ? $this->get_args ( 'describe' ) : "";
  2467. $payType = isset ( $this->params ['payType'] ) ? $this->params ['payType'] : '';
  2468. if (! empty ( $ridKey ) && ! empty ( $item ) && is_numeric( $price ) && ! empty ( $date ) && ! empty ( $inputer )) {
  2469. Doo::loadClass ( 'XDeode' );
  2470. $XDeode = new XDeode ( 5 );
  2471. Doo::loadModel ( 'RItem' );
  2472. $RItem = new RItem ();
  2473. $rid = $XDeode->decode ( $ridKey );
  2474. if (! is_numeric ( $rid ))
  2475. die ( 'illegal request' );
  2476. if($payType=='company'){
  2477. $RItem->payType = 1;
  2478. }
  2479. $RItem->rid = $rid;
  2480. $RItem->item = $item;
  2481. $RItem->price = $price;
  2482. $RItem->date = $date;
  2483. $RItem->inputer = $inputer;
  2484. $order = array (
  2485. "\r\n",
  2486. "\n",
  2487. "\r"
  2488. );
  2489. $replace = '<br/>';
  2490. $describe = str_replace ( $order, $replace, $describe );
  2491. $RItem->describe = $describe;
  2492. $RItem->creater=$this->staff['0']['username'];
  2493. $RItem->creatDate=date ( "Y-m-d H:i:s" ) ;
  2494. $RItem->insert ();
  2495. // 添加公司汇总
  2496. // 报销详情
  2497. Doo::loadModel ( 'receiptDetail' );
  2498. $receiptDetail = new receiptDetail ();
  2499. Doo::loadModel ( 'receipt' );
  2500. $receipt = new receipt ();
  2501. $rInfo = $receipt->getReceiptByRid ( $rid );
  2502. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, $item, '培训班费用' );
  2503. if (empty ( $rdInfo )) {
  2504. $receiptDetail = new receiptDetail ();
  2505. $receiptDetail->staff = $rInfo ['staff'];
  2506. $receiptDetail->item = $item;
  2507. $receiptDetail->itemCategory = '培训班费用';
  2508. $receiptDetail->price = $price;
  2509. $receiptDetail->date = date ( "Y-m-d" );
  2510. $receiptDetail->cid = $rInfo ['cid'];
  2511. $receiptDetail->rid = $rid;
  2512. $receiptDetail->status = 4;
  2513. $receiptDetail->insert ();
  2514. } else {
  2515. $receiptDetail = new receiptDetail ();
  2516. $rdInfo ['price'] += $price;
  2517. $receiptDetail->price = $rdInfo ['price'];
  2518. $receiptDetail->update ( array (
  2519. 'where' => 'rid=' . $rid . ' and item like "' . $item . '" and itemCategory like "培训班费用"'
  2520. ) );
  2521. }
  2522. //更新费用合计金额
  2523. $receipt = new receipt ();
  2524. $receipt->sum=$rInfo['sum']+ $price;
  2525. $receipt->update ( array (
  2526. 'where' => 'rid=' . $rid
  2527. ) );
  2528. //汇总金额--提交审批之后有 支出项时 需要更新汇总
  2529. if($payType=='company'){
  2530. Doo::loadModel ( "statistics" );
  2531. $statistics = new statistics ();
  2532. $dateArray = explode ( "-", $rInfo ['date'] );
  2533. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2534. $stat = $statistics->getOne ( array (
  2535. 'where' => 'staff=' . $rInfo ['staff'] . $dateCondition,
  2536. 'asArray' => true
  2537. ) );
  2538. if (!empty($stat)){
  2539. //$statistics->agPrice = $stat ['agPrice'] + $price;
  2540. $statistics->rePrice = $stat ['rePrice'] + $price;
  2541. $statistics->update ( array (
  2542. 'where' => 'sid=' . $stat ['sid']
  2543. ) );
  2544. }
  2545. // Doo::loadModel ( "itemStatistics" );
  2546. // $itemStatistics = new itemStatistics ();
  2547. // $iStatistics = $itemStatistics->getOne ( array (
  2548. // 'where' => 'staff=' . $rInfo ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  2549. // 'asArray' => true
  2550. // ) );
  2551. // if (!empty($iStatistics)){
  2552. // $itemStatistics->price = $iStatistics ['price']+$price;
  2553. // $itemStatistics->update ( array (
  2554. // 'where' => 'sid=' . $iStatistics ['sid']
  2555. // ) );
  2556. // }
  2557. }
  2558. $XDeode = new XDeode ( 7 );
  2559. if($payType=='company'){
  2560. return '/receiptTrainItem/approval/' . $XDeode->encode ( $rid ) . '.html';
  2561. }else{
  2562. return '/receiptTrainItemEdi/' . $XDeode->encode ( $rid ) . '.html';
  2563. }
  2564. } else
  2565. die ( 'illegal request-dataError' );
  2566. }
  2567. /**
  2568. * 培训班结算-讲师
  2569. */
  2570. function receiptTrainLecturerEdi() {
  2571. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2572. Doo::loadClass ( 'XDeode' );
  2573. $XDeode = new XDeode ( 7 );
  2574. $rid = $XDeode->decode ( $ridKey );
  2575. if (! is_numeric ( $rid ))
  2576. die ( 'illegal request' );
  2577. Doo::loadModel ( 'receipt' );
  2578. $receipt = new receipt ();
  2579. Doo::loadModel ( 'receiptTraining' );
  2580. $receiptTraining = new receiptTraining ();
  2581. Doo::loadModel ( 'RILecturer' );
  2582. $RILecturer = new RILecturer ();
  2583. Doo::loadModel ( 'lecturer' );
  2584. $lecturer = new lecturer ();
  2585. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2586. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4))
  2587. die ();
  2588. $receiptTrainingDetail = $receiptTraining->getReceiptTrainingByRtid ( $receiptDetail ['trainId'] );
  2589. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2590. $lecturerList = $lecturer->getLecturerAll ();
  2591. $INSIDEhtml = $OUTSIDEhtml = '';
  2592. foreach ( $lecturerList as $key => $value ) {
  2593. if ($value ['ltype'] == 'INSIDE') {
  2594. $INSIDEhtml .= '<option value="' . $value ['category'] . '-' . $value ['staff'] . '">' . $value ['category'] . '-' . $value ['staff'] . '</option>';
  2595. } elseif ($value ['ltype'] == 'OUTSIDE') {
  2596. $OUTSIDEhtml .= '<option value="' . $value ['staff'] . '">' . $value ['staff'] . '</option>';
  2597. }
  2598. }
  2599. $data ['INSIDEhtml'] = $INSIDEhtml;
  2600. $data ['OUTSIDEhtml'] = $OUTSIDEhtml;
  2601. // print_r($RItemList);
  2602. $data ['RILecturerList'] = $RILecturerList;
  2603. $data ['receiptTrainingDetail'] = $receiptTrainingDetail;
  2604. $data ['receiptDetail'] = $receiptDetail;
  2605. $data ['trainEdiType'] = "LECTURER";
  2606. $data ['ridKey'] = $ridKey;
  2607. $data ['memu'] = "receipt";
  2608. $data ['staff'] = $this->staff;
  2609. $data ['receiptMemu'] = 'saeaBorad';
  2610. $data ['verifyId'] = $this->verifyId;
  2611. $data ['executeId'] = $this->executeId;
  2612. $this->render ( "/receipt/receiptTrainLecturerEdi", $data );
  2613. }
  2614. /**
  2615. * 添加讲师
  2616. */
  2617. function receiptTrainLecturerAddDo() {
  2618. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2619. // 支出项信息
  2620. $ltype = $this->get_args ( 'ltype' ) ? $this->get_args ( 'ltype' ) : "";
  2621. $lecturerName = $this->get_args ( 'lecturerName' ) ? $this->get_args ( 'lecturerName' ) : "";
  2622. $schoolDay = $this->get_args ( 'schoolDay' ) ? $this->get_args ( 'schoolDay' ) : "";
  2623. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  2624. $taxation = $this->get_args ( 'taxation' ) ? $this->get_args ( 'taxation' ) : "";
  2625. if (! empty ( $ridKey ) && ! empty ( $ltype ) && ! empty ( $lecturerName ) && ! empty ( $schoolDay ) && ! empty ( $price )) {
  2626. Doo::loadClass ( 'XDeode' );
  2627. $XDeode = new XDeode ( 5 );
  2628. Doo::loadModel ( 'RILecturer' );
  2629. $RILecturer = new RILecturer ();
  2630. $rid = $XDeode->decode ( $ridKey );
  2631. if (! is_numeric ( $rid ))
  2632. die ( 'illegal request' );
  2633. if ($ltype == 'OUTSIDE' && empty ( $taxation ))
  2634. die ( 'illegal request-taxationError' );
  2635. $RILecturer->rid = $rid;
  2636. $RILecturer->ltype = $ltype;
  2637. if ($ltype == 'OUTSIDE') {
  2638. if ($taxation == 'TAXATION') {
  2639. $RILecturer->taxation = 1;
  2640. } elseif ($taxation == 'NOTAXATION') {
  2641. $RILecturer->taxation = 0;
  2642. }
  2643. }
  2644. $RILecturer->lecturerName = $lecturerName;
  2645. $RILecturer->schoolDay = $schoolDay;
  2646. $RILecturer->price = $price;
  2647. $RILecturer->insert ();
  2648. // 添加公司汇总
  2649. // 报销详情
  2650. Doo::loadModel ( 'receiptDetail' );
  2651. $receiptDetail = new receiptDetail ();
  2652. Doo::loadModel ( 'receipt' );
  2653. $receipt = new receipt ();
  2654. // 金额总计
  2655. $price = $price * $schoolDay;
  2656. $rInfo = $receipt->getReceiptByRid ( $rid );
  2657. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2658. if (empty ( $rdInfo )) {
  2659. $receiptDetail = new receiptDetail ();
  2660. $receiptDetail->staff = $rInfo ['staff'];
  2661. $receiptDetail->item = '讲课费';
  2662. $receiptDetail->itemCategory = '培训班费用';
  2663. $receiptDetail->price = number_format ( $price, 2, '.', '' );
  2664. $receiptDetail->date = date ( "Y-m-d" );
  2665. $receiptDetail->cid = $rInfo ['cid'];
  2666. $receiptDetail->rid = $rid;
  2667. $receiptDetail->status = 4;
  2668. $receiptDetail->insert ();
  2669. } else {
  2670. $receiptDetail = new receiptDetail ();
  2671. $rdInfo ['price'] += $price;
  2672. $receiptDetail->price = $rdInfo ['price'];
  2673. $receiptDetail->update ( array (
  2674. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2675. ) );
  2676. }
  2677. $receipt = new receipt ();
  2678. $receipt->sum=$rInfo['sum']+$price;
  2679. $receipt->update ( array (
  2680. 'where' => 'rid=' . $rid
  2681. ) );
  2682. $XDeode = new XDeode ( 7 );
  2683. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2684. } else
  2685. die ( 'illegal request' );
  2686. }
  2687. /**
  2688. * 移除讲师
  2689. */
  2690. function receiptTrainLecturerDelDo() {
  2691. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : ""; // 费用 培训班结算
  2692. $rlidKey = $this->get_args ( 'rlidKey' ) ? $this->get_args ( 'rlidKey' ) : ""; // 发票培训班
  2693. Doo::loadModel ( 'receipt' );
  2694. $receipt = new receipt ();
  2695. Doo::loadModel ( 'RILecturer' );
  2696. $RILecturer = new RILecturer ();
  2697. Doo::loadClass ( 'XDeode' );
  2698. $XDeode = new XDeode ( 5 );
  2699. $rid = $XDeode->decode ( $ridKey );
  2700. $rlid = $XDeode->decode ( $rlidKey );
  2701. if (is_numeric ( $rid ) && is_numeric ( $rlid )) {
  2702. $receiptDetail = $receipt->getReceiptByRid ( $rid );
  2703. if (!($receiptDetail ['status'] == 5||$receiptDetail ['status'] == 4)){
  2704. die ( 'illegal request-status' );
  2705. }
  2706. $detail=$RILecturer->getRILecturerByRlid($rlid);
  2707. if (empty($detail)){
  2708. die ( 'illegal request-data' );
  2709. }
  2710. $RILecturer->delete ( array (
  2711. 'where' => 'rid=' . $rid . ' and rlid=' . $rlid
  2712. ) );
  2713. //更新费用合计金额
  2714. $rInfo = $receipt->getReceiptByRid ( $rid );
  2715. $receipt = new receipt ();
  2716. $receipt->sum= $receiptDetail['sum']-$detail['price'];
  2717. $receipt->update ( array (
  2718. 'where' => 'rid=' . $rid
  2719. ) );
  2720. Doo::loadModel ( 'receiptDetail' );
  2721. $receiptDetail = new receiptDetail ();
  2722. $rdInfo = $receiptDetail->getReceiptDetailByRIC ( $rid, '讲课费', '培训班费用' );
  2723. $receiptDetail = new receiptDetail ();
  2724. $rdInfo ['price'] -= number_format ( $detail['price'], 2, '.', '' );
  2725. $receiptDetail->price = $rdInfo ['price'];
  2726. $receiptDetail->update ( array (
  2727. 'where' => 'rid=' . $rid . ' and item like "' . '讲课费' . '" and itemCategory like "培训班费用"'
  2728. ) );
  2729. $XDeode = new XDeode ( 7 );
  2730. return '/receiptTrainLecturerEdi/' . $XDeode->encode ( $rid ) . '.html';
  2731. } else
  2732. die ( 'illegal request-iid' );
  2733. }
  2734. /**
  2735. * 培训班提交审批
  2736. */
  2737. function receiptTrainDo() {
  2738. $ridKey = $this->get_args ( 'ridKey' ) ? $this->get_args ( 'ridKey' ) : "";
  2739. Doo::loadClass ( 'XDeode' );
  2740. $XDeode = new XDeode ( 7 );
  2741. $rid = $XDeode->decode ( $ridKey );
  2742. Doo::loadModel ( 'receipt' );
  2743. $receipt = new receipt ();
  2744. Doo::loadModel ( 'receiptDetail' );
  2745. $receiptDetail = new receiptDetail ();
  2746. Doo::loadModel ( 'statistics' );
  2747. $statistics = new statistics ();
  2748. Doo::loadModel ( "verify" );
  2749. $verify = new verify ();
  2750. // 审批状态的判定
  2751. $receiptDetailList = $receipt->getOne ( array (
  2752. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  2753. 'asArray' => true
  2754. ) );
  2755. if (empty ( $receiptDetailList ))
  2756. return "/saeaBorad";
  2757. $verifyDetail = $verify->getOne ( array (
  2758. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2759. 'asArray' => true
  2760. ) );
  2761. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2762. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2763. $nowStaff = "";
  2764. $nowStaffList = array ();
  2765. if ($verifyDetail [0] [1] == 'ROLE') {
  2766. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2767. foreach ( $vStaffString as $key => $value ) {
  2768. $staffK = explode ( "_", $value );
  2769. array_push ( $nowStaffList, $staffK [0] );
  2770. }
  2771. $nowStaff = implode ( ',', $nowStaffList );
  2772. } else {
  2773. $nowStaff = $verifyDetail [0] [0];
  2774. }
  2775. $receipt->nowStaff = $nowStaff;
  2776. }
  2777. // echo $nowStaff;
  2778. // print_r($verifyDetail);die;
  2779. $receipt->rid = $receiptDetailList ['rid'];
  2780. $receipt->date = date ( "Y-m-d" );
  2781. $receipt->status = 2;
  2782. $receipt->update ();
  2783. $receiptDetail->status = 2;
  2784. $receiptDetail->update ( array (
  2785. 'where' => 'rid=' . $receiptDetailList ['rid']
  2786. ) );
  2787. Doo::loadModel ( "receiptLog" );
  2788. $receiptLog = new receiptLog ();
  2789. Doo::loadModel ( "verify" );
  2790. $verify = new verify ();
  2791. $vr = $verify->getOne ( array (
  2792. 'where' => 'vid=' . $receiptDetailList ['verify'],
  2793. 'asArray' => true
  2794. ) );
  2795. $jd = json_decode ( $vr ['staff'] );
  2796. $roleId = 0;
  2797. foreach ( $jd as $key => $value ) {
  2798. if ($value [1] == 'ROLE') {
  2799. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2800. if ($pos !== false) {
  2801. $roleId = $value [0];
  2802. }
  2803. }
  2804. }
  2805. // 审批日志
  2806. // echo $roleId;die;
  2807. if (! empty ( $roleId )) {
  2808. Doo::loadModel ( "role" );
  2809. $role = new role ();
  2810. $roleInfo = $role->getOne ( array (
  2811. 'where' => 'rid=' . $roleId,
  2812. 'asArray' => true
  2813. ) );
  2814. // $receiptLog->rolename = $roleInfo ['name'];
  2815. }
  2816. $receiptLog->username = $this->staff [0] ['username'];
  2817. $receiptLog->uid = $this->staff [0] ['sid'];
  2818. $receiptLog->date = date ( "Y-m-d" );
  2819. $receiptLog->opinion = '提交审批';
  2820. $receiptLog->img = $this->staff [0] ['avatar'];
  2821. $receiptLog->status = 2;
  2822. $receiptLog->rid = $rid;
  2823. $receiptLog->insert ();
  2824. // 写入列表项
  2825. Doo::loadModel ( 'accountItem' );
  2826. $accountItem = new accountItem ();
  2827. $aItem = $accountItem->getAccountBookByCategory ( '培训班费用' );
  2828. // 项目金额合计
  2829. Doo::loadModel ( 'RItem' );
  2830. $RItem = new RItem ();
  2831. // 讲师获得
  2832. Doo::loadModel ( 'RILecturer' );
  2833. $RILecturer = new RILecturer ();
  2834. $RItemList = $RItem->getRItemByRid ( $rid );
  2835. $RILecturerList = $RILecturer->getRILecturerByRid ( $rid );
  2836. // 支出项金额详情
  2837. $aiData = $accountItem->getTrainingDetail ( $RItemList, $RILecturerList, 0 );
  2838. // print_r($aItem);
  2839. // print_r($aiData);
  2840. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  2841. $ag = $tr = $ta = $ot = 0;
  2842. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  2843. foreach ( $aItem as $key => $value ) {
  2844. if ($value ['category'] == $this->TRAIN) {
  2845. foreach ( $aiData ['dataList'] as $k => $v ) {
  2846. if ($value ['name'] == $v ['name']) {
  2847. array_push ( $accountJson [$this->TRAIN], array (
  2848. 'aid' => $value ['aid'],
  2849. 'name' => $value ['name'],
  2850. 'price' => number_format ( $v ['price'], 2, '.', '' )
  2851. ) );
  2852. $sum += $v ['price'];
  2853. $trainSum += $v ['price'];
  2854. unset ( $aiData ['dataList'] [$k] );
  2855. break;
  2856. }
  2857. }
  2858. }
  2859. }
  2860. $accountJson ['cSum'] = array (
  2861. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  2862. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  2863. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  2864. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  2865. );
  2866. // 报销单
  2867. $receipt = new receipt ();
  2868. $receipt->accountItem = json_encode ( $accountJson );
  2869. $receipt->sum = number_format ( $sum, 2, '.', '' );
  2870. $receipt->update ( array (
  2871. 'where' => 'rid=' . $rid
  2872. ) );
  2873. // print_r($accountJson);
  2874. // statistics item 统计写入
  2875. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  2876. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  2877. $accountItem = $accountJson;
  2878. $stat = $statistics->getOne ( array (
  2879. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  2880. 'asArray' => true
  2881. ) );
  2882. if (empty ( $stat )) {
  2883. $statistics->date = date ( "Y-m-d" );
  2884. $statistics->cid = $this->staff [0] ['cid'];
  2885. $statistics->staff = $this->staff [0] ['sid'];
  2886. $statistics->agPrice = 0;
  2887. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2888. $statistics->insert ();
  2889. } else {
  2890. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  2891. $statistics->update ( array (
  2892. 'where' => 'sid=' . $stat ['sid']
  2893. ) );
  2894. }
  2895. return "/saeaBorad";
  2896. }
  2897. function confirmation() {
  2898. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2899. Doo::loadModel ( 'receipt' );
  2900. Doo::loadModel ( 'receiptDetail' );
  2901. $receipt = new receipt ();
  2902. $receiptDetail = new receiptDetail ();
  2903. Doo::loadModel ( 'statistics' );
  2904. Doo::loadModel ( 'itemStatistics' );
  2905. $statistics = new statistics ();
  2906. $itemStatistics = new itemStatistics ();
  2907. Doo::loadModel ( "verify" );
  2908. $verify = new verify ();
  2909. $receiptDetailList = $receipt->getOne ( array (
  2910. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  2911. 'asArray' => true
  2912. ) );
  2913. if (empty ( $receiptDetailList ))
  2914. return "/saeaBorad";
  2915. $verifyDetail = $verify->getOne ( array (
  2916. 'where' => ' vid =' . $receiptDetailList ['verify'],
  2917. 'asArray' => true
  2918. ) );
  2919. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  2920. if (empty ( $receiptDetailList ['nowStaff'] )) {
  2921. $nowStaff = "";
  2922. $nowStaffList = array ();
  2923. if ($verifyDetail [0] [1] == 'ROLE') {
  2924. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  2925. foreach ( $vStaffString as $key => $value ) {
  2926. $staffK = explode ( "_", $value );
  2927. array_push ( $nowStaffList, $staffK [0] );
  2928. }
  2929. $nowStaff = implode ( ',', $nowStaffList );
  2930. } else {
  2931. $nowStaff = $verifyDetail [0] [0];
  2932. }
  2933. $receipt->nowStaff = $nowStaff;
  2934. }
  2935. // echo $nowStaff;
  2936. // print_r($verifyDetail);die;
  2937. $receipt->rid = $receiptDetailList ['rid'];
  2938. $receipt->status = 2;
  2939. $receipt->update ();
  2940. // 操作日志
  2941. Doo::loadModel ( "receiptLog" );
  2942. $receiptLog = new receiptLog ();
  2943. $verify = new verify ();
  2944. $receiptInfo = $receipt->getOne ( array (
  2945. 'where' => 'rid=' . $rid,
  2946. 'asArray' => true
  2947. ) );
  2948. $vr = $verify->getOne ( array (
  2949. 'where' => 'vid=' . $receiptInfo ['verify'],
  2950. 'asArray' => true
  2951. ) );
  2952. $jd = json_decode ( $vr ['staff'] );
  2953. $roleId = 0;
  2954. foreach ( $jd as $key => $value ) {
  2955. if ($value [1] == 'ROLE') {
  2956. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  2957. if ($pos !== false) {
  2958. $roleId = $value [0];
  2959. }
  2960. }
  2961. }
  2962. // 审批日志
  2963. // echo $roleId;die;
  2964. if (! empty ( $roleId )) {
  2965. Doo::loadModel ( "role" );
  2966. $role = new role ();
  2967. $roleInfo = $role->getOne ( array (
  2968. 'where' => 'rid=' . $roleId,
  2969. 'asArray' => true
  2970. ) );
  2971. // $receiptLog->rolename = $roleInfo ['name'];
  2972. }
  2973. $receiptLog->username = $this->staff [0] ['username'];
  2974. $receiptLog->uid = $this->staff [0] ['sid'];
  2975. $receiptLog->date = date ( "Y-m-d" );
  2976. $receiptLog->opinion = '提交审批';
  2977. $receiptLog->img = $this->staff [0] ['avatar'];
  2978. $receiptLog->status = 2;
  2979. $receiptLog->rid = $rid;
  2980. $receiptLog->insert ();
  2981. return "/expenses";
  2982. }
  2983. function expenses() {
  2984. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  2985. if (empty ( $item ))
  2986. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  2987. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  2988. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  2989. Doo::loadClass ( 'XDeode' );
  2990. $XDeode = new XDeode ( 7 );
  2991. Doo::loadModel ( 'receipt' );
  2992. $receipt = new receipt ();
  2993. Doo::loadModel ( 'L_category' );
  2994. $Lcategory = new L_category ();
  2995. Doo::loadModel ( 'verify' );
  2996. Doo::loadModel ( 'statistics' );
  2997. $statistics = new statistics ();
  2998. $verify = new verify ();
  2999. Doo::loadModel ( 'staff' );
  3000. $staff = new staff ();
  3001. $condition = "";
  3002. if ($item == "expenses")
  3003. $condition = " and Rtype=1 ";
  3004. elseif ($item == "receipts")
  3005. $condition = " and Rtype=0 ";
  3006. elseif ($item == "remits")
  3007. $condition = " and Rtype=2 ";
  3008. elseif ($item == "train")
  3009. $condition = " and Rtype=3 ";
  3010. $dateCondition = " and Year(date) =" . $year;
  3011. if (! empty ( $moth )) {
  3012. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  3013. $stList = $statistics->getOne ( array (
  3014. 'select' => 'rePrice ,agPrice',
  3015. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  3016. 'asArray' => true
  3017. ) );
  3018. } else
  3019. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  3020. if (empty ( $stList ))
  3021. $stList = array (
  3022. 'rePrice' => 0,
  3023. 'agPrice' => 0
  3024. );
  3025. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  3026. if (! isset ( $noPassSum ['sum'] ))
  3027. $noPassSum ['sum'] = 0;
  3028. $data ['stList'] = array (
  3029. 'rePrice' => $stList ['rePrice'],
  3030. 'agPrice' => $stList ['agPrice'],
  3031. 'skPrice' => ($noPassSum ['sum'])
  3032. );
  3033. $receiptList = $receipt->find ( array (
  3034. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  3035. 'desc' => 'rid',
  3036. 'asArray' => true
  3037. ) );
  3038. $Locate = 0;
  3039. $roleId = 0;
  3040. $button = 0;
  3041. foreach ( $receiptList as $key => $value ) {
  3042. $receiptList [$key] ['Locate'] = $Locate;
  3043. $Locate ++;
  3044. $receiptList [$key] ['reviseDetail'] = array ();
  3045. if (! empty ( $value ['reviseDetail'] ))
  3046. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3047. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3048. $categoryDetil = $Lcategory->getOne ( array (
  3049. 'where' => 'cid=' . $value ['cid'],
  3050. 'asArray' => true
  3051. ) );
  3052. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3053. // 检测编辑状态
  3054. $verifyList = $verify->getOne ( array (
  3055. 'where' => 'vid=' . $value ['verify'],
  3056. 'asArray' => true
  3057. ) );
  3058. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3059. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3060. Doo::loadModel ( 'role' );
  3061. $role = new role ();
  3062. $flag = true;
  3063. $roleKey = 0;
  3064. $endStaffArray = array ();
  3065. $roleArrayCopy = array ();
  3066. foreach ( $verifyList as $k => $v ) {
  3067. // init verifyStaff
  3068. if ($v [1] == 'ROLE') {
  3069. if (! empty ( $verifyStaff )) {
  3070. $endStaffArray = end ( $verifyStaff );
  3071. // if ($v[0]==$endStaffArray['nextStaff']){
  3072. // $roleId=$v[0];
  3073. // }
  3074. }
  3075. $roleVerify = json_decode ( $v [3], true );
  3076. $roleKey = $k;
  3077. $roleArray = array ();
  3078. $rolename = $role->getOne ( array (
  3079. 'where' => 'rid=' . $v [0],
  3080. 'asArray' => true
  3081. ) );
  3082. foreach ( $roleVerify as $o => $p ) {
  3083. $staffID = explode ( '_', $p );
  3084. $staffInfo = $staff->getOne ( array (
  3085. 'where' => 'sid=' . $staffID [0],
  3086. 'asArray' => true
  3087. ) );
  3088. // print_r($staffID);
  3089. $exp = array (
  3090. 0 => $staffInfo ['sid'],
  3091. 1 => $staffID [1],
  3092. 2 => $staffInfo ['avatar'],
  3093. 'date' => '',
  3094. 'date' => '',
  3095. 'opinion' => '',
  3096. 'status' => '',
  3097. 'rolename' => $rolename ['name']
  3098. );
  3099. array_push ( $roleArray, $exp );
  3100. }
  3101. $roleArrayCopy [$v [0]] = $roleArray;
  3102. // $verifyList[$k]['roleArray']=$roleArray;
  3103. }
  3104. $verifyList [$k] ['date'] = "";
  3105. $verifyList [$k] ['opinion'] = "";
  3106. $verifyList [$k] ['status'] = "";
  3107. if (empty ( $verifyStaff )) {
  3108. $verifyList [$k] ['date'] = "";
  3109. $verifyList [$k] ['opinion'] = "";
  3110. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3111. $verifyList [$k] ['status'] = 4;
  3112. $flag = false;
  3113. }
  3114. } else {
  3115. foreach ( $verifyStaff as $m => $u ) {
  3116. if ($v [0] == $m) {
  3117. $verifyList [$k] ['date'] = $u ['date'];
  3118. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3119. $verifyList [$k] ['status'] = $u ['status'];
  3120. $flag = false;
  3121. break;
  3122. }
  3123. }
  3124. $endStaffArray = end ( $verifyStaff );
  3125. if (isset ( $endStaffArray ['ROLE'] )) {
  3126. } else {
  3127. // $endKey=key($verifyStaff);
  3128. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3129. // $button=4;
  3130. // $verifyList[$k]['status']=4;
  3131. // }
  3132. }
  3133. }
  3134. }
  3135. $rolename ['name'] = '';
  3136. if (! empty ( $roleId )) {
  3137. Doo::loadModel ( 'role' );
  3138. $role = new role ();
  3139. $rolename = $role->getOne ( array (
  3140. 'where' => 'rid=' . $roleId,
  3141. 'asArray' => true
  3142. ) );
  3143. }
  3144. if (! empty ( $verifyStaff ))
  3145. $endStaffArray = end ( $verifyStaff );
  3146. $KOP = false;
  3147. foreach ( $roleArrayCopy as $P => $A ) {
  3148. foreach ( $A as $MKI => $AVL ) {
  3149. if (! empty ( $verifyStaff )) {
  3150. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3151. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3152. $button = 4;
  3153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3154. }
  3155. foreach ( $verifyStaff as $m => $u ) {
  3156. $AVLFK = $AVL [0] . '_R';
  3157. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3158. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3159. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3160. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3161. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3162. break;
  3163. }
  3164. }
  3165. } else {
  3166. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3167. $button = 4;
  3168. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3169. }
  3170. }
  3171. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3172. $KOP = true;
  3173. }
  3174. }
  3175. foreach ( $roleArrayCopy as $k => $v ) {
  3176. foreach ( $verifyList as $m => $n ) {
  3177. if ($n [0] == $k) {
  3178. array_splice ( $verifyList, $m, 1, $v );
  3179. }
  3180. }
  3181. }
  3182. $receiptList [$key] ['verifyList'] = $verifyList;
  3183. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3184. 'where' => 'sid=' . $value ['staff'],
  3185. 'asArray' => true
  3186. ) );
  3187. $receiptList [$key] ['button'] = $button;
  3188. $receiptList [$key] ['ridKey'] =$XDeode->encode( $value ['rid'] );
  3189. }
  3190. // print_r($receiptList);die;
  3191. $mothHtml = "";
  3192. for($i = 1; $i <= 12; $i ++) {
  3193. if ($moth == $i)
  3194. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3195. else
  3196. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3197. }
  3198. $dateHtml = "";
  3199. $now = date ( "Y" );
  3200. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3201. if ($YEARD <= $now) {
  3202. $dateHtml .= '<option ';
  3203. if ($year == $YEARD) {
  3204. $dateHtml .= 'selected ';
  3205. }
  3206. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3207. }
  3208. }
  3209. $data ['dateHtml'] = $dateHtml;
  3210. $data ['mothHtml'] = $mothHtml;
  3211. $data ['receiptList'] = $receiptList;
  3212. $data ['memu'] = "receipt";
  3213. $data ['staff'] = $this->staff;
  3214. $data ['receiptMemu'] = 'expenses';
  3215. $data ['verifyId'] = $this->verifyId;
  3216. $data ['executeId'] = $this->executeId;
  3217. $data ['item'] = $item;
  3218. $data ['year'] = $year;
  3219. $this->render ( "/admin/expenses", $data );
  3220. }
  3221. function expensesCollect() {
  3222. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3223. Doo::loadModel ( 'receipt' );
  3224. $receipt = new receipt ();
  3225. Doo::loadModel ( 'L_category' );
  3226. $Lcategory = new L_category ();
  3227. Doo::loadModel ( 'verify' );
  3228. Doo::loadModel ( 'statistics' );
  3229. $statistics = new statistics ();
  3230. $verify = new verify ();
  3231. Doo::loadModel ( 'staff' );
  3232. $staff = new staff ();
  3233. Doo::loadModel ( 'loanReceipt' );
  3234. $loanReceipt = new loanReceipt ();
  3235. $receiptList = $receipt->find ( array (//去掉
  3236. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  3237. 'desc' => 'rid',
  3238. 'asArray' => true
  3239. ) );
  3240. $loanList = $loanReceipt->find ( array (
  3241. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3242. 'desc' => 'rid',
  3243. 'asArray' => true
  3244. ) );
  3245. /*
  3246. * $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;
  3247. */
  3248. $data ['explanation'] = '';
  3249. if (! empty ( $loanList ))
  3250. $data ['explanation'] = $loanList [0] ['explanation'];
  3251. $Locate = 0;
  3252. $roleId = 0;
  3253. $button = 0;
  3254. foreach ( $receiptList as $key => $value ) {
  3255. $receiptList [$key] ['Locate'] = $Locate;
  3256. $Locate ++;
  3257. $receiptList [$key] ['reviseDetail'] = array ();
  3258. if (! empty ( $value ['reviseDetail'] ))
  3259. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3260. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3261. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3262. $categoryDetil = $Lcategory->getOne ( array (
  3263. 'where' => 'cid=' . $value ['cid'],
  3264. 'asArray' => true
  3265. ) );
  3266. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3267. // 检测编辑状态
  3268. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  3269. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  3270. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  3271. else
  3272. $verifyList ['staff'] = $value ['verifyBreakup'];
  3273. } else
  3274. $verifyList = $verify->getOne ( array (
  3275. 'where' => 'vid=' . $value ['verify'],
  3276. 'asArray' => true
  3277. ) );
  3278. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3279. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3280. Doo::loadModel ( 'role' );
  3281. $role = new role ();
  3282. $flag = true;
  3283. $roleKey = 0;
  3284. $endStaffArray = array ();
  3285. $roleArrayCopy = array ();
  3286. foreach ( $verifyList as $k => $v ) {
  3287. // init verifyStaff
  3288. if ($v [1] == 'ROLE') {
  3289. if (! empty ( $verifyStaff )) {
  3290. $endStaffArray = end ( $verifyStaff );
  3291. // if ($v[0]==$endStaffArray['nextStaff']){
  3292. // $roleId=$v[0];
  3293. // }
  3294. }
  3295. $roleVerify = json_decode ( $v [3], true );
  3296. $roleKey = $k;
  3297. $roleArray = array ();
  3298. $rolename = $role->getOne ( array (
  3299. 'where' => 'rid=' . $v [0],
  3300. 'asArray' => true
  3301. ) );
  3302. foreach ( $roleVerify as $o => $p ) {
  3303. $staffID = explode ( '_', $p );
  3304. $staffInfo = $staff->getOne ( array (
  3305. 'where' => 'sid=' . $staffID [0],
  3306. 'asArray' => true
  3307. ) );
  3308. // print_r($staffID);
  3309. $exp = array (
  3310. 0 => $staffInfo ['sid'],
  3311. 1 => $staffID [1],
  3312. 2 => $staffInfo ['avatar'],
  3313. 'date' => '',
  3314. 'date' => '',
  3315. 'opinion' => '',
  3316. 'status' => '',
  3317. 'rolename' => $rolename ['name']
  3318. );
  3319. array_push ( $roleArray, $exp );
  3320. }
  3321. $roleArrayCopy [$v [0]] = $roleArray;
  3322. // $verifyList[$k]['roleArray']=$roleArray;
  3323. }
  3324. $verifyList [$k] ['date'] = "";
  3325. $verifyList [$k] ['opinion'] = "";
  3326. $verifyList [$k] ['status'] = "";
  3327. if (empty ( $verifyStaff )) {
  3328. $verifyList [$k] ['date'] = "";
  3329. $verifyList [$k] ['opinion'] = "";
  3330. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3331. $verifyList [$k] ['status'] = 4;
  3332. $flag = false;
  3333. }
  3334. } else {
  3335. foreach ( $verifyStaff as $m => $u ) {
  3336. if ($v [0] == $m) {
  3337. $verifyList [$k] ['date'] = $u ['date'];
  3338. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3339. $verifyList [$k] ['status'] = $u ['status'];
  3340. $flag = false;
  3341. break;
  3342. }
  3343. }
  3344. $endStaffArray = end ( $verifyStaff );
  3345. if (isset ( $endStaffArray ['ROLE'] )) {
  3346. } else {
  3347. // $endKey=key($verifyStaff);
  3348. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3349. // $button=4;
  3350. // $verifyList[$k]['status']=4;
  3351. // }
  3352. }
  3353. }
  3354. }
  3355. $rolename ['name'] = '';
  3356. if (! empty ( $roleId )) {
  3357. Doo::loadModel ( 'role' );
  3358. $role = new role ();
  3359. $rolename = $role->getOne ( array (
  3360. 'where' => 'rid=' . $roleId,
  3361. 'asArray' => true
  3362. ) );
  3363. }
  3364. if (! empty ( $verifyStaff ))
  3365. $endStaffArray = end ( $verifyStaff );
  3366. $KOP = false;
  3367. foreach ( $roleArrayCopy as $P => $A ) {
  3368. foreach ( $A as $MKI => $AVL ) {
  3369. if (! empty ( $verifyStaff )) {
  3370. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3371. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3372. $button = 4;
  3373. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3374. }
  3375. foreach ( $verifyStaff as $m => $u ) {
  3376. $AVLFK = $AVL [0] . '_R';
  3377. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3378. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3379. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3380. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3381. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3382. break;
  3383. }
  3384. }
  3385. } else {
  3386. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3387. $button = 4;
  3388. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3389. }
  3390. }
  3391. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3392. $KOP = true;
  3393. }
  3394. }
  3395. foreach ( $roleArrayCopy as $k => $v ) {
  3396. foreach ( $verifyList as $m => $n ) {
  3397. if ($n [0] == $k) {
  3398. array_splice ( $verifyList, $m, 1, $v );
  3399. }
  3400. }
  3401. }
  3402. // 费用执行人相关数据
  3403. $executeCopy = json_decode ( $value ['executeCopy'], true );
  3404. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3405. foreach ( $executeCopy as $k => $v ) {
  3406. $executeCopy [$k] ['date'] = '';
  3407. $executeCopy [$k] ['opinion'] = '';
  3408. $executeCopy [$k] ['status'] = '';
  3409. if (! empty ( $executeStaff ))
  3410. foreach ( $executeStaff as $m => $u ) {
  3411. if ($v [0] == $m) {
  3412. $executeCopy [$k] ['date'] = $u ['date'];
  3413. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  3414. $executeCopy [$k] ['status'] = $u ['status'];
  3415. break;
  3416. }
  3417. }
  3418. }
  3419. $receiptList [$key] ['executeCopy'] = $executeCopy;
  3420. $receiptList [$key] ['verifyList'] = $verifyList;
  3421. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3422. 'where' => 'sid=' . $value ['staff'],
  3423. 'asArray' => true
  3424. ) );
  3425. $receiptList [$key] ['button'] = $button;
  3426. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3427. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3428. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  3429. $receiptList [$key] ['relust'] = $relust;
  3430. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  3431. }
  3432. Doo::loadModel ( 'enclosur' );
  3433. $enclosur = new enclosur ();
  3434. $enclosurList = $enclosur->find ( array (
  3435. 'where' => 'rid=' . $rid,
  3436. 'asArray' => true
  3437. ) );
  3438. $enclosurHtml = '';
  3439. foreach ( $enclosurList as $value ) {
  3440. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3441. }
  3442. $data ['enclosurHtml'] = $enclosurHtml;
  3443. // print_r($receiptList);
  3444. $data ['receiptList'] = $receiptList;
  3445. $data ['memu'] = "receipt";
  3446. $data ['staff'] = $this->staff;
  3447. $data ['receiptMemu'] = 'expenses';
  3448. $data ['verifyId'] = $this->verifyId;
  3449. $data ['executeId'] = $this->executeId;
  3450. $this->render ( "/admin/expensesCollect", $data );
  3451. }
  3452. function approvalExpenses() {
  3453. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  3454. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3455. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3456. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3457. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3458. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  3459. // echo $rdate;
  3460. if (empty ( $status ))
  3461. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3462. $page_size = 8;
  3463. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  3464. $vidList = array ();
  3465. $button = 0;
  3466. Doo::loadModel ( 'verify' );
  3467. $verify = new verify ();
  3468. Doo::loadModel ( 'receipt' );
  3469. $receipt = new receipt ();
  3470. Doo::loadModel ( 'staff' );
  3471. $staff = new staff ();
  3472. Doo::loadModel ( 'L_category' );
  3473. $Lcategory = new L_category ();
  3474. // user verify ID
  3475. $verifyDetail = $verify->find ( array (
  3476. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3477. 'asArray' => true
  3478. ) );
  3479. foreach ( $verifyDetail as $key => $value ) {
  3480. array_push ( $vidList, $value ['vid'] );
  3481. }
  3482. $vid = implode ( ",", $vidList );
  3483. if (empty ( $verifyDetail ))
  3484. $vid = 0;
  3485. // if ($status==0)
  3486. // $dateCondition="";
  3487. // else
  3488. $dateCondition = " ";
  3489. // if (! empty ( $month ))
  3490. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  3491. if ($status == 'done' || $status == 'termination') {
  3492. if (! empty ( $year )) {
  3493. $dateCondition = " and Year(pastDate) =" . $year;
  3494. if (! empty ( $month ))
  3495. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3496. }
  3497. } elseif ($status == 'finish') {
  3498. if (! empty ( $year )) {
  3499. $dateCondition = " and Year(pastDate) =" . $year;
  3500. if (! empty ( $month ))
  3501. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  3502. }
  3503. }
  3504. // date ( 'Y-m' )
  3505. // if (! empty ( $rdate ) && $status == 'done')
  3506. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  3507. // elseif (! empty ( $rdate ))
  3508. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  3509. $categoryList = $Lcategory->find ( array (
  3510. 'asArray' => true
  3511. ) );
  3512. $staffList = $staff->find ( array (
  3513. 'where' => 'cid=' . $cid,
  3514. 'asArray' => true
  3515. ) );
  3516. $cateCondition = "";
  3517. $staffCondition = "";
  3518. $approvalCondition = "";
  3519. if (! empty ( $cid )) {
  3520. $cateCondition = ' and cid=' . $cid;
  3521. }
  3522. if (! empty ( $sid )) {
  3523. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  3524. $cateCondition = "";
  3525. }
  3526. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  3527. if ($status == 'pendApproval') {
  3528. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3529. }
  3530. if ($status == 'ongoing') {
  3531. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  3532. }
  3533. if ($status == 'done') {
  3534. $approvalCondition = ' and (status=8 or status=9 ) ';
  3535. }
  3536. if ($status == 'termination') {
  3537. $approvalCondition = " and status=3";
  3538. }
  3539. if ($status == 'finish') {
  3540. $approvalCondition = " and (status=1 or status=8 or status=9)";
  3541. }
  3542. $pageinfo ['page'] = array (
  3543. 'previous' => ''
  3544. );
  3545. if(!empty($receiptOrder)){
  3546. $pageinfo = $this->get_page ( "CLD_receipt", ' and receiptOrder like "%' . $receiptOrder . '%"', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3547. $receiptList = $receipt->find ( array ( // $dateCondition
  3548. 'where' => 'receiptOrder like "%' . $receiptOrder . '%"',
  3549. 'desc' => 'rid',
  3550. 'asArray' => true
  3551. ) );
  3552. }else{
  3553. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  3554. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  3555. $receiptList = $receipt->find ( array ( // $dateCondition.
  3556. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3557. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  3558. 'desc' => 'rid',
  3559. 'asArray' => true
  3560. ) );
  3561. } else {
  3562. $receiptList = $receipt->find ( array ( // $dateCondition
  3563. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  3564. 'desc' => 'rid',
  3565. 'asArray' => true
  3566. ) );
  3567. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3568. }
  3569. }
  3570. $rLRes = $receipt->find ( array (
  3571. '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 . ')',
  3572. 'desc' => 'rid',
  3573. 'asArray' => true
  3574. ) );
  3575. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  3576. // print_r($receiptList);
  3577. Doo::loadClass ( 'XDeode' );
  3578. $XDeode = new XDeode ( 7 );
  3579. $Locate = 0;
  3580. $reportList = $reportCateList = array ();
  3581. foreach ( $receiptList as $key => $value ) {
  3582. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  3583. $receiptList [$key] ['Locate'] = $Locate;
  3584. $Locate ++;
  3585. $receiptList [$key] ['reviseDetail'] = array ();
  3586. if (! empty ( $value ['reviseDetail'] ))
  3587. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3588. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3589. $categoryDetil = $Lcategory->getOne ( array (
  3590. 'where' => 'cid=' . $value ['cid'],
  3591. 'asArray' => true
  3592. ) );
  3593. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3594. $verifyList = $verify->getOne ( array (
  3595. 'where' => 'vid=' . $value ['verify'],
  3596. 'asArray' => true
  3597. ) );
  3598. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3599. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3600. foreach ( $verifyList as $k => $v ) {
  3601. // init verifyStaff
  3602. $verifyList [$k] ['date'] = "";
  3603. $verifyList [$k] ['opinion'] = "";
  3604. $verifyList [$k] ['status'] = "";
  3605. if (empty ( $verifyStaff )) {
  3606. $verifyList [$k] ['date'] = "";
  3607. $verifyList [$k] ['opinion'] = "";
  3608. if ($v [0] == $this->staff [0] ['sid']) {
  3609. $verifyList [$k] ['status'] = 4;
  3610. $button = 4;
  3611. }
  3612. } else {
  3613. $flag = true;
  3614. foreach ( $verifyStaff as $m => $u ) {
  3615. if ($v [0] == $m) {
  3616. $verifyList [$k] ['date'] = $u ['date'];
  3617. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3618. $verifyList [$k] ['status'] = $u ['status'];
  3619. $flag = false;
  3620. break;
  3621. }
  3622. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  3623. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  3624. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  3625. }
  3626. if ($flag) { // 检测可编辑
  3627. if ($v [0] == $this->staff [0] ['sid']) {
  3628. $verifyList [$k] ['status'] = 4;
  3629. $button = 4;
  3630. }
  3631. }
  3632. }
  3633. }
  3634. $receiptList [$key] ['verifyList'] = $verifyList;
  3635. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3636. 'where' => 'sid=' . $value ['staff'],
  3637. 'asArray' => true
  3638. ) );
  3639. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3640. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  3641. $receiptList [$key] ['button'] = $button;
  3642. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  3643. }
  3644. $reportList = array_unique ( $reportList );
  3645. $reportHtml = '';
  3646. foreach ( $reportList as $key => $value ) {
  3647. $v = explode ( "-", $value );
  3648. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  3649. }
  3650. // print_r($reportList)
  3651. $data ['reportHtml'] = $reportHtml;
  3652. $reportCateList = array_unique ( $reportCateList );
  3653. $reportCateHtml = '';
  3654. foreach ( $reportCateList as $key => $value ) {
  3655. $v = explode ( "-", $value );
  3656. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  3657. }
  3658. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  3659. $data ['reportCateHtml'] = $reportCateHtml;
  3660. // print_r($receiptList);die;
  3661. // $data['verifyDetail']=$verifyDetail;
  3662. $mothHtml = "";
  3663. for($i = 1; $i <= 12; $i ++) {
  3664. if ($month == $i)
  3665. $mothHtml .= '<option selected value="0' . $i . '">' . $i . '月</option>';
  3666. else
  3667. $mothHtml .= '<option value="0' . $i . '">' . $i . '月</option>';
  3668. }
  3669. $data ['mothHtml'] = $mothHtml;
  3670. $dateHtml = "";
  3671. $now = date ( "Y" );
  3672. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  3673. if ($YEARD <= $now) {
  3674. $dateHtml .= '<option ';
  3675. if ($year == $YEARD) {
  3676. $dateHtml .= 'selected ';
  3677. }
  3678. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  3679. }
  3680. }
  3681. $data ['dateHtml'] = $dateHtml;
  3682. $data ['page'] = $pageinfo;
  3683. $data ['receiptList'] = $receiptList;
  3684. $data ['receiptApprovalCount'] = count ( $rLRes );
  3685. $data ['status'] = $status;
  3686. $data ['year'] = $year;
  3687. $data ['month'] = $month;
  3688. $data ['categoryList'] = $categoryList;
  3689. $data ['staffList'] = $staffList;
  3690. $data ['cid'] = $cid;
  3691. $data ['sid'] = $sid;
  3692. // print_r($receiptList);
  3693. $data['receiptOrder']=$receiptOrder;
  3694. $data ['memu'] = "receipt";
  3695. $data ['staff'] = $this->staff;
  3696. $data ['receiptMemu'] = 'approvalExpenses';
  3697. $data ['verifyId'] = $this->verifyId;
  3698. $data ['executeId'] = $this->executeId;
  3699. $this->render ( "/admin/approvalExpenses", $data );
  3700. }
  3701. function expensesDoc() {
  3702. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  3703. Doo::loadClass ( 'XDeode' );
  3704. $XDeode = new XDeode ( 5 );
  3705. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  3706. $rid = $XDeode->decode ( $rid );
  3707. if (! is_numeric ( $rid ))
  3708. die ( 'illegal request' );
  3709. Doo::loadModel ( 'receipt' );
  3710. $receipt = new receipt ();
  3711. Doo::loadModel ( 'L_category' );
  3712. $Lcategory = new L_category ();
  3713. Doo::loadModel ( 'verify' );
  3714. Doo::loadModel ( 'statistics' );
  3715. $statistics = new statistics ();
  3716. $verify = new verify ();
  3717. Doo::loadModel ( 'staff' );
  3718. $staff = new staff ();
  3719. Doo::loadModel ( 'loanReceipt' );
  3720. $loanReceipt = new loanReceipt ();
  3721. $receiptList = $receipt->find ( array (
  3722. 'where' => ' rid=' . $rid,
  3723. 'desc' => 'rid',
  3724. 'asArray' => true
  3725. ) );
  3726. $loanList = array ();
  3727. if (! empty ( $receiptList ))
  3728. $loanList = $loanReceipt->find ( array (
  3729. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3730. 'desc' => 'rid',
  3731. 'asArray' => true
  3732. ) );
  3733. $Locate = 0;
  3734. $roleId = 0;
  3735. $button = 0;
  3736. foreach ( $loanList as $key => $value ) {
  3737. $loanList [$key] ['Locate'] = $Locate;
  3738. $Locate ++;
  3739. $loanList [$key] ['reviseDetail'] = array ();
  3740. if (! empty ( $value ['reviseDetail'] ))
  3741. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3742. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3743. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3744. $categoryDetil = $Lcategory->getOne ( array (
  3745. 'where' => 'cid=' . $value ['cid'],
  3746. 'asArray' => true
  3747. ) );
  3748. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3749. // 检测编辑状态
  3750. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  3751. $verifyList ['staff'] = $value ['verifyBreakup'];
  3752. else
  3753. $verifyList = $verify->getOne ( array (
  3754. 'where' => 'vid=' . $value ['verify'],
  3755. 'asArray' => true
  3756. ) );
  3757. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3758. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3759. Doo::loadModel ( 'role' );
  3760. $role = new role ();
  3761. $flag = true;
  3762. $roleKey = 0;
  3763. $endStaffArray = array ();
  3764. $roleArrayCopy = array ();
  3765. foreach ( $verifyList as $k => $v ) {
  3766. // init verifyStaff
  3767. if ($v [1] == 'ROLE') {
  3768. if (! empty ( $verifyStaff )) {
  3769. $endStaffArray = end ( $verifyStaff );
  3770. // if ($v[0]==$endStaffArray['nextStaff']){
  3771. // $roleId=$v[0];
  3772. // }
  3773. }
  3774. $roleVerify = json_decode ( $v [3], true );
  3775. $roleKey = $k;
  3776. $roleArray = array ();
  3777. $rolename = $role->getOne ( array (
  3778. 'where' => 'rid=' . $v [0],
  3779. 'asArray' => true
  3780. ) );
  3781. foreach ( $roleVerify as $o => $p ) {
  3782. $staffID = explode ( '_', $p );
  3783. $staffInfo = $staff->getOne ( array (
  3784. 'where' => 'sid=' . $staffID [0],
  3785. 'asArray' => true
  3786. ) );
  3787. // print_r($staffID);
  3788. $exp = array (
  3789. 0 => $staffInfo ['sid'],
  3790. 1 => $staffID [1],
  3791. 2 => $staffInfo ['avatar'],
  3792. 'date' => '',
  3793. 'date' => '',
  3794. 'opinion' => '',
  3795. 'status' => '',
  3796. 'rolename' => $rolename ['name']
  3797. );
  3798. array_push ( $roleArray, $exp );
  3799. }
  3800. $roleArrayCopy [$v [0]] = $roleArray;
  3801. // $verifyList[$k]['roleArray']=$roleArray;
  3802. }
  3803. $verifyList [$k] ['date'] = "";
  3804. $verifyList [$k] ['opinion'] = "";
  3805. $verifyList [$k] ['status'] = "";
  3806. if (empty ( $verifyStaff )) {
  3807. $verifyList [$k] ['date'] = "";
  3808. $verifyList [$k] ['opinion'] = "";
  3809. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3810. $verifyList [$k] ['status'] = 4;
  3811. $flag = false;
  3812. }
  3813. } else {
  3814. foreach ( $verifyStaff as $m => $u ) {
  3815. if ($v [0] == $m) {
  3816. $verifyList [$k] ['date'] = $u ['date'];
  3817. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3818. $verifyList [$k] ['status'] = $u ['status'];
  3819. $flag = false;
  3820. break;
  3821. }
  3822. }
  3823. $endStaffArray = end ( $verifyStaff );
  3824. if (isset ( $endStaffArray ['ROLE'] )) {
  3825. } else {
  3826. // $endKey=key($verifyStaff);
  3827. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3828. // $button=4;
  3829. // $verifyList[$k]['status']=4;
  3830. // }
  3831. }
  3832. }
  3833. }
  3834. $rolename ['name'] = '';
  3835. if (! empty ( $roleId )) {
  3836. Doo::loadModel ( 'role' );
  3837. $role = new role ();
  3838. $rolename = $role->getOne ( array (
  3839. 'where' => 'rid=' . $roleId,
  3840. 'asArray' => true
  3841. ) );
  3842. }
  3843. if (! empty ( $verifyStaff ))
  3844. $endStaffArray = end ( $verifyStaff );
  3845. $KOP = false;
  3846. foreach ( $roleArrayCopy as $P => $A ) {
  3847. foreach ( $A as $MKI => $AVL ) {
  3848. if (! empty ( $verifyStaff )) {
  3849. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3850. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3851. $button = 4;
  3852. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3853. }
  3854. foreach ( $verifyStaff as $m => $u ) {
  3855. $AVLFK = $AVL [0] . '_R';
  3856. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3857. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3858. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3859. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3860. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3861. break;
  3862. }
  3863. }
  3864. } else {
  3865. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3866. $button = 4;
  3867. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3868. }
  3869. }
  3870. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3871. $KOP = true;
  3872. }
  3873. }
  3874. foreach ( $roleArrayCopy as $k => $v ) {
  3875. foreach ( $verifyList as $m => $n ) {
  3876. if ($n [0] == $k) {
  3877. array_splice ( $verifyList, $m, 1, $v );
  3878. }
  3879. }
  3880. }
  3881. $loanList [$key] ['verifyList'] = $verifyList;
  3882. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3883. 'where' => 'sid=' . $value ['staff'],
  3884. 'asArray' => true
  3885. ) );
  3886. $loanList [$key] ['button'] = $button;
  3887. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  3888. }
  3889. $data ['loanList'] = $loanList;
  3890. // print_r($loanList);
  3891. $Locate = 0;
  3892. $roleId = 0;
  3893. $button = 0;
  3894. foreach ( $receiptList as $key => $value ) {
  3895. $receiptList [$key] ['Locate'] = $Locate;
  3896. $Locate ++;
  3897. $receiptList [$key] ['reviseDetail'] = array ();
  3898. if (! empty ( $value ['reviseDetail'] ))
  3899. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3900. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3901. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3902. $categoryDetil = $Lcategory->getOne ( array (
  3903. 'where' => 'cid=' . $value ['cid'],
  3904. 'asArray' => true
  3905. ) );
  3906. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3907. // 检测编辑状态
  3908. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3909. $verifyList ['staff'] = $value ['verifyBreakup'];
  3910. } else
  3911. $verifyList = $verify->getOne ( array (
  3912. 'where' => 'vid=' . $value ['verify'],
  3913. 'asArray' => true
  3914. ) );
  3915. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3916. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3917. Doo::loadModel ( 'role' );
  3918. $role = new role ();
  3919. if ($verifyList == NULL)
  3920. $verifyList = array ();
  3921. $flag = true;
  3922. $roleKey = 0;
  3923. $endStaffArray = array ();
  3924. $roleArrayCopy = array ();
  3925. foreach ( $verifyList as $k => $v ) {
  3926. // init verifyStaff
  3927. if ($v [1] == 'ROLE') {
  3928. if (! empty ( $verifyStaff )) {
  3929. $endStaffArray = end ( $verifyStaff );
  3930. // if ($v[0]==$endStaffArray['nextStaff']){
  3931. // $roleId=$v[0];
  3932. // }
  3933. }
  3934. $roleVerify = json_decode ( $v [3], true );
  3935. $roleKey = $k;
  3936. $roleArray = array ();
  3937. $rolename = $role->getOne ( array (
  3938. 'where' => 'rid=' . $v [0],
  3939. 'asArray' => true
  3940. ) );
  3941. foreach ( $roleVerify as $o => $p ) {
  3942. $staffID = explode ( '_', $p );
  3943. $staffInfo = $staff->getOne ( array (
  3944. 'where' => 'sid=' . $staffID [0],
  3945. 'asArray' => true
  3946. ) );
  3947. // print_r($staffID);
  3948. $exp = array (
  3949. 0 => $staffInfo ['sid'],
  3950. 1 => $staffID [1],
  3951. 2 => $staffInfo ['avatar'],
  3952. 'date' => '',
  3953. 'date' => '',
  3954. 'opinion' => '',
  3955. 'status' => '',
  3956. 'rolename' => $rolename ['name']
  3957. );
  3958. array_push ( $roleArray, $exp );
  3959. }
  3960. $roleArrayCopy [$v [0]] = $roleArray;
  3961. // $verifyList[$k]['roleArray']=$roleArray;
  3962. }
  3963. $verifyList [$k] ['date'] = "";
  3964. $verifyList [$k] ['opinion'] = "";
  3965. $verifyList [$k] ['status'] = "";
  3966. if (empty ( $verifyStaff )) {
  3967. $verifyList [$k] ['date'] = "";
  3968. $verifyList [$k] ['opinion'] = "";
  3969. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3970. $verifyList [$k] ['status'] = 4;
  3971. $flag = false;
  3972. }
  3973. } else {
  3974. foreach ( $verifyStaff as $m => $u ) {
  3975. if ($v [0] == $m) {
  3976. $verifyList [$k] ['date'] = $u ['date'];
  3977. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3978. $verifyList [$k] ['status'] = $u ['status'];
  3979. $flag = false;
  3980. break;
  3981. }
  3982. }
  3983. $endStaffArray = end ( $verifyStaff );
  3984. if (isset ( $endStaffArray ['ROLE'] )) {
  3985. } else {
  3986. // $endKey=key($verifyStaff);
  3987. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3988. // $button=4;
  3989. // $verifyList[$k]['status']=4;
  3990. // }
  3991. }
  3992. }
  3993. }
  3994. $FC = @$rolename ['name'];
  3995. $rolename ['name'] = '';
  3996. if (! empty ( $roleId )) {
  3997. Doo::loadModel ( 'role' );
  3998. $role = new role ();
  3999. $rolename = $role->getOne ( array (
  4000. 'where' => 'rid=' . $roleId,
  4001. 'asArray' => true
  4002. ) );
  4003. }
  4004. if (! empty ( $verifyStaff ))
  4005. $endStaffArray = end ( $verifyStaff );
  4006. $KOP = false;
  4007. foreach ( $roleArrayCopy as $P => $A ) {
  4008. foreach ( $A as $MKI => $AVL ) {
  4009. if (! empty ( $verifyStaff )) {
  4010. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4011. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4012. $button = 4;
  4013. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4014. }
  4015. foreach ( $verifyStaff as $m => $u ) {
  4016. $AVLFK = $AVL [0] . '_R';
  4017. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4018. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4019. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4020. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4021. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4022. break;
  4023. }
  4024. }
  4025. } else {
  4026. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4027. $button = 4;
  4028. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4029. }
  4030. }
  4031. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4032. $KOP = true;
  4033. }
  4034. }
  4035. foreach ( $roleArrayCopy as $k => $v ) {
  4036. foreach ( $verifyList as $m => $n ) {
  4037. if ($n [0] == $k) {
  4038. array_splice ( $verifyList, $m, 1, $v );
  4039. }
  4040. }
  4041. }
  4042. // 费用执行人相关数据
  4043. $executeCopy = json_decode ( $value ['executeCopy'], true );
  4044. $executeStaff = json_decode ( $value ['executeStaff'], true );
  4045. foreach ( $executeCopy as $k => $v ) {
  4046. $executeCopy [$k] ['date'] = '';
  4047. $executeCopy [$k] ['opinion'] = '';
  4048. $executeCopy [$k] ['status'] = '';
  4049. if (! empty ( $executeStaff ))
  4050. foreach ( $executeStaff as $m => $u ) {
  4051. if ($v [0] == $m) {
  4052. $executeCopy [$k] ['date'] = $u ['date'];
  4053. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  4054. $executeCopy [$k] ['status'] = $u ['status'];
  4055. break;
  4056. }
  4057. }
  4058. }
  4059. $receiptList [$key] ['executeCopy'] = $executeCopy;
  4060. // print_r($verifyList);
  4061. $receiptList [$key] ['verifyList'] = $verifyList;
  4062. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4063. 'where' => 'sid=' . $value ['staff'],
  4064. 'asArray' => true
  4065. ) );
  4066. $receiptList [$key] ['button'] = $button;
  4067. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4068. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4069. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4070. $receiptList [$key] ['relust'] = $relust;
  4071. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4072. }
  4073. // print_r($receiptList);
  4074. // 获取审批日志
  4075. Doo::loadModel ( 'receiptLog' );
  4076. $receiptLog = new receiptLog ();
  4077. $rlList = array ();
  4078. $rlInfo = $receiptLog->getOne ( array (
  4079. 'where' => 'rid=' . $rid . ' and status=4',
  4080. 'asArray' => true
  4081. ) );
  4082. $tijdate = $receiptLog->getOne ( array (
  4083. 'where' => 'rid=' . $rid . ' and status=2',
  4084. 'asc' => 'rlid',
  4085. 'asArray' => true
  4086. ) );
  4087. if (! empty ( $rlInfo )) {
  4088. $rlList = $receiptLog->find ( array (
  4089. 'where' => 'rid=' . $rid,
  4090. 'asc' => 'rlid',
  4091. 'asArray' => true
  4092. ) );
  4093. }
  4094. $RN = @json_decode ( $rolename ['staff'] );
  4095. //
  4096. foreach ( $rlList as $key => $value ) {
  4097. $rlList [$key] ['rolename'] = '';
  4098. foreach ( $RN as $k => $v ) {
  4099. $id = explode ( "_", $v );
  4100. if ($id [0] == $value ['uid']) {
  4101. $rlList [$key] ['rolename'] = $FC;
  4102. break;
  4103. }
  4104. }
  4105. }
  4106. Doo::loadModel ( 'enclosur' );
  4107. $enclosur = new enclosur ();
  4108. $enclosurList = $enclosur->find ( array (
  4109. 'where' => 'rid=' . $rid,
  4110. 'asArray' => true
  4111. ) );
  4112. $enclosurHtml = '';
  4113. foreach ( $enclosurList as $value ) {
  4114. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4115. }
  4116. $data ['enclosurHtml'] = $enclosurHtml;
  4117. $receiptList [0] ['rlList'] = $rlList;
  4118. $data ['receiptList'] = $receiptList;
  4119. // print_r($receiptList);
  4120. $data ['memu'] = "receipt";
  4121. $data ['staff'] = $this->staff;
  4122. $data ['receiptMemu'] = 'approvalExpenses';
  4123. $data ['verifyId'] = $this->verifyId;
  4124. $data ['executeId'] = $this->executeId;
  4125. $this->render ( "/admin/expensesDoc", $data );
  4126. }
  4127. function expensesEdi() {
  4128. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4129. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4130. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4131. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4132. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4133. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4134. if (empty ( $status ))
  4135. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4136. $vidList = array ();
  4137. $button = 0;
  4138. Doo::loadModel ( 'verify' );
  4139. Doo::loadModel ( 'receipt' );
  4140. Doo::loadModel ( 'staff' );
  4141. $staff = new staff ();
  4142. $receipt = new receipt ();
  4143. $verify = new verify ();
  4144. Doo::loadModel ( 'L_category' );
  4145. $Lcategory = new L_category ();
  4146. Doo::loadModel ( 'enclosur' );
  4147. $enclosur = new enclosur ();
  4148. // user verify ID
  4149. $verifyDetail = $verify->find ( array (
  4150. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4151. 'asArray' => true
  4152. ) );
  4153. foreach ( $verifyDetail as $key => $value ) {
  4154. array_push ( $vidList, $value ['vid'] );
  4155. }
  4156. $vid = implode ( ",", $vidList );
  4157. if (empty ( $verifyDetail ))
  4158. $vid = 0;
  4159. $categoryList = $Lcategory->find ( array (
  4160. 'asArray' => true
  4161. ) );
  4162. $staffList = $staff->find ( array (
  4163. 'where' => 'cid=' . $cid,
  4164. 'asArray' => true
  4165. ) );
  4166. $ap = "";
  4167. if ($status == 4) {
  4168. $ap = 4;
  4169. $status = 2;
  4170. }
  4171. // get Receipt By verifyID status 2
  4172. $receiptList = $receipt->find ( array (
  4173. 'where' => 'rid =' . $rid . ' and status=2',
  4174. 'desc' => 'rid',
  4175. 'asArray' => true
  4176. ) );
  4177. if (empty ( $receiptList )) {
  4178. die ( 'illegal request' );
  4179. }
  4180. $Locate = 0;
  4181. $roleId = 0;
  4182. if ($ap == 4)
  4183. $status = 4;
  4184. foreach ( $receiptList as $key => $value ) {
  4185. $receiptList [$key] ['Locate'] = $Locate;
  4186. $Locate ++;
  4187. $receiptList [$key] ['reviseDetail'] = array ();
  4188. if (! empty ( $value ['reviseDetail'] ))
  4189. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4190. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4191. $categoryDetil = $Lcategory->getOne ( array (
  4192. 'where' => 'cid=' . $value ['cid'],
  4193. 'asArray' => true
  4194. ) );
  4195. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4196. // 检测编辑状态
  4197. $verifyList = $verify->getOne ( array (
  4198. 'where' => 'vid=' . $value ['verify'],
  4199. 'asArray' => true
  4200. ) );
  4201. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4202. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4203. Doo::loadModel ( 'role' );
  4204. $role = new role ();
  4205. // print_r($verifyList);
  4206. $flag = true;
  4207. $roleKey = 0;
  4208. $endStaffArray = array ();
  4209. $roleArrayCopy = array ();
  4210. foreach ( $verifyList as $k => $v ) {
  4211. // init verifyStaff
  4212. if ($v [1] == 'ROLE') {
  4213. if (! empty ( $verifyStaff )) {
  4214. $endStaffArray = end ( $verifyStaff );
  4215. if ($v [0] == $endStaffArray ['nextStaff']) {
  4216. $roleId = $v [0];
  4217. }
  4218. }
  4219. $roleVerify = json_decode ( $v [3], true );
  4220. $roleKey = $k;
  4221. $roleArray = array ();
  4222. $rolename = $role->getOne ( array (
  4223. 'where' => 'rid=' . $v [0],
  4224. 'asArray' => true
  4225. ) );
  4226. foreach ( $roleVerify as $o => $p ) {
  4227. $staffID = explode ( '_', $p );
  4228. $staffInfo = $staff->getOne ( array (
  4229. 'where' => 'sid=' . $staffID [0],
  4230. 'asArray' => true
  4231. ) );
  4232. // print_r($staffID);
  4233. $exp = array (
  4234. 0 => $staffInfo ['sid'],
  4235. 1 => $staffID [1],
  4236. 2 => $staffInfo ['avatar'],
  4237. 'date' => '',
  4238. 'date' => '',
  4239. 'opinion' => '',
  4240. 'status' => '',
  4241. 'rolename' => $rolename ['name']
  4242. );
  4243. array_push ( $roleArray, $exp );
  4244. }
  4245. $roleArrayCopy [$v [0]] = $roleArray;
  4246. // $verifyList[$k]['roleArray']=$roleArray;
  4247. }
  4248. // print_r($roleArray);
  4249. $verifyList [$k] ['date'] = "";
  4250. $verifyList [$k] ['opinion'] = "";
  4251. $verifyList [$k] ['status'] = "";
  4252. if (empty ( $verifyStaff )) {
  4253. $verifyList [$k] ['date'] = "";
  4254. $verifyList [$k] ['opinion'] = "";
  4255. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4256. $verifyList [$k] ['status'] = 4;
  4257. $button = 4;
  4258. $flag = false;
  4259. }
  4260. } else {
  4261. foreach ( $verifyStaff as $m => $u ) {
  4262. if ($v [0] == $m) {
  4263. $verifyList [$k] ['date'] = $u ['date'];
  4264. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4265. $verifyList [$k] ['status'] = $u ['status'];
  4266. $flag = false;
  4267. break;
  4268. }
  4269. }
  4270. $endStaffArray = end ( $verifyStaff );
  4271. if (isset ( $endStaffArray ['ROLE'] )) {
  4272. } else {
  4273. $endKey = key ( $verifyStaff );
  4274. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4275. $button = 4;
  4276. $verifyList [$k] ['status'] = 4;
  4277. }
  4278. }
  4279. }
  4280. }
  4281. $rolename ['name'] = '';
  4282. if (! empty ( $roleId )) {
  4283. Doo::loadModel ( 'role' );
  4284. $role = new role ();
  4285. $rolename = $role->getOne ( array (
  4286. 'where' => 'rid=' . $roleId,
  4287. 'asArray' => true
  4288. ) );
  4289. }
  4290. if (! empty ( $verifyStaff ))
  4291. $endStaffArray = end ( $verifyStaff );
  4292. $KOP = false;
  4293. foreach ( $roleArrayCopy as $P => $A ) {
  4294. foreach ( $A as $MKI => $AVL ) {
  4295. if (! empty ( $verifyStaff )) {
  4296. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4297. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4298. $button = 4;
  4299. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4300. }
  4301. foreach ( $verifyStaff as $m => $u ) {
  4302. $AVLFK = $AVL [0] . '_R';
  4303. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4304. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4305. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4306. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4307. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4308. break;
  4309. }
  4310. }
  4311. } else {
  4312. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4313. $button = 4;
  4314. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4315. }
  4316. }
  4317. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4318. $KOP = true;
  4319. }
  4320. }
  4321. // print_r($roleArrayCopy);
  4322. // echo $roleKey;
  4323. foreach ( $roleArrayCopy as $k => $v ) {
  4324. foreach ( $verifyList as $m => $n ) {
  4325. if ($n [0] == $k) {
  4326. array_splice ( $verifyList, $m, 1, $v );
  4327. }
  4328. }
  4329. }
  4330. $receiptList [$key] ['verifyList'] = $verifyList;
  4331. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4332. 'where' => 'sid=' . $value ['staff'],
  4333. 'asArray' => true
  4334. ) );
  4335. $receiptList [$key] ['button'] = $button;
  4336. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  4337. }
  4338. // $data['verifyDetail']=$verifyDetail;
  4339. $mothHtml = "";
  4340. for($i = 1; $i <= 12; $i ++) {
  4341. if ($month == $i)
  4342. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4343. else
  4344. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4345. }
  4346. // 获取审批日志
  4347. Doo::loadModel ( 'receiptLog' );
  4348. $receiptLog = new receiptLog ();
  4349. $rlList = array ();
  4350. $rlInfo = $receiptLog->getOne ( array (
  4351. 'where' => 'rid=' . $rid . ' and status=4',
  4352. 'asArray' => true
  4353. ) );
  4354. $tijdate = $receiptLog->getOne ( array (
  4355. 'where' => 'rid=' . $rid . ' and status=2',
  4356. 'asc' => 'rlid',
  4357. 'asArray' => true
  4358. ) );
  4359. if (! empty ( $rlInfo )) {
  4360. $rlList = $receiptLog->find ( array (
  4361. 'where' => 'rid=' . $rid,
  4362. 'asc' => 'rlid',
  4363. 'asArray' => true
  4364. ) );
  4365. }
  4366. $receiptList [0] ['rlList'] = $rlList;
  4367. $enclosurList = $enclosur->find ( array (
  4368. 'where' => 'rid=' . $rid,
  4369. 'asArray' => true
  4370. ) );
  4371. $enclosurHtml = '';
  4372. foreach ( $enclosurList as $value ) {
  4373. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4374. }
  4375. // print_r($receiptList);
  4376. $data ['rid'] = $rid;
  4377. $data ['enclosurHtml'] = $enclosurHtml;
  4378. $data ['rolename'] = $rolename ['name'];
  4379. $data ['datetij'] = $tijdate ['date'];
  4380. $data ['mothHtml'] = $mothHtml;
  4381. $data ['receiptList'] = $receiptList;
  4382. $data ['receiptApprovalCount'] = count ( $receiptList );
  4383. $data ['status'] = $status;
  4384. $data ['year'] = $year;
  4385. $data ['categoryList'] = $categoryList;
  4386. $data ['staffList'] = $staffList;
  4387. $data ['cid'] = $cid;
  4388. $data ['sid'] = $sid;
  4389. $data ['ap'] = $ap;
  4390. $data ['memu'] = "receipt";
  4391. $data ['staff'] = $this->staff;
  4392. $data ['receiptMemu'] = 'approvalExpenses';
  4393. $data ['verifyId'] = $this->verifyId;
  4394. $data ['executeId'] = $this->executeId;
  4395. $this->render ( "/admin/expensesEdi", $data );
  4396. }
  4397. function expensesDefray() {
  4398. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4399. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  4400. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4401. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  4402. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  4403. if (! empty ( $rid )) {
  4404. Doo::loadModel ( "verify" );
  4405. $verify = new verify ();
  4406. Doo::loadModel ( "receiptDetail" );
  4407. $receiptDetailObj = new receiptDetail ();
  4408. Doo::loadModel ( "itemStatistics" );
  4409. Doo::loadModel ( "statistics" );
  4410. $statistics = new statistics ();
  4411. $itemStatistics = new itemStatistics ();
  4412. Doo::loadModel ( "receipt" );
  4413. $receipt = new receipt ();
  4414. Doo::loadModel ( "loanReceipt" );
  4415. $loanReceipt = new loanReceipt ();
  4416. $receiptDetail = $receipt->getOne ( array (
  4417. 'where' => 'rid=' . $rid . ' and status=2 ',
  4418. 'asArray' => true
  4419. ) );
  4420. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  4421. $nsflag = true;
  4422. foreach ( $nslist as $value ) {
  4423. if ($value == $this->staff ['0'] ['sid']) {
  4424. $nsflag = false;
  4425. break;
  4426. }
  4427. }
  4428. // print_r($nslist);die;
  4429. if (empty ( $receiptDetail ) || $nsflag)
  4430. return "/approvalExpenses/pendApproval";
  4431. $verifyDetail = $verify->getOne ( array (
  4432. 'where' => ' vid =' . $receiptDetail ['verify'],
  4433. 'asArray' => true
  4434. ) );
  4435. $verifyString = $verifyDetail ['staff'];
  4436. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  4437. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  4438. if (empty ( $opinion )) {
  4439. if ($status == 3)
  4440. $opinion = "终止";
  4441. else
  4442. $opinion = "同意支付";
  4443. }
  4444. $nowStaff = 0;
  4445. $nowStaffList = array ();
  4446. if (empty ( $verifyStaff )) {
  4447. // 还需加入是否已经进入角色审批
  4448. if ($verifyDetail [0] [1] == 'ROLE') {
  4449. // print_r($verifyDetail);echo "ddd";
  4450. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  4451. foreach ( $vStaffString as $key => $value ) {
  4452. $staffK = explode ( "_", $value );
  4453. if ($staffK [0] != $this->staff [0] ['sid'])
  4454. array_push ( $nowStaffList, $staffK [0] );
  4455. }
  4456. // print_r($verifyDetail);
  4457. // die;
  4458. if (! empty ( $nowStaffList )) {
  4459. $nowStaff = implode ( ',', $nowStaffList );
  4460. $verifyStaff = array (
  4461. $this->staff [0] ['sid'] . "_R" => array (
  4462. 'date' => date ( 'Y-m-d' ),
  4463. 'opinion' => $opinion,
  4464. 'status' => $status,
  4465. 'nextStaff' => $verifyDetail [0] [0],
  4466. 'ROLE' => 1
  4467. )
  4468. );
  4469. } else {
  4470. $nowStaff = $verifyDetail [1] [0];
  4471. $verifyStaff = array (
  4472. $this->staff [0] ['sid'] . "_R" => array (
  4473. 'date' => date ( 'Y-m-d' ),
  4474. 'opinion' => $opinion,
  4475. 'status' => $status,
  4476. 'nextStaff' => $verifyDetail [1] [0]
  4477. )
  4478. );
  4479. }
  4480. } else {
  4481. if ($verifyDetail [1] [1] == 'ROLE') {
  4482. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  4483. // echo "dd";
  4484. foreach ( $vStaffString as $key => $value ) {
  4485. $staffK = explode ( "_", $value );
  4486. array_push ( $nowStaffList, $staffK [0] );
  4487. }
  4488. $nowStaff = implode ( ',', $nowStaffList );
  4489. $verifyStaff = array (
  4490. $this->staff [0] ['sid'] => array (
  4491. 'date' => date ( 'Y-m-d' ),
  4492. 'opinion' => $opinion,
  4493. 'status' => $status,
  4494. 'nextStaff' => $verifyDetail [1] [0],
  4495. 'ROLE' => 1
  4496. )
  4497. );
  4498. } else {
  4499. $nowStaff = $verifyDetail [1] [0];
  4500. $verifyStaff = array (
  4501. $this->staff [0] ['sid'] => array (
  4502. 'date' => date ( 'Y-m-d' ),
  4503. 'opinion' => $opinion,
  4504. 'status' => $status,
  4505. 'nextStaff' => $verifyDetail [1] [0]
  4506. )
  4507. );
  4508. }
  4509. }
  4510. if ($status == 3)
  4511. $verifyStaff = array (
  4512. 'final' => $status,
  4513. $this->staff [0] ['sid'] => array (
  4514. 'date' => date ( 'Y-m-d' ),
  4515. 'opinion' => $opinion,
  4516. 'status' => $status
  4517. )
  4518. );
  4519. $vStaffString = json_encode ( $verifyStaff );
  4520. $receipt->nowStaff = $nowStaff;
  4521. $receipt->verifyStaff = $vStaffString;
  4522. $loanReceipt->nowStaff = $nowStaff;
  4523. $loanReceipt->verifyStaff = $vStaffString;
  4524. } else {
  4525. $VS = end ( $verifyStaff );
  4526. // 非角色审批
  4527. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  4528. $nextStaff = 0;
  4529. $roleSTF = false;
  4530. foreach ( $verifyDetail as $key => $value ) {
  4531. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  4532. if (isset ( $verifyDetail [$key + 1] )) {
  4533. $nextStaff = $verifyDetail [$key + 1] [0];
  4534. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  4535. $roleSTF = true;
  4536. }
  4537. break;
  4538. }
  4539. }
  4540. if (! $roleSTF) {
  4541. $nowStaff = $nextStaff;
  4542. $verifyStaff [$this->staff [0] ['sid']] = array (
  4543. 'date' => date ( 'Y-m-d' ),
  4544. 'opinion' => $opinion,
  4545. 'status' => $status,
  4546. 'nextStaff' => $nextStaff
  4547. );
  4548. } else {
  4549. // 获取角色下的所有用户ID
  4550. $nowStaffList = array ();
  4551. foreach ( $verifyDetail as $vfk ) {
  4552. if ($vfk [1] == 'ROLE') {
  4553. $vStaffString = json_decode ( $vfk [3] );
  4554. foreach ( $vStaffString as $key => $value ) {
  4555. $staffK = explode ( "_", $value );
  4556. array_push ( $nowStaffList, $staffK [0] );
  4557. }
  4558. }
  4559. }
  4560. $nowStaff = implode ( ',', $nowStaffList );
  4561. $verifyStaff [$this->staff [0] ['sid']] = array (
  4562. 'date' => date ( 'Y-m-d' ),
  4563. 'opinion' => $opinion,
  4564. 'status' => $status,
  4565. 'nextStaff' => $nextStaff,
  4566. 'ROLE' => 0
  4567. );
  4568. }
  4569. if ($status == 3) {
  4570. $verifyStaff ['final'] = $status;
  4571. $verifyStaff [$this->staff [0] ['sid']] = array (
  4572. 'date' => date ( 'Y-m-d' ),
  4573. 'opinion' => $opinion,
  4574. 'status' => $status
  4575. );
  4576. }
  4577. $vStaffString = json_encode ( $verifyStaff );
  4578. $receipt->nowStaff = $nowStaff;
  4579. $receipt->verifyStaff = $vStaffString;
  4580. $loanReceipt->nowStaff = $nowStaff;
  4581. $loanReceipt->verifyStaff = $vStaffString;
  4582. }
  4583. // 角色审批
  4584. if (isset ( $VS ['ROLE'] )) {
  4585. // 找出角色人 当前审批角色组
  4586. $verifyJSStaff = array ();
  4587. $nowStaffList2 = array ();
  4588. foreach ( $verifyDetail as $key => $value ) {
  4589. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  4590. $verifyJSStaff = json_decode ( $value [3] );
  4591. foreach ( $verifyJSStaff as $m ) {
  4592. $staffK = explode ( "_", $m );
  4593. array_push ( $nowStaffList2, $staffK [0] );
  4594. }
  4595. // print_r($nowStaffList2);
  4596. }
  4597. }
  4598. $RoleVerifyStaff = array ();
  4599. foreach ( $verifyStaff as $key => $value ) {
  4600. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  4601. foreach ( $nowStaffList2 as $m ) {
  4602. if ($key == $m . "_R")
  4603. $RoleVerifyStaff [$key] = $value;
  4604. }
  4605. }
  4606. }
  4607. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  4608. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  4609. // 下一个审批人ID
  4610. $nextStaff = 0;
  4611. $falg = false;
  4612. foreach ( $verifyDetail as $key => $value ) {
  4613. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  4614. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  4615. $falg = true;
  4616. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  4617. $nowStaffList = array ();
  4618. foreach ( $vStaffString as $v ) {
  4619. $staffK = explode ( "_", $v );
  4620. array_push ( $nowStaffList, $staffK [0] );
  4621. }
  4622. $nowStaff = implode ( ',', $nowStaffList );
  4623. $nextStaff = $verifyDetail [$key + 1] [0];
  4624. } elseif (isset ( $verifyDetail [$key + 1] )) {
  4625. $nextStaff = $verifyDetail [$key + 1] [0];
  4626. $nowStaff = $nextStaff;
  4627. } else
  4628. $nowStaff = '';
  4629. break;
  4630. }
  4631. }
  4632. if ($falg)
  4633. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4634. 'date' => date ( 'Y-m-d' ),
  4635. 'opinion' => $opinion,
  4636. 'status' => $status,
  4637. 'nextStaff' => $nextStaff,
  4638. 'ROLE' => 1
  4639. );
  4640. else
  4641. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4642. 'date' => date ( 'Y-m-d' ),
  4643. 'opinion' => $opinion,
  4644. 'status' => $status,
  4645. 'nextStaff' => $nextStaff
  4646. );
  4647. // print_r($verifyStaff);
  4648. // echo $nowStaff;die;
  4649. } else { // 进入下一个角色或者审批人
  4650. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  4651. //
  4652. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  4653. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  4654. 'date' => date ( 'Y-m-d' ),
  4655. 'opinion' => $opinion,
  4656. 'status' => $status,
  4657. 'nextStaff' => $VS ['nextStaff'],
  4658. 'ROLE' => 1
  4659. );
  4660. // print_r($verifyStaff);
  4661. // die;
  4662. }
  4663. if ($status == 3) {
  4664. $verifyStaff ['final'] = $status;
  4665. $verifyStaff [$this->staff [0] ['sid']] = array (
  4666. 'date' => date ( 'Y-m-d' ),
  4667. 'opinion' => $opinion,
  4668. 'status' => $status
  4669. );
  4670. }
  4671. $vStaffString = json_encode ( $verifyStaff );
  4672. $receipt->verifyStaff = $vStaffString;
  4673. $receipt->nowStaff = $nowStaff;
  4674. $loanReceipt->nowStaff = $nowStaff;
  4675. $loanReceipt->verifyStaff = $vStaffString;
  4676. // die;
  4677. // }
  4678. // print_r($verifyStaff);
  4679. // die;
  4680. }
  4681. // print_r($verifyStaff);die;
  4682. }
  4683. // print_r($verifyDetail);
  4684. $roleKey = 0;
  4685. $roleId = 0;
  4686. $verifyDetailCopy = array ();
  4687. foreach ( $verifyDetail as $k => $v ) {
  4688. if ($v [1] == 'ROLE') {
  4689. $roleId = $v [0];
  4690. $roleVerify = json_decode ( $v [3], true );
  4691. $roleKey = $k;
  4692. $roleArray = array ();
  4693. foreach ( $roleVerify as $o => $p ) {
  4694. $staffID = explode ( '_', $p );
  4695. $exp = array (
  4696. 0 => $staffID [0],
  4697. 1 => $staffID [1]
  4698. );
  4699. array_push ( $roleArray, $exp );
  4700. }
  4701. $verifyDetailCopy [$v [0]] = $roleArray;
  4702. }
  4703. }
  4704. // print_r($verifyDetail);
  4705. foreach ( $verifyDetailCopy as $k => $v ) {
  4706. foreach ( $verifyDetail as $m => $n ) {
  4707. if ($n [0] == $k) {
  4708. array_splice ( $verifyDetail, $m, 1, $v );
  4709. }
  4710. }
  4711. }
  4712. // 审批日志
  4713. if (! isset ( $verifyStaff ['final'] )) {
  4714. Doo::loadModel ( "receiptLog" );
  4715. $receiptLog = new receiptLog ();
  4716. if (! empty ( $roleId )) {
  4717. Doo::loadModel ( "role" );
  4718. $role = new role ();
  4719. $roleInfo = $role->getOne ( array (
  4720. 'where' => 'rid=' . $roleId,
  4721. 'asArray' => true
  4722. ) );
  4723. $receiptLog->rolename = $roleInfo ['name'];
  4724. }
  4725. $receiptLog->username = $this->staff [0] ['username'];
  4726. $receiptLog->uid = $this->staff [0] ['sid'];
  4727. $receiptLog->date = date ( "Y-m-d" );
  4728. $receiptLog->opinion = $opinion;
  4729. $receiptLog->img = $this->staff [0] ['avatar'];
  4730. $receiptLog->status = 1;
  4731. $receiptLog->rid = $rid;
  4732. $receiptLog->insert ();
  4733. }
  4734. if (isset ( $verifyStaff ['final'] )) { // rDetail
  4735. $receipt->status = 3;
  4736. $receipt->verifyBreakup = $verifyString;
  4737. $receiptDetailObj->status = 3;
  4738. $receiptDetailObj->update ( array (
  4739. 'where' => 'rid=' . $rid
  4740. ) );
  4741. // 微信企业号通知
  4742. $this->setWXMsg ( $rid, 3 );
  4743. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  4744. $receipt->status = 6;
  4745. $receipt->pastDate = date ( "Y-m-d" );
  4746. $receipt->isBK = 1;
  4747. $loanReceipt->verifyBreakup = $verifyString;
  4748. $loanReceipt->status = 1;
  4749. $loanReceipt->pastDate = date ( "Y-m-d" );
  4750. $loanReceipt->amount = $receiptDetail ['amount'];
  4751. $loanReceipt->update ( array (
  4752. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  4753. ) );
  4754. // 微信企业号通知
  4755. $this->setWXMsg ( $rid, 1 );
  4756. }
  4757. $receipt->amount = $amount;
  4758. $receipt->update ( array (
  4759. 'where' => ' rid = ' . $rid
  4760. ) );
  4761. // 进入下一条审批费用新加需求
  4762. $vidList = array ();
  4763. $verifyDetail = $verify->find ( array (
  4764. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  4765. 'asArray' => true
  4766. ) );
  4767. foreach ( $verifyDetail as $key => $value ) {
  4768. array_push ( $vidList, $value ['vid'] );
  4769. }
  4770. $vid = implode ( ",", $vidList );
  4771. if (empty ( $verifyDetail ))
  4772. $vid = 0;
  4773. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  4774. $receipt = new receipt ();
  4775. $rd = $receipt->getOne ( array (
  4776. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  4777. 'asc' => 'rid',
  4778. 'asArray' => true
  4779. ) );
  4780. if (empty ( $rd )) {
  4781. return '/approvalExpenses/pendApproval';
  4782. }
  4783. if ($rd ['Rtype'] == 1) {
  4784. if ($rd ['isBK'] == 1) {
  4785. return '/receiptburEdi/' . $rd ['rid'];
  4786. } else {
  4787. return '/expensesEdi/' . $rd ['rid'];
  4788. }
  4789. } elseif ($rd ['Rtype'] == 2) {
  4790. return '/remitApproval/' . $rd ['rid'];
  4791. } else {
  4792. return '/receiptburEdi/' . $rd ['rid'];
  4793. }
  4794. // return "/approvalExpenses/pendApproval";
  4795. }
  4796. }
  4797. function ajaxExamineExe() {
  4798. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4799. Doo::loadModel ( 'receipt' );
  4800. $receipt = new receipt ();
  4801. Doo::loadClass ( 'XDeode' );
  4802. $XDeode = new XDeode ( 5 );
  4803. if (! empty ( $rid )) {
  4804. $rLRes = $receipt->find ( array (
  4805. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  4806. 'asArray' => true
  4807. ) );
  4808. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  4809. echo json_encode ( array (
  4810. 'status' => 1,
  4811. 'receipt' => $rLRes [0]
  4812. ) );
  4813. die ();
  4814. }
  4815. echo json_encode ( array (
  4816. 'status' => 0,
  4817. 'receipt' => array ()
  4818. ) );
  4819. die ();
  4820. }
  4821. function implement() {
  4822. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4823. Doo::loadClass ( 'XDeode' );
  4824. $XDeode = new XDeode ( 5 );
  4825. Doo::loadModel ( 'receipt' );
  4826. $receipt = new receipt ();
  4827. Doo::loadModel ( 'L_category' );
  4828. $Lcategory = new L_category ();
  4829. Doo::loadModel ( 'verify' );
  4830. $verify = new verify ();
  4831. Doo::loadModel ( 'staff' );
  4832. $staff = new staff ();
  4833. Doo::loadModel ( "execute" );
  4834. $execute = new execute ();
  4835. $rid = $XDeode->decode ( $rid );
  4836. $receiptList = $receipt->find ( array (
  4837. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  4838. 'desc' => 'rid',
  4839. 'asArray' => true
  4840. ) );
  4841. Doo::loadModel ( 'loanReceipt' );
  4842. $loanReceipt = new loanReceipt ();
  4843. // print_r($receiptList);
  4844. $loanList = array ();
  4845. if (! isset ( $receiptList ))
  4846. $loanList = $loanReceipt->find ( array (
  4847. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4848. 'desc' => 'rid',
  4849. 'asArray' => true
  4850. ) );
  4851. $Locate = 0;
  4852. $roleId = 0;
  4853. $button = 0;
  4854. foreach ( $loanList as $key => $value ) {
  4855. $loanList [$key] ['Locate'] = $Locate;
  4856. $Locate ++;
  4857. $loanList [$key] ['reviseDetail'] = array ();
  4858. if (! empty ( $value ['reviseDetail'] ))
  4859. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4860. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4861. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4862. $categoryDetil = $Lcategory->getOne ( array (
  4863. 'where' => 'cid=' . $value ['cid'],
  4864. 'asArray' => true
  4865. ) );
  4866. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4867. // 检测编辑状态
  4868. $verifyList = $verify->getOne ( array (
  4869. 'where' => 'vid=' . $value ['verify'],
  4870. 'asArray' => true
  4871. ) );
  4872. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4873. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4874. Doo::loadModel ( 'role' );
  4875. $role = new role ();
  4876. $flag = true;
  4877. $roleKey = 0;
  4878. $endStaffArray = array ();
  4879. $roleArrayCopy = array ();
  4880. foreach ( $verifyList as $k => $v ) {
  4881. // init verifyStaff
  4882. if ($v [1] == 'ROLE') {
  4883. if (! empty ( $verifyStaff )) {
  4884. $endStaffArray = end ( $verifyStaff );
  4885. // if ($v[0]==$endStaffArray['nextStaff']){
  4886. // $roleId=$v[0];
  4887. // }
  4888. }
  4889. $roleVerify = json_decode ( $v [3], true );
  4890. $roleKey = $k;
  4891. $roleArray = array ();
  4892. $rolename = $role->getOne ( array (
  4893. 'where' => 'rid=' . $v [0],
  4894. 'asArray' => true
  4895. ) );
  4896. foreach ( $roleVerify as $o => $p ) {
  4897. $staffID = explode ( '_', $p );
  4898. $staffInfo = $staff->getOne ( array (
  4899. 'where' => 'sid=' . $staffID [0],
  4900. 'asArray' => true
  4901. ) );
  4902. // print_r($staffID);
  4903. $exp = array (
  4904. 0 => $staffInfo ['sid'],
  4905. 1 => $staffID [1],
  4906. 2 => $staffInfo ['avatar'],
  4907. 'date' => '',
  4908. 'date' => '',
  4909. 'opinion' => '',
  4910. 'status' => '',
  4911. 'rolename' => $rolename ['name']
  4912. );
  4913. array_push ( $roleArray, $exp );
  4914. }
  4915. $roleArrayCopy [$v [0]] = $roleArray;
  4916. // $verifyList[$k]['roleArray']=$roleArray;
  4917. }
  4918. $verifyList [$k] ['date'] = "";
  4919. $verifyList [$k] ['opinion'] = "";
  4920. $verifyList [$k] ['status'] = "";
  4921. if (empty ( $verifyStaff )) {
  4922. $verifyList [$k] ['date'] = "";
  4923. $verifyList [$k] ['opinion'] = "";
  4924. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4925. $verifyList [$k] ['status'] = 4;
  4926. $flag = false;
  4927. }
  4928. } else {
  4929. foreach ( $verifyStaff as $m => $u ) {
  4930. if ($v [0] == $m) {
  4931. $verifyList [$k] ['date'] = $u ['date'];
  4932. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4933. $verifyList [$k] ['status'] = $u ['status'];
  4934. $flag = false;
  4935. break;
  4936. }
  4937. }
  4938. $endStaffArray = end ( $verifyStaff );
  4939. if (isset ( $endStaffArray ['ROLE'] )) {
  4940. } else {
  4941. // $endKey=key($verifyStaff);
  4942. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4943. // $button=4;
  4944. // $verifyList[$k]['status']=4;
  4945. // }
  4946. }
  4947. }
  4948. }
  4949. $rolename ['name'] = '';
  4950. if (! empty ( $roleId )) {
  4951. Doo::loadModel ( 'role' );
  4952. $role = new role ();
  4953. $rolename = $role->getOne ( array (
  4954. 'where' => 'rid=' . $roleId,
  4955. 'asArray' => true
  4956. ) );
  4957. }
  4958. if (! empty ( $verifyStaff ))
  4959. $endStaffArray = end ( $verifyStaff );
  4960. $KOP = false;
  4961. foreach ( $roleArrayCopy as $P => $A ) {
  4962. foreach ( $A as $MKI => $AVL ) {
  4963. if (! empty ( $verifyStaff )) {
  4964. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4965. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4966. $button = 4;
  4967. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4968. }
  4969. foreach ( $verifyStaff as $m => $u ) {
  4970. $AVLFK = $AVL [0] . '_R';
  4971. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4972. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4973. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4974. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4975. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4976. break;
  4977. }
  4978. }
  4979. } else {
  4980. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4981. $button = 4;
  4982. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4983. }
  4984. }
  4985. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4986. $KOP = true;
  4987. }
  4988. }
  4989. foreach ( $roleArrayCopy as $k => $v ) {
  4990. foreach ( $verifyList as $m => $n ) {
  4991. if ($n [0] == $k) {
  4992. array_splice ( $verifyList, $m, 1, $v );
  4993. }
  4994. }
  4995. }
  4996. $loanList [$key] ['verifyList'] = $verifyList;
  4997. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  4998. 'where' => 'sid=' . $value ['staff'],
  4999. 'asArray' => true
  5000. ) );
  5001. }
  5002. $data ['loanList'] = $loanList;
  5003. $Locate = 0;
  5004. $roleId = 0;
  5005. $button = 0;
  5006. Doo::loadClass ( 'XDeode' );
  5007. $XDeode = new XDeode ( 5 );
  5008. foreach ( $receiptList as $key => $value ) {
  5009. $receiptList[$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  5010. $button2 = 0;
  5011. $receiptList [$key] ['Locate'] = $Locate;
  5012. $Locate ++;
  5013. $receiptList [$key] ['reviseDetail'] = array ();
  5014. if (! empty ( $value ['reviseDetail'] ))
  5015. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5016. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5017. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5018. $categoryDetil = $Lcategory->getOne ( array (
  5019. 'where' => 'cid=' . $value ['cid'],
  5020. 'asArray' => true
  5021. ) );
  5022. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5023. $executeList = json_decode ( $value ['executeCopy'], true );
  5024. $executeStaff = array ();
  5025. if (! empty ( $value ['executeStaff'] ))
  5026. $executeStaff = json_decode ( $value ['executeStaff'], true );
  5027. if (isset ( $executeList )) {
  5028. foreach ( $executeList as $op => $lo ) {
  5029. $executeList [$op] ['date'] = "";
  5030. $executeList [$op] ['opinion'] = "";
  5031. $executeList [$op] ['status'] = "";
  5032. foreach ( $executeStaff as $m => $u ) {
  5033. if ($lo [0] == $m) {
  5034. $executeList [$op] ['date'] = $u ['date'];
  5035. $executeList [$op] ['opinion'] = $u ['opinion'];
  5036. $executeList [$op] ['status'] = $u ['status'];
  5037. break;
  5038. }
  5039. }
  5040. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  5041. $button2 = 1;
  5042. $executeList [$op] ['status'] = 4;
  5043. }
  5044. }
  5045. }
  5046. // 检测编辑状态
  5047. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  5048. $verifyList ['staff'] = $value ['verifyBreakup'];
  5049. } else
  5050. $verifyList = $verify->getOne ( array (
  5051. 'where' => 'vid=' . $value ['verify'],
  5052. 'asArray' => true
  5053. ) );
  5054. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5055. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5056. Doo::loadModel ( 'role' );
  5057. $role = new role ();
  5058. if ($verifyList == NULL)
  5059. $verifyList = array ();
  5060. $flag = true;
  5061. $roleKey = 0;
  5062. $endStaffArray = array ();
  5063. $roleArrayCopy = array ();
  5064. foreach ( $verifyList as $k => $v ) {
  5065. // init verifyStaff
  5066. if ($v [1] == 'ROLE') {
  5067. if (! empty ( $verifyStaff )) {
  5068. $endStaffArray = end ( $verifyStaff );
  5069. // if ($v[0]==$endStaffArray['nextStaff']){
  5070. // $roleId=$v[0];
  5071. // }
  5072. }
  5073. $roleVerify = json_decode ( $v [3], true );
  5074. $roleKey = $k;
  5075. $roleArray = array ();
  5076. $rolename = $role->getOne ( array (
  5077. 'where' => 'rid=' . $v [0],
  5078. 'asArray' => true
  5079. ) );
  5080. foreach ( $roleVerify as $o => $p ) {
  5081. $staffID = explode ( '_', $p );
  5082. $staffInfo = $staff->getOne ( array (
  5083. 'where' => 'sid=' . $staffID [0],
  5084. 'asArray' => true
  5085. ) );
  5086. // print_r($staffID);
  5087. $exp = array (
  5088. 0 => $staffInfo ['sid'],
  5089. 1 => $staffID [1],
  5090. 2 => $staffInfo ['avatar'],
  5091. 'date' => '',
  5092. 'date' => '',
  5093. 'opinion' => '',
  5094. 'status' => '',
  5095. 'rolename' => $rolename ['name']
  5096. );
  5097. array_push ( $roleArray, $exp );
  5098. }
  5099. $roleArrayCopy [$v [0]] = $roleArray;
  5100. // $verifyList[$k]['roleArray']=$roleArray;
  5101. }
  5102. $verifyList [$k] ['date'] = "";
  5103. $verifyList [$k] ['opinion'] = "";
  5104. $verifyList [$k] ['status'] = "";
  5105. if (empty ( $verifyStaff )) {
  5106. $verifyList [$k] ['date'] = "";
  5107. $verifyList [$k] ['opinion'] = "";
  5108. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5109. $verifyList [$k] ['status'] = 4;
  5110. $flag = false;
  5111. }
  5112. } else {
  5113. foreach ( $verifyStaff as $m => $u ) {
  5114. if ($v [0] == $m) {
  5115. $verifyList [$k] ['date'] = $u ['date'];
  5116. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5117. $verifyList [$k] ['status'] = $u ['status'];
  5118. $flag = false;
  5119. break;
  5120. }
  5121. }
  5122. $endStaffArray = end ( $verifyStaff );
  5123. if (isset ( $endStaffArray ['ROLE'] )) {
  5124. } else {
  5125. // $endKey=key($verifyStaff);
  5126. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5127. // $button=4;
  5128. // $verifyList[$k]['status']=4;
  5129. // }
  5130. }
  5131. }
  5132. }
  5133. $rolename ['name'] = '';
  5134. if (! empty ( $roleId )) {
  5135. Doo::loadModel ( 'role' );
  5136. $role = new role ();
  5137. $rolename = $role->getOne ( array (
  5138. 'where' => 'rid=' . $roleId,
  5139. 'asArray' => true
  5140. ) );
  5141. }
  5142. if (! empty ( $verifyStaff ))
  5143. $endStaffArray = end ( $verifyStaff );
  5144. $KOP = false;
  5145. foreach ( $roleArrayCopy as $P => $A ) {
  5146. foreach ( $A as $MKI => $AVL ) {
  5147. if (! empty ( $verifyStaff )) {
  5148. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5149. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5150. $button = 4;
  5151. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5152. }
  5153. foreach ( $verifyStaff as $m => $u ) {
  5154. $AVLFK = $AVL [0] . '_R';
  5155. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5156. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5157. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5158. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5159. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5160. break;
  5161. }
  5162. }
  5163. } else {
  5164. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5165. $button = 4;
  5166. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5167. }
  5168. }
  5169. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5170. $KOP = true;
  5171. }
  5172. }
  5173. foreach ( $roleArrayCopy as $k => $v ) {
  5174. foreach ( $verifyList as $m => $n ) {
  5175. if ($n [0] == $k) {
  5176. array_splice ( $verifyList, $m, 1, $v );
  5177. }
  5178. }
  5179. }
  5180. $receiptList [$key] ['verifyList'] = $verifyList;
  5181. $receiptList [$key] ['executeList'] = $executeList;
  5182. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5183. 'where' => 'sid=' . $value ['staff'],
  5184. 'asArray' => true
  5185. ) );
  5186. $receiptList [$key] ['button2'] = $button2;
  5187. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5188. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5189. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5190. $receiptList [$key] ['relust'] = $relust;
  5191. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  5192. }
  5193. // 是否写入过流水
  5194. $accountType = 0;
  5195. if ($receiptList [0] ['Rtype'] == 0) {
  5196. $accountType = 3;
  5197. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5198. if ($receiptList [0] ['Rtype'] == 0) {
  5199. $accountType = 1;
  5200. } elseif ($receiptList [0] ['Rtype'] == 1) {
  5201. $accountType = 2;
  5202. }
  5203. } elseif ($receiptList [0] ['Rtype'] == 2) {
  5204. $accountType = 4;
  5205. } elseif ($receiptList [0] ['Rtype'] == 3) {
  5206. $accountType = 12;
  5207. }
  5208. Doo::loadModel ( 'wasteBook' );
  5209. $wasteBook = new wasteBook ();
  5210. $wbDetail = $wasteBook->getWateBookByAD ( $accountType, $receiptList [0] ['rid'] );
  5211. $data ['wbDetail'] = $wbDetail;
  5212. //print_r($receiptList);
  5213. $data ['receiptList'] = $receiptList;
  5214. $data ['memu'] = "receipt";
  5215. $data ['staff'] = $this->staff;
  5216. $data ['receiptMemu'] = 'implement';
  5217. $data ['verifyId'] = $this->verifyId;
  5218. $data ['executeId'] = $this->executeId;
  5219. $this->render ( "/admin/implement", $data );
  5220. }
  5221. function implementDo() {
  5222. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5223. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  5224. // $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  5225. // $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  5226. // $ab = '';
  5227. // if ($accountBank == 'CGBDeposit')
  5228. // $ab = '纵横广发';
  5229. // elseif ($accountBank == 'ICBCDeposit')
  5230. // $ab = '纵横工行';
  5231. // elseif ($accountBank == 'HUADeposit')
  5232. // $ab = '华润银行';
  5233. // elseif ($accountBank == 'PersonalDeposit')
  5234. // $ab = '个人广发';
  5235. // if (empty ( $ab ))
  5236. // die ( 'illegal request--22' );
  5237. if (! empty ( $rid )) {
  5238. Doo::loadModel ( 'receipt' );
  5239. $receipt = new receipt ();
  5240. // Doo::loadClass ( 'XDeode' );
  5241. // $XDeode = new XDeode ( 5 );
  5242. // $rinfo = $receipt->getOne ( array (
  5243. // 'where' => 'rid=' . $rid,
  5244. // 'asArray' => true
  5245. // ) );
  5246. $rinfo = $receipt->getReceiptByRid ( $rid );
  5247. $accountType = '';
  5248. if ($rinfo ['Rtype'] == 1) {
  5249. if ($rinfo ['loanRid'] != 0)
  5250. $accountType = 2;
  5251. else
  5252. $accountType = 1;
  5253. } elseif ($rinfo ['Rtype'] == 2) {
  5254. $accountType = 4;
  5255. } elseif ($rinfo ['Rtype'] == 0)
  5256. $accountType = 3;
  5257. if (empty ( $accountType ))
  5258. die ( 'illegal request' );
  5259. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  5260. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  5261. if (empty ( $executeStaff )) {
  5262. $executeStaff = array (
  5263. $this->staff [0] ['sid'] => array (
  5264. 'date' => date ( 'Y-m-d' ),
  5265. 'opinion' => $implementOpinions,
  5266. 'status' => 1
  5267. )
  5268. );
  5269. } else {
  5270. $executeStaff [$this->staff [0] ['sid']] = array (
  5271. 'date' => date ( 'Y-m-d' ),
  5272. 'opinion' => $implementOpinions,
  5273. 'status' => 1
  5274. );
  5275. }
  5276. if (count ( $executeStaff ) == count ( $executeCopy )) {
  5277. $receipt->executeStaff = json_encode ( $executeStaff );
  5278. $receipt->status = 8;
  5279. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  5280. $receipt->status = 9;
  5281. if ($rinfo ['status'] == 6) {
  5282. $receipt->loanDate = date ( "Y-m-d" );
  5283. }
  5284. $receipt->executeDate = date ( "Y-m-d" );
  5285. } else {
  5286. $receipt->executeStaff = json_encode ( $executeStaff );
  5287. }
  5288. $receipt->amount = $amount;
  5289. $receipt->update ( array (
  5290. 'where' => 'rid=' . $rid
  5291. ) );
  5292. // 公司流水记录
  5293. // Doo::loadModel ( 'wasteBook' );
  5294. // $wasteBook = new wasteBook ();
  5295. // $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  5296. // // 银行
  5297. // if (empty ( $abDetail ) && ! empty ( $amount )) {
  5298. // $item = array (
  5299. // 'dataID' => $rid,
  5300. // 'expensesType' => 2,
  5301. // 'accountType' => $accountType,
  5302. // 'accountPriceShow' => $amount,
  5303. // 'accountPrice' => - $amount,
  5304. // 'accountBank' => $accountBank,
  5305. // 'category' => $rinfo ['category'] [0] ['title'],
  5306. // 'cid' => $rinfo ['category'] [0] ['cid'],
  5307. // 'name' => $rinfo ['staffDetail'] ['username'],
  5308. // 'sid' => $rinfo ['staffDetail'] ['sid'],
  5309. // 'inputDate' => date ( "Y-m-d H:i:s" )
  5310. // );
  5311. // $wasteBook->setAccountBookStatistics ( $item );
  5312. // }
  5313. }
  5314. //$ridKey = $XDeode->encode ( $rid );
  5315. return "/hisImplement";
  5316. // return "/implement/" . $ridKey . ".html";
  5317. }
  5318. function receiptburEdi() {
  5319. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5320. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5321. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5322. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5323. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5324. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5325. if (empty ( $status ))
  5326. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5327. $vidList = array ();
  5328. $button = 0;
  5329. Doo::loadModel ( 'verify' );
  5330. Doo::loadModel ( 'receipt' );
  5331. Doo::loadModel ( 'staff' );
  5332. $staff = new staff ();
  5333. $receipt = new receipt ();
  5334. $verify = new verify ();
  5335. Doo::loadModel ( 'L_category' );
  5336. $Lcategory = new L_category ();
  5337. Doo::loadModel ( 'enclosur' );
  5338. $enclosur = new enclosur ();
  5339. Doo::loadModel ( 'loanReceipt' );
  5340. $loanReceipt = new loanReceipt ();
  5341. // user verify ID
  5342. $verifyDetail = $verify->find ( array (
  5343. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5344. 'asArray' => true
  5345. ) );
  5346. foreach ( $verifyDetail as $key => $value ) {
  5347. array_push ( $vidList, $value ['vid'] );
  5348. }
  5349. $vid = implode ( ",", $vidList );
  5350. if (empty ( $verifyDetail ))
  5351. $vid = 0;
  5352. $categoryList = $Lcategory->find ( array (
  5353. 'asArray' => true
  5354. ) );
  5355. $staffList = $staff->find ( array (
  5356. 'where' => 'cid=' . $cid,
  5357. 'asArray' => true
  5358. ) );
  5359. $ap = "";
  5360. if ($status == 4) {
  5361. $ap = 4;
  5362. $status = 2;
  5363. }
  5364. // get Receipt By verifyID status 2
  5365. $receiptList = $receipt->find ( array (
  5366. 'where' => 'rid =' . $rid . ' and status=2',
  5367. 'desc' => 'rid',
  5368. 'asArray' => true
  5369. ) );
  5370. if (empty ( $receiptList )) {
  5371. die ( 'illegal request' );
  5372. }
  5373. $loanList = $loanReceipt->find ( array (
  5374. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  5375. 'desc' => 'rid',
  5376. 'asArray' => true
  5377. ) );
  5378. $data ['explanation'] = '';
  5379. if (! empty ( $loanList ))
  5380. $data ['explanation'] = $loanList [0] ['explanation'];
  5381. $Locate = 0;
  5382. $roleId = 0;
  5383. $button = 0;
  5384. foreach ( $loanList as $key => $value ) {
  5385. $loanList [$key] ['Locate'] = $Locate;
  5386. $Locate ++;
  5387. $loanList [$key] ['reviseDetail'] = array ();
  5388. if (! empty ( $value ['reviseDetail'] ))
  5389. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5390. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5391. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5392. $categoryDetil = $Lcategory->getOne ( array (
  5393. 'where' => 'cid=' . $value ['cid'],
  5394. 'asArray' => true
  5395. ) );
  5396. $loanList [$key] ['category'] = $categoryDetil ['title'];
  5397. // 检测编辑状态
  5398. $verifyList = $verify->getOne ( array (
  5399. 'where' => 'vid=' . $value ['verify'],
  5400. 'asArray' => true
  5401. ) );
  5402. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5403. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5404. Doo::loadModel ( 'role' );
  5405. $role = new role ();
  5406. $flag = true;
  5407. $roleKey = 0;
  5408. $endStaffArray = array ();
  5409. $roleArrayCopy = array ();
  5410. foreach ( $verifyList as $k => $v ) {
  5411. // init verifyStaff
  5412. if ($v [1] == 'ROLE') {
  5413. if (! empty ( $verifyStaff )) {
  5414. $endStaffArray = end ( $verifyStaff );
  5415. }
  5416. $roleVerify = json_decode ( $v [3], true );
  5417. $roleKey = $k;
  5418. $roleArray = array ();
  5419. $rolename = $role->getOne ( array (
  5420. 'where' => 'rid=' . $v [0],
  5421. 'asArray' => true
  5422. ) );
  5423. foreach ( $roleVerify as $o => $p ) {
  5424. $staffID = explode ( '_', $p );
  5425. $staffInfo = $staff->getOne ( array (
  5426. 'where' => 'sid=' . $staffID [0],
  5427. 'asArray' => true
  5428. ) );
  5429. // print_r($staffID);
  5430. $exp = array (
  5431. 0 => $staffInfo ['sid'],
  5432. 1 => $staffID [1],
  5433. 2 => $staffInfo ['avatar'],
  5434. 'date' => '',
  5435. 'date' => '',
  5436. 'opinion' => '',
  5437. 'status' => '',
  5438. 'rolename' => $rolename ['name']
  5439. );
  5440. array_push ( $roleArray, $exp );
  5441. }
  5442. $roleArrayCopy [$v [0]] = $roleArray;
  5443. // $verifyList[$k]['roleArray']=$roleArray;
  5444. }
  5445. $verifyList [$k] ['date'] = "";
  5446. $verifyList [$k] ['opinion'] = "";
  5447. $verifyList [$k] ['status'] = "";
  5448. if (empty ( $verifyStaff )) {
  5449. $verifyList [$k] ['date'] = "";
  5450. $verifyList [$k] ['opinion'] = "";
  5451. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5452. $verifyList [$k] ['status'] = 4;
  5453. $flag = false;
  5454. }
  5455. } else {
  5456. foreach ( $verifyStaff as $m => $u ) {
  5457. if ($v [0] == $m) {
  5458. $verifyList [$k] ['date'] = $u ['date'];
  5459. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5460. $verifyList [$k] ['status'] = $u ['status'];
  5461. $flag = false;
  5462. break;
  5463. }
  5464. }
  5465. $endStaffArray = end ( $verifyStaff );
  5466. if (isset ( $endStaffArray ['ROLE'] )) {
  5467. } else {
  5468. }
  5469. }
  5470. }
  5471. $rolename ['name'] = '';
  5472. if (! empty ( $roleId )) {
  5473. Doo::loadModel ( 'role' );
  5474. $role = new role ();
  5475. $rolename = $role->getOne ( array (
  5476. 'where' => 'rid=' . $roleId,
  5477. 'asArray' => true
  5478. ) );
  5479. }
  5480. if (! empty ( $verifyStaff ))
  5481. $endStaffArray = end ( $verifyStaff );
  5482. $KOP = false;
  5483. foreach ( $roleArrayCopy as $P => $A ) {
  5484. foreach ( $A as $MKI => $AVL ) {
  5485. if (! empty ( $verifyStaff )) {
  5486. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5487. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5488. $button = 4;
  5489. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5490. }
  5491. foreach ( $verifyStaff as $m => $u ) {
  5492. $AVLFK = $AVL [0] . '_R';
  5493. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5494. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5495. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5496. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5497. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5498. break;
  5499. }
  5500. }
  5501. } else {
  5502. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5503. $button = 4;
  5504. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5505. }
  5506. }
  5507. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5508. $KOP = true;
  5509. }
  5510. }
  5511. foreach ( $roleArrayCopy as $k => $v ) {
  5512. foreach ( $verifyList as $m => $n ) {
  5513. if ($n [0] == $k) {
  5514. array_splice ( $verifyList, $m, 1, $v );
  5515. }
  5516. }
  5517. }
  5518. $loanList [$key] ['verifyList'] = $verifyList;
  5519. }
  5520. $htmlLoan = '';
  5521. $data ['loanReceiptDate'] = '';
  5522. if (isset ( $loanList [0] )) {
  5523. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  5524. if ($value ['status'] == 1)
  5525. $htmlLoan .= '<li class="done" >';
  5526. elseif ($value ['status'] == 3)
  5527. $htmlLoan .= '<li class="undone" >';
  5528. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  5529. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  5530. if (isset ( $value ['rolename'] ))
  5531. $htmlLoan .= $value ['rolename'];
  5532. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  5533. }
  5534. $data ['loanDate'] = $loanList [0] ['date'];
  5535. } else {
  5536. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  5537. }
  5538. $data ['htmlLoan'] = $htmlLoan;
  5539. // $data ['LoanReceipt']=$loanList[0];
  5540. // print_r($loanList);
  5541. $Locate = 0;
  5542. $roleId = 0;
  5543. $button = 0;
  5544. if ($ap == 4)
  5545. $status = 4;
  5546. Doo::loadClass ( 'XDeode' );
  5547. $XDeode = new XDeode ( 5 );
  5548. foreach ( $receiptList as $key => $value ) {
  5549. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5550. $receiptList [$key] ['Locate'] = $Locate;
  5551. $Locate ++;
  5552. $receiptList [$key] ['reviseDetail'] = array ();
  5553. // 调整金额 代码调整
  5554. if (! empty ( $value ['reviseDetail'] )) {
  5555. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  5556. foreach ( $reviseDetail as $ry => $re ) {
  5557. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  5558. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  5559. }
  5560. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  5561. // print_r($reviseDetail);
  5562. }
  5563. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5564. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  5565. $categoryDetil = $Lcategory->getOne ( array (
  5566. 'where' => 'cid=' . $value ['cid'],
  5567. 'asArray' => true
  5568. ) );
  5569. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5570. // 检测编辑状态
  5571. $verifyList = $verify->getOne ( array (
  5572. 'where' => 'vid=' . $value ['verify'],
  5573. 'asArray' => true
  5574. ) );
  5575. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5576. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5577. Doo::loadModel ( 'role' );
  5578. $role = new role ();
  5579. // print_r($verifyList);
  5580. $flag = true;
  5581. $roleKey = 0;
  5582. $endStaffArray = array ();
  5583. $roleArrayCopy = array ();
  5584. foreach ( $verifyList as $k => $v ) {
  5585. // init verifyStaff
  5586. if ($v [1] == 'ROLE') {
  5587. if (! empty ( $verifyStaff )) {
  5588. $endStaffArray = end ( $verifyStaff );
  5589. if ($v [0] == $endStaffArray ['nextStaff']) {
  5590. $roleId = $v [0];
  5591. }
  5592. }
  5593. $roleVerify = json_decode ( $v [3], true );
  5594. $roleKey = $k;
  5595. $roleArray = array ();
  5596. $rolename = $role->getOne ( array (
  5597. 'where' => 'rid=' . $v [0],
  5598. 'asArray' => true
  5599. ) );
  5600. foreach ( $roleVerify as $o => $p ) {
  5601. $staffID = explode ( '_', $p );
  5602. $staffInfo = $staff->getOne ( array (
  5603. 'where' => 'sid=' . $staffID [0],
  5604. 'asArray' => true
  5605. ) );
  5606. // print_r($staffID);
  5607. $exp = array (
  5608. 0 => $staffInfo ['sid'],
  5609. 1 => $staffID [1],
  5610. 2 => $staffInfo ['avatar'],
  5611. 'date' => '',
  5612. 'date' => '',
  5613. 'opinion' => '',
  5614. 'status' => '',
  5615. 'rolename' => $rolename ['name']
  5616. );
  5617. array_push ( $roleArray, $exp );
  5618. }
  5619. $roleArrayCopy [$v [0]] = $roleArray;
  5620. // $verifyList[$k]['roleArray']=$roleArray;
  5621. }
  5622. // print_r($roleArray);
  5623. $verifyList [$k] ['date'] = "";
  5624. $verifyList [$k] ['opinion'] = "";
  5625. $verifyList [$k] ['status'] = "";
  5626. if (empty ( $verifyStaff )) {
  5627. $verifyList [$k] ['date'] = "";
  5628. $verifyList [$k] ['opinion'] = "";
  5629. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5630. $verifyList [$k] ['status'] = 4;
  5631. $button = 4;
  5632. $flag = false;
  5633. }
  5634. } else {
  5635. foreach ( $verifyStaff as $m => $u ) {
  5636. if ($v [0] == $m) {
  5637. $verifyList [$k] ['date'] = $u ['date'];
  5638. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5639. $verifyList [$k] ['status'] = $u ['status'];
  5640. $flag = false;
  5641. break;
  5642. }
  5643. }
  5644. $endStaffArray = end ( $verifyStaff );
  5645. if (isset ( $endStaffArray ['ROLE'] )) {
  5646. } else {
  5647. $endKey = key ( $verifyStaff );
  5648. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5649. $button = 4;
  5650. $verifyList [$k] ['status'] = 4;
  5651. }
  5652. }
  5653. }
  5654. }
  5655. $rolename ['name'] = '';
  5656. if (! empty ( $roleId )) {
  5657. Doo::loadModel ( 'role' );
  5658. $role = new role ();
  5659. $rolename = $role->getOne ( array (
  5660. 'where' => 'rid=' . $roleId,
  5661. 'asArray' => true
  5662. ) );
  5663. }
  5664. if (! empty ( $verifyStaff ))
  5665. $endStaffArray = end ( $verifyStaff );
  5666. $KOP = false;
  5667. foreach ( $roleArrayCopy as $P => $A ) {
  5668. foreach ( $A as $MKI => $AVL ) {
  5669. if (! empty ( $verifyStaff )) {
  5670. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5671. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5672. $button = 4;
  5673. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5674. }
  5675. foreach ( $verifyStaff as $m => $u ) {
  5676. $AVLFK = $AVL [0] . '_R';
  5677. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5678. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5679. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5680. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5681. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5682. break;
  5683. }
  5684. }
  5685. } else {
  5686. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5687. $button = 4;
  5688. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5689. }
  5690. }
  5691. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5692. $KOP = true;
  5693. }
  5694. }
  5695. foreach ( $roleArrayCopy as $k => $v ) {
  5696. foreach ( $verifyList as $m => $n ) {
  5697. if ($n [0] == $k) {
  5698. array_splice ( $verifyList, $m, 1, $v );
  5699. }
  5700. }
  5701. }
  5702. // print_r($verifyList);
  5703. $receiptList [$key] ['verifyList'] = $verifyList;
  5704. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5705. 'where' => 'sid=' . $value ['staff'],
  5706. 'asArray' => true
  5707. ) );
  5708. $receiptList [$key] ['button'] = $button;
  5709. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  5710. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  5711. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  5712. $receiptList [$key] ['relust'] = $relust;
  5713. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  5714. }
  5715. // print_r($receiptList);die;
  5716. // $data['verifyDetail']=$verifyDetail;
  5717. $mothHtml = "";
  5718. for($i = 1; $i <= 12; $i ++) {
  5719. if ($month == $i)
  5720. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5721. else
  5722. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5723. }
  5724. // 获取审批日志
  5725. Doo::loadModel ( 'receiptLog' );
  5726. $receiptLog = new receiptLog ();
  5727. $rlList = array ();
  5728. $rlInfo = $receiptLog->getOne ( array (
  5729. 'where' => 'rid=' . $rid . ' and status=4',
  5730. 'asArray' => true
  5731. ) );
  5732. $tijdate = $receiptLog->getOne ( array (
  5733. 'where' => 'rid=' . $rid . ' and status=2',
  5734. 'asc' => 'rlid',
  5735. 'asArray' => true
  5736. ) );
  5737. if (! empty ( $rlInfo )) {
  5738. $rlList = $receiptLog->find ( array (
  5739. 'where' => 'rid=' . $rid,
  5740. 'asc' => 'rlid',
  5741. 'asArray' => true
  5742. ) );
  5743. }
  5744. // echo $rid;
  5745. // print_r($receiptList);
  5746. $receiptList [0] ['rlList'] = $rlList;
  5747. // print_r($receiptList);
  5748. $enclosurList = $enclosur->find ( array (
  5749. 'where' => 'rid=' . $rid,
  5750. 'asArray' => true
  5751. ) );
  5752. $enclosurHtml = '';
  5753. foreach ( $enclosurList as $value ) {
  5754. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5755. }
  5756. $data ['enclosurHtml'] = $enclosurHtml;
  5757. $data ['rolename'] = $rolename ['name'];
  5758. $data ['mothHtml'] = $mothHtml;
  5759. // print_r($receiptList);
  5760. $data ['rid'] = $rid;
  5761. $data ['tijdate'] = $tijdate ['date'];
  5762. $data ['receiptList'] = $receiptList;
  5763. $data ['receiptApprovalCount'] = count ( $receiptList );
  5764. $data ['status'] = $status;
  5765. $data ['year'] = $year;
  5766. $data ['categoryList'] = $categoryList;
  5767. $data ['staffList'] = $staffList;
  5768. $data ['cid'] = $cid;
  5769. $data ['sid'] = $sid;
  5770. $data ['ap'] = $ap;
  5771. $data ['memu'] = "receipt";
  5772. $data ['staff'] = $this->staff;
  5773. $data ['receiptMemu'] = 'approvalExpenses';
  5774. $data ['verifyId'] = $this->verifyId;
  5775. $data ['executeId'] = $this->executeId;
  5776. $this->render ( "/admin/receiptburEdi", $data );
  5777. }
  5778. function hisImplement() {
  5779. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  5780. if (empty ( $item ))
  5781. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  5782. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  5783. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5784. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  5785. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  5786. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  5787. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  5788. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  5789. $receiptOrder=$this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) :"";
  5790. Doo::loadClass ( 'XDeode' );
  5791. $XDeode = new XDeode ( 5 );
  5792. Doo::loadModel ( 'receipt' );
  5793. $receipt = new receipt ();
  5794. Doo::loadModel ( 'L_category' );
  5795. $Lcategory = new L_category ();
  5796. Doo::loadModel ( 'verify' );
  5797. Doo::loadModel ( 'statistics' );
  5798. $statistics = new statistics ();
  5799. $verify = new verify ();
  5800. Doo::loadModel ( 'staff' );
  5801. $staff = new staff ();
  5802. Doo::loadClass ( 'XDeode' );
  5803. $XDeode = new XDeode ( 5 );
  5804. $XDeode7 = new XDeode ( 7 );
  5805. $cid = $XDeode->decode ( $cidKey );
  5806. $condition = "";
  5807. if ($item == "expenses")
  5808. $condition = " and Rtype=1 ";
  5809. elseif ($item == "receipts")
  5810. $condition = " and Rtype=0 ";
  5811. elseif ($item == "remits")
  5812. $condition = " and Rtype=2 ";
  5813. elseif($item == "train")
  5814. $condition = " and Rtype=3 ";
  5815. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  5816. $sopString = $cidString = "";
  5817. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  5818. if (empty ( $rdate ))
  5819. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  5820. else
  5821. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  5822. if ($status == 'pendImplement') {
  5823. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  5824. } elseif ($status == 'alerpts') {
  5825. $statusCon = '(status=8 or status=9 )';
  5826. if (empty ( $rdate ))
  5827. $dateCondition .= " and Year(date) =" . $year;
  5828. else
  5829. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  5830. }
  5831. if ($sop != 'SOP')
  5832. $sopString = " and staff=" . $sop;
  5833. if ($cidKey != 'ALL')
  5834. $cidString = " and cid=" . $cid;
  5835. if(!empty($receiptOrder)){
  5836. $receiptList = $receipt->find ( array (
  5837. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5838. 'desc' => 'rid',
  5839. 'asArray' => true
  5840. ) );
  5841. // 员工筛选
  5842. $receiptList2 = $receipt->find ( array (
  5843. 'where' => $statusCon.' and receiptOrder like "%' . $receiptOrder . '%"',
  5844. 'desc' => 'rid',
  5845. 'asArray' => true
  5846. ) );
  5847. }else{
  5848. $receiptList = $receipt->find ( array (
  5849. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  5850. 'desc' => 'rid',
  5851. 'asArray' => true
  5852. ) );
  5853. // 员工筛选
  5854. $receiptList2 = $receipt->find ( array (
  5855. 'where' => $statusCon . $condition . $dateCondition,
  5856. 'desc' => 'rid',
  5857. 'asArray' => true
  5858. ) );
  5859. }
  5860. $sopStaff = array ();
  5861. foreach ( $receiptList2 as $key => $value ) {
  5862. $staffDetail = $staff->getOne ( array (
  5863. 'select' => 'username',
  5864. 'where' => 'sid=' . $value ['staff'],
  5865. 'asArray' => true
  5866. ) );
  5867. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  5868. }
  5869. // 办事处筛选
  5870. $categoryScreen = array ();
  5871. $categorList = $Lcategory->getCategory ();
  5872. foreach ( $receiptList2 as $key => $value ) {
  5873. foreach ( $categorList as $k => $v ) {
  5874. if ($value ['cid'] == $v ['cid']) {
  5875. $categoryScreen [$v ['cidKey']] = $v ['title'];
  5876. break;
  5877. }
  5878. }
  5879. }
  5880. $categoryScreenHtml = "";
  5881. foreach ( $categoryScreen as $key => $value ) {
  5882. if ($cidKey == $key)
  5883. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  5884. else
  5885. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  5886. }
  5887. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  5888. $data ['cidKey'] = $cidKey;
  5889. $Locate = 0;
  5890. $roleId = 0;
  5891. $button = 0;
  5892. $staffBatchNumber = 100001;
  5893. $remittanceList = array ();
  5894. foreach ( $receiptList as $key => $value ) {
  5895. $receiptList [$key] ['ridKey7'] = $XDeode7->encode ( $value ['rid'] );
  5896. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  5897. $receiptList [$key] ['Texe'] = 'false';
  5898. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  5899. $receiptList [$key] ['Texe'] = 'true';
  5900. }
  5901. $receiptList [$key] ['TRexe'] = 'true';
  5902. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  5903. $receiptList [$key] ['TRexe'] = 'false';
  5904. }
  5905. $receiptList [$key] ['Locate'] = $Locate;
  5906. $Locate ++;
  5907. $receiptList [$key] ['reviseDetail'] = array ();
  5908. if (! empty ( $value ['reviseDetail'] ))
  5909. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5910. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5911. $categoryDetil = $Lcategory->getOne ( array (
  5912. 'where' => 'cid=' . $value ['cid'],
  5913. 'asArray' => true
  5914. ) );
  5915. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5916. // 检测编辑状态
  5917. $verifyList = $verify->getOne ( array (
  5918. 'where' => 'vid=' . $value ['verify'],
  5919. 'asArray' => true
  5920. ) );
  5921. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5922. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5923. Doo::loadModel ( 'role' );
  5924. $role = new role ();
  5925. $flag = true;
  5926. $roleKey = 0;
  5927. $endStaffArray = array ();
  5928. $roleArrayCopy = array ();
  5929. foreach ( $verifyList as $k => $v ) {
  5930. // init verifyStaff
  5931. if ($v [1] == 'ROLE') {
  5932. if (! empty ( $verifyStaff )) {
  5933. $endStaffArray = end ( $verifyStaff );
  5934. }
  5935. $roleVerify = json_decode ( $v [3], true );
  5936. $roleKey = $k;
  5937. $roleArray = array ();
  5938. $rolename = $role->getOne ( array (
  5939. 'where' => 'rid=' . $v [0],
  5940. 'asArray' => true
  5941. ) );
  5942. foreach ( $roleVerify as $o => $p ) {
  5943. $staffID = explode ( '_', $p );
  5944. $staffInfo = $staff->getOne ( array (
  5945. 'where' => 'sid=' . $staffID [0],
  5946. 'asArray' => true
  5947. ) );
  5948. $exp = array (
  5949. 0 => $staffInfo ['sid'],
  5950. 1 => $staffID [1],
  5951. 2 => $staffInfo ['avatar'],
  5952. 'date' => '',
  5953. 'date' => '',
  5954. 'opinion' => '',
  5955. 'status' => '',
  5956. 'rolename' => $rolename ['name']
  5957. );
  5958. array_push ( $roleArray, $exp );
  5959. }
  5960. $roleArrayCopy [$v [0]] = $roleArray;
  5961. }
  5962. $verifyList [$k] ['date'] = "";
  5963. $verifyList [$k] ['opinion'] = "";
  5964. $verifyList [$k] ['status'] = "";
  5965. if (empty ( $verifyStaff )) {
  5966. $verifyList [$k] ['date'] = "";
  5967. $verifyList [$k] ['opinion'] = "";
  5968. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5969. $verifyList [$k] ['status'] = 4;
  5970. $flag = false;
  5971. }
  5972. } else {
  5973. foreach ( $verifyStaff as $m => $u ) {
  5974. if ($v [0] == $m) {
  5975. $verifyList [$k] ['date'] = $u ['date'];
  5976. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5977. $verifyList [$k] ['status'] = $u ['status'];
  5978. $flag = false;
  5979. break;
  5980. }
  5981. }
  5982. $endStaffArray = end ( $verifyStaff );
  5983. }
  5984. }
  5985. $rolename ['name'] = '';
  5986. if (! empty ( $roleId )) {
  5987. Doo::loadModel ( 'role' );
  5988. $role = new role ();
  5989. $rolename = $role->getOne ( array (
  5990. 'where' => 'rid=' . $roleId,
  5991. 'asArray' => true
  5992. ) );
  5993. }
  5994. if (! empty ( $verifyStaff ))
  5995. $endStaffArray = end ( $verifyStaff );
  5996. $KOP = false;
  5997. foreach ( $roleArrayCopy as $P => $A ) {
  5998. foreach ( $A as $MKI => $AVL ) {
  5999. if (! empty ( $verifyStaff )) {
  6000. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6001. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6002. $button = 4;
  6003. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6004. }
  6005. foreach ( $verifyStaff as $m => $u ) {
  6006. $AVLFK = $AVL [0] . '_R';
  6007. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6008. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6009. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6010. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6011. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6012. break;
  6013. }
  6014. }
  6015. } else {
  6016. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6017. $button = 4;
  6018. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6019. }
  6020. }
  6021. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6022. $KOP = true;
  6023. }
  6024. }
  6025. foreach ( $roleArrayCopy as $k => $v ) {
  6026. foreach ( $verifyList as $m => $n ) {
  6027. if ($n [0] == $k) {
  6028. array_splice ( $verifyList, $m, 1, $v );
  6029. }
  6030. }
  6031. }
  6032. $receiptList [$key] ['verifyList'] = $verifyList;
  6033. $staffDetail = $staff->getOne ( array (
  6034. 'where' => 'sid=' . $value ['staff'],
  6035. 'asArray' => true
  6036. ) );
  6037. $receiptList [$key] ['staffDetail'] = $staffDetail;
  6038. $receiptList [$key] ['button'] = $button;
  6039. // 设置导出汇款execl
  6040. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  6041. $remittanceDetail = array (
  6042. $staffBatchNumber,
  6043. $value ['remittanceName'],
  6044. $value ['bankNumber'],
  6045. $value ['bankName'],
  6046. $value ['remittanceBankType'],
  6047. $value ['coupletNumber'],
  6048. $value ['sum']
  6049. );
  6050. array_push ( $remittanceList, $remittanceDetail );
  6051. $staffBatchNumber ++;
  6052. }
  6053. }
  6054. $data ['remittanceList'] = json_encode ( $remittanceList );
  6055. // print_r($receiptList);
  6056. $mothHtml = "";
  6057. for($i = 1; $i <= 12; $i ++) {
  6058. if ($moth == $i)
  6059. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6060. else
  6061. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6062. }
  6063. $dayHtml = "";
  6064. if ($day != "DAY" || $moth != "MONTH") {
  6065. for($i = 1; $i <= 31; $i ++) {
  6066. if ($day == $i)
  6067. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6068. else
  6069. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6070. }
  6071. }
  6072. $sopHtml = "";
  6073. foreach ( $sopStaff as $key => $value ) {
  6074. if ($sop == $key)
  6075. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  6076. else
  6077. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  6078. }
  6079. $data ['status'] = $status;
  6080. $data ['rdate'] = $rdate;
  6081. $data ['sopHtml'] = $sopHtml;
  6082. $data ['dayHtml'] = $dayHtml;
  6083. $data ['mothHtml'] = $mothHtml;
  6084. $data ['receiptList'] = $receiptList;
  6085. $data ['memu'] = "receipt";
  6086. $data ['staff'] = $this->staff;
  6087. $data ['receiptMemu'] = 'implement';
  6088. $data ['verifyId'] = $this->verifyId;
  6089. $data ['executeId'] = $this->executeId;
  6090. $data ['item'] = $item;
  6091. $data ['year'] = $year;
  6092. $data ['moth'] = $moth;
  6093. $data['receiptOrder']=$receiptOrder;
  6094. $data ['day'] = $day;
  6095. $data ['sop'] = $sop;
  6096. $this->render ( "/admin/hisImplement", $data );
  6097. }
  6098. /**
  6099. * 导出汇款信息的exelc
  6100. */
  6101. function exportRemittance() {
  6102. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  6103. if (empty ( $remittanceInfo ))
  6104. die ( 'illegal request' );
  6105. $title = array (
  6106. '员工编号',
  6107. '姓名',
  6108. '员工账号',
  6109. '员工账户开户行',
  6110. '转账类型',
  6111. '联行号',
  6112. '金额'
  6113. );
  6114. $data = json_decode ( $remittanceInfo, true );
  6115. if (empty ( $data ))
  6116. die ( 'illegal request' );
  6117. Doo::loadClass ( 'receipt.func' );
  6118. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  6119. header ( 'Content-Type:text/html;charset=utf-8' );
  6120. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  6121. }
  6122. function ajaxExamine() {
  6123. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6124. Doo::loadModel ( 'receipt' );
  6125. $receipt = new receipt ();
  6126. if (! empty ( $rid )) {
  6127. $rLRes = $receipt->find ( array (
  6128. '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,
  6129. 'asArray' => true
  6130. ) );
  6131. echo json_encode ( array (
  6132. 'status' => 1,
  6133. 'receipt' => $rLRes [0]
  6134. ) );
  6135. die ();
  6136. }
  6137. echo json_encode ( array (
  6138. 'status' => 0,
  6139. 'receipt' => array ()
  6140. ) );
  6141. die ();
  6142. }
  6143. /*
  6144. * 废弃
  6145. */
  6146. function myReceipt() {
  6147. // all approval past withdraw
  6148. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  6149. if (empty ( $item ))
  6150. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  6151. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6152. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  6153. Doo::loadModel ( 'receipt' );
  6154. $receipt = new receipt ();
  6155. // pre-loaded
  6156. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6157. // have cache
  6158. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  6159. if (! empty ( $moth )) // yearPage
  6160. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  6161. $this->showCache ( $path );
  6162. }
  6163. Doo::loadModel ( 'L_category' );
  6164. $Lcategory = new L_category ();
  6165. Doo::loadModel ( 'verify' );
  6166. Doo::loadModel ( 'statistics' );
  6167. $statistics = new statistics ();
  6168. $verify = new verify ();
  6169. Doo::loadModel ( 'staff' );
  6170. $staff = new staff ();
  6171. $condition = " and status!=0 ";
  6172. if ($item == "approval")
  6173. $condition = " and status=2 ";
  6174. elseif ($item == "withdraw")
  6175. $condition = " and status=3 ";
  6176. elseif ($item == "past")
  6177. $condition = " and status=1 ";
  6178. elseif ($item == "whdw")
  6179. $condition = " and status=4 ";
  6180. $dateCondition = " and Year(date) =" . $year;
  6181. if (! empty ( $moth )) {
  6182. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  6183. $stList = $statistics->getOne ( array (
  6184. 'select' => 'rePrice ,agPrice',
  6185. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  6186. 'asArray' => true
  6187. ) );
  6188. } else
  6189. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  6190. if (empty ( $stList ))
  6191. $stList = array (
  6192. 'rePrice' => 0,
  6193. 'agPrice' => 0
  6194. );
  6195. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  6196. $data ['stList'] = array (
  6197. 'rePrice' => $stList ['rePrice'],
  6198. 'agPrice' => $stList ['agPrice'],
  6199. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  6200. );
  6201. $receiptList = $receipt->find ( array (
  6202. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  6203. 'desc' => 'rid',
  6204. 'asArray' => true
  6205. ) );
  6206. $Locate = 0;
  6207. $roleId = 0;
  6208. $button = 0;
  6209. foreach ( $receiptList as $key => $value ) {
  6210. $receiptList [$key] ['Locate'] = $Locate;
  6211. $Locate ++;
  6212. $receiptList [$key] ['reviseDetail'] = array ();
  6213. if (! empty ( $value ['reviseDetail'] ))
  6214. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6215. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6216. $categoryDetil = $Lcategory->getOne ( array (
  6217. 'where' => 'cid=' . $value ['cid'],
  6218. 'asArray' => true
  6219. ) );
  6220. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6221. // 检测编辑状态
  6222. $verifyList = $verify->getOne ( array (
  6223. 'where' => 'vid=' . $value ['verify'],
  6224. 'asArray' => true
  6225. ) );
  6226. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6227. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6228. Doo::loadModel ( 'role' );
  6229. $role = new role ();
  6230. $flag = true;
  6231. $roleKey = 0;
  6232. $endStaffArray = array ();
  6233. $roleArrayCopy = array ();
  6234. foreach ( $verifyList as $k => $v ) {
  6235. // init verifyStaff
  6236. if ($v [1] == 'ROLE') {
  6237. if (! empty ( $verifyStaff )) {
  6238. $endStaffArray = end ( $verifyStaff );
  6239. // if ($v[0]==$endStaffArray['nextStaff']){
  6240. // $roleId=$v[0];
  6241. // }
  6242. }
  6243. $roleVerify = json_decode ( $v [3], true );
  6244. $roleKey = $k;
  6245. $roleArray = array ();
  6246. $rolename = $role->getOne ( array (
  6247. 'where' => 'rid=' . $v [0],
  6248. 'asArray' => true
  6249. ) );
  6250. foreach ( $roleVerify as $o => $p ) {
  6251. $staffID = explode ( '_', $p );
  6252. $staffInfo = $staff->getOne ( array (
  6253. 'where' => 'sid=' . $staffID [0],
  6254. 'asArray' => true
  6255. ) );
  6256. // print_r($staffID);
  6257. $exp = array (
  6258. 0 => $staffInfo ['sid'],
  6259. 1 => $staffID [1],
  6260. 2 => $staffInfo ['avatar'],
  6261. 'date' => '',
  6262. 'date' => '',
  6263. 'opinion' => '',
  6264. 'status' => '',
  6265. 'rolename' => $rolename ['name']
  6266. );
  6267. array_push ( $roleArray, $exp );
  6268. }
  6269. $roleArrayCopy [$v [0]] = $roleArray;
  6270. // $verifyList[$k]['roleArray']=$roleArray;
  6271. }
  6272. $verifyList [$k] ['date'] = "";
  6273. $verifyList [$k] ['opinion'] = "";
  6274. $verifyList [$k] ['status'] = "";
  6275. if (empty ( $verifyStaff )) {
  6276. $verifyList [$k] ['date'] = "";
  6277. $verifyList [$k] ['opinion'] = "";
  6278. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6279. $verifyList [$k] ['status'] = 4;
  6280. $flag = false;
  6281. }
  6282. } else {
  6283. foreach ( $verifyStaff as $m => $u ) {
  6284. if ($v [0] == $m) {
  6285. $verifyList [$k] ['date'] = $u ['date'];
  6286. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6287. $verifyList [$k] ['status'] = $u ['status'];
  6288. $flag = false;
  6289. break;
  6290. }
  6291. }
  6292. $endStaffArray = end ( $verifyStaff );
  6293. if (isset ( $endStaffArray ['ROLE'] )) {
  6294. } else {
  6295. // $endKey=key($verifyStaff);
  6296. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  6297. // $button=4;
  6298. // $verifyList[$k]['status']=4;
  6299. // }
  6300. }
  6301. }
  6302. }
  6303. $rolename ['name'] = '';
  6304. if (! empty ( $roleId )) {
  6305. Doo::loadModel ( 'role' );
  6306. $role = new role ();
  6307. $rolename = $role->getOne ( array (
  6308. 'where' => 'rid=' . $roleId,
  6309. 'asArray' => true
  6310. ) );
  6311. }
  6312. if (! empty ( $verifyStaff ))
  6313. $endStaffArray = end ( $verifyStaff );
  6314. $KOP = false;
  6315. foreach ( $roleArrayCopy as $P => $A ) {
  6316. foreach ( $A as $MKI => $AVL ) {
  6317. if (! empty ( $verifyStaff )) {
  6318. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6319. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6320. $button = 4;
  6321. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6322. }
  6323. foreach ( $verifyStaff as $m => $u ) {
  6324. $AVLFK = $AVL [0] . '_R';
  6325. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6326. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6327. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6328. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6329. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6330. break;
  6331. }
  6332. }
  6333. } else {
  6334. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6335. $button = 4;
  6336. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6337. }
  6338. }
  6339. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6340. $KOP = true;
  6341. }
  6342. }
  6343. foreach ( $roleArrayCopy as $k => $v ) {
  6344. foreach ( $verifyList as $m => $n ) {
  6345. if ($n [0] == $k) {
  6346. array_splice ( $verifyList, $m, 1, $v );
  6347. }
  6348. }
  6349. }
  6350. $receiptList [$key] ['verifyList'] = $verifyList;
  6351. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6352. 'where' => 'sid=' . $value ['staff'],
  6353. 'asArray' => true
  6354. ) );
  6355. $receiptList [$key] ['button'] = $button;
  6356. }
  6357. // print_r($receiptList);die;
  6358. $mothHtml = "";
  6359. for($i = 1; $i <= 12; $i ++) {
  6360. if ($moth == $i)
  6361. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6362. else
  6363. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6364. }
  6365. $data ['mothHtml'] = $mothHtml;
  6366. $data ['receiptList'] = $receiptList;
  6367. $data ['memu'] = "receipt";
  6368. $data ['staff'] = $this->staff;
  6369. $data ['receiptMemu'] = 'receipt';
  6370. $data ['verifyId'] = $this->verifyId;
  6371. $data ['executeId'] = $this->executeId;
  6372. $data ['item'] = $item;
  6373. $data ['year'] = $year;
  6374. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  6375. // sufficient condition to generate cache
  6376. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  6377. $receiptList = $receipt->find ( array (
  6378. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  6379. 'asArray' => true
  6380. ) );
  6381. if (empty ( $receiptList )) { // generated files
  6382. ob_start ();
  6383. $this->render ( "/admin/saea_myList", $data );
  6384. $this->cacheFile ( $path );
  6385. die ();
  6386. // $content = ob_get_contents();
  6387. // $fp = fopen($path, "w");
  6388. // fwrite($fp, $content);
  6389. // fclose($fp);
  6390. }
  6391. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  6392. $receiptList = $receipt->find ( array (
  6393. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  6394. 'asArray' => true
  6395. ) );
  6396. if (empty ( $receiptList )) { // generated files
  6397. ob_start ();
  6398. $this->render ( "/admin/saea_myList", $data );
  6399. $this->cacheFile ( $path );
  6400. die ();
  6401. }
  6402. }
  6403. }
  6404. $this->render ( "/admin/saea_myList", $data );
  6405. }
  6406. function saeaCreate() {
  6407. Doo::loadModel ( 'accountItem' );
  6408. Doo::loadModel ( 'verify' );
  6409. Doo::loadModel ( 'receipt' );
  6410. Doo::loadModel ( 'L_category' );
  6411. $lCategory = new L_category ();
  6412. $receipt = new receipt ();
  6413. $verify = new verify ();
  6414. $accountItem = new accountItem ();
  6415. Doo::loadModel ( "role" );
  6416. $role = new role ();
  6417. $acItem = $accountItem->find ( array (
  6418. 'asArray' => true
  6419. ) );
  6420. $veList = $verify->find ( array (
  6421. 'asArray' => true
  6422. ) );
  6423. foreach ( $veList as $key => $value ) {
  6424. $v = json_decode ( $value ['staff'] );
  6425. $list = array ();
  6426. foreach ( $v as $n => $m ) {
  6427. if ($m ['1'] == 'ROLE') {
  6428. $roleInfo = $role->getOne ( array (
  6429. 'where' => 'rid=' . $m [0],
  6430. 'asArray' => true
  6431. ) );
  6432. $v [$n] [1] = $roleInfo ['name'];
  6433. array_push ( $list, $roleInfo ['name'] );
  6434. } else {
  6435. array_push ( $list, $v [$n] [1] );
  6436. }
  6437. }
  6438. $veList [$key] ['staff'] = implode ( '>', $list );
  6439. }
  6440. $data ['category'] = $lCategory->find ( array (
  6441. 'asArray' => true
  6442. ) );
  6443. $data ['veList'] = $veList;
  6444. $data ['acItem'] = $acItem;
  6445. $data ['memu'] = "receipt";
  6446. $data ['staff'] = $this->staff;
  6447. $data ['receiptMemu'] = 'saeaBorad';
  6448. $data ['verifyId'] = $this->verifyId;
  6449. $data ['executeId'] = $this->executeId;
  6450. $this->render ( "/admin/saea_create", $data );
  6451. }
  6452. function addReceipt() {
  6453. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  6454. $agency = $this->get_args ( 'agency' );
  6455. $travel = $this->get_args ( 'travel' );
  6456. $train = $this->get_args ( 'train' );
  6457. $other = $this->get_args ( 'other' );
  6458. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6459. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6460. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6461. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6462. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6463. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6464. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6465. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6466. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6467. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6468. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6469. header ( 'Content-Type:text/html;charset=utf-8' );
  6470. die ( '请填写联行号' );
  6471. }
  6472. Doo::loadModel ( 'receipt' );
  6473. Doo::loadModel ( 'receiptDetail' );
  6474. Doo::loadModel ( 'accountItem' );
  6475. $accountItem = new accountItem ();
  6476. $receipt = new receipt ();
  6477. Doo::loadModel ( 'enclosur' );
  6478. Doo::loadModel ( 'execute' );
  6479. $execute = new execute ();
  6480. $executeDetail = $execute->getOne ( array (
  6481. 'where' => 'mold="报销单执行人"',
  6482. 'asArray' => true
  6483. ) );
  6484. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  6485. // if(!empty($receiptDetail))
  6486. // return "/referReceipt/".$receiptDetail['rid'];
  6487. $aItem = $accountItem->find ( array (
  6488. 'asArray' => true
  6489. ) );
  6490. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6491. $ag = $tr = $ta = $ot = 0;
  6492. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6493. foreach ( $aItem as $key => $value ) {
  6494. if ($value ['category'] == $this->AGENCY) {
  6495. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6496. array_push ( $accountJson [$this->AGENCY], array (
  6497. 'aid' => $value ['aid'],
  6498. 'name' => $value ['name'],
  6499. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6500. ) );
  6501. $sum += $agency [$ag];
  6502. $agencySum += $agency [$ag];
  6503. }
  6504. $ag ++;
  6505. }
  6506. if ($value ['category'] == $this->TRAVEL) {
  6507. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6508. array_push ( $accountJson [$this->TRAVEL], array (
  6509. 'aid' => $value ['aid'],
  6510. 'name' => $value ['name'],
  6511. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6512. ) );
  6513. $sum += $travel [$tr];
  6514. $travelSum += $travel [$tr];
  6515. }
  6516. $tr ++;
  6517. }
  6518. if ($value ['category'] == $this->TRAIN) {
  6519. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6520. array_push ( $accountJson [$this->TRAIN], array (
  6521. 'aid' => $value ['aid'],
  6522. 'name' => $value ['name'],
  6523. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6524. ) );
  6525. $sum += $train [$ta];
  6526. $trainSum += $train [$ta];
  6527. }
  6528. $ta ++;
  6529. }
  6530. if ($value ['category'] == $this->OTHER) {
  6531. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6532. array_push ( $accountJson [$this->OTHER], array (
  6533. 'aid' => $value ['aid'],
  6534. 'name' => $value ['name'],
  6535. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6536. ) );
  6537. $sum += $other [$ot];
  6538. $otherSum += $other [$ot];
  6539. }
  6540. $ot ++;
  6541. }
  6542. }
  6543. $accountJson ['cSum'] = array (
  6544. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6545. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6546. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6547. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6548. );
  6549. // 报销单
  6550. $receipt->accountItem = json_encode ( $accountJson );
  6551. $receipt->staff = $this->staff [0] ['sid'];
  6552. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6553. $receipt->date = date ( "Y-m-d" );
  6554. $receipt->cid = $cid;
  6555. $receipt->status = 5;
  6556. // 修改审批流程加入角色
  6557. $receipt->verify = $verify;
  6558. $receipt->executeCopy = $executeDetail ['staff'];
  6559. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  6560. $order = array (
  6561. "\r\n",
  6562. "\n",
  6563. "\r"
  6564. );
  6565. $replace = '<br/>';
  6566. $explanation = str_replace ( $order, $replace, $explanation );
  6567. $receipt->explanation = $explanation;
  6568. $receipt->remittanceName = $remittanceName;
  6569. $receipt->bankName = $bankName;
  6570. $receipt->bankNumber = $bankNumber;
  6571. $receipt->remittanceBankType = $remittanceBankType;
  6572. if ($remittanceBankType == 1)
  6573. $receipt->coupletNumber = $coupletNumber;
  6574. $rid = $receipt->insert ();
  6575. // 附件
  6576. if (! empty ( $enclosurName )) {
  6577. $enclosurArray = explode ( '-', $enclosurName );
  6578. foreach ( $enclosurArray as $value ) {
  6579. $enclosur = new enclosur ();
  6580. $enclosur->name = $value;
  6581. $enclosur->rid = $rid;
  6582. $enclosur->insert ();
  6583. }
  6584. // print_r($enclosurArray);die;
  6585. }
  6586. // 报销详情
  6587. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6588. $receiptDetail = new receiptDetail ();
  6589. $receiptDetail->staff = $this->staff [0] ['sid'];
  6590. $receiptDetail->item = $value ['name'];
  6591. $receiptDetail->itemCategory = $this->AGENCY;
  6592. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6593. $receiptDetail->date = date ( "Y-m-d" );
  6594. $receiptDetail->cid = $cid;
  6595. $receiptDetail->rid = $rid;
  6596. $receiptDetail->status = 4;
  6597. $receiptDetail->insert ();
  6598. }
  6599. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6600. $receiptDetail = new receiptDetail ();
  6601. $receiptDetail->staff = $this->staff [0] ['sid'];
  6602. $receiptDetail->item = $value ['name'];
  6603. $receiptDetail->itemCategory = $this->TRAVEL;
  6604. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6605. $receiptDetail->date = date ( "Y-m-d" );
  6606. $receiptDetail->cid = $cid;
  6607. $receiptDetail->rid = $rid;
  6608. $receiptDetail->status = 4;
  6609. $receiptDetail->insert ();
  6610. }
  6611. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6612. $receiptDetail = new receiptDetail ();
  6613. $receiptDetail->staff = $this->staff [0] ['sid'];
  6614. $receiptDetail->item = $value ['name'];
  6615. $receiptDetail->itemCategory = $this->TRAIN;
  6616. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6617. $receiptDetail->date = date ( "Y-m-d" );
  6618. $receiptDetail->cid = $cid;
  6619. $receiptDetail->rid = $rid;
  6620. $receiptDetail->status = 4;
  6621. $receiptDetail->insert ();
  6622. }
  6623. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6624. $receiptDetail = new receiptDetail ();
  6625. $receiptDetail->staff = $this->staff [0] ['sid'];
  6626. $receiptDetail->item = $value ['name'];
  6627. $receiptDetail->itemCategory = $this->OTHER;
  6628. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6629. $receiptDetail->date = date ( "Y-m-d" );
  6630. $receiptDetail->cid = $cid;
  6631. $receiptDetail->rid = $rid;
  6632. $receiptDetail->status = 4;
  6633. $receiptDetail->insert ();
  6634. }
  6635. return "/saeaBorad";
  6636. } else
  6637. die ( 'illegal request' );
  6638. }
  6639. function referReceipt() {
  6640. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6641. Doo::loadModel ( 'receipt' );
  6642. Doo::loadModel ( 'verify' );
  6643. $verify = new verify ();
  6644. $receipt = new receipt ();
  6645. Doo::loadModel ( 'L_category' );
  6646. $lCategory = new L_category ();
  6647. Doo::loadModel ( "role" );
  6648. $role = new role ();
  6649. $receiptDetail = $receipt->find ( array (
  6650. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  6651. 'asArray' => true
  6652. ) );
  6653. if (empty ( $receiptDetail ))
  6654. return "/addReceipt";
  6655. foreach ( $receiptDetail as $key => $value ) {
  6656. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6657. $veList = $verify->getOne ( array (
  6658. 'where' => 'vid=' . $value ['verify'],
  6659. 'asArray' => true
  6660. ) );
  6661. $v = json_decode ( $veList ['staff'] );
  6662. array_push ( $v [0], $veList ['description'] );
  6663. foreach ( $v as $n => $m ) {
  6664. if ($m ['1'] == 'ROLE') {
  6665. $roleInfo = $role->getOne ( array (
  6666. 'where' => 'rid=' . $m [0],
  6667. 'asArray' => true
  6668. ) );
  6669. $v [$n] [1] = $roleInfo ['name'];
  6670. }
  6671. }
  6672. $receiptDetail [$key] ['staff'] = $v;
  6673. $category = $lCategory->getOne ( array (
  6674. 'where' => 'cid=' . $value ['cid'],
  6675. 'asArray' => true
  6676. ) );
  6677. $receiptDetail [$key] ['category'] = $category ['title'];
  6678. }
  6679. // print_r($receiptDetail);
  6680. $data ['receiptDetail'] = $receiptDetail;
  6681. $data ['memu'] = "receipt";
  6682. $data ['staff'] = $this->staff;
  6683. $data ['receiptMemu'] = 'saeaCreate';
  6684. $data ['verifyId'] = $this->verifyId;
  6685. $data ['executeId'] = $this->executeId;
  6686. $this->render ( "/admin/saea_confirm", $data );
  6687. }
  6688. function editReceipt() {
  6689. // edit status 4
  6690. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  6691. Doo::loadClass ( 'XDeode' );
  6692. $XDeode = new XDeode ( 7 );
  6693. $rid = $XDeode->decode ( $ridKey );
  6694. if (empty ( $rid ))
  6695. die ( 'illegal request' );
  6696. // echo $rid.'sd';
  6697. Doo::loadModel ( 'accountItem' );
  6698. Doo::loadModel ( 'verify' );
  6699. Doo::loadModel ( 'receipt' );
  6700. $receipt = new receipt ();
  6701. $verify = new verify ();
  6702. $accountItem = new accountItem ();
  6703. Doo::loadModel ( 'L_category' );
  6704. $lCategory = new L_category ();
  6705. Doo::loadModel ( "role" );
  6706. $role = new role ();
  6707. Doo::loadModel ( 'enclosur' );
  6708. $enclosur = new enclosur ();
  6709. $receiptDetail = $receipt->getOne ( array (
  6710. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  6711. 'asArray' => true
  6712. ) );
  6713. if (empty ( $receiptDetail ))
  6714. die ( 'illegal request' );
  6715. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  6716. $acItem = $accountItem->find ( array (
  6717. 'asArray' => true
  6718. ) );
  6719. $veList = $verify->find ( array (
  6720. 'asArray' => true
  6721. ) );
  6722. foreach ( $veList as $key => $value ) {
  6723. $v = json_decode ( $value ['staff'] );
  6724. $list = array ();
  6725. foreach ( $v as $n => $m ) {
  6726. if ($m ['1'] == 'ROLE') {
  6727. $roleInfo = $role->getOne ( array (
  6728. 'where' => 'rid=' . $m [0],
  6729. 'asArray' => true
  6730. ) );
  6731. $v [$n] [1] = $roleInfo ['name'];
  6732. array_push ( $list, $roleInfo ['name'] );
  6733. } else {
  6734. array_push ( $list, $v [$n] [1] );
  6735. }
  6736. }
  6737. $veList [$key] ['staff'] = implode ( '>', $list );
  6738. }
  6739. // 配置编辑信息
  6740. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  6741. foreach ( $acItem as $key => $value ) {
  6742. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  6743. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  6744. $acItem [$key] ['price'] = $v ['price'];
  6745. }
  6746. }
  6747. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  6748. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  6749. $acItem [$key] ['price'] = $v ['price'];
  6750. }
  6751. }
  6752. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  6753. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  6754. $acItem [$key] ['price'] = $v ['price'];
  6755. }
  6756. }
  6757. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  6758. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  6759. $acItem [$key] ['price'] = $v ['price'];
  6760. }
  6761. }
  6762. }
  6763. $data ['category'] = $lCategory->find ( array (
  6764. 'asArray' => true
  6765. ) );
  6766. $data ['cSum'] = $accountItemList ['cSum'];
  6767. $data ['sum'] = $receiptDetail ['sum'];
  6768. $data ['enclosurList'] = $enclosurList;
  6769. $data ['receiptDetail'] = $receiptDetail;
  6770. $data ['veList'] = $veList;
  6771. $data ['acItem'] = $acItem;
  6772. $data ['memu'] = "receipt";
  6773. $data ['staff'] = $this->staff;
  6774. $data ['receiptMemu'] = 'saeaBorad';
  6775. $data ['verify'] = $receiptDetail ['verify'];
  6776. $data ['verifyId'] = $this->verifyId;
  6777. $data ['executeId'] = $this->executeId;
  6778. $data ['rid'] = $ridKey;
  6779. $this->render ( "/admin/saea_edit", $data );
  6780. }
  6781. function updateReceipt() {
  6782. $agency = $this->get_args ( 'agency' );
  6783. $travel = $this->get_args ( 'travel' );
  6784. $train = $this->get_args ( 'train' );
  6785. $other = $this->get_args ( 'other' );
  6786. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  6787. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  6788. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  6789. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  6790. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  6791. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  6792. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  6793. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  6794. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  6795. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  6796. Doo::loadClass ( 'XDeode' );
  6797. $XDeode = new XDeode ( 7 );
  6798. $rid = $XDeode->decode ( $ridKey );
  6799. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  6800. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  6801. header ( 'Content-Type:text/html;charset=utf-8' );
  6802. die ( '请填写联行号' );
  6803. }
  6804. Doo::loadModel ( 'receipt' );
  6805. Doo::loadModel ( 'receiptDetail' );
  6806. Doo::loadModel ( 'accountItem' );
  6807. $accountItem = new accountItem ();
  6808. $receipt = new receipt ();
  6809. Doo::loadModel ( 'enclosur' );
  6810. Doo::loadModel ( 'execute' );
  6811. $execute = new execute ();
  6812. $receiptDetail = $receipt->getOne ( array (
  6813. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  6814. 'asArray' => true
  6815. ) );
  6816. if (empty ( $receiptDetail ))
  6817. return "/saeaBorad";
  6818. if ($receiptDetail ['Rtype'] == 1)
  6819. $executeDetail = $execute->getOne ( array (
  6820. 'where' => 'mold="借款费用执行人"',
  6821. 'asArray' => true
  6822. ) );
  6823. else
  6824. $executeDetail = $execute->getOne ( array (
  6825. 'where' => 'mold="报销单执行人"',
  6826. 'asArray' => true
  6827. ) );
  6828. $aItem = $accountItem->find ( array (
  6829. 'asArray' => true
  6830. ) );
  6831. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  6832. $ag = $tr = $ta = $ot = 0;
  6833. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  6834. foreach ( $aItem as $key => $value ) {
  6835. if ($value ['category'] == $this->AGENCY) {
  6836. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  6837. array_push ( $accountJson [$this->AGENCY], array (
  6838. 'aid' => $value ['aid'],
  6839. 'name' => $value ['name'],
  6840. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  6841. ) );
  6842. $sum += $agency [$ag];
  6843. $agencySum += $agency [$ag];
  6844. }
  6845. $ag ++;
  6846. }
  6847. if ($value ['category'] == $this->TRAVEL) {
  6848. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  6849. array_push ( $accountJson [$this->TRAVEL], array (
  6850. 'aid' => $value ['aid'],
  6851. 'name' => $value ['name'],
  6852. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  6853. ) );
  6854. $sum += $travel [$tr];
  6855. $travelSum += $travel [$tr];
  6856. }
  6857. $tr ++;
  6858. }
  6859. if ($value ['category'] == $this->TRAIN) {
  6860. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  6861. array_push ( $accountJson [$this->TRAIN], array (
  6862. 'aid' => $value ['aid'],
  6863. 'name' => $value ['name'],
  6864. 'price' => number_format ( $train [$ta], 2, '.', '' )
  6865. ) );
  6866. $sum += $train [$ta];
  6867. $trainSum += $train [$ta];
  6868. }
  6869. $ta ++;
  6870. }
  6871. if ($value ['category'] == $this->OTHER) {
  6872. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  6873. array_push ( $accountJson [$this->OTHER], array (
  6874. 'aid' => $value ['aid'],
  6875. 'name' => $value ['name'],
  6876. 'price' => number_format ( $other [$ot], 2, '.', '' )
  6877. ) );
  6878. $sum += $other [$ot];
  6879. $otherSum += $other [$ot];
  6880. }
  6881. $ot ++;
  6882. }
  6883. }
  6884. $accountJson ['cSum'] = array (
  6885. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  6886. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  6887. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  6888. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  6889. );
  6890. // 报销单
  6891. $rid = $receipt->rid = $receiptDetail ['rid'];
  6892. $receipt->accountItem = json_encode ( $accountJson );
  6893. $receipt->staff = $this->staff [0] ['sid'];
  6894. $receipt->sum = number_format ( $sum, 2, '.', '' );
  6895. $receipt->date = date ( "Y-m-d" );
  6896. $receipt->cid = $cid;
  6897. if (($receiptDetail ['status'] != 4)) {
  6898. if ($receiptDetail ['Rtype'] == 1)
  6899. $receipt->status = 7;
  6900. else
  6901. $receipt->status = 5;
  6902. }
  6903. if ($receiptDetail != 4 && ! empty ( $verify ))
  6904. $receipt->verify = $verify;
  6905. $receipt->executeCopy = $executeDetail ['staff'];
  6906. $order = array (
  6907. "\r\n",
  6908. "\n",
  6909. "\r"
  6910. );
  6911. $replace = '<br/>';
  6912. $explanation = str_replace ( $order, $replace, $explanation );
  6913. $receipt->explanation = $explanation;
  6914. $receipt->remittanceName = $remittanceName;
  6915. $receipt->bankName = $bankName;
  6916. $receipt->bankNumber = $bankNumber;
  6917. $receipt->remittanceBankType = $remittanceBankType;
  6918. if ($remittanceBankType == 1)
  6919. $receipt->coupletNumber = $coupletNumber;
  6920. $receipt->update ();
  6921. $receiptDetail = new receiptDetail ();
  6922. $receiptDetail->delete ( array (
  6923. 'where' => 'rid=' . $rid
  6924. ) );
  6925. // 报销详情
  6926. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  6927. $receiptDetail = new receiptDetail ();
  6928. $receiptDetail->staff = $this->staff [0] ['sid'];
  6929. $receiptDetail->item = $value ['name'];
  6930. $receiptDetail->itemCategory = $this->AGENCY;
  6931. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6932. $receiptDetail->date = date ( "Y-m-d" );
  6933. $receiptDetail->cid = $cid;
  6934. $receiptDetail->rid = $rid;
  6935. $receiptDetail->status = 4;
  6936. $receiptDetail->insert ();
  6937. }
  6938. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  6939. $receiptDetail = new receiptDetail ();
  6940. $receiptDetail->staff = $this->staff [0] ['sid'];
  6941. $receiptDetail->item = $value ['name'];
  6942. $receiptDetail->itemCategory = $this->TRAVEL;
  6943. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6944. $receiptDetail->date = date ( "Y-m-d" );
  6945. $receiptDetail->cid = $cid;
  6946. $receiptDetail->rid = $rid;
  6947. $receiptDetail->status = 4;
  6948. $receiptDetail->insert ();
  6949. }
  6950. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  6951. $receiptDetail = new receiptDetail ();
  6952. $receiptDetail->staff = $this->staff [0] ['sid'];
  6953. $receiptDetail->item = $value ['name'];
  6954. $receiptDetail->itemCategory = $this->TRAIN;
  6955. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6956. $receiptDetail->date = date ( "Y-m-d" );
  6957. $receiptDetail->cid = $cid;
  6958. $receiptDetail->rid = $rid;
  6959. $receiptDetail->status = 4;
  6960. $receiptDetail->insert ();
  6961. }
  6962. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  6963. $receiptDetail = new receiptDetail ();
  6964. $receiptDetail->staff = $this->staff [0] ['sid'];
  6965. $receiptDetail->item = $value ['name'];
  6966. $receiptDetail->itemCategory = $this->OTHER;
  6967. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  6968. $receiptDetail->date = date ( "Y-m-d" );
  6969. $receiptDetail->cid = $cid;
  6970. $receiptDetail->rid = $rid;
  6971. $receiptDetail->status = 4;
  6972. $receiptDetail->insert ();
  6973. }
  6974. // 附件
  6975. if (! empty ( $enclosurName )) {
  6976. $enclosurArray = explode ( '-', $enclosurName );
  6977. foreach ( $enclosurArray as $value ) {
  6978. $enclosur = new enclosur ();
  6979. $enclosur->name = $value;
  6980. $enclosur->rid = $rid;
  6981. $enclosur->insert ();
  6982. }
  6983. }
  6984. // return "/referReceipt/".$rid;
  6985. }
  6986. return "/saeaBorad";
  6987. }
  6988. function approvedReceipt() {
  6989. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6990. Doo::loadModel ( 'receipt' );
  6991. Doo::loadModel ( 'receiptDetail' );
  6992. $receipt = new receipt ();
  6993. $receiptDetail = new receiptDetail ();
  6994. Doo::loadModel ( 'statistics' );
  6995. Doo::loadModel ( 'itemStatistics' );
  6996. $statistics = new statistics ();
  6997. $itemStatistics = new itemStatistics ();
  6998. Doo::loadModel ( "verify" );
  6999. $verify = new verify ();
  7000. // 审批状态的判定
  7001. $receiptDetailList = $receipt->getOne ( array (
  7002. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  7003. 'asArray' => true
  7004. ) );
  7005. if (empty ( $receiptDetailList ))
  7006. return "/saeaBorad";
  7007. $verifyDetail = $verify->getOne ( array (
  7008. 'where' => ' vid =' . $receiptDetailList ['verify'],
  7009. 'asArray' => true
  7010. ) );
  7011. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7012. if (empty ( $receiptDetailList ['nowStaff'] )) {
  7013. $nowStaff = "";
  7014. $nowStaffList = array ();
  7015. if ($verifyDetail [0] [1] == 'ROLE') {
  7016. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7017. foreach ( $vStaffString as $key => $value ) {
  7018. $staffK = explode ( "_", $value );
  7019. array_push ( $nowStaffList, $staffK [0] );
  7020. }
  7021. $nowStaff = implode ( ',', $nowStaffList );
  7022. } else {
  7023. $nowStaff = $verifyDetail [0] [0];
  7024. }
  7025. $receipt->nowStaff = $nowStaff;
  7026. }
  7027. // echo $nowStaff;
  7028. // print_r($verifyDetail);die;
  7029. $receipt->rid = $receiptDetailList ['rid'];
  7030. $receipt->date = date ( "Y-m-d" );
  7031. $receipt->status = 2;
  7032. $receipt->update ();
  7033. $receiptDetail->status = 2;
  7034. $receiptDetail->update ( array (
  7035. 'where' => 'rid=' . $receiptDetailList ['rid']
  7036. ) );
  7037. Doo::loadModel ( "receiptLog" );
  7038. $receiptLog = new receiptLog ();
  7039. Doo::loadModel ( "verify" );
  7040. $verify = new verify ();
  7041. $receiptInfo = $receipt->getOne ( array (
  7042. 'where' => 'rid=' . $rid,
  7043. 'asArray' => true
  7044. ) );
  7045. $vr = $verify->getOne ( array (
  7046. 'where' => 'vid=' . $receiptInfo ['verify'],
  7047. 'asArray' => true
  7048. ) );
  7049. $jd = json_decode ( $vr ['staff'] );
  7050. $roleId = 0;
  7051. foreach ( $jd as $key => $value ) {
  7052. if ($value [1] == 'ROLE') {
  7053. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7054. if ($pos !== false) {
  7055. $roleId = $value [0];
  7056. }
  7057. }
  7058. }
  7059. // 审批日志
  7060. // echo $roleId;die;
  7061. if (! empty ( $roleId )) {
  7062. Doo::loadModel ( "role" );
  7063. $role = new role ();
  7064. $roleInfo = $role->getOne ( array (
  7065. 'where' => 'rid=' . $roleId,
  7066. 'asArray' => true
  7067. ) );
  7068. // $receiptLog->rolename = $roleInfo ['name'];
  7069. }
  7070. $receiptLog->username = $this->staff [0] ['username'];
  7071. $receiptLog->uid = $this->staff [0] ['sid'];
  7072. $receiptLog->date = date ( "Y-m-d" );
  7073. $receiptLog->opinion = '提交审批';
  7074. $receiptLog->img = $this->staff [0] ['avatar'];
  7075. $receiptLog->status = 2;
  7076. $receiptLog->rid = $rid;
  7077. $receiptLog->insert ();
  7078. // statistics item
  7079. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  7080. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7081. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  7082. $stat = $statistics->getOne ( array (
  7083. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  7084. 'asArray' => true
  7085. ) );
  7086. if (empty ( $stat )) {
  7087. $statistics->date = date ( "Y-m-d" );
  7088. $statistics->cid = $this->staff [0] ['cid'];
  7089. $statistics->staff = $this->staff [0] ['sid'];
  7090. $statistics->agPrice = 0;
  7091. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7092. $statistics->insert ();
  7093. } else {
  7094. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  7095. $statistics->update ( array (
  7096. 'where' => 'sid=' . $stat ['sid']
  7097. ) );
  7098. }
  7099. return "/expenses";
  7100. }
  7101. function approval() {
  7102. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7103. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7104. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7105. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7106. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7107. if (empty ( $status ))
  7108. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7109. $vidList = array ();
  7110. $button = 0;
  7111. Doo::loadModel ( 'verify' );
  7112. $verify = new verify ();
  7113. Doo::loadModel ( 'receipt' );
  7114. $receipt = new receipt ();
  7115. Doo::loadModel ( 'staff' );
  7116. $staff = new staff ();
  7117. Doo::loadModel ( 'L_category' );
  7118. $Lcategory = new L_category ();
  7119. // user verify ID
  7120. $verifyDetail = $verify->find ( array (
  7121. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7122. 'asArray' => true
  7123. ) );
  7124. foreach ( $verifyDetail as $key => $value ) {
  7125. array_push ( $vidList, $value ['vid'] );
  7126. }
  7127. $vid = implode ( ",", $vidList );
  7128. if (empty ( $verifyDetail ))
  7129. $vid = 0;
  7130. /*
  7131. */
  7132. $dateCondition = " and Year(date) =" . $year;
  7133. if (! empty ( $month ))
  7134. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  7135. $categoryList = $Lcategory->find ( array (
  7136. 'asArray' => true
  7137. ) );
  7138. $staffList = $staff->find ( array (
  7139. 'where' => 'cid=' . $cid,
  7140. 'asArray' => true
  7141. ) );
  7142. $cateCondition = "";
  7143. $staffCondition = "";
  7144. $approvalCondition = "";
  7145. if (! empty ( $cid ))
  7146. $cateCondition = ' and cid=' . $cid;
  7147. if (! empty ( $sid )) {
  7148. $staffCondition = ' and staff=' . $sid;
  7149. $cateCondition = "";
  7150. }
  7151. // elseif($status==1){
  7152. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  7153. // }
  7154. if ($status == 2) {
  7155. // 查找角色审批人
  7156. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  7157. }
  7158. $ap = "";
  7159. if ($status == 4) {
  7160. $ap = 4;
  7161. $status = 2;
  7162. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  7163. }
  7164. if ($status == 5) {
  7165. $status = 4;
  7166. $ap = 5;
  7167. }
  7168. // echo $vid;
  7169. // get Receipt By verifyID status 2 .$approvalCondition
  7170. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  7171. $receiptList = $receipt->find ( array (
  7172. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  7173. 'desc' => 'rid',
  7174. 'asArray' => true
  7175. ) );
  7176. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  7177. $Locate = 0;
  7178. if ($ap == 4)
  7179. $status = 4;
  7180. elseif ($ap == 5)
  7181. $status = 5;
  7182. foreach ( $receiptList as $key => $value ) {
  7183. $receiptList [$key] ['Locate'] = $Locate;
  7184. $Locate ++;
  7185. $receiptList [$key] ['reviseDetail'] = array ();
  7186. if (! empty ( $value ['reviseDetail'] ))
  7187. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7188. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7189. $categoryDetil = $Lcategory->getOne ( array (
  7190. 'where' => 'cid=' . $value ['cid'],
  7191. 'asArray' => true
  7192. ) );
  7193. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7194. $verifyList = $verify->getOne ( array (
  7195. 'where' => 'vid=' . $value ['verify'],
  7196. 'asArray' => true
  7197. ) );
  7198. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7199. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7200. foreach ( $verifyList as $k => $v ) {
  7201. // init verifyStaff
  7202. $verifyList [$k] ['date'] = "";
  7203. $verifyList [$k] ['opinion'] = "";
  7204. $verifyList [$k] ['status'] = "";
  7205. if (empty ( $verifyStaff )) {
  7206. $verifyList [$k] ['date'] = "";
  7207. $verifyList [$k] ['opinion'] = "";
  7208. if ($v [0] == $this->staff [0] ['sid']) {
  7209. $verifyList [$k] ['status'] = 4;
  7210. $button = 4;
  7211. }
  7212. } else {
  7213. $flag = true;
  7214. foreach ( $verifyStaff as $m => $u ) {
  7215. if ($v [0] == $m) {
  7216. $verifyList [$k] ['date'] = $u ['date'];
  7217. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7218. $verifyList [$k] ['status'] = $u ['status'];
  7219. $flag = false;
  7220. break;
  7221. }
  7222. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  7223. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  7224. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  7225. }
  7226. if ($flag) { // 检测可编辑
  7227. if ($v [0] == $this->staff [0] ['sid']) {
  7228. $verifyList [$k] ['status'] = 4;
  7229. $button = 4;
  7230. }
  7231. }
  7232. }
  7233. }
  7234. $receiptList [$key] ['verifyList'] = $verifyList;
  7235. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7236. 'where' => 'sid=' . $value ['staff'],
  7237. 'asArray' => true
  7238. ) );
  7239. $receiptList [$key] ['button'] = $button;
  7240. }
  7241. // print_r($receiptList);die;
  7242. // $data['verifyDetail']=$verifyDetail;
  7243. $mothHtml = "";
  7244. for($i = 1; $i <= 12; $i ++) {
  7245. if ($month == $i)
  7246. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7247. else
  7248. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7249. }
  7250. $data ['mothHtml'] = $mothHtml;
  7251. $data ['receiptList'] = $receiptList;
  7252. $data ['receiptApprovalCount'] = count ( $receiptList );
  7253. $data ['status'] = $status;
  7254. $data ['year'] = $year;
  7255. $data ['categoryList'] = $categoryList;
  7256. $data ['staffList'] = $staffList;
  7257. $data ['cid'] = $cid;
  7258. $data ['sid'] = $sid;
  7259. $data ['ap'] = $ap;
  7260. $data ['memu'] = "receipt";
  7261. $data ['staff'] = $this->staff;
  7262. $data ['receiptMemu'] = 'approval';
  7263. $data ['verifyId'] = $this->verifyId;
  7264. $data ['executeId'] = $this->executeId;
  7265. $this->render ( "/admin/saea_reportList", $data );
  7266. }
  7267. function approvalDetails() {
  7268. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7269. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7270. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7271. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7272. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7273. Doo::loadModel ( 'verify' );
  7274. $verify = new verify ();
  7275. Doo::loadModel ( 'receipt' );
  7276. $receipt = new receipt ();
  7277. Doo::loadModel ( 'staff' );
  7278. $staff = new staff ();
  7279. Doo::loadModel ( 'L_category' );
  7280. $Lcategory = new L_category ();
  7281. Doo::loadModel ( 'enclosur' );
  7282. $enclosur = new enclosur ();
  7283. $vidList = array ();
  7284. $verifyDetail = $verify->find ( array (
  7285. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7286. 'asArray' => true
  7287. ) );
  7288. foreach ( $verifyDetail as $key => $value ) {
  7289. array_push ( $vidList, $value ['vid'] );
  7290. }
  7291. $vid = implode ( ",", $vidList );
  7292. if (empty ( $verifyDetail ))
  7293. $vid = 0;
  7294. $categoryList = $Lcategory->find ( array (
  7295. 'asArray' => true
  7296. ) );
  7297. $staffList = $staff->find ( array (
  7298. 'where' => 'cid=' . $cid,
  7299. 'asArray' => true
  7300. ) );
  7301. $ap = 0;
  7302. $receiptList = $receipt->find ( array (
  7303. 'where' => 'rid =' . $rid,
  7304. 'desc' => 'rid',
  7305. 'asArray' => true
  7306. ) );
  7307. $Locate = 0;
  7308. $roleId = 0;
  7309. $button = 0;
  7310. foreach ( $receiptList as $key => $value ) {
  7311. $receiptList [$key] ['Locate'] = $Locate;
  7312. $Locate ++;
  7313. $receiptList [$key] ['reviseDetail'] = array ();
  7314. if (! empty ( $value ['reviseDetail'] ))
  7315. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7316. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7317. $categoryDetil = $Lcategory->getOne ( array (
  7318. 'where' => 'cid=' . $value ['cid'],
  7319. 'asArray' => true
  7320. ) );
  7321. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7322. // 检测编辑状态
  7323. $verifyList = $verify->getOne ( array (
  7324. 'where' => 'vid=' . $value ['verify'],
  7325. 'asArray' => true
  7326. ) );
  7327. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7328. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7329. Doo::loadModel ( 'role' );
  7330. $role = new role ();
  7331. // print_r($verifyList);
  7332. $flag = true;
  7333. $roleKey = 0;
  7334. $endStaffArray = array ();
  7335. $roleArrayCopy = array ();
  7336. foreach ( $verifyList as $k => $v ) {
  7337. // init verifyStaff
  7338. if ($v [1] == 'ROLE') {
  7339. if (! empty ( $verifyStaff )) {
  7340. $endStaffArray = end ( $verifyStaff );
  7341. if ($v [0] == $endStaffArray ['nextStaff']) {
  7342. $roleId = $v [0];
  7343. }
  7344. }
  7345. $roleVerify = json_decode ( $v [3], true );
  7346. $roleKey = $k;
  7347. $roleArray = array ();
  7348. $rolename = $role->getOne ( array (
  7349. 'where' => 'rid=' . $v [0],
  7350. 'asArray' => true
  7351. ) );
  7352. foreach ( $roleVerify as $o => $p ) {
  7353. $staffID = explode ( '_', $p );
  7354. $staffInfo = $staff->getOne ( array (
  7355. 'where' => 'sid=' . $staffID [0],
  7356. 'asArray' => true
  7357. ) );
  7358. // print_r($staffID);
  7359. $exp = array (
  7360. 0 => $staffInfo ['sid'],
  7361. 1 => $staffID [1],
  7362. 2 => $staffInfo ['avatar'],
  7363. 'date' => '',
  7364. 'date' => '',
  7365. 'opinion' => '',
  7366. 'status' => '',
  7367. 'rolename' => $rolename ['name']
  7368. );
  7369. array_push ( $roleArray, $exp );
  7370. }
  7371. $roleArrayCopy [$v [0]] = $roleArray;
  7372. // $verifyList[$k]['roleArray']=$roleArray;
  7373. }
  7374. // print_r($roleArray);
  7375. $verifyList [$k] ['date'] = "";
  7376. $verifyList [$k] ['opinion'] = "";
  7377. $verifyList [$k] ['status'] = "";
  7378. if (empty ( $verifyStaff )) {
  7379. $verifyList [$k] ['date'] = "";
  7380. $verifyList [$k] ['opinion'] = "";
  7381. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7382. $verifyList [$k] ['status'] = 4;
  7383. $button = 4;
  7384. $flag = false;
  7385. }
  7386. } else {
  7387. foreach ( $verifyStaff as $m => $u ) {
  7388. if ($v [0] == $m) {
  7389. $verifyList [$k] ['date'] = $u ['date'];
  7390. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7391. $verifyList [$k] ['status'] = $u ['status'];
  7392. $flag = false;
  7393. break;
  7394. }
  7395. }
  7396. $endStaffArray = end ( $verifyStaff );
  7397. if (isset ( $endStaffArray ['ROLE'] )) {
  7398. } else {
  7399. $endKey = key ( $verifyStaff );
  7400. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7401. $button = 4;
  7402. $verifyList [$k] ['status'] = 4;
  7403. }
  7404. }
  7405. }
  7406. }
  7407. $rolename ['name'] = '';
  7408. if (! empty ( $roleId )) {
  7409. Doo::loadModel ( 'role' );
  7410. $role = new role ();
  7411. $rolename = $role->getOne ( array (
  7412. 'where' => 'rid=' . $roleId,
  7413. 'asArray' => true
  7414. ) );
  7415. }
  7416. if (! empty ( $verifyStaff ))
  7417. $endStaffArray = end ( $verifyStaff );
  7418. $KOP = false;
  7419. foreach ( $roleArrayCopy as $P => $A ) {
  7420. foreach ( $A as $MKI => $AVL ) {
  7421. if (! empty ( $verifyStaff )) {
  7422. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7423. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7424. $button = 4;
  7425. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7426. }
  7427. foreach ( $verifyStaff as $m => $u ) {
  7428. $AVLFK = $AVL [0] . '_R';
  7429. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7430. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7431. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7432. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7433. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7434. break;
  7435. }
  7436. }
  7437. } else {
  7438. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7439. $button = 4;
  7440. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7441. }
  7442. }
  7443. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7444. $KOP = true;
  7445. }
  7446. }
  7447. foreach ( $roleArrayCopy as $k => $v ) {
  7448. foreach ( $verifyList as $m => $n ) {
  7449. if ($n [0] == $k) {
  7450. array_splice ( $verifyList, $m, 1, $v );
  7451. }
  7452. }
  7453. }
  7454. $receiptList [$key] ['verifyList'] = $verifyList;
  7455. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7456. 'where' => 'sid=' . $value ['staff'],
  7457. 'asArray' => true
  7458. ) );
  7459. $receiptList [$key] ['button'] = $button;
  7460. }
  7461. $mothHtml = "";
  7462. for($i = 1; $i <= 12; $i ++) {
  7463. if ($month == $i)
  7464. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7465. else
  7466. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7467. }
  7468. // 获取审批日志
  7469. Doo::loadModel ( 'receiptLog' );
  7470. $receiptLog = new receiptLog ();
  7471. $rlList = array ();
  7472. $rlInfo = $receiptLog->getOne ( array (
  7473. 'where' => 'rid=' . $rid . ' and status=4',
  7474. 'asArray' => true
  7475. ) );
  7476. $tijdate = $receiptLog->getOne ( array (
  7477. 'where' => 'rid=' . $rid . ' and status=2',
  7478. 'asc' => 'rlid',
  7479. 'asArray' => true
  7480. ) );
  7481. if (! empty ( $rlInfo )) {
  7482. $rlList = $receiptLog->find ( array (
  7483. 'where' => 'rid=' . $rid,
  7484. 'asc' => 'rlid',
  7485. 'asArray' => true
  7486. ) );
  7487. }
  7488. $receiptList [0] ['rlList'] = $rlList;
  7489. $enclosurList = $enclosur->find ( array (
  7490. 'where' => 'rid=' . $rid,
  7491. 'asArray' => true
  7492. ) );
  7493. $enclosurHtml = '';
  7494. foreach ( $enclosurList as $value ) {
  7495. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7496. }
  7497. $data ['enclosurHtml'] = $enclosurHtml;
  7498. $data ['rolename'] = $rolename ['name'];
  7499. $data ['datetij'] = $tijdate ['date'];
  7500. $data ['mothHtml'] = $mothHtml;
  7501. $data ['receiptList'] = $receiptList;
  7502. $data ['receiptApprovalCount'] = count ( $receiptList );
  7503. $data ['year'] = $year;
  7504. $data ['categoryList'] = $categoryList;
  7505. $data ['staffList'] = $staffList;
  7506. $data ['cid'] = $cid;
  7507. $data ['sid'] = $sid;
  7508. $data ['status'] = 0;
  7509. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  7510. $ap = 4;
  7511. } else
  7512. $data ['status'] = $receiptList [0] ['status'];
  7513. if ($receiptList [0] ['status'] == 4) {
  7514. $data ['status'] = 5;
  7515. $ap = 0;
  7516. }
  7517. $data ['ap'] = $ap;
  7518. $data ['memu'] = "receipt";
  7519. $data ['staff'] = $this->staff;
  7520. $data ['receiptMemu'] = 'approval';
  7521. $data ['verifyId'] = $this->verifyId;
  7522. $data ['executeId'] = $this->executeId;
  7523. $this->render ( "/admin/saeaReportListReport", $data );
  7524. }
  7525. function approvalEdi() {
  7526. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7527. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  7528. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7529. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7530. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7531. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  7532. if (empty ( $status ))
  7533. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  7534. $vidList = array ();
  7535. $button = 0;
  7536. Doo::loadModel ( 'verify' );
  7537. Doo::loadModel ( 'receipt' );
  7538. Doo::loadModel ( 'staff' );
  7539. $staff = new staff ();
  7540. $receipt = new receipt ();
  7541. $verify = new verify ();
  7542. Doo::loadModel ( 'L_category' );
  7543. $Lcategory = new L_category ();
  7544. Doo::loadModel ( 'enclosur' );
  7545. $enclosur = new enclosur ();
  7546. // user verify ID
  7547. $verifyDetail = $verify->find ( array (
  7548. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  7549. 'asArray' => true
  7550. ) );
  7551. foreach ( $verifyDetail as $key => $value ) {
  7552. array_push ( $vidList, $value ['vid'] );
  7553. }
  7554. $vid = implode ( ",", $vidList );
  7555. if (empty ( $verifyDetail ))
  7556. $vid = 0;
  7557. $categoryList = $Lcategory->find ( array (
  7558. 'asArray' => true
  7559. ) );
  7560. $staffList = $staff->find ( array (
  7561. 'where' => 'cid=' . $cid,
  7562. 'asArray' => true
  7563. ) );
  7564. $ap = "";
  7565. if ($status == 4) {
  7566. $ap = 4;
  7567. $status = 2;
  7568. }
  7569. // get Receipt By verifyID status 2
  7570. $receiptList = $receipt->find ( array (
  7571. 'where' => 'rid =' . $rid,
  7572. 'desc' => 'rid',
  7573. 'asArray' => true
  7574. ) );
  7575. $Locate = 0;
  7576. $roleId = 0;
  7577. if ($ap == 4)
  7578. $status = 4;
  7579. foreach ( $receiptList as $key => $value ) {
  7580. $receiptList [$key] ['Locate'] = $Locate;
  7581. $Locate ++;
  7582. $receiptList [$key] ['reviseDetail'] = array ();
  7583. if (! empty ( $value ['reviseDetail'] ))
  7584. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  7585. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  7586. $categoryDetil = $Lcategory->getOne ( array (
  7587. 'where' => 'cid=' . $value ['cid'],
  7588. 'asArray' => true
  7589. ) );
  7590. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  7591. // 检测编辑状态
  7592. $verifyList = $verify->getOne ( array (
  7593. 'where' => 'vid=' . $value ['verify'],
  7594. 'asArray' => true
  7595. ) );
  7596. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  7597. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  7598. // print_r($verifyList);
  7599. //
  7600. // if (empty($verifyStaff)){
  7601. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7602. // $verifyList[0]['status']=4;$button=4;
  7603. // }
  7604. //
  7605. // }else{
  7606. //
  7607. // }
  7608. // die;
  7609. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7610. // echo array_search("green",$a);
  7611. //
  7612. Doo::loadModel ( 'role' );
  7613. $role = new role ();
  7614. // print_r($verifyList);
  7615. $flag = true;
  7616. $roleKey = 0;
  7617. $endStaffArray = array ();
  7618. $roleArrayCopy = array ();
  7619. foreach ( $verifyList as $k => $v ) {
  7620. // init verifyStaff
  7621. if ($v [1] == 'ROLE') {
  7622. if (! empty ( $verifyStaff )) {
  7623. $endStaffArray = end ( $verifyStaff );
  7624. if ($v [0] == $endStaffArray ['nextStaff']) {
  7625. $roleId = $v [0];
  7626. }
  7627. }
  7628. $roleVerify = json_decode ( $v [3], true );
  7629. $roleKey = $k;
  7630. $roleArray = array ();
  7631. $rolename = $role->getOne ( array (
  7632. 'where' => 'rid=' . $v [0],
  7633. 'asArray' => true
  7634. ) );
  7635. foreach ( $roleVerify as $o => $p ) {
  7636. $staffID = explode ( '_', $p );
  7637. $staffInfo = $staff->getOne ( array (
  7638. 'where' => 'sid=' . $staffID [0],
  7639. 'asArray' => true
  7640. ) );
  7641. // print_r($staffID);
  7642. $exp = array (
  7643. 0 => $staffInfo ['sid'],
  7644. 1 => $staffID [1],
  7645. 2 => $staffInfo ['avatar'],
  7646. 'date' => '',
  7647. 'date' => '',
  7648. 'opinion' => '',
  7649. 'status' => '',
  7650. 'rolename' => $rolename ['name']
  7651. );
  7652. array_push ( $roleArray, $exp );
  7653. }
  7654. $roleArrayCopy [$v [0]] = $roleArray;
  7655. // $verifyList[$k]['roleArray']=$roleArray;
  7656. }
  7657. // print_r($roleArray);
  7658. $verifyList [$k] ['date'] = "";
  7659. $verifyList [$k] ['opinion'] = "";
  7660. $verifyList [$k] ['status'] = "";
  7661. if (empty ( $verifyStaff )) {
  7662. $verifyList [$k] ['date'] = "";
  7663. $verifyList [$k] ['opinion'] = "";
  7664. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  7665. $verifyList [$k] ['status'] = 4;
  7666. $button = 4;
  7667. $flag = false;
  7668. }
  7669. } else {
  7670. foreach ( $verifyStaff as $m => $u ) {
  7671. if ($v [0] == $m) {
  7672. $verifyList [$k] ['date'] = $u ['date'];
  7673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  7674. $verifyList [$k] ['status'] = $u ['status'];
  7675. $flag = false;
  7676. break;
  7677. }
  7678. }
  7679. $endStaffArray = end ( $verifyStaff );
  7680. if (isset ( $endStaffArray ['ROLE'] )) {
  7681. } else {
  7682. $endKey = key ( $verifyStaff );
  7683. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  7684. $button = 4;
  7685. $verifyList [$k] ['status'] = 4;
  7686. }
  7687. }
  7688. // print_r($endStaffArray);die;
  7689. // if (empty($verifyStaff)){
  7690. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  7691. // $verifyList[$k]['status']=4;$button=4;
  7692. // }
  7693. //
  7694. // }else{
  7695. //
  7696. // }
  7697. // if($flag){//检测可编辑
  7698. // if($v[0]==$this->staff[0]['sid']){
  7699. // $verifyList[$k]['status']=4;$button=4;
  7700. // }
  7701. // }
  7702. }
  7703. }
  7704. $rolename ['name'] = '';
  7705. if (! empty ( $roleId )) {
  7706. Doo::loadModel ( 'role' );
  7707. $role = new role ();
  7708. $rolename = $role->getOne ( array (
  7709. 'where' => 'rid=' . $roleId,
  7710. 'asArray' => true
  7711. ) );
  7712. }
  7713. if (! empty ( $verifyStaff ))
  7714. $endStaffArray = end ( $verifyStaff );
  7715. $KOP = false;
  7716. foreach ( $roleArrayCopy as $P => $A ) {
  7717. foreach ( $A as $MKI => $AVL ) {
  7718. if (! empty ( $verifyStaff )) {
  7719. // &&$rolename['rid']==$endStaffArray['nextStaff']
  7720. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  7721. $button = 4;
  7722. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7723. }
  7724. foreach ( $verifyStaff as $m => $u ) {
  7725. $AVLFK = $AVL [0] . '_R';
  7726. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  7727. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  7728. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  7729. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  7730. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  7731. break;
  7732. }
  7733. }
  7734. } else {
  7735. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  7736. $button = 4;
  7737. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  7738. }
  7739. }
  7740. // $roleArray[$MKI]['rolename']=$rolename['name'];
  7741. $KOP = true;
  7742. }
  7743. }
  7744. // print_r($roleArrayCopy);
  7745. // echo $roleKey;
  7746. foreach ( $roleArrayCopy as $k => $v ) {
  7747. foreach ( $verifyList as $m => $n ) {
  7748. if ($n [0] == $k) {
  7749. array_splice ( $verifyList, $m, 1, $v );
  7750. }
  7751. }
  7752. }
  7753. // if ($KOP)
  7754. // array_splice($verifyList,$roleKey,1,$roleArray);
  7755. // print_r($verifyList);
  7756. $receiptList [$key] ['verifyList'] = $verifyList;
  7757. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  7758. 'where' => 'sid=' . $value ['staff'],
  7759. 'asArray' => true
  7760. ) );
  7761. $receiptList [$key] ['button'] = $button;
  7762. }
  7763. // $data['verifyDetail']=$verifyDetail;
  7764. $mothHtml = "";
  7765. for($i = 1; $i <= 12; $i ++) {
  7766. if ($month == $i)
  7767. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7768. else
  7769. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7770. }
  7771. // 获取审批日志
  7772. Doo::loadModel ( 'receiptLog' );
  7773. $receiptLog = new receiptLog ();
  7774. $rlList = array ();
  7775. $rlInfo = $receiptLog->getOne ( array (
  7776. 'where' => 'rid=' . $rid . ' and status=4',
  7777. 'asArray' => true
  7778. ) );
  7779. $tijdate = $receiptLog->getOne ( array (
  7780. 'where' => 'rid=' . $rid . ' and status=2',
  7781. 'asc' => 'rlid',
  7782. 'asArray' => true
  7783. ) );
  7784. if (! empty ( $rlInfo )) {
  7785. $rlList = $receiptLog->find ( array (
  7786. 'where' => 'rid=' . $rid,
  7787. 'asc' => 'rlid',
  7788. 'asArray' => true
  7789. ) );
  7790. }
  7791. $receiptList [0] ['rlList'] = $rlList;
  7792. $enclosurList = $enclosur->find ( array (
  7793. 'where' => 'rid=' . $rid,
  7794. 'asArray' => true
  7795. ) );
  7796. $enclosurHtml = '';
  7797. foreach ( $enclosurList as $value ) {
  7798. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  7799. }
  7800. $data ['enclosurHtml'] = $enclosurHtml;
  7801. $data ['rolename'] = $rolename ['name'];
  7802. $data ['datetij'] = $tijdate ['date'];
  7803. $data ['mothHtml'] = $mothHtml;
  7804. $data ['receiptList'] = $receiptList;
  7805. $data ['receiptApprovalCount'] = count ( $receiptList );
  7806. $data ['status'] = $status;
  7807. $data ['year'] = $year;
  7808. $data ['categoryList'] = $categoryList;
  7809. $data ['staffList'] = $staffList;
  7810. $data ['cid'] = $cid;
  7811. $data ['sid'] = $sid;
  7812. $data ['ap'] = $ap;
  7813. $data ['memu'] = "receipt";
  7814. $data ['staff'] = $this->staff;
  7815. $data ['receiptMemu'] = 'approval';
  7816. $data ['verifyId'] = $this->verifyId;
  7817. $data ['executeId'] = $this->executeId;
  7818. $this->render ( "/admin/saeaReportListReport", $data );
  7819. }
  7820. function remittanceHky() {
  7821. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7822. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  7823. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  7824. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  7825. $page_size = 15;
  7826. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  7827. Doo::loadModel ( 'receipt' );
  7828. $receipt = new receipt ();
  7829. Doo::loadModel ( 'staff' );
  7830. $staff = new staff ();
  7831. $dateCondition = " and Year(executeDate) =" . $year;
  7832. if ($moth != 'MONTH')
  7833. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  7834. if ($day != 'DAY' && $moth != 'MONTH')
  7835. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  7836. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  7837. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  7838. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  7839. $limit = $pageinfo ['lower'] . ',' . $page_size;
  7840. $dayList = $receipt->find ( array (
  7841. 'select' => 'executeDate,sum(amount) as amount',
  7842. 'where' => $sql,
  7843. 'desc' => 'executeDate',
  7844. 'groupby' => 'executeDate',
  7845. 'limit' => $limit,
  7846. 'asArray' => true
  7847. ) );
  7848. // print_r($dayList);
  7849. foreach ( $dayList as $key => $value ) {
  7850. $remitString = "";
  7851. $receiptList = $receipt->find ( array (
  7852. 'select' => 'rid,executeDate,amount,staff,cid',
  7853. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  7854. 'desc' => 'executeDate',
  7855. 'asArray' => true
  7856. ) );
  7857. foreach ( $receiptList as $k => $v ) {
  7858. $sinfo = $staff->getOne ( array (
  7859. 'select' => 'username,category',
  7860. 'where' => ' sid=' . $v ['staff'],
  7861. 'asArray' => true
  7862. ) );
  7863. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  7864. }
  7865. $dayList [$key] ['staff'] = $remitString;
  7866. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  7867. }
  7868. // print_r($dayList);
  7869. $mothHtml = "";
  7870. for($i = 1; $i <= 12; $i ++) {
  7871. if ($moth == $i)
  7872. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7873. else
  7874. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7875. }
  7876. $dayHtml = "";
  7877. if ($day != "DAY" || $moth != "MONTH") {
  7878. for($i = 1; $i <= 31; $i ++) {
  7879. if ($day == $i)
  7880. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  7881. else
  7882. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  7883. }
  7884. }
  7885. $dateHtml = "";
  7886. $now = date ( "Y" );
  7887. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7888. if ($YEARD <= $now) {
  7889. $dateHtml .= '<option ';
  7890. if ($year == $YEARD) {
  7891. $dateHtml .= 'selected ';
  7892. }
  7893. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7894. }
  7895. }
  7896. $data ['dateHtml'] = $dateHtml;
  7897. $data ['page'] = $pageinfo;
  7898. $data ['year'] = $year;
  7899. $data ['moth'] = $moth;
  7900. $data ['day'] = $day;
  7901. $data ['get'] = $get;
  7902. $data ['dayHtml'] = $dayHtml;
  7903. $data ['mothHtml'] = $mothHtml;
  7904. $data ['receiptList'] = $dayList;
  7905. $data ['memu'] = "receipt";
  7906. $data ['staff'] = $this->staff;
  7907. $data ['receiptMemu'] = 'remittanceHky';
  7908. $data ['verifyId'] = $this->verifyId;
  7909. $data ['executeId'] = $this->executeId;
  7910. $this->render ( "/admin/remittanceHky", $data );
  7911. }
  7912. function remittancep() {
  7913. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  7914. Doo::loadModel ( 'receipt' );
  7915. $receipt = new receipt ();
  7916. Doo::loadModel ( 'staff' );
  7917. $staff = new staff ();
  7918. Doo::loadClass ( 'XDeode' );
  7919. $XDeode = new XDeode ( 5 );
  7920. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  7921. $rplist = $receipt->find ( array (
  7922. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7923. 'asArray' => true
  7924. ) );
  7925. $dayList = $receipt->find ( array (
  7926. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  7927. 'desc' => 'executeDate',
  7928. 'groupby' => 'staff',
  7929. 'asArray' => true
  7930. ) );
  7931. $html = '';
  7932. foreach ( $dayList as $key => $value ) {
  7933. $sinfo = $staff->getOne ( array (
  7934. 'select' => 'username,category',
  7935. 'where' => ' sid=' . $value ['staff'],
  7936. 'asArray' => true
  7937. ) );
  7938. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  7939. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  7940. $au = 0;
  7941. foreach ( $rplist as $k => $v ) {
  7942. if ($value ['staff'] == $v ['staff']) {
  7943. $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>';
  7944. $au += $v ['amount'];
  7945. }
  7946. }
  7947. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  7948. }
  7949. $data ['html'] = $html;
  7950. $data ['memu'] = "receipt";
  7951. $data ['staff'] = $this->staff;
  7952. $data ['receiptMemu'] = 'remittanceHky';
  7953. $data ['verifyId'] = $this->verifyId;
  7954. $data ['executeId'] = $this->executeId;
  7955. $this->render ( "/admin/remittancep", $data );
  7956. }
  7957. function ajaxGetReceiptDetails() {
  7958. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  7959. Doo::loadClass ( 'XDeode' );
  7960. $XDeode = new XDeode ( 5 );
  7961. $rid = $XDeode->decode ( $rid );
  7962. if (empty ( $rid )) {
  7963. echo json_encode ( array (
  7964. 'status' => 2,
  7965. 'msg' => 'illegal request'
  7966. ) );
  7967. die ();
  7968. }
  7969. Doo::loadModel ( 'receipt' );
  7970. $receipt = new receipt ();
  7971. Doo::loadModel ( 'staff' );
  7972. $staff = new staff ();
  7973. $rinfo = $receipt->getOne ( array (
  7974. 'where' => 'rid= ' . $rid,
  7975. 'asArray' => true
  7976. ) );
  7977. $sinfo = $staff->getOne ( array (
  7978. 'select' => 'username,category',
  7979. 'where' => ' sid=' . $rinfo ['staff'],
  7980. 'asArray' => true
  7981. ) );
  7982. $rinfo ['reviseDetail'] = array ();
  7983. if (! empty ( $rinfo ['reviseDetail'] ))
  7984. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  7985. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  7986. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  7987. $rinfo ['category'] = $sinfo ['category'];
  7988. $verifyStaff = array ();
  7989. if (! empty ( $rinfo ['verifyStaff'] ))
  7990. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  7991. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  7992. $rinfo ['relust'] = $relust;
  7993. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  7994. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  7995. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  7996. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  7997. // 费用执行人相关数据
  7998. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  7999. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  8000. foreach ( $executeCopy as $k => $v ) {
  8001. $executeCopy [$k] ['date'] = '';
  8002. $executeCopy [$k] ['opinion'] = '';
  8003. $executeCopy [$k] ['status'] = '';
  8004. if (! empty ( $executeStaff ))
  8005. foreach ( $executeStaff as $m => $u ) {
  8006. if ($v [0] == $m) {
  8007. $executeCopy [$k] ['date'] = $u ['date'];
  8008. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  8009. $executeCopy [$k] ['status'] = $u ['status'];
  8010. break;
  8011. }
  8012. }
  8013. }
  8014. $rinfo ['executeCopy'] = $executeCopy;
  8015. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  8016. if ($rinfo ['Rtype'] == 1) { // 借款费用
  8017. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8018. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  8019. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  8020. $html .= '<tr><th>' . $value ['name'] . '</th>
  8021. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8022. }
  8023. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8024. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8025. <tr><th class="taC" colspan="2">费用说明</th>
  8026. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8027. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8028. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  8029. </tbody></table>';
  8030. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  8031. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8032. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8033. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8034. $html .= '<tr><th>' . $value ['name'] . '</th>
  8035. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8036. }
  8037. $html .= '<tr><th class="taR">合计</th>
  8038. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8039. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8040. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8041. $html .= '<tr><th>' . $value ['name'] . '</th>
  8042. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8043. }
  8044. $html .= '<tr><th class="taR">合计</th>
  8045. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8046. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8047. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8048. $html .= '<tr><th>' . $value ['name'] . '</th>
  8049. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8050. }
  8051. $html .= '<tr><th class="taR">合计</th>
  8052. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8053. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8054. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8055. $html .= '<tr><th>' . $value ['name'] . '</th>
  8056. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8057. }
  8058. $html .= '<tr><th class="taR">合计</th>
  8059. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8060. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8061. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8062. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8063. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8064. }
  8065. $html .= '<tr><th class="taR">合计</th>
  8066. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8067. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8068. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8069. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8070. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8071. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8072. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8073. <tr';
  8074. if ($rinfo ['relust'] >= 0) {
  8075. $html .= 'class="success"';
  8076. } else {
  8077. $html .= 'class="error"';
  8078. }
  8079. $html .= '><td class="taR"><b>借款结余</b></td>
  8080. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  8081. </tbody></table>
  8082. ';
  8083. }
  8084. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  8085. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  8086. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  8087. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8088. $html .= '<tr><th>' . $value ['name'] . '</th>
  8089. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8090. }
  8091. $html .= '<tr><th class="taR">合计</th>
  8092. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8093. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8094. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8095. <tr><th class="taC" colspan="2">费用说明</th>
  8096. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8097. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  8098. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  8099. </tbody></table>';
  8100. } else {
  8101. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  8102. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  8103. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  8104. $html .= '<tr><th>' . $value ['name'] . '</th>
  8105. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8106. }
  8107. $html .= '<tr><th class="taR">合计</th>
  8108. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  8109. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  8110. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  8111. $html .= '<tr><th>' . $value ['name'] . '</th>
  8112. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8113. }
  8114. $html .= '<tr><th class="taR">合计</th>
  8115. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  8116. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  8117. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  8118. $html .= '<tr><th>' . $value ['name'] . '</th>
  8119. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8120. }
  8121. $html .= '<tr><th class="taR">合计</th>
  8122. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  8123. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  8124. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  8125. $html .= '<tr><th>' . $value ['name'] . '</th>
  8126. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  8127. }
  8128. $html .= '<tr><th class="taR">合计</th>
  8129. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  8130. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  8131. foreach ( $rinfo ['reviseDetail'] as $value ) {
  8132. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  8133. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  8134. }
  8135. $html .= '<tr><th class="taR">合计</th>
  8136. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  8137. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  8138. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  8139. <tr><th class="taC" colspan="2">报销说明</th></tr>
  8140. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  8141. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  8142. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  8143. $html .= '</tbody></table>';
  8144. /*
  8145. * <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>
  8146. */
  8147. }
  8148. // print_r($verifyStaff);die;
  8149. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  8150. foreach ( $verifyStaff as $key => $value ) {
  8151. $key = trim ( strtr ( $key, '_R', ' ' ) );
  8152. $sinfo = $staff->getOne ( array (
  8153. 'select' => 'username',
  8154. 'where' => ' sid=' . $key,
  8155. 'asArray' => true
  8156. ) );
  8157. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8158. }
  8159. $html .= '</tbody></table>';
  8160. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  8161. foreach ( $rinfo ['executeCopy'] as $value ) {
  8162. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  8163. }
  8164. $html .= '</tbody></table>';
  8165. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  8166. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  8167. </tr></table>';
  8168. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  8169. echo json_encode ( array (
  8170. 'status' => 1,
  8171. 'html' => $html
  8172. ) );
  8173. die ();
  8174. }
  8175. /**
  8176. * 删除附件
  8177. */
  8178. function ajaxRemEnclousur() {
  8179. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  8180. if (empty ( $key ))
  8181. echo json_encode ( array (
  8182. 'status' => 2
  8183. ) );
  8184. Doo::loadModel ( 'enclosur' );
  8185. $enclosur = new enclosur ();
  8186. $enclosur->delEnclosurByEid ( $key );
  8187. echo json_encode ( array (
  8188. 'status' => 1
  8189. ) );
  8190. }
  8191. function remittance() {
  8192. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  8193. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8194. Doo::loadModel ( 'receipt' );
  8195. $receipt = new receipt ();
  8196. Doo::loadModel ( 'staff' );
  8197. $staff = new staff ();
  8198. $dateCondition = " and Year(pastDate) =" . $year;
  8199. if (! empty ( $month ))
  8200. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  8201. // get Receipt By verifyID status 1
  8202. $receiptList = $receipt->find ( array (
  8203. 'select' => 'sum(sum) as sum,staff,pastDate',
  8204. 'where' => ' status=1' . $dateCondition,
  8205. 'desc' => 'pastDate',
  8206. 'groupby' => 'staff,pastDate',
  8207. 'asArray' => true
  8208. ) );
  8209. $dateList = $receipt->find ( array (
  8210. 'select' => 'pastDate,verifyStaff',
  8211. 'where' => ' status=1' . $dateCondition,
  8212. 'desc' => 'pastDate',
  8213. 'groupby' => 'pastDate',
  8214. 'asArray' => true
  8215. ) );
  8216. $dataList = array ();
  8217. foreach ( $dateList as $d => $a ) {
  8218. $dataList [$a ['pastDate']] = array ();
  8219. $daySum = 0;
  8220. foreach ( $receiptList as $key => $value ) {
  8221. if ($a ['pastDate'] == $value ['pastDate']) {
  8222. $oderList = $receipt->find ( array (
  8223. 'select' => 'receiptOrder',
  8224. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  8225. 'asArray' => true
  8226. ) );
  8227. $list = array ();
  8228. $html = "";
  8229. foreach ( $oderList as $v ) {
  8230. array_push ( $list, $v ['receiptOrder'] );
  8231. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  8232. }
  8233. $receiptList [$key] ['receiptOrder'] = $html;
  8234. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  8235. $sinfo = $staff->getOne ( array (
  8236. 'select' => 'username ',
  8237. 'where' => ' sid=' . $value ['staff'],
  8238. 'asArray' => true
  8239. ) );
  8240. $receiptList [$key] ['username'] = $sinfo ['username'];
  8241. $daySum += $value ['sum'];
  8242. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  8243. }
  8244. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  8245. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  8246. }
  8247. }
  8248. // print_r($dataList);
  8249. $data ['dataList'] = $dataList;
  8250. $mothHtml = "";
  8251. for($i = 1; $i <= 12; $i ++) {
  8252. if ($month == $i)
  8253. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  8254. else
  8255. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  8256. }
  8257. $data ['year'] = $year;
  8258. $data ['mothHtml'] = $mothHtml;
  8259. $data ['memu'] = "receipt";
  8260. $data ['staff'] = $this->staff;
  8261. $data ['receiptMemu'] = 'approval';
  8262. $data ['verifyId'] = $this->verifyId;
  8263. $data ['executeId'] = $this->executeId;
  8264. $this->render ( "/admin/saeaReportListPay", $data );
  8265. }
  8266. /**
  8267. * 金额调整,提高稳定性
  8268. * @return string
  8269. */
  8270. function revocationAdjustment() {
  8271. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  8272. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  8273. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  8274. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  8275. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  8276. Doo::loadClass ( 'XDeode' );
  8277. $XDeode = new XDeode ( 5 );
  8278. Doo::loadModel ( 'receipt' );
  8279. $receipt = new receipt ();
  8280. $sid = $XDeode->decode ( $sidKey );
  8281. $rid = $XDeode->decode ( $ridKey );
  8282. $reviseKey = $XDeode->decode ( $reviseKey );
  8283. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  8284. die ( 'illegal request' );
  8285. $receiptDetail = $receipt->getOne ( array (
  8286. 'where' => 'rid=' . $rid,
  8287. 'asArray' => true
  8288. ) );
  8289. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  8290. die ( 'illegal request' );
  8291. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8292. if (! isset ( $reviseDetail [$reviseKey] ))
  8293. die ( 'illegal request' );
  8294. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  8295. unset ( $reviseDetail [$reviseKey] );
  8296. $revisePrice = 0;
  8297. foreach ( $reviseDetail as $key => $value ) {
  8298. $revisePrice += $value ['price'];
  8299. }
  8300. $reviseDetailString = json_encode ( $reviseDetail );
  8301. $receipt->reviseDetail = $reviseDetailString;
  8302. $receipt->sum = $receiptDetail ['sum'] - $price;
  8303. $receipt->revisePrice = $revisePrice;
  8304. $receipt->update ( array (
  8305. 'where' => 'rid=' . $rid
  8306. ) );
  8307. return '/receiptburEdi/' . $rid;
  8308. } else
  8309. die ( 'illegal request2' );
  8310. }
  8311. function updateApprovalReceipt() {
  8312. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8313. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  8314. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8315. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  8316. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  8317. if (! empty ( $rid )) {
  8318. Doo::loadModel ( "verify" );
  8319. $verify = new verify ();
  8320. Doo::loadModel ( "receiptDetail" );
  8321. $receiptDetailObj = new receiptDetail ();
  8322. Doo::loadModel ( "itemStatistics" );
  8323. Doo::loadModel ( "statistics" );
  8324. $statistics = new statistics ();
  8325. $itemStatistics = new itemStatistics ();
  8326. Doo::loadModel ( "receipt" );
  8327. $receipt = new receipt ();
  8328. $receiptDetail = $receipt->getOne ( array (
  8329. 'where' => 'rid=' . $rid . ' and status=2 ',
  8330. 'asArray' => true
  8331. ) );
  8332. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  8333. $nsflag = true;
  8334. foreach ( $nslist as $value ) {
  8335. if ($value == $this->staff ['0'] ['sid']) {
  8336. $nsflag = false;
  8337. break;
  8338. }
  8339. }
  8340. if (empty ( $receiptDetail ) || $nsflag)
  8341. return "/approvalExpenses/pendApproval";
  8342. $verifyDetail = $verify->getOne ( array (
  8343. 'where' => ' vid =' . $receiptDetail ['verify'],
  8344. 'asArray' => true
  8345. ) );
  8346. $verifyString = $verifyDetail ['staff'];
  8347. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  8348. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  8349. if (empty ( $opinion )) {
  8350. if ($status == 3)
  8351. $opinion = "终止";
  8352. else
  8353. $opinion = "同意支付";
  8354. }
  8355. $nowStaff = 0;
  8356. $nowStaffList = array ();
  8357. if (empty ( $verifyStaff )) {
  8358. // 还需加入是否已经进入角色审批
  8359. if ($verifyDetail [0] [1] == 'ROLE') {
  8360. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  8361. foreach ( $vStaffString as $key => $value ) {
  8362. $staffK = explode ( "_", $value );
  8363. if ($staffK [0] != $this->staff [0] ['sid'])
  8364. array_push ( $nowStaffList, $staffK [0] );
  8365. }
  8366. // print_r($verifyDetail);
  8367. // die;
  8368. if (! empty ( $nowStaffList )) {
  8369. $nowStaff = implode ( ',', $nowStaffList );
  8370. $verifyStaff = array (
  8371. $this->staff [0] ['sid'] . "_R" => array (
  8372. 'date' => date ( 'Y-m-d' ),
  8373. 'opinion' => $opinion,
  8374. 'status' => $status,
  8375. 'nextStaff' => $verifyDetail [0] [0],
  8376. 'ROLE' => 1
  8377. )
  8378. );
  8379. } else {
  8380. $nowStaff = $verifyDetail [1] [0];
  8381. $verifyStaff = array (
  8382. $this->staff [0] ['sid'] . "_R" => array (
  8383. 'date' => date ( 'Y-m-d' ),
  8384. 'opinion' => $opinion,
  8385. 'status' => $status,
  8386. 'nextStaff' => $verifyDetail [1] [0]
  8387. )
  8388. );
  8389. }
  8390. } else {
  8391. if ($verifyDetail [1] [1] == 'ROLE') {
  8392. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  8393. // echo "dd";
  8394. foreach ( $vStaffString as $key => $value ) {
  8395. $staffK = explode ( "_", $value );
  8396. array_push ( $nowStaffList, $staffK [0] );
  8397. }
  8398. $nowStaff = implode ( ',', $nowStaffList );
  8399. $verifyStaff = array (
  8400. $this->staff [0] ['sid'] => array (
  8401. 'date' => date ( 'Y-m-d' ),
  8402. 'opinion' => $opinion,
  8403. 'status' => $status,
  8404. 'nextStaff' => $verifyDetail [1] [0],
  8405. 'ROLE' => 1
  8406. )
  8407. );
  8408. } else {
  8409. $nowStaff = $verifyDetail [1] [0];
  8410. $verifyStaff = array (
  8411. $this->staff [0] ['sid'] => array (
  8412. 'date' => date ( 'Y-m-d' ),
  8413. 'opinion' => $opinion,
  8414. 'status' => $status,
  8415. 'nextStaff' => $verifyDetail [1] [0]
  8416. )
  8417. );
  8418. }
  8419. }
  8420. if ($status == 3)
  8421. $verifyStaff = array (
  8422. 'final' => $status,
  8423. $this->staff [0] ['sid'] => array (
  8424. 'date' => date ( 'Y-m-d' ),
  8425. 'opinion' => $opinion,
  8426. 'status' => $status
  8427. )
  8428. );
  8429. $vStaffString = json_encode ( $verifyStaff );
  8430. $receipt->nowStaff = $nowStaff;
  8431. $receipt->verifyStaff = $vStaffString;
  8432. } else {
  8433. $VS = end ( $verifyStaff );
  8434. // 非角色审批
  8435. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  8436. $nextStaff = 0;
  8437. $roleSTF = false;
  8438. foreach ( $verifyDetail as $key => $value ) {
  8439. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  8440. if (isset ( $verifyDetail [$key + 1] )) {
  8441. $nextStaff = $verifyDetail [$key + 1] [0];
  8442. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  8443. $roleSTF = true;
  8444. }
  8445. break;
  8446. }
  8447. }
  8448. if (! $roleSTF) {
  8449. $nowStaff = $nextStaff;
  8450. $verifyStaff [$this->staff [0] ['sid']] = array (
  8451. 'date' => date ( 'Y-m-d' ),
  8452. 'opinion' => $opinion,
  8453. 'status' => $status,
  8454. 'nextStaff' => $nextStaff
  8455. );
  8456. } else {
  8457. // 获取角色下的所有用户ID
  8458. $nowStaffList = array ();
  8459. foreach ( $verifyDetail as $vfk ) {
  8460. if ($vfk [1] == 'ROLE') {
  8461. $vStaffString = json_decode ( $vfk [3] );
  8462. foreach ( $vStaffString as $key => $value ) {
  8463. $staffK = explode ( "_", $value );
  8464. array_push ( $nowStaffList, $staffK [0] );
  8465. }
  8466. }
  8467. }
  8468. $nowStaff = implode ( ',', $nowStaffList );
  8469. $verifyStaff [$this->staff [0] ['sid']] = array (
  8470. 'date' => date ( 'Y-m-d' ),
  8471. 'opinion' => $opinion,
  8472. 'status' => $status,
  8473. 'nextStaff' => $nextStaff,
  8474. 'ROLE' => 0
  8475. );
  8476. }
  8477. if ($status == 3) {
  8478. $verifyStaff ['final'] = $status;
  8479. $verifyStaff [$this->staff [0] ['sid']] = array (
  8480. 'date' => date ( 'Y-m-d' ),
  8481. 'opinion' => $opinion,
  8482. 'status' => $status
  8483. );
  8484. }
  8485. $vStaffString = json_encode ( $verifyStaff );
  8486. $receipt->nowStaff = $nowStaff;
  8487. $receipt->verifyStaff = $vStaffString;
  8488. }
  8489. // 角色审批
  8490. if (isset ( $VS ['ROLE'] )) {
  8491. // 找出角色人 当前审批角色组
  8492. $verifyJSStaff = array ();
  8493. $nowStaffList2 = array ();
  8494. foreach ( $verifyDetail as $key => $value ) {
  8495. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  8496. $verifyJSStaff = json_decode ( $value [3] );
  8497. foreach ( $verifyJSStaff as $m ) {
  8498. $staffK = explode ( "_", $m );
  8499. array_push ( $nowStaffList2, $staffK [0] );
  8500. }
  8501. // print_r($nowStaffList2);
  8502. }
  8503. }
  8504. $RoleVerifyStaff = array ();
  8505. foreach ( $verifyStaff as $key => $value ) {
  8506. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  8507. foreach ( $nowStaffList2 as $m ) {
  8508. if ($key == $m . "_R")
  8509. $RoleVerifyStaff [$key] = $value;
  8510. }
  8511. }
  8512. }
  8513. // print_r($verifyStaff);
  8514. // print_r($nowStaffList2);
  8515. // print_r($RoleVerifyStaff);
  8516. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  8517. // print_r($verifyJSStaff);
  8518. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  8519. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  8520. // 下一个审批人ID
  8521. $nextStaff = 0;
  8522. $falg = false;
  8523. foreach ( $verifyDetail as $key => $value ) {
  8524. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  8525. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  8526. $falg = true;
  8527. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  8528. $nowStaffList = array ();
  8529. foreach ( $vStaffString as $v ) {
  8530. $staffK = explode ( "_", $v );
  8531. array_push ( $nowStaffList, $staffK [0] );
  8532. }
  8533. $nowStaff = implode ( ',', $nowStaffList );
  8534. $nextStaff = $verifyDetail [$key + 1] [0];
  8535. } elseif (isset ( $verifyDetail [$key + 1] )) {
  8536. $nextStaff = $verifyDetail [$key + 1] [0];
  8537. $nowStaff = $nextStaff;
  8538. } else
  8539. $nowStaff = '';
  8540. break;
  8541. }
  8542. }
  8543. if ($falg)
  8544. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8545. 'date' => date ( 'Y-m-d' ),
  8546. 'opinion' => $opinion,
  8547. 'status' => $status,
  8548. 'nextStaff' => $nextStaff,
  8549. 'ROLE' => 1
  8550. );
  8551. else
  8552. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8553. 'date' => date ( 'Y-m-d' ),
  8554. 'opinion' => $opinion,
  8555. 'status' => $status,
  8556. 'nextStaff' => $nextStaff
  8557. );
  8558. // print_r($verifyStaff);
  8559. // echo $nowStaff;die;
  8560. } else { // 进入下一个角色或者审批人
  8561. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  8562. //
  8563. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  8564. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  8565. 'date' => date ( 'Y-m-d' ),
  8566. 'opinion' => $opinion,
  8567. 'status' => $status,
  8568. 'nextStaff' => $VS ['nextStaff'],
  8569. 'ROLE' => 1
  8570. );
  8571. // print_r($verifyStaff);
  8572. // die;
  8573. }
  8574. if ($status == 3) {
  8575. $verifyStaff ['final'] = $status;
  8576. $verifyStaff [$this->staff [0] ['sid']] = array (
  8577. 'date' => date ( 'Y-m-d' ),
  8578. 'opinion' => $opinion,
  8579. 'status' => $status
  8580. );
  8581. }
  8582. $vStaffString = json_encode ( $verifyStaff );
  8583. $receipt->verifyStaff = $vStaffString;
  8584. $receipt->nowStaff = $nowStaff;
  8585. // die;
  8586. // }
  8587. // print_r($verifyStaff);
  8588. // die;
  8589. }
  8590. // print_r($verifyStaff);die;
  8591. }
  8592. // print_r($verifyDetail);
  8593. $roleKey = 0;
  8594. $roleId = 0;
  8595. $verifyDetailCopy = array ();
  8596. foreach ( $verifyDetail as $k => $v ) {
  8597. if ($v [1] == 'ROLE') {
  8598. $roleId = $v [0];
  8599. $roleVerify = json_decode ( $v [3], true );
  8600. $roleKey = $k;
  8601. $roleArray = array ();
  8602. foreach ( $roleVerify as $o => $p ) {
  8603. $staffID = explode ( '_', $p );
  8604. $exp = array (
  8605. 0 => $staffID [0],
  8606. 1 => $staffID [1]
  8607. );
  8608. array_push ( $roleArray, $exp );
  8609. }
  8610. $verifyDetailCopy [$v [0]] = $roleArray;
  8611. }
  8612. }
  8613. // print_r($verifyDetail);
  8614. foreach ( $verifyDetailCopy as $k => $v ) {
  8615. foreach ( $verifyDetail as $m => $n ) {
  8616. if ($n [0] == $k) {
  8617. array_splice ( $verifyDetail, $m, 1, $v );
  8618. }
  8619. }
  8620. }
  8621. // die;
  8622. // if (!empty($roleArray))
  8623. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  8624. // echo $roleId;
  8625. // print_r($verifyStaff);
  8626. // print_r($verifyDetail);
  8627. // die;
  8628. Doo::loadModel ( "receiptLog" );
  8629. $receiptLog = new receiptLog ();
  8630. // 审批日志
  8631. if (! isset ( $verifyStaff ['final'] )) {
  8632. if (! empty ( $roleId )) {
  8633. Doo::loadModel ( "role" );
  8634. $role = new role ();
  8635. $roleInfo = $role->getOne ( array (
  8636. 'where' => 'rid=' . $roleId,
  8637. 'asArray' => true
  8638. ) );
  8639. $receiptLog->rolename = $roleInfo ['name'];
  8640. }
  8641. $receiptLog->username = $this->staff [0] ['username'];
  8642. $receiptLog->uid = $this->staff [0] ['sid'];
  8643. $receiptLog->date = date ( "Y-m-d" );
  8644. $receiptLog->opinion = $opinion;
  8645. $receiptLog->img = $this->staff [0] ['avatar'];
  8646. $receiptLog->status = 1;
  8647. $receiptLog->rid = $rid;
  8648. $receiptLog->insert ();
  8649. }
  8650. if (isset ( $verifyStaff ['final'] )) { // rDetail
  8651. $receipt->verifyBreakup = $verifyString;
  8652. $receipt->status = 3;
  8653. $receiptDetailObj->status = 3;
  8654. $receiptDetailObj->update ( array (
  8655. 'where' => 'rid=' . $rid
  8656. ) );
  8657. if (! empty ( $roleId )) {
  8658. Doo::loadModel ( "role" );
  8659. $role = new role ();
  8660. $roleInfo = $role->getOne ( array (
  8661. 'where' => 'rid=' . $roleId,
  8662. 'asArray' => true
  8663. ) );
  8664. $receiptLog->rolename = $roleInfo ['name'];
  8665. }
  8666. $receiptLog->username = $this->staff [0] ['username'];
  8667. $receiptLog->uid = $this->staff [0] ['sid'];
  8668. $receiptLog->date = date ( "Y-m-d" );
  8669. $receiptLog->opinion = $opinion;
  8670. $receiptLog->img = $this->staff [0] ['avatar'];
  8671. $receiptLog->status = 3;
  8672. $receiptLog->rid = $rid;
  8673. $receiptLog->insert ();
  8674. // 微信企业号通知
  8675. $this->setWXMsg ( $rid, 3 );
  8676. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  8677. $receipt->status = 1;
  8678. $reviseSum = 0;
  8679. $receipt->verifyBreakup = $verifyString;
  8680. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  8681. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  8682. foreach ( $reviseDetail as $key => $value ) {
  8683. $receiptDetailObj = new receiptDetail ();
  8684. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8685. $receiptDetailObj->item = $value ['description'];
  8686. $receiptDetailObj->itemCategory = "报销金额调整";
  8687. $receiptDetailObj->price = $value ['price'];
  8688. $receiptDetailObj->date = $receiptDetail ['date'];
  8689. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  8690. $receiptDetailObj->rid = $rid;
  8691. $receiptDetailObj->status = 1;
  8692. $receiptDetailObj->insert ();
  8693. $reviseSum += $value ['price'];
  8694. }
  8695. $itemStatistics = new itemStatistics ();
  8696. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8697. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8698. $itemStatistics->price = $reviseSum;
  8699. $itemStatistics->itemCategory = "报销金额调整";
  8700. $itemStatistics->date = $receiptDetail ['date'];
  8701. $itemStatistics->insert ();
  8702. }
  8703. $receiptDetailObj = new receiptDetail ();
  8704. $receiptDetailObj->status = 1;
  8705. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  8706. $receiptDetailObj->update ( array (
  8707. 'where' => 'rid=' . $rid
  8708. ) );
  8709. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8710. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8711. $stat = $statistics->getOne ( array (
  8712. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  8713. 'asArray' => true
  8714. ) );
  8715. if (empty ( $stat )) {
  8716. $statistics->date = $receiptDetail ['date'];
  8717. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  8718. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  8719. $statistics->agPrice = $receiptDetail ['sum'];
  8720. $statistics->rePrice = $reviseSum;
  8721. $statistics->insert ();
  8722. } else {
  8723. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  8724. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  8725. $statistics->update ( array (
  8726. 'where' => 'sid=' . $stat ['sid']
  8727. ) );
  8728. }
  8729. $dateArray = explode ( "-", $receiptDetail ['date'] );
  8730. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  8731. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  8732. foreach ( $accountItem ['cSum'] as $key => $value ) {
  8733. if ($key == "agencySum") {
  8734. $iStatistics = $itemStatistics->getOne ( array (
  8735. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  8736. 'asArray' => true
  8737. ) );
  8738. if (empty ( $iStatistics )) {
  8739. $itemStatistics->cid = $receiptDetail ['cid'];
  8740. ;
  8741. $itemStatistics->staff = $receiptDetail ['staff'];
  8742. $itemStatistics->price = $value;
  8743. $itemStatistics->itemCategory = $this->AGENCY;
  8744. $itemStatistics->date = $receiptDetail ['date'];
  8745. $itemStatistics->insert ();
  8746. } else {
  8747. if (! empty ( $value )) {
  8748. $itemStatistics->price = $value + $iStatistics ['price'];
  8749. $itemStatistics->update ( array (
  8750. 'where' => 'sid=' . $iStatistics ['sid']
  8751. ) );
  8752. }
  8753. }
  8754. } elseif ($key == "travelSum") {
  8755. $iStatistics = $itemStatistics->getOne ( array (
  8756. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  8757. 'asArray' => true
  8758. ) );
  8759. if (empty ( $iStatistics )) {
  8760. $itemStatistics->cid = $receiptDetail ['cid'];
  8761. $itemStatistics->staff = $receiptDetail ['staff'];
  8762. $itemStatistics->price = $value;
  8763. $itemStatistics->itemCategory = $this->TRAVEL;
  8764. $itemStatistics->date = $receiptDetail ['date'];
  8765. $itemStatistics->insert ();
  8766. } else {
  8767. if (! empty ( $value )) {
  8768. $itemStatistics->price = $value + $iStatistics ['price'];
  8769. $itemStatistics->update ( array (
  8770. 'where' => 'sid=' . $iStatistics ['sid']
  8771. ) );
  8772. }
  8773. }
  8774. } elseif ($key == "trainSum") {
  8775. $iStatistics = $itemStatistics->getOne ( array (
  8776. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  8777. 'asArray' => true
  8778. ) );
  8779. if (empty ( $iStatistics )) {
  8780. $itemStatistics->cid = $receiptDetail ['cid'];
  8781. $itemStatistics->staff = $receiptDetail ['staff'];
  8782. $itemStatistics->price = $value;
  8783. $itemStatistics->itemCategory = $this->TRAIN;
  8784. $itemStatistics->date = $receiptDetail ['date'];
  8785. $itemStatistics->insert ();
  8786. } else {
  8787. if (! empty ( $value )) {
  8788. $itemStatistics->price = $value + $iStatistics ['price'];
  8789. $itemStatistics->update ( array (
  8790. 'where' => 'sid=' . $iStatistics ['sid']
  8791. ) );
  8792. }
  8793. }
  8794. } elseif ($key == "otherSum") {
  8795. $iStatistics = $itemStatistics->getOne ( array (
  8796. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  8797. 'asArray' => true
  8798. ) );
  8799. if (empty ( $iStatistics )) {
  8800. $itemStatistics->cid = $receiptDetail ['cid'];
  8801. $itemStatistics->staff = $receiptDetail ['staff'];
  8802. $itemStatistics->price = $value;
  8803. $itemStatistics->itemCategory = $this->OTHER;
  8804. $itemStatistics->date = $receiptDetail ['date'];
  8805. $itemStatistics->insert ();
  8806. } else {
  8807. if (! empty ( $value )) {
  8808. $itemStatistics->price = $value + $iStatistics ['price'];
  8809. $itemStatistics->update ( array (
  8810. 'where' => 'sid=' . $iStatistics ['sid']
  8811. ) );
  8812. }
  8813. }
  8814. }
  8815. }
  8816. $receipt->pastDate = date ( "Y-m-d" );
  8817. // 微信企业号通知
  8818. $this->setWXMsg ( $rid, 1 );
  8819. }
  8820. $receipt->amount = $amount;
  8821. $receipt->update ( array (
  8822. 'where' => ' rid = ' . $rid
  8823. ) );
  8824. // 进入下一条审批费用新加需求
  8825. $vidList = array ();
  8826. $verifyDetail = $verify->find ( array (
  8827. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  8828. 'asArray' => true
  8829. ) );
  8830. foreach ( $verifyDetail as $key => $value ) {
  8831. array_push ( $vidList, $value ['vid'] );
  8832. }
  8833. $vid = implode ( ",", $vidList );
  8834. if (empty ( $verifyDetail ))
  8835. $vid = 0;
  8836. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  8837. $receipt = new receipt ();
  8838. $rd = $receipt->getOne ( array (
  8839. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ') and Rtype!=3',
  8840. 'asc' => 'rid',
  8841. 'asArray' => true
  8842. ) );
  8843. if (empty ( $rd )) {
  8844. return '/approvalExpenses/pendApproval';
  8845. }
  8846. if ($rd ['Rtype'] == 1) {
  8847. if ($rd ['isBK'] == 1) {
  8848. return '/receiptburEdi/' . $rd ['rid'];
  8849. } else {
  8850. return '/expensesEdi/' . $rd ['rid'];
  8851. }
  8852. } elseif ($rd ['Rtype'] == 2) {
  8853. return '/remitApproval/' . $rd ['rid'];
  8854. } else {
  8855. return '/receiptburEdi/' . $rd ['rid'];
  8856. }
  8857. // return "/approvalExpenses/pendApproval";
  8858. }
  8859. }
  8860. function expensesRetreats() {
  8861. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  8862. if (! empty ( $rid )) {
  8863. // 操作记录
  8864. Doo::loadModel ( "receipt" );
  8865. $receipt = new receipt ();
  8866. Doo::loadModel ( "receiptLog" );
  8867. $receiptLog = new receiptLog ();
  8868. Doo::loadModel ( "verify" );
  8869. $verify = new verify ();
  8870. $receiptInfo = $receipt->getOne ( array (
  8871. 'where' => 'rid=' . $rid,
  8872. 'asArray' => true
  8873. ) );
  8874. $vr = $verify->getOne ( array (
  8875. 'where' => 'vid=' . $receiptInfo ['verify'],
  8876. 'asArray' => true
  8877. ) );
  8878. $jd = json_decode ( $vr ['staff'] );
  8879. $roleId = 0;
  8880. foreach ( $jd as $key => $value ) {
  8881. if ($value [1] == 'ROLE') {
  8882. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8883. if ($pos !== false) {
  8884. $roleId = $value [0];
  8885. }
  8886. }
  8887. }
  8888. // 审批日志
  8889. // echo $roleId;die;
  8890. if (! empty ( $roleId )) {
  8891. Doo::loadModel ( "role" );
  8892. $role = new role ();
  8893. $roleInfo = $role->getOne ( array (
  8894. 'where' => 'rid=' . $roleId,
  8895. 'asArray' => true
  8896. ) );
  8897. $receiptLog->rolename = $roleInfo ['name'];
  8898. }
  8899. $receiptLog->username = $this->staff [0] ['username'];
  8900. $receiptLog->uid = $this->staff [0] ['sid'];
  8901. $receiptLog->date = date ( "Y-m-d" );
  8902. $receiptLog->opinion = '撤回';
  8903. $receiptLog->img = $this->staff [0] ['avatar'];
  8904. $receiptLog->status = 4;
  8905. $receiptLog->rid = $rid;
  8906. $receiptLog->insert ();
  8907. $receipt->status = 4;
  8908. $receipt->update ( array (
  8909. 'where' => 'rid=' . $rid
  8910. ) );
  8911. // 微信企业号通知
  8912. $this->setWXMsg ( $rid, 2 );
  8913. }
  8914. // echo "ddd";
  8915. return '/approvalExpenses/pendApproval';
  8916. }
  8917. function updateCheReceipt() {
  8918. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8919. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  8920. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  8921. if (! empty ( $rid )) {
  8922. // 操作记录
  8923. Doo::loadModel ( "receipt" );
  8924. $receipt = new receipt ();
  8925. Doo::loadModel ( "receiptLog" );
  8926. $receiptLog = new receiptLog ();
  8927. Doo::loadModel ( "verify" );
  8928. $verify = new verify ();
  8929. $receiptInfo = $receipt->getOne ( array (
  8930. 'where' => 'rid=' . $rid . ' and status=2',
  8931. 'asArray' => true
  8932. ) );
  8933. if (empty ( $receiptInfo )) {
  8934. echo json_encode ( array (
  8935. 'status' => 2
  8936. ) );
  8937. die ();
  8938. }
  8939. $vr = $verify->getOne ( array (
  8940. 'where' => 'vid=' . $receiptInfo ['verify'],
  8941. 'asArray' => true
  8942. ) );
  8943. $jd = json_decode ( $vr ['staff'] );
  8944. $roleId = 0;
  8945. foreach ( $jd as $key => $value ) {
  8946. if ($value [1] == 'ROLE') {
  8947. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  8948. if ($pos !== false) {
  8949. $roleId = $value [0];
  8950. }
  8951. }
  8952. }
  8953. // 审批日志
  8954. // echo $roleId;die;
  8955. if (! empty ( $roleId )) {
  8956. Doo::loadModel ( "role" );
  8957. $role = new role ();
  8958. $roleInfo = $role->getOne ( array (
  8959. 'where' => 'rid=' . $roleId,
  8960. 'asArray' => true
  8961. ) );
  8962. $receiptLog->rolename = $roleInfo ['name'];
  8963. }
  8964. $receiptLog->username = $this->staff [0] ['username'];
  8965. $receiptLog->uid = $this->staff [0] ['sid'];
  8966. $receiptLog->date = date ( "Y-m-d" );
  8967. $receiptLog->opinion = $opinion;
  8968. $receiptLog->img = $this->staff [0] ['avatar'];
  8969. $receiptLog->status = 4;
  8970. $receiptLog->rid = $rid;
  8971. $receiptLog->insert ();
  8972. $receipt->status = 4;
  8973. $receipt->update ( array (
  8974. 'where' => 'rid=' . $rid
  8975. ) );
  8976. // 微信企业号通知
  8977. $this->setWXMsg ( $rid, 2 );
  8978. echo json_encode ( array (
  8979. 'status' => 1
  8980. ) );
  8981. // Header("HTTP/1.1 303 See Other");
  8982. // Header("Location: /approvalExpenses/pendApproval");
  8983. die ();
  8984. }
  8985. echo json_encode ( array (
  8986. 'status' => 2
  8987. ) );
  8988. die ();
  8989. // echo "ddd";
  8990. // return '/saeaBorad';
  8991. }
  8992. function revisePrice() {
  8993. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  8994. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  8995. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  8996. // echo $price;die;
  8997. if (! empty ( $rid )) {
  8998. Doo::loadModel ( "receipt" );
  8999. $receipt = new receipt ();
  9000. $receiptDetail = $receipt->getOne ( array (
  9001. 'where' => 'rid=' . $rid . ' and status=2 ',
  9002. 'asArray' => true
  9003. ) );
  9004. if (empty ( $receiptDetail ))
  9005. die ( 'illegal request' );
  9006. $reviseDetail = array ();
  9007. if (empty ( $receiptDetail ['reviseDetail'] )) {
  9008. array_push ( $reviseDetail, array (
  9009. 'sid' => $this->staff [0] ['sid'],
  9010. 'name' => $this->staff [0] ['username'],
  9011. 'description' => $description,
  9012. 'price' => $price
  9013. ) );
  9014. $reviseDetailString = json_encode ( $reviseDetail );
  9015. $receipt->reviseDetail = $reviseDetailString;
  9016. $receipt->revisePrice = $price;
  9017. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9018. } else {
  9019. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  9020. array_push ( $reviseDetail, array (
  9021. 'sid' => $this->staff [0] ['sid'],
  9022. 'name' => $this->staff [0] ['username'],
  9023. 'description' => $description,
  9024. 'price' => $price
  9025. ) );
  9026. $reviseDetailString = json_encode ( $reviseDetail );
  9027. $receipt->reviseDetail = $reviseDetailString;
  9028. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  9029. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  9030. }
  9031. $receipt->update ( array (
  9032. 'where' => 'rid=' . $rid
  9033. ) );
  9034. if ($receiptDetail ['Rtype'] == 1) {
  9035. if ($receiptDetail ['isBK'] == 1) {
  9036. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9037. }
  9038. } elseif ($receiptDetail ['Rtype'] == 2) {
  9039. } else {
  9040. return '/receiptburEdi/' . $receiptDetail ['rid'];
  9041. }
  9042. }
  9043. die ( 'illegal request' );
  9044. }
  9045. function personalCollect() {
  9046. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9047. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  9048. $this->showCache ( $path );
  9049. Doo::loadModel ( "receiptDetail" );
  9050. Doo::loadModel ( "itemStatistics" );
  9051. Doo::loadModel ( 'statistics' );
  9052. $statistics = new statistics ();
  9053. $itemStatistics = new itemStatistics ();
  9054. $receiptDetail = new receiptDetail ();
  9055. $receiptCollectList = $receiptDetail->find ( array (
  9056. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9057. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9058. 'groupby' => 'itemCategory,Month(date)',
  9059. 'asArray' => true
  9060. ) );
  9061. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  9062. 'where' => 'staff=' . $this->staff [0] ['sid'],
  9063. 'asArray' => true
  9064. ) );
  9065. // create collect html
  9066. $collectArray = array (
  9067. '日常相关费用' => array (),
  9068. '差旅相关费用' => array (),
  9069. '培训班费用' => array (),
  9070. '其他' => array ()
  9071. );
  9072. $adjustment = array ();
  9073. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  9074. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9075. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  9076. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9077. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  9078. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9079. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  9080. array_push ( $collectArray ['其他'], $collectHtml );
  9081. $data ['collectArray'] = $collectArray;
  9082. // statistics html
  9083. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9084. if (empty ( $stList ))
  9085. $stList = array (
  9086. 'rePrice' => 0,
  9087. 'agPrice' => 0
  9088. );
  9089. $data ['stList'] = array (
  9090. 'rePrice' => $stList ['rePrice'],
  9091. 'agPrice' => $stList ['agPrice'],
  9092. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9093. );
  9094. // Adjustment price html
  9095. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9096. array_push ( $adjustment, $collectHtml );
  9097. $data ['adjustment'] = $adjustment;
  9098. // total price html
  9099. $collectHtml = "";
  9100. $total = 0;
  9101. for($i = 1; $i <= 12; $i ++) {
  9102. $sumPrice = 0;
  9103. foreach ( $receiptCollectList as $key => $value ) {
  9104. if ($value ['month'] == $i) {
  9105. $sumPrice += $value ['price'];
  9106. }
  9107. }
  9108. if ($sumPrice == 0)
  9109. $collectHtml .= '<td class="taR">-</td>';
  9110. else
  9111. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9112. $total += $sumPrice;
  9113. }
  9114. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9115. $data ['totalPrice'] = $collectHtml;
  9116. $dateHtml = "";
  9117. $now = date ( "Y" );
  9118. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9119. if ($YEARD <= $now) {
  9120. $dateHtml .= '<option ';
  9121. if ($year == $YEARD) {
  9122. $dateHtml .= 'selected ';
  9123. }
  9124. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9125. }
  9126. }
  9127. $data ['dateHtml'] = $dateHtml;
  9128. $data ['year'] = $year;
  9129. $data ['totalYear'] = $total;
  9130. $data ['memu'] = "receipt";
  9131. $data ['staff'] = $this->staff;
  9132. $data ['receiptMemu'] = 'personalCollect';
  9133. $data ['verifyId'] = $this->verifyId;
  9134. $data ['executeId'] = $this->executeId;
  9135. // year staff status 2,4
  9136. if ($year < date ( "Y" )) {
  9137. Doo::loadModel ( 'receipt' );
  9138. $receipt = new receipt ();
  9139. $receiptList = $receipt->find ( array (
  9140. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9141. 'asArray' => true
  9142. ) );
  9143. if (empty ( $receiptList )) {
  9144. ob_start ();
  9145. $this->render ( "/admin/saea_slist_collect", $data );
  9146. $this->cacheFile ( $path );
  9147. die ();
  9148. }
  9149. }
  9150. $this->render ( "/admin/saea_slist_collect", $data );
  9151. }
  9152. function personalCollectDetail() {
  9153. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9154. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  9155. $this->showCache ( $path );
  9156. Doo::loadModel ( "receiptDetail" );
  9157. Doo::loadModel ( "itemStatistics" );
  9158. Doo::loadModel ( 'statistics' );
  9159. Doo::loadModel ( 'accountItem' );
  9160. $accountItem = new accountItem ();
  9161. $statistics = new statistics ();
  9162. $itemStatistics = new itemStatistics ();
  9163. $receiptDetail = new receiptDetail ();
  9164. $receiptCollectList = $receiptDetail->find ( array (
  9165. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9166. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9167. 'groupby' => 'item,Month(date)',
  9168. 'asArray' => true
  9169. ) );
  9170. $accountList = $accountItem->find ( array (
  9171. 'asArray' => true
  9172. ) );
  9173. // create CollectDetail HTML
  9174. $collectHtml = array ();
  9175. foreach ( $accountList as $key => $value ) {
  9176. $html = "";
  9177. $asum = 0;
  9178. for($i = 1; $i <= 12; $i ++) {
  9179. $falg = true;
  9180. foreach ( $receiptCollectList as $v ) {
  9181. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9182. $asum += $v ['price'];
  9183. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9184. $falg = false;
  9185. break;
  9186. }
  9187. }
  9188. if ($falg)
  9189. $html .= '<td class="taR">-</td>';
  9190. }
  9191. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9192. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9193. }
  9194. $data ['collectHtml'] = $collectHtml;
  9195. // create Adjustment price html
  9196. $receiptCollectList = $receiptDetail->find ( array (
  9197. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  9198. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  9199. 'groupby' => 'itemCategory,Month(date)',
  9200. 'asArray' => true
  9201. ) );
  9202. $adjustment = array ();
  9203. $collectArray = array (
  9204. '日常相关费用' => array (),
  9205. '差旅相关费用' => array (),
  9206. '培训班费用' => array (),
  9207. '其他' => array ()
  9208. );
  9209. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9210. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9211. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9212. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9213. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9214. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9215. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9216. array_push ( $collectArray ['其他'], $collectHtml );
  9217. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9218. array_push ( $adjustment, $collectHtml );
  9219. // total price html
  9220. $collectHtml = "";
  9221. $total = 0;
  9222. for($i = 1; $i <= 12; $i ++) {
  9223. $sumPrice = 0;
  9224. foreach ( $receiptCollectList as $key => $value ) {
  9225. if ($value ['month'] == $i) {
  9226. $sumPrice += $value ['price'];
  9227. }
  9228. }
  9229. if ($sumPrice == 0)
  9230. $collectHtml .= '<td class="taR">-</td>';
  9231. else
  9232. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9233. $total += $sumPrice;
  9234. }
  9235. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9236. // statistics html
  9237. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  9238. if (empty ( $stList ))
  9239. $stList = array (
  9240. 'rePrice' => 0,
  9241. 'agPrice' => 0
  9242. );
  9243. $data ['stList'] = array (
  9244. 'rePrice' => $stList ['rePrice'],
  9245. 'agPrice' => $stList ['agPrice'],
  9246. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9247. );
  9248. $data ['collectArray'] = $collectArray;
  9249. $data ['adjustment'] = $adjustment;
  9250. $data ['totalPrice'] = $collectHtml;
  9251. $data ['totalYear'] = $total;
  9252. $data ['year'] = $year;
  9253. $dateHtml = "";
  9254. $now = date ( "Y" );
  9255. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9256. if ($YEARD <= $now) {
  9257. $dateHtml .= '<option ';
  9258. if ($year == $YEARD) {
  9259. $dateHtml .= 'selected ';
  9260. }
  9261. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9262. }
  9263. }
  9264. $data ['dateHtml'] = $dateHtml;
  9265. $data ['memu'] = "receipt";
  9266. $data ['staff'] = $this->staff;
  9267. $data ['receiptMemu'] = 'personalCollect';
  9268. $data ['verifyId'] = $this->verifyId;
  9269. $data ['executeId'] = $this->executeId;
  9270. // year staff status 2,4
  9271. if ($year < date ( "Y" )) {
  9272. Doo::loadModel ( 'receipt' );
  9273. $receipt = new receipt ();
  9274. $receiptList = $receipt->find ( array (
  9275. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  9276. 'asArray' => true
  9277. ) );
  9278. if (empty ( $receiptList )) {
  9279. ob_start ();
  9280. $this->render ( "/admin/saeaCollectArticles", $data );
  9281. $this->cacheFile ( $path );
  9282. die ();
  9283. }
  9284. }
  9285. $this->render ( "/admin/saeaCollectArticles", $data );
  9286. }
  9287. function companyCategoryCollect() {
  9288. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9289. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  9290. $this->showCache ( $path );
  9291. Doo::loadModel ( 'L_category' );
  9292. Doo::loadModel ( 'itemStatistics' );
  9293. Doo::loadModel ( 'statistics' );
  9294. $statistics = new statistics ();
  9295. $Lcategory = new L_category ();
  9296. $itemStatistics = new itemStatistics ();
  9297. Doo::loadModel ( "receiptAuthorityManage" );
  9298. $receiptAuthorityManage = new receiptAuthorityManage ();
  9299. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9300. $cidList = array ();
  9301. foreach ( $imcStaff as $key => $value ) {
  9302. array_push ( $cidList, $value ['cid'] );
  9303. }
  9304. $cidString = implode ( ',', $cidList );
  9305. $LcategoryList = $Lcategory->find ( array (
  9306. 'where' => ' cid in (' . $cidString . ')',
  9307. 'asArray' => true
  9308. ) ); // 'staff='.$this->staff[0]['sid']." and
  9309. $itemStatisticsList = $itemStatistics->find ( array (
  9310. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9311. 'where' => " Year(date)=" . $year,
  9312. 'groupby' => 'cid,Month(date)',
  9313. 'asArray' => true
  9314. ) );
  9315. // ceatre companyCollectHtml
  9316. foreach ( $LcategoryList as $value ) {
  9317. $html = "";
  9318. $asum = 0;
  9319. for($i = 1; $i <= 12; $i ++) {
  9320. $falg = true;
  9321. foreach ( $itemStatisticsList as $v ) {
  9322. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  9323. $asum += $v ['price'];
  9324. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9325. $falg = false;
  9326. break;
  9327. }
  9328. }
  9329. if ($falg)
  9330. $html .= '<td class="taR">-</td>';
  9331. }
  9332. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9333. $collectHtml [$value ['title']] = array (
  9334. 'html' => $html,
  9335. 'cid' => $value ['cid']
  9336. );
  9337. }
  9338. $data ['companyHtml'] = $collectHtml;
  9339. // total price html
  9340. $collectHtml = "";
  9341. $total = 0;
  9342. for($i = 1; $i <= 12; $i ++) {
  9343. $sumPrice = 0;
  9344. foreach ( $itemStatisticsList as $key => $value ) {
  9345. if ($value ['month'] == $i) {
  9346. $sumPrice += $value ['price'];
  9347. }
  9348. }
  9349. if ($sumPrice == 0)
  9350. $collectHtml .= '<td class="taR">-</td>';
  9351. else
  9352. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9353. $total += $sumPrice;
  9354. }
  9355. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9356. $data ['companyTotalHtml'] = $collectHtml;
  9357. $data ['total'] = $total;
  9358. // statistics html
  9359. // echo $cidString;
  9360. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9361. if (empty ( $stList ))
  9362. $stList = array (
  9363. 'rePrice' => 0,
  9364. 'agPrice' => 0
  9365. );
  9366. $data ['stList'] = array (
  9367. 'rePrice' => $stList ['rePrice'],
  9368. 'agPrice' => $stList ['agPrice'],
  9369. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9370. );
  9371. $data ['year'] = $year;
  9372. $data ['memu'] = "receipt";
  9373. $data ['staff'] = $this->staff;
  9374. $data ['receiptMemu'] = 'companyCategoryCollect';
  9375. $data ['verifyId'] = $this->verifyId;
  9376. $data ['executeId'] = $this->executeId;
  9377. $dateHtml = "";
  9378. $now = date ( "Y" );
  9379. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  9380. if ($YEARD <= $now) {
  9381. $dateHtml .= '<option ';
  9382. if ($year == $YEARD) {
  9383. $dateHtml .= 'selected ';
  9384. }
  9385. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  9386. }
  9387. }
  9388. $data ['dateHtml'] = $dateHtml;
  9389. // year staff status 2,4
  9390. if ($year < date ( "Y" )) {
  9391. Doo::loadModel ( 'receipt' );
  9392. $receipt = new receipt ();
  9393. $receiptList = $receipt->find ( array (
  9394. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  9395. 'asArray' => true
  9396. ) );
  9397. if (empty ( $receiptList )) {
  9398. ob_start ();
  9399. $this->render ( "/admin/saeaCompanyCollect", $data );
  9400. $this->cacheFile ( $path );
  9401. die ();
  9402. }
  9403. }
  9404. $this->render ( "/admin/saeaCompanyCollect", $data );
  9405. }
  9406. function categoryCollectDetail() {
  9407. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9408. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  9409. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  9410. $this->showCache ( $path );
  9411. Doo::loadModel ( 'statistics' );
  9412. $statistics = new statistics ();
  9413. Doo::loadModel ( "receiptDetail" );
  9414. $receiptDetail = new receiptDetail ();
  9415. Doo::loadModel ( 'L_category' );
  9416. $Lcategory = new L_category ();
  9417. Doo::loadModel ( 'accountItem' );
  9418. $accountItem = new accountItem ();
  9419. Doo::loadModel ( "receiptAuthorityManage" );
  9420. $receiptAuthorityManage = new receiptAuthorityManage ();
  9421. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9422. $cidList = array ();
  9423. foreach ( $imcStaff as $key => $value ) {
  9424. array_push ( $cidList, $value ['cid'] );
  9425. }
  9426. $cidString = implode ( ',', $cidList );
  9427. $LcategoryList = $Lcategory->find ( array (
  9428. 'where' => 'cid in (' . $cidString . ')',
  9429. 'asArray' => true
  9430. ) );
  9431. if ($cid == 0) {
  9432. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9433. if ($cid == 0)
  9434. $cid = $LcategoryList [0] ['cid'];
  9435. }
  9436. $data ['LcategoryList'] = $LcategoryList;
  9437. $receiptCollectList = $receiptDetail->find ( array (
  9438. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9439. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9440. 'groupby' => 'item,Month(pastDate)',
  9441. 'asArray' => true
  9442. ) );
  9443. $accountList = $accountItem->find ( array (
  9444. 'asArray' => true
  9445. ) );
  9446. // create CollectDetail HTML
  9447. $collectHtml = array ();
  9448. foreach ( $accountList as $key => $value ) {
  9449. $html = "";
  9450. $asum = 0;
  9451. for($i = 1; $i <= 12; $i ++) {
  9452. $falg = true;
  9453. foreach ( $receiptCollectList as $v ) {
  9454. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9455. $asum += $v ['price'];
  9456. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9457. $falg = false;
  9458. break;
  9459. }
  9460. }
  9461. if ($falg)
  9462. $html .= '<td class="taR">-</td>';
  9463. }
  9464. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9465. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9466. }
  9467. $data ['collectHtml'] = $collectHtml;
  9468. // create Adjustment price html
  9469. $receiptCollectList = $receiptDetail->find ( array (
  9470. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9471. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  9472. 'groupby' => 'itemCategory,Month(pastDate)',
  9473. 'asArray' => true
  9474. ) );
  9475. $adjustment = array ();
  9476. $collectArray = array (
  9477. '日常相关费用' => array (),
  9478. '差旅相关费用' => array (),
  9479. '培训班费用' => array (),
  9480. '其他' => array ()
  9481. );
  9482. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9483. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9484. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9485. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9486. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9487. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9488. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9489. array_push ( $collectArray ['其他'], $collectHtml );
  9490. $data ['collectArray'] = $collectArray;
  9491. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9492. array_push ( $adjustment, $collectHtml );
  9493. $data ['adjustment'] = $adjustment;
  9494. // total price html
  9495. $collectHtml = "";
  9496. $total = 0;
  9497. for($i = 1; $i <= 12; $i ++) {
  9498. $sumPrice = 0;
  9499. foreach ( $receiptCollectList as $key => $value ) {
  9500. if ($value ['month'] == $i) {
  9501. $sumPrice += $value ['price'];
  9502. }
  9503. }
  9504. if ($sumPrice == 0)
  9505. $collectHtml .= '<td class="taR">-</td>';
  9506. else
  9507. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9508. $total += $sumPrice;
  9509. }
  9510. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9511. // statistics html
  9512. $stList = $statistics->statisticsByCid ( $year, $cid );
  9513. if (empty ( $stList ))
  9514. $stList = array (
  9515. 'rePrice' => 0,
  9516. 'agPrice' => 0
  9517. );
  9518. $data ['stList'] = array (
  9519. 'rePrice' => $stList ['rePrice'],
  9520. 'agPrice' => $stList ['agPrice'],
  9521. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9522. );
  9523. $data ['totalYear'] = $total;
  9524. $data ['year'] = $year;
  9525. $data ['cid'] = $cid;
  9526. $data ['memu'] = "receipt";
  9527. $data ['staff'] = $this->staff;
  9528. $data ['receiptMemu'] = 'companyCategoryCollect';
  9529. $data ['verifyId'] = $this->verifyId;
  9530. $data ['executeId'] = $this->executeId;
  9531. // year staff status 2,4
  9532. if ($year < date ( "Y" )) {
  9533. Doo::loadModel ( 'receipt' );
  9534. $receipt = new receipt ();
  9535. $receiptList = $receipt->find ( array (
  9536. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  9537. 'asArray' => true
  9538. ) );
  9539. if (empty ( $receiptList )) {
  9540. ob_start ();
  9541. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9542. $this->cacheFile ( $path );
  9543. die ();
  9544. }
  9545. }
  9546. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  9547. }
  9548. function staffCollect() {
  9549. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9550. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ONJOB';//
  9551. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  9552. // $this->showCache($path);
  9553. Doo::loadModel ( 'statistics' );
  9554. $statistics = new statistics ();
  9555. Doo::loadModel ( "receiptDetail" );
  9556. $receiptDetail = new receiptDetail ();
  9557. Doo::loadModel ( 'L_category' );
  9558. $Lcategory = new L_category ();
  9559. Doo::loadModel ( 'accountItem' );
  9560. $accountItem = new accountItem ();
  9561. Doo::loadModel ( 'staff' );
  9562. $staff = new staff ();
  9563. Doo::loadModel ( 'itemStatistics' );
  9564. $itemStatistics = new itemStatistics ();
  9565. Doo::loadModel ( "receiptAuthorityManage" );
  9566. $receiptAuthorityManage = new receiptAuthorityManage ();
  9567. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9568. $cidList = array ();
  9569. foreach ( $imcStaff as $key => $value ) {
  9570. array_push ( $cidList, $value ['cid'] );
  9571. }
  9572. $cidString = implode ( ',', $cidList );
  9573. $naturecon='';
  9574. if ($nature=='ONJOB'){
  9575. $naturecon=' and (nature!=4 )';
  9576. }elseif($nature=='LEAVEJOB'){
  9577. $naturecon=' and (nature=4 )';
  9578. }else{
  9579. die ( 'illegal request--nature' );
  9580. }
  9581. // statistics html
  9582. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  9583. if (empty ( $stList ))
  9584. $stList = array (
  9585. 'rePrice' => 0,
  9586. 'agPrice' => 0
  9587. );
  9588. $data ['stList'] = array (
  9589. 'rePrice' => $stList ['rePrice'],
  9590. 'agPrice' => $stList ['agPrice'],
  9591. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9592. );
  9593. // ---
  9594. $staffList = $staff->find ( array (
  9595. 'where' => 'username !="admin" '.$naturecon,
  9596. 'asArray' => true
  9597. ) );
  9598. $LcategoryList = $Lcategory->find ( array (
  9599. 'asArray' => true
  9600. ) ); // 'staff='.$this->staff[0]['sid']." and
  9601. $itemStatisticsList = $itemStatistics->find ( array (
  9602. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9603. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  9604. 'groupby' => 'staff,Month(date)',
  9605. 'asArray' => true
  9606. ) );
  9607. $categoryList = $staff->find ( array (
  9608. 'select' => 'COUNT(*) as count,cid,category',
  9609. 'where' => 'username !="admin" and cid in (' . $cidString . ') '.$naturecon,
  9610. 'groupby' => 'cid',
  9611. 'asArray' => true
  9612. ) );
  9613. // print_r($itemStatisticsList);die;
  9614. // ceatre companyCollectHtml
  9615. foreach ( $categoryList as $vlu ) {
  9616. $count = $vlu ['count'] + 1;
  9617. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  9618. $m1 = 0;
  9619. $m2 = 0;
  9620. $m3 = 0;
  9621. $m4 = 0;
  9622. $m5 = 0;
  9623. $m6 = 0;
  9624. $m7 = 0;
  9625. $m8 = 0;
  9626. $m9 = 0;
  9627. $m10 = 0;
  9628. $m11 = 0;
  9629. $m12 = 0;
  9630. $m13 = 0;
  9631. foreach ( $staffList as $value ) {
  9632. if ($vlu ['cid'] == $value ['cid']) {
  9633. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  9634. $asum = 0;
  9635. for($i = 1; $i <= 12; $i ++) {
  9636. $falg = true;
  9637. foreach ( $itemStatisticsList as $v ) {
  9638. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  9639. if ($v ['month'] == 1)
  9640. $m1 += $v ['price'];
  9641. if ($v ['month'] == 2)
  9642. $m2 += $v ['price'];
  9643. if ($v ['month'] == 3)
  9644. $m3 += $v ['price'];
  9645. if ($v ['month'] == 4)
  9646. $m4 += $v ['price'];
  9647. if ($v ['month'] == 5)
  9648. $m5 += $v ['price'];
  9649. if ($v ['month'] == 6)
  9650. $m6 += $v ['price'];
  9651. if ($v ['month'] == 7)
  9652. $m7 += $v ['price'];
  9653. if ($v ['month'] == 8)
  9654. $m8 += $v ['price'];
  9655. if ($v ['month'] == 9)
  9656. $m9 += $v ['price'];
  9657. if ($v ['month'] == 10)
  9658. $m10 += $v ['price'];
  9659. if ($v ['month'] == 11)
  9660. $m11 += $v ['price'];
  9661. if ($v ['month'] == 12)
  9662. $m12 += $v ['price'];
  9663. $asum += $v ['price'];
  9664. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9665. $falg = false;
  9666. break;
  9667. }
  9668. }
  9669. if ($falg)
  9670. $html .= '<td class="taR">-</td>';
  9671. }
  9672. $m13 += $asum;
  9673. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9674. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  9675. 'html' => $html,
  9676. 'sid' => $value ['sid']
  9677. );
  9678. $html = "";
  9679. }
  9680. }
  9681. $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>
  9682. <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>
  9683. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  9684. $collectHtml [$vlu ['cid']] = array (
  9685. 'html' => $hl,
  9686. 'sid' => ''
  9687. );
  9688. }
  9689. $data ['companyHtml'] = $collectHtml;
  9690. // total price html
  9691. $collectHtml = "";
  9692. $total = 0;
  9693. for($i = 1; $i <= 12; $i ++) {
  9694. $sumPrice = 0;
  9695. foreach ( $itemStatisticsList as $key => $value ) {
  9696. if ($value ['month'] == $i) {
  9697. $sumPrice += $value ['price'];
  9698. }
  9699. }
  9700. if ($sumPrice == 0)
  9701. $collectHtml .= '<td class="taR">-</td>';
  9702. else
  9703. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9704. $total += $sumPrice;
  9705. }
  9706. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9707. $data ['companyTotalHtml'] = $collectHtml;
  9708. $data ['total'] = $total;
  9709. $data ['nature'] =$nature;
  9710. $data ['year'] = $year;
  9711. $data ['memu'] = "receipt";
  9712. $data ['staff'] = $this->staff;
  9713. $data ['receiptMemu'] = 'companyCategoryCollect';
  9714. $data ['verifyId'] = $this->verifyId;
  9715. $data ['executeId'] = $this->executeId;
  9716. if ($year <= date ( "Y" )) {
  9717. Doo::loadModel ( 'receipt' );
  9718. $receipt = new receipt ();
  9719. $receiptList = $receipt->find ( array (
  9720. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  9721. 'asArray' => true
  9722. ) );
  9723. if (empty ( $receiptList )) { // generated files
  9724. ob_start ();
  9725. $this->render ( "/admin/saeaStaffCollectB", $data );
  9726. $this->cacheFile ( $path );
  9727. die ();
  9728. }
  9729. }
  9730. $this->render ( "/admin/saeaStaffCollectB", $data );
  9731. }
  9732. function staffCollectBak() {
  9733. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9734. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  9735. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  9736. $this->showCache ( $path );
  9737. Doo::loadModel ( 'statistics' );
  9738. $statistics = new statistics ();
  9739. Doo::loadModel ( "receiptDetail" );
  9740. $receiptDetail = new receiptDetail ();
  9741. Doo::loadModel ( 'L_category' );
  9742. $Lcategory = new L_category ();
  9743. Doo::loadModel ( 'accountItem' );
  9744. $accountItem = new accountItem ();
  9745. Doo::loadModel ( 'staff' );
  9746. $staff = new staff ();
  9747. Doo::loadModel ( 'itemStatistics' );
  9748. $itemStatistics = new itemStatistics ();
  9749. $itemStatisticsList = $itemStatistics->find ( array (
  9750. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9751. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9752. 'groupby' => 'staff,itemCategory,Month(date)',
  9753. 'asArray' => true
  9754. ) );
  9755. $itemCategoryList = $itemStatistics->find ( array (
  9756. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  9757. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9758. 'groupby' => 'cid,itemCategory,Month(date)',
  9759. 'asArray' => true
  9760. ) );
  9761. $LcategoryList = $Lcategory->find ( array (
  9762. 'asArray' => true
  9763. ) );
  9764. $staffList = $staff->find ( array (
  9765. 'asArray' => true
  9766. ) );
  9767. $htmlArray = array ();
  9768. foreach ( $LcategoryList as $value ) {
  9769. $htmlArray [$value ['title']] = array ();
  9770. foreach ( $staffList as $v ) {
  9771. if ($value ['cid'] == $v ['cid']) {
  9772. $html = "";
  9773. $falg = true;
  9774. $staffSumPrice = 0;
  9775. foreach ( $itemStatisticsList as $a ) {
  9776. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  9777. if (empty ( $a ['price'] )) {
  9778. $html .= '<td class="taR">-</td>';
  9779. $falg = false;
  9780. break;
  9781. } else {
  9782. $staffSumPrice += $a ['price'];
  9783. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9784. $falg = false;
  9785. break;
  9786. }
  9787. }
  9788. }
  9789. if ($falg) {
  9790. $html .= '<td class="taR">-</td>';
  9791. $falg = true;
  9792. }
  9793. $falg = true;
  9794. foreach ( $itemStatisticsList as $a ) {
  9795. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  9796. if (empty ( $a ['price'] )) {
  9797. $html .= '<td class="taR">-</td>';
  9798. $falg = false;
  9799. break;
  9800. } else {
  9801. $staffSumPrice += $a ['price'];
  9802. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9803. $falg = false;
  9804. break;
  9805. }
  9806. }
  9807. }
  9808. if ($falg) {
  9809. $html .= '<td class="taR">-</td>';
  9810. $falg = true;
  9811. }
  9812. $falg = true;
  9813. foreach ( $itemStatisticsList as $a ) {
  9814. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  9815. if (empty ( $a ['price'] )) {
  9816. $html .= '<td class="taR">-</td>';
  9817. $falg = false;
  9818. break;
  9819. } else {
  9820. $staffSumPrice += $a ['price'];
  9821. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9822. $falg = false;
  9823. break;
  9824. }
  9825. }
  9826. }
  9827. if ($falg) {
  9828. $html .= '<td class="taR">-</td>';
  9829. $falg = true;
  9830. }
  9831. $falg = true;
  9832. foreach ( $itemStatisticsList as $a ) {
  9833. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  9834. if (! empty ( $a ['price'] )) {
  9835. $staffSumPrice += $a ['price'];
  9836. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9837. $falg = false;
  9838. break;
  9839. } else {
  9840. $html .= '<td class="taR">-</td>';
  9841. $falg = false;
  9842. break;
  9843. }
  9844. }
  9845. }
  9846. if ($falg) {
  9847. $html .= '<td class="taR">-</td>';
  9848. $falg = true;
  9849. }
  9850. $falg = true;
  9851. foreach ( $itemStatisticsList as $a ) {
  9852. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  9853. if (! empty ( $a ['price'] )) {
  9854. $staffSumPrice += $a ['price'];
  9855. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  9856. $falg = false;
  9857. break;
  9858. } else {
  9859. $html .= '<td class="taR">-</td>';
  9860. $falg = false;
  9861. break;
  9862. }
  9863. }
  9864. }
  9865. if ($falg) {
  9866. $html .= '<td class="taR">-</td>';
  9867. $falg = true;
  9868. }
  9869. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  9870. $htmlArray [$value ['title']] [$v ['username']] = $html;
  9871. }
  9872. }
  9873. /* -- --- */
  9874. // 合计费用
  9875. $cateHtml = "";
  9876. $catePrice = 0;
  9877. $cateFalg = true;
  9878. foreach ( $itemCategoryList as $l ) {
  9879. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  9880. if (empty ( $l ['price'] )) {
  9881. $cateHtml .= '<td class="colGreen taR">-</td>';
  9882. $cateFalg = false;
  9883. break;
  9884. } else {
  9885. $catePrice += $l ['price'];
  9886. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9887. $cateFalg = false;
  9888. break;
  9889. }
  9890. }
  9891. }
  9892. if ($cateFalg) {
  9893. $cateHtml .= '<td class="colGreen taR">-</td>';
  9894. $cateFalg = true;
  9895. }
  9896. $cateFalg = true;
  9897. foreach ( $itemCategoryList as $l ) {
  9898. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  9899. if (empty ( $l ['price'] )) {
  9900. $cateHtml .= '<td class="colGreen taR">-</td>';
  9901. $cateFalg = false;
  9902. break;
  9903. } else {
  9904. $catePrice += $l ['price'];
  9905. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9906. $cateFalg = false;
  9907. break;
  9908. }
  9909. }
  9910. }
  9911. if ($cateFalg) {
  9912. $cateHtml .= '<td class="colGreen taR">-</td>';
  9913. $cateFalg = true;
  9914. }
  9915. $cateFalg = true;
  9916. foreach ( $itemCategoryList as $l ) {
  9917. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  9918. if (empty ( $l ['price'] )) {
  9919. $cateHtml .= '<td class="colGreen taR">-</td>';
  9920. $cateFalg = false;
  9921. break;
  9922. } else {
  9923. $catePrice += $l ['price'];
  9924. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9925. $cateFalg = false;
  9926. break;
  9927. }
  9928. }
  9929. }
  9930. if ($cateFalg) {
  9931. $cateHtml .= '<td class="colGreen taR">-</td>';
  9932. $cateFalg = true;
  9933. }
  9934. $cateFalg = true;
  9935. foreach ( $itemCategoryList as $l ) {
  9936. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  9937. if (empty ( $l ['price'] )) {
  9938. $cateHtml .= '<td class="colGreen taR">-</td>';
  9939. $cateFalg = false;
  9940. break;
  9941. } else {
  9942. $catePrice += $l ['price'];
  9943. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9944. $cateFalg = false;
  9945. break;
  9946. }
  9947. }
  9948. }
  9949. if ($cateFalg) {
  9950. $cateHtml .= '<td class="colGreen taR">-</td>';
  9951. $cateFalg = true;
  9952. }
  9953. $cateFalg = true;
  9954. foreach ( $itemCategoryList as $l ) {
  9955. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  9956. if (empty ( $l ['price'] )) {
  9957. $cateHtml .= '<td class="colGreen taR">-</td>';
  9958. $cateFalg = false;
  9959. break;
  9960. } else {
  9961. $catePrice += $l ['price'];
  9962. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  9963. $cateFalg = false;
  9964. break;
  9965. }
  9966. }
  9967. }
  9968. if ($cateFalg) {
  9969. $cateHtml .= '<td class="colGreen taR">-</td>';
  9970. $cateFalg = true;
  9971. }
  9972. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  9973. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  9974. /* -- --- */
  9975. }
  9976. // print_r($htmlArray);die;
  9977. $data ['htmlArray'] = $htmlArray;
  9978. // statistics html
  9979. $stList = $statistics->getOne ( array (
  9980. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9981. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9982. 'groupby' => 'Month(date)',
  9983. 'asArray' => true
  9984. ) );
  9985. if (empty ( $stList ))
  9986. $stList = array (
  9987. 'rePrice' => 0,
  9988. 'agPrice' => 0
  9989. );
  9990. $data ['stList'] = array (
  9991. 'rePrice' => $stList ['rePrice'],
  9992. 'agPrice' => $stList ['agPrice'],
  9993. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9994. );
  9995. $monthHtml = "";
  9996. for($i = 1; $i <= 12; $i ++) {
  9997. if ($i == $month)
  9998. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9999. else
  10000. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10001. }
  10002. $data ['monthHtml'] = $monthHtml;
  10003. $data ['year'] = $year;
  10004. $data ['month'] = $month;
  10005. $data ['memu'] = "receipt";
  10006. $data ['staff'] = $this->staff;
  10007. $data ['receiptMemu'] = 'companyCategoryCollect';
  10008. $data ['verifyId'] = $this->verifyId;
  10009. $data ['executeId'] = $this->executeId;
  10010. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  10011. Doo::loadModel ( 'receipt' );
  10012. $receipt = new receipt ();
  10013. $receiptList = $receipt->find ( array (
  10014. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  10015. 'asArray' => true
  10016. ) );
  10017. if (empty ( $receiptList )) { // generated files
  10018. ob_start ();
  10019. $this->render ( "/admin/saeaStaffCollect", $data );
  10020. $this->cacheFile ( $path );
  10021. die ();
  10022. }
  10023. }
  10024. $this->render ( "/admin/saeaStaffCollect", $data );
  10025. }
  10026. /**
  10027. * 日常收支
  10028. */
  10029. function payments() {
  10030. // include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  10031. Doo::loadModel ( "execute" );
  10032. $execute = new execute ();
  10033. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  10034. die ( 'illegal request' );
  10035. }
  10036. Doo::loadModel ( "accountBook" );
  10037. $accountBook = new accountBook ();
  10038. Doo::loadModel ( "accountBookStatistics" );
  10039. $accountBookStatistics = new accountBookStatistics ();
  10040. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10041. $list = $accountBook->getAccountBookByLimit ( 10 );
  10042. $data ['date'] = date ( "Y-m-d" );
  10043. $data ['statisticsList'] = $statisticsList;
  10044. $data ['list'] = $list;
  10045. $data ['memu'] = "receipt";
  10046. $data ['staff'] = $this->staff;
  10047. $data ['receiptMemu'] = 'payments';
  10048. $data ['verifyId'] = $this->verifyId;
  10049. $data ['executeId'] = $this->executeId;
  10050. $this->render ( "/expenses/payments", $data );
  10051. }
  10052. function paymentsIncomeDo() {
  10053. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10054. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10055. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10056. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10057. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10058. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10059. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10060. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10061. Doo::loadClass ( 'XDeode' );
  10062. $XDeode = new XDeode ( 5 );
  10063. Doo::loadModel ( "accountBook" );
  10064. Doo::loadModel ( "accountBookStatistics" );
  10065. Doo::loadModel ( 'wasteBook' );
  10066. // 记录流水时银行的转换
  10067. $accountBank = '';
  10068. if ($receivedBank == '纵横广发') {
  10069. $accountBank = 'CGBDeposit';
  10070. } elseif ($receivedBank == '纵横工行') {
  10071. $accountBank = 'ICBCDeposit';
  10072. } elseif ($receivedBank == '华润银行') {
  10073. $accountBank = 'HUADeposit';
  10074. } elseif ($receivedBank == '个人广发') {
  10075. $accountBank = 'PersonalDeposit';
  10076. }
  10077. if (empty ( $accountBank ))
  10078. die ( 'illegal request' );
  10079. // 收入为理财时特殊处理
  10080. if ($accountType == 7 || $accountType == 9) {
  10081. if ($receivedBank == '个人广发') {
  10082. die ( '个人广发 illegal request' );
  10083. }
  10084. // 添加一条收入
  10085. $accountBook = new accountBook ();
  10086. $accountBook->accountType = 10;
  10087. $accountBook->accountMsg = $accountMsg;
  10088. $accountBook->receivedPrice = $receivedPrice;
  10089. $accountBook->receivedMsg = $receivedMsg;
  10090. $accountBook->receivedBank = $receivedBank;
  10091. $accountBook->receivedDate = $receivedDate;
  10092. $accountBook->remarks = $remarks;
  10093. $accountBook->expensesType = 1;
  10094. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10095. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10096. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10097. $inComeId = $accountBook->insert ();
  10098. // 收支汇总-添加一条收入日常汇总
  10099. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  10100. $accountBookStatistics = new accountBookStatistics ();
  10101. $item = array (
  10102. 'date' => date ( "Y-m-d" ),
  10103. 'accountType' => $abDetail ['accountType'],
  10104. 'accountMsg' => $abDetail ['accountMsg'],
  10105. 'aid' => $abDetail ['aid'],
  10106. 'inComePrice' => $abDetail ['receivedPrice'],
  10107. 'expensesType' => $abDetail ['expensesType']
  10108. );
  10109. $accountBookStatistics->setAccountBookStatistics ( $item );
  10110. // 添加收入流水
  10111. $wasteBook = new wasteBook ();
  10112. $itemWaste = array (
  10113. 'accountPriceShow' => $receivedPrice,
  10114. 'accountPrice' => $receivedPrice,
  10115. 'expensesType' => 1,
  10116. 'accountType' => 6, // 流水类型
  10117. 'dataID' => $inComeId,
  10118. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10119. 'accountBank' => $accountBank,
  10120. 'category' => $this->staff [0] ['category'],
  10121. 'cid' => $this->staff [0] ['cid'],
  10122. 'name' => $this->staff [0] ['username'],
  10123. 'sid' => $this->staff [0] ['sid'],
  10124. 'inputDate' => date ( "Y-m-d H:i:s" )
  10125. );
  10126. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10127. // 添加一条理财支出
  10128. $accountBank = 'CGBDeposit';
  10129. $expenditureBank = '纵横广发';
  10130. $dailyExpenditureType = 4;
  10131. if ($accountType == 9) {
  10132. $accountBank = 'ICBCDeposit';
  10133. $expenditureBank = '纵横工行';
  10134. $dailyExpenditureType = 6;
  10135. }
  10136. $accountBook = new accountBook ();
  10137. $accountBook->expensesType = 2;
  10138. $accountBook->expenditureType = $dailyExpenditureType;
  10139. $accountBook->expenditureMsg = $accountMsg;
  10140. $accountBook->expenditurePrice = $receivedPrice;
  10141. $accountBook->expenditureBank = $expenditureBank;
  10142. $accountBook->expenditureDate = $receivedDate;
  10143. $accountBook->remarks = $remarks;
  10144. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10145. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10146. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10147. $id = $accountBook->insert ();
  10148. // 收支汇总-添加一条理财支出汇总
  10149. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10150. $accountBookStatistics = new accountBookStatistics ();
  10151. $item = array (
  10152. 'date' => date ( "Y-m-d" ),
  10153. 'accountType' => $abDetail ['accountType'],
  10154. 'accountMsg' => $abDetail ['accountMsg'],
  10155. 'aid' => $abDetail ['aid'],
  10156. 'financingPrice' => - $receivedPrice,
  10157. 'expensesType' => 3
  10158. );
  10159. $accountBookStatistics->setAccountBookStatistics ( $item );
  10160. // 添加一条支出理财流水
  10161. $accountTypeWaste = 5;
  10162. if ($accountMsg == '公司固定') {
  10163. $accountTypeWaste = 9;
  10164. } elseif ($accountMsg == '公司活期') {
  10165. $accountTypeWaste = 10;
  10166. } elseif ($accountMsg == '个人(GR)') {
  10167. $accountBank = 'PersonalDeposit';
  10168. }
  10169. $itemWaste = array (
  10170. 'expensesType' => 2,
  10171. 'accountType' => $accountTypeWaste,
  10172. 'accountPriceShow' => $receivedPrice,
  10173. 'accountPrice' => - $receivedPrice,
  10174. 'dataID' => $id,
  10175. 'dailyExpenditureType' => $dailyExpenditureType,
  10176. 'accountBank' => $accountBank,
  10177. 'category' => $this->staff [0] ['category'],
  10178. 'cid' => $this->staff [0] ['cid'],
  10179. 'name' => $this->staff [0] ['username'],
  10180. 'sid' => $this->staff [0] ['sid'],
  10181. 'inputDate' => date ( "Y-m-d H:i:s" )
  10182. );
  10183. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10184. } elseif ($accountType == 1) {
  10185. if ($receivedBank == '个人广发')
  10186. die ( 'illegal request' );
  10187. // 添加一条收入
  10188. $accountBook = new accountBook ();
  10189. $accountBook->accountType = $accountType;
  10190. $accountBook->accountMsg = $accountMsg;
  10191. $accountBook->receivedPrice = $receivedPrice;
  10192. $accountBook->receivedMsg = $receivedMsg;
  10193. $accountBook->receivedBank = $receivedBank;
  10194. $accountBook->receivedDate = $receivedDate;
  10195. $accountBook->remarks = $remarks;
  10196. $accountBook->expensesType = 1;
  10197. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10198. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10199. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10200. $id = $accountBook->insert ();
  10201. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10202. // 收支汇总-添加一条收入日常汇总
  10203. $accountBookStatistics = new accountBookStatistics ();
  10204. $item = array (
  10205. 'date' => date ( "Y-m-d" ),
  10206. 'accountType' => $abDetail ['accountType'],
  10207. 'accountMsg' => $abDetail ['accountMsg'],
  10208. 'aid' => $abDetail ['aid'],
  10209. 'expensesType' => $abDetail ['expensesType']
  10210. );
  10211. if ($abDetail ['accountType'] == 8) {
  10212. $item += array (
  10213. 'inComePrice' => $abDetail ['receivedPrice']
  10214. );
  10215. } else {
  10216. $item += array (
  10217. 'inComePrice' => $abDetail ['receivedPrice']
  10218. );
  10219. }
  10220. $accountBookStatistics->setAccountBookStatistics ( $item );
  10221. // 流水存储方向
  10222. $itemWaste = array (
  10223. 'accountType' => 6
  10224. ); // 流水类型
  10225. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  10226. // }else
  10227. if ($accountMsg == '活期理财收益') {
  10228. $itemWaste = array (
  10229. 'accountType' => 10
  10230. ); // 流水类型
  10231. }
  10232. // 添加收入流水
  10233. $wasteBook = new wasteBook ();
  10234. $itemWaste += array (
  10235. 'accountPrice' => $receivedPrice,
  10236. 'accountPriceShow' => $receivedPrice,
  10237. 'expensesType' => 1,
  10238. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10239. 'dataID' => $id,
  10240. 'accountBank' => $accountBank,
  10241. 'category' => $this->staff [0] ['category'],
  10242. 'cid' => $this->staff [0] ['cid'],
  10243. 'name' => $this->staff [0] ['username'],
  10244. 'sid' => $this->staff [0] ['sid'],
  10245. 'inputDate' => date ( "Y-m-d H:i:s" )
  10246. );
  10247. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10248. } else { // 普通日常收入处理
  10249. // 添加一条收入
  10250. $accountBook = new accountBook ();
  10251. $accountBook->accountType = $accountType;
  10252. $accountBook->accountMsg = $accountMsg;
  10253. $accountBook->receivedPrice = $receivedPrice;
  10254. $accountBook->receivedMsg = $receivedMsg;
  10255. $accountBook->receivedBank = $receivedBank;
  10256. $accountBook->receivedDate = $receivedDate;
  10257. $accountBook->remarks = $remarks;
  10258. $accountBook->expensesType = 1;
  10259. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10260. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10261. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10262. $id = $accountBook->insert ();
  10263. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10264. // 收支汇总-添加一条收入日常汇总
  10265. $accountBookStatistics = new accountBookStatistics ();
  10266. $item = array (
  10267. 'date' => date ( "Y-m-d" ),
  10268. 'accountType' => $abDetail ['accountType'],
  10269. 'accountMsg' => $abDetail ['accountMsg'],
  10270. 'aid' => $abDetail ['aid'],
  10271. 'expensesType' => $abDetail ['expensesType']
  10272. );
  10273. if ($abDetail ['accountType'] == 8) {
  10274. $item += array (
  10275. 'inComePrice' => $abDetail ['receivedPrice']
  10276. );
  10277. } else {
  10278. $item += array (
  10279. 'inComePrice' => $abDetail ['receivedPrice']
  10280. );
  10281. }
  10282. $accountBookStatistics->setAccountBookStatistics ( $item );
  10283. // 添加收入流水
  10284. $itemWaste = array (
  10285. 'accountPrice' => $receivedPrice
  10286. );
  10287. if ($receivedBank == '个人广发') {
  10288. $itemWaste = array (
  10289. 'accountPrice' => - $receivedPrice
  10290. );
  10291. }
  10292. $wasteBook = new wasteBook ();
  10293. $itemWaste += array (
  10294. 'accountPriceShow' => $receivedPrice,
  10295. 'expensesType' => 1,
  10296. 'accountType' => 6, // 流水类型
  10297. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10298. 'dataID' => $id,
  10299. 'accountBank' => $accountBank,
  10300. 'category' => $this->staff [0] ['category'],
  10301. 'cid' => $this->staff [0] ['cid'],
  10302. 'name' => $this->staff [0] ['username'],
  10303. 'sid' => $this->staff [0] ['sid'],
  10304. 'inputDate' => date ( "Y-m-d H:i:s" )
  10305. );
  10306. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10307. }
  10308. }
  10309. return '/payments';
  10310. }
  10311. /**
  10312. * 添加收入
  10313. * @return string
  10314. */
  10315. function paymentsIncomeDo_() {
  10316. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10317. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10318. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10319. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10320. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10321. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10322. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10323. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10324. Doo::loadClass ( 'XDeode' );
  10325. $XDeode = new XDeode ( 5 );
  10326. Doo::loadModel ( "accountBook" );
  10327. $accountBook = new accountBook ();
  10328. $accountBank = '';
  10329. $accountTypeWaste = 6;
  10330. if ($receivedBank == '纵横广发') {
  10331. $accountBank = 'CGBDeposit';
  10332. } elseif ($receivedBank == '纵横工行') {
  10333. $accountBank = 'ICBCDeposit';
  10334. } elseif ($receivedBank == '华润银行') {
  10335. $accountBank = 'HUADeposit';
  10336. } elseif ($receivedBank == '个人广发') {
  10337. $accountBank = 'PersonalDeposit';
  10338. }
  10339. if (empty ( $accountBank ))
  10340. die ( 'illegal request' );
  10341. $dailyIncomeType = '';
  10342. $itemWaste = array (
  10343. 'accountPrice' => $receivedPrice,
  10344. 'expensesType' => 1
  10345. );
  10346. if ($receivedBank == '个人广发') {
  10347. $itemWaste = array (
  10348. 'accountPrice' => - $receivedPrice,
  10349. 'expensesType' => 1
  10350. );
  10351. }
  10352. if ($accountType == 4) {
  10353. $dailyIncomeType = 4;
  10354. } elseif ($accountType == 1) {
  10355. $dailyIncomeType = 1;
  10356. } elseif ($accountType == 2) {
  10357. $dailyIncomeType = 2;
  10358. } elseif ($accountType == 3) {
  10359. $dailyIncomeType = 3;
  10360. } elseif ($accountType == 5) {
  10361. $dailyIncomeType = 5;
  10362. } elseif ($accountType == 6) {
  10363. $dailyIncomeType = 6;
  10364. } elseif ($accountType == 7 || $accountType == 9) {
  10365. $dailyIncomeType = 7;
  10366. if ($accountMsg == '公司固定') {
  10367. $accountTypeWaste = 9;
  10368. } elseif ($accountMsg == '公司活期') {
  10369. $accountTypeWaste = 10;
  10370. } elseif ($accountMsg == '个人(GR)') {
  10371. $accountBank = 'PersonalDeposit';
  10372. }
  10373. $itemWaste = array (
  10374. 'accountPrice' => - $receivedPrice,
  10375. 'expensesType' => 2
  10376. );
  10377. } elseif ($accountType == 8) {
  10378. $dailyIncomeType = 8;
  10379. }
  10380. if (empty ( $dailyIncomeType ))
  10381. die ( 'illegal request' );
  10382. $accountBook->accountType = $accountType;
  10383. $accountBook->accountMsg = $accountMsg;
  10384. $accountBook->receivedPrice = $receivedPrice;
  10385. $accountBook->receivedMsg = $receivedMsg;
  10386. $accountBook->receivedBank = $receivedBank;
  10387. $accountBook->receivedDate = $receivedDate;
  10388. $accountBook->remarks = $remarks;
  10389. $accountBook->expensesType = 1;
  10390. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10391. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10392. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10393. $id = $accountBook->insert ();
  10394. //
  10395. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10396. // 收支汇总
  10397. Doo::loadModel ( "accountBookStatistics" );
  10398. $accountBookStatistics = new accountBookStatistics ();
  10399. $item = array (
  10400. 'date' => date ( "Y-m-d" ),
  10401. 'accountType' => $abDetail ['accountType'],
  10402. 'accountMsg' => $abDetail ['accountMsg'],
  10403. 'aid' => $abDetail ['aid']
  10404. );
  10405. if ($abDetail ['expensesType'] == 1) {
  10406. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  10407. $item += array (
  10408. 'financingPrice' => - $receivedPrice,
  10409. 'expensesType' => 3
  10410. );
  10411. } else if ($abDetail ['accountType'] == 8) {
  10412. $item += array (
  10413. 'inComePrice' => - $abDetail ['receivedPrice'],
  10414. 'expensesType' => $abDetail ['expensesType']
  10415. );
  10416. } else {
  10417. $item += array (
  10418. 'inComePrice' => $abDetail ['receivedPrice'],
  10419. 'expensesType' => $abDetail ['expensesType']
  10420. );
  10421. }
  10422. }
  10423. $accountBookStatistics->setAccountBookStatistics ( $item );
  10424. // 为理财时需添加一条日常支出
  10425. if ($accountType == 7 || $accountType == 9) {
  10426. }
  10427. // 公司流水记录
  10428. Doo::loadModel ( 'wasteBook' );
  10429. $wasteBook = new wasteBook ();
  10430. // 银行
  10431. // if (empty($abDetail)){
  10432. $itemWaste += array (
  10433. 'accountPriceShow' => $receivedPrice,
  10434. 'dataID' => $id,
  10435. 'accountType' => $accountTypeWaste,
  10436. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  10437. 'accountBank' => $accountBank,
  10438. 'category' => $this->staff [0] ['category'],
  10439. 'cid' => $this->staff [0] ['cid'],
  10440. 'name' => $this->staff [0] ['username'],
  10441. 'sid' => $this->staff [0] ['sid'],
  10442. 'inputDate' => date ( "Y-m-d H:i:s" )
  10443. );
  10444. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10445. // }
  10446. // 类型为理财7或者9 要添加一笔理财支出
  10447. if ($accountType == 7 || $accountType == 9) {
  10448. $accountBank = 'CGBDeposit';
  10449. $expenditureBank = '纵横广发';
  10450. $dailyExpenditureType = 4;
  10451. if ($accountType == 9) {
  10452. $accountBank = 'ICBCDeposit';
  10453. $expenditureBank = '纵横工行';
  10454. $dailyExpenditureType = 6;
  10455. }
  10456. // 添加一条支出
  10457. $accountBook = new accountBook ();
  10458. $accountBook->expenditureType = $dailyExpenditureType;
  10459. $accountBook->expenditureMsg = $accountMsg;
  10460. $accountBook->expenditurePrice = $receivedPrice;
  10461. $accountBook->expenditureBank = $expenditureBank;
  10462. $accountBook->expenditureDate = $receivedDate;
  10463. $accountBook->remarks = $remarks;
  10464. $accountBook->expensesType = 2;
  10465. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10466. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10467. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10468. $id = $accountBook->insert ();
  10469. // 添加一条收入流水
  10470. $itemWaste = array (
  10471. 'accountPriceShow' => $receivedPrice,
  10472. 'accountPrice' => $receivedPrice,
  10473. 'dataID' => $id,
  10474. 'expensesType' => 2,
  10475. 'accountType' => $accountTypeWaste,
  10476. 'dailyExpenditureType' => $dailyExpenditureType,
  10477. 'accountBank' => $accountBank,
  10478. 'category' => $this->staff [0] ['category'],
  10479. 'cid' => $this->staff [0] ['cid'],
  10480. 'name' => $this->staff [0] ['username'],
  10481. 'sid' => $this->staff [0] ['sid'],
  10482. 'inputDate' => date ( "Y-m-d H:i:s" )
  10483. );
  10484. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10485. }
  10486. }
  10487. return '/payments';
  10488. }
  10489. function paymentsExpenditureDo() {
  10490. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10491. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10492. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10493. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10494. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10495. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10496. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10497. // 理财支出特殊处理
  10498. Doo::loadModel ( "accountBook" );
  10499. Doo::loadModel ( "accountBookStatistics" );
  10500. Doo::loadModel ( 'wasteBook' );
  10501. $accountBank = '';
  10502. if ($expenditureBank == '纵横广发') {
  10503. $accountBank = 'CGBDeposit';
  10504. } elseif ($expenditureBank == '纵横工行') {
  10505. $accountBank = 'ICBCDeposit';
  10506. } elseif ($expenditureBank == '华润银行') {
  10507. $accountBank = 'HUADeposit';
  10508. } elseif ($expenditureBank == '个人广发') {
  10509. $accountBank = 'PersonalDeposit';
  10510. }
  10511. if (empty ( $accountBank ))
  10512. die ( 'illegal request' );
  10513. if ($expenditureType == 4 || $expenditureType == 6) {
  10514. if ($expenditureBank == '个人广发') {
  10515. die ( '个人广发 illegal request' );
  10516. }
  10517. // 添加一笔日常支出
  10518. $accountBook = new accountBook ();
  10519. $accountBook->expensesType = 2;
  10520. $accountBook->expenditureType = 7;
  10521. $accountBook->expenditureMsg = $expenditureMsg;
  10522. $accountBook->expenditurePrice = $expenditurePrice;
  10523. $accountBook->expenditureBank = $expenditureBank;
  10524. $accountBook->expenditureDate = $expenditureDate;
  10525. $accountBook->remarks = $remarks;
  10526. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10527. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10528. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10529. $expenditureId = $accountBook->insert ();
  10530. // 添加日常支出汇总
  10531. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10532. $accountBookStatistics = new accountBookStatistics ();
  10533. $item = array (
  10534. 'date' => date ( "Y-m-d" ),
  10535. 'expenditureType' => $abDetail ['expenditureType'],
  10536. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10537. 'aid' => $abDetail ['aid'],
  10538. 'payPrice' => $abDetail ['expenditurePrice'],
  10539. 'expensesType' => $abDetail ['expensesType']
  10540. );
  10541. $accountBookStatistics->setAccountBookStatistics ( $item );
  10542. // 公司日常支出流水
  10543. $wasteBook = new wasteBook ();
  10544. $itemWaste = array (
  10545. 'accountPrice' => - $expenditurePrice
  10546. );
  10547. if ($expenditureBank == '个人广发') {
  10548. $itemWaste = array (
  10549. 'accountPrice' => $expenditurePrice
  10550. );
  10551. }
  10552. $itemWaste += array (
  10553. 'expensesType' => 2,
  10554. 'accountType' => 5,
  10555. 'dailyExpenditureType' => $expenditureType,
  10556. 'accountPriceShow' => $expenditurePrice,
  10557. 'accountPrice' => - $expenditurePrice,
  10558. 'dataID' => $expenditureId,
  10559. 'accountBank' => $accountBank,
  10560. 'category' => $this->staff [0] ['category'],
  10561. 'cid' => $this->staff [0] ['cid'],
  10562. 'name' => $this->staff [0] ['username'],
  10563. 'sid' => $this->staff [0] ['sid'],
  10564. 'inputDate' => date ( "Y-m-d H:i:s" )
  10565. );
  10566. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10567. // 添加一笔理财收入
  10568. $accountBank = 'CGBDeposit';
  10569. $dailyIncomeType = 7;
  10570. $receivedBank = '纵横广发';
  10571. if ($expenditureType == 6) {
  10572. $accountBank = 'ICBCDeposit';
  10573. $receivedBank = '纵横工行';
  10574. $dailyIncomeType = 9;
  10575. }
  10576. $accountBook = new accountBook ();
  10577. $accountBook->expensesType = 1;
  10578. $accountBook->accountType = $dailyIncomeType;
  10579. $accountBook->accountMsg = $expenditureMsg;
  10580. $accountBook->receivedPrice = $expenditurePrice;
  10581. $accountBook->receivedBank = $receivedBank;
  10582. $accountBook->receivedDate = $expenditureDate;
  10583. $accountBook->remarks = $remarks;
  10584. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10585. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10586. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10587. $id = $accountBook->insert ();
  10588. // 添加日常理财收入汇总
  10589. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  10590. $accountBookStatistics = new accountBookStatistics ();
  10591. $item = array (
  10592. 'date' => date ( "Y-m-d" ),
  10593. 'expenditureType' => $abDetail ['expenditureType'],
  10594. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10595. 'aid' => $abDetail ['aid'],
  10596. 'financingPrice' => $expenditurePrice,
  10597. 'expensesType' => 3
  10598. );
  10599. $accountBookStatistics->setAccountBookStatistics ( $item );
  10600. // 添加一笔收入流水
  10601. if ($expenditureMsg == '公司固定') {
  10602. $accountTypeWaste = 9;
  10603. } elseif ($expenditureMsg == '公司活期') {
  10604. $accountTypeWaste = 10;
  10605. } elseif ($expenditureMsg == '个人(GR)') {
  10606. $accountBank = 'PersonalDeposit';
  10607. }
  10608. $itemWaste = array (
  10609. 'expensesType' => 1,
  10610. 'accountType' => $accountTypeWaste,
  10611. 'accountPriceShow' => $expenditurePrice,
  10612. 'accountPrice' => $expenditurePrice,
  10613. 'dataID' => $id,
  10614. 'dailyIncomeType' => $dailyIncomeType,
  10615. 'accountBank' => $accountBank,
  10616. 'category' => $this->staff [0] ['category'],
  10617. 'cid' => $this->staff [0] ['cid'],
  10618. 'name' => $this->staff [0] ['username'],
  10619. 'sid' => $this->staff [0] ['sid'],
  10620. 'inputDate' => date ( "Y-m-d H:i:s" )
  10621. );
  10622. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10623. } else {
  10624. // 添加一笔日常支出
  10625. $accountBook = new accountBook ();
  10626. $accountBook->expensesType = 2;
  10627. $accountBook->expenditureType = $expenditureType;
  10628. $accountBook->expenditureMsg = $expenditureMsg;
  10629. $accountBook->expenditurePrice = $expenditurePrice;
  10630. $accountBook->expenditureBank = $expenditureBank;
  10631. $accountBook->expenditureDate = $expenditureDate;
  10632. $accountBook->remarks = $remarks;
  10633. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10634. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10635. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10636. $id = $accountBook->insert ();
  10637. // 添加日常支出汇总
  10638. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10639. $accountBookStatistics = new accountBookStatistics ();
  10640. $item = array (
  10641. 'date' => date ( "Y-m-d" ),
  10642. 'expenditureType' => $abDetail ['expenditureType'],
  10643. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10644. 'aid' => $abDetail ['aid'],
  10645. 'expensesType' => $abDetail ['expensesType']
  10646. );
  10647. if ($expenditureType == 5) {
  10648. $item += array (
  10649. 'payPrice' => - $abDetail ['expenditurePrice']
  10650. );
  10651. } else {
  10652. $item += array (
  10653. 'payPrice' => $abDetail ['expenditurePrice']
  10654. );
  10655. }
  10656. $accountBookStatistics->setAccountBookStatistics ( $item );
  10657. // 公司日常支出流水
  10658. $wasteBook = new wasteBook ();
  10659. $itemWaste = array (
  10660. 'accountPrice' => - $expenditurePrice
  10661. );
  10662. if ($expenditureBank == '个人广发') {
  10663. $itemWaste = array (
  10664. 'accountPrice' => $expenditurePrice
  10665. );
  10666. }
  10667. $itemWaste += array (
  10668. 'expensesType' => 2,
  10669. 'accountType' => 5,
  10670. 'accountPriceShow' => $expenditurePrice,
  10671. 'dataID' => $id,
  10672. 'dailyExpenditureType' => $expenditureType,
  10673. 'accountBank' => $accountBank,
  10674. 'category' => $this->staff [0] ['category'],
  10675. 'cid' => $this->staff [0] ['cid'],
  10676. 'name' => $this->staff [0] ['username'],
  10677. 'sid' => $this->staff [0] ['sid'],
  10678. 'inputDate' => date ( "Y-m-d H:i:s" )
  10679. );
  10680. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10681. }
  10682. }
  10683. return '/payments';
  10684. }
  10685. /**
  10686. * 添加支出
  10687. */
  10688. function paymentsExpenditureDo_() {
  10689. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10690. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10691. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10692. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10693. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10694. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10695. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10696. $dailyExpenditureType = '';
  10697. $accountTypeWaste = 5;
  10698. $accountBank = '';
  10699. if ($expenditureBank == '纵横广发') {
  10700. $accountBank = 'CGBDeposit';
  10701. } elseif ($expenditureBank == '纵横工行') {
  10702. $accountBank = 'ICBCDeposit';
  10703. } elseif ($expenditureBank == '华润银行') {
  10704. $accountBank = 'HUADeposit';
  10705. } elseif ($expenditureBank == '个人广发') {
  10706. $accountBank = 'PersonalDeposit';
  10707. }
  10708. if (empty ( $accountBank ))
  10709. die ( 'illegal request' );
  10710. $itemWaste = array (
  10711. 'accountPrice' => - $expenditurePrice
  10712. );
  10713. if ($expenditureBank == '个人广发') {
  10714. $itemWaste = array (
  10715. 'accountPrice' => $expenditurePrice
  10716. );
  10717. }
  10718. if ($expenditureType == 4 || $expenditureType == 6) {
  10719. $dailyExpenditureType = 4;
  10720. if ($expenditureMsg == '公司固定') {
  10721. $accountTypeWaste = 9;
  10722. } elseif ($expenditureMsg == '公司活期') {
  10723. $accountTypeWaste = 10;
  10724. } elseif ($expenditureMsg == '个人(GR)') {
  10725. $accountBank = 'PersonalDeposit';
  10726. }
  10727. $itemWaste = array (
  10728. 'accountPrice' => $expenditurePrice
  10729. );
  10730. } elseif ($expenditureType == 1) {
  10731. $dailyExpenditureType = 1;
  10732. } elseif ($expenditureType == 2) {
  10733. $dailyExpenditureType = 2;
  10734. } elseif ($expenditureType == 3) {
  10735. $dailyExpenditureType = 3;
  10736. } elseif ($expenditureType == 5) {
  10737. $dailyExpenditureType = 5;
  10738. }
  10739. if (empty ( $dailyExpenditureType ))
  10740. die ( 'illegal request' );
  10741. Doo::loadModel ( "accountBook" );
  10742. $accountBook = new accountBook ();
  10743. $accountBook->expenditureType = $expenditureType;
  10744. $accountBook->expenditureMsg = $expenditureMsg;
  10745. $accountBook->expenditurePrice = $expenditurePrice;
  10746. $accountBook->expenditureBank = $expenditureBank;
  10747. $accountBook->expenditureDate = $expenditureDate;
  10748. $accountBook->remarks = $remarks;
  10749. $accountBook->expensesType = 2;
  10750. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10751. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10752. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10753. $id = $accountBook->insert ();
  10754. //
  10755. $abDetail = $accountBook->getAccountBookByAid ( $id );
  10756. Doo::loadModel ( "accountBookStatistics" );
  10757. $accountBookStatistics = new accountBookStatistics ();
  10758. $item = array (
  10759. 'date' => date ( "Y-m-d" ),
  10760. 'expenditureType' => $abDetail ['expenditureType'],
  10761. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  10762. 'aid' => $abDetail ['aid']
  10763. );
  10764. if ($abDetail ['expensesType'] == 2) {
  10765. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  10766. $item += array (
  10767. 'financingPrice' => $expenditurePrice,
  10768. 'expensesType' => 3
  10769. );
  10770. } elseif ($abDetail ['expenditureType'] == 5) {
  10771. $item += array (
  10772. 'payPrice' => $abDetail ['expenditurePrice'],
  10773. 'expensesType' => $abDetail ['expensesType']
  10774. );
  10775. } else {
  10776. $item += array (
  10777. 'payPrice' => $abDetail ['expenditurePrice'],
  10778. 'expensesType' => $abDetail ['expensesType']
  10779. );
  10780. }
  10781. }
  10782. $accountBookStatistics->setAccountBookStatistics ( $item );
  10783. // 公司流水记录
  10784. Doo::loadModel ( 'wasteBook' );
  10785. $wasteBook = new wasteBook ();
  10786. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  10787. // 银行
  10788. if (empty ( $abDetail )) {
  10789. $itemWaste += array (
  10790. 'accountPriceShow' => $expenditurePrice,
  10791. 'dataID' => $id,
  10792. 'expensesType' => 2,
  10793. 'accountType' => $accountTypeWaste,
  10794. 'dailyExpenditureType' => $expenditureType,
  10795. 'accountBank' => $accountBank,
  10796. 'category' => $this->staff [0] ['category'],
  10797. 'cid' => $this->staff [0] ['cid'],
  10798. 'name' => $this->staff [0] ['username'],
  10799. 'sid' => $this->staff [0] ['sid'],
  10800. 'inputDate' => date ( "Y-m-d H:i:s" )
  10801. );
  10802. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10803. }
  10804. // 支出类型为4或者6 需要添加一笔收入和收入流水
  10805. if ($expenditureType == 4 || $expenditureType == 6) {
  10806. $accountBank = 'CGBDeposit';
  10807. $dailyIncomeType = 7;
  10808. $receivedBank = '纵横广发';
  10809. if ($expenditureType == 6) {
  10810. $accountBank = 'ICBCDeposit';
  10811. $receivedBank = '纵横工行';
  10812. $dailyIncomeType = 9;
  10813. }
  10814. // 添加一笔收入
  10815. $accountBook = new accountBook ();
  10816. $accountBook->accountType = $dailyIncomeType;
  10817. $accountBook->accountMsg = $expenditureMsg;
  10818. $accountBook->receivedPrice = $expenditurePrice;
  10819. $accountBook->receivedBank = $receivedBank;
  10820. $accountBook->receivedDate = $expenditureDate;
  10821. $accountBook->remarks = $remarks;
  10822. $accountBook->expensesType = 1;
  10823. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  10824. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  10825. $accountBook->inputStaff = $this->staff [0] ['sid'];
  10826. $id = $accountBook->insert ();
  10827. // 添加一笔收入流水
  10828. $itemWaste = array (
  10829. 'accountPriceShow' => $expenditurePrice,
  10830. 'accountPrice' => - $expenditurePrice,
  10831. 'dataID' => $id,
  10832. 'expensesType' => 1,
  10833. 'accountType' => $accountTypeWaste,
  10834. 'dailyIncomeType' => $dailyIncomeType,
  10835. 'accountBank' => $accountBank,
  10836. 'category' => $this->staff [0] ['category'],
  10837. 'cid' => $this->staff [0] ['cid'],
  10838. 'name' => $this->staff [0] ['username'],
  10839. 'sid' => $this->staff [0] ['sid'],
  10840. 'inputDate' => date ( "Y-m-d H:i:s" )
  10841. );
  10842. $wasteBook->setAccountBookStatistics ( $itemWaste );
  10843. }
  10844. }
  10845. return '/payments';
  10846. }
  10847. /**
  10848. * 所有收支
  10849. */
  10850. function paymentsAchieve() {
  10851. $page_size = 12;
  10852. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10853. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  10854. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10855. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  10856. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10857. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10858. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10859. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  10860. Doo::loadModel ( "accountBookStatistics" );
  10861. $accountBookStatistics = new accountBookStatistics ();
  10862. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  10863. $data ['statisticsList'] = $statisticsList;
  10864. Doo::loadModel ( "accountBook" );
  10865. $accountBook = new accountBook ();
  10866. $con = '';
  10867. if ($expensesType == 'INCOME')
  10868. $con = ' and expensesType=1 ';
  10869. elseif ($expensesType == 'PAY')
  10870. $con = ' and expensesType=2 ';
  10871. $dateArr = explode ( ':', $date );
  10872. $D1 = $dateString = '';
  10873. $D2 = '';
  10874. if (! empty ( $date )) {
  10875. $D1 = $dateArr [0];
  10876. if (isset ( $dateArr [1] ))
  10877. $D2 = $dateArr [1];
  10878. else
  10879. $D2 = '';
  10880. $dateString = $D1 . " : " . $D2;
  10881. }
  10882. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10883. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10884. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10885. $con .= ' and inputDate like "%' . $D1 . '%" ';
  10886. if (! empty ( $price ))
  10887. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  10888. if ($submitType == 1) {
  10889. if ($accountType != '') {
  10890. $expenditureType = '';
  10891. $con .= ' and accountType=' . $accountType;
  10892. if (! empty ( $accountMsg ))
  10893. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  10894. }
  10895. } elseif ($submitType == 2) {
  10896. if ($expenditureType != '') {
  10897. $accountType = $accountMsg = '';
  10898. $con .= ' and expenditureType=' . $expenditureType;
  10899. }
  10900. } else {
  10901. $accountType = $accountMsg = $expenditureType = '';
  10902. }
  10903. $sql = "" . $con;
  10904. $action = "paymentsAchieve";
  10905. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  10906. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  10907. $limit = $pageinfo ['lower'] . ',' . $page_size;
  10908. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  10909. $data ['expenditureType'] = $expenditureType;
  10910. $data ['accountMsg'] = $accountMsg;
  10911. $data ['accountType'] = $accountType;
  10912. $data ['inputDate'] = $date;
  10913. $data ['price'] = $price;
  10914. $data ['expensesType'] = $expensesType;
  10915. $data ['page'] = $pageinfo;
  10916. $data ['list'] = $list;
  10917. $data ['memu'] = "receipt";
  10918. $data ['staff'] = $this->staff;
  10919. $data ['receiptMemu'] = 'payments';
  10920. $data ['verifyId'] = $this->verifyId;
  10921. $data ['executeId'] = $this->executeId;
  10922. $this->render ( "/expenses/paymentsAchieve", $data );
  10923. }
  10924. function paymentsIncomeUpdateDo() {
  10925. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10926. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  10927. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  10928. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  10929. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  10930. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  10931. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  10932. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10933. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  10934. Doo::loadClass ( 'XDeode' );
  10935. $XDeode = new XDeode ( 5 );
  10936. $aid = $XDeode->decode ( $aidKey );
  10937. Doo::loadModel ( "accountBook" );
  10938. $accountBook = new accountBook ();
  10939. //
  10940. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10941. $price = $receivedPrice - $abDetail [inComePrice];
  10942. Doo::loadModel ( "accountBookStatistics" );
  10943. $accountBookStatistics = new accountBookStatistics ();
  10944. if ($abDetail ['accountType'] == 7) {
  10945. $item += array (
  10946. 'date' => date ( "Y-m-d" ),
  10947. 'financingPrice' => - $price,
  10948. 'expensesType' => 3,
  10949. 'aid' => $abDetail ['aid']
  10950. );
  10951. } elseif ($abDetail ['accountType'] == 8) {
  10952. $item += array (
  10953. 'date' => date ( "Y-m-d" ),
  10954. 'expensesType' => $abDetail ['expensesType'],
  10955. 'inComePrice' => - $price,
  10956. 'aid' => $abDetail ['aid']
  10957. );
  10958. } else {
  10959. $item = array (
  10960. 'date' => date ( "Y-m-d" ),
  10961. 'expensesType' => $abDetail ['expensesType'],
  10962. 'inComePrice' => $price,
  10963. 'aid' => $abDetail ['aid']
  10964. );
  10965. }
  10966. $accountBookStatistics->setAccountBookStatistics ( $item );
  10967. $accountBook->accountType = $accountType;
  10968. $accountBook->accountMsg = $accountMsg;
  10969. $accountBook->receivedPrice = $receivedPrice;
  10970. $accountBook->receivedMsg = $receivedMsg;
  10971. $accountBook->receivedBank = $receivedBank;
  10972. $accountBook->receivedDate = $receivedDate;
  10973. $accountBook->remarks = $remarks;
  10974. $accountBook->aid = $aid;
  10975. $accountBook->update ();
  10976. }
  10977. return '/paymentsAchieve';
  10978. }
  10979. function paymentsExpenditureEdiDo() {
  10980. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  10981. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  10982. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  10983. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  10984. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  10985. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  10986. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  10987. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  10988. Doo::loadClass ( 'XDeode' );
  10989. $XDeode = new XDeode ( 5 );
  10990. $aid = $XDeode->decode ( $aidKey );
  10991. Doo::loadModel ( "accountBook" );
  10992. $accountBook = new accountBook ();
  10993. // 汇总信息
  10994. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  10995. $price = $expenditurePrice - $abDetail [expenditurePrice];
  10996. Doo::loadModel ( "accountBookStatistics" );
  10997. $accountBookStatistics = new accountBookStatistics ();
  10998. if ($abDetail ['expenditureType'] == 4) {
  10999. $item += array (
  11000. 'date' => date ( "Y-m-d" ),
  11001. 'financingPrice' => $price,
  11002. 'expensesType' => 3,
  11003. 'aid' => $abDetail ['aid']
  11004. );
  11005. } elseif ($abDetail ['expenditureType'] == 5) {
  11006. $item += array (
  11007. 'date' => date ( "Y-m-d" ),
  11008. 'expensesType' => $abDetail ['expensesType'],
  11009. 'payPrice' => $price,
  11010. 'aid' => $abDetail ['aid']
  11011. );
  11012. } else {
  11013. $item = array (
  11014. 'date' => date ( "Y-m-d" ),
  11015. 'expensesType' => $abDetail ['expensesType'],
  11016. 'payPrice' => $price,
  11017. 'aid' => $abDetail ['aid']
  11018. );
  11019. }
  11020. $accountBookStatistics->setAccountBookStatistics ( $item );
  11021. //
  11022. $accountBook->expenditureType = $expenditureType;
  11023. $accountBook->expenditureMsg = $expenditureMsg;
  11024. $accountBook->expenditurePrice = $expenditurePrice;
  11025. $accountBook->expenditureBank = $expenditureBank;
  11026. $accountBook->remarks = $remarks;
  11027. $accountBook->expenditureDate = $expenditureDate;
  11028. $accountBook->aid = $aid;
  11029. $id = $accountBook->update ();
  11030. }
  11031. return '/paymentsAchieve';
  11032. }
  11033. function paymentsDelDo() {
  11034. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  11035. if (! empty ( $aidKey )) {
  11036. Doo::loadClass ( 'XDeode' );
  11037. $XDeode = new XDeode ( 5 );
  11038. $aid = $XDeode->decode ( $aidKey );
  11039. Doo::loadModel ( "accountBook" );
  11040. $accountBook = new accountBook ();
  11041. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  11042. if (empty ( $abDetail ))
  11043. die ( 'illegal request' );
  11044. // 删除收支
  11045. Doo::loadModel ( "accountBookStatistics" );
  11046. $accountBookStatistics = new accountBookStatistics ();
  11047. $item = array (
  11048. 'date' => date ( "Y-m-d" ),
  11049. 'aid' => $abDetail ['aid']
  11050. );
  11051. $accountType = '';
  11052. if ($abDetail ['expensesType'] == 1) {
  11053. $accountType = 6;
  11054. if ($abDetail ['accountType'] != 7) {
  11055. $item += array (
  11056. 'expensesType' => $abDetail ['expensesType'],
  11057. 'inComePrice' => - $abDetail ['receivedPrice']
  11058. );
  11059. } else {
  11060. $item += array (
  11061. 'financingPrice' => $abDetail ['receivedPrice'],
  11062. 'expensesType' => 3
  11063. );
  11064. }
  11065. } elseif ($abDetail ['expensesType'] == 2) {
  11066. $accountType = 5;
  11067. if ($abDetail ['accountType'] != 7) {
  11068. $item += array (
  11069. 'expensesType' => $abDetail ['expensesType'],
  11070. 'payPrice' => - $abDetail ['expenditurePrice']
  11071. );
  11072. } else {
  11073. $item += array (
  11074. 'financingPrice' => - $abDetail ['expenditurePrice'],
  11075. 'expensesType' => 3
  11076. );
  11077. }
  11078. }
  11079. if (($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) && $abDetail ['expensesType'] == 2) {
  11080. if ($abDetail ['expenditureMsg'] == '公司固定')
  11081. $accountType = 9;
  11082. elseif ($abDetail ['expenditureMsg'] == '公司活期')
  11083. $accountType = 10;
  11084. }
  11085. if (($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) && $abDetail ['expensesType'] == 1) {
  11086. if ($abDetail ['accountMsg'] == '公司固定')
  11087. $accountType = 9;
  11088. elseif ($abDetail ['accountMsg'] == '公司活期')
  11089. $accountType = 10;
  11090. }
  11091. if ($abDetail ['accountMsg'] == '活期理财收益') {
  11092. $accountType = 10;
  11093. }
  11094. $accountBookStatistics->setAccountBookStatistics ( $item );
  11095. $accountBook->delete ( array (
  11096. 'where' => 'aid=' . $aid,
  11097. 'limit' => 1
  11098. ) );
  11099. // 删除收入流水
  11100. if (! empty ( $accountType )) {
  11101. Doo::loadModel ( 'wasteBook' );
  11102. $wasteBook = new wasteBook ();
  11103. $wasteBook->delete ( array (
  11104. 'where' => 'dataID=' . $aid . ' and accountType=' . $accountType,
  11105. 'limit' => 1
  11106. ) );
  11107. }
  11108. }
  11109. return '/paymentsAchieve';
  11110. }
  11111. function paymentsCollect() {
  11112. Doo::loadModel ( "execute" );
  11113. $execute = new execute ();
  11114. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11115. die ( 'illegal request' );
  11116. }
  11117. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11118. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  11119. Doo::loadModel ( "accountBookStatistics" );
  11120. $accountBookStatistics = new accountBookStatistics ();
  11121. Doo::loadClass ( 'receipt.func' );
  11122. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  11123. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  11124. $data ['html'] = $html ['html'];
  11125. $data ['inSum'] = $html ['sum'];
  11126. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  11127. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  11128. $data ['payHtml'] = $html ['html'];
  11129. $data ['paySum'] = $html ['sum'];
  11130. // 余额统计
  11131. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  11132. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  11133. include './protected/config/wasteBook.conf.php';
  11134. Doo::loadModel ( 'wasteBook' );
  11135. $wasteBook = new wasteBook ();
  11136. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  11137. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  11138. // 获得年份之前所有金额
  11139. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  11140. // print_r($detail);
  11141. // $waste['total'];
  11142. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  11143. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11144. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11145. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11146. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  11147. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11148. $limitMonth = date ( 'm' ); // 限制显示月份参数
  11149. if (date ( 'Y' ) > $year) {
  11150. $limitMonth = 12;
  11151. }
  11152. for($i = 1; $i <= 12; $i ++) {
  11153. $inComeA = $payB = 0;
  11154. $falg = true;
  11155. foreach ( $inComePay as $key => $value ) {
  11156. if ($value ['month'] == $i) {
  11157. $falg = false;
  11158. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11159. $inSum += $value ['accountPrice'];
  11160. $showInSum += $value ['accountPriceShow'];
  11161. $inComeA = $value ['accountPrice'];
  11162. break;
  11163. }
  11164. }
  11165. if ($falg)
  11166. $inComeHtml .= '<td class="taR">-</td>';
  11167. $payFalg = true;
  11168. foreach ( $pay as $key => $value ) {
  11169. if ($value ['month'] == $i) {
  11170. $payFalg = false;
  11171. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11172. $paySum += $value ['accountPrice'];
  11173. $showPaySum += $value ['accountPriceShow'];
  11174. $payB = $value ['accountPrice'];
  11175. break;
  11176. }
  11177. }
  11178. if ($payFalg)
  11179. $payHtml .= '<td class="taR">-</td>';
  11180. if (empty ( $balanceC ) || $limitMonth < $i)
  11181. $lastBalanceHtml .= '<td class="taR">-</td>';
  11182. else
  11183. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11184. $balanceC = $balanceC + $inComeA + $payB;
  11185. $balanceSum += $balanceC;
  11186. if (empty ( $balanceC ) || $limitMonth < $i)
  11187. $BalanceHtml .= '<td class="taR">-</td>';
  11188. else
  11189. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11190. // 余额统计
  11191. }
  11192. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11193. $data ['inComeHtml'] = $inComeHtml;
  11194. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11195. $data ['payBalanceHtml'] = $payHtml;
  11196. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11197. $data ['BalanceHtml'] = $BalanceHtml;
  11198. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11199. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11200. $mothHtml = "";
  11201. for($i = 1; $i <= 12; $i ++) {
  11202. if ($moth == $i)
  11203. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11204. else
  11205. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11206. }
  11207. $data ['mothHtml'] = $mothHtml;
  11208. $dateHtml = "";
  11209. $now = date ( "Y" );
  11210. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11211. if ($YEARD <= $now) {
  11212. $dateHtml .= '<option ';
  11213. if ($year == $YEARD) {
  11214. $dateHtml .= 'selected ';
  11215. }
  11216. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11217. }
  11218. }
  11219. $data ['dateHtml'] = $dateHtml;
  11220. $data ['year'] = $year;
  11221. $data ['memu'] = "receipt";
  11222. $data ['staff'] = $this->staff;
  11223. $data ['receiptMemu'] = 'paymentsCollect';
  11224. $data ['verifyId'] = $this->verifyId;
  11225. $data ['executeId'] = $this->executeId;
  11226. $this->render ( "/expenses/paymentsCollect", $data );
  11227. }
  11228. function paymentsCollectDay() {
  11229. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  11230. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  11231. if (empty ( $moth ))
  11232. return 'paymentsCollect';
  11233. Doo::loadModel ( "accountBookStatistics" );
  11234. $accountBookStatistics = new accountBookStatistics ();
  11235. $i = 2;
  11236. $y = 2013;
  11237. $day = date ( "t", strtotime ( "$year-$moth" ) );
  11238. Doo::loadClass ( 'receipt.func' );
  11239. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  11240. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  11241. $data ['html'] = $html ['html'];
  11242. $data ['inSum'] = $html ['sum'];
  11243. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  11244. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  11245. $data ['payHtml'] = $html ['html'];
  11246. $data ['paySum'] = $html ['sum'];
  11247. $mothHtml = "";
  11248. for($i = 1; $i <= 12; $i ++) {
  11249. if ($moth == $i)
  11250. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  11251. else
  11252. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  11253. }
  11254. $data ['mothHtml'] = $mothHtml;
  11255. $data ['year'] = $year;
  11256. // 余额
  11257. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  11258. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  11259. include './protected/config/wasteBook.conf.php';
  11260. Doo::loadModel ( 'wasteBook' );
  11261. $wasteBook = new wasteBook ();
  11262. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  11263. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  11264. // 获得年份之前所有金额
  11265. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  11266. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  11267. $inComeHtml = '<tr><th colspan="2">收入</th>';
  11268. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  11269. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  11270. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  11271. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  11272. // $balanceC = 0;
  11273. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  11274. $limitDay = date ( 'd' );
  11275. $monthLK = ( int ) date ( 'm' );
  11276. if (date ( 'Y' ) > $year) {
  11277. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  11278. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  11279. $limitDay = 0;
  11280. }
  11281. for($i = 1; $i <= $day; $i ++) {
  11282. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  11283. $inComeA = $payB = 0;
  11284. $falg = true;
  11285. foreach ( $inComePay as $key => $value ) {
  11286. if ($value ['day'] == $i) {
  11287. $falg = false;
  11288. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11289. $inSum += $value ['accountPrice'];
  11290. $showInSum += $value ['accountPriceShow'];
  11291. $inComeA = $value ['accountPrice'];
  11292. break;
  11293. }
  11294. }
  11295. if ($falg)
  11296. $inComeHtml .= '<td class="taR">-</td>';
  11297. $payFalg = true;
  11298. foreach ( $pay as $key => $value ) {
  11299. if ($value ['day'] == $i) {
  11300. $payFalg = false;
  11301. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  11302. $paySum += $value ['accountPrice'];
  11303. $showPaySum += $value ['accountPriceShow'];
  11304. $payB = $value ['accountPrice'];
  11305. break;
  11306. }
  11307. }
  11308. if ($payFalg)
  11309. $payHtml .= '<td class="taR">-</td>';
  11310. if (empty ( $balanceC ) || $limitDay < $i)
  11311. $lastBalanceHtml .= '<td class="taR">-</td>';
  11312. else
  11313. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11314. $balanceC = $balanceC + $inComeA + $payB;
  11315. $balanceSum += $balanceC;
  11316. if (empty ( $balanceC ) || $limitDay < $i)
  11317. $BalanceHtml .= '<td class="taR">-</td>';
  11318. else
  11319. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  11320. }
  11321. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  11322. $data ['inComeHtml'] = $inComeHtml;
  11323. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  11324. $data ['payBalanceHtml'] = $payHtml;
  11325. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  11326. $data ['BalanceHtml'] = $BalanceHtml;
  11327. $dayHtml .= '<td class="taR ">总计</td></tr>';
  11328. $data ['dayHtml'] = $dayHtml;
  11329. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  11330. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  11331. $dateHtml = "";
  11332. $now = date ( "Y" );
  11333. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  11334. if ($YEARD <= $now) {
  11335. $dateHtml .= '<option ';
  11336. if ($year == $YEARD) {
  11337. $dateHtml .= 'selected ';
  11338. }
  11339. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  11340. }
  11341. }
  11342. $data ['dateHtml'] = $dateHtml;
  11343. $data ['memu'] = "receipt";
  11344. $data ['staff'] = $this->staff;
  11345. $data ['receiptMemu'] = 'paymentsCollect';
  11346. $data ['verifyId'] = $this->verifyId;
  11347. $data ['executeId'] = $this->executeId;
  11348. $this->render ( "/expenses/paymentsCollectDay", $data );
  11349. }
  11350. // 公司流水
  11351. function wasteBook() {
  11352. Doo::loadModel ( "execute" );
  11353. $execute = new execute ();
  11354. if (! $execute->isPaymentsShow ( $this->staff [0] ['sid'] )) {
  11355. die ( 'illegal request' );
  11356. }
  11357. include './protected/config/wasteBook.conf.php';
  11358. Doo::loadModel ( 'wasteBook' );
  11359. $wasteBook = new wasteBook ();
  11360. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  11361. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  11362. $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'];
  11363. // print_r($waste);
  11364. $data ['waste'] = $waste;
  11365. $data ['total'] = $total;
  11366. // 月流水数据结构
  11367. $monthStatistics = array ();
  11368. $incomeMothStatistics = array ();
  11369. $expenditureMothStatistics = array ();
  11370. for($i = 1; $i <= 12; $i ++) {
  11371. $month = date ( 'Y' ) . '-' . $i;
  11372. if ($i < 10)
  11373. $month = date ( 'Y' ) . '-0' . $i;
  11374. array_push ( $monthStatistics, $month );
  11375. }
  11376. foreach ( $monthStatistics as $value ) {
  11377. $falg = true;
  11378. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  11379. if ($value == $v ['inputDate']) {
  11380. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  11381. $falg = false;
  11382. }
  11383. }
  11384. if ($falg) {
  11385. array_push ( $incomeMothStatistics, '' );
  11386. }
  11387. $falgEx = true;
  11388. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  11389. if ($value == $v ['inputDate']) {
  11390. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  11391. $falg = false;
  11392. }
  11393. }
  11394. if ($falgEx) {
  11395. array_push ( $expenditureMothStatistics, '' );
  11396. }
  11397. }
  11398. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  11399. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  11400. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  11401. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  11402. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  11403. // print_r($incomeList);
  11404. $data ['expenditureList'] = $expenditureList;
  11405. $data ['incomeList'] = $incomeList;
  11406. $data ['memu'] = "receipt";
  11407. $data ['staff'] = $this->staff;
  11408. $data ['receiptMemu'] = 'wasteBook';
  11409. $data ['verifyId'] = $this->verifyId;
  11410. $data ['executeId'] = $this->executeId;
  11411. $this->render ( "/expenses/wasteBook", $data );
  11412. }
  11413. function wasteBookIncome() {
  11414. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11415. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11416. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11417. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  11418. $data ['dailyIncomeType'] = $dailyIncomeType;
  11419. Doo::loadModel ( 'wasteBook' );
  11420. $wasteBook = new wasteBook ();
  11421. Doo::loadModel ( 'L_category' );
  11422. $L_category = new L_category ();
  11423. Doo::loadClass ( 'XDeode' );
  11424. $XDeode = new XDeode ( 5 );
  11425. // echo $XDeode->encode(1).'<br>';
  11426. // echo $XDeode->encode(2).'<br>';
  11427. // echo $XDeode->encode(3).'<br>';
  11428. // echo $XDeode->encode(4).'<br>';
  11429. // echo $XDeode->encode(5).'<br>';
  11430. // echo $XDeode->encode(6).'<br>';
  11431. // echo $XDeode->encode(7).'<br>';
  11432. // echo $XDeode->encode(8).'<br>';
  11433. // echo $XDeode->encode(9).'<br>';
  11434. // echo $XDeode->encode(10).'<br>';
  11435. $dateArr = explode ( ':', $date );
  11436. $D1 = '';
  11437. $D2 = '';
  11438. $con = '';
  11439. if (! empty ( $date )) {
  11440. $D1 = $dateArr [0];
  11441. $D2 = $dateArr [1];
  11442. }
  11443. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11444. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11445. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11446. $con = ' and inputDate = "' . $D1 . '"';
  11447. if ($cid != 'ALL') {
  11448. $cid = $XDeode->decode ( $cid );
  11449. $con .= ' and cid = "' . $cid . '"';
  11450. }
  11451. if ($accountType != 'ALL') {
  11452. if ($accountType == 'INVOICE') {
  11453. $con .= ' and (accountType = 7 or accountType = 8)';
  11454. } elseif ($accountType == 'PAYMENTS') {
  11455. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  11456. if ($dailyIncomeType != 'ALL') {
  11457. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  11458. $con .= ' and dailyIncomeType = ' . $dailyIncomeType;
  11459. }
  11460. }
  11461. }
  11462. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  11463. $sum = 0;
  11464. foreach ( $incomeList as $key => $value ) {
  11465. $sum += $value ['accountPrice'];
  11466. }
  11467. // print_r($incomeList);
  11468. // 获得办事和部门
  11469. $categoryList = $L_category->getCategory ();
  11470. $data ['accountType'] = $accountType;
  11471. $data ['cid'] = $cid;
  11472. $data ['categoryList'] = $categoryList;
  11473. $data ['sum'] = $sum;
  11474. $data ['incomeList'] = $incomeList;
  11475. $data ['inputDate'] = $date;
  11476. $data ['memu'] = "receipt";
  11477. $data ['staff'] = $this->staff;
  11478. $data ['receiptMemu'] = 'wasteBook';
  11479. $data ['verifyId'] = $this->verifyId;
  11480. $data ['executeId'] = $this->executeId;
  11481. $this->render ( "/expenses/wasteBookIncome", $data );
  11482. }
  11483. /**
  11484. * 所有支出
  11485. */
  11486. function wasteBookExpenditure() {
  11487. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  11488. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  11489. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  11490. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  11491. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  11492. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  11493. $data ['receiptType'] = $receiptType;
  11494. Doo::loadModel ( 'wasteBook' );
  11495. $wasteBook = new wasteBook ();
  11496. Doo::loadModel ( 'L_category' );
  11497. $L_category = new L_category ();
  11498. Doo::loadClass ( 'XDeode' );
  11499. $XDeode = new XDeode ( 5 );
  11500. $dateArr = explode ( ':', $date );
  11501. $D1 = '';
  11502. $D2 = '';
  11503. $con = '';
  11504. if (! empty ( $date )) {
  11505. $D1 = $dateArr [0];
  11506. $D2 = $dateArr [1];
  11507. }
  11508. if (! empty ( $D1 ) && ! empty ( $D2 ))
  11509. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  11510. elseif (! empty ( $D1 ) && empty ( $D2 ))
  11511. $con = ' and inputDate = "' . $D1 . '"';
  11512. if ($cid != 'ALL') {
  11513. $cid = $XDeode->decode ( $cid );
  11514. $con .= ' and cid = "' . $cid . '"';
  11515. }
  11516. if ($accountType != 'ALL') {
  11517. if ($accountType == 'INVOICE') {
  11518. $con .= ' and accountType = 11';
  11519. } elseif ($accountType == 'PAYMENTS') {
  11520. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  11521. if ($dailyExpenditureType != 'ALL') {
  11522. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  11523. $con .= ' and dailyExpenditureType = ' . $dailyExpenditureType;
  11524. }
  11525. } elseif ($accountType == 'RECEIPT') {
  11526. if ($receiptType == 'ALL') {
  11527. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  11528. } else {
  11529. $receiptType = $XDeode->decode ( $receiptType );
  11530. echo $receiptType;
  11531. if ($receiptType == 1) {
  11532. $con .= ' and (accountType = 1 or accountType=2)';
  11533. } else {
  11534. $con .= ' and accountType = ' . $receiptType;
  11535. }
  11536. }
  11537. }
  11538. }
  11539. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  11540. $sum = 0;
  11541. foreach ( $incomeList as $key => $value ) {
  11542. $sum += $value ['accountPriceShow'];
  11543. }
  11544. // print_r($incomeList);
  11545. // 获得办事和部门
  11546. $categoryList = $L_category->getCategory ();
  11547. $data ['accountType'] = $accountType;
  11548. $data ['cid'] = $cid;
  11549. $data ['categoryList'] = $categoryList;
  11550. $data ['sum'] = $sum;
  11551. $data ['incomeList'] = $incomeList;
  11552. $data ['inputDate'] = $date;
  11553. $data ['memu'] = "receipt";
  11554. $data ['staff'] = $this->staff;
  11555. $data ['receiptMemu'] = 'wasteBook';
  11556. $data ['verifyId'] = $this->verifyId;
  11557. $data ['executeId'] = $this->executeId;
  11558. $this->render ( "/expenses/wasteBookExpenditure", $data );
  11559. }
  11560. function ajaxGetWasteinvoiceReceivables() {
  11561. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11562. Doo::loadClass ( 'XDeode' );
  11563. $XDeode = new XDeode ( 5 );
  11564. $irid = $XDeode->decode ( $serial );
  11565. Doo::loadModel ( 'invoiceReceivables' );
  11566. $invoiceReceivables = new invoiceReceivables ();
  11567. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  11568. echo json_encode ( array (
  11569. 'status' => 1,
  11570. 'detail' => $detail
  11571. ) );
  11572. }
  11573. function ajaxGetPaymentsByAid() {
  11574. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11575. Doo::loadModel ( "accountBook" );
  11576. $accountBook = new accountBook ();
  11577. $detail = $accountBook->getAccountBookByAid ( $serial );
  11578. echo json_encode ( array (
  11579. 'status' => 1,
  11580. 'detail' => $detail
  11581. ) );
  11582. }
  11583. function ajaxGetWasteInvoice() {
  11584. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11585. Doo::loadModel ( 'invoice' );
  11586. $invoice = new invoice ();
  11587. Doo::loadModel ( 'invoiceReceivables' );
  11588. $invoiceReceivables = new invoiceReceivables ();
  11589. $detail = $invoice->getInvoiceByIid ( $serial );
  11590. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  11591. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  11592. echo json_encode ( array (
  11593. 'status' => 1,
  11594. 'detail' => $detail
  11595. ) );
  11596. }
  11597. /**
  11598. */
  11599. function ajaxGetWasteReceipt() {
  11600. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  11601. Doo::loadModel ( 'receipt' );
  11602. $receipt = new receipt ();
  11603. Doo::loadClass ( 'XDeode' );
  11604. $XDeode = new XDeode ( 5 );
  11605. $rid = $XDeode->decode ( $serial );
  11606. // 获得个数据
  11607. $detail = $receipt->getReceiptByRid ( $rid );
  11608. // 初始化
  11609. $detail ['reviseDetail'] = array ();
  11610. if (! empty ( $value ['reviseDetail'] ))
  11611. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  11612. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  11613. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  11614. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  11615. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  11616. // 获得费用html
  11617. $html = $this->getWasteReceiptHtml ( $detail );
  11618. // 获得费用审批人数据
  11619. $detail = $this->getReceiptApproverHtml ( $detail );
  11620. // 审批执行
  11621. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11622. <th class="taC" width="90">审批人</th>
  11623. <th class="taC">审批意见</th></tr>';
  11624. foreach ( $detail ['verifyList'] as $key => $value ) {
  11625. $html .= '<tr>
  11626. <td>' . $value [1] . '</td>
  11627. <td>' . $value ['opinion'] . '</td>
  11628. </tr>
  11629. ';
  11630. }
  11631. $html .= ' </tbody></table>';
  11632. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  11633. <th class="taC" width="90">执行人</th>
  11634. <th class="taC">执行意见</th></tr>';
  11635. foreach ( $detail ['executeCopy'] as $key => $value ) {
  11636. $html .= '<tr>
  11637. <td>' . $value [1] . '</td>
  11638. <td>' . $value ['opinion'] . '</td>
  11639. </tr>
  11640. ';
  11641. }
  11642. $html .= ' </tbody></table>';
  11643. $html .= '<table class="table table-bordered table-condensed">
  11644. <tr class="warning">
  11645. <td class="taR"><b>汇款金额</b></td>
  11646. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  11647. </tr>
  11648. </table>';
  11649. // print_r($detail['verifyList']);
  11650. // header ( 'Content-Type:text/html;charset=utf-8' );
  11651. // echo $html;
  11652. echo json_encode ( array (
  11653. 'status' => 1,
  11654. 'html' => $html,
  11655. 'detail' => $detail
  11656. ) );
  11657. }
  11658. function getReceiptApproverHtml($detail = array()) {
  11659. Doo::loadModel ( 'loanReceipt' );
  11660. $loanReceipt = new loanReceipt ();
  11661. Doo::loadModel ( 'verify' );
  11662. $verify = new verify ();
  11663. Doo::loadModel ( 'staff' );
  11664. $staff = new staff ();
  11665. if (empty ( $detail ))
  11666. return array ();
  11667. $loanList = $loanReceipt->getOne ( array (
  11668. 'where' => 'rid=' . $detail ['loanRid'],
  11669. 'desc' => 'rid',
  11670. 'asArray' => true
  11671. ) );
  11672. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  11673. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  11674. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  11675. else
  11676. $verifyList ['staff'] = $detail ['verifyBreakup'];
  11677. } else
  11678. $verifyList = $verify->getOne ( array (
  11679. 'where' => 'vid=' . $detail ['verify'],
  11680. 'asArray' => true
  11681. ) );
  11682. $verifyList = json_decode ( $verifyList ['staff'], true );
  11683. Doo::loadModel ( 'role' );
  11684. $role = new role ();
  11685. $roleId = 0;
  11686. $flag = true;
  11687. $roleKey = 0;
  11688. $endStaffArray = array ();
  11689. $roleArrayCopy = array ();
  11690. foreach ( $verifyList as $k => $v ) {
  11691. // init verifyStaff
  11692. if ($v [1] == 'ROLE') {
  11693. if (! empty ( $verifyStaff )) {
  11694. $endStaffArray = end ( $verifyStaff );
  11695. }
  11696. $roleVerify = json_decode ( $v [3], true );
  11697. $roleKey = $k;
  11698. $roleArray = array ();
  11699. $rolename = $role->getOne ( array (
  11700. 'where' => 'rid=' . $v [0],
  11701. 'asArray' => true
  11702. ) );
  11703. foreach ( $roleVerify as $o => $p ) {
  11704. $staffID = explode ( '_', $p );
  11705. $staffInfo = $staff->getOne ( array (
  11706. 'where' => 'sid=' . $staffID [0],
  11707. 'asArray' => true
  11708. ) );
  11709. // print_r($staffID);
  11710. $exp = array (
  11711. 0 => $staffInfo ['sid'],
  11712. 1 => $staffID [1],
  11713. 2 => $staffInfo ['avatar'],
  11714. 'date' => '',
  11715. 'date' => '',
  11716. 'opinion' => '',
  11717. 'status' => '',
  11718. 'rolename' => $rolename ['name']
  11719. );
  11720. array_push ( $roleArray, $exp );
  11721. }
  11722. $roleArrayCopy [$v [0]] = $roleArray;
  11723. // $verifyList[$k]['roleArray']=$roleArray;
  11724. }
  11725. $verifyList [$k] ['date'] = "";
  11726. $verifyList [$k] ['opinion'] = "";
  11727. $verifyList [$k] ['status'] = "";
  11728. if (empty ( $verifyStaff )) {
  11729. $verifyList [$k] ['date'] = "";
  11730. $verifyList [$k] ['opinion'] = "";
  11731. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  11732. $verifyList [$k] ['status'] = 4;
  11733. $flag = false;
  11734. }
  11735. } else {
  11736. foreach ( $verifyStaff as $m => $u ) {
  11737. if ($v [0] == $m) {
  11738. $verifyList [$k] ['date'] = $u ['date'];
  11739. $verifyList [$k] ['opinion'] = $u ['opinion'];
  11740. $verifyList [$k] ['status'] = $u ['status'];
  11741. $flag = false;
  11742. break;
  11743. }
  11744. }
  11745. $endStaffArray = end ( $verifyStaff );
  11746. }
  11747. }
  11748. $rolename ['name'] = '';
  11749. if (! empty ( $roleId )) {
  11750. Doo::loadModel ( 'role' );
  11751. $role = new role ();
  11752. $rolename = $role->getOne ( array (
  11753. 'where' => 'rid=' . $roleId,
  11754. 'asArray' => true
  11755. ) );
  11756. }
  11757. if (! empty ( $verifyStaff ))
  11758. $endStaffArray = end ( $verifyStaff );
  11759. $KOP = false;
  11760. foreach ( $roleArrayCopy as $P => $A ) {
  11761. foreach ( $A as $MKI => $AVL ) {
  11762. if (! empty ( $verifyStaff )) {
  11763. // &&$rolename['rid']==$endStaffArray['nextStaff']
  11764. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  11765. $button = 4;
  11766. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11767. }
  11768. foreach ( $verifyStaff as $m => $u ) {
  11769. $AVLFK = $AVL [0] . '_R';
  11770. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  11771. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  11772. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  11773. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  11774. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  11775. break;
  11776. }
  11777. }
  11778. } else {
  11779. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  11780. $button = 4;
  11781. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  11782. }
  11783. }
  11784. // $roleArray[$MKI]['rolename']=$rolename['name'];
  11785. $KOP = true;
  11786. }
  11787. }
  11788. foreach ( $roleArrayCopy as $k => $v ) {
  11789. foreach ( $verifyList as $m => $n ) {
  11790. if ($n [0] == $k) {
  11791. array_splice ( $verifyList, $m, 1, $v );
  11792. }
  11793. }
  11794. }
  11795. // 费用执行人相关数据
  11796. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  11797. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  11798. foreach ( $executeCopy as $k => $v ) {
  11799. $executeCopy [$k] ['date'] = '';
  11800. $executeCopy [$k] ['opinion'] = '';
  11801. $executeCopy [$k] ['status'] = '';
  11802. if (! empty ( $executeStaff ))
  11803. foreach ( $executeStaff as $m => $u ) {
  11804. if ($v [0] == $m) {
  11805. $executeCopy [$k] ['date'] = $u ['date'];
  11806. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  11807. $executeCopy [$k] ['status'] = $u ['status'];
  11808. break;
  11809. }
  11810. }
  11811. }
  11812. $detail ['executeCopy'] = $executeCopy;
  11813. $detail ['verifyList'] = $verifyList;
  11814. return $detail;
  11815. }
  11816. function getWasteReceiptHtml($detail = array()) {
  11817. if (empty ( $detail ))
  11818. return '';
  11819. $html = '';
  11820. if ($detail ['Rtype'] == 0) { // 报销单
  11821. $html .= '
  11822. <table class="table table-bordered table-condensed">
  11823. <tbody>
  11824. <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'] ['agencySum'] . '</td>
  11838. </tr>';
  11839. $html .= '<tr>
  11840. <th colspan="2" class="taC">差旅相关费用</th>
  11841. </tr>';
  11842. foreach ( $detail ['accountItem'] ['差旅相关费用'] 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 ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11853. </tr>';
  11854. $html .= '<tr>
  11855. <th colspan="2" class="taC">培训班费用</th>
  11856. </tr>';
  11857. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11858. $html .= '
  11859. <tr>
  11860. <th>' . $value ['name'] . '</th>
  11861. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11862. </tr>';
  11863. }
  11864. $html .= '
  11865. <tr>
  11866. <th class="taR">合计</th>
  11867. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11868. </tr>';
  11869. $html .= '<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'] ['otherSum'] . '</td>
  11883. </tr>';
  11884. $html .= '<tr>
  11885. <th colspan="2" class="taC">报销金额调整</th>
  11886. </tr>';
  11887. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  11888. $html .= '
  11889. <tr>
  11890. <th>' . $value ['name'] . '</th>
  11891. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11892. </tr>';
  11893. }
  11894. $html .= '
  11895. <tr>
  11896. <th class="taR">合计</th>
  11897. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  11898. </tr>';
  11899. $html .= '
  11900. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11901. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11902. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11903. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11904. <tr class="warning">
  11905. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11906. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11907. </tr>
  11908. </tbody>
  11909. </table>';
  11910. } elseif ($detail ['Rtype'] == 2) {
  11911. $html .= '
  11912. <table class="table table-bordered table-condensed">
  11913. <tbody>
  11914. <tr>
  11915. <th colspan="2" class="taC">办事处相关费用</th>
  11916. </tr>';
  11917. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11918. $html .= '
  11919. <tr>
  11920. <th>' . $value ['name'] . '</th>
  11921. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11922. </tr>';
  11923. }
  11924. $html .= '
  11925. <tr>
  11926. <th class="taR">合计</th>
  11927. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11928. </tr>';
  11929. $html .= '
  11930. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  11931. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  11932. <tr><th class="taC" colspan="2">报销说明</th></tr>
  11933. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  11934. <tr class="warning">
  11935. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  11936. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  11937. </tr>
  11938. </tbody>
  11939. </table>';
  11940. } elseif ($detail ['Rtype'] == 1) {
  11941. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  11942. $html .= '<table class="table table-bordered table-condensed">
  11943. <tbody>
  11944. <tr>
  11945. <th colspan="2" class="taC">日常相关费用</th>
  11946. </tr>';
  11947. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  11948. $html .= '
  11949. <tr>
  11950. <th>' . $value ['name'] . '</th>
  11951. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11952. </tr>';
  11953. }
  11954. $html .= '
  11955. <tr>
  11956. <th class="taR">合计</th>
  11957. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  11958. </tr>';
  11959. $html .= '<tr>
  11960. <th colspan="2" class="taC">差旅相关费用</th>
  11961. </tr>';
  11962. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  11963. $html .= '
  11964. <tr>
  11965. <th>' . $value ['name'] . '</th>
  11966. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11967. </tr>';
  11968. }
  11969. $html .= '
  11970. <tr>
  11971. <th class="taR">合计</th>
  11972. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  11973. </tr>';
  11974. $html .= '<tr>
  11975. <th colspan="2" class="taC">培训班费用</th>
  11976. </tr>';
  11977. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  11978. $html .= '
  11979. <tr>
  11980. <th>' . $value ['name'] . '</th>
  11981. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11982. </tr>';
  11983. }
  11984. $html .= '
  11985. <tr>
  11986. <th class="taR">合计</th>
  11987. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  11988. </tr>';
  11989. $html .= '<tr>
  11990. <th colspan="2" class="taC">其他</th>
  11991. </tr>';
  11992. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  11993. $html .= '
  11994. <tr>
  11995. <th>' . $value ['name'] . '</th>
  11996. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  11997. </tr>';
  11998. }
  11999. $html .= '
  12000. <tr>
  12001. <th class="taR">合计</th>
  12002. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  12003. </tr>';
  12004. $html .= '<tr>
  12005. <th colspan="2" class="taC">报销金额调整</th>
  12006. </tr>';
  12007. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  12008. $html .= '
  12009. <tr>
  12010. <th>' . $value ['name'] . '</th>
  12011. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12012. </tr>';
  12013. }
  12014. $html .= '
  12015. <tr>
  12016. <th class="taR">合计</th>
  12017. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  12018. </tr>';
  12019. $html .= '
  12020. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  12021. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  12022. <tr><th class="taC" colspan="2">报销说明</th></tr>
  12023. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  12024. <tr class="warning">
  12025. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  12026. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  12027. </tr>
  12028. </tbody>
  12029. </table>';
  12030. }
  12031. Doo::loadModel ( 'loanReceipt' );
  12032. $loanReceipt = new loanReceipt ();
  12033. $loanList = $loanReceipt->getOne ( array (
  12034. 'where' => 'rid=' . $detail ['loanRid'],
  12035. 'desc' => 'rid',
  12036. 'asArray' => true
  12037. ) );
  12038. // print_r($loanList);
  12039. $html .= '<table class="table table-bordered table-condensed">
  12040. <tbody>
  12041. <tr>
  12042. <th colspan="2" class="taC">借款费用</th>
  12043. </tr>';
  12044. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  12045. $html .= '<tr>
  12046. <th>' . $value ['name'] . '</th>
  12047. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  12048. </tr>';
  12049. }
  12050. $html .= '<tr>
  12051. <th class="taC" colspan="2">产生费用所在办事处</th>
  12052. </tr>
  12053. <tr>
  12054. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  12055. </tr>
  12056. <tr>
  12057. <th class="taC" colspan="2">费用说明</th>
  12058. </tr>
  12059. <tr>
  12060. <td colspan="2">' . $loanList ['explanation'] . '</td>
  12061. </tr>
  12062. <tr class="warning">
  12063. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  12064. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  12065. </tr>
  12066. </tbody>
  12067. </table>
  12068. ';
  12069. }
  12070. return $html;
  12071. }
  12072. /**
  12073. * 计算流水
  12074. */
  12075. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  12076. $bakWaste ['bank'] = array (
  12077. 'CGBDeposit' => 0,
  12078. 'ICBCDeposit' => 0,
  12079. 'HUADeposit' => 0,
  12080. 'PersonalDeposit' => 0
  12081. );
  12082. $bakWaste ['financial'] = array (
  12083. 'current' => array (
  12084. 'CGBDeposit' => 0,
  12085. 'ICBCDeposit' => 0
  12086. ),
  12087. 'fixed' => array (
  12088. 'CGBDeposit' => 0,
  12089. 'ICBCDeposit' => 0
  12090. )
  12091. );
  12092. // 存款
  12093. foreach ( $waste ['bank'] as $key => $value ) {
  12094. // 收入
  12095. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  12096. // 广发
  12097. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12098. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12099. }
  12100. // 工商
  12101. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12102. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12103. }
  12104. // 华润
  12105. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12106. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12107. }
  12108. // 个人
  12109. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12110. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12111. }
  12112. }
  12113. }
  12114. foreach ( $waste ['bank'] as $key => $value ) {
  12115. // 支出
  12116. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  12117. // 广发
  12118. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12119. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  12120. }
  12121. // 工商
  12122. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12123. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  12124. }
  12125. // 华润
  12126. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  12127. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  12128. }
  12129. // 个人
  12130. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12131. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  12132. }
  12133. }
  12134. }
  12135. // 活期
  12136. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  12137. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  12138. // 广发
  12139. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12140. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12141. }
  12142. // 工商
  12143. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12144. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12145. }
  12146. // 个人
  12147. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12148. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12149. }
  12150. }
  12151. }
  12152. // print_r($inComeStatistics ['fixedStatistics']);
  12153. // 固期
  12154. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  12155. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  12156. // 广发
  12157. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  12158. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  12159. }
  12160. // 工商
  12161. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  12162. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  12163. }
  12164. // 个人
  12165. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  12166. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  12167. }
  12168. }
  12169. }
  12170. return $waste;
  12171. }
  12172. function lyt() {
  12173. Doo::loadModel ( "receiptDetail" );
  12174. $receiptDetail = new receiptDetail ();
  12175. $receiptCollectList = $receiptDetail->find ( array (
  12176. 'where' => 'status=1 ',
  12177. 'asArray' => true
  12178. ) );
  12179. foreach ( $receiptCollectList as $key => $value ) {
  12180. $receiptDetail = new receiptDetail ();
  12181. $receiptDetail->pastDate = $value ['date'];
  12182. $receiptDetail->update ( array (
  12183. 'where' => "rdid= '" . $value ['rdid'] . "'"
  12184. ) );
  12185. }
  12186. }
  12187. function staffCollectMonthDetail() {
  12188. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12189. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12190. if (! $year)
  12191. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12192. if (! $month)
  12193. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12194. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  12195. if (! $nature){
  12196. $nature = isset ( $this->params ['nature'] ) ? $this->params ['nature'] : 'ONJOB';
  12197. }
  12198. Doo::loadModel ( 'staff' );
  12199. $staff = new staff ();
  12200. Doo::loadModel ( "receiptDetail" );
  12201. $receiptDetail = new receiptDetail ();
  12202. Doo::loadModel ( 'accountItem' );
  12203. $accountItem = new accountItem ();
  12204. Doo::loadModel ( 'statistics' );
  12205. $statistics = new statistics ();
  12206. Doo::loadModel ( 'L_category' );
  12207. $lCategory = new L_category ();
  12208. Doo::loadModel ( "receiptAuthorityManage" );
  12209. $receiptAuthorityManage = new receiptAuthorityManage ();
  12210. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12211. $cidList = array ();
  12212. foreach ( $imcStaff as $key => $value ) {
  12213. array_push ( $cidList, $value ['cid'] );
  12214. }
  12215. $cidString = implode ( ',', $cidList );
  12216. $naturecon='';
  12217. if ($nature=='ONJOB'){
  12218. $naturecon=' and (nature!=4 )';
  12219. }elseif($nature=='LEAVEJOB'){
  12220. $naturecon=' and (nature=4 )';
  12221. }else{
  12222. die ( 'illegal request--nature' );
  12223. }
  12224. $staffList = $staff->find ( array (
  12225. 'where' => 'username!="admin" and cid in (' . $cidString . ')'.$naturecon,
  12226. 'asArray' => true
  12227. ) );
  12228. $categoryList = $staff->find ( array (
  12229. 'select' => 'COUNT(*) as count,cid,category',
  12230. 'where' => 'username !="admin" and cid in (' . $cidString . ')'.$naturecon,
  12231. 'groupby' => 'cid',
  12232. 'asArray' => true
  12233. ) );
  12234. $list = array ();
  12235. foreach ( $categoryList as $vlu ) {
  12236. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12237. $r1 = 0;
  12238. $r2 = 0;
  12239. $r3 = 0;
  12240. $r4 = 0;
  12241. $r5 = 0;
  12242. $r6 = 0;
  12243. $r7 = 0;
  12244. $r8 = 0;
  12245. $r9 = 0;
  12246. $r10 = 0;
  12247. $r11 = 0;
  12248. $r12 = 0;
  12249. $r13 = 0;
  12250. $r14 = 0;
  12251. $r15 = 0;
  12252. $r16 = 0;
  12253. $r17 = 0;
  12254. $r18 = 0;
  12255. $c1 = 0;
  12256. $c2 = 0;
  12257. $c3 = 0;
  12258. $c4 = 0;
  12259. $c5 = 0;
  12260. $c6 = 0;
  12261. $p1 = 0;
  12262. $p2 = 0;
  12263. $p3 = 0;
  12264. $p4 = 0;
  12265. $p5 = 0;
  12266. $p6 = 0;
  12267. $p7 = 0;
  12268. $p8 = 0;
  12269. $p9 = 0;
  12270. $p10 = 0;
  12271. $p11 = 0;
  12272. $t1 = 0;
  12273. $t2 = 0;
  12274. $t3 = 0;
  12275. $t4 = 0;
  12276. $t5 = 0;
  12277. $s1 = 0;
  12278. $m1 = 0;
  12279. foreach ( $staffList as $value ) {
  12280. if ($vlu ['cid'] == $value ['cid']) {
  12281. // pastDate
  12282. $receiptCollectList = $receiptDetail->find ( array (
  12283. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12284. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12285. 'groupby' => 'item,Month(pastDate),itemCategory',
  12286. 'asArray' => true
  12287. ) );
  12288. // if ($value['sid']==42){
  12289. // print_r($receiptCollectList);die;
  12290. // }
  12291. if (! empty ( $receiptCollectList )) {
  12292. $receiptL = array (
  12293. '日常相关费用' => array (),
  12294. '差旅相关费用' => array (),
  12295. '培训班费用' => array (),
  12296. '其他' => array ()
  12297. );
  12298. $html = "";
  12299. $psum = 0;
  12300. $item = array (
  12301. '市内交通费',
  12302. '市内出租费',
  12303. '办事处房租',
  12304. '电话费',
  12305. '水费',
  12306. '电费',
  12307. '办公费用',
  12308. '邮寄费',
  12309. '其他费用',
  12310. '车辆费用',
  12311. '广告费',
  12312. '团队建设费',
  12313. '物业管理费',
  12314. '宽带费',
  12315. '人员薪酬',
  12316. '公积金',
  12317. '社保'
  12318. );
  12319. foreach ( $item as $va ) {
  12320. $falg = true;
  12321. foreach ( $receiptCollectList as $v ) {
  12322. if ($v ['itemCategory'] == '日常相关费用') {
  12323. if ($v ['item'] == $va) {
  12324. if ($va == '市内交通费')
  12325. $r1 += $v ['price'];
  12326. if ($va == '市内出租费')
  12327. $r2 += $v ['price'];
  12328. if ($va == '办事处房租')
  12329. $r3 += $v ['price'];
  12330. if ($va == '电话费')
  12331. $r4 += $v ['price'];
  12332. if ($va == '水费')
  12333. $r5 += $v ['price'];
  12334. if ($va == '电费')
  12335. $r6 += $v ['price'];
  12336. if ($va == '办公费用')
  12337. $r7 += $v ['price'];
  12338. if ($va == '邮寄费')
  12339. $r8 += $v ['price'];
  12340. if ($va == '其他费用')
  12341. $r9 += $v ['price'];
  12342. if ($va == '车辆费用')
  12343. $r10 += $v ['price'];
  12344. if ($va == '广告费')
  12345. $r11 += $v ['price'];
  12346. if ($va == '团队建设费')
  12347. $r13 += $v ['price'];
  12348. if ($va == '物业管理费')
  12349. $r14 += $v ['price'];
  12350. if ($va == '宽带费')
  12351. $r15 += $v ['price'];
  12352. if ($va == '公积金')
  12353. $r16 += $v ['price'];
  12354. if ($va == '社保')
  12355. $r17 += $v ['price'];
  12356. if ($va == '人员薪酬')
  12357. $r18 += $v ['price'];
  12358. $psum += $v ['price'];
  12359. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12360. $falg = false;
  12361. break;
  12362. }
  12363. }
  12364. }
  12365. if ($falg)
  12366. $html .= '<td class="taR">-</td>';
  12367. }
  12368. $r12 += $psum;
  12369. if (! empty ( $psum ))
  12370. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12371. else
  12372. $psum = '<td class="colGreen taR">-</td>';
  12373. $receiptL ['日常相关费用'] = $psum . $html;
  12374. /* ----------------------------------- */
  12375. $html = "";
  12376. $psum = 0;
  12377. $item = array (
  12378. '往来交通费',
  12379. '市内交通费',
  12380. '出差住宿费',
  12381. '出差补助',
  12382. '其他费用'
  12383. );
  12384. foreach ( $item as $va ) {
  12385. $falg = true;
  12386. foreach ( $receiptCollectList as $v ) {
  12387. if ($v ['itemCategory'] == '差旅相关费用') {
  12388. if ($v ['item'] == $va) {
  12389. if ($va == '往来交通费')
  12390. $c1 += $v ['price'];
  12391. if ($va == '市内交通费')
  12392. $c2 += $v ['price'];
  12393. if ($va == '出差住宿费')
  12394. $c3 += $v ['price'];
  12395. if ($va == '出差补助')
  12396. $c4 += $v ['price'];
  12397. if ($va == '其他费用')
  12398. $c5 += $v ['price'];
  12399. $psum += $v ['price'];
  12400. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12401. $falg = false;
  12402. break;
  12403. }
  12404. }
  12405. }
  12406. if ($falg)
  12407. $html .= '<td class="taR">-</td>';
  12408. }
  12409. $c6 += $psum;
  12410. if (! empty ( $psum ))
  12411. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12412. else
  12413. $psum = '<td class="colGreen taR">-</td>';
  12414. $receiptL ['差旅相关费用'] = $psum . $html;
  12415. /* ------------------------------------- */
  12416. $html = "";
  12417. $psum = 0;
  12418. $item = array (
  12419. '场租费',
  12420. '薪酬',
  12421. '住宿费',
  12422. '交通费',
  12423. '餐饮费',
  12424. '办公费',
  12425. '公关费',
  12426. '其他',
  12427. '电话费',
  12428. '邮寄费'
  12429. );
  12430. foreach ( $item as $va ) {
  12431. $falg = true;
  12432. foreach ( $receiptCollectList as $v ) {
  12433. if ($v ['itemCategory'] == '培训班费用') {
  12434. if ($v ['item'] == $va) {
  12435. if ($va == '场租费')
  12436. $p1 += $v ['price'];
  12437. if ($va == '薪酬')
  12438. $p2 += $v ['price'];
  12439. if ($va == '住宿费')
  12440. $p3 += $v ['price'];
  12441. if ($va == '交通费')
  12442. $p4 += $v ['price'];
  12443. if ($va == '餐饮费')
  12444. $p5 += $v ['price'];
  12445. if ($va == '办公费')
  12446. $p6 += $v ['price'];
  12447. if ($va == '公关费')
  12448. $p7 += $v ['price'];
  12449. if ($va == '其他')
  12450. $p8 += $v ['price'];
  12451. if ($va == '电话费')
  12452. $p9 += $v ['price'];
  12453. if ($va == '邮寄费')
  12454. $p10 += $v ['price'];
  12455. $psum += $v ['price'];
  12456. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12457. $falg = false;
  12458. break;
  12459. }
  12460. }
  12461. }
  12462. if ($falg)
  12463. $html .= '<td class="taR">-</td>';
  12464. }
  12465. $p11 += $psum;
  12466. if (! empty ( $psum ))
  12467. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12468. else
  12469. $psum = '<td class="colGreen taR">-</td>';
  12470. $receiptL ['培训班费用'] = $psum . $html;
  12471. /* ------------------------------------- */
  12472. $html = "";
  12473. $psum = 0;
  12474. $item = array (
  12475. '公关费',
  12476. '广告费',
  12477. '借款',
  12478. '可自加费用'
  12479. );
  12480. foreach ( $item as $va ) {
  12481. $falg = true;
  12482. foreach ( $receiptCollectList as $v ) {
  12483. if ($v ['itemCategory'] == '其他') {
  12484. // if ($value['sid']==42){
  12485. //
  12486. // echo var_dump($v['item']);
  12487. // echo var_dump($va);
  12488. // echo var_dump($v['item']==" ".$va);
  12489. // echo $v['item']."==".$va."/<br/>";
  12490. // //print_r( $receiptCollectList);//echo $va;
  12491. // }
  12492. if (trim ( $v ['item'] ) == $va) {
  12493. if ($va == '公关费')
  12494. $t1 += $v ['price'];
  12495. if ($va == '广告费') {
  12496. $t2 += $v ['price'];
  12497. }
  12498. if ($va == '借款')
  12499. $t3 += $v ['price'];
  12500. if ($va == '可自加费用')
  12501. $t4 += $v ['price'];
  12502. $psum += $v ['price'];
  12503. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12504. $falg = false;
  12505. break;
  12506. }
  12507. }
  12508. }
  12509. if ($falg)
  12510. $html .= '<td class="taR">-</td>';
  12511. }
  12512. $t5 += $psum;
  12513. if (! empty ( $psum ))
  12514. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12515. else
  12516. $psum = '<td class="colGreen taR">-</td>';
  12517. $receiptL ['其他'] = $psum . $html;
  12518. /* ------------------------------------- */
  12519. $html = "";
  12520. $psum = 0;
  12521. foreach ( $receiptCollectList as $v ) {
  12522. if ($v ['itemCategory'] == '报销金额调整') {
  12523. if (! empty ( $v ['price'] )) {
  12524. $psum += $v ['price'];
  12525. }
  12526. }
  12527. }
  12528. $s1 += $psum;
  12529. if (! empty ( $psum ))
  12530. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12531. else
  12532. $psum = '<td class="taR colOrange">-</td>';
  12533. $receiptL ['报销金额调整'] = $psum . $html;
  12534. } else {
  12535. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12536. <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>
  12537. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12538. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12539. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12540. $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>
  12541. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12542. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12543. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12544. }
  12545. $monthStaffPrice = $receiptDetail->find ( array (
  12546. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12547. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12548. 'groupby' => 'Month(pastDate)',
  12549. 'asArray' => true
  12550. ) );
  12551. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  12552. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12553. $m1 += $monthStaffPrice [0] ['price'];
  12554. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12555. } else
  12556. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12557. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  12558. $list [$value ['username']] = $receiptL;
  12559. }
  12560. }
  12561. $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>
  12562. <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>
  12563. <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>';
  12564. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12565. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12566. $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>
  12567. <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>';
  12568. $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>';
  12569. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12570. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12571. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12572. }
  12573. $data ['list'] = $list;
  12574. // print_r($list);
  12575. $receiptCollectList = $receiptDetail->find ( array (
  12576. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12577. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12578. 'groupby' => 'item,Month(pastDate),itemCategory',
  12579. 'asArray' => true
  12580. ) );
  12581. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12582. // statistics html
  12583. $stList = $statistics->getOne ( array (
  12584. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12585. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12586. 'groupby' => 'Month(date)',
  12587. 'asArray' => true
  12588. ) );
  12589. if (empty ( $stList ))
  12590. $stList = array (
  12591. 'rePrice' => 0,
  12592. 'agPrice' => 0
  12593. );
  12594. $data ['stList'] = array (
  12595. 'rePrice' => $stList ['rePrice'],
  12596. 'agPrice' => $stList ['agPrice'],
  12597. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12598. );
  12599. $monthHtml = "";
  12600. for($i = 1; $i <= 12; $i ++) {
  12601. if ($i == $month)
  12602. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12603. else
  12604. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12605. }
  12606. $data ['monthHtml'] = $monthHtml;
  12607. $data ['year'] = $year;
  12608. $data ['month'] = $month;
  12609. $data ['nature'] = $nature;
  12610. $data ['memu'] = "receipt";
  12611. $data ['staff'] = $this->staff;
  12612. $data ['receiptMemu'] = 'companyCategoryCollect';
  12613. $data ['verifyId'] = $this->verifyId;
  12614. $data ['executeId'] = $this->executeId;
  12615. $this->render ( "/admin/staffCollectMonthDetail", $data );
  12616. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12617. }
  12618. function staffCollectMonthDetail2() {
  12619. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12620. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12621. if (! $year)
  12622. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  12623. if (! $month)
  12624. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  12625. Doo::loadModel ( 'staff' );
  12626. $staff = new staff ();
  12627. Doo::loadModel ( "receiptDetail" );
  12628. $receiptDetail = new receiptDetail ();
  12629. Doo::loadModel ( 'accountItem' );
  12630. $accountItem = new accountItem ();
  12631. Doo::loadModel ( 'statistics' );
  12632. $statistics = new statistics ();
  12633. Doo::loadModel ( 'L_category' );
  12634. $lCategory = new L_category ();
  12635. $staffList = $staff->find ( array (
  12636. 'where' => 'username!="admin"',
  12637. 'asArray' => true
  12638. ) );
  12639. $categoryList = $staff->find ( array (
  12640. 'select' => 'COUNT(*) as count,cid,category',
  12641. 'where' => 'username !="admin"',
  12642. 'groupby' => 'cid',
  12643. 'asArray' => true
  12644. ) );
  12645. $list = array ();
  12646. foreach ( $categoryList as $vlu ) {
  12647. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  12648. $r1 = 0;
  12649. $r2 = 0;
  12650. $r3 = 0;
  12651. $r4 = 0;
  12652. $r5 = 0;
  12653. $r6 = 0;
  12654. $r7 = 0;
  12655. $r8 = 0;
  12656. $r9 = 0;
  12657. $r10 = 0;
  12658. $r11 = 0;
  12659. $r12 = 0;
  12660. $r13 = 0;
  12661. $r14 = 0;
  12662. $r15 = 0;
  12663. $c1 = 0;
  12664. $c2 = 0;
  12665. $c3 = 0;
  12666. $c4 = 0;
  12667. $c5 = 0;
  12668. $c6 = 0;
  12669. $p1 = 0;
  12670. $p2 = 0;
  12671. $p3 = 0;
  12672. $p4 = 0;
  12673. $p5 = 0;
  12674. $p6 = 0;
  12675. $p7 = 0;
  12676. $p8 = 0;
  12677. $p9 = 0;
  12678. $t1 = 0;
  12679. $t2 = 0;
  12680. $t3 = 0;
  12681. $t4 = 0;
  12682. $t5 = 0;
  12683. $s1 = 0;
  12684. $m1 = 0;
  12685. foreach ( $staffList as $value ) {
  12686. if ($vlu ['cid'] == $value ['cid']) {
  12687. $receiptCollectList = $receiptDetail->find ( array (
  12688. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12689. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12690. 'groupby' => 'item,Month(date),itemCategory',
  12691. 'asArray' => true
  12692. ) );
  12693. if (! empty ( $receiptCollectList )) {
  12694. $receiptL = array (
  12695. '日常相关费用' => array (),
  12696. '差旅相关费用' => array (),
  12697. '培训班费用' => array (),
  12698. '其他' => array ()
  12699. );
  12700. $html = "";
  12701. $psum = 0;
  12702. $item = array (
  12703. '市内交通费',
  12704. '市内出租费',
  12705. '办事处房租',
  12706. '电话费',
  12707. '水费',
  12708. '电费',
  12709. '办公费用',
  12710. '邮寄费',
  12711. '其他费用',
  12712. '车辆费用',
  12713. '广告费',
  12714. '团队建设费',
  12715. '物业管理费',
  12716. '宽带费'
  12717. );
  12718. foreach ( $item as $va ) {
  12719. $falg = true;
  12720. foreach ( $receiptCollectList as $v ) {
  12721. if ($v ['itemCategory'] == '日常相关费用') {
  12722. if ($v ['item'] == $va) {
  12723. if ($va == '市内交通费')
  12724. $r1 += $v ['price'];
  12725. if ($va == '市内出租费')
  12726. $r2 += $v ['price'];
  12727. if ($va == '办事处房租')
  12728. $r3 += $v ['price'];
  12729. if ($va == '电话费')
  12730. $r4 += $v ['price'];
  12731. if ($va == '水费')
  12732. $r5 += $v ['price'];
  12733. if ($va == '电费')
  12734. $r6 += $v ['price'];
  12735. if ($va == '办公费用')
  12736. $r7 += $v ['price'];
  12737. if ($va == '邮寄费')
  12738. $r8 += $v ['price'];
  12739. if ($va == '其他费用')
  12740. $r9 += $v ['price'];
  12741. if ($va == '车辆费用')
  12742. $r10 += $v ['price'];
  12743. if ($va == '广告费')
  12744. $r11 += $v ['price'];
  12745. if ($va == '团队建设费')
  12746. $r13 += $v ['price'];
  12747. if ($va == '物业管理费')
  12748. $r14 += $v ['price'];
  12749. if ($va == '宽带费')
  12750. $r15 += $v ['price'];
  12751. $psum += $v ['price'];
  12752. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12753. $falg = false;
  12754. break;
  12755. }
  12756. }
  12757. }
  12758. if ($falg)
  12759. $html .= '<td class="taR">-</td>';
  12760. }
  12761. $r12 += $psum;
  12762. if (! empty ( $psum ))
  12763. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12764. else
  12765. $psum = '<td class="colGreen taR">-</td>';
  12766. $receiptL ['日常相关费用'] = $psum . $html;
  12767. /* ----------------------------------- */
  12768. $html = "";
  12769. $psum = 0;
  12770. $item = array (
  12771. '往来交通费',
  12772. '市内交通费',
  12773. '出差住宿费',
  12774. '出差补助',
  12775. '其他费用'
  12776. );
  12777. foreach ( $item as $va ) {
  12778. $falg = true;
  12779. foreach ( $receiptCollectList as $v ) {
  12780. if ($v ['itemCategory'] == '差旅相关费用') {
  12781. if ($v ['item'] == $va) {
  12782. if ($va == '往来交通费')
  12783. $c1 += $v ['price'];
  12784. if ($va == '市内交通费')
  12785. $c2 += $v ['price'];
  12786. if ($va == '出差住宿费')
  12787. $c3 += $v ['price'];
  12788. if ($va == '出差补助')
  12789. $c4 += $v ['price'];
  12790. if ($va == '其他费用')
  12791. $c5 += $v ['price'];
  12792. $psum += $v ['price'];
  12793. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12794. $falg = false;
  12795. break;
  12796. }
  12797. }
  12798. }
  12799. if ($falg)
  12800. $html .= '<td class="taR">-</td>';
  12801. }
  12802. $c6 += $psum;
  12803. if (! empty ( $psum ))
  12804. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12805. else
  12806. $psum = '<td class="colGreen taR">-</td>';
  12807. $receiptL ['差旅相关费用'] = $psum . $html;
  12808. /* ------------------------------------- */
  12809. $html = "";
  12810. $psum = 0;
  12811. $item = array (
  12812. '场租费',
  12813. '薪酬',
  12814. '住宿费',
  12815. '交通费',
  12816. '餐饮费',
  12817. '办公费',
  12818. '公关费',
  12819. '其他'
  12820. );
  12821. foreach ( $item as $va ) {
  12822. $falg = true;
  12823. foreach ( $receiptCollectList as $v ) {
  12824. if ($v ['itemCategory'] == '培训班费用') {
  12825. if ($v ['item'] == $va) {
  12826. if ($va == '场租费')
  12827. $p1 += $v ['price'];
  12828. if ($va == '薪酬')
  12829. $p2 += $v ['price'];
  12830. if ($va == '住宿费')
  12831. $p3 += $v ['price'];
  12832. if ($va == '交通费')
  12833. $p4 += $v ['price'];
  12834. if ($va == '餐饮费')
  12835. $p5 += $v ['price'];
  12836. if ($va == '办公费')
  12837. $p6 += $v ['price'];
  12838. if ($va == '公关费')
  12839. $p7 += $v ['price'];
  12840. if ($va == '其他')
  12841. $p8 += $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. $p9 += $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. $item = array (
  12862. '公关费',
  12863. '广告费',
  12864. '借款',
  12865. '可自加费用'
  12866. );
  12867. foreach ( $item as $va ) {
  12868. $falg = true;
  12869. foreach ( $receiptCollectList as $v ) {
  12870. if ($v ['itemCategory'] == '其他') {
  12871. if ($v ['item'] == $va) {
  12872. if ($va == '公关费')
  12873. $t1 += $v ['price'];
  12874. if ($va == '广告费')
  12875. $t2 += $v ['price'];
  12876. if ($va == '借款')
  12877. $t3 += $v ['price'];
  12878. if ($va == '可自加费用')
  12879. $t4 += $v ['price'];
  12880. $psum += $v ['price'];
  12881. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12882. $falg = false;
  12883. break;
  12884. }
  12885. }
  12886. }
  12887. if ($falg)
  12888. $html .= '<td class="taR">-</td>';
  12889. }
  12890. $t5 += $psum;
  12891. if (! empty ( $psum ))
  12892. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  12893. else
  12894. $psum = '<td class="colGreen taR">-</td>';
  12895. $receiptL ['其他'] = $psum . $html;
  12896. /* ------------------------------------- */
  12897. $html = "";
  12898. $psum = 0;
  12899. foreach ( $receiptCollectList as $v ) {
  12900. if ($v ['itemCategory'] == '报销金额调整') {
  12901. if (! empty ( $v ['price'] )) {
  12902. $psum += $v ['price'];
  12903. }
  12904. }
  12905. }
  12906. $s1 += $psum;
  12907. if (! empty ( $psum ))
  12908. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  12909. else
  12910. $psum = '<td class="taR colOrange">-</td>';
  12911. $receiptL ['报销金额调整'] = $psum . $html;
  12912. } else {
  12913. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12914. <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>';
  12915. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12916. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12917. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12918. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12919. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12920. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12921. }
  12922. $monthStaffPrice = $receiptDetail->find ( array (
  12923. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12924. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12925. 'asArray' => true
  12926. ) );
  12927. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  12928. $m1 += $monthStaffPrice [0] ['price'];
  12929. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12930. } else
  12931. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12932. $list [$value ['username']] = $receiptL;
  12933. }
  12934. }
  12935. $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>
  12936. <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>
  12937. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  12938. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  12939. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  12940. $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>
  12941. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  12942. $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>';
  12943. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  12944. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  12945. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  12946. }
  12947. $data ['list'] = $list;
  12948. $receiptCollectList = $receiptDetail->find ( array (
  12949. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  12950. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  12951. 'groupby' => 'item,Month(date),itemCategory',
  12952. 'asArray' => true
  12953. ) );
  12954. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12955. // statistics html
  12956. $stList = $statistics->getOne ( array (
  12957. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12958. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12959. 'groupby' => 'Month(date)',
  12960. 'asArray' => true
  12961. ) );
  12962. if (empty ( $stList ))
  12963. $stList = array (
  12964. 'rePrice' => 0,
  12965. 'agPrice' => 0
  12966. );
  12967. $data ['stList'] = array (
  12968. 'rePrice' => $stList ['rePrice'],
  12969. 'agPrice' => $stList ['agPrice'],
  12970. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12971. );
  12972. $monthHtml = "";
  12973. for($i = 1; $i <= 12; $i ++) {
  12974. if ($i == $month)
  12975. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12976. else
  12977. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12978. }
  12979. $data ['monthHtml'] = $monthHtml;
  12980. $data ['year'] = $year;
  12981. $data ['month'] = $month;
  12982. $data ['memu'] = "receipt";
  12983. $data ['staff'] = $this->staff;
  12984. $data ['receiptMemu'] = 'companyCategoryCollect';
  12985. $data ['verifyId'] = $this->verifyId;
  12986. $data ['executeId'] = $this->executeId;
  12987. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  12988. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12989. }
  12990. /**
  12991. * 用户报销单列表
  12992. */
  12993. function receiptStatisticsStaffDetail() {
  12994. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  12995. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12996. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12997. Doo::loadModel ( "receipt" );
  12998. $receipt = new receipt ();
  12999. Doo::loadModel ( "receiptDetail" );
  13000. $receiptDetail = new receiptDetail ();
  13001. Doo::loadModel ( 'staff' );
  13002. $staff = new staff ();
  13003. Doo::loadModel ( 'accountItem' );
  13004. $accountItem = new accountItem ();
  13005. Doo::loadModel ( 'statistics' );
  13006. $statistics = new statistics ();
  13007. if (! empty ( $username )) {
  13008. $username = addslashes ( urldecode ( $username ) );
  13009. $staffDetail = $staff->getStaffByName ( $username );
  13010. if (empty ( $staffDetail ))
  13011. die ( 'illegal request' );
  13012. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  13013. $itemList = $accountItem->getAccountItem ();
  13014. $itemHtml = '';
  13015. $categoryHtml = '';
  13016. $itemKeyList = array_keys ( $itemList );
  13017. $revisePrice = 0;
  13018. // 报销单内容详情
  13019. foreach ( $list as $key => $value ) {
  13020. $accountItemList = json_decode ( $value ['accountItem'], true );
  13021. $list [$key] ['accountItemList'] = $accountItemList;
  13022. $receiptItemHtml = '';
  13023. foreach ( $itemKeyList as $v ) {
  13024. if ($v == '日常相关费用')
  13025. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  13026. elseif ($v == '差旅相关费用')
  13027. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  13028. elseif ($v == '培训班费用')
  13029. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  13030. elseif ($v == '其他')
  13031. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  13032. foreach ( $itemList [$v] as $ke => $va ) {
  13033. $falg = true;
  13034. if (! empty ( $accountItemList [$v] )) {
  13035. foreach ( $accountItemList [$v] as $ve ) {
  13036. if ($va ['name'] == $ve ['name']) {
  13037. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  13038. $falg = false;
  13039. break;
  13040. }
  13041. }
  13042. }
  13043. if ($falg)
  13044. $receiptItemHtml .= '<td class="taR"></td>';
  13045. }
  13046. }
  13047. // 金额调整和费用查看
  13048. $revisePrice += $value ['revisePrice'];
  13049. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  13050. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" id="sen'.$key.'" data="' . htmlspecialchars($value ['explanation']) . '" onclick=showExplanation() >查看</a></td>';
  13051. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  13052. }
  13053. // 报销单合计
  13054. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  13055. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  13056. $receiptTotalHtml = '';
  13057. // 报销单项目抬头
  13058. foreach ( $itemKeyList as $value ) {
  13059. $count = count ( $itemList [$value] ) + 1;
  13060. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  13061. $categoryHtml .= '<th class="taC">合计</th>';
  13062. $sumfalg=true;
  13063. foreach ( $rtl as $rtlValue ) {
  13064. if ($rtlValue ['itemCategory'] == $value) {
  13065. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  13066. $sumfalg=false;
  13067. break;
  13068. }
  13069. }
  13070. if ($sumfalg)
  13071. $receiptTotalHtml .= '<th></th>';
  13072. foreach ( $itemList [$value] as $k => $v ) {
  13073. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  13074. // 合计
  13075. $falg = true;
  13076. foreach ( $receiptTotalList as $ve ) {
  13077. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  13078. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  13079. $falg = false;
  13080. break;
  13081. }
  13082. }
  13083. if ($falg)
  13084. $receiptTotalHtml .= '<th></th>';
  13085. }
  13086. }
  13087. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  13088. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  13089. if (empty ( $stList ))
  13090. $stList = array (
  13091. 'rePrice' => 0,
  13092. 'agPrice' => 0
  13093. );
  13094. $data ['stList'] = array (
  13095. 'rePrice' => $stList ['rePrice'],
  13096. 'agPrice' => $stList ['agPrice'],
  13097. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13098. );
  13099. $monthHtml = "";
  13100. for($i = 1; $i <= 12; $i ++) {
  13101. if ($i == $month)
  13102. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13103. else
  13104. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13105. }
  13106. $data ['username'] = urlencode ( $username );
  13107. $data ['usernameEN'] = $username;
  13108. $data ['monthHtml'] = $monthHtml;
  13109. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  13110. $data ['list'] = $list;
  13111. $data ['categoryHtml'] = $categoryHtml;
  13112. $data ['itemHtml'] = $itemHtml;
  13113. $data ['itemList'] = $itemList;
  13114. $data ['year'] = $year;
  13115. $data ['month'] = $month;
  13116. $data ['memu'] = "receipt";
  13117. $data ['staff'] = $this->staff;
  13118. $data ['receiptMemu'] = 'companyCategoryCollect';
  13119. $data ['verifyId'] = $this->verifyId;
  13120. $data ['executeId'] = $this->executeId;
  13121. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  13122. }
  13123. die ( 'illegal request' );
  13124. }
  13125. function companyMonthCollectDetail() {
  13126. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  13127. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13128. if (! $year)
  13129. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  13130. if (! $month)
  13131. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  13132. Doo::loadModel ( 'staff' );
  13133. $staff = new staff ();
  13134. Doo::loadModel ( "receiptDetail" );
  13135. $receiptDetail = new receiptDetail ();
  13136. Doo::loadModel ( 'accountItem' );
  13137. $accountItem = new accountItem ();
  13138. Doo::loadModel ( 'statistics' );
  13139. $statistics = new statistics ();
  13140. Doo::loadModel ( 'L_category' );
  13141. $lCategory = new L_category ();
  13142. $staffList = $staff->find ( array (
  13143. 'where' => 'username!="admin"',
  13144. 'asArray' => true
  13145. ) );
  13146. $categoryList = $lCategory->find ( array (
  13147. 'asArray' => true
  13148. ) );
  13149. $list = array ();
  13150. foreach ( $categoryList as $value ) {
  13151. $receiptCollectList = $receiptDetail->find ( array (
  13152. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13153. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13154. 'groupby' => 'item,Month(pastDate),itemCategory',
  13155. 'asArray' => true
  13156. ) );
  13157. if (! empty ( $receiptCollectList )) {
  13158. $receiptL = array (
  13159. '日常相关费用' => array (),
  13160. '差旅相关费用' => array (),
  13161. '培训班费用' => array (),
  13162. '其他' => array ()
  13163. );
  13164. $html = "";
  13165. $psum = 0;
  13166. $item = array (
  13167. '市内交通费',
  13168. '市内出租费',
  13169. '办事处房租',
  13170. '电话费',
  13171. '水费',
  13172. '电费',
  13173. '办公费用',
  13174. '邮寄费',
  13175. '其他费用',
  13176. '车辆费用',
  13177. '广告费',
  13178. '团队建设费'
  13179. );
  13180. foreach ( $item as $va ) {
  13181. $falg = true;
  13182. foreach ( $receiptCollectList as $v ) {
  13183. if ($v ['itemCategory'] == '日常相关费用') {
  13184. if ($v ['item'] == $va) {
  13185. $psum += $v ['price'];
  13186. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13187. $falg = false;
  13188. break;
  13189. }
  13190. }
  13191. }
  13192. if ($falg)
  13193. $html .= '<td class="taR">-</td>';
  13194. }
  13195. if (! empty ( $psum ))
  13196. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13197. else
  13198. $psum = '<td class="colGreen taR">-</td>';
  13199. $receiptL ['日常相关费用'] = $psum . $html;
  13200. /* ----------------------------------- */
  13201. $html = "";
  13202. $psum = 0;
  13203. $item = array (
  13204. '往来交通费',
  13205. '市内交通费',
  13206. '出差住宿费',
  13207. '出差补助',
  13208. '其他费用'
  13209. );
  13210. foreach ( $item as $va ) {
  13211. $falg = true;
  13212. foreach ( $receiptCollectList as $v ) {
  13213. if ($v ['itemCategory'] == '差旅相关费用') {
  13214. if ($v ['item'] == $va) {
  13215. $psum += $v ['price'];
  13216. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13217. $falg = false;
  13218. break;
  13219. }
  13220. }
  13221. }
  13222. if ($falg)
  13223. $html .= '<td class="taR">-</td>';
  13224. }
  13225. if (! empty ( $psum ))
  13226. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13227. else
  13228. $psum = '<td class="colGreen taR">-</td>';
  13229. $receiptL ['差旅相关费用'] = $psum . $html;
  13230. /* ------------------------------------- */
  13231. $html = "";
  13232. $psum = 0;
  13233. $item = array (
  13234. '场租费',
  13235. '薪酬',
  13236. '住宿费',
  13237. '交通费',
  13238. '餐饮费',
  13239. '办公费',
  13240. '公关费',
  13241. '其他'
  13242. );
  13243. foreach ( $item as $va ) {
  13244. $falg = true;
  13245. foreach ( $receiptCollectList as $v ) {
  13246. if ($v ['itemCategory'] == '培训班费用') {
  13247. if ($v ['item'] == $va) {
  13248. $psum += $v ['price'];
  13249. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13250. $falg = false;
  13251. break;
  13252. }
  13253. }
  13254. }
  13255. if ($falg)
  13256. $html .= '<td class="taR">-</td>';
  13257. }
  13258. if (! empty ( $psum ))
  13259. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13260. else
  13261. $psum = '<td class="colGreen taR">-</td>';
  13262. $receiptL ['培训班费用'] = $psum . $html;
  13263. /* ------------------------------------- */
  13264. $html = "";
  13265. $psum = 0;
  13266. $item = array (
  13267. '公关费',
  13268. '广告费',
  13269. '借款',
  13270. '可自加费用'
  13271. );
  13272. foreach ( $item as $va ) {
  13273. $falg = true;
  13274. foreach ( $receiptCollectList as $v ) {
  13275. if ($v ['itemCategory'] == '其他') {
  13276. if ($v ['item'] == $va) {
  13277. $psum += $v ['price'];
  13278. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13279. $falg = false;
  13280. break;
  13281. }
  13282. }
  13283. }
  13284. if ($falg)
  13285. $html .= '<td class="taR">-</td>';
  13286. }
  13287. if (! empty ( $psum ))
  13288. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13289. else
  13290. $psum = '<td class="colGreen taR">-</td>';
  13291. $receiptL ['其他'] = $psum . $html;
  13292. /* ------------------------------------- */
  13293. $html = "";
  13294. $psum = 0;
  13295. foreach ( $receiptCollectList as $v ) {
  13296. if ($v ['itemCategory'] == '报销金额调整') {
  13297. if (! empty ( $v ['price'] ))
  13298. $psum += $v ['price'];
  13299. }
  13300. }
  13301. if (! empty ( $psum ))
  13302. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13303. else
  13304. $psum = '<td class="taR colOrange">-</td>';
  13305. $receiptL ['报销金额调整'] = $psum . $html;
  13306. } else {
  13307. $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>
  13308. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13309. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13310. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13311. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  13312. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13313. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13314. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13315. }
  13316. $monthStaffPrice = $receiptDetail->find ( array (
  13317. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13318. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13319. 'asArray' => true
  13320. ) );
  13321. if (! empty ( $monthStaffPrice [0] ['price'] ))
  13322. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  13323. else
  13324. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  13325. $list [$value ['title']] = $receiptL;
  13326. }
  13327. $data ['list'] = $list;
  13328. $receiptCollectList = $receiptDetail->find ( array (
  13329. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  13330. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  13331. 'groupby' => 'item,Month(pastDate),itemCategory',
  13332. 'asArray' => true
  13333. ) );
  13334. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  13335. // print_r($data['monthPriceHtml']);
  13336. // foreach ($data['monthPriceHtml'] as $value){
  13337. // echo $value;
  13338. // }
  13339. // die;
  13340. // statistics html
  13341. $stList = $statistics->getOne ( array (
  13342. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  13343. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  13344. 'groupby' => 'Month(date)',
  13345. 'asArray' => true
  13346. ) );
  13347. if (empty ( $stList ))
  13348. $stList = array (
  13349. 'rePrice' => 0,
  13350. 'agPrice' => 0
  13351. );
  13352. $data ['stList'] = array (
  13353. 'rePrice' => $stList ['rePrice'],
  13354. 'agPrice' => $stList ['agPrice'],
  13355. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13356. );
  13357. $monthHtml = "";
  13358. for($i = 1; $i <= 12; $i ++) {
  13359. if ($i == $month)
  13360. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  13361. else
  13362. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  13363. }
  13364. $data ['monthHtml'] = $monthHtml;
  13365. $data ['year'] = $year;
  13366. $data ['month'] = $month;
  13367. $data ['memu'] = "receipt";
  13368. $data ['staff'] = $this->staff;
  13369. $data ['receiptMemu'] = 'companyCategoryCollect';
  13370. $data ['verifyId'] = $this->verifyId;
  13371. $data ['executeId'] = $this->executeId;
  13372. $this->render ( "/admin/companyMonthCollectDetail", $data );
  13373. }
  13374. function staffCollectDetail() {
  13375. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  13376. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  13377. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  13378. if (! $staffname) {
  13379. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  13380. $staffname = urldecode ( $staffname );
  13381. }
  13382. Doo::loadModel ( 'staff' );
  13383. $staff = new staff ();
  13384. Doo::loadModel ( "receiptDetail" );
  13385. $receiptDetail = new receiptDetail ();
  13386. Doo::loadModel ( 'accountItem' );
  13387. $accountItem = new accountItem ();
  13388. Doo::loadModel ( 'statistics' );
  13389. $statistics = new statistics ();
  13390. Doo::loadModel ( 'L_category' );
  13391. $lCategory = new L_category ();
  13392. Doo::loadModel ( "receiptAuthorityManage" );
  13393. $receiptAuthorityManage = new receiptAuthorityManage ();
  13394. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  13395. $cidList = array ();
  13396. foreach ( $imcStaff as $key => $value ) {
  13397. array_push ( $cidList, $value ['cid'] );
  13398. }
  13399. $cidString = implode ( ',', $cidList );
  13400. $staffList = $staff->find ( array (
  13401. 'where' => ' cid in (' . $cidString . ')',
  13402. 'asArray' => true
  13403. ) );
  13404. $stHtml = '';
  13405. $stTitle = "";
  13406. $staffId = 0;
  13407. $cid = 0;
  13408. $ocid = 0;
  13409. foreach ( $staffList as $value ) {
  13410. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  13411. $stTitle = $value ['category'] . '-' . $value ['username'];
  13412. $staffId = $value ['sid'];
  13413. $cid = $value ['cid'];
  13414. $ocid = $value ['cid'];
  13415. if (! empty ( $value ['othercid'] ))
  13416. $cid = $value ['cid'] . ',' . $value ['othercid'];
  13417. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13418. } elseif ($value ['username'] != 'admin')
  13419. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  13420. }
  13421. $data ['lCategoryHtml'] = $lCategory->find ( array (
  13422. 'where' => 'cid in(' . $cid . ')',
  13423. 'asArray' => true
  13424. ) );
  13425. if (empty ( $pcid ))
  13426. $pcid = $ocid;
  13427. $data ['ocid'] = $pcid;
  13428. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  13429. $this->showCache ( $path );
  13430. //
  13431. $receiptCollectList = $receiptDetail->find ( array (
  13432. 'select' => 'staff,item,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' => 'item,Month(pastDate),itemCategory',
  13435. 'asArray' => true
  13436. ) );
  13437. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  13438. // print_r($receiptCollectList);
  13439. $accountList = $accountItem->find ( array (
  13440. 'asArray' => true
  13441. ) );
  13442. // create CollectDetail HTML
  13443. $collectHtml = array ();
  13444. foreach ( $accountList as $key => $value ) {
  13445. $html = "";
  13446. $asum = 0;
  13447. for($i = 1; $i <= 12; $i ++) {
  13448. $falg = true;
  13449. foreach ( $receiptCollectList as $v ) {
  13450. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  13451. if ($v ['item'] == '可自加费用') {
  13452. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  13453. }
  13454. $asum += $v ['price'];
  13455. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13456. $falg = false;
  13457. break;
  13458. }
  13459. }
  13460. if ($falg)
  13461. $html .= '<td class="taR">-</td>';
  13462. }
  13463. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  13464. $collectHtml [$value ['category']] [$value ['name']] = $html;
  13465. }
  13466. $data ['collectHtml'] = $collectHtml;
  13467. // print_r($collectHtml);
  13468. // create Adjustment price html
  13469. $receiptCollectList = $receiptDetail->find ( array (
  13470. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  13471. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  13472. 'groupby' => 'itemCategory,Month(pastDate)',
  13473. 'asArray' => true
  13474. ) );
  13475. $adjustment = array ();
  13476. $collectArray = array (
  13477. '日常相关费用' => array (),
  13478. '差旅相关费用' => array (),
  13479. '培训班费用' => array (),
  13480. '其他' => array ()
  13481. );
  13482. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  13483. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  13484. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  13485. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  13486. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  13487. array_push ( $collectArray ['培训班费用'], $collectHtml );
  13488. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  13489. array_push ( $collectArray ['其他'], $collectHtml );
  13490. $data ['collectArray'] = $collectArray;
  13491. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  13492. array_push ( $adjustment, $collectHtml );
  13493. $data ['adjustment'] = $adjustment;
  13494. // total price html
  13495. $collectHtml = "";
  13496. $total = 0;
  13497. for($i = 1; $i <= 12; $i ++) {
  13498. $sumPrice = 0;
  13499. foreach ( $receiptCollectList as $key => $value ) {
  13500. if ($value ['month'] == $i) {
  13501. $sumPrice += $value ['price'];
  13502. }
  13503. }
  13504. if ($sumPrice == 0)
  13505. $collectHtml .= '<td class="taR">-</td>';
  13506. else
  13507. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  13508. $total += $sumPrice;
  13509. }
  13510. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  13511. // statistics html
  13512. $stList = $statistics->statisticsByYear ( $year, $staffId );
  13513. if (empty ( $stList ))
  13514. $stList = array (
  13515. 'rePrice' => 0,
  13516. 'agPrice' => 0
  13517. );
  13518. $data ['stList'] = array (
  13519. 'rePrice' => $stList ['rePrice'],
  13520. 'agPrice' => $stList ['agPrice'],
  13521. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  13522. );
  13523. $data ['totalPrice'] = $collectHtml;
  13524. $data ['totalYear'] = $total;
  13525. $data ['stHtml'] = $stHtml;
  13526. $data ['year'] = $year;
  13527. $data ['stTitle'] = $stTitle;
  13528. $data ['staffname'] = urlencode ( $staffname );
  13529. $data ['memu'] = "receipt";
  13530. $data ['staff'] = $this->staff;
  13531. $data ['receiptMemu'] = 'companyCategoryCollect';
  13532. $data ['verifyId'] = $this->verifyId;
  13533. $data ['executeId'] = $this->executeId;
  13534. if ($year < date ( "Y" )) {
  13535. Doo::loadModel ( 'receipt' );
  13536. $receipt = new receipt ();
  13537. $receiptList = $receipt->find ( array (
  13538. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  13539. 'asArray' => true
  13540. ) );
  13541. if (empty ( $receiptList )) { // generated files
  13542. ob_start ();
  13543. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13544. $this->cacheFile ( $path );
  13545. die ();
  13546. }
  13547. }
  13548. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  13549. }
  13550. function BUGFLAG() {
  13551. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  13552. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  13553. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  13554. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  13555. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  13556. if (empty ( $status ))
  13557. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  13558. $page_size = 12;
  13559. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  13560. $vidList = array ();
  13561. $button = 0;
  13562. Doo::loadModel ( 'verify' );
  13563. $verify = new verify ();
  13564. Doo::loadModel ( 'receipt' );
  13565. $receipt = new receipt ();
  13566. Doo::loadModel ( 'staff' );
  13567. $staff = new staff ();
  13568. Doo::loadModel ( 'L_category' );
  13569. $Lcategory = new L_category ();
  13570. $dateCondition = " and Year(date) =" . $year;
  13571. if (! empty ( $month ))
  13572. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  13573. $categoryList = $Lcategory->find ( array (
  13574. 'asArray' => true
  13575. ) );
  13576. $staffList = $staff->find ( array (
  13577. 'where' => 'cid=' . $cid,
  13578. 'asArray' => true
  13579. ) );
  13580. $cateCondition = "";
  13581. $staffCondition = "";
  13582. $approvalCondition = "";
  13583. if (! empty ( $cid ))
  13584. $cateCondition = ' and cid=' . $cid;
  13585. if (! empty ( $sid )) {
  13586. $staffCondition = ' and staff=' . $sid;
  13587. $cateCondition = "";
  13588. }
  13589. $approvalCondition = " and status=" . $status;
  13590. if ($status == 2) {
  13591. // 查找角色审批人
  13592. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  13593. }
  13594. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  13595. $approvalCondition = ' and status=2 ';
  13596. }
  13597. if ($status == 1) {
  13598. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  13599. }
  13600. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  13601. $pageinfo ['page'] = array (
  13602. 'previous' => ''
  13603. );
  13604. if ($status == 0) {
  13605. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  13606. $receiptList = $receipt->find ( array (
  13607. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  13608. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  13609. 'desc' => 'rid',
  13610. 'asArray' => true
  13611. ) );
  13612. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13613. } else
  13614. $receiptList = $receipt->find ( array (
  13615. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  13616. 'desc' => 'rid',
  13617. 'asArray' => true
  13618. ) );
  13619. $rLRes = $receipt->find ( array (
  13620. '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,
  13621. 'desc' => 'rid',
  13622. 'asArray' => true
  13623. ) );
  13624. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  13625. // print_r($pageinfo);
  13626. $Locate = 0;
  13627. foreach ( $receiptList as $key => $value ) {
  13628. $receiptList [$key] ['Locate'] = $Locate;
  13629. $Locate ++;
  13630. $receiptList [$key] ['reviseDetail'] = array ();
  13631. if (! empty ( $value ['reviseDetail'] ))
  13632. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  13633. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  13634. $categoryDetil = $Lcategory->getOne ( array (
  13635. 'where' => 'cid=' . $value ['cid'],
  13636. 'asArray' => true
  13637. ) );
  13638. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  13639. $verifyList = $verify->getOne ( array (
  13640. 'where' => 'vid=' . $value ['verify'],
  13641. 'asArray' => true
  13642. ) );
  13643. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  13644. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  13645. foreach ( $verifyList as $k => $v ) {
  13646. // init verifyStaff
  13647. $verifyList [$k] ['date'] = "";
  13648. $verifyList [$k] ['opinion'] = "";
  13649. $verifyList [$k] ['status'] = "";
  13650. if (empty ( $verifyStaff )) {
  13651. $verifyList [$k] ['date'] = "";
  13652. $verifyList [$k] ['opinion'] = "";
  13653. if ($v [0] == $this->staff [0] ['sid']) {
  13654. $verifyList [$k] ['status'] = 4;
  13655. $button = 4;
  13656. }
  13657. } else {
  13658. $flag = true;
  13659. foreach ( $verifyStaff as $m => $u ) {
  13660. if ($v [0] == $m) {
  13661. $verifyList [$k] ['date'] = $u ['date'];
  13662. $verifyList [$k] ['opinion'] = $u ['opinion'];
  13663. $verifyList [$k] ['status'] = $u ['status'];
  13664. $flag = false;
  13665. break;
  13666. }
  13667. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  13668. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  13669. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  13670. }
  13671. if ($flag) { // 检测可编辑
  13672. if ($v [0] == $this->staff [0] ['sid']) {
  13673. $verifyList [$k] ['status'] = 4;
  13674. $button = 4;
  13675. }
  13676. }
  13677. }
  13678. }
  13679. $receiptList [$key] ['verifyList'] = $verifyList;
  13680. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  13681. 'where' => 'sid=' . $value ['staff'],
  13682. 'asArray' => true
  13683. ) );
  13684. $receiptList [$key] ['button'] = $button;
  13685. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  13686. }
  13687. // print_r($receiptList);die;
  13688. // $data['verifyDetail']=$verifyDetail;
  13689. $mothHtml = "";
  13690. for($i = 1; $i <= 12; $i ++) {
  13691. if ($month == $i)
  13692. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  13693. else
  13694. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  13695. }
  13696. $data ['mothHtml'] = $mothHtml;
  13697. $data ['page'] = $pageinfo;
  13698. $data ['receiptList'] = $receiptList;
  13699. $data ['receiptApprovalCount'] = count ( $rLRes );
  13700. $data ['status'] = $status;
  13701. $data ['year'] = $year;
  13702. $data ['categoryList'] = $categoryList;
  13703. $data ['staffList'] = $staffList;
  13704. $data ['cid'] = $cid;
  13705. $data ['sid'] = $sid;
  13706. // print_r($receiptList);
  13707. $data ['memu'] = "receipt";
  13708. $data ['staff'] = $this->staff;
  13709. $data ['receiptMemu'] = 'approvalExpenses';
  13710. $data ['verifyId'] = $this->verifyId;
  13711. $data ['executeId'] = $this->executeId;
  13712. $this->render ( "/admin/FALG", $data );
  13713. }
  13714. function ajaxGetReceiptOrder() {
  13715. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  13716. if (! empty ( $receiptOrder )) {
  13717. Doo::loadModel ( 'receipt' );
  13718. $receipt = new receipt ();
  13719. Doo::loadModel ( 'staff' );
  13720. $staff = new staff ();
  13721. $receiptInfo = $receipt->getOne ( array (
  13722. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  13723. 'asArray' => true
  13724. ) );
  13725. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  13726. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  13727. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  13728. </tbody></table><table class="table table table-bordered"><tbody>';
  13729. foreach ( $verifyStaff as $key => $value ) {
  13730. $staffInfo = $staff->getOne ( array (
  13731. 'select' => 'username',
  13732. 'where' => ' sid="' . $key . '"',
  13733. 'asArray' => true
  13734. ) );
  13735. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  13736. }
  13737. $html .= '</tbody></table></div></div>';
  13738. echo json_encode ( array (
  13739. 'status' => 1,
  13740. 'receiptHtml' => $html
  13741. ) );
  13742. die ();
  13743. }
  13744. echo json_encode ( array (
  13745. 'status' => 2,
  13746. 'receiptHtml' => ''
  13747. ) );
  13748. die ();
  13749. }
  13750. function _getMonthCollectDetail($receiptCollectList) {
  13751. if (! empty ( $receiptCollectList )) {
  13752. $receiptL = array (
  13753. '日常相关费用' => array (),
  13754. '差旅相关费用' => array (),
  13755. '培训班费用' => array (),
  13756. '其他' => array ()
  13757. );
  13758. $html = "";
  13759. $psum = 0;
  13760. $item = array (
  13761. '市内交通费',
  13762. '市内出租费',
  13763. '办事处房租',
  13764. '电话费',
  13765. '水费',
  13766. '电费',
  13767. '办公费用',
  13768. '邮寄费',
  13769. '其他费用',
  13770. '车辆费用',
  13771. '广告费',
  13772. '团队建设费',
  13773. '物业管理费',
  13774. '宽带费',
  13775. '人员薪酬',
  13776. '公积金',
  13777. '社保'
  13778. );
  13779. foreach ( $item as $value ) {
  13780. $falg = true;
  13781. foreach ( $receiptCollectList as $v ) {
  13782. if ($v ['itemCategory'] == '日常相关费用') {
  13783. if ($v ['item'] == $value) {
  13784. $psum += $v ['price'];
  13785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13786. $falg = false;
  13787. break;
  13788. }
  13789. }
  13790. }
  13791. if ($falg)
  13792. $html .= '<td class="taR">-</td>';
  13793. }
  13794. if (! empty ( $psum ))
  13795. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13796. else
  13797. $psum = '<td class="colGreen taR">-</td>';
  13798. $receiptL ['日常相关费用'] = $psum . $html;
  13799. /* ----------------------------------- */
  13800. $html = "";
  13801. $psum = 0;
  13802. $item = array (
  13803. '往来交通费',
  13804. '市内交通费',
  13805. '出差住宿费',
  13806. '出差补助',
  13807. '其他费用'
  13808. );
  13809. foreach ( $item as $value ) {
  13810. $falg = true;
  13811. foreach ( $receiptCollectList as $v ) {
  13812. if ($v ['itemCategory'] == '差旅相关费用') {
  13813. if ($v ['item'] == $value) {
  13814. $psum += $v ['price'];
  13815. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13816. $falg = false;
  13817. break;
  13818. }
  13819. }
  13820. }
  13821. if ($falg)
  13822. $html .= '<td class="taR">-</td>';
  13823. }
  13824. if (! empty ( $psum ))
  13825. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13826. else
  13827. $psum = '<td class="colGreen taR">-</td>';
  13828. $receiptL ['差旅相关费用'] = $psum . $html;
  13829. /* ------------------------------------- */
  13830. $html = "";
  13831. $psum = 0;
  13832. $item = array (
  13833. '场租费',
  13834. '薪酬',
  13835. '住宿费',
  13836. '交通费',
  13837. '餐饮费',
  13838. '办公费',
  13839. '公关费',
  13840. '其他',
  13841. '电话费',
  13842. '邮寄费'
  13843. );
  13844. foreach ( $item as $value ) {
  13845. $falg = true;
  13846. foreach ( $receiptCollectList as $v ) {
  13847. if ($v ['itemCategory'] == '培训班费用') {
  13848. if ($v ['item'] == $value) {
  13849. $psum += $v ['price'];
  13850. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13851. $falg = false;
  13852. break;
  13853. }
  13854. }
  13855. }
  13856. if ($falg)
  13857. $html .= '<td class="taR">-</td>';
  13858. }
  13859. if (! empty ( $psum ))
  13860. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13861. else
  13862. $psum = '<td class="colGreen taR">-</td>';
  13863. $receiptL ['培训班费用'] = $psum . $html;
  13864. /* ------------------------------------- */
  13865. $html = "";
  13866. $psum = 0;
  13867. $item = array (
  13868. '公关费',
  13869. '广告费',
  13870. '借款',
  13871. '可自加费用'
  13872. );
  13873. foreach ( $item as $value ) {
  13874. $falg = true;
  13875. foreach ( $receiptCollectList as $v ) {
  13876. if ($v ['itemCategory'] == '其他') {
  13877. if ($v ['item'] == $value) {
  13878. $psum += $v ['price'];
  13879. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  13880. $falg = false;
  13881. break;
  13882. }
  13883. }
  13884. }
  13885. if ($falg)
  13886. $html .= '<td class="taR">-</td>';
  13887. }
  13888. if (! empty ( $psum ))
  13889. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  13890. else
  13891. $psum = '<td class="colGreen taR">-</td>';
  13892. $receiptL ['其他'] = $psum . $html;
  13893. /* ------------------------------------- */
  13894. $html = "";
  13895. $psum = 0;
  13896. foreach ( $receiptCollectList as $v ) {
  13897. if ($v ['itemCategory'] == '报销金额调整') {
  13898. if (! empty ( $v ['price'] ))
  13899. $psum += $v ['price'];
  13900. }
  13901. }
  13902. if (! empty ( $psum ))
  13903. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  13904. else
  13905. $psum = '<td class="taR colOrange">-</td>';
  13906. $receiptL ['报销金额调整'] = $psum . $html;
  13907. } else {
  13908. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  13909. <td class="taR">-</td>
  13910. <td class="taR">-</td>
  13911. <td class="taR">-</td>
  13912. <td class="taR">-</td>
  13913. <td class="taR">-</td>
  13914. <td class="taR">-</td>
  13915. <td class="taR">-</td>
  13916. <td class="taR">-</td>
  13917. <td class="taR">-</td>
  13918. <td class="taR">-</td>
  13919. <td class="taR">-</td>
  13920. <td class="taR">-</td>';
  13921. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  13922. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13923. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  13924. <td class="taR">-</td>
  13925. <td class="taR">-</td>
  13926. <td class="taR">-</td>
  13927. <td class="taR">-</td>
  13928. <td class="taR">-</td>
  13929. <td class="taR">-</td>
  13930. <td class="taR">-</td>
  13931. <td class="taR">-</td>';
  13932. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  13933. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  13934. }
  13935. return $receiptL;
  13936. }
  13937. function eMail() {
  13938. Doo::loadModel ( 'staff' );
  13939. $staff = new staff ();
  13940. Doo::loadModel ( 'receipt' );
  13941. $receipt = new receipt ();
  13942. Doo::loadModel ( 'L_category' );
  13943. $Lcategory = new L_category ();
  13944. Doo::loadModel ( "verify" );
  13945. $verify = new verify ();
  13946. $staffList = $staff->find ( array (
  13947. 'asArray' => true
  13948. ) );
  13949. foreach ( $staffList as $key => $value ) {
  13950. if ($value ['username'] != 'admin') {
  13951. // 提交人
  13952. $receiptList = $receipt->find ( array (
  13953. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  13954. 'asArray' => true
  13955. ) );
  13956. if (! empty ( $receiptList )) {
  13957. $html = '<br><div><style></style>
  13958. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  13959. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  13960. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  13961. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  13962. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  13963. <tbody><tr>
  13964. <td style="padding: 0 40px;" align="left">
  13965. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  13966. </td></tr><tr>
  13967. <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>
  13968. </tr>
  13969. </tbody> </table></td> </tr> <tr><td>
  13970. <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">
  13971. <tbody> <tr><td>
  13972. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  13973. 以下报销单完成了审批,等着收款吧:</p>
  13974. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  13975. foreach ( $receiptList as $k => $v ) {
  13976. $category = $Lcategory->getOne ( array (
  13977. 'where' => 'cid=' . $v ['cid'],
  13978. 'asArray' => true
  13979. ) );
  13980. $html .= '
  13981. <tr>
  13982. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  13983. <td align="left">
  13984. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  13985. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  13986. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  13987. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  13988. </tr>';
  13989. }
  13990. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  13991. <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>
  13992. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  13993. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  13994. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  13995. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13996. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  13997. $receipt = new receipt ();
  13998. $receipt->notice = 1;
  13999. $receipt->update ( array (
  14000. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  14001. ) );
  14002. }
  14003. }
  14004. // 审批人
  14005. $verifyList = $verify->find ( array (
  14006. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  14007. 'asArray' => true
  14008. ) );
  14009. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  14010. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  14011. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  14012. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  14013. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  14014. <tbody><tr><td style="padding: 0 40px;" align="left">
  14015. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  14016. </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>
  14017. </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">
  14018. <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>
  14019. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  14020. foreach ( $verifyList as $k => $v ) {
  14021. $receiptList = $receipt->find ( array (
  14022. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  14023. 'asArray' => true
  14024. ) );
  14025. foreach ( $receiptList as $r => $l ) {
  14026. $category = $Lcategory->getOne ( array (
  14027. 'where' => 'cid=' . $l ['cid'],
  14028. 'asArray' => true
  14029. ) );
  14030. $staffDetile = $staff->getOne ( array (
  14031. 'where' => 'sid=' . $l ['staff'],
  14032. 'asArray' => true
  14033. ) );
  14034. $html .= '
  14035. <tr>
  14036. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  14037. <td align="left">
  14038. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  14039. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  14040. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  14041. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  14042. </tr>';
  14043. }
  14044. }
  14045. $html .= '
  14046. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  14047. <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>
  14048. </tr></tbody></table></td></tr></tbody></table></div><br>';
  14049. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  14050. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  14051. // $receipt=new receipt();
  14052. // $receipt->notice=1;
  14053. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  14054. }
  14055. }
  14056. }
  14057. }
  14058. function setWXMsg($rid, $type) {
  14059. Doo::loadModel ( "receipt" );
  14060. $receipt = new receipt ();
  14061. $receiptDetail = $receipt->getOne ( array (
  14062. 'where' => 'rid=' . $rid,
  14063. 'asArray' => true
  14064. ) );
  14065. if (! empty ( $receiptDetail )) {
  14066. Doo::loadModel ( 'staff' );
  14067. $staff = new staff ();
  14068. $staffmsg = $staff->getOne ( array (
  14069. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  14070. 'asArray' => TRUE
  14071. ) );
  14072. if (! empty ( $staffmsg ['wxid'] )) {
  14073. require_once (SITE_PATH . '/protected/class/client.php');
  14074. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  14075. $user = $staffmsg ['wxid'];
  14076. $receiptName = '';
  14077. $msg = '';
  14078. switch ($receiptDetail ['Rtype']) {
  14079. case 0 :
  14080. $receiptName = '报销';
  14081. break;
  14082. case 1 :
  14083. $receiptName = '借款';
  14084. break;
  14085. case 2 :
  14086. $receiptName = '对公汇款';
  14087. break;
  14088. }
  14089. switch ($type) {
  14090. case 1 :
  14091. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  14092. break;
  14093. case 2 :
  14094. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  14095. break;
  14096. case 3 :
  14097. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  14098. break;
  14099. }
  14100. // $result = $client->SendMsg ( $user, $msg, 'text' );
  14101. }
  14102. }
  14103. }
  14104. // Email发送函数
  14105. function SMail($toemail, $subject, $contents) {
  14106. Doo::loadClass ( 'class.phpmailer' );
  14107. $mail = new PHPMailer ();
  14108. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  14109. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  14110. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  14111. $mail->Password = "cDO1GjtY1seH"; // 密码
  14112. $mail->CharSet = "UTF8";
  14113. $mail->SMTPAuth = true;
  14114. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  14115. $mail->Mailer = "smtp";
  14116. $mail->Port = 25;
  14117. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  14118. $mail->MsgHTML ( $contents );
  14119. $mail->AddAddress ( $toemail );
  14120. $mail->CharSet = "UTF-8";
  14121. return $mail->Send ();
  14122. }
  14123. function h5Upload() {
  14124. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14125. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14126. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14127. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14128. header ( "HTTP/1.1 500 Internal Server Error" );
  14129. echo "POST exceeded maximum allowed size.";
  14130. exit ( 0 );
  14131. }
  14132. // Settings
  14133. $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)
  14134. $upload_name = "Filedata";
  14135. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14136. $extension_whitelist = array (
  14137. "doc",
  14138. "txt",
  14139. "jpg",
  14140. "gif",
  14141. "png"
  14142. ); // Allowed file extensions
  14143. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14144. // Other variables
  14145. $MAX_FILENAME_LENGTH = 260;
  14146. $file_name = "";
  14147. $file_extension = "";
  14148. $uploadErrors = array (
  14149. 0 => "文件上传成功",
  14150. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14151. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14152. 3 => "上传的文件仅为部分文件",
  14153. 4 => "没有文件上传",
  14154. 6 => "缺少临时文件夹"
  14155. );
  14156. $nk = time ();
  14157. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14158. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14159. echo "文件无法保存.";
  14160. exit ( 0 );
  14161. }
  14162. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14163. echo json_encode ( array (
  14164. 'filename' => $file_name,
  14165. 'id' => $nk
  14166. ) );
  14167. exit ( 0 );
  14168. }
  14169. function swfupload() {
  14170. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  14171. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  14172. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  14173. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  14174. header ( "HTTP/1.1 500 Internal Server Error" );
  14175. echo "POST exceeded maximum allowed size.";
  14176. exit ( 0 );
  14177. }
  14178. // Settings
  14179. $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)
  14180. $upload_name = "Filedata";
  14181. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  14182. $extension_whitelist = array (
  14183. "doc",
  14184. "txt",
  14185. "jpg",
  14186. "gif",
  14187. "png"
  14188. ); // Allowed file extensions
  14189. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  14190. // Other variables
  14191. $MAX_FILENAME_LENGTH = 260;
  14192. $file_name = "";
  14193. $file_extension = "";
  14194. $uploadErrors = array (
  14195. 0 => "文件上传成功",
  14196. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  14197. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  14198. 3 => "上传的文件仅为部分文件",
  14199. 4 => "没有文件上传",
  14200. 6 => "缺少临时文件夹"
  14201. );
  14202. $nk = time ();
  14203. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  14204. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  14205. echo "文件无法保存.";
  14206. exit ( 0 );
  14207. }
  14208. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  14209. echo json_encode ( array (
  14210. 'filename' => $file_name,
  14211. 'id' => $nk
  14212. ) );
  14213. exit ( 0 );
  14214. }
  14215. function _GetFileEXT($filename) {
  14216. $pics = explode ( '.', $filename );
  14217. $num = count ( $pics );
  14218. return $pics [$num - 1];
  14219. }
  14220. /**
  14221. * 获取get或者POST值
  14222. * @param string $name 属性名称
  14223. * @return fixed 值
  14224. */
  14225. function get_args($name) {
  14226. if (isset ( $_GET [$name] )) {
  14227. if (is_array ( $_GET [$name] ))
  14228. return $_GET [$name];
  14229. else
  14230. return addslashes ( $_GET [$name] );
  14231. } elseif (isset ( $_POST [$name] )) {
  14232. if (is_array ( $_POST [$name] ))
  14233. return $_POST [$name];
  14234. else
  14235. return addslashes ( $_POST [$name] );
  14236. } else
  14237. return false;
  14238. }
  14239. function num_to_rmb($num) {
  14240. $c1 = "零壹贰叁肆伍陆柒捌玖";
  14241. $c2 = "分角元拾佰仟万拾佰仟亿";
  14242. // 精确到分后面就不要了,所以只留两个小数位
  14243. $num = round ( $num, 2 );
  14244. // 将数字转化为整数
  14245. $num = $num * 100;
  14246. if (strlen ( $num ) > 10) {
  14247. return "金额太大,请检查";
  14248. }
  14249. $i = 0;
  14250. $c = "";
  14251. while ( 1 ) {
  14252. if ($i == 0) {
  14253. // 获取最后一位数字
  14254. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  14255. } else {
  14256. $n = $num % 10;
  14257. }
  14258. // 每次将最后一位数字转化为中文
  14259. $p1 = substr ( $c1, 3 * $n, 3 );
  14260. $p2 = substr ( $c2, 3 * $i, 3 );
  14261. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  14262. $c = $p1 . $p2 . $c;
  14263. } else {
  14264. $c = $p1 . $c;
  14265. }
  14266. $i = $i + 1;
  14267. // 去掉数字最后一位了
  14268. $num = $num / 10;
  14269. // echo $num.'</br>';
  14270. $num = ( int ) $num;
  14271. // $num =floor($num);
  14272. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  14273. // echo $num.'</br>';
  14274. // 结束循环
  14275. if ($num == 0) {
  14276. break;
  14277. }
  14278. }
  14279. // echo $c.'</br>';
  14280. $j = 0;
  14281. $slen = strlen ( $c );
  14282. while ( $j < $slen ) {
  14283. // utf8一个汉字相当3个字符
  14284. $m = substr ( $c, $j, 6 );
  14285. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  14286. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  14287. $left = substr ( $c, 0, $j );
  14288. $right = substr ( $c, $j + 3 );
  14289. $c = $left . $right;
  14290. $j = $j - 3;
  14291. $slen = $slen - 3;
  14292. }
  14293. $j = $j + 3;
  14294. }
  14295. // 这个是为了去掉类似23.0中最后一个“零”字
  14296. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  14297. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  14298. }
  14299. // 将处理的汉字加上“整”
  14300. if (empty ( $c )) {
  14301. return "零元整";
  14302. } else {
  14303. return $c . "整";
  14304. }
  14305. }
  14306. /**
  14307. * 获得分页数据
  14308. * @param unknown_type $table
  14309. * @param unknown_type $condition
  14310. * @param unknown_type $on_page
  14311. * @param unknown_type $page_size
  14312. */
  14313. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  14314. $page_c = "";
  14315. $page ['previous'] = $this->get_previous ( $on_page );
  14316. $page ['on_page'] = $on_page;
  14317. $total_count = $this->get_table_count ( $table, $condition );
  14318. $total = intval ( $total_count / $page_size );
  14319. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  14320. $page ['total_data'] = $total_count;
  14321. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  14322. $i = 1;
  14323. $page_max = 1;
  14324. $page_width = 3;
  14325. if ($on_page >= $page_width) {
  14326. $page_max = intval ( $on_page / $page_width ) + 1;
  14327. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  14328. }
  14329. for(; $i <= $page ['total_page']; $i ++) {
  14330. if ($i == $on_page)
  14331. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  14332. else
  14333. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  14334. if ($i == ($page_width * $page_max))
  14335. break;
  14336. }
  14337. $page ['page'] = $page_c;
  14338. $page ['lower'] = (-- $on_page) * $page_size;
  14339. return $page;
  14340. }
  14341. /**
  14342. * 获取总页数
  14343. * @param unknown_type $table
  14344. * @param unknown_type $condition
  14345. */
  14346. public function get_table_count($table = "", $condition = "") {
  14347. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14348. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  14349. // echo $sql;die;
  14350. $query = Doo::db ()->query ( $sql );
  14351. $result = $query->fetch ();
  14352. return $result ['count'];
  14353. }
  14354. /**
  14355. * 获取上一页
  14356. * @param unknown_type $on_page
  14357. */
  14358. function get_previous($on_page = 1) {
  14359. return $on_page != 0 ? $on_page - 1 : $on_page;
  14360. }
  14361. }
  14362. ?>